From afe9dcf6ff150fffebbc2ee868f7aa45f436d761 Mon Sep 17 00:00:00 2001 From: sotaro Date: Wed, 27 Sep 2017 09:56:38 +0900 Subject: [PATCH] Bug 1403049 - Remove EGLImageImage r=snorp --- gfx/gl/GLBlitHelper.cpp | 39 ------------------ gfx/gl/GLBlitHelper.h | 3 -- gfx/layers/GLImages.cpp | 29 ------------- gfx/layers/GLImages.h | 32 --------------- gfx/layers/ImageContainer.h | 2 - gfx/layers/ImageTypes.h | 5 --- gfx/layers/LayersLogging.cpp | 2 - gfx/layers/client/ImageClient.cpp | 22 +++------- gfx/layers/opengl/TextureClientOGL.cpp | 56 -------------------------- gfx/layers/opengl/TextureClientOGL.h | 28 ------------- 10 files changed, 6 insertions(+), 212 deletions(-) diff --git a/gfx/gl/GLBlitHelper.cpp b/gfx/gl/GLBlitHelper.cpp index 1b1f299f67f5..894ce0af1e8a 100644 --- a/gfx/gl/GLBlitHelper.cpp +++ b/gfx/gl/GLBlitHelper.cpp @@ -608,10 +608,6 @@ GLBlitHelper::BlitImageToFramebuffer(layers::Image* srcImage, case ImageFormat::SURFACE_TEXTURE: return BlitImage(static_cast(srcImage), destSize, destOrigin); - - case ImageFormat::EGLIMAGE: - return BlitImage(static_cast(srcImage), destSize, - destOrigin); #endif #ifdef XP_MACOSX case ImageFormat::MAC_IOSURFACE: @@ -647,41 +643,6 @@ GLBlitHelper::BlitImage(layers::SurfaceTextureImage* srcImage, const gfx::IntSiz gfxCriticalError() << "BlitImage(SurfaceTextureImage) not implemented."; return false; } - -bool -GLBlitHelper::BlitImage(layers::EGLImageImage* const srcImage, - const gfx::IntSize& destSize, const OriginPos destOrigin) const -{ - const EGLImage eglImage = srcImage->GetImage(); - const EGLSync eglSync = srcImage->GetSync(); - if (eglSync) { - EGLint status = sEGLLibrary.fClientWaitSync(EGL_DISPLAY(), eglSync, 0, LOCAL_EGL_FOREVER); - if (status != LOCAL_EGL_CONDITION_SATISFIED) { - return false; - } - } - - GLuint tex = 0; - mGL->fGenTextures(1, &tex); - - const ScopedSaveMultiTex saveTex(mGL, 1, LOCAL_GL_TEXTURE_2D); - mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, tex); - mGL->TexParams_SetClampNoMips(); - mGL->fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, eglImage); - - const auto& srcOrigin = srcImage->GetOriginPos(); - const bool yFlip = destOrigin != srcOrigin; - const gfx::IntRect srcRect(0, 0, 1, 1); - const gfx::IntSize srcSize(1, 1); - const DrawBlitProg::BaseArgs baseArgs = { destSize, yFlip, srcRect, srcSize }; - - const auto& prog = GetDrawBlitProg({kFragHeader_Tex2D, kFragBody_RGBA}); - MOZ_RELEASE_ASSERT(prog); - prog->Draw(baseArgs); - - mGL->fDeleteTextures(1, &tex); - return true; -} #endif // ------------------------------------- diff --git a/gfx/gl/GLBlitHelper.h b/gfx/gl/GLBlitHelper.h index b08ae31cd19f..343d3ee8a08b 100644 --- a/gfx/gl/GLBlitHelper.h +++ b/gfx/gl/GLBlitHelper.h @@ -28,7 +28,6 @@ class GPUVideoImage; class PlanarYCbCrImage; class SurfaceTextureImage; class MacIOSurfaceImage; -class EGLImageImage; class SurfaceDescriptorD3D10; class SurfaceDescriptorDXGIYCbCr; } // namespace layers @@ -133,8 +132,6 @@ public: // Blit onto the current FB. bool BlitImage(layers::SurfaceTextureImage* stImage, const gfx::IntSize& destSize, OriginPos destOrigin) const; - bool BlitImage(layers::EGLImageImage* eglImage, const gfx::IntSize& destSize, - OriginPos destOrigin) const; #endif #ifdef XP_MACOSX bool BlitImage(layers::MacIOSurfaceImage* srcImage, const gfx::IntSize& destSize, diff --git a/gfx/layers/GLImages.cpp b/gfx/layers/GLImages.cpp index 142feadc5fed..2017cbe02736 100644 --- a/gfx/layers/GLImages.cpp +++ b/gfx/layers/GLImages.cpp @@ -16,35 +16,6 @@ namespace layers { static RefPtr sSnapshotContext; -EGLImageImage::EGLImageImage(EGLImage aImage, EGLSync aSync, - const gfx::IntSize& aSize, const gl::OriginPos& aOrigin, - bool aOwns) - : GLImage(ImageFormat::EGLIMAGE), - mImage(aImage), - mSync(aSync), - mSize(aSize), - mPos(aOrigin), - mOwns(aOwns) -{ -} - -EGLImageImage::~EGLImageImage() -{ - if (!mOwns) { - return; - } - - if (mImage) { - sEGLLibrary.fDestroyImage(EGL_DISPLAY(), mImage); - mImage = nullptr; - } - - if (mSync) { - sEGLLibrary.fDestroySync(EGL_DISPLAY(), mSync); - mSync = nullptr; - } -} - already_AddRefed GLImage::GetAsSourceSurface() { diff --git a/gfx/layers/GLImages.h b/gfx/layers/GLImages.h index 3044d132466e..8b71700b16f6 100644 --- a/gfx/layers/GLImages.h +++ b/gfx/layers/GLImages.h @@ -28,38 +28,6 @@ public: } }; -class EGLImageImage : public GLImage { -public: - EGLImageImage(EGLImage aImage, EGLSync aSync, - const gfx::IntSize& aSize, const gl::OriginPos& aOrigin, - bool aOwns); - - gfx::IntSize GetSize() override { return mSize; } - gl::OriginPos GetOriginPos() const { - return mPos; - } - EGLImage GetImage() const { - return mImage; - } - EGLSync GetSync() const { - return mSync; - } - - EGLImageImage* AsEGLImageImage() override { - return this; - } - -protected: - virtual ~EGLImageImage(); - -private: - EGLImage mImage; - EGLSync mSync; - gfx::IntSize mSize; - gl::OriginPos mPos; - bool mOwns; -}; - #ifdef MOZ_WIDGET_ANDROID class SurfaceTextureImage : public GLImage { diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 2662352ee3ea..b06ab5fd545d 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -174,7 +174,6 @@ protected: /* Forward declarations for Image derivatives. */ class GLImage; -class EGLImageImage; class SharedRGBImage; #ifdef MOZ_WIDGET_ANDROID class SurfaceTextureImage; @@ -233,7 +232,6 @@ public: virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) { return nullptr; } /* Access to derived classes. */ - virtual EGLImageImage* AsEGLImageImage() { return nullptr; } virtual GLImage* AsGLImage() { return nullptr; } #ifdef MOZ_WIDGET_ANDROID virtual SurfaceTextureImage* AsSurfaceTextureImage() { return nullptr; } diff --git a/gfx/layers/ImageTypes.h b/gfx/layers/ImageTypes.h index cb656e24b1b6..55236a687a60 100644 --- a/gfx/layers/ImageTypes.h +++ b/gfx/layers/ImageTypes.h @@ -55,11 +55,6 @@ enum class ImageFormat { */ SURFACE_TEXTURE, - /** - * An EGL Image that can be shared across threads. - */ - EGLIMAGE, - /** * The D3D9_RGB32_TEXTURE format creates a D3D9SurfaceImage, and wraps a * IDirect3DTexture9 in RGB32 layout. diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp index a25f17a8da96..5539cbd02eb4 100644 --- a/gfx/layers/LayersLogging.cpp +++ b/gfx/layers/LayersLogging.cpp @@ -400,8 +400,6 @@ AppendToString(std::stringstream& aStream, ImageFormat format, aStream << "ImageFormat::MAC_IOSURFACE"; break; case ImageFormat::SURFACE_TEXTURE: aStream << "ImageFormat::SURFACE_TEXTURE"; break; - case ImageFormat::EGLIMAGE: - aStream << "ImageFormat::EGLIMAGE"; break; case ImageFormat::D3D9_RGB32_TEXTURE: aStream << "ImageFormat::D3D9_RBG32_TEXTURE"; break; case ImageFormat::OVERLAY_IMAGE: diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index 2723edea0ca8..cc9dd207e7e8 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -118,24 +118,14 @@ ImageClient::CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwar if (!status) { return nullptr; } - } else if (aImage->GetFormat() == ImageFormat::SURFACE_TEXTURE || - aImage->GetFormat() == ImageFormat::EGLIMAGE) { - gfx::IntSize size = aImage->GetSize(); - - if (aImage->GetFormat() == ImageFormat::EGLIMAGE) { - EGLImageImage* typedImage = aImage->AsEGLImageImage(); - texture = EGLImageTextureData::CreateTextureClient( - typedImage, size, aForwarder->GetTextureForwarder(), TextureFlags::DEFAULT); #ifdef MOZ_WIDGET_ANDROID - } else if (aImage->GetFormat() == ImageFormat::SURFACE_TEXTURE) { - SurfaceTextureImage* typedImage = aImage->AsSurfaceTextureImage(); - texture = AndroidSurfaceTextureData::CreateTextureClient( - typedImage->GetHandle(), size, typedImage->GetContinuous(), typedImage->GetOriginPos(), - aForwarder->GetTextureForwarder(), TextureFlags::DEFAULT); + } else if (aImage->GetFormat() == ImageFormat::SURFACE_TEXTURE) { + gfx::IntSize size = aImage->GetSize(); + SurfaceTextureImage* typedImage = aImage->AsSurfaceTextureImage(); + texture = AndroidSurfaceTextureData::CreateTextureClient( + typedImage->GetHandle(), size, typedImage->GetContinuous(), typedImage->GetOriginPos(), + aForwarder->GetTextureForwarder(), TextureFlags::DEFAULT); #endif - } else { - MOZ_ASSERT(false, "Bad ImageFormat."); - } } else { RefPtr surface = aImage->GetAsSourceSurface(); MOZ_ASSERT(surface); diff --git a/gfx/layers/opengl/TextureClientOGL.cpp b/gfx/layers/opengl/TextureClientOGL.cpp index 80643d6ed0cb..867062c70d89 100644 --- a/gfx/layers/opengl/TextureClientOGL.cpp +++ b/gfx/layers/opengl/TextureClientOGL.cpp @@ -17,62 +17,6 @@ namespace layers { class CompositableForwarder; -//////////////////////////////////////////////////////////////////////// -// EGLImage - -EGLImageTextureData::EGLImageTextureData(EGLImageImage* aImage, gfx::IntSize aSize) -: mImage(aImage) -, mSize(aSize) -{ - MOZ_ASSERT(aImage); -} - -already_AddRefed -EGLImageTextureData::CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize, - LayersIPCChannel* aAllocator, TextureFlags aFlags) -{ - MOZ_ASSERT(XRE_IsParentProcess(), - "Can't pass an `EGLImage` between processes."); - - if (!aImage || !XRE_IsParentProcess()) { - return nullptr; - } - - // XXX - This is quite sad and slow. - aFlags |= TextureFlags::DEALLOCATE_CLIENT; - - if (aImage->GetOriginPos() == gl::OriginPos::BottomLeft) { - aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT; - } - - return TextureClient::CreateWithData( - new EGLImageTextureData(aImage, aSize), - aFlags, aAllocator - ); -} - -void -EGLImageTextureData::FillInfo(TextureData::Info& aInfo) const -{ - aInfo.size = mSize; - aInfo.format = gfx::SurfaceFormat::UNKNOWN; - aInfo.hasIntermediateBuffer = false; - aInfo.hasSynchronization = false; - aInfo.supportsMoz2D = false; - aInfo.canExposeMappedData = false; -} - -bool -EGLImageTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) -{ - const bool hasAlpha = true; - aOutDescriptor = - EGLImageDescriptor((uintptr_t)mImage->GetImage(), - (uintptr_t)mImage->GetSync(), - mImage->GetSize(), hasAlpha); - return true; -} - //////////////////////////////////////////////////////////////////////// // AndroidSurface diff --git a/gfx/layers/opengl/TextureClientOGL.h b/gfx/layers/opengl/TextureClientOGL.h index aae9d04316e7..c22664859375 100644 --- a/gfx/layers/opengl/TextureClientOGL.h +++ b/gfx/layers/opengl/TextureClientOGL.h @@ -20,34 +20,6 @@ namespace mozilla { namespace layers { -class EGLImageTextureData : public TextureData -{ -public: - - static already_AddRefed - CreateTextureClient(EGLImageImage* aImage, gfx::IntSize aSize, - LayersIPCChannel* aAllocator, TextureFlags aFlags); - - virtual void FillInfo(TextureData::Info& aInfo) const override; - - virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override; - - virtual void Deallocate(LayersIPCChannel*) override { mImage = nullptr; } - - virtual void Forget(LayersIPCChannel*) override { mImage = nullptr; } - - // Unused functions. - virtual bool Lock(OpenMode) override { return true; } - - virtual void Unlock() override {} - -protected: - EGLImageTextureData(EGLImageImage* aImage, gfx::IntSize aSize); - - RefPtr mImage; - const gfx::IntSize mSize; -}; - #ifdef MOZ_WIDGET_ANDROID class AndroidSurfaceTextureData : public TextureData