mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Move CompositorBridgeParent::IsInCompositorThread to CompositorThreadHolder. (bug 1273017 part 3, r=mattwoodrow)
This commit is contained in:
parent
03a3af51b6
commit
800882adb1
@ -5,7 +5,7 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaSystemResourceManagerParent.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
||||
#include "MediaSystemResourceService.h"
|
||||
@ -46,7 +46,7 @@ MediaSystemResourceService::Shutdown()
|
||||
MediaSystemResourceService::MediaSystemResourceService()
|
||||
: mDestroyed(false)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
// The maximum number of hardware resoureces available.
|
||||
// XXX need to hange to a dynamic way.
|
||||
@ -82,7 +82,7 @@ MediaSystemResourceService::Acquire(media::MediaSystemResourceManagerParent* aPa
|
||||
MediaSystemResourceType aResourceType,
|
||||
bool aWillWait)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
if (mDestroyed) {
|
||||
@ -123,7 +123,7 @@ MediaSystemResourceService::ReleaseResource(media::MediaSystemResourceManagerPar
|
||||
uint32_t aId,
|
||||
MediaSystemResourceType aResourceType)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
MOZ_ASSERT(aParent);
|
||||
|
||||
if (mDestroyed) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "TexturePoolOGL.h"
|
||||
#include "mozilla/layers/CompositorOGL.h"
|
||||
#include "mozilla/layers/CompositorBridgeParent.h"
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/layers/LayerManagerComposite.h"
|
||||
#include "mozilla/layers/TextureHostOGL.h"
|
||||
|
||||
@ -1899,7 +1899,7 @@ bool
|
||||
LayerScope::CheckSendable()
|
||||
{
|
||||
// Only compositor threads check LayerScope status
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread() || gIsGtest);
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread() || gIsGtest);
|
||||
|
||||
if (!gfxPrefs::LayerScopeEnabled()) {
|
||||
return false;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "mozilla/layers/APZUtils.h" // for CompleteAsyncTransform
|
||||
#include "mozilla/layers/Compositor.h" // for Compositor
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent, etc
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "mozilla/layers/LayerAnimationUtils.h" // for TimingFunctionToComputedTimingFunction
|
||||
#include "mozilla/layers/LayerMetricsWrapper.h" // for LayerMetricsWrapper
|
||||
#include "nsCoord.h" // for NSAppUnitsToFloatPixels, etc
|
||||
@ -706,7 +707,7 @@ void
|
||||
AsyncCompositionManager::RecordShadowTransforms(Layer* aLayer)
|
||||
{
|
||||
MOZ_ASSERT(gfxPrefs::CollectScrollTransforms());
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
|
||||
ForEachNodePostOrder<ForwardIterator>(
|
||||
aLayer,
|
||||
@ -1439,7 +1440,7 @@ AsyncCompositionManager::TransformScrollableLayer(Layer* aLayer)
|
||||
void
|
||||
AsyncCompositionManager::GetFrameUniformity(FrameUniformityData* aOutData)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
mLayerTransformRecorder.EndTest(aOutData);
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
|
||||
{
|
||||
// SetDisplay() is usually called from nsScreenManager at main thread. Post
|
||||
// to compositor thread if needs.
|
||||
if (!CompositorBridgeParent::IsInCompositorThread()) {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MonitorAutoLock lock(mSetDisplayMonitor);
|
||||
RefPtr<CancelableRunnable> task =
|
||||
@ -312,7 +312,7 @@ CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
|
||||
void
|
||||
CompositorVsyncScheduler::CancelSetDisplayTask()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
MonitorAutoLock lock(mSetDisplayMonitor);
|
||||
if (mSetDisplayTask) {
|
||||
mSetDisplayTask->Cancel();
|
||||
@ -333,7 +333,7 @@ CompositorVsyncScheduler::Destroy()
|
||||
// Destroy was already called on this object.
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
UnobserveVsync();
|
||||
mVsyncObserver->Destroy();
|
||||
mVsyncObserver = nullptr;
|
||||
@ -364,7 +364,7 @@ CompositorVsyncScheduler::PostCompositeTask(TimeStamp aCompositeTimestamp)
|
||||
void
|
||||
CompositorVsyncScheduler::ScheduleComposition()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
if (mAsapScheduling) {
|
||||
// Used only for performance testing purposes
|
||||
PostCompositeTask(TimeStamp::Now());
|
||||
@ -386,7 +386,7 @@ CompositorVsyncScheduler::ScheduleComposition()
|
||||
void
|
||||
CompositorVsyncScheduler::CancelCurrentSetNeedsCompositeTask()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
MonitorAutoLock lock(mSetNeedsCompositeMonitor);
|
||||
if (mSetNeedsCompositeTask) {
|
||||
mSetNeedsCompositeTask->Cancel();
|
||||
@ -405,7 +405,7 @@ CompositorVsyncScheduler::CancelCurrentSetNeedsCompositeTask()
|
||||
void
|
||||
CompositorVsyncScheduler::SetNeedsComposite()
|
||||
{
|
||||
if (!CompositorBridgeParent::IsInCompositorThread()) {
|
||||
if (!CompositorThreadHolder::IsInCompositorThread()) {
|
||||
MonitorAutoLock lock(mSetNeedsCompositeMonitor);
|
||||
RefPtr<CancelableRunnable> task =
|
||||
NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite);
|
||||
@ -436,7 +436,7 @@ bool
|
||||
CompositorVsyncScheduler::NotifyVsync(TimeStamp aVsyncTimestamp)
|
||||
{
|
||||
// Called from the vsync dispatch thread
|
||||
MOZ_ASSERT(!CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(!CompositorThreadHolder::IsInCompositorThread());
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
PostCompositeTask(aVsyncTimestamp);
|
||||
return true;
|
||||
@ -445,7 +445,7 @@ CompositorVsyncScheduler::NotifyVsync(TimeStamp aVsyncTimestamp)
|
||||
void
|
||||
CompositorVsyncScheduler::CancelCurrentCompositeTask()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread() || NS_IsMainThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread() || NS_IsMainThread());
|
||||
MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
|
||||
if (mCurrentCompositeTask) {
|
||||
mCurrentCompositeTask->Cancel();
|
||||
@ -456,7 +456,7 @@ CompositorVsyncScheduler::CancelCurrentCompositeTask()
|
||||
void
|
||||
CompositorVsyncScheduler::Composite(TimeStamp aVsyncTimestamp)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
{
|
||||
MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
|
||||
mCurrentCompositeTask = nullptr;
|
||||
@ -499,14 +499,14 @@ CompositorVsyncScheduler::OnForceComposeToTarget()
|
||||
* free and this oscillating behavior causes a performance hit. In order to avoid this problem,
|
||||
* we reset the mVsyncNotificationsSkipped counter to keep vsync enabled.
|
||||
*/
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
mVsyncNotificationsSkipped = 0;
|
||||
}
|
||||
|
||||
void
|
||||
CompositorVsyncScheduler::ForceComposeToTarget(gfx::DrawTarget* aTarget, const IntRect* aRect)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
OnForceComposeToTarget();
|
||||
mLastCompose = TimeStamp::Now();
|
||||
ComposeToTarget(aTarget, aRect);
|
||||
@ -515,14 +515,14 @@ CompositorVsyncScheduler::ForceComposeToTarget(gfx::DrawTarget* aTarget, const I
|
||||
bool
|
||||
CompositorVsyncScheduler::NeedsComposite()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
return mNeedsComposite;
|
||||
}
|
||||
|
||||
void
|
||||
CompositorVsyncScheduler::ObserveVsync()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
mCompositorVsyncDispatcher->SetCompositorVsyncObserver(mVsyncObserver);
|
||||
mIsObservingVsync = true;
|
||||
}
|
||||
@ -530,7 +530,7 @@ CompositorVsyncScheduler::ObserveVsync()
|
||||
void
|
||||
CompositorVsyncScheduler::UnobserveVsync()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
mCompositorVsyncDispatcher->SetCompositorVsyncObserver(nullptr);
|
||||
mIsObservingVsync = false;
|
||||
}
|
||||
@ -546,7 +546,7 @@ CompositorVsyncScheduler::DispatchTouchEvents(TimeStamp aVsyncTimestamp)
|
||||
void
|
||||
CompositorVsyncScheduler::DispatchVREvents(TimeStamp aVsyncTimestamp)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
|
||||
VRManager* vm = VRManager::Get();
|
||||
vm->NotifyVsync(aVsyncTimestamp);
|
||||
@ -564,7 +564,7 @@ CompositorVsyncScheduler::ScheduleTask(already_AddRefed<CancelableRunnable> aTas
|
||||
void
|
||||
CompositorVsyncScheduler::ResumeComposition()
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
mLastCompose = TimeStamp::Now();
|
||||
ComposeToTarget(nullptr);
|
||||
}
|
||||
@ -572,7 +572,7 @@ CompositorVsyncScheduler::ResumeComposition()
|
||||
void
|
||||
CompositorVsyncScheduler::ComposeToTarget(gfx::DrawTarget* aTarget, const IntRect* aRect)
|
||||
{
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
MOZ_ASSERT(mCompositorBridgeParent);
|
||||
mCompositorBridgeParent->CompositeToTarget(aTarget, aRect);
|
||||
}
|
||||
@ -643,12 +643,6 @@ CompositorBridgeParent::CompositorBridgeParent(widget::CompositorWidgetProxy* aW
|
||||
mSelfRef = this;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorBridgeParent::IsInCompositorThread()
|
||||
{
|
||||
return CompositorThread() && CompositorThread()->thread_id() == PlatformThread::CurrentId();
|
||||
}
|
||||
|
||||
uint64_t
|
||||
CompositorBridgeParent::RootLayerTreeId()
|
||||
{
|
||||
@ -914,7 +908,7 @@ CompositorBridgeParent::InvalidateOnCompositorThread()
|
||||
void
|
||||
CompositorBridgeParent::PauseComposition()
|
||||
{
|
||||
MOZ_ASSERT(IsInCompositorThread(),
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread(),
|
||||
"PauseComposition() can only be called on the compositor thread");
|
||||
|
||||
MonitorAutoLock lock(mPauseCompositionMonitor);
|
||||
@ -935,7 +929,7 @@ CompositorBridgeParent::PauseComposition()
|
||||
void
|
||||
CompositorBridgeParent::ResumeComposition()
|
||||
{
|
||||
MOZ_ASSERT(IsInCompositorThread(),
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread(),
|
||||
"ResumeComposition() can only be called on the compositor thread");
|
||||
|
||||
MonitorAutoLock lock(mResumeCompositionMonitor);
|
||||
@ -1069,7 +1063,7 @@ CompositorBridgeParent::NotifyShadowTreeTransaction(uint64_t aId, bool aIsFirstP
|
||||
void
|
||||
CompositorBridgeParent::ScheduleComposition()
|
||||
{
|
||||
MOZ_ASSERT(IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
if (mPaused) {
|
||||
return;
|
||||
}
|
||||
@ -1112,7 +1106,7 @@ CompositorBridgeParent::CompositeToTarget(DrawTarget* aTarget, const gfx::IntRec
|
||||
PROFILER_LABEL("CompositorBridgeParent", "Composite",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
|
||||
MOZ_ASSERT(IsInCompositorThread(),
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread(),
|
||||
"Composite can only be called on the compositor thread");
|
||||
TimeStamp start = TimeStamp::Now();
|
||||
|
||||
@ -1272,7 +1266,7 @@ void
|
||||
CompositorBridgeParent::ScheduleRotationOnCompositorThread(const TargetConfig& aTargetConfig,
|
||||
bool aIsFirstPaint)
|
||||
{
|
||||
MOZ_ASSERT(IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
|
||||
if (!aIsFirstPaint &&
|
||||
!mCompositionManager->IsFirstPaint() &&
|
||||
@ -1771,7 +1765,7 @@ static void
|
||||
InsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
|
||||
{
|
||||
#ifdef MOZ_ENABLE_PROFILER_SPS
|
||||
MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
|
||||
MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
|
||||
VsyncPayload* payload = new VsyncPayload(aVsyncTimestamp);
|
||||
PROFILER_MARKER_PAYLOAD("VsyncTimestamp", payload);
|
||||
#endif
|
||||
|
@ -475,11 +475,6 @@ public:
|
||||
|
||||
float ComputeRenderIntegrity();
|
||||
|
||||
/**
|
||||
* Returns true if the calling thread is the compositor thread.
|
||||
*/
|
||||
static bool IsInCompositorThread();
|
||||
|
||||
widget::CompositorWidgetProxy* GetWidgetProxy() { return mWidgetProxy; }
|
||||
|
||||
void ForceComposeToTarget(gfx::DrawTarget* aTarget, const gfx::IntRect* aRect = nullptr);
|
||||
|
@ -142,5 +142,12 @@ CompositorThreadHolder::Shutdown()
|
||||
CompositorBridgeParent::FinishShutdown();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
CompositorThreadHolder::IsInCompositorThread()
|
||||
{
|
||||
return CompositorThread() &&
|
||||
CompositorThread()->thread_id() == PlatformThread::CurrentId();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
} // namespace layers
|
||||
|
@ -46,6 +46,9 @@ public:
|
||||
|
||||
static MessageLoop* Loop();
|
||||
|
||||
// Returns true if the calling thread is the compositor thread.
|
||||
static bool IsInCompositorThread();
|
||||
|
||||
private:
|
||||
~CompositorThreadHolder();
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "gfxGDIFontList.h"
|
||||
#include "gfxGDIFont.h"
|
||||
|
||||
#include "mozilla/layers/CompositorBridgeParent.h" // for CompositorBridgeParent::IsInCompositorThread
|
||||
#include "mozilla/layers/CompositorThread.h"
|
||||
#include "DeviceManagerD3D9.h"
|
||||
#include "mozilla/layers/ReadbackManagerD3D11.h"
|
||||
|
||||
@ -1410,7 +1410,7 @@ gfxWindowsPlatform::GetD3D9DeviceManager()
|
||||
RefPtr<DeviceManagerD3D9> result;
|
||||
if (!mDeviceManager &&
|
||||
(!gfxPlatform::UsesOffMainThreadCompositing() ||
|
||||
CompositorBridgeParent::IsInCompositorThread())) {
|
||||
CompositorThreadHolder::IsInCompositorThread())) {
|
||||
mDeviceManager = new DeviceManagerD3D9();
|
||||
if (!mDeviceManager->Init()) {
|
||||
gfxCriticalError() << "[D3D9] Could not Initialize the DeviceManagerD3D9";
|
||||
|
Loading…
Reference in New Issue
Block a user