--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -1,29 +1,29 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "ContainerLayerComposite.h"
#include <algorithm> // for min
-#include "apz/src/AsyncPanZoomController.h" // for AsyncPanZoomController
#include "FrameMetrics.h" // for FrameMetrics
#include "Units.h" // for LayerRect, LayerPixel, etc
#include "CompositableHost.h" // for CompositableHost
#include "gfxEnv.h" // for gfxEnv
#include "gfxPrefs.h" // for gfxPrefs
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/RefPtr.h" // for RefPtr
#include "mozilla/UniquePtr.h" // for UniquePtr
#include "mozilla/gfx/BaseRect.h" // for BaseRect
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/gfx/Point.h" // for Point, IntPoint
#include "mozilla/gfx/Rect.h" // for IntRect, Rect
+#include "mozilla/layers/APZSampler.h" // for APZSampler
#include "mozilla/layers/Compositor.h" // for Compositor, etc
#include "mozilla/layers/CompositorTypes.h" // for DiagnosticFlags::CONTAINER
#include "mozilla/layers/Effects.h" // for Effect, EffectChain, etc
#include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "mozilla/RefPtr.h" // for nsRefPtr
@@ -281,46 +281,49 @@ ContainerPrepare(ContainerT* aContainer,
aContainer->mLastIntermediateSurface = nullptr;
}
} else {
aContainer->mLastIntermediateSurface = nullptr;
}
}
template<class ContainerT> void
-RenderMinimap(ContainerT* aContainer, LayerManagerComposite* aManager,
- const RenderTargetIntRect& aClipRect, Layer* aLayer)
+RenderMinimap(ContainerT* aContainer,
+ const RefPtr<APZSampler>& aSampler,
+ LayerManagerComposite* aManager,
+ const RenderTargetIntRect& aClipRect, Layer* aLayer)
{
Compositor* compositor = aManager->GetCompositor();
+ MOZ_ASSERT(aSampler);
if (aLayer->GetScrollMetadataCount() < 1) {
return;
}
- AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController(0);
- if (!controller) {
+ LayerMetricsWrapper wrapper(aLayer, 0);
+ const FrameMetrics& fm = wrapper.Metrics();
+ if (!fm.IsScrollable()) {
return;
}
- ParentLayerPoint scrollOffset = controller->GetCurrentAsyncScrollOffset(AsyncPanZoomController::eForCompositing);
+ ParentLayerPoint scrollOffset = aSampler->GetCurrentAsyncScrollOffset(wrapper);
// Options
const int verticalPadding = 10;
const int horizontalPadding = 5;
gfx::Color backgroundColor(0.3f, 0.3f, 0.3f, 0.3f);
gfx::Color tileActiveColor(1, 1, 1, 0.4f);
gfx::Color tileBorderColor(0, 0, 0, 0.1f);
gfx::Color pageBorderColor(0, 0, 0);
gfx::Color criticalDisplayPortColor(1.f, 1.f, 0);
gfx::Color displayPortColor(0, 1.f, 0);
gfx::Color viewPortColor(0, 0, 1.f, 0.3f);
gfx::Color visibilityColor(1.f, 0, 0);
// Rects
- const FrameMetrics& fm = aLayer->GetFrameMetrics(0);
ParentLayerRect compositionBounds = fm.GetCompositionBounds();
LayerRect scrollRect = fm.GetScrollableRect() * fm.LayersPixelsPerCSSPixel();
LayerRect viewRect = ParentLayerRect(scrollOffset, compositionBounds.Size()) / LayerToParentLayerScale(1);
LayerRect dp = (fm.GetDisplayPort() + fm.GetScrollOffset()) * fm.LayersPixelsPerCSSPixel();
Maybe<LayerRect> cdp;
if (!fm.GetCriticalDisplayPort().IsEmpty()) {
cdp = Some((fm.GetCriticalDisplayPort() + fm.GetScrollOffset()) * fm.LayersPixelsPerCSSPixel());
}
@@ -357,22 +360,20 @@ RenderMinimap(ContainerT* aContainer, La
IntRect clipRect = RoundedOut(aContainer->GetEffectiveTransform().TransformBounds(transformedScrollRect));
// Render the scrollable area.
compositor->FillRect(transformedScrollRect, backgroundColor, clipRect, aContainer->GetEffectiveTransform());
compositor->SlowDrawRect(transformedScrollRect, pageBorderColor, clipRect, aContainer->GetEffectiveTransform());
// If enabled, render information about visibility.
if (gfxPrefs::APZMinimapVisibilityEnabled()) {
- // Retrieve the APZC scrollable layer guid, which we'll use to get the
+ // Retrieve the scrollable layer guid, which we'll use to get the
// appropriate visibility information from the layer manager.
- AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController(0);
- MOZ_ASSERT(controller);
-
- ScrollableLayerGuid guid = controller->GetGuid();
+ MOZ_ASSERT(compositor->GetCompositorBridgeParent()); // we wouldn't have an APZSampler otherwise
+ ScrollableLayerGuid guid(compositor->GetCompositorBridgeParent()->RootLayerTreeId(), fm);
// Get the approximately visible region.
static CSSIntRegion emptyRegion;
CSSIntRegion* visibleRegion = aManager->GetApproximatelyVisibleRegion(guid);
if (!visibleRegion) {
visibleRegion = &emptyRegion;
}
@@ -406,16 +407,21 @@ RenderMinimap(ContainerT* aContainer, La
template<class ContainerT> void
RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect,
const Maybe<gfx::Polygon>& aGeometry)
{
Compositor* compositor = aManager->GetCompositor();
+ RefPtr<APZSampler> sampler;
+ if (CompositorBridgeParent* cbp = compositor->GetCompositorBridgeParent()) {
+ sampler = cbp->GetAPZSampler();
+ }
+
for (size_t i = 0u; i < aContainer->mPrepared->mLayers.Length(); i++) {
PreparedLayer& preparedData = aContainer->mPrepared->mLayers[i];
const gfx::IntRect clipRect = preparedData.mClipRect.ToUnknownRect();
LayerComposite* layerToRender = static_cast<LayerComposite*>(preparedData.mLayer->ImplData());
const Maybe<gfx::Polygon>& childGeometry = preparedData.mGeometry;
Layer* layer = layerToRender->GetLayer();
@@ -474,35 +480,36 @@ RenderLayers(ContainerT* aContainer, Lay
// Draw a border around scrollable layers.
// A layer can be scrolled by multiple scroll frames. Draw a border
// for each.
// Within the list of scroll frames for a layer, the layer border for a
// scroll frame lower down is affected by the async transforms on scroll
// frames higher up, so loop from the top down, and accumulate an async
// transform as we go along.
Matrix4x4 asyncTransform;
- for (uint32_t i = layer->GetScrollMetadataCount(); i > 0; --i) {
- if (layer->GetFrameMetrics(i - 1).IsScrollable()) {
- // Since the composition bounds are in the parent layer's coordinates,
- // use the parent's effective transform rather than the layer's own.
- ParentLayerRect compositionBounds = layer->GetFrameMetrics(i - 1).GetCompositionBounds();
- aManager->GetCompositor()->DrawDiagnostics(DiagnosticFlags::CONTAINER,
- compositionBounds.ToUnknownRect(),
- aClipRect.ToUnknownRect(),
- asyncTransform * aContainer->GetEffectiveTransform());
- if (AsyncPanZoomController* apzc = layer->GetAsyncPanZoomController(i - 1)) {
+ if (sampler) {
+ for (uint32_t i = layer->GetScrollMetadataCount(); i > 0; --i) {
+ LayerMetricsWrapper wrapper(layer, i - 1);
+ if (wrapper.Metrics().IsScrollable()) {
+ // Since the composition bounds are in the parent layer's coordinates,
+ // use the parent's effective transform rather than the layer's own.
+ ParentLayerRect compositionBounds = wrapper.Metrics().GetCompositionBounds();
+ aManager->GetCompositor()->DrawDiagnostics(DiagnosticFlags::CONTAINER,
+ compositionBounds.ToUnknownRect(),
+ aClipRect.ToUnknownRect(),
+ asyncTransform * aContainer->GetEffectiveTransform());
asyncTransform =
- apzc->GetCurrentAsyncTransformWithOverscroll(AsyncPanZoomController::eForCompositing).ToUnknownMatrix()
- * asyncTransform;
+ sampler->GetCurrentAsyncTransformWithOverscroll(wrapper).ToUnknownMatrix()
+ * asyncTransform;
}
}
- }
- if (gfxPrefs::APZMinimap()) {
- RenderMinimap(aContainer, aManager, aClipRect, layer);
+ if (gfxPrefs::APZMinimap()) {
+ RenderMinimap(aContainer, sampler, aManager, aClipRect, layer);
+ }
}
// invariant: our GL context should be current here, I don't think we can
// assert it though
}
}
template<class ContainerT> RefPtr<CompositingRenderTarget>
@@ -629,26 +636,24 @@ ContainerRender(ContainerT* aContainer,
aGeometry);
}
// If it is a scrollable container layer with no child layers, and one of the APZCs
// attached to it has a nonempty async transform, then that transform is not applied
// to any visible content. Display a warning box (conditioned on the FPS display being
// enabled).
if (gfxPrefs::LayersDrawFPS() && aContainer->IsScrollableWithoutContent()) {
+ RefPtr<APZSampler> sampler = aManager->GetCompositor()->GetCompositorBridgeParent()->GetAPZSampler();
// Since aContainer doesn't have any children we can just iterate from the top metrics
// on it down to the bottom using GetFirstChild and not worry about walking onto another
// underlying layer.
for (LayerMetricsWrapper i(aContainer); i; i = i.GetFirstChild()) {
- if (AsyncPanZoomController* apzc = i.GetApzc()) {
- if (!apzc->GetAsyncTransformAppliedToContent()
- && !AsyncTransformComponentMatrix(apzc->GetCurrentAsyncTransform(AsyncPanZoomController::eForHitTesting)).IsIdentity()) {
- aManager->UnusedApzTransformWarning();
- break;
- }
+ if (sampler->HasUnusedAsyncTransform(i)) {
+ aManager->UnusedApzTransformWarning();
+ break;
}
}
}
}
ContainerLayerComposite::ContainerLayerComposite(LayerManagerComposite *aManager)
: ContainerLayer(aManager, nullptr)
, LayerComposite(aManager)
--- a/gfx/layers/composite/ContainerLayerComposite.h
+++ b/gfx/layers/composite/ContainerLayerComposite.h
@@ -11,16 +11,17 @@
#include "mozilla/Attributes.h" // for override
#include "mozilla/UniquePtr.h" // for UniquePtr
#include "mozilla/layers/LayerManagerComposite.h"
#include "mozilla/gfx/Rect.h"
namespace mozilla {
namespace layers {
+class APZSampler;
class CompositableHost;
class CompositingRenderTarget;
struct PreparedData;
class ContainerLayerComposite : public ContainerLayer,
public LayerComposite
{
template<class ContainerT>
@@ -49,17 +50,19 @@ class ContainerLayerComposite : public C
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
friend RefPtr<CompositingRenderTarget>
CreateOrRecycleTarget(ContainerT* aContainer,
LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect);
template<class ContainerT>
- void RenderMinimap(ContainerT* aContainer, LayerManagerComposite* aManager,
+ void RenderMinimap(ContainerT* aContainer,
+ const RefPtr<APZSampler>& aSampler,
+ LayerManagerComposite* aManager,
const RenderTargetIntRect& aClipRect, Layer* aLayer);
public:
explicit ContainerLayerComposite(LayerManagerComposite *aManager);
protected:
~ContainerLayerComposite();
public: