Bug 1312059 - Stop passing the CompositorBridgeParent into the APZCTreeManager; instead the necessary subinterfaces can be obtained via the LayerTreeState. r=botond

MozReview-Commit-ID: 3N8vC3l3jfV
This commit is contained in:
Kartikaya Gupta 2016-10-24 15:12:57 -04:00
Родитель 98051ec8f2
Коммит 3af5c36a88
10 изменённых файлов: 61 добавлений и 45 удалений

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

@ -56,10 +56,10 @@ typedef mozilla::gfx::Matrix4x4 Matrix4x4;
float APZCTreeManager::sDPI = 160.0;
struct APZCTreeManager::TreeBuildingState {
TreeBuildingState(CompositorBridgeParent* aCompositor,
TreeBuildingState(const CompositorBridgeParent::LayerTreeState* aLayerTreeState,
bool aIsFirstPaint, uint64_t aOriginatingLayersId,
APZTestData* aTestData, uint32_t aPaintSequence)
: mCompositor(aCompositor)
: mLayerTreeState(aLayerTreeState)
, mIsFirstPaint(aIsFirstPaint)
, mOriginatingLayersId(aOriginatingLayersId)
, mPaintLogger(aTestData, aPaintSequence)
@ -67,7 +67,7 @@ struct APZCTreeManager::TreeBuildingState {
}
// State that doesn't change as we recurse in the tree building
CompositorBridgeParent* const mCompositor;
const CompositorBridgeParent::LayerTreeState* mLayerTreeState;
const bool mIsFirstPaint;
const uint64_t mOriginatingLayersId;
const APZPaintLogHelper mPaintLogger;
@ -212,7 +212,7 @@ APZCTreeManager::SetAllowedTouchBehavior(uint64_t aInputBlockId,
}
void
APZCTreeManager::UpdateHitTestingTree(CompositorBridgeParent* aCompositor,
APZCTreeManager::UpdateHitTestingTree(uint64_t aRootLayerTreeId,
Layer* aRoot,
bool aIsFirstPaint,
uint64_t aOriginatingLayersId,
@ -232,7 +232,10 @@ APZCTreeManager::UpdateHitTestingTree(CompositorBridgeParent* aCompositor,
}
}
TreeBuildingState state(aCompositor, aIsFirstPaint, aOriginatingLayersId,
const CompositorBridgeParent::LayerTreeState* treeState =
CompositorBridgeParent::GetIndirectShadowTree(aRootLayerTreeId);
MOZ_ASSERT(treeState);
TreeBuildingState state(treeState, aIsFirstPaint, aOriginatingLayersId,
testData, aPaintSequenceNumber);
// We do this business with collecting the entire tree into an array because otherwise
@ -259,9 +262,7 @@ APZCTreeManager::UpdateHitTestingTree(CompositorBridgeParent* aCompositor,
std::stack<gfx::Matrix4x4> ancestorTransforms;
HitTestingTreeNode* parent = nullptr;
HitTestingTreeNode* next = nullptr;
// aCompositor is null in gtest scenarios
uint64_t layersId = aCompositor ? aCompositor->RootLayerTreeId() : 0;
uint64_t layersId = aRootLayerTreeId;
ancestorTransforms.push(Matrix4x4());
mApzcTreeLog << "[start]\n";
@ -549,12 +550,13 @@ APZCTreeManager::PrepareNodeForLayer(const LayerMetricsWrapper& aLayer,
// a destroyed APZC and so we need to throw that out and make a new one.
bool newApzc = (apzc == nullptr || apzc->IsDestroyed());
if (newApzc) {
MOZ_ASSERT(aState.mLayerTreeState);
apzc = NewAPZCInstance(aLayersId, state->mController);
apzc->SetCompositorController(aState.mCompositor);
apzc->SetCompositorController(aState.mLayerTreeState->GetCompositorController());
if (state->mCrossProcessParent) {
apzc->SetMetricsSharingController(state->CrossProcessSharingController());
} else {
apzc->SetMetricsSharingController(aState.mCompositor);
apzc->SetMetricsSharingController(aState.mLayerTreeState->InProcessSharingController());
}
MOZ_ASSERT(node == nullptr);
node = new HitTestingTreeNode(apzc, true, aLayersId);

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

@ -107,8 +107,8 @@ public:
*
* This must be called on the compositor thread as it walks the layer tree.
*
* @param aCompositor A pointer to the compositor parent instance that owns
* this APZCTreeManager
* @param aRootLayerTreeId The layer tree ID of the root layer corresponding
* to this APZCTreeManager
* @param aRoot The root of the (full) layer tree
* @param aFirstPaintLayersId The layers id of the subtree to which aIsFirstPaint
* applies.
@ -121,7 +121,7 @@ public:
* process' layer subtree has its own sequence
* numbers.
*/
void UpdateHitTestingTree(CompositorBridgeParent* aCompositor,
void UpdateHitTestingTree(uint64_t aRootLayerTreeId,
Layer* aRoot,
bool aIsFirstPaint,
uint64_t aOriginatingLayersId,

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

@ -42,7 +42,7 @@ protected:
layers[2]->SetEventRegions(regions);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
rootApzc = ApzcOf(root);
}
@ -63,7 +63,7 @@ protected:
layers[1]->SetEventRegions(regions);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
rootApzc = ApzcOf(root);
}
@ -97,7 +97,7 @@ protected:
layers[2]->SetEventRegions(regions);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
rootApzc = ApzcOf(root);
}
@ -119,7 +119,7 @@ protected:
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
}
void CreateBug1117712LayerTree() {
@ -156,7 +156,7 @@ protected:
layers[3]->SetEventRegions(regions);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
}
};
@ -229,7 +229,7 @@ TEST_F(APZEventRegionsTester, Obscuration) {
CreateObscuringLayerTree();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
TestAsyncPanZoomController* parent = ApzcOf(layers[1]);
TestAsyncPanZoomController* child = ApzcOf(layers[2]);

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

@ -117,7 +117,7 @@ TEST_F(APZHitTestingTester, HitTesting1) {
// Now we have a root APZC that will match the page
SetScrollableFrameMetrics(root, FrameMetrics::START_SCROLL_ID);
manager->UpdateHitTestingTree(nullptr, root, false, 0, paintSequenceNumber++);
manager->UpdateHitTestingTree(0, root, false, 0, paintSequenceNumber++);
hit = GetTargetAPZC(ScreenPoint(15, 15));
EXPECT_EQ(ApzcOf(root), hit.get());
// expect hit point at LayerIntPoint(15, 15)
@ -126,7 +126,7 @@ TEST_F(APZHitTestingTester, HitTesting1) {
// Now we have a sub APZC with a better fit
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 1);
manager->UpdateHitTestingTree(nullptr, root, false, 0, paintSequenceNumber++);
manager->UpdateHitTestingTree(0, root, false, 0, paintSequenceNumber++);
EXPECT_NE(ApzcOf(root), ApzcOf(layers[3]));
hit = GetTargetAPZC(ScreenPoint(25, 25));
EXPECT_EQ(ApzcOf(layers[3]), hit.get());
@ -141,7 +141,7 @@ TEST_F(APZHitTestingTester, HitTesting1) {
// Now test hit testing when we have two scrollable layers
SetScrollableFrameMetrics(layers[4], FrameMetrics::START_SCROLL_ID + 2);
manager->UpdateHitTestingTree(nullptr, root, false, 0, paintSequenceNumber++);
manager->UpdateHitTestingTree(0, root, false, 0, paintSequenceNumber++);
hit = GetTargetAPZC(ScreenPoint(15, 15));
EXPECT_EQ(ApzcOf(layers[4]), hit.get());
// expect hit point at LayerIntPoint(15, 15)
@ -173,7 +173,7 @@ TEST_F(APZHitTestingTester, HitTesting2) {
CreateHitTesting2LayerTree();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
// At this point, the following holds (all coordinates in screen pixels):
// layers[0] has content from (0,0)-(200,200), clipped by composition bounds (0,0)-(100,100)
@ -280,7 +280,7 @@ TEST_F(APZHitTestingTester, HitTesting2) {
TEST_F(APZHitTestingTester, ComplexMultiLayerTree) {
CreateComplexMultiLayerTree();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
/* The layer tree looks like this:
@ -370,7 +370,7 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnNewInputBlock) {
CreateSimpleScrollingLayer();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
TestAsyncPanZoomController* apzcroot = ApzcOf(root);
// At this point, the following holds (all coordinates in screen pixels):
@ -435,7 +435,7 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnWheelEvents) {
CreateSimpleScrollingLayer();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
TestAsyncPanZoomController* apzcroot = ApzcOf(root);
EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtLeast(3));
@ -463,7 +463,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) {
CreateSimpleScrollingLayer();
DisableApzOn(root);
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
TestAsyncPanZoomController* apzcroot = ApzcOf(root);
ScreenPoint origin(100, 50);
@ -504,7 +504,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) {
TEST_F(APZHitTestingTester, Bug1148350) {
CreateBug1148350LayerTree();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
MockFunction<void(std::string checkPointName)> check;
{
@ -528,7 +528,7 @@ TEST_F(APZHitTestingTester, Bug1148350) {
layers[0]->SetVisibleRegion(LayerIntRegion(LayerIntRect(0,50,200,150)));
layers[0]->SetBaseTransform(Matrix4x4::Translation(0, 50, 0));
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
TouchUp(manager, ScreenIntPoint(100, 100), mcc->Time());
mcc->RunThroughDelayedTasks();
@ -567,7 +567,7 @@ TEST_F(APZHitTestingTester, HitTestingRespectsScrollClip_Bug1257288) {
// Build the hit testing tree.
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
// Pan on a region that's inside layers[2]'s layer clip, but outside
// its subframe metadata's scroll clip.

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

@ -14,7 +14,7 @@ TEST_F(APZCTreeManagerTester, WheelInterruptedByMouseDrag) {
// Set up a scrollable layer
CreateSimpleScrollingLayer();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
RefPtr<TestAsyncPanZoomController> apzc = ApzcOf(root);
uint64_t dragBlockId = 0;

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

@ -24,7 +24,7 @@ protected:
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 100, 100));
SetScrollHandoff(layers[1], root);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
rootApzc = ApzcOf(root);
rootApzc->GetFrameMetrics().SetIsRootContent(true); // make root APZC zoomable
}
@ -45,7 +45,7 @@ protected:
// No ScopedLayerTreeRegistration as that just needs to be done once per test
// and this is the second layer tree for a particular test.
MOZ_ASSERT(registration);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
rootApzc = ApzcOf(root);
}
@ -69,7 +69,7 @@ protected:
SetScrollHandoff(layers[2], layers[1]);
SetScrollHandoff(layers[4], layers[3]);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
}
void CreateScrollgrabLayerTree(bool makeParentScrollable = true) {
@ -84,7 +84,7 @@ protected:
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 100, 200));
SetScrollHandoff(layers[1], root);
registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
rootApzc = ApzcOf(root);
rootApzc->GetScrollMetadata().SetHasScrollgrab(true);
}

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

@ -33,7 +33,7 @@ TEST_F(APZCSnappingTester, Bug1265510)
root->SetScrollMetadata(metadata);
UniquePtr<ScopedLayerTreeRegistration> registration = MakeUnique<ScopedLayerTreeRegistration>(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
TestAsyncPanZoomController* outer = ApzcOf(layers[0]);
TestAsyncPanZoomController* inner = ApzcOf(layers[1]);

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

@ -15,7 +15,7 @@ TEST_F(APZCTreeManagerTester, ScrollablePaintedLayers) {
// both layers have the same scrollId
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID);
SetScrollableFrameMetrics(layers[2], FrameMetrics::START_SCROLL_ID);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
TestAsyncPanZoomController* nullAPZC = nullptr;
// so they should have the same APZC
@ -26,13 +26,13 @@ TEST_F(APZCTreeManagerTester, ScrollablePaintedLayers) {
// Change the scrollId of layers[1], and verify the APZC changes
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
EXPECT_NE(ApzcOf(layers[1]), ApzcOf(layers[2]));
// Change the scrollId of layers[2] to match that of layers[1], ensure we get the same
// APZC for both again
SetScrollableFrameMetrics(layers[2], FrameMetrics::START_SCROLL_ID + 1);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
EXPECT_EQ(ApzcOf(layers[1]), ApzcOf(layers[2]));
}
@ -40,7 +40,7 @@ TEST_F(APZCTreeManagerTester, Bug1068268) {
CreatePotentiallyLeakingTree();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
RefPtr<HitTestingTreeNode> root = manager->GetRootNode();
RefPtr<HitTestingTreeNode> node2 = root->GetFirstChild()->GetFirstChild();
RefPtr<HitTestingTreeNode> node5 = root->GetLastChild()->GetLastChild();
@ -61,7 +61,7 @@ TEST_F(APZCTreeManagerTester, Bug1068268) {
TEST_F(APZCTreeManagerTester, Bug1194876) {
CreateBug1194876Tree();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
uint64_t blockId;
nsTArray<ScrollableLayerGuid> targets;
@ -99,7 +99,7 @@ TEST_F(APZCTreeManagerTester, Bug1198900) {
// crash.
CreateSimpleDTCScrollingLayer();
ScopedLayerTreeRegistration registration(manager, 0, root, mcc);
manager->UpdateHitTestingTree(nullptr, root, false, 0, 0);
manager->UpdateHitTestingTree(0, root, false, 0, 0);
ScreenPoint origin(100, 50);
ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,

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

@ -1216,8 +1216,8 @@ CompositorBridgeParent::NotifyShadowTreeTransaction(uint64_t aId, bool aIsFirstP
#endif
if (mApzcTreeManager && aHitTestUpdate) {
mApzcTreeManager->UpdateHitTestingTree(this, mLayerManager->GetRoot(),
aIsFirstPaint, aId, aPaintSequenceNumber);
mApzcTreeManager->UpdateHitTestingTree(mRootLayerTreeID,
mLayerManager->GetRoot(), aIsFirstPaint, aId, aPaintSequenceNumber);
}
mLayerManager->NotifyShadowTreeTransaction();
@ -1569,7 +1569,7 @@ CompositorBridgeParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
if (mApzcTreeManager && !aIsRepeatTransaction && aHitTestUpdate) {
AutoResolveRefLayers resolve(mCompositionManager);
mApzcTreeManager->UpdateHitTestingTree(this, root, aIsFirstPaint,
mApzcTreeManager->UpdateHitTestingTree(mRootLayerTreeID, root, aIsFirstPaint,
mRootLayerTreeID, aPaintSequenceNumber);
}
@ -2288,12 +2288,24 @@ private:
bool mDestroyCalled;
};
CompositorController*
CompositorBridgeParent::LayerTreeState::GetCompositorController() const
{
return mParent;
}
MetricsSharingController*
CompositorBridgeParent::LayerTreeState::CrossProcessSharingController() const
{
return mCrossProcessParent;
}
MetricsSharingController*
CompositorBridgeParent::LayerTreeState::InProcessSharingController() const
{
return mParent;
}
void
CompositorBridgeParent::DidComposite(TimeStamp& aCompositeStart,
TimeStamp& aCompositeEnd)

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

@ -479,7 +479,9 @@ public:
// acknowledged by the child.
uint32_t mPendingCompositorUpdates;
CompositorController* GetCompositorController() const;
MetricsSharingController* CrossProcessSharingController() const;
MetricsSharingController* InProcessSharingController() const;
};
/**