mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1417519 - Hook up APZ to use the hit-testing API. r=botond,mstange
This adds the code that APZ needs to use the WR hit-testing API. For now (if the pref is enabled) it just does the hit-test and compares the result to the regular hit-test, printing out discrepancies. It also doesn't yet get the scrollbar result. MozReview-Commit-ID: 3pjYSWDGeDr --HG-- extra : rebase_source : 9766fe3e77dd85f130ce155041cec7c0daae67ec
This commit is contained in:
parent
ce6a99a6e8
commit
81e67cd608
@ -2187,13 +2187,32 @@ APZCTreeManager::GetTargetAPZC(const ScreenPoint& aPoint,
|
||||
HitTestResult* aOutHitResult,
|
||||
RefPtr<HitTestingTreeNode>* aOutScrollbarNode)
|
||||
{
|
||||
MutexAutoLock lock(mTreeLock);
|
||||
HitTestResult hitResult = HitNothing;
|
||||
HitTestingTreeNode* scrollbarNode = nullptr;
|
||||
ParentLayerPoint point = ViewAs<ParentLayerPixel>(aPoint,
|
||||
PixelCastJustification::ScreenIsParentLayerForRoot);
|
||||
RefPtr<AsyncPanZoomController> target = GetAPZCAtPoint(mRootNode, point,
|
||||
&hitResult, &scrollbarNode);
|
||||
RefPtr<AsyncPanZoomController> target;
|
||||
|
||||
{ // scope mTreeLock
|
||||
MutexAutoLock lock(mTreeLock);
|
||||
target = GetAPZCAtPoint(mRootNode, aPoint, &hitResult, &scrollbarNode);
|
||||
}
|
||||
|
||||
if (gfxPrefs::WebRenderHitTest()) {
|
||||
HitTestResult wrHitResult = HitNothing;
|
||||
RefPtr<AsyncPanZoomController> wrTarget = GetAPZCAtPointWR(aPoint, &wrHitResult);
|
||||
// For now just compare the WR and non-WR results.
|
||||
if (wrHitResult != hitResult) {
|
||||
printf_stderr("WR hit result mismatch at %s: got %d, expected %d\n",
|
||||
Stringify(aPoint).c_str(), (int)wrHitResult, (int)hitResult);
|
||||
// MOZ_RELEASE_ASSERT(false);
|
||||
}
|
||||
if (wrTarget.get() != target.get()) {
|
||||
printf_stderr("WR hit target mismatch at %s: got %s, expected %s\n",
|
||||
Stringify(aPoint).c_str(),
|
||||
wrTarget ? Stringify(wrTarget->GetGuid()).c_str() : "null",
|
||||
target ? Stringify(target->GetGuid()).c_str() : "null");
|
||||
// MOZ_RELEASE_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (aOutHitResult) {
|
||||
*aOutHitResult = hitResult;
|
||||
@ -2204,6 +2223,63 @@ APZCTreeManager::GetTargetAPZC(const ScreenPoint& aPoint,
|
||||
return target.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<AsyncPanZoomController>
|
||||
APZCTreeManager::GetAPZCAtPointWR(const ScreenPoint& aHitTestPoint,
|
||||
HitTestResult* aOutHitResult)
|
||||
{
|
||||
MOZ_ASSERT(aOutHitResult);
|
||||
|
||||
RefPtr<AsyncPanZoomController> result;
|
||||
RefPtr<wr::WebRenderAPI> wr = GetWebRenderAPI();
|
||||
if (!wr) {
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
wr::WrPipelineId pipelineId;
|
||||
FrameMetrics::ViewID scrollId;
|
||||
gfx::CompositorHitTestInfo hitInfo;
|
||||
bool hitSomething = wr->HitTest(wr::ToWorldPoint(aHitTestPoint),
|
||||
pipelineId, scrollId, hitInfo);
|
||||
if (!hitSomething) {
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
uint64_t layersId = wr::AsUint64(pipelineId);
|
||||
result = GetTargetAPZC(layersId, scrollId);
|
||||
if (!result) {
|
||||
// It falls back to the root
|
||||
MOZ_ASSERT(scrollId == FrameMetrics::NULL_SCROLL_ID);
|
||||
result = FindRootApzcForLayersId(layersId);
|
||||
MOZ_ASSERT(result);
|
||||
}
|
||||
|
||||
*aOutHitResult = HitLayer;
|
||||
if (hitInfo & gfx::CompositorHitTestInfo::eDispatchToContent) {
|
||||
*aOutHitResult = HitDispatchToContentRegion;
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
auto touchFlags = hitInfo & gfx::CompositorHitTestInfo::eTouchActionMask;
|
||||
if (!touchFlags) {
|
||||
return result.forget();
|
||||
}
|
||||
if (touchFlags == gfx::CompositorHitTestInfo::eTouchActionMask) {
|
||||
*aOutHitResult = HitLayerTouchActionNone;
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
bool panX = !(hitInfo & gfx::CompositorHitTestInfo::eTouchActionPanXDisabled);
|
||||
bool panY = !(hitInfo & gfx::CompositorHitTestInfo::eTouchActionPanYDisabled);
|
||||
if (panX && panY) {
|
||||
*aOutHitResult = HitLayerTouchActionPanXY;
|
||||
} else if (panY) {
|
||||
*aOutHitResult = HitLayerTouchActionPanY;
|
||||
} else if (panX) {
|
||||
*aOutHitResult = HitLayerTouchActionPanX;
|
||||
}
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
RefPtr<const OverscrollHandoffChain>
|
||||
APZCTreeManager::BuildOverscrollHandoffChain(const RefPtr<AsyncPanZoomController>& aInitialTarget)
|
||||
{
|
||||
@ -2321,7 +2397,7 @@ APZCTreeManager::GetTargetApzcForNode(HitTestingTreeNode* aNode)
|
||||
|
||||
AsyncPanZoomController*
|
||||
APZCTreeManager::GetAPZCAtPoint(HitTestingTreeNode* aNode,
|
||||
const ParentLayerPoint& aHitTestPoint,
|
||||
const ScreenPoint& aHitTestPoint,
|
||||
HitTestResult* aOutHitResult,
|
||||
HitTestingTreeNode** aOutScrollbarNode)
|
||||
{
|
||||
@ -2332,7 +2408,9 @@ APZCTreeManager::GetAPZCAtPoint(HitTestingTreeNode* aNode,
|
||||
HitTestingTreeNode* resultNode;
|
||||
HitTestingTreeNode* root = aNode;
|
||||
std::stack<LayerPoint> hitTestPoints;
|
||||
hitTestPoints.push(ViewAs<LayerPixel>(aHitTestPoint,
|
||||
ParentLayerPoint point = ViewAs<ParentLayerPixel>(aHitTestPoint,
|
||||
PixelCastJustification::ScreenIsParentLayerForRoot);
|
||||
hitTestPoints.push(ViewAs<LayerPixel>(point,
|
||||
PixelCastJustification::MovingDownToChildren));
|
||||
|
||||
ForEachNode<ReverseIterator>(root,
|
||||
|
@ -520,9 +520,11 @@ private:
|
||||
GuidComparator aComparator);
|
||||
AsyncPanZoomController* GetTargetApzcForNode(HitTestingTreeNode* aNode);
|
||||
AsyncPanZoomController* GetAPZCAtPoint(HitTestingTreeNode* aNode,
|
||||
const ParentLayerPoint& aHitTestPoint,
|
||||
const ScreenPoint& aHitTestPoint,
|
||||
HitTestResult* aOutHitResult,
|
||||
HitTestingTreeNode** aOutScrollbarNode);
|
||||
already_AddRefed<AsyncPanZoomController> GetAPZCAtPointWR(const ScreenPoint& aHitTestPoint,
|
||||
HitTestResult* aOutHitResult);
|
||||
AsyncPanZoomController* FindRootApzcForLayersId(uint64_t aLayersId) const;
|
||||
AsyncPanZoomController* FindRootContentApzcForLayersId(uint64_t aLayersId) const;
|
||||
AsyncPanZoomController* FindRootContentOrRootApzc() const;
|
||||
|
@ -283,6 +283,14 @@ static inline wr::LayoutPoint ToLayoutPoint(const mozilla::LayoutDeviceIntPoint&
|
||||
return ToLayoutPoint(LayoutDevicePoint(point));
|
||||
}
|
||||
|
||||
static inline wr::WorldPoint ToWorldPoint(const mozilla::ScreenPoint& point)
|
||||
{
|
||||
wr::WorldPoint p;
|
||||
p.x = point.x;
|
||||
p.y = point.y;
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline wr::LayoutVector2D ToLayoutVector2D(const mozilla::LayoutDevicePoint& point)
|
||||
{
|
||||
wr::LayoutVector2D p;
|
||||
|
Loading…
Reference in New Issue
Block a user