Bug 1447299 - Have the APZCTreeManager keep a pointer to the sampler. r=botond

MozReview-Commit-ID: GiITwCDuWAW

--HG--
extra : rebase_source : 13a288785c0c3d7d0374e253f4211bfe7c5540bc
This commit is contained in:
Kartikaya Gupta 2018-03-28 14:55:58 -04:00
Родитель 6b3f0c8b18
Коммит 4bbad90793
3 изменённых файлов: 26 добавлений и 1 удалений

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

@ -21,6 +21,7 @@
#include "mozilla/gfx/GPUParent.h" // for GPUParent
#include "mozilla/gfx/Logging.h" // for gfx::TreeLog
#include "mozilla/gfx/Point.h" // for Point
#include "mozilla/layers/APZSampler.h" // for APZSampler
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnControllerThread, etc
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
#include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics
@ -224,6 +225,7 @@ private:
APZCTreeManager::APZCTreeManager(LayersId aRootLayersId)
: mInputQueue(new InputQueue()),
mRootLayersId(aRootLayersId),
mSampler(nullptr),
mTreeLock("APZCTreeLock"),
mHitResultForInputBlock(CompositorHitTestInfo::eInvisibleToHitTest),
mRetainedTouchIdentifier(-1),
@ -246,6 +248,14 @@ APZCTreeManager::APZCTreeManager(LayersId aRootLayersId)
APZCTreeManager::~APZCTreeManager() = default;
void
APZCTreeManager::SetSampler(APZSampler* aSampler)
{
// We're either setting the sampler or clearing it
MOZ_ASSERT((mSampler == nullptr) != (aSampler == nullptr));
mSampler = aSampler;
}
void
APZCTreeManager::NotifyLayerTreeAdopted(LayersId aLayersId,
const RefPtr<APZCTreeManager>& aOldApzcTreeManager)

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

@ -45,6 +45,7 @@ namespace layers {
class Layer;
class AsyncPanZoomController;
class APZCTreeManagerParent;
class APZSampler;
class CompositorBridgeParent;
class OverscrollHandoffChain;
struct OverscrollHandoffState;
@ -116,6 +117,8 @@ class APZCTreeManager : public IAPZCTreeManager
public:
explicit APZCTreeManager(LayersId aRootLayersId);
void SetSampler(APZSampler* aSampler);
/**
* Notifies this APZCTreeManager that the associated compositor is now
* responsible for managing another layers id, which got moved over from
@ -691,6 +694,13 @@ private:
/* Layers id for the root CompositorBridgeParent that owns this APZCTreeManager. */
LayersId mRootLayersId;
/* Pointer to the APZSampler instance that is bound to this APZCTreeManager.
* The sampler has a RefPtr to this class, and this non-owning raw pointer
* back to the APZSampler is nulled out in the sampler's destructor, so this
* pointer should always be valid.
*/
APZSampler* MOZ_NON_OWNING_REF mSampler;
/* Whenever walking or mutating the tree rooted at mRootNode, mTreeLock must be held.
* This lock does not need to be held while manipulating a single APZC instance in
* isolation (that is, if its tree pointers are not being accessed or mutated). The

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

@ -18,9 +18,14 @@ namespace layers {
APZSampler::APZSampler(const RefPtr<APZCTreeManager>& aApz)
: mApz(aApz)
{
MOZ_ASSERT(aApz);
mApz->SetSampler(this);
}
APZSampler::~APZSampler() = default;
APZSampler::~APZSampler()
{
mApz->SetSampler(nullptr);
}
void
APZSampler::ClearTree()