Bug 1273913: Call |CompositorThreadHolder::IsInCompositorThread| in Gonk screen manager, r?mattwoodrow draft
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 18 May 2016 16:45:08 +0200
changeset 368337 85eb53b8c53972105adf7878b68e2ce857ab6130
parent 367997 f3f2fa1d7eed5a8262f6401ef18ff8117a3ce43e
child 521222 cb48d2818276019476ae2e98f35450f5e642b355
push id18483
push usertdz@users.sourceforge.net
push dateWed, 18 May 2016 14:45:54 +0000
reviewersmattwoodrow
bugs1273913
milestone49.0a1
Bug 1273913: Call |CompositorThreadHolder::IsInCompositorThread| in Gonk screen manager, r?mattwoodrow MozReview-Commit-ID: BlGqaCDHmCA
widget/gonk/nsScreenManagerGonk.cpp
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -147,18 +147,19 @@ nsScreenGonk::nsScreenGonk(uint32_t aId,
         property_get("ro.sf.hwrotation", propValue, "0");
         mPhysicalScreenRotation = atoi(propValue) / 90;
     }
 
     mColorDepth = SurfaceFormatToColorDepth(mSurfaceFormat);
 }
 
 static void
-ReleaseGLContextSync(mozilla::gl::GLContext* aGLContext) {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+ReleaseGLContextSync(mozilla::gl::GLContext* aGLContext)
+{
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     aGLContext->Release();
 }
 
 nsScreenGonk::~nsScreenGonk()
 {
     // Release GLContext on compositor thread
     if (mGLContext) {
         CompositorBridgeParent::CompositorLoop()->PostTask(
@@ -417,17 +418,17 @@ NeedsRBSwap(int aHalFormat)
         MOZ_CRASH("Unhandled HAL pixel format");
         return false; // not reached
     }
 }
 
 already_AddRefed<DrawTarget>
 nsScreenGonk::StartRemoteDrawing()
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     MOZ_ASSERT(!mFramebuffer);
     MOZ_ASSERT(!mMappedBuffer);
 
     mFramebuffer = DequeueBuffer();
     int width = mFramebuffer->width, height = mFramebuffer->height;
     if (gralloc_module()->lock(gralloc_module(), mFramebuffer->handle,
                                GRALLOC_USAGE_SW_READ_NEVER |
                                GRALLOC_USAGE_SW_WRITE_OFTEN |
@@ -455,17 +456,17 @@ nsScreenGonk::StartRemoteDrawing()
     }
     RefPtr<DrawTarget> buffer(mBackBuffer);
     return buffer.forget();
 }
 
 void
 nsScreenGonk::EndRemoteDrawing()
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
 
     if (mFramebufferTarget && mFramebuffer) {
         IntSize size = mFramebufferTarget->GetSize();
         Rect rect(0, 0, size.width, size.height);
         RefPtr<SourceSurface> source = mBackBuffer->Snapshot();
         mFramebufferTarget->DrawSurface(source, rect, rect);
 
         // Convert from BGR to RGB
@@ -522,17 +523,17 @@ nsScreenGonk::QueueBuffer(ANativeWindowB
   int ret = mNativeWindow->queueBuffer(mNativeWindow.get(), buf);
   return ret == 0;
 #endif
 }
 
 nsresult
 nsScreenGonk::MakeSnapshot(ANativeWindowBuffer* aBuffer)
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     MOZ_ASSERT(aBuffer);
 
     layers::CompositorBridgeParent* compositorParent = mCompositorBridgeParent;
     if (!compositorParent) {
         return NS_ERROR_FAILURE;
     }
 
     int width = aBuffer->width, height = aBuffer->height;
@@ -604,48 +605,48 @@ nsScreenGonk::GetDisplayType()
     return mDisplayType;
 }
 
 void
 nsScreenGonk::SetEGLInfo(hwc_display_t aDisplay,
                          hwc_surface_t aSurface,
                          gl::GLContext* aGLContext)
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     mEGLDisplay = aDisplay;
     mEGLSurface = aSurface;
     mGLContext = aGLContext;
 }
 
 hwc_display_t
 nsScreenGonk::GetEGLDisplay()
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     return mEGLDisplay;
 }
 
 hwc_surface_t
 nsScreenGonk::GetEGLSurface()
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     return mEGLSurface;
 }
 
 already_AddRefed<mozilla::gl::GLContext>
 nsScreenGonk::GetGLContext()
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     RefPtr<mozilla::gl::GLContext>glContext = mGLContext;
     return glContext.forget();
 }
 
 static void
 UpdateMirroringWidgetSync(nsMainThreadPtrHandle<nsScreenGonk>&& aScreen, nsWindow* aWindow)
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     already_AddRefed<nsWindow> window(aWindow);
     aScreen->UpdateMirroringWidget(window);
 }
 
 bool
 nsScreenGonk::EnableMirroring()
 {
     MOZ_ASSERT(NS_IsMainThread());
@@ -723,30 +724,30 @@ nsScreenGonk::ClearMirroringScreen(nsScr
     }
     mMirroringScreen = nullptr;
     return true;
 }
 
 void
 nsScreenGonk::UpdateMirroringWidget(already_AddRefed<nsWindow>& aWindow)
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     MOZ_ASSERT(IsPrimaryScreen());
 
     if (mMirroringWidget) {
         nsCOMPtr<nsIWidget> widget = mMirroringWidget.forget();
         NS_ReleaseOnMainThread(widget.forget());
     }
     mMirroringWidget = aWindow;
 }
 
 nsWindow*
 nsScreenGonk::GetMirroringWidget()
 {
-    MOZ_ASSERT(CompositorBridgeParent::IsInCompositorThread());
+    MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
     MOZ_ASSERT(IsPrimaryScreen());
 
     return mMirroringWidget;
 }
 
 NS_IMPL_ISUPPORTS(nsScreenManagerGonk, nsIScreenManager)
 
 nsScreenManagerGonk::nsScreenManagerGonk()