Bug 1040906 - Replace the out-param on matrix conversion helpers with a return value. r=Bas

This commit is contained in:
Kartikaya Gupta 2014-07-22 09:12:14 -04:00
parent 50cb796d79
commit 2c6bc3f45f
17 changed files with 78 additions and 123 deletions

View File

@ -80,10 +80,8 @@ static LayerSortOrder CompareDepth(Layer* aOne, Layer* aTwo) {
gfxRect ourRect = aOne->GetEffectiveVisibleRegion().GetBounds();
gfxRect otherRect = aTwo->GetEffectiveVisibleRegion().GetBounds();
gfx3DMatrix ourTransform;
To3DMatrix(aOne->GetTransform(), ourTransform);
gfx3DMatrix otherTransform;
To3DMatrix(aTwo->GetTransform(), otherTransform);
gfx3DMatrix ourTransform = To3DMatrix(aOne->GetTransform());
gfx3DMatrix otherTransform = To3DMatrix(aTwo->GetTransform());
// Transform both rectangles and project into 2d space.
gfxQuad ourTransformedRect = ourTransform.TransformRect(ourRect);

View File

@ -114,7 +114,7 @@ struct LayerPropertiesBase : public LayerProperties
if (mUseClipRect) {
mClipRect = *aLayer->GetClipRect();
}
gfx::To3DMatrix(aLayer->GetTransform(), mTransform);
mTransform = gfx::To3DMatrix(aLayer->GetTransform());
}
LayerPropertiesBase()
: mLayer(nullptr)
@ -136,8 +136,7 @@ struct LayerPropertiesBase : public LayerProperties
nsIntRegion ComputeChange(NotifySubDocInvalidationFunc aCallback,
bool& aGeometryChanged)
{
gfx3DMatrix transform;
gfx::To3DMatrix(mLayer->GetTransform(), transform);
gfx3DMatrix transform = gfx::To3DMatrix(mLayer->GetTransform());
bool transformChanged = !mTransform.FuzzyEqual(transform) ||
mLayer->GetPostXScale() != mPostXScale ||
mLayer->GetPostYScale() != mPostYScale;
@ -185,9 +184,8 @@ struct LayerPropertiesBase : public LayerProperties
nsIntRect NewTransformedBounds()
{
gfx3DMatrix transform;
gfx::To3DMatrix(mLayer->GetTransform(), transform);
return TransformRect(mLayer->GetVisibleRegion().GetBounds(), transform);
return TransformRect(mLayer->GetVisibleRegion().GetBounds(),
gfx::To3DMatrix(mLayer->GetTransform()));
}
nsIntRect OldTransformedBounds()
@ -294,9 +292,8 @@ struct ContainerLayerProperties : public LayerPropertiesBase
}
if (invalidateChildsCurrentArea) {
aGeometryChanged = true;
gfx3DMatrix transform;
gfx::To3DMatrix(child->GetTransform(), transform);
AddTransformedRegion(result, child->GetVisibleRegion(), transform);
AddTransformedRegion(result, child->GetVisibleRegion(),
gfx::To3DMatrix(child->GetTransform()));
if (aCallback) {
NotifySubdocumentInvalidationRecursive(child, aCallback);
} else {
@ -315,9 +312,7 @@ struct ContainerLayerProperties : public LayerPropertiesBase
aCallback(container, result);
}
gfx3DMatrix transform;
gfx::To3DMatrix(mLayer->GetTransform(), transform);
result.Transform(transform);
result.Transform(gfx::To3DMatrix(mLayer->GetTransform()));
return result;
}
@ -447,8 +442,7 @@ LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFu
} else {
ClearInvalidations(aRoot);
}
gfx3DMatrix transform;
gfx::To3DMatrix(aRoot->GetTransform(), transform);
gfx3DMatrix transform = gfx::To3DMatrix(aRoot->GetTransform());
nsIntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(), transform);
result = result.Union(OldTransformedBounds());
if (aGeometryChanged != nullptr) {

View File

@ -244,8 +244,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
* metrics.mDevPixelsPerCSSPixel
* metrics.GetParentResolution());
}
gfx3DMatrix transform;
gfx::To3DMatrix(aLayer->GetTransform(), transform);
gfx3DMatrix transform = gfx::To3DMatrix(aLayer->GetTransform());
apzc->SetLayerHitTestData(visible, aTransform, transform);
APZCTM_LOG("Setting rect(%f %f %f %f) as visible region for APZC %p\n", visible.x, visible.y,
@ -312,9 +311,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
aTransform = gfx3DMatrix();
} else {
// Multiply child layer transforms on the left so they get applied first
gfx3DMatrix matrix;
gfx::To3DMatrix(aLayer->GetTransform(), matrix);
aTransform = matrix * aTransform;
aTransform = gfx::To3DMatrix(aLayer->GetTransform()) * aTransform;
}
uint64_t childLayersId = (aLayer->AsRefLayer() ? aLayer->AsRefLayer()->GetReferentId() : aLayersId);

View File

@ -262,7 +262,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect,
dest->SetTransform(destTransform);
// Get the bounds post-transform.
To3DMatrix(aTransform, new3DTransform);
new3DTransform = To3DMatrix(aTransform);
gfxRect bounds = new3DTransform.TransformBounds(ThebesRect(aRect));
bounds.IntersectRect(bounds, gfxRect(offset.x, offset.y, buffer->GetSize().width, buffer->GetSize().height));

View File

@ -897,8 +897,7 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
temp->Paint();
}
#endif
gfx3DMatrix effectiveTransform;
gfx::To3DMatrix(aLayer->GetEffectiveTransform(), effectiveTransform);
gfx3DMatrix effectiveTransform = gfx::To3DMatrix(aLayer->GetEffectiveTransform());
nsRefPtr<gfxASurface> result =
Transform3D(untransformedDT->Snapshot(), aTarget, bounds,
effectiveTransform, destRect);

View File

@ -77,9 +77,7 @@ GetTransformToAncestorsParentLayer(Layer* aStart, Layer* aAncestor)
}
transform = transform * iter->GetTransform();
}
gfx3DMatrix ret;
gfx::To3DMatrix(transform, ret);
return ret;
return gfx::To3DMatrix(transform);
}
void

View File

@ -1081,8 +1081,7 @@ GetCompositorSideCompositionBounds(ContainerLayer* aScrollAncestor,
aScrollAncestor->GetFrameMetrics().mResolution.scale,
1.f);
gfx3DMatrix layerTransform;
gfx::To3DMatrix(aScrollAncestor->GetTransform(), layerTransform);
gfx3DMatrix layerTransform = gfx::To3DMatrix(aScrollAncestor->GetTransform());
// First take off the last two "terms" of aTransformToCompBounds, which
// are the scroll ancestor's local transform and the APZ's nontransient async

View File

@ -405,9 +405,7 @@ SampleValue(float aPortion, Animation& aAnimation, StyleAnimationValue& aStart,
transform.Translate(scaledOrigin);
InfallibleTArray<TransformFunction> functions;
Matrix4x4 realTransform;
ToMatrix4x4(transform, realTransform);
functions.AppendElement(TransformMatrix(realTransform));
functions.AppendElement(TransformMatrix(ToMatrix4x4(transform)));
*aValue = functions;
}
@ -513,10 +511,7 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
Matrix4x4
CombineWithCSSTransform(const gfx3DMatrix& treeTransform, Layer* aLayer)
{
Matrix4x4 result;
ToMatrix4x4(treeTransform, result);
result = result * aLayer->GetTransform();
return result;
return ToMatrix4x4(treeTransform) * aLayer->GetTransform();
}
bool
@ -701,9 +696,7 @@ ApplyAsyncTransformToScrollbarForContent(TimeStamp aCurrentFrame, ContainerLayer
// the content. This is needed because otherwise that transient async transform is
// part of the effective transform of this scrollbar, and the scrollbar will jitter
// as the content scrolls.
Matrix4x4 targetUntransform;
ToMatrix4x4(transientTransform.Inverse(), targetUntransform);
transform = transform * targetUntransform;
transform = transform * ToMatrix4x4(transientTransform.Inverse());
}
// GetTransform already takes the pre- and post-scale into account. Since we
@ -771,8 +764,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer)
const FrameMetrics& metrics = container->GetFrameMetrics();
// We must apply the resolution scale before a pan/zoom transform, so we call
// GetTransform here.
gfx3DMatrix currentTransform;
To3DMatrix(aLayer->GetTransform(), currentTransform);
gfx3DMatrix currentTransform = To3DMatrix(aLayer->GetTransform());
Matrix4x4 oldTransform = aLayer->GetTransform();
gfx3DMatrix treeTransform;
@ -849,9 +841,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer)
computedTransform.ScalePost(1.0f/container->GetPostXScale(),
1.0f/container->GetPostYScale(),
1);
Matrix4x4 matrix;
ToMatrix4x4(computedTransform, matrix);
layerComposite->SetShadowTransform(matrix);
layerComposite->SetShadowTransform(ToMatrix4x4(computedTransform));
NS_ASSERTION(!layerComposite->GetShadowTransformSetByAnimation(),
"overwriting animated transform!");

View File

@ -587,7 +587,7 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
// Accumulate the transform of intermediate surfaces
gfx3DMatrix transform = aTransform;
if (container->UseIntermediateSurface()) {
gfx::To3DMatrix(aLayer->GetEffectiveTransform(), transform);
transform = gfx::To3DMatrix(aLayer->GetEffectiveTransform());
transform.PreMultiply(aTransform);
}
for (Layer* child = aLayer->GetFirstChild(); child;
@ -609,8 +609,7 @@ LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer,
if (!incompleteRegion.IsEmpty()) {
// Calculate the transform to get between screen and layer space
gfx3DMatrix transformToScreen;
To3DMatrix(aLayer->GetEffectiveTransform(), transformToScreen);
gfx3DMatrix transformToScreen = To3DMatrix(aLayer->GetEffectiveTransform());
transformToScreen.PreMultiply(aTransform);
SubtractTransformedRegion(aScreenRegion, incompleteRegion, transformToScreen);
@ -689,8 +688,7 @@ LayerManagerComposite::ComputeRenderIntegrity()
// This is derived from the code in
// AsyncCompositionManager::TransformScrollableLayer
const FrameMetrics& metrics = primaryScrollable->AsContainerLayer()->GetFrameMetrics();
gfx3DMatrix transform;
gfx::To3DMatrix(primaryScrollable->GetEffectiveTransform(), transform);
gfx3DMatrix transform = gfx::To3DMatrix(primaryScrollable->GetEffectiveTransform());
transform.ScalePost(metrics.mResolution.scale, metrics.mResolution.scale, 1);
// Clip the screen rect to the document bounds

View File

@ -629,8 +629,7 @@ LayerTransactionParent::RecvGetAnimationTransform(PLayerParent* aParent,
// from the shadow transform by undoing the translations in
// AsyncCompositionManager::SampleValue.
gfx3DMatrix transform;
gfx::To3DMatrix(layer->AsLayerComposite()->GetShadowTransform(), transform);
gfx3DMatrix transform = gfx::To3DMatrix(layer->AsLayerComposite()->GetShadowTransform());
if (ContainerLayer* c = layer->AsContainerLayer()) {
// Undo the scale transform applied by AsyncCompositionManager::SampleValue
transform.ScalePost(1.0f/c->GetInheritedXScale(),

View File

@ -194,9 +194,7 @@ already_AddRefed<Layer> CreateLayerTree(
layer->SetVisibleRegion(aVisibleRegions[layerNumber]);
}
if (aTransforms) {
Matrix4x4 transform;
ToMatrix4x4(aTransforms[layerNumber], transform);
layer->SetBaseTransform(transform);
layer->SetBaseTransform(ToMatrix4x4(aTransforms[layerNumber]));
}
aLayersOut.AppendElement(layer);
layerNumber++;

View File

@ -376,46 +376,50 @@ inline gfxContext::GraphicsOperator ThebesOp(CompositionOp aOp)
}
}
inline void
ToMatrix4x4(const gfx3DMatrix& aIn, Matrix4x4& aOut)
inline Matrix4x4
ToMatrix4x4(const gfx3DMatrix& aIn)
{
aOut._11 = aIn._11;
aOut._12 = aIn._12;
aOut._13 = aIn._13;
aOut._14 = aIn._14;
aOut._21 = aIn._21;
aOut._22 = aIn._22;
aOut._23 = aIn._23;
aOut._24 = aIn._24;
aOut._31 = aIn._31;
aOut._32 = aIn._32;
aOut._33 = aIn._33;
aOut._34 = aIn._34;
aOut._41 = aIn._41;
aOut._42 = aIn._42;
aOut._43 = aIn._43;
aOut._44 = aIn._44;
Matrix4x4 m;
m._11 = aIn._11;
m._12 = aIn._12;
m._13 = aIn._13;
m._14 = aIn._14;
m._21 = aIn._21;
m._22 = aIn._22;
m._23 = aIn._23;
m._24 = aIn._24;
m._31 = aIn._31;
m._32 = aIn._32;
m._33 = aIn._33;
m._34 = aIn._34;
m._41 = aIn._41;
m._42 = aIn._42;
m._43 = aIn._43;
m._44 = aIn._44;
return m;
}
inline void
To3DMatrix(const Matrix4x4& aIn, gfx3DMatrix& aOut)
inline gfx3DMatrix
To3DMatrix(const Matrix4x4& aIn)
{
aOut._11 = aIn._11;
aOut._12 = aIn._12;
aOut._13 = aIn._13;
aOut._14 = aIn._14;
aOut._21 = aIn._21;
aOut._22 = aIn._22;
aOut._23 = aIn._23;
aOut._24 = aIn._24;
aOut._31 = aIn._31;
aOut._32 = aIn._32;
aOut._33 = aIn._33;
aOut._34 = aIn._34;
aOut._41 = aIn._41;
aOut._42 = aIn._42;
aOut._43 = aIn._43;
aOut._44 = aIn._44;
gfx3DMatrix m;
m._11 = aIn._11;
m._12 = aIn._12;
m._13 = aIn._13;
m._14 = aIn._14;
m._21 = aIn._21;
m._22 = aIn._22;
m._23 = aIn._23;
m._24 = aIn._24;
m._31 = aIn._31;
m._32 = aIn._32;
m._33 = aIn._33;
m._34 = aIn._34;
m._41 = aIn._41;
m._42 = aIn._42;
m._43 = aIn._43;
m._44 = aIn._44;
return m;
}
}

View File

@ -1711,8 +1711,7 @@ static void
SetOuterVisibleRegion(Layer* aLayer, nsIntRegion* aOuterVisibleRegion,
const nsIntRect* aLayerContentsVisibleRect = nullptr)
{
gfx3DMatrix transform;
To3DMatrix(aLayer->GetTransform(), transform);
gfx3DMatrix transform = To3DMatrix(aLayer->GetTransform());
gfxMatrix transform2D;
if (transform.Is2D(&transform2D) && !transform2D.HasNonIntegerTranslation()) {
aOuterVisibleRegion->MoveBy(-int(transform2D._31), -int(transform2D._32));
@ -3647,9 +3646,7 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
}
// Store the inverse of our resolution-scale on the layer
Matrix4x4 baseTransform;
ToMatrix4x4(transform, baseTransform);
aLayer->SetBaseTransform(baseTransform);
aLayer->SetBaseTransform(ToMatrix4x4(transform));
aLayer->SetPreScale(1.0f/float(scale.width),
1.0f/float(scale.height));
aLayer->SetInheritedScale(aIncomingScale.mXScale,

View File

@ -284,9 +284,7 @@ static void AddTransformFunctions(nsCSSValueList* aList,
aPresContext,
canStoreInRuleTree,
aBounds);
gfx::Matrix4x4 transform;
gfx::ToMatrix4x4(matrix, transform);
aFunctions.AppendElement(TransformMatrix(transform));
aFunctions.AppendElement(TransformMatrix(gfx::ToMatrix4x4(matrix)));
break;
}
case eCSSKeyword_perspective:
@ -5151,10 +5149,8 @@ bool nsDisplayTransform::UntransformVisibleRect(nsDisplayListBuilder* aBuilder,
void
nsDisplayTransform::WriteDebugInfo(nsACString& aTo)
{
gfx::Matrix4x4 transform;
gfx::ToMatrix4x4(GetTransform(), transform);
std::stringstream ss;
AppendToString(ss, transform);
AppendToString(ss, gfx::ToMatrix4x4(GetTransform()));
aTo += ss.str().c_str();
}
#endif

View File

@ -4975,9 +4975,7 @@ nsIFrame::TryUpdateTransformOnly(Layer** aLayerResult)
!gfx::FuzzyEqual(transform._12, previousTransform._12, kError)) {
return false;
}
gfx::Matrix4x4 matrix;
gfx::ToMatrix4x4(transform3d, matrix);
layer->SetBaseTransformForNextTransaction(matrix);
layer->SetBaseTransformForNextTransaction(gfx::ToMatrix4x4(transform3d));
*aLayerResult = layer;
return true;
}

View File

@ -228,9 +228,7 @@ BuildListForLayer(Layer* aLayer,
gfx3DMatrix applyTransform = ComputeShadowTreeTransform(
aSubdocFrame, aRootFrameLoader, metrics, view->GetViewConfig(),
1 / GetXScale(aTransform), 1 / GetYScale(aTransform));
gfx3DMatrix layerTransform;
To3DMatrix(aLayer->GetTransform(), layerTransform);
transform = applyTransform * layerTransform * aTransform;
transform = applyTransform * To3DMatrix(aLayer->GetTransform()) * aTransform;
// As mentioned above, bounds calculation also depends on the scale
// of this layer.
@ -249,9 +247,7 @@ BuildListForLayer(Layer* aLayer,
new (aBuilder) nsDisplayRemoteShadow(aBuilder, aSubdocFrame, bounds, scrollId));
} else {
gfx3DMatrix layerTransform;
To3DMatrix(aLayer->GetTransform(), layerTransform);
transform = layerTransform * aTransform;
transform = To3DMatrix(aLayer->GetTransform()) * aTransform;
}
for (Layer* child = aLayer->GetFirstChild(); child;
@ -276,8 +272,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
const FrameMetrics* metrics = GetFrameMetrics(aLayer);
gfx3DMatrix shadowTransform;
To3DMatrix(aLayer->GetTransform(), shadowTransform);
gfx3DMatrix shadowTransform = To3DMatrix(aLayer->GetTransform());
ViewTransform layerTransform = aTransform;
if (metrics && metrics->IsScrollable()) {
@ -285,8 +280,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
const nsContentView* view =
aFrameLoader->GetCurrentRemoteFrame()->GetContentView(scrollId);
NS_ABORT_IF_FALSE(view, "Array of views should be consistent with layer tree");
gfx3DMatrix currentTransform;
To3DMatrix(aLayer->GetTransform(), currentTransform);
gfx3DMatrix currentTransform = To3DMatrix(aLayer->GetTransform());
const ViewConfig& config = view->GetViewConfig();
// With temporary scale we should compensate translation
@ -338,9 +332,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
1.0f/aLayer->GetPostYScale(),
1);
gfx::Matrix4x4 realShadowTransform;
ToMatrix4x4(shadowTransform, realShadowTransform);
shadow->SetShadowTransform(realShadowTransform);
shadow->SetShadowTransform(gfx::ToMatrix4x4(shadowTransform));
for (Layer* child = aLayer->GetFirstChild();
child; child = child->GetNextSibling()) {
TransformShadowTree(aBuilder, aFrameLoader, aFrame, child, layerTransform,
@ -384,8 +376,7 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
return;
const FrameMetrics metrics = container->GetFrameMetrics();
const ViewID scrollId = metrics.GetScrollId();
gfx3DMatrix transform;
To3DMatrix(aLayer->GetTransform(), transform);
gfx3DMatrix transform = To3DMatrix(aLayer->GetTransform());
aXScale *= GetXScale(transform);
aYScale *= GetYScale(transform);

View File

@ -2858,8 +2858,7 @@ RectTextureImage::Draw(GLManager* aManager,
program->Activate();
program->SetProjectionMatrix(aManager->GetProjMatrix());
gfx::Matrix4x4 transform;
gfx::ToMatrix4x4(aTransform, transform);
gfx::Matrix4x4 transform = gfx::ToMatrix4x4(aTransform);
program->SetLayerTransform(transform * gfx::Matrix4x4().Translate(aLocation.x, aLocation.y, 0));
program->SetTextureTransform(gfx::Matrix4x4());
program->SetRenderOffset(nsIntPoint(0, 0));