Bug 1055760 - Update some more bits of compositor layer code to deal with multiple FrameMetrics. r=BenWa,botond

This commit is contained in:
Kartikaya Gupta 2014-08-27 22:13:42 -04:00
parent 30c7225718
commit dd86fa4d26
7 changed files with 37 additions and 23 deletions

View File

@ -713,6 +713,15 @@ Layer::HasScrollableFrameMetrics() const
return false;
}
bool
Layer::IsScrollInfoLayer() const
{
// A scrollable container layer with no children
return AsContainerLayer()
&& HasScrollableFrameMetrics()
&& !GetFirstChild();
}
const Matrix4x4
Layer::GetTransform() const
{

View File

@ -1203,6 +1203,7 @@ public:
uint32_t GetFrameMetricsCount() const { return mFrameMetrics.Length(); }
const nsTArray<FrameMetrics>& GetAllFrameMetrics() { return mFrameMetrics; }
bool HasScrollableFrameMetrics() const;
bool IsScrollInfoLayer() const;
const EventRegions& GetEventRegions() const { return mEventRegions; }
ContainerLayer* GetParent() { return mParent; }
Layer* GetNextSibling() { return mNextSibling; }

View File

@ -23,6 +23,7 @@
#include "mozilla/layers/TextureHost.h" // for CompositingRenderTarget
#include "mozilla/layers/AsyncPanZoomController.h" // for AsyncPanZoomController
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "nsAutoPtr.h" // for nsRefPtr
#include "nsDebug.h" // for NS_ASSERTION
@ -254,10 +255,18 @@ RenderLayers(ContainerT* aContainer,
// composited area. If the layer has a background color, fill these areas
// with the background color by drawing a rectangle of the background color
// over the entire composited area before drawing the container contents.
if (AsyncPanZoomController* apzc = aContainer->GetAsyncPanZoomController()) {
// Make sure not to do this on a "scrollinfo" layer (one with an empty visible
// region) because it's just a placeholder for APZ purposes.
if (apzc->IsOverscrolled() && !aContainer->GetVisibleRegion().IsEmpty()) {
// Make sure not to do this on a "scrollinfo" layer because it's just a
// placeholder for APZ purposes.
if (aContainer->HasScrollableFrameMetrics() && !aContainer->IsScrollInfoLayer()) {
bool overscrolled = false;
for (uint32_t i = 0; i < aContainer->GetFrameMetricsCount(); i++) {
AsyncPanZoomController* apzc = aContainer->GetAsyncPanZoomController(i);
if (apzc && apzc->IsOverscrolled()) {
overscrolled = true;
break;
}
}
if (overscrolled) {
gfxRGBA color = aContainer->GetBackgroundColor();
// If the background is completely transparent, there's no point in
// drawing anything for it. Hopefully the layers behind, if any, will
@ -421,8 +430,11 @@ ContainerRender(ContainerT* aContainer,
}
aContainer->mPrepared = nullptr;
if (aContainer->GetFrameMetrics().IsScrollable()) {
const FrameMetrics& frame = aContainer->GetFrameMetrics();
for (uint32_t i = 0; i < aContainer->GetFrameMetricsCount(); i++) {
if (!aContainer->GetFrameMetrics(i).IsScrollable()) {
continue;
}
const FrameMetrics& frame = aContainer->GetFrameMetrics(i);
LayerRect layerBounds = frame.mCompositionBounds * ParentLayerToLayerScale(1.0);
gfx::Rect rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height);
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);

View File

@ -797,7 +797,13 @@ LayerManagerComposite::ComputeRenderIntegrity()
return 1.f;
}
const FrameMetrics& rootMetrics = root->GetFrameMetrics();
FrameMetrics rootMetrics = LayerMetricsWrapper::TopmostScrollableMetrics(root);
if (!rootMetrics.IsScrollable()) {
// The root may not have any scrollable metrics, in which case rootMetrics
// will just be an empty FrameMetrics. Instead use the actual metrics from
// the root layer.
rootMetrics = LayerMetricsWrapper(root).Metrics();
}
ParentLayerIntRect bounds = RoundedToInt(rootMetrics.mCompositionBounds);
nsIntRect screenRect(bounds.x,
bounds.y,

View File

@ -172,19 +172,6 @@ ThebesLayerComposite::GenEffectChain(EffectChain& aEffect)
aEffect.mPrimaryEffect = mBuffer->GenEffect(GetEffectFilter());
}
CSSToScreenScale
ThebesLayerComposite::GetEffectiveResolution()
{
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
const FrameMetrics& metrics = parent->GetFrameMetrics();
if (metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
return metrics.GetZoom();
}
}
return CSSToScreenScale(1.0);
}
void
ThebesLayerComposite::PrintInfo(std::stringstream& aStream, const char* aPrefix)
{

View File

@ -86,8 +86,6 @@ protected:
private:
gfx::Filter GetEffectFilter() { return gfx::Filter::LINEAR; }
CSSToScreenScale GetEffectiveResolution();
private:
RefPtr<ContentHost> mBuffer;
};

View File

@ -9,6 +9,7 @@
#include "mozilla/gfx/Matrix.h" // for Matrix4x4
#include "mozilla/layers/Compositor.h" // for Compositor
#include "mozilla/layers/Effects.h" // for TexturedEffect, Effect, etc
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
#include "nsAString.h"
#include "nsDebug.h" // for NS_WARNING
@ -367,7 +368,7 @@ TiledContentHost::Composite(EffectChain& aEffectChain,
// Background colors are only stored on scrollable layers. Grab
// the one from the nearest scrollable ancestor layer.
for (Layer* ancestor = GetLayer(); ancestor; ancestor = ancestor->GetParent()) {
if (ancestor->GetFrameMetrics().IsScrollable()) {
if (ancestor->HasScrollableFrameMetrics()) {
backgroundColor = ancestor->GetBackgroundColor();
break;
}