diff --git a/dom/media/platforms/apple/AppleVDADecoder.cpp b/dom/media/platforms/apple/AppleVDADecoder.cpp index 8d1aebcade4c..7f4a9923dc56 100644 --- a/dom/media/platforms/apple/AppleVDADecoder.cpp +++ b/dom/media/platforms/apple/AppleVDADecoder.cpp @@ -397,11 +397,7 @@ AppleVDADecoder::OutputFrame(CVPixelBufferRef aImage, RefPtr macSurface = new MacIOSurface(surface); - RefPtr image = - mImageContainer->CreateImage(ImageFormat::MAC_IOSURFACE); - layers::MacIOSurfaceImage* videoImage = - static_cast(image.get()); - videoImage->SetSurface(macSurface); + RefPtr image = new MacIOSurfaceImage(macSurface); data = VideoData::CreateFromImage(info, diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index eccd43bbdfe2..9b12a02a2170 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -694,17 +694,8 @@ PluginInstanceParent::GetImageContainer(ImageContainer** aContainer) #ifdef XP_MACOSX if (ioSurface) { - RefPtr image = container->CreateImage(ImageFormat::MAC_IOSURFACE); - if (!image) { - return NS_ERROR_FAILURE; - } - - NS_ASSERTION(image->GetFormat() == ImageFormat::MAC_IOSURFACE, "Wrong format?"); - - MacIOSurfaceImage* pluginImage = static_cast(image.get()); - pluginImage->SetSurface(ioSurface); - - container->SetCurrentImageInTransaction(pluginImage); + RefPtr image = new MacIOSurfaceImage(ioSurface); + container->SetCurrentImageInTransaction(image); NS_IF_ADDREF(container); *aContainer = container; diff --git a/gfx/gl/GLBlitHelper.cpp b/gfx/gl/GLBlitHelper.cpp index 930312e2651b..69e60497ccd0 100644 --- a/gfx/gl/GLBlitHelper.cpp +++ b/gfx/gl/GLBlitHelper.cpp @@ -892,7 +892,7 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage, #ifdef XP_MACOSX case ConvertMacIOSurfaceImage: - return BlitMacIOSurfaceImage(static_cast(srcImage)); + return BlitMacIOSurfaceImage(srcImage->AsMacIOSurfaceImage()); #endif default: diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index d6c0721a0cba..3a6b8e9b5f07 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -30,7 +30,6 @@ #ifdef XP_MACOSX #include "mozilla/gfx/QuartzSupport.h" -#include "MacIOSurfaceImage.h" #endif #ifdef XP_WIN @@ -75,12 +74,6 @@ ImageFactory::CreateImage(ImageFormat aFormat, img = new RecyclingPlanarYCbCrImage(aRecycleBin); return img.forget(); } -#ifdef XP_MACOSX - if (aFormat == ImageFormat::MAC_IOSURFACE) { - img = new MacIOSurfaceImage(); - return img.forget(); - } -#endif return nullptr; } diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 152a173df5d3..c0504c49e06a 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -120,6 +120,9 @@ class EGLImageImage; #ifdef MOZ_WIDGET_ANDROID class SurfaceTextureImage; #endif +#ifdef XP_MACOSX +class MacIOSurfaceImage; +#endif /** * A class representing a buffer of pixel data. The data can be in one @@ -177,6 +180,9 @@ public: #ifdef MOZ_WIDGET_ANDROID virtual SurfaceTextureImage* AsSurfaceTextureImage() { return nullptr; } #endif +#ifdef XP_MACOSX + virtual MacIOSurfaceImage* AsMacIOSurfaceImage() { return nullptr; } +#endif protected: Image(void* aImplData, ImageFormat aFormat) : diff --git a/gfx/layers/MacIOSurfaceImage.h b/gfx/layers/MacIOSurfaceImage.h index 31d33a2c1861..0c131925ab6c 100644 --- a/gfx/layers/MacIOSurfaceImage.h +++ b/gfx/layers/MacIOSurfaceImage.h @@ -17,7 +17,11 @@ namespace layers { class MacIOSurfaceImage : public Image { public: - void SetSurface(MacIOSurface* aSurface) { mSurface = aSurface; } + explicit MacIOSurfaceImage(MacIOSurface* aSurface) + : Image(nullptr, ImageFormat::MAC_IOSURFACE), + mSurface(aSurface) + {} + MacIOSurface* GetSurface() { return mSurface; } gfx::IntSize GetSize() override { @@ -28,7 +32,9 @@ public: virtual TextureClient* GetTextureClient(CompositableClient* aClient) override; - MacIOSurfaceImage() : Image(nullptr, ImageFormat::MAC_IOSURFACE) {} + virtual MacIOSurfaceImage* AsMacIOSurfaceImage() override { + return this; + } private: RefPtr mSurface;