diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp index cfce39aeb98a..6094d5ed9518 100644 --- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -129,7 +129,10 @@ public: if (mTextureInfo.mWidth == 0 || mTextureInfo.mHeight == 0) return 0; - SharedTextureHandle handle = sPluginContext->CreateSharedHandle(TextureImage::ThreadShared, (void*)mTextureInfo.mTexture, GLContext::TextureID); + SharedTextureHandle handle = + sPluginContext->CreateSharedHandle(GLContext::SameProcess, + (void*)mTextureInfo.mTexture, + GLContext::TextureID); // We want forget about this now, so delete the texture. Assigning it to zero // ensures that we create a new one in Lock() @@ -1000,7 +1003,9 @@ SharedTextureHandle nsNPAPIPluginInstance::CreateSharedHandle() return mContentTexture->CreateSharedHandle(); } else if (mContentSurface) { EnsureGLContext(); - return sPluginContext->CreateSharedHandle(TextureImage::ThreadShared, mContentSurface, GLContext::SurfaceTexture); + return sPluginContext->CreateSharedHandle(GLContext::SameProcess, + mContentSurface, + GLContext::SurfaceTexture); } else return 0; } diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index bf2d859833ca..55014898a03e 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -186,7 +186,7 @@ nsPluginInstanceOwner::GetImageContainer() SharedTextureImage::Data data; data.mHandle = mInstance->CreateSharedHandle(); - data.mShareType = mozilla::gl::TextureImage::ThreadShared; + data.mShareType = mozilla::gl::GLContext::SameProcess; data.mInverted = mInstance->Inverted(); gfxRect r = GetPluginRect(); @@ -1723,8 +1723,10 @@ already_AddRefed nsPluginInstanceOwner::GetImageContainerForVide SharedTextureImage::Data data; - data.mHandle = mInstance->GLContext()->CreateSharedHandle(gl::TextureImage::ThreadShared, aVideoInfo->mSurfaceTexture, gl::GLContext::SurfaceTexture); - data.mShareType = mozilla::gl::TextureImage::ThreadShared; + data.mShareType = gl::GLContext::SameProcess; + data.mHandle = mInstance->GLContext()->CreateSharedHandle(data.mShareType, + aVideoInfo->mSurfaceTexture, + gl::GLContext::SurfaceTexture); // The logic below for Honeycomb is just a guess, but seems to work. We don't have a separate // inverted flag for video. diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 38b26722f416..5188d4411157 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -90,11 +90,6 @@ public: ForceSingleTile = 0x4 }; - enum TextureShareType { - ThreadShared = 0x0, - ProcessShared = 0x1 - }; - typedef gfxASurface::gfxContentType ContentType; virtual ~TextureImage() {} @@ -912,6 +907,12 @@ public: return IsExtensionSupported(EXT_framebuffer_blit) || IsExtensionSupported(ANGLE_framebuffer_blit); } + + enum SharedTextureShareType { + SameProcess = 0, + CrossProcess + }; + enum SharedTextureBufferType { TextureID #ifdef MOZ_WIDGET_ANDROID @@ -922,23 +923,26 @@ public: /** * Create new shared GLContext content handle, must be released by ReleaseSharedHandle. */ - virtual SharedTextureHandle CreateSharedHandle(TextureImage::TextureShareType aType) { return 0; } + virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType) + { return 0; } /* * Create a new shared GLContext content handle, using the passed buffer as a source. * Must be released by ReleaseSharedHandle. UpdateSharedHandle will have no effect * on handles created with this method, as the caller owns the source (the passed buffer) * and is responsible for updating it accordingly. */ - virtual SharedTextureHandle CreateSharedHandle(TextureImage::TextureShareType aType, - void* aBuffer, - SharedTextureBufferType aBufferType) { return 0; } + virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType, + void* buffer, + SharedTextureBufferType bufferType) + { return 0; } /** * Publish GLContext content to intermediate buffer attached to shared handle. * Shared handle content is ready to be used after call returns, and no need extra Flush/Finish are required. * GLContext must be current before this call */ - virtual void UpdateSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle) { } + virtual void UpdateSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle) + { } /** * - It is better to call ReleaseSharedHandle before original GLContext destroyed, * otherwise warning will be thrown on attempt to destroy Texture associated with SharedHandle, depends on backend implementation. @@ -952,8 +956,9 @@ public: * SharedHandle (currently EGLImage) does not require GLContext because it is EGL call, and can be destroyed * at any time, unless EGLImage have siblings (which are not expected with current API). */ - virtual void ReleaseSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle) { } + virtual void ReleaseSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle) + { } typedef struct { @@ -966,21 +971,24 @@ public: * Returns information necessary for rendering a shared handle. * These values change depending on what sharing mechanism is in use */ - virtual bool GetSharedHandleDetails(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle, - SharedHandleDetails& aDetails) { return false; } + virtual bool GetSharedHandleDetails(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle, + SharedHandleDetails& details) + { return false; } /** * Attach Shared GL Handle to GL_TEXTURE_2D target * GLContext must be current before this call */ - virtual bool AttachSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle) { return false; } + virtual bool AttachSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle) + { return false; } /** * Detach Shared GL Handle from GL_TEXTURE_2D target */ - virtual void DetachSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle) { return; } + virtual void DetachSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle) + { } private: GLuint mUserBoundDrawFBO; diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index e080cb10159b..85bb1c6aad10 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -646,19 +646,19 @@ public: return sEGLLibrary.HasKHRLockSurface(); } - virtual SharedTextureHandle CreateSharedHandle(TextureImage::TextureShareType aType); - virtual SharedTextureHandle CreateSharedHandle(TextureImage::TextureShareType aType, - void* aBuffer, - SharedTextureBufferType aBufferType); - virtual void UpdateSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle); - virtual void ReleaseSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle); - virtual bool GetSharedHandleDetails(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle, - SharedHandleDetails& aDetails); - virtual bool AttachSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle); + virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType); + virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType, + void* buffer, + SharedTextureBufferType bufferType); + virtual void UpdateSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle); + virtual void ReleaseSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle); + virtual bool GetSharedHandleDetails(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle, + SharedHandleDetails& details); + virtual bool AttachSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle); protected: friend class GLContextProviderEGL; @@ -854,15 +854,15 @@ private: }; void -GLContextEGL::UpdateSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle) +GLContextEGL::UpdateSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle) { - if (aType != TextureImage::ThreadShared) { + if (shareType != SameProcess) { NS_ERROR("Implementation not available for this sharing type"); return; } - SharedTextureHandleWrapper* wrapper = reinterpret_cast(aSharedHandle); + SharedTextureHandleWrapper* wrapper = reinterpret_cast(sharedHandle); NS_ASSERTION(wrapper->Type() == SharedHandleType::Image, "Expected EGLImage shared handle"); NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime"); @@ -895,9 +895,9 @@ GLContextEGL::UpdateSharedHandle(TextureImage::TextureShareType aType, } SharedTextureHandle -GLContextEGL::CreateSharedHandle(TextureImage::TextureShareType aType) +GLContextEGL::CreateSharedHandle(SharedTextureShareType shareType) { - if (aType != TextureImage::ThreadShared) + if (shareType != SameProcess) return 0; if (!mShareWithEGLImage) @@ -914,7 +914,7 @@ GLContextEGL::CreateSharedHandle(TextureImage::TextureShareType aType) if (!ok) { NS_ERROR("EGLImage creation for EGLTextureWrapper failed"); - ReleaseSharedHandle(aType, (SharedTextureHandle)tex); + ReleaseSharedHandle(shareType, (SharedTextureHandle)tex); return 0; } @@ -923,16 +923,16 @@ GLContextEGL::CreateSharedHandle(TextureImage::TextureShareType aType) } SharedTextureHandle -GLContextEGL::CreateSharedHandle(TextureImage::TextureShareType aType, - void* aBuffer, - SharedTextureBufferType aBufferType) +GLContextEGL::CreateSharedHandle(SharedTextureShareType shareType, + void* buffer, + SharedTextureBufferType bufferType) { // Both EGLImage and SurfaceTexture only support ThreadShared currently, but // it's possible to make SurfaceTexture work across processes. We should do that. - if (aType != TextureImage::ThreadShared) + if (shareType != SameProcess) return 0; - switch (aBufferType) { + switch (bufferType) { #ifdef MOZ_WIDGET_ANDROID case SharedTextureBufferType::SurfaceTexture: if (!IsExtensionSupported(GLContext::OES_EGL_image_external)) { @@ -940,13 +940,13 @@ GLContextEGL::CreateSharedHandle(TextureImage::TextureShareType aType, return 0; } - return (SharedTextureHandle) new SurfaceTextureWrapper(reinterpret_cast(aBuffer)); + return (SharedTextureHandle) new SurfaceTextureWrapper(reinterpret_cast(buffer)); #endif case SharedTextureBufferType::TextureID: { if (!mShareWithEGLImage) return 0; - GLuint texture = (uintptr_t)aBuffer; + GLuint texture = (uintptr_t)buffer; EGLTextureWrapper* tex = new EGLTextureWrapper(); if (!tex->CreateEGLImage(this, texture)) { NS_ERROR("EGLImage creation for EGLTextureWrapper failed"); @@ -962,15 +962,15 @@ GLContextEGL::CreateSharedHandle(TextureImage::TextureShareType aType, } } -void GLContextEGL::ReleaseSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle) +void GLContextEGL::ReleaseSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle) { - if (aType != TextureImage::ThreadShared) { + if (shareType != SameProcess) { NS_ERROR("Implementation not available for this sharing type"); return; } - SharedTextureHandleWrapper* wrapper = reinterpret_cast(aSharedHandle); + SharedTextureHandleWrapper* wrapper = reinterpret_cast(sharedHandle); switch (wrapper->Type()) { #ifdef MOZ_WIDGET_ANDROID @@ -982,24 +982,25 @@ void GLContextEGL::ReleaseSharedHandle(TextureImage::TextureShareType aType, case SharedHandleType::Image: { NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime"); - EGLTextureWrapper* wrap = (EGLTextureWrapper*)aSharedHandle; + EGLTextureWrapper* wrap = (EGLTextureWrapper*)sharedHandle; delete wrap; break; } default: NS_ERROR("Unknown shared handle type"); + return; } } -bool GLContextEGL::GetSharedHandleDetails(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle, - SharedHandleDetails& aDetails) +bool GLContextEGL::GetSharedHandleDetails(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle, + SharedHandleDetails& details) { - if (aType != TextureImage::ThreadShared) + if (shareType != SameProcess) return false; - SharedTextureHandleWrapper* wrapper = reinterpret_cast(aSharedHandle); + SharedTextureHandleWrapper* wrapper = reinterpret_cast(sharedHandle); switch (wrapper->Type()) { #ifdef MOZ_WIDGET_ANDROID @@ -1014,8 +1015,8 @@ bool GLContextEGL::GetSharedHandleDetails(TextureImage::TextureShareType aType, #endif case SharedHandleType::Image: - aDetails.mTarget = LOCAL_GL_TEXTURE_2D; - aDetails.mProgramType = RGBALayerProgramType; + details.mTarget = LOCAL_GL_TEXTURE_2D; + details.mProgramType = RGBALayerProgramType; break; default: @@ -1026,13 +1027,13 @@ bool GLContextEGL::GetSharedHandleDetails(TextureImage::TextureShareType aType, return true; } -bool GLContextEGL::AttachSharedHandle(TextureImage::TextureShareType aType, - SharedTextureHandle aSharedHandle) +bool GLContextEGL::AttachSharedHandle(SharedTextureShareType shareType, + SharedTextureHandle sharedHandle) { - if (aType != TextureImage::ThreadShared) + if (shareType != SameProcess) return false; - SharedTextureHandleWrapper* wrapper = reinterpret_cast(aSharedHandle); + SharedTextureHandleWrapper* wrapper = reinterpret_cast(sharedHandle); switch (wrapper->Type()) { #ifdef MOZ_WIDGET_ANDROID @@ -1057,7 +1058,7 @@ bool GLContextEGL::AttachSharedHandle(TextureImage::TextureShareType aType, case SharedHandleType::Image: { NS_ASSERTION(mShareWithEGLImage, "EGLImage not supported or disabled in runtime"); - EGLTextureWrapper* wrap = (EGLTextureWrapper*)aSharedHandle; + EGLTextureWrapper* wrap = (EGLTextureWrapper*)sharedHandle; wrap->WaitSync(); fEGLImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, wrap->GetEGLImage()); break; diff --git a/gfx/layers/SharedTextureImage.h b/gfx/layers/SharedTextureImage.h index 3f0732023954..2a42154cfcf6 100644 --- a/gfx/layers/SharedTextureImage.h +++ b/gfx/layers/SharedTextureImage.h @@ -20,7 +20,7 @@ class THEBES_API SharedTextureImage : public Image { public: struct Data { gl::SharedTextureHandle mHandle; - gl::TextureImage::TextureShareType mShareType; + gl::GLContext::SharedTextureShareType mShareType; gfxIntSize mSize; bool mInverted; }; @@ -41,4 +41,4 @@ private: } // layers } // mozilla -#endif // GFX_SHAREDTEXTUREIMAGE_H \ No newline at end of file +#endif // GFX_SHAREDTEXTUREIMAGE_H diff --git a/gfx/layers/basic/BasicCanvasLayer.cpp b/gfx/layers/basic/BasicCanvasLayer.cpp index fdc133d38747..e028468f29b1 100644 --- a/gfx/layers/basic/BasicCanvasLayer.cpp +++ b/gfx/layers/basic/BasicCanvasLayer.cpp @@ -387,24 +387,25 @@ BasicShadowableCanvasLayer::Paint(gfxContext* aContext, Layer* aMaskLayer) if (mGLContext && !mForceReadback && - BasicManager()->GetParentBackendType() == mozilla::layers::LAYERS_OPENGL) { - TextureImage::TextureShareType flags; + BasicManager()->GetParentBackendType() == mozilla::layers::LAYERS_OPENGL) + { + GLContext::SharedTextureShareType shareType; // if process type is default, then it is single-process (non-e10s) if (XRE_GetProcessType() == GeckoProcessType_Default) - flags = TextureImage::ThreadShared; + shareType = GLContext::SameProcess; else - flags = TextureImage::ProcessShared; + shareType = GLContext::CrossProcess; SharedTextureHandle handle = GetSharedBackBufferHandle(); if (!handle) { - handle = mGLContext->CreateSharedHandle(flags); + handle = mGLContext->CreateSharedHandle(shareType); if (handle) { - mBackBuffer = SharedTextureDescriptor(flags, handle, mBounds.Size(), false); + mBackBuffer = SharedTextureDescriptor(shareType, handle, mBounds.Size(), false); } } if (handle) { mGLContext->MakeCurrent(); - mGLContext->UpdateSharedHandle(flags, handle); + mGLContext->UpdateSharedHandle(shareType, handle); // call Painted() to reset our dirty 'bit' Painted(); FireDidTransactionCallback(); diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index 39db98123782..2d8e763f05b8 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -22,7 +22,7 @@ using mozilla::layers::SurfaceDescriptorX11; using mozilla::null_t; using mozilla::WindowsHandle; using mozilla::gl::SharedTextureHandle; -using mozilla::gl::TextureImage::TextureShareType; +using mozilla::gl::GLContext::SharedTextureShareType; namespace mozilla { namespace layers { @@ -37,7 +37,7 @@ struct SurfaceDescriptorD3D10 { }; struct SharedTextureDescriptor { - TextureShareType shareType; + SharedTextureShareType shareType; SharedTextureHandle handle; nsIntSize size; bool inverted; diff --git a/gfx/layers/ipc/ShadowLayerUtils.h b/gfx/layers/ipc/ShadowLayerUtils.h index 4d66cef624bd..b7eaa1d4d191 100644 --- a/gfx/layers/ipc/ShadowLayerUtils.h +++ b/gfx/layers/ipc/ShadowLayerUtils.h @@ -52,9 +52,9 @@ struct ParamTraits { #endif // !defined(MOZ_HAVE_XSURFACEDESCRIPTORX11) template<> -struct ParamTraits +struct ParamTraits { - typedef mozilla::gl::TextureImage::TextureShareType paramType; + typedef mozilla::gl::GLContext::SharedTextureShareType paramType; static void Write(Message* msg, const paramType& param) { diff --git a/gfx/layers/opengl/CanvasLayerOGL.cpp b/gfx/layers/opengl/CanvasLayerOGL.cpp index 3bd9e578b40e..6616fb9fde05 100644 --- a/gfx/layers/opengl/CanvasLayerOGL.cpp +++ b/gfx/layers/opengl/CanvasLayerOGL.cpp @@ -420,7 +420,10 @@ ShadowCanvasLayerOGL::Swap(const CanvasSurface& aNewFront, } else if (IsValidSharedTexDescriptor(aNewFront)) { MakeTextureIfNeeded(gl(), mTexture); if (!IsValidSharedTexDescriptor(mFrontBufferDescriptor)) { - mFrontBufferDescriptor = SharedTextureDescriptor(TextureImage::ThreadShared, 0, nsIntSize(0, 0), false); + mFrontBufferDescriptor = SharedTextureDescriptor(GLContext::SameProcess, + 0, + nsIntSize(0, 0), + false); } *aNewBack = mFrontBufferDescriptor; mFrontBufferDescriptor = aNewFront; diff --git a/gfx/layers/opengl/ImageLayerOGL.h b/gfx/layers/opengl/ImageLayerOGL.h index 5db8b6e9c897..5995c12ef7c9 100644 --- a/gfx/layers/opengl/ImageLayerOGL.h +++ b/gfx/layers/opengl/ImageLayerOGL.h @@ -194,7 +194,7 @@ private: // For SharedTextureHandle gl::SharedTextureHandle mSharedHandle; - gl::TextureImage::TextureShareType mShareType; + gl::GLContext::SharedTextureShareType mShareType; bool mInverted; GLuint mTexture;