Bug 1240668 - Duplicate GonkNativeHandle::NhObj in ImageClientSingle::UpdateImage() r=nical
authorSotaro Ikeda <sotaro.ikeda.g@gmail.com>
Wed, 20 Jan 2016 01:47:05 -0800
changeset 280750 dbbfbc2fb26a147ee32e2af2082400eec4d7c053
parent 280749 9576824c598f7ef53c21571747e5b5b0bcca440d
child 280751 05d2f38a2544d792c0a4cf59f73f05778251e248
push id29922
push usercbook@mozilla.com
push dateThu, 21 Jan 2016 10:51:00 +0000
treeherdermozilla-central@977d78a8dd78 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1240668
milestone46.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 1240668 - Duplicate GonkNativeHandle::NhObj in ImageClientSingle::UpdateImage() r=nical
gfx/layers/ImageContainer.h
gfx/layers/client/ImageClient.cpp
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -862,17 +862,17 @@ public:
   void SetData(const SidebandStreamData& aData)
   {
     mSidebandStream = aData.mStream;
     mSize = aData.mSize;
   }
 
   already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; } ;
   int32_t GetOverlayId() { return mOverlayId; }
-  const GonkNativeHandle& GetSidebandStream() { return mSidebandStream; }
+  GonkNativeHandle& GetSidebandStream() { return mSidebandStream; }
 
   gfx::IntSize GetSize() { return mSize; }
 
 private:
   int32_t mOverlayId;
   GonkNativeHandle mSidebandStream;
   gfx::IntSize mSize;
 };
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -150,17 +150,25 @@ ImageClientSingle::UpdateImage(ImageCont
   for (auto& img : images) {
     Image* image = img.mImage;
 
 #ifdef MOZ_WIDGET_GONK
     if (image->GetFormat() == ImageFormat::OVERLAY_IMAGE) {
       OverlayImage* overlayImage = static_cast<OverlayImage*>(image);
       OverlaySource source;
       if (overlayImage->GetSidebandStream().IsValid()) {
-        source.handle() = OverlayHandle(overlayImage->GetSidebandStream());
+        // Duplicate GonkNativeHandle::NhObj for ipc,
+        // since ParamTraits<GonkNativeHandle>::Write() absorbs native_handle_t.
+        RefPtr<GonkNativeHandle::NhObj> nhObj = overlayImage->GetSidebandStream().GetDupNhObj();
+        GonkNativeHandle handle(nhObj);
+        if (!handle.IsValid()) {
+          gfxWarning() << "ImageClientSingle::UpdateImage failed in GetDupNhObj";
+          return false;
+        }
+        source.handle() = OverlayHandle(handle);
       } else {
         source.handle() = OverlayHandle(overlayImage->GetOverlayId());
       }
       source.size() = overlayImage->GetSize();
       GetForwarder()->UseOverlaySource(this, source, image->GetPictureRect());
       continue;
     }
 #endif