Skip to content

Commit

Permalink
Bug 1220873 - Make Layer::mVisibleRegion a LayerIntRegion. r=botond
Browse files Browse the repository at this point in the history
--HG--
extra : source : dc46048f7a9e9cc008c97e2d9e0a100944743055
extra : amend_source : 63783bc076e5969ebacdc8c74f9b5194a1891d9e
  • Loading branch information
sidhus11 committed Nov 29, 2015
1 parent 4c4002a commit cfa8942
Show file tree
Hide file tree
Showing 39 changed files with 98 additions and 95 deletions.
4 changes: 2 additions & 2 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,7 @@ CheckLeafLayers(Layer* aLayer, const nsIntPoint& aOffset, nsIntRegion* aCoveredR
child = child->GetNextSibling();
}
} else {
nsIntRegion rgn = aLayer->GetVisibleRegion();
nsIntRegion rgn = aLayer->GetVisibleRegion().ToUnknownRegion();
rgn.MoveBy(offset);
nsIntRegion tmp;
tmp.And(rgn, *aCoveredRegion);
Expand Down Expand Up @@ -2603,7 +2603,7 @@ nsDOMWindowUtils::LeafLayersPartitionWindow(bool* aResult)
if (!CheckLeafLayers(root, offset, &coveredRegion)) {
*aResult = false;
}
if (!coveredRegion.IsEqual(root->GetVisibleRegion())) {
if (!coveredRegion.IsEqual(root->GetVisibleRegion().ToUnknownRegion())) {
*aResult = false;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion embedding/browser/nsWebBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ nsWebBrowser::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion)
RefPtr<PaintedLayer> root = layerManager->CreatePaintedLayer();
if (root) {
nsIntRect dirtyRect = aRegion.GetBounds();
root->SetVisibleRegion(dirtyRect);
root->SetVisibleRegion(LayerIntRegion::FromUnknownRegion(dirtyRect));
layerManager->SetRoot(root);
}

Expand Down
8 changes: 5 additions & 3 deletions gfx/ipc/GfxMessageUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,11 @@ struct RegionParamTraits
}
};

template<>
struct ParamTraits<nsIntRegion>
: RegionParamTraits<nsIntRegion, mozilla::gfx::IntRect, nsIntRegionRectIterator>
template<class Units>
struct ParamTraits<mozilla::gfx::IntRegionTyped<Units>>
: RegionParamTraits<mozilla::gfx::IntRegionTyped<Units>,
mozilla::gfx::IntRectTyped<Units>,
typename mozilla::gfx::IntRegionTyped<Units>::RectIterator>
{};

template<>
Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/LayerMetricsWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ class MOZ_STACK_CLASS LayerMetricsWrapper {
return nullptr;
}

nsIntRegion GetVisibleRegion() const
LayerIntRegion GetVisibleRegion() const
{
MOZ_ASSERT(IsValid());

if (AtBottomLayer()) {
return mLayer->GetVisibleRegion();
}
nsIntRegion region = mLayer->GetVisibleRegion();
LayerIntRegion region = mLayer->GetVisibleRegion();
region.Transform(mLayer->GetTransform());
return region;
}
Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/LayerSorter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ static gfxFloat RecoverZDepth(const Matrix4x4& aTransform, const gfxPoint& aPoin
* unsolved without changing our rendering code.
*/
static LayerSortOrder CompareDepth(Layer* aOne, Layer* aTwo) {
gfxRect ourRect = ThebesRect(aOne->GetEffectiveVisibleRegion().GetBounds());
gfxRect otherRect = ThebesRect(aTwo->GetEffectiveVisibleRegion().GetBounds());
gfxRect ourRect = ThebesRect(aOne->GetEffectiveVisibleRegion().ToUnknownRegion().GetBounds());
gfxRect otherRect = ThebesRect(aTwo->GetEffectiveVisibleRegion().ToUnknownRegion().GetBounds());

MOZ_ASSERT(aOne->GetParent() && aOne->GetParent()->Extend3DContext() &&
aTwo->GetParent() && aTwo->GetParent()->Extend3DContext());
Expand Down
14 changes: 7 additions & 7 deletions gfx/layers/LayerTreeInvalidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ NotifySubdocumentInvalidationRecursive(Layer* aLayer, NotifySubDocInvalidationFu
NotifySubdocumentInvalidationRecursive(child, aCallback);
}

aCallback(container, container->GetVisibleRegion());
aCallback(container, container->GetVisibleRegion().ToUnknownRegion());
}

struct LayerPropertiesBase : public LayerProperties
{
explicit LayerPropertiesBase(Layer* aLayer)
: mLayer(aLayer)
, mMaskLayer(nullptr)
, mVisibleRegion(aLayer->GetVisibleRegion())
, mVisibleRegion(aLayer->GetVisibleRegion().ToUnknownRegion())
, mInvalidRegion(aLayer->GetInvalidRegion())
, mPostXScale(aLayer->GetPostXScale())
, mPostYScale(aLayer->GetPostYScale())
Expand Down Expand Up @@ -235,13 +235,13 @@ struct LayerPropertiesBase : public LayerProperties

IntRect NewTransformedBounds()
{
return TransformRect(mLayer->GetVisibleRegion().GetBounds(),
return TransformRect(mLayer->GetVisibleRegion().ToUnknownRegion().GetBounds(),
GetTransformForInvalidation(mLayer));
}

IntRect OldTransformedBounds()
{
return TransformRect(mVisibleRegion.GetBounds(), mTransform);
return TransformRect(mVisibleRegion.ToUnknownRegion().GetBounds(), mTransform);
}

virtual nsIntRegion ComputeChangeInternal(NotifySubDocInvalidationFunc aCallback,
Expand Down Expand Up @@ -347,7 +347,7 @@ struct ContainerLayerProperties : public LayerPropertiesBase
}
if (invalidateChildsCurrentArea) {
aGeometryChanged = true;
AddTransformedRegion(result, child->GetVisibleRegion(),
AddTransformedRegion(result, child->GetVisibleRegion().ToUnknownRegion(),
GetTransformForInvalidation(child));
if (aCallback) {
NotifySubdocumentInvalidationRecursive(child, aCallback);
Expand Down Expand Up @@ -454,7 +454,7 @@ struct ImageLayerProperties : public LayerPropertiesBase
{
ImageLayer* imageLayer = static_cast<ImageLayer*>(mLayer.get());

if (!imageLayer->GetVisibleRegion().IsEqual(mVisibleRegion)) {
if (!imageLayer->GetVisibleRegion().ToUnknownRegion().IsEqual(mVisibleRegion)) {
aGeometryChanged = true;
IntRect result = NewTransformedBounds();
result = result.Union(OldTransformedBounds());
Expand Down Expand Up @@ -596,7 +596,7 @@ LayerPropertiesBase::ComputeDifferences(Layer* aRoot, NotifySubDocInvalidationFu
} else {
ClearInvalidations(aRoot);
}
IntRect result = TransformRect(aRoot->GetVisibleRegion().GetBounds(),
IntRect result = TransformRect(aRoot->GetVisibleRegion().ToUnknownRegion().GetBounds(),
aRoot->GetLocalTransform());
result = result.Union(OldTransformedBounds());
if (aGeometryChanged != nullptr) {
Expand Down
18 changes: 9 additions & 9 deletions gfx/layers/Layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ Layer::GetEffectiveClipRect()
return GetClipRect();
}

const nsIntRegion&
const LayerIntRegion&
Layer::GetEffectiveVisibleRegion()
{
if (LayerComposite* shadow = AsLayerComposite()) {
Expand Down Expand Up @@ -1023,7 +1023,7 @@ Layer::GetVisibleRegionRelativeToRootLayer(nsIntRegion& aResult,
}

IntPoint offset;
aResult = GetEffectiveVisibleRegion();
aResult = GetEffectiveVisibleRegion().ToUnknownRegion();
for (Layer* layer = this; layer; layer = layer->GetParent()) {
gfx::Matrix matrix;
if (!layer->GetLocalTransform().Is2D(&matrix) ||
Expand Down Expand Up @@ -1060,7 +1060,7 @@ Layer::GetVisibleRegionRelativeToRootLayer(nsIntRegion& aResult,
// Retreive the translation from sibling to |layer|. The accumulated
// visible region is currently oriented with |layer|.
IntPoint siblingOffset = RoundedToInt(siblingMatrix.GetTranslation());
nsIntRegion siblingVisibleRegion(sibling->GetEffectiveVisibleRegion());
nsIntRegion siblingVisibleRegion(sibling->GetEffectiveVisibleRegion().ToUnknownRegion());
// Translate the siblings region to |layer|'s origin.
siblingVisibleRegion.MoveBy(-siblingOffset.x, -siblingOffset.y);
// Apply the sibling's clip.
Expand Down Expand Up @@ -1894,7 +1894,7 @@ Layer::PrintInfo(std::stringstream& aStream, const char* aPrefix)
AppendToString(aStream, mLayerBounds, " [bounds=", "]");
}
if (!mVisibleRegion.IsEmpty()) {
AppendToString(aStream, mVisibleRegion, " [visible=", "]");
AppendToString(aStream, mVisibleRegion.ToUnknownRegion(), " [visible=", "]");
} else {
aStream << " [not visible]";
}
Expand Down Expand Up @@ -2013,7 +2013,7 @@ Layer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
DumpTransform(s->mutable_transform(), lc->GetShadowTransform());
}
if (!lc->GetShadowVisibleRegion().IsEmpty()) {
DumpRegion(s->mutable_vregion(), lc->GetShadowVisibleRegion());
DumpRegion(s->mutable_vregion(), lc->GetShadowVisibleRegion().ToUnknownRegion());
}
}
// Clip
Expand All @@ -2025,8 +2025,8 @@ Layer::DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent)
DumpTransform(layer->mutable_transform(), mTransform);
}
// Visible region
if (!mVisibleRegion.IsEmpty()) {
DumpRegion(layer->mutable_vregion(), mVisibleRegion);
if (!mVisibleRegion.ToUnknownRegion().IsEmpty()) {
DumpRegion(layer->mutable_vregion(), mVisibleRegion.ToUnknownRegion());
}
// EventRegions
if (!mEventRegions.IsEmpty()) {
Expand Down Expand Up @@ -2422,7 +2422,7 @@ PrintInfo(std::stringstream& aStream, LayerComposite* aLayerComposite)
AppendToString(aStream, aLayerComposite->GetShadowTransform(), " [shadow-transform=", "]");
}
if (!aLayerComposite->GetShadowVisibleRegion().IsEmpty()) {
AppendToString(aStream, aLayerComposite->GetShadowVisibleRegion(), " [shadow-visible=", "]");
AppendToString(aStream, aLayerComposite->GetShadowVisibleRegion().ToUnknownRegion(), " [shadow-visible=", "]");
}
}

Expand All @@ -2435,7 +2435,7 @@ SetAntialiasingFlags(Layer* aLayer, DrawTarget* aTarget)
return;
}

const IntRect& bounds = aLayer->GetVisibleRegion().GetBounds();
const IntRect& bounds = aLayer->GetVisibleRegion().ToUnknownRegion().GetBounds();
gfx::Rect transformedBounds = aTarget->GetTransform().TransformBounds(gfx::Rect(Float(bounds.x), Float(bounds.y),
Float(bounds.width), Float(bounds.height)));
transformedBounds.RoundOut();
Expand Down
12 changes: 6 additions & 6 deletions gfx/layers/Layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ class Layer {
* visible region will be ignored. So if a layer draws outside the bounds
* of its visible region, it needs to ensure that what it draws is valid.
*/
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
virtual void SetVisibleRegion(const LayerIntRegion& aRegion)
{
if (!mVisibleRegion.IsEqual(aRegion)) {
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) VisibleRegion was %s is %s", this,
Expand Down Expand Up @@ -1261,7 +1261,7 @@ class Layer {
const Maybe<ParentLayerIntRect>& GetClipRect() const { return mClipRect; }
uint32_t GetContentFlags() { return mContentFlags; }
const gfx::IntRect& GetLayerBounds() const { return mLayerBounds; }
const nsIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
const LayerIntRegion& GetVisibleRegion() const { return mVisibleRegion; }
const FrameMetrics& GetFrameMetrics(uint32_t aIndex) const;
uint32_t GetFrameMetricsCount() const { return mFrameMetrics.Length(); }
const nsTArray<FrameMetrics>& GetAllFrameMetrics() { return mFrameMetrics; }
Expand Down Expand Up @@ -1473,7 +1473,7 @@ class Layer {
// values that should be used when drawing this layer to screen,
// accounting for this layer possibly being a shadow.
const Maybe<ParentLayerIntRect>& GetEffectiveClipRect();
const nsIntRegion& GetEffectiveVisibleRegion();
const LayerIntRegion& GetEffectiveVisibleRegion();

bool Extend3DContext() {
return GetContentFlags() & CONTENT_EXTEND_3D_CONTEXT;
Expand Down Expand Up @@ -1644,7 +1644,7 @@ class Layer {
/**
* Mark the entirety of the layer's visible region as being invalid.
*/
void SetInvalidRectToVisibleRegion() { mInvalidRegion = GetVisibleRegion(); }
void SetInvalidRectToVisibleRegion() { mInvalidRegion = GetVisibleRegion().ToUnknownRegion(); }

/**
* Adds to the current invalid rect.
Expand Down Expand Up @@ -1787,7 +1787,7 @@ class Layer {
nsTArray<RefPtr<Layer>> mAncestorMaskLayers;
gfx::UserData mUserData;
gfx::IntRect mLayerBounds;
nsIntRegion mVisibleRegion;
LayerIntRegion mVisibleRegion;
nsTArray<FrameMetrics> mFrameMetrics;
EventRegions mEventRegions;
gfx::Matrix4x4 mTransform;
Expand Down Expand Up @@ -2088,7 +2088,7 @@ class ContainerLayer : public Layer {
RenderTargetIntRect GetIntermediateSurfaceRect()
{
NS_ASSERTION(mUseIntermediateSurface, "Must have intermediate surface");
return RenderTargetIntRect::FromUnknownRect(GetEffectiveVisibleRegion().GetBounds());
return RenderTargetIntRect::FromUnknownRect(GetEffectiveVisibleRegion().ToUnknownRegion().GetBounds());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/ReadbackProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ FindBackgroundLayer(ReadbackLayer* aLayer, nsIntPoint* aOffset)

nsIntPoint backgroundOffset(int32_t(backgroundTransform._31), int32_t(backgroundTransform._32));
IntRect rectInBackground(transformOffset - backgroundOffset, aLayer->GetSize());
const nsIntRegion& visibleRegion = l->GetEffectiveVisibleRegion();
const nsIntRegion visibleRegion = l->GetEffectiveVisibleRegion().ToUnknownRegion();
if (!visibleRegion.Intersects(rectInBackground))
continue;
// Since l is present in the background, from here on we either choose l
Expand Down
8 changes: 4 additions & 4 deletions gfx/layers/RotatedBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ RotatedContentBuffer::DrawTo(PaintedLayer* aLayer,
// Also clip to the visible region if we're told to.
if (!aLayer->GetValidRegion().Contains(BufferRect()) ||
(ToData(aLayer)->GetClipToVisibleRegion() &&
!aLayer->GetVisibleRegion().Contains(BufferRect())) ||
IsClippingCheap(aTarget, aLayer->GetEffectiveVisibleRegion())) {
!aLayer->GetVisibleRegion().ToUnknownRegion().Contains(BufferRect())) ||
IsClippingCheap(aTarget, aLayer->GetEffectiveVisibleRegion().ToUnknownRegion())) {
// We don't want to draw invalid stuff, so we need to clip. Might as
// well clip to the smallest area possible --- the visible region.
// Bug 599189 if there is a non-integer-translation transform in aTarget,
// we might sample pixels outside GetEffectiveVisibleRegion(), which is wrong
// and may cause gray lines.
gfxUtils::ClipToRegion(aTarget, aLayer->GetEffectiveVisibleRegion());
gfxUtils::ClipToRegion(aTarget, aLayer->GetEffectiveVisibleRegion().ToUnknownRegion());
clipped = true;
}

Expand Down Expand Up @@ -454,7 +454,7 @@ RotatedContentBuffer::BeginPaint(PaintedLayer* aLayer,

while (true) {
mode = aLayer->GetSurfaceMode();
neededRegion = aLayer->GetVisibleRegion();
neededRegion = aLayer->GetVisibleRegion().ToUnknownRegion();
canReuseBuffer &= BufferSizeOkFor(neededRegion.GetBounds().Size());
result.mContentType = layerContentType;

Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/apz/test/gtest/TestAsyncPanZoomController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ class APZCTreeManagerTester : public ::testing::Test {
if (aScrollId == FrameMetrics::START_SCROLL_ID) {
metrics.SetIsLayersIdRoot(true);
}
IntRect layerBound = aLayer->GetVisibleRegion().GetBounds();
IntRect layerBound = aLayer->GetVisibleRegion().ToUnknownRegion().GetBounds();
metrics.SetCompositionBounds(ParentLayerRect(layerBound.x, layerBound.y,
layerBound.width, layerBound.height));
metrics.SetScrollableRect(aScrollableRect);
Expand Down Expand Up @@ -2755,7 +2755,7 @@ TEST_F(APZHitTestingTester, Bug1148350) {
}
mcc->AdvanceByMillis(100);

layers[0]->SetVisibleRegion(nsIntRegion(IntRect(0,50,200,150)));
layers[0]->SetVisibleRegion(LayerIntRegion(LayerIntRect(0,50,200,150)));
layers[0]->SetBaseTransform(Matrix4x4::Translation(0, 50, 0));
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);

Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/basic/BasicCanvasLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BasicCanvasLayer : public CopyableCanvasLayer,
CopyableCanvasLayer(aLayerManager, static_cast<BasicImplData*>(this))
{ }

virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override
{
NS_ASSERTION(BasicManager()->InConstruction(),
"Can only set properties in construction phase");
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/basic/BasicColorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BasicColorLayer : public ColorLayer, public BasicImplData {
}

public:
virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override
{
NS_ASSERTION(BasicManager()->InConstruction(),
"Can only set properties in construction phase");
Expand Down
4 changes: 2 additions & 2 deletions gfx/layers/basic/BasicContainerLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect)
return false;

nsIntPoint offset(int32_t(transform._31), int32_t(transform._32));
gfx::IntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().GetBounds() + offset);
gfx::IntRect rect = aInRect.Intersect(GetEffectiveVisibleRegion().ToUnknownRegion().GetBounds() + offset);
nsIntRegion covered;

for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
Expand All @@ -121,7 +121,7 @@ BasicContainerLayer::ChildrenPartitionVisibleRegion(const gfx::IntRect& aInRect)
ThebesMatrix(childTransform).HasNonIntegerTranslation() ||
l->GetEffectiveOpacity() != 1.0)
return false;
nsIntRegion childRegion = l->GetEffectiveVisibleRegion();
nsIntRegion childRegion = l->GetEffectiveVisibleRegion().ToUnknownRegion();
childRegion.MoveBy(int32_t(childTransform._31), int32_t(childTransform._32));
childRegion.And(childRegion, rect);
if (l->GetClipRect()) {
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/basic/BasicContainerLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BasicContainerLayer : public ContainerLayer, public BasicImplData {
virtual ~BasicContainerLayer();

public:
virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override
{
NS_ASSERTION(BasicManager()->InConstruction(),
"Can only set properties in construction phase");
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/basic/BasicImageLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BasicImageLayer : public ImageLayer, public BasicImplData {
}

public:
virtual void SetVisibleRegion(const nsIntRegion& aRegion) override
virtual void SetVisibleRegion(const LayerIntRegion& aRegion) override
{
NS_ASSERTION(BasicManager()->InConstruction(),
"Can only set properties in construction phase");
Expand Down
Loading

0 comments on commit cfa8942

Please sign in to comment.