mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1441916 - Introduce the notion of the APZ sampler thread. r=botond
The sampler thread is similar to the controller thread in that it doesn't correspond to a particular actual thread, but instead introduces an abstraction that allows us to reason about code flow and data ownership that is logically grouped on a single thread. For now the sampler thread remains mapped to the compositor thread, but eventually we will allow it to be render backend thread when webrender is enabled. MozReview-Commit-ID: D6i2t5lDvkv --HG-- extra : rebase_source : 06211ad878973c76ca3fd618386bbbd0cfdd4821
This commit is contained in:
parent
3f4e721fca
commit
bad638dcd9
@ -61,14 +61,6 @@ Compositor::EndFrame()
|
||||
mLastCompositionEndTime = TimeStamp::Now();
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
Compositor::AssertOnCompositorThread()
|
||||
{
|
||||
MOZ_ASSERT(!CompositorThreadHolder::Loop() ||
|
||||
CompositorThreadHolder::Loop() == MessageLoop::current(),
|
||||
"Can only call this from the compositor thread!");
|
||||
}
|
||||
|
||||
bool
|
||||
Compositor::ShouldDrawDiagnostics(DiagnosticFlags aFlags)
|
||||
{
|
||||
|
@ -497,12 +497,6 @@ public:
|
||||
|
||||
widget::CompositorWidget* GetWidget() const { return mWidget; }
|
||||
|
||||
/**
|
||||
* Debug-build assertion that can be called to ensure code is running on the
|
||||
* compositor thread.
|
||||
*/
|
||||
static void AssertOnCompositorThread();
|
||||
|
||||
// Return statistics for the most recent frame we computed statistics for.
|
||||
virtual void GetFrameStats(GPUStats* aStats);
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "gfxPrefs.h" // for gfxPrefs
|
||||
#include "InputData.h" // for InputData, etc
|
||||
#include "mozilla/EventStateManager.h" // for WheelPrefs
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnCompositorThread, etc
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnControllerThread, etc
|
||||
#include "mozilla/MouseEvents.h" // for WidgetMouseEvent
|
||||
#include "mozilla/TextEvents.h" // for WidgetKeyboardEvent
|
||||
#include "mozilla/TouchEvents.h" // for WidgetTouchEvent
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
|
||||
/**
|
||||
* Kicks an animation to zoom to a rect. This may be either a zoom out or zoom
|
||||
* in. The actual animation is done on the compositor thread after being set
|
||||
* in. The actual animation is done on the sampler thread after being set
|
||||
* up. |aRect| must be given in CSS pixels, relative to the document.
|
||||
* |aFlags| is a combination of the ZoomToRectBehavior enum values.
|
||||
*/
|
||||
|
@ -20,7 +20,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/APZThreadUtils.h" // for AssertOnCompositorThread, etc
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnControllerThread, etc
|
||||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform
|
||||
#include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent, etc
|
||||
@ -269,7 +269,7 @@ void
|
||||
APZCTreeManager::NotifyLayerTreeAdopted(uint64_t aLayersId,
|
||||
const RefPtr<APZCTreeManager>& aOldApzcTreeManager)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
MOZ_ASSERT(aOldApzcTreeManager);
|
||||
aOldApzcTreeManager->mFocusState.RemoveFocusTarget(aLayersId);
|
||||
@ -295,7 +295,7 @@ APZCTreeManager::NotifyLayerTreeAdopted(uint64_t aLayersId,
|
||||
void
|
||||
APZCTreeManager::NotifyLayerTreeRemoved(uint64_t aLayersId)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
mFocusState.RemoveFocusTarget(aLayersId);
|
||||
|
||||
@ -333,7 +333,7 @@ APZCTreeManager::UpdateHitTestingTreeImpl(uint64_t aRootLayerTreeId,
|
||||
uint64_t aOriginatingLayersId,
|
||||
uint32_t aPaintSequenceNumber)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
RecursiveMutexAutoLock lock(mTreeLock);
|
||||
|
||||
@ -528,7 +528,7 @@ APZCTreeManager::PushStateToWR(wr::TransactionBuilder& aTxn,
|
||||
const TimeStamp& aSampleTime,
|
||||
nsTArray<wr::WrTransformProperty>& aTransformArray)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
RecursiveMutexAutoLock lock(mTreeLock);
|
||||
|
||||
@ -2982,7 +2982,7 @@ bool
|
||||
APZCTreeManager::GetAPZTestData(uint64_t aLayersId,
|
||||
APZTestData* aOutData)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
MutexAutoLock lock(mTestDataLock);
|
||||
auto it = mTestData.find(aLayersId);
|
||||
if (it == mTestData.end()) {
|
||||
|
@ -77,7 +77,7 @@ struct AncestorTransform;
|
||||
* This class manages the tree of AsyncPanZoomController instances. There is one
|
||||
* instance of this class owned by each CompositorBridgeParent, and it contains as
|
||||
* many AsyncPanZoomController instances as there are scrollable container layers.
|
||||
* This class generally lives on the compositor thread, although some functions
|
||||
* This class generally lives on the sampler thread, although some functions
|
||||
* may be called from other threads as noted; thread safety is ensured internally.
|
||||
*
|
||||
* The bulk of the work of this class happens as part of the UpdateHitTestingTree
|
||||
@ -126,7 +126,7 @@ public:
|
||||
* some other compositor. That other compositor's APZCTreeManager is also
|
||||
* provided. This allows APZCTreeManager to transfer any necessary state
|
||||
* from the old APZCTreeManager related to that layers id.
|
||||
* This function must be called on the compositor thread.
|
||||
* This function must be called on the sampler thread.
|
||||
*/
|
||||
void NotifyLayerTreeAdopted(uint64_t aLayersId,
|
||||
const RefPtr<APZCTreeManager>& aOldTreeManager);
|
||||
@ -136,7 +136,7 @@ public:
|
||||
* associated compositor has been removed/destroyed. Note that this does
|
||||
* NOT get called during shutdown situations, when the root layer tree is
|
||||
* also getting destroyed.
|
||||
* This function must be called on the compositor thread.
|
||||
* This function must be called on the sampler thread.
|
||||
*/
|
||||
void NotifyLayerTreeRemoved(uint64_t aLayersId);
|
||||
|
||||
@ -158,7 +158,7 @@ public:
|
||||
* Preserve nodes and APZC instances where possible, but retire those whose
|
||||
* layers are no longer in the layer tree.
|
||||
*
|
||||
* This must be called on the compositor thread as it walks the layer tree.
|
||||
* This must be called on the sampler thread as it walks the layer tree.
|
||||
*
|
||||
* @param aRootLayerTreeId The layer tree ID of the root layer corresponding
|
||||
* to this APZCTreeManager
|
||||
@ -193,7 +193,7 @@ public:
|
||||
uint32_t aPaintSequenceNumber);
|
||||
|
||||
/**
|
||||
* Called when webrender is enabled, from the compositor thread. This function
|
||||
* Called when webrender is enabled, from the sampler thread. This function
|
||||
* walks through the tree of APZC instances and tells webrender about the
|
||||
* async scroll position. It also advances APZ animations to the specified
|
||||
* sample time. In effect it is the webrender equivalent of (part of) the
|
||||
@ -260,7 +260,7 @@ public:
|
||||
|
||||
/**
|
||||
* Kicks an animation to zoom to a rect. This may be either a zoom out or zoom
|
||||
* in. The actual animation is done on the compositor thread after being set
|
||||
* in. The actual animation is done on the sampler thread after being set
|
||||
* up. |aRect| must be given in CSS pixels, relative to the document.
|
||||
* |aFlags| is a combination of the ZoomToRectBehavior enum values.
|
||||
*/
|
||||
|
@ -834,7 +834,7 @@ AsyncPanZoomController::GetInputQueue() const {
|
||||
void
|
||||
AsyncPanZoomController::Destroy()
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
CancelAnimation(CancelAnimationFlags::ScrollSnap);
|
||||
|
||||
@ -3431,7 +3431,7 @@ AsyncPanZoomController::RequestContentRepaint(const FrameMetrics& aFrameMetrics,
|
||||
bool AsyncPanZoomController::UpdateAnimation(const TimeStamp& aSampleTime,
|
||||
nsTArray<RefPtr<Runnable>>* aOutDeferredTasks)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
// This function may get called multiple with the same sample time, because
|
||||
// there may be multiple layers with this APZC, and each layer invokes this
|
||||
@ -3490,7 +3490,7 @@ AsyncPanZoomController::GetOverscrollTransform(AsyncTransformConsumer aMode) con
|
||||
|
||||
bool AsyncPanZoomController::AdvanceAnimations(const TimeStamp& aSampleTime)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
// Don't send any state-change notifications until the end of the function,
|
||||
// because we may go through some intermediate states while we finish
|
||||
@ -3769,7 +3769,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const ScrollMetadata& aScrollMe
|
||||
bool aIsFirstPaint,
|
||||
bool aThisLayerTreeUpdated)
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
bool isDefault = mScrollMetadata.IsDefault();
|
||||
@ -4387,7 +4387,7 @@ void AsyncPanZoomController::UpdateSharedCompositorFrameMetrics()
|
||||
|
||||
void AsyncPanZoomController::ShareCompositorFrameMetrics()
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
// Only create the shared memory buffer if it hasn't already been created,
|
||||
// we are using progressive tile painting, and we have a
|
||||
|
@ -190,7 +190,7 @@ public:
|
||||
|
||||
/**
|
||||
* Kicks an animation to zoom to a rect. This may be either a zoom out or zoom
|
||||
* in. The actual animation is done on the compositor thread after being set
|
||||
* in. The actual animation is done on the sampler thread after being set
|
||||
* up.
|
||||
*/
|
||||
void ZoomToRect(CSSRect aRect, const uint32_t aFlags);
|
||||
@ -213,7 +213,7 @@ public:
|
||||
void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// These methods must only be called on the compositor thread.
|
||||
// These methods must only be called on the sampler thread.
|
||||
//
|
||||
|
||||
/**
|
||||
@ -776,7 +776,7 @@ protected:
|
||||
|
||||
/* Access to the following two fields is protected by the mRefPtrMonitor,
|
||||
since they are accessed on the UI thread but can be cleared on the
|
||||
compositor thread. */
|
||||
sampler thread. */
|
||||
RefPtr<GeckoContentController> mGeckoContentController;
|
||||
RefPtr<GestureEventListener> mGestureEventListener;
|
||||
mutable Monitor mRefPtrMonitor;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "gfxPrefs.h"
|
||||
#include "LayersLogging.h" // for Stringify
|
||||
#include "mozilla/gfx/Point.h" // for Point4D
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnCompositorThread
|
||||
#include "mozilla/layers/APZThreadUtils.h" // for AssertOnSamplerThread
|
||||
#include "mozilla/layers/APZUtils.h" // for CompleteAsyncTransform
|
||||
#include "mozilla/layers/AsyncCompositionManager.h" // for ViewTransform::operator Matrix4x4()
|
||||
#include "mozilla/layers/AsyncDragMetrics.h" // for AsyncDragMetrics
|
||||
@ -59,7 +59,7 @@ HitTestingTreeNode::~HitTestingTreeNode()
|
||||
void
|
||||
HitTestingTreeNode::Destroy()
|
||||
{
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
APZThreadUtils::AssertOnSamplerThread();
|
||||
|
||||
mPrevSibling = nullptr;
|
||||
mLastChild = nullptr;
|
||||
|
@ -35,7 +35,7 @@ protected:
|
||||
// Reference-counted classes cannot have public destructors.
|
||||
~OverscrollHandoffChain();
|
||||
public:
|
||||
// Threadsafe so that the controller and compositor threads can both maintain
|
||||
// Threadsafe so that the controller and sampler threads can both maintain
|
||||
// nsRefPtrs to the same handoff chain.
|
||||
// Mutable so that we can pass around the class by
|
||||
// RefPtr<const OverscrollHandoffChain> and thus enforce that, once built,
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "mozilla/layers/APZThreadUtils.h"
|
||||
|
||||
#include "mozilla/layers/Compositor.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -43,10 +43,10 @@ APZThreadUtils::AssertOnControllerThread() {
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
APZThreadUtils::AssertOnCompositorThread()
|
||||
APZThreadUtils::AssertOnSamplerThread()
|
||||
{
|
||||
if (GetThreadAssertionsEnabled()) {
|
||||
Compositor::AssertOnCompositorThread();
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,10 +42,10 @@ public:
|
||||
|
||||
/**
|
||||
* This can be used to assert that the current thread is the
|
||||
* compositor thread (which applies the async transform).
|
||||
* sampler thread (which samples the async transform).
|
||||
* This does nothing if thread assertions are disabled.
|
||||
*/
|
||||
static void AssertOnCompositorThread();
|
||||
static void AssertOnSamplerThread();
|
||||
|
||||
/**
|
||||
* Run the given task on the APZ "controller thread" for this platform. If
|
||||
|
@ -2096,9 +2096,8 @@ UpdateIndirectTree(uint64_t aId, Layer* aRoot, const TargetConfig& aTargetConfig
|
||||
/* static */ CompositorBridgeParent::LayerTreeState*
|
||||
CompositorBridgeParent::GetIndirectShadowTree(uint64_t aId)
|
||||
{
|
||||
// Only the compositor thread should use this method variant, however it is
|
||||
// safe to be called on the main thread during APZ gtests.
|
||||
APZThreadUtils::AssertOnCompositorThread();
|
||||
// Only the compositor thread should use this method variant
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
|
||||
MonitorAutoLock lock(*sIndirectLayerTreesLock);
|
||||
LayerTreeMap::iterator cit = sIndirectLayerTrees.find(aId);
|
||||
|
Loading…
Reference in New Issue
Block a user