Bug 706179 Part 2: Add a BaseTransform to layers to return the layer's transform without scaling applied r=roc

This commit is contained in:
David Zbarsky 2012-07-25 01:48:10 -07:00
parent e14b114016
commit d29cc0cf63
12 changed files with 30 additions and 22 deletions

View File

@ -601,6 +601,14 @@ Layer::CalculateScissorRect(const nsIntRect& aCurrentScissorRect,
return currentClip.Intersect(scissor);
}
const gfx3DMatrix
Layer::GetTransform()
{
gfx3DMatrix transform = mTransform;
transform.Scale(mXScale, mYScale, 1);
return transform;
}
const gfx3DMatrix
Layer::GetLocalTransform()
{

View File

@ -716,7 +716,7 @@ public:
* XXX Currently only transformations corresponding to 2D affine transforms
* are supported.
*/
void SetTransform(const gfx3DMatrix& aMatrix)
void SetBaseTransform(const gfx3DMatrix& aMatrix)
{
mTransform = aMatrix;
Mutated();
@ -764,7 +764,8 @@ public:
Layer* GetPrevSibling() { return mPrevSibling; }
virtual Layer* GetFirstChild() { return nsnull; }
virtual Layer* GetLastChild() { return nsnull; }
const gfx3DMatrix& GetTransform() { return mTransform; }
const gfx3DMatrix GetTransform();
const gfx3DMatrix& GetBaseTransform() { return mTransform; }
float GetXScale() { return mXScale; }
float GetYScale() { return mYScale; }
bool GetIsFixedPosition() { return mIsFixedPosition; }

View File

@ -526,7 +526,7 @@ SetShadowProperties(Layer* aLayer)
{
// FIXME: Bug 717688 -- Do these updates in ShadowLayersParent::RecvUpdate.
ShadowLayer* shadow = aLayer->AsShadowLayer();
shadow->SetShadowTransform(aLayer->GetTransform());
shadow->SetShadowTransform(aLayer->GetBaseTransform());
shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion());
shadow->SetShadowClipRect(aLayer->GetClipRect());
shadow->SetShadowOpacity(aLayer->GetOpacity());
@ -696,7 +696,7 @@ CompositorParent::TransformShadowTree(TimeStamp aCurrentFrame)
const FrameMetrics& metrics = container->GetFrameMetrics();
const gfx3DMatrix& rootTransform = root->GetTransform();
const gfx3DMatrix& currentTransform = layer->GetTransform();
const gfx3DMatrix& currentTransform = layer->GetBaseTransform();
// FIXME/bug 775437: unify this interface with the ~native-fennec
// derived code

View File

@ -299,7 +299,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies)
LayerAttributes attrs;
CommonLayerAttributes& common = attrs.common();
common.visibleRegion() = mutant->GetVisibleRegion();
common.transform() = mutant->GetTransform();
common.transform() = mutant->GetBaseTransform();
common.xScale() = mutant->GetXScale();
common.yScale() = mutant->GetYScale();
common.contentFlags() = mutant->GetContentFlags();

View File

@ -216,7 +216,7 @@ ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
layer->SetContentFlags(common.contentFlags());
layer->SetOpacity(common.opacity().value());
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
layer->SetTransform(common.transform().value());
layer->SetBaseTransform(common.transform().value());
layer->SetScale(common.xScale(), common.yScale());
static bool fixedPositionLayersEnabled = getenv("MOZ_ENABLE_FIXED_POSITION_LAYERS") != 0;
if (fixedPositionLayersEnabled) {

View File

@ -1114,7 +1114,7 @@ ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
RoundToMatchResidual(scaledOffset.y, data->mActiveScrolledRootPosition.y));
gfxMatrix matrix;
matrix.Translate(gfxPoint(pixOffset.x, pixOffset.y));
layer->SetTransform(gfx3DMatrix::From2D(matrix));
layer->SetBaseTransform(gfx3DMatrix::From2D(matrix));
// FIXME: Temporary workaround for bug 681192 and bug 724786.
#ifndef MOZ_JAVA_COMPOSITOR
@ -1267,9 +1267,7 @@ ContainerState::PopThebesLayerData()
imageLayer->SetContainer(imageContainer);
data->mImage->ConfigureLayer(imageLayer);
// The layer's current transform is applied first, then the result is scaled.
gfx3DMatrix transform = imageLayer->GetTransform()*
gfx3DMatrix::ScalingMatrix(mParameters.mXScale, mParameters.mYScale, 1.0f);
imageLayer->SetTransform(transform);
imageLayer->SetScale(mParameters.mXScale, mParameters.mYScale);
if (data->mItemClip.mHaveClipRect) {
nsIntRect clip = ScaleToNearestPixels(data->mItemClip.mClipRect);
imageLayer->IntersectClipRect(clip);
@ -1281,7 +1279,8 @@ ContainerState::PopThebesLayerData()
colorLayer->SetColor(data->mSolidColor);
// Copy transform
colorLayer->SetTransform(data->mLayer->GetTransform());
colorLayer->SetBaseTransform(data->mLayer->GetTransform());
colorLayer->SetScale(data->mLayer->GetXScale(), data->mLayer->GetYScale());
// Clip colorLayer to its visible region, since ColorLayers are
// allowed to paint outside the visible region. Here we rely on the
@ -1780,7 +1779,7 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList,
// The layer's current transform is applied first, then the result is scaled.
gfx3DMatrix transform = ownLayer->GetTransform()*
gfx3DMatrix::ScalingMatrix(mParameters.mXScale, mParameters.mYScale, 1.0f);
ownLayer->SetTransform(transform);
ownLayer->SetBaseTransform(transform);
}
ownLayer->SetIsFixedPosition(
@ -2124,7 +2123,7 @@ ChooseScaleAndSetTransform(FrameLayerBuilder* aLayerBuilder,
scale = gfxSize(1.0, 1.0);
}
aLayer->SetTransform(transform);
aLayer->SetBaseTransform(transform);
// Store the inverse of our resolution-scale on the layer
aLayer->SetScale(1.0f/float(scale.width), 1.0f/float(scale.height));
@ -3132,7 +3131,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const FrameLayerBuilder::Clip& aCl
}
maskLayer->SetContainer(container);
maskLayer->SetTransform(gfx3DMatrix::From2D(maskTransform.Invert()));
maskLayer->SetBaseTransform(gfx3DMatrix::From2D(maskTransform.Invert()));
// save the details of the clip in user data
userData->mScaleX = newData.mScaleX;

View File

@ -988,10 +988,10 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
return;
}
// Root is being scaled up by the X/Y resolution. Scale it back down.
gfx3DMatrix rootTransform = root->GetTransform()*
gfx3DMatrix rootTransform = root->GetBaseTransform()*
gfx3DMatrix::ScalingMatrix(1.0f/containerParameters.mXScale,
1.0f/containerParameters.mYScale, 1.0f);
root->SetTransform(rootTransform);
root->SetBaseTransform(rootTransform);
ViewID id = presContext->IsRootContentDocument() ? FrameMetrics::ROOT_SCROLL_ID
: FrameMetrics::NULL_SCROLL_ID;
@ -1650,7 +1650,7 @@ nsDisplayBackground::ConfigureLayer(ImageLayer* aLayer)
transform.Translate(mDestRect.TopLeft());
transform.Scale(mDestRect.width/imageSize.width,
mDestRect.height/imageSize.height);
aLayer->SetTransform(gfx3DMatrix::From2D(transform));
aLayer->SetBaseTransform(gfx3DMatrix::From2D(transform));
aLayer->SetVisibleRegion(nsIntRect(0, 0, imageSize.width, imageSize.height));
}

View File

@ -278,7 +278,7 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
gfxMatrix transform;
transform.Translate(r.TopLeft());
transform.Scale(r.Width()/canvasSize.width, r.Height()/canvasSize.height);
layer->SetTransform(gfx3DMatrix::From2D(transform));
layer->SetBaseTransform(gfx3DMatrix::From2D(transform));
layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));
layer->SetVisibleRegion(nsIntRect(0, 0, canvasSize.width, canvasSize.height));

View File

@ -1289,7 +1289,7 @@ nsDisplayImage::ConfigureLayer(ImageLayer *aLayer)
transform.Translate(destRect.TopLeft());
transform.Scale(destRect.Width()/imageWidth,
destRect.Height()/imageHeight);
aLayer->SetTransform(gfx3DMatrix::From2D(transform));
aLayer->SetBaseTransform(gfx3DMatrix::From2D(transform));
aLayer->SetVisibleRegion(nsIntRect(0, 0, imageWidth, imageHeight));
}

View File

@ -1723,7 +1723,7 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
gfxMatrix transform;
transform.Translate(r.TopLeft());
layer->SetTransform(gfx3DMatrix::From2D(transform));
layer->SetBaseTransform(gfx3DMatrix::From2D(transform));
layer->SetVisibleRegion(nsIntRect(0, 0, size.width, size.height));
return layer.forget();
}

View File

@ -206,7 +206,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
gfxMatrix transform;
transform.Translate(r.TopLeft());
transform.Scale(r.Width()/frameSize.width, r.Height()/frameSize.height);
layer->SetTransform(gfx3DMatrix::From2D(transform));
layer->SetBaseTransform(gfx3DMatrix::From2D(transform));
layer->SetVisibleRegion(nsIntRect(0, 0, frameSize.width, frameSize.height));
nsRefPtr<Layer> result = layer.forget();
return result.forget();

View File

@ -605,7 +605,7 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
layer->SetReferentId(id);
layer->SetVisibleRegion(aVisibleRect);
nsIntPoint rootFrameOffset = GetRootFrameOffset(aFrame, aBuilder);
layer->SetTransform(
layer->SetBaseTransform(
gfx3DMatrix::Translation(rootFrameOffset.x, rootFrameOffset.y, 0.0));
return layer.forget();