From a117d896ccfac718bed31845a5d62eec0d8a5cf9 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 28 Aug 2013 15:21:05 +0200 Subject: [PATCH] Bug 907745 - cleanup ImageClient::CreateImage. r=mattwoodrow --- gfx/layers/client/ImageClient.cpp | 40 +++++++++++++++++++++---------- gfx/layers/client/ImageClient.h | 15 +++++++++++- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index 384fa39c749e..22e12587f5f1 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -449,25 +449,17 @@ ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag } already_AddRefed -ImageClient::CreateImage(const uint32_t *aFormats, - uint32_t aNumFormats) +ImageClientSingle::CreateImage(const uint32_t *aFormats, + uint32_t aNumFormats) { nsRefPtr img; for (uint32_t i = 0; i < aNumFormats; i++) { switch (aFormats[i]) { case PLANAR_YCBCR: - if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) { - img = new DeprecatedSharedPlanarYCbCrImage(GetForwarder()); - } else { - img = new SharedPlanarYCbCrImage(this); - } + img = new SharedPlanarYCbCrImage(this); return img.forget(); case SHARED_RGB: - if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) { - img = new DeprecatedSharedRGBImage(GetForwarder()); - } else { - img = new SharedRGBImage(this); - } + img = new SharedRGBImage(this); return img.forget(); #ifdef MOZ_WIDGET_GONK case GRALLOC_PLANAR_YCBCR: @@ -479,5 +471,29 @@ ImageClient::CreateImage(const uint32_t *aFormats, return nullptr; } +already_AddRefed +DeprecatedImageClientSingle::CreateImage(const uint32_t *aFormats, + uint32_t aNumFormats) +{ + nsRefPtr img; + for (uint32_t i = 0; i < aNumFormats; i++) { + switch (aFormats[i]) { + case PLANAR_YCBCR: + img = new DeprecatedSharedPlanarYCbCrImage(GetForwarder()); + return img.forget(); + case SHARED_RGB: + img = new DeprecatedSharedRGBImage(GetForwarder()); + return img.forget(); +#ifdef MOZ_WIDGET_GONK + case GRALLOC_PLANAR_YCBCR: + img = new GrallocImage(); + return img.forget(); +#endif + } + } + return nullptr; +} + + } } diff --git a/gfx/layers/client/ImageClient.h b/gfx/layers/client/ImageClient.h index ce1482c08e98..5ae01c567cb7 100644 --- a/gfx/layers/client/ImageClient.h +++ b/gfx/layers/client/ImageClient.h @@ -60,7 +60,7 @@ public: virtual void UpdatePictureRect(nsIntRect aPictureRect); virtual already_AddRefed CreateImage(const uint32_t *aFormats, - uint32_t aNumFormats); + uint32_t aNumFormats) = 0; protected: ImageClient(CompositableForwarder* aFwd, CompositableType aType); @@ -93,6 +93,9 @@ public: CreateBufferTextureClient(gfx::SurfaceFormat aFormat) MOZ_OVERRIDE; virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE; + + virtual already_AddRefed CreateImage(const uint32_t *aFormats, + uint32_t aNumFormats) MOZ_OVERRIDE; protected: RefPtr mFrontBuffer; // Some layers may want to enforce some flags to all their textures @@ -155,6 +158,9 @@ public: return mTextureInfo; } + virtual already_AddRefed CreateImage(const uint32_t *aFormats, + uint32_t aNumFormats) MOZ_OVERRIDE; + private: RefPtr mDeprecatedTextureClient; TextureInfo mTextureInfo; @@ -189,6 +195,13 @@ public: MOZ_ASSERT(!aChild, "ImageClientBridge should not have IPDL actor"); } + virtual already_AddRefed CreateImage(const uint32_t *aFormats, + uint32_t aNumFormats) MOZ_OVERRIDE + { + NS_WARNING("Should not create an image through an ImageClientBridge"); + return nullptr; + } + protected: uint64_t mAsyncContainerID; ShadowableLayer* mLayer;