michael@0: /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef SHARED_SURFACE_ANGLE_H_ michael@0: #define SHARED_SURFACE_ANGLE_H_ michael@0: michael@0: #include "SharedSurfaceGL.h" michael@0: #include "SurfaceFactory.h" michael@0: #include "GLLibraryEGL.h" michael@0: #include "SurfaceTypes.h" michael@0: michael@0: #include michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: michael@0: class GLContext; michael@0: michael@0: class SharedSurface_ANGLEShareHandle michael@0: : public SharedSurface_GL michael@0: { michael@0: public: michael@0: static SharedSurface_ANGLEShareHandle* Create(GLContext* gl, ID3D10Device1* d3d, michael@0: EGLContext context, EGLConfig config, michael@0: const gfx::IntSize& size, michael@0: bool hasAlpha); michael@0: michael@0: static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) { michael@0: MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLSurfaceANGLE); michael@0: michael@0: return (SharedSurface_ANGLEShareHandle*)surf; michael@0: } michael@0: michael@0: protected: michael@0: GLLibraryEGL* const mEGL; michael@0: const EGLContext mContext; michael@0: const EGLSurface mPBuffer; michael@0: nsRefPtr mTexture; michael@0: nsRefPtr mSRV; michael@0: michael@0: SharedSurface_ANGLEShareHandle(GLContext* gl, michael@0: GLLibraryEGL* egl, michael@0: const gfx::IntSize& size, michael@0: bool hasAlpha, michael@0: EGLContext context, michael@0: EGLSurface pbuffer, michael@0: ID3D10Texture2D* texture, michael@0: ID3D10ShaderResourceView* srv) michael@0: : SharedSurface_GL(SharedSurfaceType::EGLSurfaceANGLE, michael@0: AttachmentType::Screen, michael@0: gl, michael@0: size, michael@0: hasAlpha) michael@0: , mEGL(egl) michael@0: , mContext(context) michael@0: , mPBuffer(pbuffer) michael@0: , mTexture(texture) michael@0: , mSRV(srv) michael@0: {} michael@0: michael@0: EGLDisplay Display(); michael@0: michael@0: public: michael@0: virtual ~SharedSurface_ANGLEShareHandle(); michael@0: michael@0: virtual void LockProdImpl() MOZ_OVERRIDE; michael@0: virtual void UnlockProdImpl() MOZ_OVERRIDE; michael@0: michael@0: virtual void Fence() MOZ_OVERRIDE; michael@0: virtual bool WaitSync() MOZ_OVERRIDE; michael@0: michael@0: // Implementation-specific functions below: michael@0: ID3D10ShaderResourceView* GetSRV() { michael@0: return mSRV; michael@0: } michael@0: }; michael@0: michael@0: michael@0: michael@0: class SurfaceFactory_ANGLEShareHandle michael@0: : public SurfaceFactory_GL michael@0: { michael@0: protected: michael@0: GLContext* const mProdGL; michael@0: GLLibraryEGL* const mEGL; michael@0: nsRefPtr mConsD3D; michael@0: EGLContext mContext; michael@0: EGLConfig mConfig; michael@0: michael@0: public: michael@0: static SurfaceFactory_ANGLEShareHandle* Create(GLContext* gl, michael@0: ID3D10Device1* d3d, michael@0: const SurfaceCaps& caps); michael@0: michael@0: protected: michael@0: SurfaceFactory_ANGLEShareHandle(GLContext* gl, michael@0: GLLibraryEGL* egl, michael@0: ID3D10Device1* d3d, michael@0: const SurfaceCaps& caps); michael@0: michael@0: virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE { michael@0: bool hasAlpha = mReadCaps.alpha; michael@0: return SharedSurface_ANGLEShareHandle::Create(mProdGL, mConsD3D, michael@0: mContext, mConfig, michael@0: size, hasAlpha); michael@0: } michael@0: }; michael@0: michael@0: } /* namespace gfx */ michael@0: } /* namespace mozilla */ michael@0: michael@0: #endif /* SHARED_SURFACE_ANGLE_H_ */