Bug 706179 Part 2: Add a BaseTransform to layers r=roc

This commit is contained in:
David Zbarsky 2012-07-27 13:23:45 -07:00
parent 7dcf199c9c
commit 9bf8a70491
12 changed files with 37 additions and 24 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

@ -545,7 +545,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());
@ -715,7 +715,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

@ -947,6 +947,7 @@ ContainerState::CreateOrRecycleColorLayer()
// We will reapply any necessary clipping.
layer->SetClipRect(nsnull);
layer->SetMaskLayer(nsnull);
layer->SetScale(1.0f, 1.0f);
} else {
// Create a new layer
layer = mManager->CreateColorLayer();
@ -970,6 +971,7 @@ ContainerState::CreateOrRecycleImageLayer()
// We will reapply any necessary clipping.
layer->SetClipRect(nsnull);
layer->SetMaskLayer(nsnull);
layer->SetScale(1.0f, 1.0f);
} else {
// Create a new layer
layer = mManager->CreateImageLayer();
@ -987,6 +989,7 @@ ContainerState::CreateOrRecycleMaskImageLayerFor(Layer* aLayer)
nsRefPtr<ImageLayer> result = mRecycledMaskImageLayers.Get(aLayer);
if (result) {
mRecycledMaskImageLayers.Remove(aLayer);
result->SetScale(1.0f, 1.0f);
// XXX if we use clip on mask layers, null it out here
} else {
// Create a new layer
@ -1061,6 +1064,7 @@ ContainerState::CreateOrRecycleThebesLayer(nsIFrame* aActiveScrolledRoot)
// We will reapply any necessary clipping.
layer->SetClipRect(nsnull);
layer->SetMaskLayer(nsnull);
layer->SetScale(1.0f, 1.0f);
data = static_cast<ThebesDisplayItemLayerUserData*>
(layer->GetUserData(&gThebesDisplayItemLayerUserData));
@ -1114,7 +1118,8 @@ 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));
layer->SetScale(1.0f, 1.0f);
// FIXME: Temporary workaround for bug 681192 and bug 724786.
#ifndef MOZ_JAVA_COMPOSITOR
@ -1269,7 +1274,7 @@ ContainerState::PopThebesLayerData()
// 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->SetBaseTransform(transform);
if (data->mItemClip.mHaveClipRect) {
nsIntRect clip = ScaleToNearestPixels(data->mItemClip.mClipRect);
imageLayer->IntersectClipRect(clip);
@ -1280,8 +1285,9 @@ ContainerState::PopThebesLayerData()
colorLayer->SetIsFixedPosition(data->mLayer->GetIsFixedPosition());
colorLayer->SetColor(data->mSolidColor);
// Copy transform
colorLayer->SetTransform(data->mLayer->GetTransform());
// Copy transform and scale
colorLayer->SetBaseTransform(data->mLayer->GetBaseTransform());
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 +1786,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 +2130,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 +3138,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,8 @@ 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::ScalingMatrix(1.0f/containerParameters.mXScale,
1.0f/containerParameters.mYScale, 1.0f);
root->SetTransform(rootTransform);
root->SetScale(1.0f/containerParameters.mXScale,
1.0f/containerParameters.mYScale);
ViewID id = presContext->IsRootContentDocument() ? FrameMetrics::ROOT_SCROLL_ID
: FrameMetrics::NULL_SCROLL_ID;
@ -1650,7 +1648,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

@ -250,7 +250,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
const FrameMetrics* metrics = GetFrameMetrics(aLayer);
gfx3DMatrix shadowTransform = aLayer->GetTransform();
gfx3DMatrix shadowTransform = aLayer->GetBaseTransform();
ViewTransform layerTransform = aTransform;
if (metrics && metrics->IsScrollable()) {
@ -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();