author | David Zbarsky <dzbarsky@gmail.com> |
Fri, 01 Aug 2014 08:31:47 -0400 | |
changeset 197235 | 9cd72d8361cb045bc1aa98a40603eedd1458b231 |
parent 197234 | 941a77086c1a6c4e491d258d9789c2c35cdf9854 |
child 197236 | 1df59831403ab2dd073f0453a0792bfdd2ac9216 |
push id | 47079 |
push user | dzbarsky@gmail.com |
push date | Fri, 01 Aug 2014 12:31:41 +0000 |
treeherder | mozilla-inbound@d764f90842f3 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nical |
bugs | 952977 |
milestone | 34.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/gfx/layers/composite/LayerManagerComposite.cpp +++ b/gfx/layers/composite/LayerManagerComposite.cpp @@ -17,17 +17,16 @@ #include "ImageLayerComposite.h" // for ImageLayerComposite #include "Layers.h" // for Layer, ContainerLayer, etc #include "LayerScope.h" // for LayerScope Tool #include "protobuf/LayerScopePacket.pb.h" // for protobuf (LayerScope) #include "ThebesLayerComposite.h" // for ThebesLayerComposite #include "TiledLayerBuffer.h" // for TiledLayerComposer #include "Units.h" // for ScreenIntRect #include "gfx2DGlue.h" // for ToMatrix4x4 -#include "gfx3DMatrix.h" // for gfx3DMatrix #include "gfxPrefs.h" // for gfxPrefs #ifdef XP_MACOSX #include "gfxPlatformMac.h" #endif #include "gfxRect.h" // for gfxRect #include "gfxUtils.h" // for frame color util #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/RefPtr.h" // for RefPtr, TemporaryRef @@ -559,53 +558,53 @@ LayerManagerComposite::WorldTransformRec gfx::Rect grect(aRect.x, aRect.y, aRect.width, aRect.height); grect = mWorldMatrix.TransformBounds(grect); aRect.SetRect(grect.X(), grect.Y(), grect.Width(), grect.Height()); } static void SubtractTransformedRegion(nsIntRegion& aRegion, const nsIntRegion& aRegionToSubtract, - const gfx3DMatrix& aTransform) + const Matrix4x4& aTransform) { if (aRegionToSubtract.IsEmpty()) { return; } // For each rect in the region, find out its bounds in screen space and // subtract it from the screen region. nsIntRegionRectIterator it(aRegionToSubtract); while (const nsIntRect* rect = it.Next()) { - gfxRect incompleteRect = aTransform.TransformBounds(gfxRect(*rect)); + Rect incompleteRect = aTransform.TransformBounds(ToRect(*rect)); aRegion.Sub(aRegion, nsIntRect(incompleteRect.x, incompleteRect.y, incompleteRect.width, incompleteRect.height)); } } /* static */ void LayerManagerComposite::ComputeRenderIntegrityInternal(Layer* aLayer, nsIntRegion& aScreenRegion, nsIntRegion& aLowPrecisionScreenRegion, - const gfx3DMatrix& aTransform) + const Matrix4x4& aTransform) { if (aLayer->GetOpacity() <= 0.f || (aScreenRegion.IsEmpty() && aLowPrecisionScreenRegion.IsEmpty())) { return; } // If the layer's a container, recurse into all of its children ContainerLayer* container = aLayer->AsContainerLayer(); if (container) { // Accumulate the transform of intermediate surfaces - gfx3DMatrix transform = aTransform; + Matrix4x4 transform = aTransform; if (container->UseIntermediateSurface()) { - transform = gfx::To3DMatrix(aLayer->GetEffectiveTransform()); - transform.PreMultiply(aTransform); + transform = aLayer->GetEffectiveTransform(); + transform = aTransform * transform; } for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) { ComputeRenderIntegrityInternal(child, aScreenRegion, aLowPrecisionScreenRegion, transform); } return; } @@ -616,18 +615,18 @@ LayerManagerComposite::ComputeRenderInte } // See if there's any incomplete rendering nsIntRegion incompleteRegion = aLayer->GetEffectiveVisibleRegion(); incompleteRegion.Sub(incompleteRegion, thebesLayer->GetValidRegion()); if (!incompleteRegion.IsEmpty()) { // Calculate the transform to get between screen and layer space - gfx3DMatrix transformToScreen = To3DMatrix(aLayer->GetEffectiveTransform()); - transformToScreen.PreMultiply(aTransform); + Matrix4x4 transformToScreen = aLayer->GetEffectiveTransform(); + transformToScreen = aTransform * transformToScreen; SubtractTransformedRegion(aScreenRegion, incompleteRegion, transformToScreen); // See if there's any incomplete low-precision rendering TiledLayerComposer* composer = nullptr; LayerComposite* shadow = aLayer->AsLayerComposite(); if (shadow) { composer = shadow->GetTiledLayerComposer(); @@ -645,24 +644,22 @@ LayerManagerComposite::ComputeRenderInte SubtractTransformedRegion(aLowPrecisionScreenRegion, incompleteRegion, transformToScreen); } } } #ifdef MOZ_ANDROID_OMTC static float GetDisplayportCoverage(const CSSRect& aDisplayPort, - const gfx3DMatrix& aTransformToScreen, + const Matrix4x4& aTransformToScreen, const nsIntRect& aScreenRect) { - gfxRect transformedDisplayport = - aTransformToScreen.TransformBounds(gfxRect(aDisplayPort.x, - aDisplayPort.y, - aDisplayPort.width, - aDisplayPort.height)); + Rect transformedDisplayport = + aTransformToScreen.TransformBounds(aDisplayPort.ToUnknownRect()); + transformedDisplayport.RoundOut(); nsIntRect displayport = nsIntRect(transformedDisplayport.x, transformedDisplayport.y, transformedDisplayport.width, transformedDisplayport.height); if (!displayport.Contains(aScreenRect)) { nsIntRegion coveredRegion; coveredRegion.And(aScreenRect, displayport); @@ -695,25 +692,25 @@ LayerManagerComposite::ComputeRenderInte #ifdef MOZ_ANDROID_OMTC // Use the transform on the primary scrollable layer and its FrameMetrics // to find out how much of the viewport the current displayport covers Layer* primaryScrollable = GetPrimaryScrollableLayer(); if (primaryScrollable) { // This is derived from the code in // AsyncCompositionManager::TransformScrollableLayer const FrameMetrics& metrics = primaryScrollable->AsContainerLayer()->GetFrameMetrics(); - gfx3DMatrix transform = gfx::To3DMatrix(primaryScrollable->GetEffectiveTransform()); + Matrix4x4 transform = primaryScrollable->GetEffectiveTransform(); transform.ScalePost(metrics.mResolution.scale, metrics.mResolution.scale, 1); // Clip the screen rect to the document bounds - gfxRect documentBounds = - transform.TransformBounds(gfxRect(metrics.mScrollableRect.x - metrics.GetScrollOffset().x, - metrics.mScrollableRect.y - metrics.GetScrollOffset().y, - metrics.mScrollableRect.width, - metrics.mScrollableRect.height)); + Rect documentBounds = + transform.TransformBounds(Rect(metrics.mScrollableRect.x - metrics.GetScrollOffset().x, + metrics.mScrollableRect.y - metrics.GetScrollOffset().y, + metrics.mScrollableRect.width, + metrics.mScrollableRect.height)); documentBounds.RoundOut(); screenRect = screenRect.Intersect(nsIntRect(documentBounds.x, documentBounds.y, documentBounds.width, documentBounds.height)); // If the screen rect is empty, the user has scrolled entirely into // over-scroll and so we can be considered to have full integrity. if (screenRect.IsEmpty()) { return 1.0f; @@ -742,17 +739,17 @@ LayerManagerComposite::ComputeRenderInte // If none of the screen is covered, we have zero integrity. if (highPrecisionMultiplier <= 0.0f && lowPrecisionMultiplier <= 0.0f) { return 0.0f; } #endif // MOZ_ANDROID_OMTC nsIntRegion screenRegion(screenRect); nsIntRegion lowPrecisionScreenRegion(screenRect); - gfx3DMatrix transform; + Matrix4x4 transform; ComputeRenderIntegrityInternal(root, screenRegion, lowPrecisionScreenRegion, transform); if (!screenRegion.IsEqual(screenRect)) { // Calculate the area of the region. All rects in an nsRegion are // non-overlapping. float screenArea = screenRect.width * screenRect.height; float highPrecisionIntegrity = screenRegion.Area() / screenArea;
--- a/gfx/layers/composite/LayerManagerComposite.h +++ b/gfx/layers/composite/LayerManagerComposite.h @@ -247,17 +247,17 @@ private: * Recursive helper method for use by ComputeRenderIntegrity. Subtracts * any incomplete rendering on aLayer from aScreenRegion. Any low-precision * rendering is included in aLowPrecisionScreenRegion. aTransform is the * accumulated transform of intermediate surfaces beneath aLayer. */ static void ComputeRenderIntegrityInternal(Layer* aLayer, nsIntRegion& aScreenRegion, nsIntRegion& aLowPrecisionScreenRegion, - const gfx3DMatrix& aTransform); + const gfx::Matrix4x4& aTransform); /** * Render the current layer tree to the active target. */ void Render(); /** * Render debug overlays such as the FPS/FrameCounter above the frame.
--- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -3,17 +3,16 @@ */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "base/basictypes.h" #include "BasicLayers.h" -#include "gfx3DMatrix.h" #ifdef MOZ_ENABLE_D3D9_LAYER # include "LayerManagerD3D9.h" #endif //MOZ_ENABLE_D3D9_LAYER #include "mozilla/BrowserElementParent.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/TabParent.h" #include "mozilla/layers/APZCTreeManager.h" #include "mozilla/layers/CompositorParent.h" @@ -26,75 +25,76 @@ #include "nsViewportFrame.h" #include "RenderFrameParent.h" #include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/layers/CompositorChild.h" #include "ClientLayerManager.h" typedef nsContentView::ViewConfig ViewConfig; using namespace mozilla::dom; +using namespace mozilla::gfx; using namespace mozilla::layers; namespace mozilla { namespace layout { typedef FrameMetrics::ViewID ViewID; typedef RenderFrameParent::ViewMap ViewMap; // Represents (affine) transforms that are calculated from a content view. struct ViewTransform { ViewTransform(nsIntPoint aTranslation = nsIntPoint(0, 0), float aXScale = 1, float aYScale = 1) : mTranslation(aTranslation) , mXScale(aXScale) , mYScale(aYScale) {} - operator gfx3DMatrix() const + operator Matrix4x4() const { return - gfx3DMatrix::Translation(mTranslation.x, mTranslation.y, 0) * - gfx3DMatrix::ScalingMatrix(mXScale, mYScale, 1); + Matrix4x4().Translate(mTranslation.x, mTranslation.y, 0) * + Matrix4x4().Scale(mXScale, mYScale, 1); } nsIntPoint mTranslation; float mXScale; float mYScale; }; // Matrix helpers // For our simple purposes, these helpers apply to 2D affine transformations // that can be represented by a scale and a translation. This makes the math // much easier because we only expect the diagonals and the translation // coordinates of the matrix to be non-zero. -static double GetXScale(const gfx3DMatrix& aTransform) +static double GetXScale(const Matrix4x4& aTransform) { return aTransform._11; } -static double GetYScale(const gfx3DMatrix& aTransform) +static double GetYScale(const Matrix4x4& aTransform) { return aTransform._22; } -static void Scale(gfx3DMatrix& aTransform, double aXScale, double aYScale) +static void Scale(Matrix4x4& aTransform, double aXScale, double aYScale) { aTransform._11 *= aXScale; aTransform._22 *= aYScale; } -static void ReverseTranslate(gfx3DMatrix& aTransform, const gfxPoint& aOffset) +static void ReverseTranslate(Matrix4x4& aTransform, const gfxPoint& aOffset) { aTransform._41 -= aOffset.x; aTransform._42 -= aOffset.y; } static void ApplyTransform(nsRect& aRect, - gfx3DMatrix& aTransform, + Matrix4x4& aTransform, nscoord auPerDevPixel) { aRect.x = aRect.x * aTransform._11 + aTransform._41 * auPerDevPixel; aRect.y = aRect.y * aTransform._22 + aTransform._42 * auPerDevPixel; aRect.width = aRect.width * aTransform._11; aRect.height = aRect.height * aTransform._22; } @@ -198,61 +198,61 @@ ComputeShadowTreeTransform(nsIFrame* aCo return ViewTransform(nsIntPoint(0, 0), 1, 1); } } // Use shadow layer tree to build display list for the browser's frame. static void BuildListForLayer(Layer* aLayer, nsFrameLoader* aRootFrameLoader, - const gfx3DMatrix& aTransform, + const Matrix4x4& aTransform, nsDisplayListBuilder* aBuilder, nsDisplayList& aShadowTree, nsIFrame* aSubdocFrame) { const FrameMetrics* metrics = GetFrameMetrics(aLayer); - gfx3DMatrix transform; + Matrix4x4 transform; if (metrics && metrics->IsScrollable()) { const ViewID scrollId = metrics->GetScrollId(); // We need to figure out the bounds of the scrollable region using the // shadow layer tree from the remote process. The metrics viewport is // defined based on all the transformations of its parent layers and // the scale of the current layer. // Calculate transform for this layer. nsContentView* view = aRootFrameLoader->GetCurrentRemoteFrame()->GetContentView(scrollId); // XXX why don't we include aLayer->GetTransform() in the inverse-scale here? // This seems wrong, but it doesn't seem to cause bugs! - gfx3DMatrix applyTransform = ComputeShadowTreeTransform( + Matrix4x4 applyTransform = ComputeShadowTreeTransform( aSubdocFrame, aRootFrameLoader, metrics, view->GetViewConfig(), 1 / GetXScale(aTransform), 1 / GetYScale(aTransform)); - transform = applyTransform * To3DMatrix(aLayer->GetTransform()) * aTransform; + transform = applyTransform * aLayer->GetTransform() * aTransform; // As mentioned above, bounds calculation also depends on the scale // of this layer. - gfx3DMatrix tmpTransform = aTransform; + Matrix4x4 tmpTransform = aTransform; Scale(tmpTransform, GetXScale(applyTransform), GetYScale(applyTransform)); // Calculate rect for this layer based on aTransform. nsRect bounds; { bounds = CSSRect::ToAppUnits(metrics->mViewport); nscoord auPerDevPixel = aSubdocFrame->PresContext()->AppUnitsPerDevPixel(); ApplyTransform(bounds, tmpTransform, auPerDevPixel); } aShadowTree.AppendToTop( new (aBuilder) nsDisplayRemoteShadow(aBuilder, aSubdocFrame, bounds, scrollId)); } else { - transform = To3DMatrix(aLayer->GetTransform()) * aTransform; + transform = aLayer->GetTransform() * aTransform; } for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) { BuildListForLayer(child, aRootFrameLoader, transform, aBuilder, aShadowTree, aSubdocFrame); } } @@ -267,45 +267,45 @@ TransformShadowTree(nsDisplayListBuilder { LayerComposite* shadow = aLayer->AsLayerComposite(); shadow->SetShadowClipRect(aLayer->GetClipRect()); shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion()); shadow->SetShadowOpacity(aLayer->GetOpacity()); const FrameMetrics* metrics = GetFrameMetrics(aLayer); - gfx3DMatrix shadowTransform = To3DMatrix(aLayer->GetTransform()); + Matrix4x4 shadowTransform = aLayer->GetTransform(); ViewTransform layerTransform = aTransform; if (metrics && metrics->IsScrollable()) { const ViewID scrollId = metrics->GetScrollId(); 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()); + Matrix4x4 currentTransform = aLayer->GetTransform(); const ViewConfig& config = view->GetViewConfig(); // With temporary scale we should compensate translation // using temporary scale value aTempScaleDiffX *= GetXScale(shadowTransform) * config.mXScale; aTempScaleDiffY *= GetYScale(shadowTransform) * config.mYScale; ViewTransform viewTransform = ComputeShadowTreeTransform( aFrame, aFrameLoader, metrics, view->GetViewConfig(), aTempScaleDiffX, aTempScaleDiffY ); // Apply the layer's own transform *before* the view transform - shadowTransform = gfx3DMatrix(viewTransform) * currentTransform; + shadowTransform = Matrix4x4(viewTransform) * currentTransform; layerTransform = viewTransform; if (metrics->IsRootScrollable()) { // Apply the translation *before* we do the rest of the transforms. nsIntPoint offset = GetContentRectLayerOffset(aFrame, aBuilder); shadowTransform = shadowTransform * - gfx3DMatrix::Translation(float(offset.x), float(offset.y), 0.0); + Matrix4x4().Translate(float(offset.x), float(offset.y), 0.0); } } if (aLayer->GetIsFixedPosition() && !aLayer->GetParent()->GetIsFixedPosition()) { // Alter the shadow transform of fixed position layers in the situation // that the view transform's scroll position doesn't match the actual // scroll position, due to asynchronous layer scrolling. @@ -327,17 +327,17 @@ TransformShadowTree(nsDisplayListBuilder shadowTransform.Scale(1.0f/c->GetPreXScale(), 1.0f/c->GetPreYScale(), 1); } shadowTransform.ScalePost(1.0f/aLayer->GetPostXScale(), 1.0f/aLayer->GetPostYScale(), 1); - shadow->SetShadowTransform(gfx::ToMatrix4x4(shadowTransform)); + shadow->SetShadowTransform(shadowTransform); for (Layer* child = aLayer->GetFirstChild(); child; child = child->GetNextSibling()) { TransformShadowTree(aBuilder, aFrameLoader, aFrame, child, layerTransform, aTempScaleDiffX, aTempScaleDiffY); } } static void @@ -371,17 +371,17 @@ BuildViewMap(ViewMap& oldContentViews, V float aXScale = 1, float aYScale = 1, float aAccConfigXScale = 1, float aAccConfigYScale = 1) { ContainerLayer* container = aLayer->AsContainerLayer(); if (!container) return; const FrameMetrics metrics = container->GetFrameMetrics(); const ViewID scrollId = metrics.GetScrollId(); - gfx3DMatrix transform = To3DMatrix(aLayer->GetTransform()); + Matrix4x4 transform = aLayer->GetTransform(); aXScale *= GetXScale(transform); aYScale *= GetYScale(transform); if (metrics.IsScrollable()) { nscoord auPerDevPixel = aFrameLoader->GetPrimaryFrameOfOwningContent() ->PresContext()->AppUnitsPerDevPixel(); nscoord auPerCSSPixel = auPerDevPixel * metrics.mDevPixelsPerCSSPixel.scale; nsContentView* view = FindViewForId(oldContentViews, scrollId);