Bug 1302641 - Update ImageBridgeChild::GetSingleton() use after 1298938 r=nical
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Wed, 14 Sep 2016 10:29:57 +0200
changeset 355260 0a5cf829f56e7c97f2e6032c921552b8aa527bc0
parent 355259 be756757b11f0ba559c1bdcafcfdfee5381198a1
child 355261 77797e21fa19e51871f9d7d726e7d78eaf67ec95
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1302641, 1298938
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1302641 - Update ImageBridgeChild::GetSingleton() use after 1298938 r=nical MozReview-Commit-ID: Cs7xUcPnPoz
dom/media/platforms/gonk/GonkVideoDecoderManager.cpp
dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
dom/media/webrtc/MediaEngineGonkVideoSource.cpp
gfx/layers/GrallocImages.cpp
widget/gonk/nativewindow/GonkBufferQueueJB.cpp
widget/gonk/nativewindow/GonkBufferQueueKK.cpp
widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.cpp
--- a/dom/media/platforms/gonk/GonkVideoDecoderManager.cpp
+++ b/dom/media/platforms/gonk/GonkVideoDecoderManager.cpp
@@ -395,17 +395,18 @@ GonkVideoDecoderManager::CreateVideoData
                                                           gfx::IntRect& aPicture)
 {
   sp<GraphicBuffer> srcBuffer(aSource->graphicBuffer());
   RefPtr<TextureClient> textureClient;
 
   if (mNeedsCopyBuffer) {
     // Copy buffer contents for bug 1199809.
     if (!mCopyAllocator) {
-      mCopyAllocator = new TextureClientRecycleAllocator(ImageBridgeChild::GetSingleton());
+      RefPtr<layers::ImageBridgeChild> bridge = layers::ImageBridgeChild::GetSingleton();
+      mCopyAllocator = new TextureClientRecycleAllocator(bridge);
     }
     if (!mCopyAllocator) {
       GVDM_LOG("Create buffer allocator failed!");
       return nullptr;
     }
 
     gfx::IntSize size(srcBuffer->getWidth(), srcBuffer->getHeight());
     GonkTextureClientAllocationHelper helper(srcBuffer->getPixelFormat(), size);
--- a/dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
+++ b/dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
@@ -150,31 +150,33 @@ class GonkTextureClientRecycleHandler : 
 {
   typedef MozPromise<layers::TextureClient*, nsresult, /* IsExclusive = */ true> TextureClientRecyclePromise;
 
 public:
   GonkTextureClientRecycleHandler(OMX_VIDEO_PORTDEFINITIONTYPE& aDef)
     : ITextureClientRecycleAllocator()
     , mMonitor("GonkTextureClientRecycleHandler")
   {
+    RefPtr<layers::ImageBridgeChild> bridge = layers::ImageBridgeChild::GetSingleton();
+
     // Allocate Gralloc texture memory.
     layers::GrallocTextureData* textureData =
       layers::GrallocTextureData::Create(gfx::IntSize(aDef.nFrameWidth, aDef.nFrameHeight),
                                          aDef.eColorFormat,
                                          gfx::BackendType::NONE,
                                          GraphicBuffer::USAGE_HW_TEXTURE | GraphicBuffer::USAGE_SW_READ_OFTEN,
-                                         layers::ImageBridgeChild::GetSingleton());
+                                         bridge);
 
     mGraphBuffer = textureData->GetGraphicBuffer();
     MOZ_ASSERT(mGraphBuffer.get());
 
     mTextureClient =
       layers::TextureClient::CreateWithData(textureData,
                                             layers::TextureFlags::DEALLOCATE_CLIENT | layers::TextureFlags::RECYCLE,
-                                            layers::ImageBridgeChild::GetSingleton());
+                                            bridge);
     MOZ_ASSERT(mTextureClient);
 
     mPromise.SetMonitor(&mMonitor);
   }
 
   RefPtr<TextureClientRecyclePromise> WaitforRecycle()
   {
     MonitorAutoLock lock(mMonitor);
--- a/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineGonkVideoSource.cpp
@@ -408,18 +408,18 @@ MediaEngineGonkVideoSource::AllocImpl() 
 
   mCameraControl = ICameraControl::Create(mCaptureIndex);
   if (mCameraControl) {
     mState = kAllocated;
     // Add this as a listener for CameraControl events. We don't need
     // to explicitly remove this--destroying the CameraControl object
     // in DeallocImpl() will do that for us.
     mCameraControl->AddListener(this);
-    mTextureClientAllocator =
-      new layers::TextureClientRecycleAllocator(layers::ImageBridgeChild::GetSingleton());
+    RefPtr<layers::ImageBridgeChild> bridge = layers::ImageBridgeChild::GetSingleton();
+    mTextureClientAllocator = new layers::TextureClientRecycleAllocator(bridge);
     mTextureClientAllocator->SetMaxPoolSize(WEBRTC_GONK_VIDEO_SOURCE_POOL_BUFFERS);
   }
   mCallbackMonitor.Notify();
 }
 
 void
 MediaEngineGonkVideoSource::DeallocImpl() {
   MOZ_ASSERT(NS_IsMainThread());
--- a/gfx/layers/GrallocImages.cpp
+++ b/gfx/layers/GrallocImages.cpp
@@ -68,17 +68,17 @@ GrallocImage::SetData(const Data& aData)
   mData = aData;
   mSize = aData.mPicSize;
 
   if (gfxPlatform::GetPlatform()->IsInGonkEmulator()) {
     // Emulator does not support HAL_PIXEL_FORMAT_YV12.
     return false;
   }
 
-  ClientIPCAllocator* allocator = ImageBridgeChild::GetSingleton();
+  RefPtr<ClientIPCAllocator> allocator = ImageBridgeChild::GetSingleton();
   GrallocTextureData* texData = GrallocTextureData::Create(mData.mYSize, HAL_PIXEL_FORMAT_YV12,
                                                            gfx::BackendType::NONE,
                                                            GraphicBuffer::USAGE_SW_READ_OFTEN |
                                                              GraphicBuffer::USAGE_SW_WRITE_OFTEN |
                                                              GraphicBuffer::USAGE_HW_TEXTURE,
                                                            allocator
   );
 
--- a/widget/gonk/nativewindow/GonkBufferQueueJB.cpp
+++ b/widget/gonk/nativewindow/GonkBufferQueueJB.cpp
@@ -419,17 +419,17 @@ status_t GonkBufferQueue::dequeueBuffer(
         *outFence = mSlots[buf].mFence;
         mSlots[buf].mFence = Fence::NO_FENCE;
     }  // end lock scope
 
     sp<GraphicBuffer> graphicBuffer;
     if (returnFlags & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
 
         usage |= GraphicBuffer::USAGE_HW_TEXTURE;
-        ClientIPCAllocator* allocator = ImageBridgeChild::GetSingleton();
+        RefPtr<ClientIPCAllocator> allocator = ImageBridgeChild::GetSingleton();
         GrallocTextureData* texData = GrallocTextureData::Create(IntSize(w,h), format,
                                                                  gfx::BackendType::NONE, usage,
                                                                  allocator);
         if (!texData) {
             ST_LOGE("dequeueBuffer: failed to alloc gralloc buffer");
             return -ENOMEM;
         }
         RefPtr<TextureClient> textureClient = new TextureClient(texData, TextureFlags::RECYCLE | TextureFlags::DEALLOCATE_CLIENT, allocator);
--- a/widget/gonk/nativewindow/GonkBufferQueueKK.cpp
+++ b/widget/gonk/nativewindow/GonkBufferQueueKK.cpp
@@ -438,17 +438,17 @@ status_t GonkBufferQueue::dequeueBuffer(
                     buf, buffer->width, buffer->height, buffer->format);
         }
         *outFence = mSlots[buf].mFence;
         mSlots[buf].mFence = Fence::NO_FENCE;
     }  // end lock scope
 
     if (returnFlags & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) {
 
-        ClientIPCAllocator* allocator = ImageBridgeChild::GetSingleton();
+        RefPtr<ClientIPCAllocator> allocator = ImageBridgeChild::GetSingleton();
         usage |= GraphicBuffer::USAGE_HW_TEXTURE;
         GrallocTextureData* texData = GrallocTextureData::Create(IntSize(w, h), format,
                                                                  gfx::BackendType::NONE, usage,
                                                                  allocator);
         if (!texData) {
             return -ENOMEM;
         }
 
--- a/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.cpp
+++ b/widget/gonk/nativewindow/GonkBufferQueueLL/GonkBufferQueueProducer.cpp
@@ -337,17 +337,17 @@ status_t GonkBufferQueueProducer::dequeu
                     found, buffer->width, buffer->height, buffer->format);
         }
 
         *outFence = mSlots[found].mFence;
         mSlots[found].mFence = Fence::NO_FENCE;
     } // Autolock scope
 
     if (returnFlags & BUFFER_NEEDS_REALLOCATION) {
-        ClientIPCAllocator* allocator = ImageBridgeChild::GetSingleton();
+        RefPtr<ClientIPCAllocator> allocator = ImageBridgeChild::GetSingleton();
         usage |= GraphicBuffer::USAGE_HW_TEXTURE;
         GrallocTextureData* texData = GrallocTextureData::Create(IntSize(width,height), format,
                                                                  gfx::BackendType::NONE,
                                                                  usage, allocator);
         if (!texData) {
             ALOGE("dequeueBuffer: failed to alloc gralloc buffer");
             return -ENOMEM;
         }