1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/gl/SharedSurfaceANGLE.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,115 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef SHARED_SURFACE_ANGLE_H_ 1.10 +#define SHARED_SURFACE_ANGLE_H_ 1.11 + 1.12 +#include "SharedSurfaceGL.h" 1.13 +#include "SurfaceFactory.h" 1.14 +#include "GLLibraryEGL.h" 1.15 +#include "SurfaceTypes.h" 1.16 + 1.17 +#include <windows.h> 1.18 +#include <d3d10_1.h> 1.19 + 1.20 +namespace mozilla { 1.21 +namespace gl { 1.22 + 1.23 +class GLContext; 1.24 + 1.25 +class SharedSurface_ANGLEShareHandle 1.26 + : public SharedSurface_GL 1.27 +{ 1.28 +public: 1.29 + static SharedSurface_ANGLEShareHandle* Create(GLContext* gl, ID3D10Device1* d3d, 1.30 + EGLContext context, EGLConfig config, 1.31 + const gfx::IntSize& size, 1.32 + bool hasAlpha); 1.33 + 1.34 + static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) { 1.35 + MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLSurfaceANGLE); 1.36 + 1.37 + return (SharedSurface_ANGLEShareHandle*)surf; 1.38 + } 1.39 + 1.40 +protected: 1.41 + GLLibraryEGL* const mEGL; 1.42 + const EGLContext mContext; 1.43 + const EGLSurface mPBuffer; 1.44 + nsRefPtr<ID3D10Texture2D> mTexture; 1.45 + nsRefPtr<ID3D10ShaderResourceView> mSRV; 1.46 + 1.47 + SharedSurface_ANGLEShareHandle(GLContext* gl, 1.48 + GLLibraryEGL* egl, 1.49 + const gfx::IntSize& size, 1.50 + bool hasAlpha, 1.51 + EGLContext context, 1.52 + EGLSurface pbuffer, 1.53 + ID3D10Texture2D* texture, 1.54 + ID3D10ShaderResourceView* srv) 1.55 + : SharedSurface_GL(SharedSurfaceType::EGLSurfaceANGLE, 1.56 + AttachmentType::Screen, 1.57 + gl, 1.58 + size, 1.59 + hasAlpha) 1.60 + , mEGL(egl) 1.61 + , mContext(context) 1.62 + , mPBuffer(pbuffer) 1.63 + , mTexture(texture) 1.64 + , mSRV(srv) 1.65 + {} 1.66 + 1.67 + EGLDisplay Display(); 1.68 + 1.69 +public: 1.70 + virtual ~SharedSurface_ANGLEShareHandle(); 1.71 + 1.72 + virtual void LockProdImpl() MOZ_OVERRIDE; 1.73 + virtual void UnlockProdImpl() MOZ_OVERRIDE; 1.74 + 1.75 + virtual void Fence() MOZ_OVERRIDE; 1.76 + virtual bool WaitSync() MOZ_OVERRIDE; 1.77 + 1.78 + // Implementation-specific functions below: 1.79 + ID3D10ShaderResourceView* GetSRV() { 1.80 + return mSRV; 1.81 + } 1.82 +}; 1.83 + 1.84 + 1.85 + 1.86 +class SurfaceFactory_ANGLEShareHandle 1.87 + : public SurfaceFactory_GL 1.88 +{ 1.89 +protected: 1.90 + GLContext* const mProdGL; 1.91 + GLLibraryEGL* const mEGL; 1.92 + nsRefPtr<ID3D10Device1> mConsD3D; 1.93 + EGLContext mContext; 1.94 + EGLConfig mConfig; 1.95 + 1.96 +public: 1.97 + static SurfaceFactory_ANGLEShareHandle* Create(GLContext* gl, 1.98 + ID3D10Device1* d3d, 1.99 + const SurfaceCaps& caps); 1.100 + 1.101 +protected: 1.102 + SurfaceFactory_ANGLEShareHandle(GLContext* gl, 1.103 + GLLibraryEGL* egl, 1.104 + ID3D10Device1* d3d, 1.105 + const SurfaceCaps& caps); 1.106 + 1.107 + virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE { 1.108 + bool hasAlpha = mReadCaps.alpha; 1.109 + return SharedSurface_ANGLEShareHandle::Create(mProdGL, mConsD3D, 1.110 + mContext, mConfig, 1.111 + size, hasAlpha); 1.112 + } 1.113 +}; 1.114 + 1.115 +} /* namespace gfx */ 1.116 +} /* namespace mozilla */ 1.117 + 1.118 +#endif /* SHARED_SURFACE_ANGLE_H_ */