Bug 1436409 - Remove gecko/APZ hit-test codepath from WebRenderCommandBuilder. r=botond

This removes the gfx.webrender.hit-test pref, assumes a value of true
everywhere it is used, and deletes all the resulting dead code.

Some gtests were setting this pref to false, and they are now updated to
set gfxVars::UseWebRender to false instead, which has the desired effect
of using the non-WR hit-testing codepath in APZ. (The data needed for
this codepath is set up by the gtests themselves).

MozReview-Commit-ID: 9ljDr8eEnv1

--HG--
extra : rebase_source : fbc321861428e7bb0bf7ab811935b682785debdc
This commit is contained in:
Kartikaya Gupta 2018-06-08 17:31:26 -04:00
parent b22610dcad
commit aa21a4d224
10 changed files with 34 additions and 99 deletions

View File

@ -2469,7 +2469,7 @@ APZCTreeManager::GetTargetAPZC(const ScreenPoint& aPoint,
CompositorHitTestInfo hitResult = CompositorHitTestInfo::eInvisibleToHitTest;
HitTestingTreeNode* scrollbarNode = nullptr;
RefPtr<AsyncPanZoomController> target;
if (gfx::gfxVars::UseWebRender() && gfxPrefs::WebRenderHitTest()) {
if (gfx::gfxVars::UseWebRender()) {
target = GetAPZCAtPointWR(aPoint, &hitResult, &scrollbarNode);
} else {
target = GetAPZCAtPoint(mRootNode, aPoint, &hitResult, &scrollbarNode);

View File

@ -16,6 +16,7 @@
#include "gmock/gmock.h"
#include "mozilla/Attributes.h"
#include "mozilla/gfx/gfxVars.h"
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
#include "mozilla/layers/GeckoContentController.h"
#include "mozilla/layers/CompositorBridgeParent.h"
@ -62,31 +63,37 @@ CreateSingleTouchData(int32_t aIdentifier, ScreenIntCoord aX, ScreenIntCoord aY)
return CreateSingleTouchData(aIdentifier, ScreenIntPoint(aX, aY));
}
template<class T>
class ScopedGfxPref {
template<class SetArg, class Storage>
class ScopedGfxSetting {
public:
ScopedGfxPref(T (*aGetPrefFunc)(void), void (*aSetPrefFunc)(T), T aVal)
ScopedGfxSetting(SetArg (*aGetPrefFunc)(void), void (*aSetPrefFunc)(SetArg), SetArg aVal)
: mSetPrefFunc(aSetPrefFunc)
{
mOldVal = aGetPrefFunc();
aSetPrefFunc(aVal);
}
~ScopedGfxPref() {
~ScopedGfxSetting() {
mSetPrefFunc(mOldVal);
}
private:
void (*mSetPrefFunc)(T);
T mOldVal;
void (*mSetPrefFunc)(SetArg);
Storage mOldVal;
};
#define SCOPED_GFX_PREF(prefBase, prefType, prefValue) \
ScopedGfxPref<prefType> pref_##prefBase( \
ScopedGfxSetting<prefType, prefType> pref_##prefBase( \
&(gfxPrefs::prefBase), \
&(gfxPrefs::Set##prefBase), \
prefValue)
#define SCOPED_GFX_VAR(varBase, varType, varValue) \
ScopedGfxSetting<const varType&, varType> var_##varBase( \
&(gfxVars::varBase), \
&(gfxVars::Set##varBase), \
varValue)
static TimeStamp GetStartupTime() {
static TimeStamp sStartupTime = TimeStamp::Now();
return sStartupTime;

View File

@ -161,7 +161,7 @@ protected:
};
TEST_F(APZEventRegionsTester, HitRegionImmediateResponse) {
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateEventRegionsLayerTree1();
@ -228,7 +228,7 @@ TEST_F(APZEventRegionsTester, HitRegionAccumulatesChildren) {
}
TEST_F(APZEventRegionsTester, Obscuration) {
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateObscuringLayerTree();
ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);

View File

@ -104,7 +104,7 @@ protected:
// A simple hit testing test that doesn't involve any transforms on layers.
TEST_F(APZHitTestingTester, HitTesting1) {
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateHitTesting1LayerTree();
ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);
@ -171,7 +171,7 @@ TEST_F(APZHitTestingTester, HitTesting1) {
// A more involved hit testing test that involves css and async transforms.
TEST_F(APZHitTestingTester, HitTesting2) {
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
SCOPED_GFX_PREF(APZVelocityBias, float, 0.0); // Velocity bias can cause extra repaint requests
CreateHitTesting2LayerTree();
@ -282,7 +282,7 @@ TEST_F(APZHitTestingTester, HitTesting2) {
}
TEST_F(APZHitTestingTester, HitTesting3) {
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
const char* layerTreeSyntax = "c(t)";
// LayerID 0 1
@ -308,7 +308,7 @@ TEST_F(APZHitTestingTester, HitTesting3) {
}
TEST_F(APZHitTestingTester, ComplexMultiLayerTree) {
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateComplexMultiLayerTree();
ScopedLayerTreeRegistration registration(manager, LayersId{0}, root, mcc);

View File

@ -240,7 +240,7 @@ TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1073250) {
// Enable overscrolling.
SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateScrollHandoffLayerTree1();
@ -279,7 +279,7 @@ TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1231228) {
// Enable overscrolling.
SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateScrollHandoffLayerTree1();
@ -347,7 +347,7 @@ TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1240202a) {
TEST_F(APZScrollHandoffTester, StuckInOverscroll_Bug1240202b) {
// Enable overscrolling.
SCOPED_GFX_PREF(APZOverscrollEnabled, bool, true);
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateScrollHandoffLayerTree1();
@ -411,7 +411,7 @@ TEST_F(APZScrollHandoffTester, OpposingConstrainedAxes_Bug1201098) {
// handed off to the parent, while the original APZC continues flinging in the
// other direction.
TEST_F(APZScrollHandoffTester, PartialFlingHandoff) {
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateScrollHandoffLayerTree1();
@ -499,14 +499,14 @@ TEST_F(APZScrollHandoffTester, ScrollgrabFling) {
TEST_F(APZScrollHandoffTester, ScrollgrabFlingAcceleration1) {
SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateScrollgrabLayerTree(true /* make parent scrollable */);
TestFlingAcceleration();
}
TEST_F(APZScrollHandoffTester, ScrollgrabFlingAcceleration2) {
SCOPED_GFX_PREF(APZFlingMinVelocityThreshold, float, 0.0f);
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
CreateScrollgrabLayerTree(false /* do not make parent scrollable */);
TestFlingAcceleration();
}

View File

@ -15,7 +15,7 @@ class APZCSnappingTester : public APZCTreeManagerTester
TEST_F(APZCSnappingTester, Bug1265510)
{
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
const char* layerTreeSyntax = "c(t)";
nsIntRegion layerVisibleRegion[] = {
@ -68,7 +68,7 @@ TEST_F(APZCSnappingTester, Bug1265510)
TEST_F(APZCSnappingTester, Snap_After_Pinch)
{
SCOPED_GFX_PREF(WebRenderHitTest, bool, false);
SCOPED_GFX_VAR(UseWebRender, bool, false);
const char* layerTreeSyntax = "c";
nsIntRegion layerVisibleRegion[] = {

View File

@ -1231,22 +1231,15 @@ WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(nsDisplayList* a
mClipManager.BeginList(aSc);
bool apzEnabled = mManager->AsyncPanZoomEnabled();
EventRegions eventRegions;
FlattenedDisplayItemIterator iter(aDisplayListBuilder, aDisplayList);
while (nsDisplayItem* i = iter.GetNext()) {
nsDisplayItem* item = i;
DisplayItemType itemType = item->GetType();
// If the item is a event regions item, but is empty (has no regions in it)
// then we should just throw it out
if (itemType == DisplayItemType::TYPE_LAYER_EVENT_REGIONS) {
nsDisplayLayerEventRegions* eventRegions =
static_cast<nsDisplayLayerEventRegions*>(item);
if (eventRegions->IsEmpty()) {
continue;
}
}
// We should never get event regions items in WR now that we always have
// WR hit-testing enabled.
MOZ_ASSERT(itemType != DisplayItemType::TYPE_LAYER_EVENT_REGIONS);
// Peek ahead to the next item and try merging with it or swapping with it
// if necessary.
@ -1286,45 +1279,6 @@ WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(nsDisplayList* a
forceNewLayerData = true;
}
// If we're creating a new layer data then flush whatever event regions
// we've collected onto the old layer.
if (forceNewLayerData && !eventRegions.IsEmpty()) {
// If eventRegions is non-empty then we must have a layer data already,
// because we (below) force one if we encounter an event regions item
// with an empty layer data list. Additionally, the most recently
// created layer data must have been created from an item whose ASR
// is the same as the ASR on the event region items that were collapsed
// into |eventRegions|. This is because any ASR change causes us to force
// a new layer data which flushes the eventRegions.
MOZ_ASSERT(!mLayerScrollData.empty());
mLayerScrollData.back().AddEventRegions(eventRegions);
eventRegions.SetEmpty();
}
// Collapse event region data into |eventRegions|, which will either be
// empty, or filled with stuff from previous display items with the same
// ASR.
if (itemType == DisplayItemType::TYPE_LAYER_EVENT_REGIONS) {
nsDisplayLayerEventRegions* regionsItem =
static_cast<nsDisplayLayerEventRegions*>(item);
int32_t auPerDevPixel = item->Frame()->PresContext()->AppUnitsPerDevPixel();
EventRegions regions(
regionsItem->HitRegion().ScaleToOutsidePixels(1.0f, 1.0f, auPerDevPixel),
regionsItem->MaybeHitRegion().ScaleToOutsidePixels(1.0f, 1.0f, auPerDevPixel),
regionsItem->DispatchToContentHitRegion().ScaleToOutsidePixels(1.0f, 1.0f, auPerDevPixel),
regionsItem->NoActionRegion().ScaleToOutsidePixels(1.0f, 1.0f, auPerDevPixel),
regionsItem->HorizontalPanRegion().ScaleToOutsidePixels(1.0f, 1.0f, auPerDevPixel),
regionsItem->VerticalPanRegion().ScaleToOutsidePixels(1.0f, 1.0f, auPerDevPixel),
/* mDTCRequiresTargetConfirmation = */ false);
eventRegions.OrWith(regions);
if (mLayerScrollData.empty()) {
// If we don't have a layer data yet then create one because we will
// need it to store this event region information.
forceNewLayerData = true;
}
}
// If we're going to create a new layer data for this item, stash the
// ASR so that if we recurse into a sublist they will know where to stop
// walking up their ASR chain when building scroll metadata.
@ -1335,7 +1289,7 @@ WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(nsDisplayList* a
mClipManager.BeginItem(item, aSc);
if (itemType != DisplayItemType::TYPE_LAYER_EVENT_REGIONS) {
{ // scope restoreDoGrouping
AutoRestore<bool> restoreDoGrouping(mDoGrouping);
if (itemType == DisplayItemType::TYPE_SVG_WRAPPER) {
// Inside an <svg>, all display items that are not LAYER_ACTIVE wrapper
@ -1417,31 +1371,10 @@ WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(nsDisplayList* a
mLayerScrollData.back().Initialize(mManager->GetScrollData(), item,
descendants, stopAtAsr, deferred ? Some((*deferred)->GetTransform().GetMatrix()) : Nothing());
}
} else if (mLayerScrollData.size() != layerCountBeforeRecursing &&
!eventRegions.IsEmpty()) {
// We are not forcing a new layer for |item|, but we did create some
// layers while recursing. In this case, we need to make sure any
// event regions that we were carrying end up on the right layer. So we
// do an event region "flush" but retroactively; i.e. the event regions
// end up on the layer that was mLayerScrollData.back() prior to the
// recursion.
MOZ_ASSERT(layerCountBeforeRecursing > 0);
mLayerScrollData[layerCountBeforeRecursing - 1].AddEventRegions(eventRegions);
eventRegions.SetEmpty();
}
}
}
// If we have any event region info left over we need to flush it before we
// return. Again, at this point the layer data list must be non-empty, and
// the most recently created layer data will have been created by an item
// with matching ASRs.
if (!eventRegions.IsEmpty()) {
MOZ_ASSERT(apzEnabled);
MOZ_ASSERT(!mLayerScrollData.empty());
mLayerScrollData.back().AddEventRegions(eventRegions);
}
mClipManager.EndList(aSc);
}

View File

@ -517,7 +517,6 @@ private:
DECL_GFX_PREF(Live, "gfx.webrender.blob-images", WebRenderBlobImages, bool, true);
DECL_GFX_PREF(Live, "gfx.webrender.blob.invalidation", WebRenderBlobInvalidation, bool, false);
DECL_GFX_PREF(Live, "gfx.webrender.highlight-painted-layers",WebRenderHighlightPaintedLayers, bool, false);
DECL_GFX_PREF(Live, "gfx.webrender.hit-test", WebRenderHitTest, bool, true);
// Use vsync events generated by hardware
DECL_GFX_PREF(Once, "gfx.work-around-driver-bugs", WorkAroundDriverBugs, bool, true);

View File

@ -1035,11 +1035,8 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
{
MOZ_COUNT_CTOR(nsDisplayListBuilder);
const bool useWRHitTest =
gfxPrefs::WebRenderHitTest() && gfxVars::UseWebRender();
mBuildCompositorHitTestInfo = mAsyncPanZoomEnabled && IsForPainting() &&
(useWRHitTest || gfxPrefs::SimpleEventRegionItems());
(gfxVars::UseWebRender() || gfxPrefs::SimpleEventRegionItems());
mLessEventRegionItems = gfxPrefs::LessEventRegionItems();

View File

@ -873,7 +873,6 @@ pref("gfx.webrender.highlight-painted-layers", false);
pref("gfx.webrender.async-scene-build", true);
pref("gfx.webrender.blob-images", true);
pref("gfx.webrender.blob.invalidation", true);
pref("gfx.webrender.hit-test", true);
// WebRender debugging utilities.
pref("gfx.webrender.debug.texture-cache", false);