Bug 1274284 - When snapshotting child processes, make sure to offset the rect accordingly. r?mattwoodrow
MozReview-Commit-ID: FBi0W1Ay987
--- a/gfx/layers/Layers.h
+++ b/gfx/layers/Layers.h
@@ -2609,17 +2609,17 @@ public:
{
mFirstChild = mLastChild = nullptr;
aLayer->SetParent(nullptr);
}
// These getters can be used anytime.
virtual RefLayer* AsRefLayer() override { return this; }
- virtual int64_t GetReferentId() { return mId; }
+ virtual uint64_t GetReferentId() { return mId; }
/**
* DRAWING PHASE ONLY
*/
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) override;
MOZ_LAYER_DECL_NAME("RefLayer", TYPE_REF)
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -1002,18 +1002,36 @@ LayerTransactionParent::RecvChildAsyncMe
}
return true;
}
bool
LayerTransactionParent::RecvMakeSnapshot(const SurfaceDescriptor& aInSnapshot,
const gfx::IntRect& aRect)
{
- CompositorBridgeParent* compositor = CompositorBridgeParent::GetCompositor(GetId());
- return compositor ? compositor->MakeSnapshot(aInSnapshot, aRect) : false;
+ uint64_t id = GetId();
+ CompositorBridgeParent* parent = CompositorBridgeParent::GetCompositor(id);
+ if (parent) {
+ gfx::IntRect adjustedRect = aRect;
+ if (parent->RootLayerTreeId() != id) {
+ // We're trying to snapshot a child process, so move |aRect| by the
+ // transform on the corresponding RefLayer
+ Layer* treeRoot = mLayerManager->GetRoot();
+ Layer* ref = DepthFirstSearch<ForwardIterator>(treeRoot,
+ [id](Layer* aLayer) {
+ return (aLayer->AsRefLayer() && aLayer->AsRefLayer()->GetReferentId() == id);
+ });
+ if (ref) {
+ adjustedRect = RoundedToInt(
+ ref->GetEffectiveTransform().TransformBounds(gfx::Rect(adjustedRect)));
+ }
+ }
+ return parent->MakeSnapshot(aInSnapshot, adjustedRect);
+ }
+ return false;
}
void
LayerTransactionParent::ActorDestroy(ActorDestroyReason why)
{
}
bool