Bug 1143522 - Convert Layer::mClipRect to ParentLayerIntRect. r=botond

Change interface of getter/setter for mClipRect,
also necessary modification for codes that use these resources.

* * *
Bundle mUseClipRect and mClipRect as Maybe<ParentLayerIntRect> mClipRect

--HG--
extra : rebase_source : ca0c60404a28b7418df88104b863760033289910
This commit is contained in:
Ying-Ruei Liang (KK) 2015-04-11 22:03:00 -04:00
Родитель 3066d09f90
Коммит f17daf9c2a
18 изменённых файлов: 156 добавлений и 125 удалений

Просмотреть файл

@ -99,6 +99,12 @@ struct IntRectTyped :
yMost += this->height; yMost += this->height;
return !xMost.isValid() || !yMost.isValid(); return !xMost.isValid() || !yMost.isValid();
} }
// This is here only to keep IPDL-generated code happy. DO NOT USE.
bool operator==(const IntRectTyped<units>& aRect) const
{
return IntRectTyped<units>::IsEqualEdges(aRect);
}
}; };
typedef IntRectTyped<UnknownUnits> IntRect; typedef IntRectTyped<UnknownUnits> IntRect;

Просмотреть файл

@ -341,15 +341,17 @@ public:
return region; return region;
} }
const nsIntRect* GetClipRect() const const Maybe<ParentLayerIntRect>& GetClipRect() const
{ {
MOZ_ASSERT(IsValid()); MOZ_ASSERT(IsValid());
static const Maybe<ParentLayerIntRect> sNoClipRect = Nothing();
if (AtBottomLayer()) { if (AtBottomLayer()) {
return mLayer->GetClipRect(); return mLayer->GetClipRect();
} }
return nullptr; return sNoClipRect;
} }
EventRegionsOverride GetEventRegionsOverride() const EventRegionsOverride GetEventRegionsOverride() const

Просмотреть файл

@ -8,6 +8,7 @@
#include "ImageContainer.h" // for ImageContainer #include "ImageContainer.h" // for ImageContainer
#include "ImageLayers.h" // for ImageLayer, etc #include "ImageLayers.h" // for ImageLayer, etc
#include "Layers.h" // for Layer, ContainerLayer, etc #include "Layers.h" // for Layer, ContainerLayer, etc
#include "Units.h" // for ParentLayerIntRect
#include "gfxColor.h" // for gfxRGBA #include "gfxColor.h" // for gfxRGBA
#include "GraphicsFilter.h" // for GraphicsFilter #include "GraphicsFilter.h" // for GraphicsFilter
#include "gfxRect.h" // for gfxRect #include "gfxRect.h" // for gfxRect
@ -140,7 +141,7 @@ struct LayerPropertiesBase : public LayerProperties
mLayer->GetPostXScale() != mPostXScale || mLayer->GetPostXScale() != mPostXScale ||
mLayer->GetPostYScale() != mPostYScale; mLayer->GetPostYScale() != mPostYScale;
Layer* otherMask = mLayer->GetMaskLayer(); Layer* otherMask = mLayer->GetMaskLayer();
const nsIntRect* otherClip = mLayer->GetClipRect(); const Maybe<ParentLayerIntRect>& otherClip = mLayer->GetClipRect();
nsIntRegion result; nsIntRegion result;
if ((mMaskLayer ? mMaskLayer->mLayer : nullptr) != otherMask || if ((mMaskLayer ? mMaskLayer->mLayer : nullptr) != otherMask ||
(mUseClipRect != !!otherClip) || (mUseClipRect != !!otherClip) ||
@ -166,7 +167,7 @@ struct LayerPropertiesBase : public LayerProperties
if (!mClipRect.IsEqualInterior(*otherClip)) { if (!mClipRect.IsEqualInterior(*otherClip)) {
aGeometryChanged = true; aGeometryChanged = true;
nsIntRegion tmp; nsIntRegion tmp;
tmp.Xor(mClipRect, *otherClip); tmp.Xor(ParentLayerIntRect::ToUntyped(mClipRect), ParentLayerIntRect::ToUntyped(*otherClip));
AddRegion(result, tmp); AddRegion(result, tmp);
} }
} }
@ -199,7 +200,7 @@ struct LayerPropertiesBase : public LayerProperties
float mPostXScale; float mPostXScale;
float mPostYScale; float mPostYScale;
float mOpacity; float mOpacity;
nsIntRect mClipRect; ParentLayerIntRect mClipRect;
bool mUseClipRect; bool mUseClipRect;
}; };

Просмотреть файл

@ -14,6 +14,7 @@
#include "LayerSorter.h" // for SortLayersBy3DZOrder #include "LayerSorter.h" // for SortLayersBy3DZOrder
#include "LayersLogging.h" // for AppendToString #include "LayersLogging.h" // for AppendToString
#include "ReadbackLayer.h" // for ReadbackLayer #include "ReadbackLayer.h" // for ReadbackLayer
#include "UnitTransforms.h" // for ViewAs
#include "gfxPlatform.h" // for gfxPlatform #include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" #include "gfxPrefs.h"
#include "gfxUtils.h" // for gfxUtils, etc #include "gfxUtils.h" // for gfxUtils, etc
@ -201,7 +202,6 @@ Layer::Layer(LayerManager* aManager, void* aImplData) :
mMixBlendMode(CompositionOp::OP_OVER), mMixBlendMode(CompositionOp::OP_OVER),
mForceIsolatedGroup(false), mForceIsolatedGroup(false),
mContentFlags(0), mContentFlags(0),
mUseClipRect(false),
mUseTileSourceRect(false), mUseTileSourceRect(false),
mIsFixedPosition(false), mIsFixedPosition(false),
mMargins(0, 0, 0, 0), mMargins(0, 0, 0, 0),
@ -547,7 +547,7 @@ Layer::CanUseOpaqueSurface()
// NB: eventually these methods will be defined unconditionally, and // NB: eventually these methods will be defined unconditionally, and
// can be moved into Layers.h // can be moved into Layers.h
const nsIntRect* const Maybe<ParentLayerIntRect>&
Layer::GetEffectiveClipRect() Layer::GetEffectiveClipRect()
{ {
if (LayerComposite* shadow = AsLayerComposite()) { if (LayerComposite* shadow = AsLayerComposite()) {
@ -673,7 +673,9 @@ Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect)
return currentClip; return currentClip;
} }
const RenderTargetIntRect clipRect = RenderTargetPixel::FromUntyped(*GetEffectiveClipRect()); const RenderTargetIntRect clipRect =
ViewAs<RenderTargetPixel>(*GetEffectiveClipRect(),
PixelCastJustification::RenderTargetIsParentLayerForRoot);
if (clipRect.IsEmpty()) { if (clipRect.IsEmpty()) {
// We might have a non-translation transform in the container so we can't // We might have a non-translation transform in the container so we can't
// use the code path below. // use the code path below.
@ -694,7 +696,7 @@ Layer::CalculateScissorRect(const RenderTargetIntRect& aCurrentScissorRect)
if (!gfxUtils::GfxRectToIntRect(trScissor, &tmp)) { if (!gfxUtils::GfxRectToIntRect(trScissor, &tmp)) {
return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0)); return RenderTargetIntRect(currentClip.TopLeft(), RenderTargetIntSize(0, 0));
} }
scissor = RenderTargetPixel::FromUntyped(tmp); scissor = ViewAs<RenderTargetPixel>(tmp);
// Find the nearest ancestor with an intermediate surface // Find the nearest ancestor with an intermediate surface
do { do {
@ -884,7 +886,7 @@ Layer::GetVisibleRegionRelativeToRootLayer(nsIntRegion& aResult,
// If the parent layer clips its lower layers, clip the visible region // If the parent layer clips its lower layers, clip the visible region
// we're accumulating. // we're accumulating.
if (layer->GetEffectiveClipRect()) { if (layer->GetEffectiveClipRect()) {
aResult.AndWith(*layer->GetEffectiveClipRect()); aResult.AndWith(ParentLayerIntRect::ToUntyped(*layer->GetEffectiveClipRect()));
} }
// Now we need to walk across the list of siblings for this parent layer, // Now we need to walk across the list of siblings for this parent layer,
@ -1099,7 +1101,7 @@ ContainerLayer::HasMultipleChildren()
{ {
uint32_t count = 0; uint32_t count = 0;
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) { for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
const nsIntRect *clipRect = child->GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& clipRect = child->GetEffectiveClipRect();
if (clipRect && clipRect->IsEmpty()) if (clipRect && clipRect->IsEmpty())
continue; continue;
if (child->GetVisibleRegion().IsEmpty()) if (child->GetVisibleRegion().IsEmpty())
@ -1166,7 +1168,7 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const Matrix4x4& aTransformToS
gfx::ThebesMatrix(contTransform).HasNonIntegerTranslation()) { gfx::ThebesMatrix(contTransform).HasNonIntegerTranslation()) {
#endif #endif
for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) { for (Layer* child = GetFirstChild(); child; child = child->GetNextSibling()) {
const nsIntRect *clipRect = child->GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& clipRect = child->GetEffectiveClipRect();
/* We can't (easily) forward our transform to children with a non-empty clip /* We can't (easily) forward our transform to children with a non-empty clip
* rect since it would need to be adjusted for the transform. See * rect since it would need to be adjusted for the transform. See
* the calculations performed by CalculateScissorRect above. * the calculations performed by CalculateScissorRect above.
@ -1565,8 +1567,8 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
layers::PrintInfo(aStream, AsLayerComposite()); layers::PrintInfo(aStream, AsLayerComposite());
if (mUseClipRect) { if (mClipRect) {
AppendToString(aStream, mClipRect, " [clip=", "]"); AppendToString(aStream, *mClipRect, " [clip=", "]");
} }
if (1.0 != mPostXScale || 1.0 != mPostYScale) { if (1.0 != mPostXScale || 1.0 != mPostYScale) {
aStream << nsPrintfCString(" [postScale=%g, %g]", mPostXScale, mPostYScale).get(); aStream << nsPrintfCString(" [postScale=%g, %g]", mPostXScale, mPostYScale).get();
@ -1650,8 +1652,10 @@ DumpTransform(layerscope::LayersPacket::Layer::Matrix* aLayerMatrix, const Matri
} }
// The static helper function sets the nsIntRect into the packet // The static helper function sets the nsIntRect into the packet
template <typename T, typename Sub, typename Point, typename SizeT, typename MarginT>
static void static void
DumpRect(layerscope::LayersPacket::Layer::Rect* aLayerRect, const nsIntRect& aRect) DumpRect(layerscope::LayersPacket::Layer::Rect* aLayerRect,
const BaseRect<T, Sub, Point, SizeT, MarginT>& aRect)
{ {
aLayerRect->set_x(aRect.x); aLayerRect->set_x(aRect.x);
aLayerRect->set_y(aRect.y); aLayerRect->set_y(aRect.y);
@ -1682,7 +1686,7 @@ Layer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
// Shadow // Shadow
if (LayerComposite* lc = AsLayerComposite()) { if (LayerComposite* lc = AsLayerComposite()) {
LayersPacket::Layer::Shadow* s = layer->mutable_shadow(); LayersPacket::Layer::Shadow* s = layer->mutable_shadow();
if (const nsIntRect* clipRect = lc->GetShadowClipRect()) { if (const Maybe<ParentLayerIntRect>& clipRect = lc->GetShadowClipRect()) {
DumpRect(s->mutable_clip(), *clipRect); DumpRect(s->mutable_clip(), *clipRect);
} }
if (!lc->GetShadowTransform().IsIdentity()) { if (!lc->GetShadowTransform().IsIdentity()) {
@ -1693,8 +1697,8 @@ Layer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
} }
} }
// Clip // Clip
if (mUseClipRect) { if (mClipRect) {
DumpRect(layer->mutable_clip(), mClipRect); DumpRect(layer->mutable_clip(), *mClipRect);
} }
// Transform // Transform
if (!mTransform.IsIdentity()) { if (!mTransform.IsIdentity()) {
@ -2047,7 +2051,7 @@ PrintInfo(std::stringstream& aStream, LayerComposite* aLayerComposite)
if (!aLayerComposite) { if (!aLayerComposite) {
return; return;
} }
if (const nsIntRect* clipRect = aLayerComposite->GetShadowClipRect()) { if (const Maybe<ParentLayerIntRect>& clipRect = aLayerComposite->GetShadowClipRect()) {
AppendToString(aStream, *clipRect, " [shadow-clip=", "]"); AppendToString(aStream, *clipRect, " [shadow-clip=", "]");
} }
if (!aLayerComposite->GetShadowTransform().IsIdentity()) { if (!aLayerComposite->GetShadowTransform().IsIdentity()) {

Просмотреть файл

@ -10,7 +10,7 @@
#include <stdio.h> // for FILE #include <stdio.h> // for FILE
#include <sys/types.h> // for int32_t, int64_t #include <sys/types.h> // for int32_t, int64_t
#include "FrameMetrics.h" // for FrameMetrics #include "FrameMetrics.h" // for FrameMetrics
#include "Units.h" // for LayerMargin, LayerPoint #include "Units.h" // for LayerMargin, LayerPoint, ParentLayerIntRect
#include "gfxContext.h" // for GraphicsOperator #include "gfxContext.h" // for GraphicsOperator
#include "gfxTypes.h" #include "gfxTypes.h"
#include "gfxColor.h" // for gfxRGBA #include "gfxColor.h" // for gfxRGBA
@ -21,6 +21,7 @@
#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2, etc #include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2, etc
#include "mozilla/DebugOnly.h" // for DebugOnly #include "mozilla/DebugOnly.h" // for DebugOnly
#include "mozilla/EventForwards.h" // for nsPaintEvent #include "mozilla/EventForwards.h" // for nsPaintEvent
#include "mozilla/Maybe.h" // for Maybe
#include "mozilla/RefPtr.h" // for TemporaryRef #include "mozilla/RefPtr.h" // for TemporaryRef
#include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc #include "mozilla/StyleAnimationValue.h" // for StyleAnimationValue, etc
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration #include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
@ -990,20 +991,20 @@ public:
* in device pixels. * in device pixels.
* If aRect is null no clipping will be performed. * If aRect is null no clipping will be performed.
*/ */
void SetClipRect(const nsIntRect* aRect) void SetClipRect(const Maybe<ParentLayerIntRect>& aRect)
{ {
if (mUseClipRect) { if (mClipRect) {
if (!aRect) { if (!aRect) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is <none>", this, MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is <none>", this,
mClipRect.x, mClipRect.y, mClipRect.width, mClipRect.height)); mClipRect->x, mClipRect->y, mClipRect->width, mClipRect->height));
mUseClipRect = false; mClipRect.reset();
Mutated(); Mutated();
} else { } else {
if (!aRect->IsEqualEdges(mClipRect)) { if (!aRect->IsEqualEdges(*mClipRect)) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is %d,%d,%d,%d", this, MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was %d,%d,%d,%d is %d,%d,%d,%d", this,
mClipRect.x, mClipRect.y, mClipRect.width, mClipRect.height, mClipRect->x, mClipRect->y, mClipRect->width, mClipRect->height,
aRect->x, aRect->y, aRect->width, aRect->height)); aRect->x, aRect->y, aRect->width, aRect->height));
mClipRect = *aRect; mClipRect = aRect;
Mutated(); Mutated();
} }
} }
@ -1011,8 +1012,7 @@ public:
if (aRect) { if (aRect) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was <none> is %d,%d,%d,%d", this, MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ClipRect was <none> is %d,%d,%d,%d", this,
aRect->x, aRect->y, aRect->width, aRect->height)); aRect->x, aRect->y, aRect->width, aRect->height));
mUseClipRect = true; mClipRect = aRect;
mClipRect = *aRect;
Mutated(); Mutated();
} }
} }
@ -1227,7 +1227,7 @@ public:
// These getters can be used anytime. // These getters can be used anytime.
float GetOpacity() { return mOpacity; } float GetOpacity() { return mOpacity; }
gfx::CompositionOp GetMixBlendMode() const { return mMixBlendMode; } gfx::CompositionOp GetMixBlendMode() const { return mMixBlendMode; }
const nsIntRect* GetClipRect() { return mUseClipRect ? &mClipRect : nullptr; } const Maybe<ParentLayerIntRect>& GetClipRect() const { return mClipRect; }
uint32_t GetContentFlags() { return mContentFlags; } uint32_t GetContentFlags() { return mContentFlags; }
const nsIntRect& GetLayerBounds() const { return mLayerBounds; } const nsIntRect& GetLayerBounds() const { return mLayerBounds; }
const nsIntRegion& GetVisibleRegion() const { return mVisibleRegion; } const nsIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
@ -1418,7 +1418,7 @@ public:
// These getters can be used anytime. They return the effective // These getters can be used anytime. They return the effective
// values that should be used when drawing this layer to screen, // values that should be used when drawing this layer to screen,
// accounting for this layer possibly being a shadow. // accounting for this layer possibly being a shadow.
const nsIntRect* GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& GetEffectiveClipRect();
const nsIntRegion& GetEffectiveVisibleRegion(); const nsIntRegion& GetEffectiveVisibleRegion();
/** /**
@ -1700,12 +1700,11 @@ protected:
float mOpacity; float mOpacity;
gfx::CompositionOp mMixBlendMode; gfx::CompositionOp mMixBlendMode;
bool mForceIsolatedGroup; bool mForceIsolatedGroup;
nsIntRect mClipRect; Maybe<ParentLayerIntRect> mClipRect;
nsIntRect mTileSourceRect; nsIntRect mTileSourceRect;
nsIntRegion mInvalidRegion; nsIntRegion mInvalidRegion;
nsTArray<nsRefPtr<AsyncPanZoomController> > mApzcs; nsTArray<nsRefPtr<AsyncPanZoomController> > mApzcs;
uint32_t mContentFlags; uint32_t mContentFlags;
bool mUseClipRect;
bool mUseTileSourceRect; bool mUseTileSourceRect;
bool mIsFixedPosition; bool mIsFixedPosition;
LayerPoint mAnchor; LayerPoint mAnchor;

Просмотреть файл

@ -7,6 +7,8 @@
#include <sys/types.h> // for int32_t #include <sys/types.h> // for int32_t
#include "Layers.h" // for Layer, PaintedLayer, etc #include "Layers.h" // for Layer, PaintedLayer, etc
#include "ReadbackLayer.h" // for ReadbackLayer, ReadbackSink #include "ReadbackLayer.h" // for ReadbackLayer, ReadbackSink
#include "UnitTransforms.h" // for ViewAs
#include "Units.h" // for ParentLayerIntRect
#include "gfxColor.h" // for gfxRGBA #include "gfxColor.h" // for gfxRGBA
#include "gfxContext.h" // for gfxContext #include "gfxContext.h" // for gfxContext
#include "gfxUtils.h" #include "gfxUtils.h"
@ -76,8 +78,8 @@ FindBackgroundLayer(ReadbackLayer* aLayer, nsIntPoint* aOffset)
return nullptr; return nullptr;
// cliprects are post-transform // cliprects are post-transform
const nsIntRect* clipRect = l->GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& clipRect = l->GetEffectiveClipRect();
if (clipRect && !clipRect->Contains(nsIntRect(transformOffset, aLayer->GetSize()))) if (clipRect && !clipRect->Contains(ViewAs<ParentLayerPixel>(nsIntRect(transformOffset, aLayer->GetSize()))))
return nullptr; return nullptr;
Layer::LayerType type = l->GetType(); Layer::LayerType type = l->GetType();

Просмотреть файл

@ -29,6 +29,7 @@
#include "gfxPrefs.h" // for gfxPrefs #include "gfxPrefs.h" // for gfxPrefs
#include "OverscrollHandoffState.h" // for OverscrollHandoffState #include "OverscrollHandoffState.h" // for OverscrollHandoffState
#include "LayersLogging.h" // for Stringify #include "LayersLogging.h" // for Stringify
#include "Units.h" // for ParentlayerPixel
#define ENABLE_APZCTM_LOGGING 0 #define ENABLE_APZCTM_LOGGING 0
// #define ENABLE_APZCTM_LOGGING 1 // #define ENABLE_APZCTM_LOGGING 1
@ -202,7 +203,7 @@ ComputeClipRegion(GeckoContentController* aController,
{ {
ParentLayerIntRegion clipRegion; ParentLayerIntRegion clipRegion;
if (aLayer.GetClipRect()) { if (aLayer.GetClipRect()) {
clipRegion = ViewAs<ParentLayerPixel>(*aLayer.GetClipRect()); clipRegion = *aLayer.GetClipRect();
} else { } else {
// if there is no clip on this layer (which should only happen for the // if there is no clip on this layer (which should only happen for the
// root scrollable layer in a process, or for some of the LayerMetrics // root scrollable layer in a process, or for some of the LayerMetrics
@ -334,7 +335,7 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
node = RecycleOrCreateNode(aState, nullptr); node = RecycleOrCreateNode(aState, nullptr);
AttachNodeToTree(node, aParent, aNextSibling); AttachNodeToTree(node, aParent, aNextSibling);
node->SetHitTestData(GetEventRegions(aLayer), aLayer.GetTransform(), node->SetHitTestData(GetEventRegions(aLayer), aLayer.GetTransform(),
aLayer.GetClipRect() ? Some(ParentLayerIntRegion(ViewAs<ParentLayerPixel>(*aLayer.GetClipRect()))) : Nothing(), aLayer.GetClipRect() ? Some(ParentLayerIntRegion(*aLayer.GetClipRect())) : Nothing(),
GetEventRegionsOverride(aParent, aLayer)); GetEventRegionsOverride(aParent, aLayer));
return node; return node;
} }

Просмотреть файл

@ -102,7 +102,7 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const nsIntRect& aInRect)
childRegion.MoveBy(int32_t(childTransform._31), int32_t(childTransform._32)); childRegion.MoveBy(int32_t(childTransform._31), int32_t(childTransform._32));
childRegion.And(childRegion, rect); childRegion.And(childRegion, rect);
if (l->GetClipRect()) { if (l->GetClipRect()) {
childRegion.And(childRegion, *l->GetClipRect() + offset); childRegion.And(childRegion, ParentLayerIntRect::ToUntyped(*l->GetClipRect()) + offset);
} }
nsIntRegion intersection; nsIntRegion intersection;
intersection.And(covered, childRegion); intersection.And(covered, childRegion);

Просмотреть файл

@ -324,9 +324,9 @@ MarkLayersHidden(Layer* aLayer, const nsIntRect& aClipRect,
} }
{ {
const nsIntRect* clipRect = aLayer->GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& clipRect = aLayer->GetEffectiveClipRect();
if (clipRect) { if (clipRect) {
nsIntRect cr = *clipRect; nsIntRect cr = ParentLayerIntRect::ToUntyped(*clipRect);
// clipRect is in the container's coordinate system. Get it into the // clipRect is in the container's coordinate system. Get it into the
// global coordinate system. // global coordinate system.
if (aLayer->GetParent()) { if (aLayer->GetParent()) {
@ -404,9 +404,9 @@ ApplyDoubleBuffering(Layer* aLayer, const nsIntRect& aVisibleRect)
nsIntRect newVisibleRect(aVisibleRect); nsIntRect newVisibleRect(aVisibleRect);
{ {
const nsIntRect* clipRect = aLayer->GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& clipRect = aLayer->GetEffectiveClipRect();
if (clipRect) { if (clipRect) {
nsIntRect cr = *clipRect; nsIntRect cr = ParentLayerIntRect::ToUntyped(*clipRect);
// clipRect is in the container's coordinate system. Get it into the // clipRect is in the container's coordinate system. Get it into the
// global coordinate system. // global coordinate system.
if (aLayer->GetParent()) { if (aLayer->GetParent()) {
@ -865,7 +865,7 @@ BasicLayerManager::PaintLayer(gfxContext* aTarget,
RenderTraceScope trace("BasicLayerManager::PaintLayer", "707070"); RenderTraceScope trace("BasicLayerManager::PaintLayer", "707070");
const nsIntRect* clipRect = aLayer->GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& clipRect = aLayer->GetEffectiveClipRect();
BasicContainerLayer* container = BasicContainerLayer* container =
static_cast<BasicContainerLayer*>(aLayer->AsContainerLayer()); static_cast<BasicContainerLayer*>(aLayer->AsContainerLayer());
bool needsGroup = container && container->UseIntermediateSurface(); bool needsGroup = container && container->UseIntermediateSurface();

Просмотреть файл

@ -140,12 +140,10 @@ static void
TransformClipRect(Layer* aLayer, TransformClipRect(Layer* aLayer,
const Matrix4x4& aTransform) const Matrix4x4& aTransform)
{ {
const nsIntRect* clipRect = aLayer->AsLayerComposite()->GetShadowClipRect(); const Maybe<ParentLayerIntRect>& clipRect = aLayer->AsLayerComposite()->GetShadowClipRect();
if (clipRect) { if (clipRect) {
LayerIntRect transformed = TransformTo<LayerPixel>( ParentLayerIntRect transformed = TransformTo<ParentLayerPixel>(aTransform, *clipRect);
aTransform, LayerIntRect::FromUntyped(*clipRect)); aLayer->AsLayerComposite()->SetShadowClipRect(Some(transformed));
nsIntRect shadowClip = LayerIntRect::ToUntyped(transformed);
aLayer->AsLayerComposite()->SetShadowClipRect(&shadowClip);
} }
} }
@ -565,8 +563,8 @@ AdjustForClip(const Matrix4x4& asyncTransform, Layer* aLayer)
// then applying it to container as-is will produce incorrect results. To // then applying it to container as-is will produce incorrect results. To
// avoid this, translate the layer so that the clip rect starts at the origin, // avoid this, translate the layer so that the clip rect starts at the origin,
// apply the tree transform, and translate back. // apply the tree transform, and translate back.
if (const nsIntRect* shadowClipRect = aLayer->AsLayerComposite()->GetShadowClipRect()) { if (const Maybe<ParentLayerIntRect>& shadowClipRect = aLayer->AsLayerComposite()->GetShadowClipRect()) {
if (shadowClipRect->TopLeft() != nsIntPoint()) { // avoid a gratuitous change of basis if (shadowClipRect->TopLeft() != ParentLayerIntPoint()) { // avoid a gratuitous change of basis
result.ChangeBasis(shadowClipRect->x, shadowClipRect->y, 0); result.ChangeBasis(shadowClipRect->x, shadowClipRect->y, 0);
} }
} }
@ -589,7 +587,7 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer)
Matrix4x4 combinedAsyncTransform; Matrix4x4 combinedAsyncTransform;
bool hasAsyncTransform = false; bool hasAsyncTransform = false;
LayerMargin fixedLayerMargins(0, 0, 0, 0); LayerMargin fixedLayerMargins(0, 0, 0, 0);
Maybe<nsIntRect> clipRect = ToMaybe(aLayer->AsLayerComposite()->GetShadowClipRect()); Maybe<ParentLayerIntRect> clipRect = aLayer->AsLayerComposite()->GetShadowClipRect();
for (uint32_t i = 0; i < aLayer->GetFrameMetricsCount(); i++) { for (uint32_t i = 0; i < aLayer->GetFrameMetricsCount(); i++) {
AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController(i); AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController(i);
@ -639,15 +637,14 @@ AsyncCompositionManager::ApplyAsyncContentTransformToTree(Layer *aLayer)
// bounds at that level. // bounds at that level.
ParentLayerRect transformed = TransformTo<ParentLayerPixel>( ParentLayerRect transformed = TransformTo<ParentLayerPixel>(
(Matrix4x4(asyncTransformWithoutOverscroll) * overscrollTransform), (Matrix4x4(asyncTransformWithoutOverscroll) * overscrollTransform),
ParentLayerRect(ViewAs<ParentLayerPixel>(*clipRect))); ParentLayerRect(*clipRect));
clipRect = Some(ParentLayerIntRect::ToUntyped( clipRect = Some(RoundedOut(transformed.Intersect(metrics.mCompositionBounds)));
RoundedOut(transformed.Intersect(metrics.mCompositionBounds))));
} }
} }
if (hasAsyncTransform) { if (hasAsyncTransform) {
if (clipRect) { if (clipRect) {
aLayer->AsLayerComposite()->SetShadowClipRect(clipRect.ptr()); aLayer->AsLayerComposite()->SetShadowClipRect(clipRect);
} }
// Apply the APZ transform on top of GetLocalTransform() here (rather than // Apply the APZ transform on top of GetLocalTransform() here (rather than
// GetTransform()) in case the OMTA code in SampleAnimations already set a // GetTransform()) in case the OMTA code in SampleAnimations already set a

Просмотреть файл

@ -21,6 +21,7 @@
#include "PaintedLayerComposite.h" // for PaintedLayerComposite #include "PaintedLayerComposite.h" // for PaintedLayerComposite
#include "TiledLayerBuffer.h" // for TiledLayerComposer #include "TiledLayerBuffer.h" // for TiledLayerComposer
#include "Units.h" // for ScreenIntRect #include "Units.h" // for ScreenIntRect
#include "UnitTransforms.h" // for ViewAs
#include "gfx2DGlue.h" // for ToMatrix4x4 #include "gfx2DGlue.h" // for ToMatrix4x4
#include "gfxPrefs.h" // for gfxPrefs #include "gfxPrefs.h" // for gfxPrefs
#ifdef XP_MACOSX #ifdef XP_MACOSX
@ -234,9 +235,9 @@ LayerManagerComposite::ApplyOcclusionCulling(Layer* aLayer, nsIntRegion& aOpaque
localOpaque.Or(localOpaque, composite->GetFullyRenderedRegion()); localOpaque.Or(localOpaque, composite->GetFullyRenderedRegion());
} }
localOpaque.MoveBy(transform2d._31, transform2d._32); localOpaque.MoveBy(transform2d._31, transform2d._32);
const nsIntRect* clip = aLayer->GetEffectiveClipRect(); const Maybe<ParentLayerIntRect>& clip = aLayer->GetEffectiveClipRect();
if (clip) { if (clip) {
localOpaque.And(localOpaque, *clip); localOpaque.And(localOpaque, ParentLayerIntRect::ToUntyped(*clip));
} }
aOpaqueRegion.Or(aOpaqueRegion, localOpaque); aOpaqueRegion.Or(aOpaqueRegion, localOpaque);
} }
@ -694,7 +695,7 @@ LayerManagerComposite::Render()
mInvalidRegion.SetEmpty(); mInvalidRegion.SetEmpty();
} }
nsIntRect clipRect; ParentLayerIntRect clipRect;
Rect bounds(mRenderBounds.x, mRenderBounds.y, mRenderBounds.width, mRenderBounds.height); Rect bounds(mRenderBounds.x, mRenderBounds.y, mRenderBounds.width, mRenderBounds.height);
Rect actualBounds; Rect actualBounds;
@ -707,7 +708,7 @@ LayerManagerComposite::Render()
} else { } else {
gfx::Rect rect; gfx::Rect rect;
mCompositor->BeginFrame(invalid, nullptr, bounds, &rect, &actualBounds); mCompositor->BeginFrame(invalid, nullptr, bounds, &rect, &actualBounds);
clipRect = nsIntRect(rect.x, rect.y, rect.width, rect.height); clipRect = ParentLayerIntRect(rect.x, rect.y, rect.width, rect.height);
} }
if (actualBounds.IsEmpty()) { if (actualBounds.IsEmpty()) {
@ -729,8 +730,8 @@ LayerManagerComposite::Render()
} }
// Render our layers. // Render our layers.
RootLayer()->Prepare(RenderTargetPixel::FromUntyped(clipRect)); RootLayer()->Prepare(ViewAs<RenderTargetPixel>(clipRect, PixelCastJustification::RenderTargetIsParentLayerForRoot));
RootLayer()->RenderLayer(clipRect); RootLayer()->RenderLayer(ParentLayerIntRect::ToUntyped(clipRect));
if (!mRegionToClear.IsEmpty()) { if (!mRegionToClear.IsEmpty()) {
nsIntRegionRectIterator iter(mRegionToClear); nsIntRegionRectIterator iter(mRegionToClear);
@ -742,7 +743,7 @@ LayerManagerComposite::Render()
if (mTwoPassTmpTarget) { if (mTwoPassTmpTarget) {
MOZ_ASSERT(haveLayerEffects); MOZ_ASSERT(haveLayerEffects);
PopGroupForLayerEffects(previousTarget, clipRect, PopGroupForLayerEffects(previousTarget, ParentLayerIntRect::ToUntyped(clipRect),
grayscaleVal, invertVal, contrastVal); grayscaleVal, invertVal, contrastVal);
} }
@ -1096,7 +1097,6 @@ LayerComposite::LayerComposite(LayerManagerComposite *aManager)
: mCompositeManager(aManager) : mCompositeManager(aManager)
, mCompositor(aManager->GetCompositor()) , mCompositor(aManager->GetCompositor())
, mShadowOpacity(1.0) , mShadowOpacity(1.0)
, mUseShadowClipRect(false)
, mShadowTransformSetByAnimation(false) , mShadowTransformSetByAnimation(false)
, mDestroyed(false) , mDestroyed(false)
, mLayerComposited(false) , mLayerComposited(false)

Просмотреть файл

@ -9,6 +9,7 @@
#include <stdint.h> // for int32_t, uint32_t #include <stdint.h> // for int32_t, uint32_t
#include "GLDefs.h" // for GLenum #include "GLDefs.h" // for GLenum
#include "Layers.h" #include "Layers.h"
#include "Units.h" // for ParentLayerIntRect
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
#include "mozilla/Attributes.h" // for override #include "mozilla/Attributes.h" // for override
#include "mozilla/RefPtr.h" // for RefPtr, TemporaryRef #include "mozilla/RefPtr.h" // for RefPtr, TemporaryRef
@ -18,6 +19,7 @@
#include "mozilla/gfx/Types.h" // for SurfaceFormat #include "mozilla/gfx/Types.h" // for SurfaceFormat
#include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/CompositorTypes.h"
#include "mozilla/layers/LayersTypes.h" // for LayersBackend, etc #include "mozilla/layers/LayersTypes.h" // for LayersBackend, etc
#include "mozilla/Maybe.h" // for Maybe
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsAString.h" #include "nsAString.h"
@ -403,12 +405,9 @@ public:
mShadowOpacity = aOpacity; mShadowOpacity = aOpacity;
} }
void SetShadowClipRect(const nsIntRect* aRect) void SetShadowClipRect(const Maybe<ParentLayerIntRect>& aRect)
{ {
mUseShadowClipRect = aRect != nullptr; mShadowClipRect = aRect;
if (aRect) {
mShadowClipRect = *aRect;
}
} }
void SetShadowTransform(const gfx::Matrix4x4& aMatrix) void SetShadowTransform(const gfx::Matrix4x4& aMatrix)
@ -432,7 +431,7 @@ public:
// These getters can be used anytime. // These getters can be used anytime.
float GetShadowOpacity() { return mShadowOpacity; } float GetShadowOpacity() { return mShadowOpacity; }
const nsIntRect* GetShadowClipRect() { return mUseShadowClipRect ? &mShadowClipRect : nullptr; } const Maybe<ParentLayerIntRect>& GetShadowClipRect() { return mShadowClipRect; }
const nsIntRegion& GetShadowVisibleRegion() { return mShadowVisibleRegion; } const nsIntRegion& GetShadowVisibleRegion() { return mShadowVisibleRegion; }
const gfx::Matrix4x4& GetShadowTransform() { return mShadowTransform; } const gfx::Matrix4x4& GetShadowTransform() { return mShadowTransform; }
bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; } bool GetShadowTransformSetByAnimation() { return mShadowTransformSetByAnimation; }
@ -449,11 +448,10 @@ public:
protected: protected:
gfx::Matrix4x4 mShadowTransform; gfx::Matrix4x4 mShadowTransform;
nsIntRegion mShadowVisibleRegion; nsIntRegion mShadowVisibleRegion;
nsIntRect mShadowClipRect; Maybe<ParentLayerIntRect> mShadowClipRect;
LayerManagerComposite* mCompositeManager; LayerManagerComposite* mCompositeManager;
RefPtr<Compositor> mCompositor; RefPtr<Compositor> mCompositor;
float mShadowOpacity; float mShadowOpacity;
bool mUseShadowClipRect;
bool mShadowTransformSetByAnimation; bool mShadowTransformSetByAnimation;
bool mDestroyed; bool mDestroyed;
bool mLayerComposited; bool mLayerComposited;

Просмотреть файл

@ -327,7 +327,7 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray<Edit>&& cset,
layer->SetEventRegions(common.eventRegions()); layer->SetEventRegions(common.eventRegions());
layer->SetContentFlags(common.contentFlags()); layer->SetContentFlags(common.contentFlags());
layer->SetOpacity(common.opacity()); layer->SetOpacity(common.opacity());
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : nullptr); layer->SetClipRect(common.useClipRect() ? Some(common.clipRect()) : Nothing());
layer->SetBaseTransform(common.transform().value()); layer->SetBaseTransform(common.transform().value());
layer->SetPostScale(common.postXScale(), common.postYScale()); layer->SetPostScale(common.postXScale(), common.postYScale());
layer->SetIsFixedPosition(common.isFixedPosition()); layer->SetIsFixedPosition(common.isFixedPosition());

Просмотреть файл

@ -33,6 +33,7 @@ using struct mozilla::layers::TextureInfo from "mozilla/layers/CompositorTypes.h
using mozilla::LayerMargin from "Units.h"; using mozilla::LayerMargin from "Units.h";
using mozilla::LayerPoint from "Units.h"; using mozilla::LayerPoint from "Units.h";
using mozilla::LayerRect from "Units.h"; using mozilla::LayerRect from "Units.h";
using mozilla::ParentLayerIntRect from "Units.h";
using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h"; using mozilla::layers::ScaleMode from "mozilla/layers/LayersTypes.h";
using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h"; using mozilla::layers::EventRegions from "mozilla/layers/LayersTypes.h";
using mozilla::layers::EventRegionsOverride from "mozilla/layers/LayersTypes.h"; using mozilla::layers::EventRegionsOverride from "mozilla/layers/LayersTypes.h";
@ -204,7 +205,7 @@ struct CommonLayerAttributes {
uint32_t contentFlags; uint32_t contentFlags;
float opacity; float opacity;
bool useClipRect; bool useClipRect;
nsIntRect clipRect; ParentLayerIntRect clipRect;
bool isFixedPosition; bool isFixedPosition;
LayerPoint fixedPositionAnchor; LayerPoint fixedPositionAnchor;
LayerMargin fixedPositionMargin; LayerMargin fixedPositionMargin;

Просмотреть файл

@ -587,7 +587,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
common.opacity() = mutant->GetOpacity(); common.opacity() = mutant->GetOpacity();
common.useClipRect() = !!mutant->GetClipRect(); common.useClipRect() = !!mutant->GetClipRect();
common.clipRect() = (common.useClipRect() ? common.clipRect() = (common.useClipRect() ?
*mutant->GetClipRect() : nsIntRect()); *mutant->GetClipRect() : ParentLayerIntRect());
common.isFixedPosition() = mutant->GetIsFixedPosition(); common.isFixedPosition() = mutant->GetIsFixedPosition();
common.fixedPositionAnchor() = mutant->GetFixedPositionAnchor(); common.fixedPositionAnchor() = mutant->GetFixedPositionAnchor();
common.fixedPositionMargin() = mutant->GetFixedPositionMargins(); common.fixedPositionMargin() = mutant->GetFixedPositionMargins();

Просмотреть файл

@ -19,6 +19,7 @@
#include "base/task.h" #include "base/task.h"
#include "Layers.h" #include "Layers.h"
#include "TestLayers.h" #include "TestLayers.h"
#include "UnitTransforms.h"
#include "gfxPrefs.h" #include "gfxPrefs.h"
using namespace mozilla; using namespace mozilla;
@ -1789,7 +1790,7 @@ protected:
metrics.SetScrollableRect(aScrollableRect); metrics.SetScrollableRect(aScrollableRect);
metrics.SetScrollOffset(CSSPoint(0, 0)); metrics.SetScrollOffset(CSSPoint(0, 0));
aLayer->SetFrameMetrics(metrics); aLayer->SetFrameMetrics(metrics);
aLayer->SetClipRect(&layerBound); aLayer->SetClipRect(Some(ViewAs<ParentLayerPixel>(layerBound)));
if (!aScrollableRect.IsEqualEdges(CSSRect(-1, -1, -1, -1))) { if (!aScrollableRect.IsEqualEdges(CSSRect(-1, -1, -1, -1))) {
// The purpose of this is to roughly mimic what layout would do in the // The purpose of this is to roughly mimic what layout would do in the
// case of a scrollable frame with the event regions and clip. This lets // case of a scrollable frame with the event regions and clip. This lets

Просмотреть файл

@ -7,35 +7,38 @@
#include "FrameLayerBuilder.h" #include "FrameLayerBuilder.h"
#include "mozilla/gfx/Matrix.h"
#include "nsDisplayList.h"
#include "nsPresContext.h"
#include "nsLayoutUtils.h"
#include "Layers.h"
#include "BasicLayers.h"
#include "gfxUtils.h"
#include "nsRenderingContext.h"
#include "MaskLayerImageCache.h"
#include "nsIScrollableFrame.h"
#include "nsPrintfCString.h"
#include "LayerTreeInvalidation.h"
#include "nsSVGIntegrationUtils.h"
#include "ImageContainer.h"
#include "ActiveLayerTracker.h"
#include "gfx2DGlue.h"
#include "mozilla/LookAndFeel.h" #include "mozilla/LookAndFeel.h"
#include "nsDocShell.h" #include "mozilla/Maybe.h"
#include "nsImageFrame.h"
#include "mozilla/dom/ProfileTimelineMarkerBinding.h" #include "mozilla/dom/ProfileTimelineMarkerBinding.h"
#include "mozilla/gfx/Matrix.h"
#include "ActiveLayerTracker.h"
#include "BasicLayers.h"
#include "ImageContainer.h"
#include "LayerTreeInvalidation.h"
#include "Layers.h"
#include "MaskLayerImageCache.h"
#include "UnitTransforms.h"
#include "Units.h"
#include "gfx2DGlue.h"
#include "gfxUtils.h"
#include "nsDisplayList.h"
#include "nsDocShell.h"
#include "nsIScrollableFrame.h"
#include "nsImageFrame.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsPrintfCString.h"
#include "nsRenderingContext.h"
#include "nsSVGIntegrationUtils.h"
#include "GeckoProfiler.h"
#include "mozilla/gfx/Tools.h"
#include "mozilla/gfx/2D.h"
#include "gfxPrefs.h"
#include "LayersLogging.h"
#include "mozilla/unused.h"
#include "mozilla/ReverseIterator.h"
#include "mozilla/Move.h" #include "mozilla/Move.h"
#include "mozilla/ReverseIterator.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Tools.h"
#include "mozilla/unused.h"
#include "GeckoProfiler.h"
#include "LayersLogging.h"
#include "gfxPrefs.h"
#include <algorithm> #include <algorithm>
@ -2828,11 +2831,11 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
imageLayer->SetPostScale(mParameters.mXScale, imageLayer->SetPostScale(mParameters.mXScale,
mParameters.mYScale); mParameters.mYScale);
if (data->mItemClip.HasClip()) { if (data->mItemClip.HasClip()) {
nsIntRect clip = ScaleToNearestPixels(data->mItemClip.GetClipRect()); ParentLayerIntRect clip = ViewAs<ParentLayerPixel>(ScaleToNearestPixels(data->mItemClip.GetClipRect()));
clip.MoveBy(mParameters.mOffset); clip.MoveBy(ViewAs<ParentLayerPixel>(mParameters.mOffset));
imageLayer->SetClipRect(&clip); imageLayer->SetClipRect(Some(clip));
} else { } else {
imageLayer->SetClipRect(nullptr); imageLayer->SetClipRect(Nothing());
} }
layer = imageLayer; layer = imageLayer;
mLayerBuilder->StoreOptimizedLayerForFrame(data->mImage, mLayerBuilder->StoreOptimizedLayerForFrame(data->mImage,
@ -2849,7 +2852,7 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
nsIntRect visibleRect = data->mVisibleRegion.GetBounds(); nsIntRect visibleRect = data->mVisibleRegion.GetBounds();
visibleRect.MoveBy(-GetTranslationForPaintedLayer(data->mLayer)); visibleRect.MoveBy(-GetTranslationForPaintedLayer(data->mLayer));
colorLayer->SetBounds(visibleRect); colorLayer->SetBounds(visibleRect);
colorLayer->SetClipRect(nullptr); colorLayer->SetClipRect(Nothing());
layer = colorLayer; layer = colorLayer;
FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected color layer=%p\n", layer.get()); FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected color layer=%p\n", layer.get());
@ -2868,15 +2871,15 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
// Hide the PaintedLayer. We leave it in the layer tree so that we // Hide the PaintedLayer. We leave it in the layer tree so that we
// can find and recycle it later. // can find and recycle it later.
nsIntRect emptyRect; ParentLayerIntRect emptyRect;
data->mLayer->SetClipRect(&emptyRect); data->mLayer->SetClipRect(Some(emptyRect));
data->mLayer->SetVisibleRegion(nsIntRegion()); data->mLayer->SetVisibleRegion(nsIntRegion());
data->mLayer->InvalidateRegion(data->mLayer->GetValidRegion().GetBounds()); data->mLayer->InvalidateRegion(data->mLayer->GetValidRegion().GetBounds());
data->mLayer->SetEventRegions(EventRegions()); data->mLayer->SetEventRegions(EventRegions());
} else { } else {
layer = data->mLayer; layer = data->mLayer;
imageContainer = nullptr; imageContainer = nullptr;
layer->SetClipRect(nullptr); layer->SetClipRect(Nothing());
FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected painted layer=%p\n", layer.get()); FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected painted layer=%p\n", layer.get());
} }
@ -3508,15 +3511,15 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
nsIntRect itemDrawRect = ScaleToOutsidePixels(itemContent, snap); nsIntRect itemDrawRect = ScaleToOutsidePixels(itemContent, snap);
bool prerenderedTransform = itemType == nsDisplayItem::TYPE_TRANSFORM && bool prerenderedTransform = itemType == nsDisplayItem::TYPE_TRANSFORM &&
static_cast<nsDisplayTransform*>(item)->ShouldPrerender(mBuilder); static_cast<nsDisplayTransform*>(item)->ShouldPrerender(mBuilder);
nsIntRect clipRect; ParentLayerIntRect clipRect;
const DisplayItemClip& itemClip = item->GetClip(); const DisplayItemClip& itemClip = item->GetClip();
if (itemClip.HasClip()) { if (itemClip.HasClip()) {
itemContent.IntersectRect(itemContent, itemClip.GetClipRect()); itemContent.IntersectRect(itemContent, itemClip.GetClipRect());
clipRect = ScaleToNearestPixels(itemClip.GetClipRect()); clipRect = ViewAs<ParentLayerPixel>(ScaleToNearestPixels(itemClip.GetClipRect()));
if (!prerenderedTransform) { if (!prerenderedTransform) {
itemDrawRect.IntersectRect(itemDrawRect, clipRect); itemDrawRect.IntersectRect(itemDrawRect, ParentLayerIntRect::ToUntyped(clipRect));
} }
clipRect.MoveBy(mParameters.mOffset); clipRect.MoveBy(ViewAs<ParentLayerPixel>(mParameters.mOffset));
} }
#ifdef DEBUG #ifdef DEBUG
nsRect bounds = itemContent; nsRect bounds = itemContent;
@ -3614,7 +3617,11 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
// visible rect for the two important cases. // visible rect for the two important cases.
nscolor uniformColor = NS_RGBA(0,0,0,0); nscolor uniformColor = NS_RGBA(0,0,0,0);
nscolor* uniformColorPtr = !mayDrawOutOfOrder ? &uniformColor : nullptr; nscolor* uniformColorPtr = !mayDrawOutOfOrder ? &uniformColor : nullptr;
nsIntRect* clipPtr = itemClip.HasClip() ? &clipRect : nullptr; nsIntRect clipRectUntyped;
nsIntRect* clipPtr = itemClip.HasClip() ? &clipRectUntyped : nullptr;
if (clipPtr) {
clipRectUntyped = ParentLayerIntRect::ToUntyped(clipRect);
}
if (animatedGeometryRoot == item->Frame() && if (animatedGeometryRoot == item->Frame() &&
animatedGeometryRoot != mBuilder->RootReferenceFrame()) { animatedGeometryRoot != mBuilder->RootReferenceFrame()) {
// This is the case for scrollbar thumbs, for example. In that case the // This is the case for scrollbar thumbs, for example. In that case the
@ -3622,10 +3629,12 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
const nsIFrame* clipAnimatedGeometryRoot = const nsIFrame* clipAnimatedGeometryRoot =
mPaintedLayerDataTree.GetParentAnimatedGeometryRoot(animatedGeometryRoot); mPaintedLayerDataTree.GetParentAnimatedGeometryRoot(animatedGeometryRoot);
mPaintedLayerDataTree.AddingOwnLayer(clipAnimatedGeometryRoot, mPaintedLayerDataTree.AddingOwnLayer(clipAnimatedGeometryRoot,
clipPtr, uniformColorPtr); clipPtr,
uniformColorPtr);
} else if (prerenderedTransform) { } else if (prerenderedTransform) {
mPaintedLayerDataTree.AddingOwnLayer(animatedGeometryRoot, mPaintedLayerDataTree.AddingOwnLayer(animatedGeometryRoot,
clipPtr, uniformColorPtr); clipPtr,
uniformColorPtr);
} else { } else {
// Using itemVisibleRect here isn't perfect. itemVisibleRect can be // Using itemVisibleRect here isn't perfect. itemVisibleRect can be
// larger or smaller than the potential bounds of item's contents in // larger or smaller than the potential bounds of item's contents in
@ -3680,9 +3689,9 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
"If we have rounded rects, we must have a clip rect"); "If we have rounded rects, we must have a clip rect");
// It has its own layer. Update that layer's clip and visible rects. // It has its own layer. Update that layer's clip and visible rects.
if (itemClip.HasClip()) { if (itemClip.HasClip()) {
ownLayer->SetClipRect(&clipRect); ownLayer->SetClipRect(Some(clipRect));
} else { } else {
ownLayer->SetClipRect(nullptr); ownLayer->SetClipRect(Nothing());
} }
// rounded rectangle clipping using mask layers // rounded rectangle clipping using mask layers
@ -4225,8 +4234,8 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
} }
uint32_t baseLength = metricsArray.Length(); uint32_t baseLength = metricsArray.Length();
nsIntRect tmpClipRect; ParentLayerIntRect tmpClipRect;
const nsIntRect* layerClip = aEntry->mLayer->GetClipRect(); const ParentLayerIntRect* layerClip = aEntry->mLayer->GetClipRect().ptrOr(nullptr);
nsIFrame* fParent; nsIFrame* fParent;
for (const nsIFrame* f = aEntry->mAnimatedGeometryRoot; for (const nsIFrame* f = aEntry->mAnimatedGeometryRoot;
f != mContainerAnimatedGeometryRoot; f != mContainerAnimatedGeometryRoot;
@ -4255,7 +4264,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
scrollFrame->ComputeFrameMetrics(aEntry->mLayer, mContainerReferenceFrame, scrollFrame->ComputeFrameMetrics(aEntry->mLayer, mContainerReferenceFrame,
mParameters, &clipRect, &metricsArray); mParameters, &clipRect, &metricsArray);
if (clipRect.width >= 0) { if (clipRect.width >= 0) {
nsIntRect pixClip = ScaleToNearestPixels(clipRect); ParentLayerIntRect pixClip = ViewAs<ParentLayerPixel>(ScaleToNearestPixels(clipRect));
if (layerClip) { if (layerClip) {
tmpClipRect.IntersectRect(pixClip, *layerClip); tmpClipRect.IntersectRect(pixClip, *layerClip);
} else { } else {
@ -4267,7 +4276,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
// both CSS and scroll clipping. // both CSS and scroll clipping.
} }
} }
aEntry->mLayer->SetClipRect(layerClip); aEntry->mLayer->SetClipRect(ToMaybe(layerClip));
// Watch out for FrameMetrics copies in profiles // Watch out for FrameMetrics copies in profiles
aEntry->mLayer->SetFrameMetrics(metricsArray); aEntry->mLayer->SetFrameMetrics(metricsArray);
} }
@ -4298,9 +4307,9 @@ ContainerState::PostprocessRetainedLayers(nsIntRegion* aOpaqueRegionForContainer
if (hideAll) { if (hideAll) {
e->mVisibleRegion.SetEmpty(); e->mVisibleRegion.SetEmpty();
} else if (!e->mLayer->IsScrollbarContainer()) { } else if (!e->mLayer->IsScrollbarContainer()) {
const nsIntRect* clipRect = e->mLayer->GetClipRect(); const Maybe<ParentLayerIntRect>& clipRect = e->mLayer->GetClipRect();
if (clipRect && opaqueRegionForContainer >= 0 && if (clipRect && opaqueRegionForContainer >= 0 &&
opaqueRegions[opaqueRegionForContainer].mOpaqueRegion.Contains(*clipRect)) { opaqueRegions[opaqueRegionForContainer].mOpaqueRegion.Contains(ParentLayerIntRect::ToUntyped(*clipRect))) {
e->mVisibleRegion.SetEmpty(); e->mVisibleRegion.SetEmpty();
} else if (data) { } else if (data) {
e->mVisibleRegion.Sub(e->mVisibleRegion, data->mOpaqueRegion); e->mVisibleRegion.Sub(e->mVisibleRegion, data->mOpaqueRegion);
@ -4333,9 +4342,9 @@ ContainerState::PostprocessRetainedLayers(nsIntRegion* aOpaqueRegionForContainer
} }
nsIntRegion clippedOpaque = e->mOpaqueRegion; nsIntRegion clippedOpaque = e->mOpaqueRegion;
const nsIntRect* clipRect = e->mLayer->GetClipRect(); const Maybe<ParentLayerIntRect>& clipRect = e->mLayer->GetClipRect();
if (clipRect) { if (clipRect) {
clippedOpaque.AndWith(*clipRect); clippedOpaque.AndWith(ParentLayerIntRect::ToUntyped(*clipRect));
} }
data->mOpaqueRegion.Or(data->mOpaqueRegion, clippedOpaque); data->mOpaqueRegion.Or(data->mOpaqueRegion, clippedOpaque);
if (e->mHideAllLayersBelow) { if (e->mHideAllLayersBelow) {

Просмотреть файл

@ -22,6 +22,8 @@ namespace mozilla {
enum class PixelCastJustification : uint8_t { enum class PixelCastJustification : uint8_t {
// For the root layer, Screen Pixel = Parent Layer Pixel. // For the root layer, Screen Pixel = Parent Layer Pixel.
ScreenIsParentLayerForRoot, ScreenIsParentLayerForRoot,
// For the root layer, Render Target Pixel = Parent Layer Pixel.
RenderTargetIsParentLayerForRoot,
// For the root composition size we want to view it as layer pixels in any layer // For the root composition size we want to view it as layer pixels in any layer
ParentLayerToLayerForRootComposition, ParentLayerToLayerForRootComposition,
// The Layer coordinate space for one layer is the ParentLayer coordinate // The Layer coordinate space for one layer is the ParentLayer coordinate
@ -54,6 +56,14 @@ template <class TargetUnits, class SourceUnits>
gfx::IntPointTyped<TargetUnits> ViewAs(const gfx::IntPointTyped<SourceUnits>& aPoint, PixelCastJustification) { gfx::IntPointTyped<TargetUnits> ViewAs(const gfx::IntPointTyped<SourceUnits>& aPoint, PixelCastJustification) {
return gfx::IntPointTyped<TargetUnits>(aPoint.x, aPoint.y); return gfx::IntPointTyped<TargetUnits>(aPoint.x, aPoint.y);
} }
template <class TargetUnits, class SourceUnits>
gfx::RectTyped<TargetUnits> ViewAs(const gfx::RectTyped<SourceUnits>& aRect, PixelCastJustification) {
return gfx::RectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}
template <class TargetUnits, class SourceUnits>
gfx::IntRectTyped<TargetUnits> ViewAs(const gfx::IntRectTyped<SourceUnits>& aRect, PixelCastJustification) {
return gfx::IntRectTyped<TargetUnits>(aRect.x, aRect.y, aRect.width, aRect.height);
}
template <class NewTargetUnits, class OldTargetUnits, class SourceUnits> template <class NewTargetUnits, class OldTargetUnits, class SourceUnits>
gfx::ScaleFactor<SourceUnits, NewTargetUnits> ViewTargetAs( gfx::ScaleFactor<SourceUnits, NewTargetUnits> ViewTargetAs(
const gfx::ScaleFactor<SourceUnits, OldTargetUnits>& aScaleFactor, const gfx::ScaleFactor<SourceUnits, OldTargetUnits>& aScaleFactor,