зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1443792 - Remove direct access to AsyncPanZoomController from ContainerLayerComposite. r=botond
MozReview-Commit-ID: 7CiK7bzDcPW --HG-- extra : rebase_source : 468e2c1e09fb03fdefc21262aeb93e7086eda50d
This commit is contained in:
Родитель
bb2e76ca71
Коммит
778e7fae97
|
@ -96,10 +96,13 @@ public:
|
|||
bool aScrollbarIsDescendant,
|
||||
AsyncTransformComponentMatrix* aOutClipTransform);
|
||||
|
||||
ParentLayerPoint GetCurrentAsyncScrollOffset(const LayerMetricsWrapper& aLayer);
|
||||
AsyncTransform GetCurrentAsyncTransform(const LayerMetricsWrapper& aLayer);
|
||||
AsyncTransformComponentMatrix GetOverscrollTransform(const LayerMetricsWrapper& aLayer);
|
||||
AsyncTransformComponentMatrix GetCurrentAsyncTransformWithOverscroll(const LayerMetricsWrapper& aLayer);
|
||||
|
||||
void MarkAsyncTransformAppliedToContent(const LayerMetricsWrapper& aLayer);
|
||||
bool HasUnusedAsyncTransform(const LayerMetricsWrapper& aLayer);
|
||||
|
||||
protected:
|
||||
virtual ~APZSampler();
|
||||
|
|
|
@ -166,6 +166,13 @@ APZSampler::ComputeTransformForScrollThumb(const LayerToParentLayerMatrix4x4& aC
|
|||
aOutClipTransform);
|
||||
}
|
||||
|
||||
ParentLayerPoint
|
||||
APZSampler::GetCurrentAsyncScrollOffset(const LayerMetricsWrapper& aLayer)
|
||||
{
|
||||
MOZ_ASSERT(aLayer.GetApzc());
|
||||
return aLayer.GetApzc()->GetCurrentAsyncScrollOffset(AsyncPanZoomController::eForCompositing);
|
||||
}
|
||||
|
||||
AsyncTransform
|
||||
APZSampler::GetCurrentAsyncTransform(const LayerMetricsWrapper& aLayer)
|
||||
{
|
||||
|
@ -180,6 +187,13 @@ APZSampler::GetOverscrollTransform(const LayerMetricsWrapper& aLayer)
|
|||
return aLayer.GetApzc()->GetOverscrollTransform(AsyncPanZoomController::eForCompositing);
|
||||
}
|
||||
|
||||
AsyncTransformComponentMatrix
|
||||
APZSampler::GetCurrentAsyncTransformWithOverscroll(const LayerMetricsWrapper& aLayer)
|
||||
{
|
||||
MOZ_ASSERT(aLayer.GetApzc());
|
||||
return aLayer.GetApzc()->GetCurrentAsyncTransformWithOverscroll(AsyncPanZoomController::eForCompositing);
|
||||
}
|
||||
|
||||
void
|
||||
APZSampler::MarkAsyncTransformAppliedToContent(const LayerMetricsWrapper& aLayer)
|
||||
{
|
||||
|
@ -187,5 +201,14 @@ APZSampler::MarkAsyncTransformAppliedToContent(const LayerMetricsWrapper& aLayer
|
|||
aLayer.GetApzc()->MarkAsyncTransformAppliedToContent();
|
||||
}
|
||||
|
||||
bool
|
||||
APZSampler::HasUnusedAsyncTransform(const LayerMetricsWrapper& aLayer)
|
||||
{
|
||||
AsyncPanZoomController* apzc = aLayer.GetApzc();
|
||||
return apzc
|
||||
&& !apzc->GetAsyncTransformAppliedToContent()
|
||||
&& !AsyncTransformComponentMatrix(apzc->GetCurrentAsyncTransform(AsyncPanZoomController::eForHitTesting)).IsIdentity();
|
||||
}
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#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
|
||||
|
@ -19,6 +18,7 @@
|
|||
#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
|
||||
|
@ -286,21 +286,25 @@ ContainerPrepare(ContainerT* aContainer,
|
|||
}
|
||||
|
||||
template<class ContainerT> void
|
||||
RenderMinimap(ContainerT* aContainer, LayerManagerComposite* aManager,
|
||||
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;
|
||||
|
@ -314,7 +318,6 @@ RenderMinimap(ContainerT* aContainer, LayerManagerComposite* aManager,
|
|||
gfx::Color viewPortColor(0, 0, 1.f, 0.3f);
|
||||
|
||||
// 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);
|
||||
|
@ -382,6 +385,11 @@ RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager,
|
|||
{
|
||||
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];
|
||||
|
||||
|
@ -450,25 +458,26 @@ RenderLayers(ContainerT* aContainer, LayerManagerComposite* aManager,
|
|||
// frames higher up, so loop from the top down, and accumulate an async
|
||||
// transform as we go along.
|
||||
Matrix4x4 asyncTransform;
|
||||
if (sampler) {
|
||||
for (uint32_t i = layer->GetScrollMetadataCount(); i > 0; --i) {
|
||||
if (layer->GetFrameMetrics(i - 1).IsScrollable()) {
|
||||
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 = layer->GetFrameMetrics(i - 1).GetCompositionBounds();
|
||||
ParentLayerRect compositionBounds = wrapper.Metrics().GetCompositionBounds();
|
||||
aManager->GetCompositor()->DrawDiagnostics(DiagnosticFlags::CONTAINER,
|
||||
compositionBounds.ToUnknownRect(),
|
||||
aClipRect.ToUnknownRect(),
|
||||
asyncTransform * aContainer->GetEffectiveTransform());
|
||||
if (AsyncPanZoomController* apzc = layer->GetAsyncPanZoomController(i - 1)) {
|
||||
asyncTransform =
|
||||
apzc->GetCurrentAsyncTransformWithOverscroll(AsyncPanZoomController::eForCompositing).ToUnknownMatrix()
|
||||
sampler->GetCurrentAsyncTransformWithOverscroll(wrapper).ToUnknownMatrix()
|
||||
* asyncTransform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gfxPrefs::APZMinimap()) {
|
||||
RenderMinimap(aContainer, aManager, aClipRect, layer);
|
||||
RenderMinimap(aContainer, sampler, aManager, aClipRect, layer);
|
||||
}
|
||||
}
|
||||
|
||||
// invariant: our GL context should be current here, I don't think we can
|
||||
|
@ -605,19 +614,17 @@ ContainerRender(ContainerT* aContainer,
|
|||
// 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()) {
|
||||
if (sampler->HasUnusedAsyncTransform(i)) {
|
||||
aManager->UnusedApzTransformWarning();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ContainerLayerComposite::ContainerLayerComposite(LayerManagerComposite *aManager)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
class APZSampler;
|
||||
class CompositableHost;
|
||||
class CompositingRenderTarget;
|
||||
struct PreparedData;
|
||||
|
@ -54,7 +55,9 @@ class ContainerLayerComposite : public ContainerLayer,
|
|||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче