Bug 1138967 - Part 1: Remove ISharedImage. r=nical, a=lmandel
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 19 Mar 2015 10:15:38 +1300
changeset 250449 c1356c27fa1b
parent 250448 17adc07baf56
child 250450 07e266d45703
push id4591
push userryanvm@gmail.com
push date2015-03-19 18:13 +0000
treeherdermozilla-beta@9b7aa96d0e11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, lmandel
bugs1138967
milestone37.0
Bug 1138967 - Part 1: Remove ISharedImage. r=nical, a=lmandel
dom/media/android/AndroidMediaReader.cpp
gfx/layers/D3D9SurfaceImage.h
gfx/layers/GrallocImages.h
gfx/layers/ImageContainer.h
gfx/layers/MacIOSurfaceImage.h
gfx/layers/client/ImageClient.cpp
gfx/layers/ipc/SharedPlanarYCbCrImage.h
gfx/layers/ipc/SharedRGBImage.h
--- a/dom/media/android/AndroidMediaReader.cpp
+++ b/dom/media/android/AndroidMediaReader.cpp
@@ -364,17 +364,17 @@ AndroidMediaReader::ImageBufferCallback:
                                                     nsIntSize(aWidth, aHeight),
                                                     gfxImageFormat::RGB16_565);
       if (!image) {
         NS_WARNING("Could not create rgb image");
         return nullptr;
       }
 
       mImage = image;
-      return image->AsSharedImage()->GetBuffer();
+      return image->GetBuffer();
     case MPAPI::I420:
       return CreateI420Image(aWidth, aHeight);
     default:
       NS_NOTREACHED("Color format not supported");
       return nullptr;
   }
 }
 
--- a/gfx/layers/D3D9SurfaceImage.h
+++ b/gfx/layers/D3D9SurfaceImage.h
@@ -13,32 +13,29 @@
 
 namespace mozilla {
 namespace layers {
 
 // Image class that wraps a IDirect3DSurface9. This class copies the image
 // passed into SetData(), so that it can be accessed from other D3D devices.
 // This class also manages the synchronization of the copy, to ensure the
 // resource is ready to use.
-class D3D9SurfaceImage : public Image
-                       , public ISharedImage {
+class D3D9SurfaceImage : public Image {
 public:
 
   struct Data {
     Data(IDirect3DSurface9* aSurface, const nsIntRect& aRegion)
       : mSurface(aSurface), mRegion(aRegion) {}
     RefPtr<IDirect3DSurface9> mSurface;
     nsIntRect mRegion;
   };
 
   D3D9SurfaceImage();
   virtual ~D3D9SurfaceImage();
 
-  virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
-
   // Copies the surface into a sharable texture's surface, and initializes
   // the image.
   HRESULT SetData(const Data& aData);
 
   // Returns the description of the shared surface.
   const D3DSURFACE_DESC& GetDesc() const;
 
   // Returns the HANDLE that can be used to open the image as a shared resource.
@@ -47,17 +44,16 @@ public:
   // complete.
   HANDLE GetShareHandle();
 
   gfx::IntSize GetSize() MOZ_OVERRIDE;
 
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
 
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
-  virtual uint8_t* GetBuffer() MOZ_OVERRIDE { return nullptr; }
 
   virtual bool IsValid() MOZ_OVERRIDE;
 
 private:
 
   // Blocks the calling thread until the copy operation started in SetData()
   // is complete, whereupon the texture is safe to use.
   void EnsureSynchronized();
--- a/gfx/layers/GrallocImages.h
+++ b/gfx/layers/GrallocImages.h
@@ -39,17 +39,16 @@ class GrallocTextureClientOGL;
  * cr_offset = y_size
  * cb_offset = y_size + c_size
  *
  * The Image that is rendered is the picture region defined by
  * mPicX, mPicY and mPicSize. The size of the rendered image is
  * mPicSize, not mYSize or mCbCrSize.
  */
 class GrallocImage : public PlanarYCbCrImage
-                   , public ISharedImage
 {
   typedef PlanarYCbCrData Data;
   static int32_t sColorIdMap[];
 public:
   struct GrallocData {
     nsRefPtr<TextureClient> mGraphicBuffer;
     gfx::IntSize mPicSize;
   };
@@ -88,18 +87,16 @@ public:
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
 
   android::sp<android::GraphicBuffer> GetGraphicBuffer() const;
 
   void* GetNativeBuffer();
 
   virtual bool IsValid() { return !!mTextureClient; }
 
-  virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
-
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
 
   virtual GrallocImage* AsGrallocImage() MOZ_OVERRIDE
   {
     return this;
   }
 
   virtual uint8_t* GetBuffer()
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -110,28 +110,16 @@ class GrallocImage;
 struct ImageBackendData
 {
   virtual ~ImageBackendData() {}
 
 protected:
   ImageBackendData() {}
 };
 
-// sadly we'll need this until we get rid of Deprected image classes
-class ISharedImage {
-public:
-    virtual uint8_t* GetBuffer() = 0;
-
-    /**
-     * For use with the CompositableClient only (so that the later can
-     * synchronize the TextureClient with the TextureHost).
-     */
-    virtual TextureClient* GetTextureClient(CompositableClient* aClient) = 0;
-};
-
 /**
  * A class representing a buffer of pixel data. The data can be in one
  * of various formats including YCbCr.
  * 
  * Create an image using an ImageContainer. Fill the image with data, and
  * then call ImageContainer::SetImage to display it. An image must not be
  * modified after calling SetImage. Image implementations do not need to
  * perform locking; when filling an Image, the Image client is responsible
@@ -140,18 +128,16 @@ public:
  * 
  * When resampling an Image, only pixels within the buffer should be
  * sampled. For example, cairo images should be sampled in EXTEND_PAD mode.
  */
 class Image {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(Image)
 
 public:
-  virtual ISharedImage* AsSharedImage() { return nullptr; }
-
   ImageFormat GetFormat() { return mFormat; }
   void* GetImplData() { return mImplData; }
 
   virtual gfx::IntSize GetSize() = 0;
   virtual nsIntRect GetPictureRect()
   {
     return nsIntRect(0, 0, GetSize().width, GetSize().height);
   }
@@ -170,16 +156,24 @@ public:
 
   virtual GrallocImage* AsGrallocImage()
   {
     return nullptr;
   }
 
   virtual bool IsValid() { return true; }
 
+  virtual uint8_t* GetBuffer() { return nullptr; }
+
+  /**
+  * For use with the CompositableClient only (so that the later can
+  * synchronize the TextureClient with the TextureHost).
+  */
+  virtual TextureClient* GetTextureClient(CompositableClient* aClient) { return nullptr; }
+
 protected:
   Image(void* aImplData, ImageFormat aFormat) :
     mImplData(aImplData),
     mSerial(++sSerialCounter),
     mFormat(aFormat),
     mSent(false)
   {}
 
@@ -788,18 +782,17 @@ protected:
   nsRefPtr<BufferRecycleBin> mRecycleBin;
 };
 
 /**
  * Currently, the data in a CairoImage surface is treated as being in the
  * device output color space. This class is very simple as all backends
  * have to know about how to deal with drawing a cairo image.
  */
-class CairoImage MOZ_FINAL : public Image,
-                             public ISharedImage {
+class CairoImage MOZ_FINAL : public Image {
 public:
   struct Data {
     gfx::IntSize mSize;
     RefPtr<gfx::SourceSurface> mSourceSurface;
   };
 
   /**
    * This can only be called on the main thread. It may add a reference
@@ -812,18 +805,16 @@ public:
     mSourceSurface = aData.mSourceSurface;
   }
 
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE
   {
     return mSourceSurface.get();
   }
 
-  virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
-  virtual uint8_t* GetBuffer() MOZ_OVERRIDE { return nullptr; }
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
 
   virtual gfx::IntSize GetSize() MOZ_OVERRIDE { return mSize; }
 
   CairoImage();
   ~CairoImage();
 
   gfx::IntSize mSize;
--- a/gfx/layers/MacIOSurfaceImage.h
+++ b/gfx/layers/MacIOSurfaceImage.h
@@ -10,32 +10,28 @@
 #include "mozilla/gfx/MacIOSurface.h"
 #include "mozilla/gfx/Point.h"
 #include "mozilla/layers/TextureClient.h"
 
 namespace mozilla {
 
 namespace layers {
 
-class MacIOSurfaceImage : public Image,
-                          public ISharedImage {
+class MacIOSurfaceImage : public Image {
 public:
   void SetSurface(MacIOSurface* aSurface) { mSurface = aSurface; }
   MacIOSurface* GetSurface() { return mSurface; }
 
   gfx::IntSize GetSize() MOZ_OVERRIDE {
     return gfx::IntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight());
   }
 
-  virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
-
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
 
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
-  virtual uint8_t* GetBuffer() MOZ_OVERRIDE { return nullptr; }
 
   MacIOSurfaceImage() : Image(nullptr, ImageFormat::MAC_IOSURFACE) {}
 
 private:
   RefPtr<MacIOSurface> mSurface;
   RefPtr<TextureClient> mTextureClient;
 };
 
--- a/gfx/layers/client/ImageClient.cpp
+++ b/gfx/layers/client/ImageClient.cpp
@@ -153,19 +153,17 @@ ImageClientSingle::UpdateImage(ImageCont
   if (!image->IsValid()) {
     return true;
   }
 
   if (mLastPaintedImageSerial == image->GetSerial()) {
     return true;
   }
 
-  RefPtr<TextureClient> texture = image->AsSharedImage()
-                                ? image->AsSharedImage()->GetTextureClient(this)
-                                : nullptr;
+  RefPtr<TextureClient> texture = image->GetTextureClient(this);
 
   AutoRemoveTexture autoRemoveTexture(this);
   if (texture != mFrontBuffer) {
     autoRemoveTexture.mTexture = mFrontBuffer;
     mFrontBuffer = nullptr;
   }
 
   if (!texture) {
--- a/gfx/layers/ipc/SharedPlanarYCbCrImage.h
+++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.h
@@ -20,26 +20,24 @@ namespace layers {
 
 class BufferTextureClient;
 class ImageClient;
 class ISurfaceAllocator;
 class SurfaceDescriptor;
 class TextureClient;
 
 class SharedPlanarYCbCrImage : public PlanarYCbCrImage
-                             , public ISharedImage
 {
 public:
   explicit SharedPlanarYCbCrImage(ImageClient* aCompositable);
 
 protected:
   ~SharedPlanarYCbCrImage();
 
 public:
-  virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
 
   virtual TemporaryRef<gfx::SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
   virtual void SetData(const PlanarYCbCrData& aData) MOZ_OVERRIDE;
   virtual void SetDataNoCopy(const Data &aData) MOZ_OVERRIDE;
 
   virtual bool Allocate(PlanarYCbCrData& aData);
--- a/gfx/layers/ipc/SharedRGBImage.h
+++ b/gfx/layers/ipc/SharedRGBImage.h
@@ -32,27 +32,24 @@ already_AddRefed<Image> CreateSharedRGBI
                                              nsIntSize aSize,
                                              gfxImageFormat aImageFormat);
 
 /**
  * Stores RGB data in shared memory
  * It is assumed that the image width and stride are equal
  */
 class SharedRGBImage : public Image
-                     , public ISharedImage
 {
 public:
   explicit SharedRGBImage(ImageClient* aCompositable);
 
 protected:
   ~SharedRGBImage();
 
 public:
-  virtual ISharedImage* AsSharedImage() MOZ_OVERRIDE { return this; }
-
   virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;
 
   virtual uint8_t* GetBuffer() MOZ_OVERRIDE;
 
   gfx::IntSize GetSize() MOZ_OVERRIDE;
 
   size_t GetBufferSize();