|
1 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef SHARED_SURFACE_ANGLE_H_ |
|
7 #define SHARED_SURFACE_ANGLE_H_ |
|
8 |
|
9 #include "SharedSurfaceGL.h" |
|
10 #include "SurfaceFactory.h" |
|
11 #include "GLLibraryEGL.h" |
|
12 #include "SurfaceTypes.h" |
|
13 |
|
14 #include <windows.h> |
|
15 #include <d3d10_1.h> |
|
16 |
|
17 namespace mozilla { |
|
18 namespace gl { |
|
19 |
|
20 class GLContext; |
|
21 |
|
22 class SharedSurface_ANGLEShareHandle |
|
23 : public SharedSurface_GL |
|
24 { |
|
25 public: |
|
26 static SharedSurface_ANGLEShareHandle* Create(GLContext* gl, ID3D10Device1* d3d, |
|
27 EGLContext context, EGLConfig config, |
|
28 const gfx::IntSize& size, |
|
29 bool hasAlpha); |
|
30 |
|
31 static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) { |
|
32 MOZ_ASSERT(surf->Type() == SharedSurfaceType::EGLSurfaceANGLE); |
|
33 |
|
34 return (SharedSurface_ANGLEShareHandle*)surf; |
|
35 } |
|
36 |
|
37 protected: |
|
38 GLLibraryEGL* const mEGL; |
|
39 const EGLContext mContext; |
|
40 const EGLSurface mPBuffer; |
|
41 nsRefPtr<ID3D10Texture2D> mTexture; |
|
42 nsRefPtr<ID3D10ShaderResourceView> mSRV; |
|
43 |
|
44 SharedSurface_ANGLEShareHandle(GLContext* gl, |
|
45 GLLibraryEGL* egl, |
|
46 const gfx::IntSize& size, |
|
47 bool hasAlpha, |
|
48 EGLContext context, |
|
49 EGLSurface pbuffer, |
|
50 ID3D10Texture2D* texture, |
|
51 ID3D10ShaderResourceView* srv) |
|
52 : SharedSurface_GL(SharedSurfaceType::EGLSurfaceANGLE, |
|
53 AttachmentType::Screen, |
|
54 gl, |
|
55 size, |
|
56 hasAlpha) |
|
57 , mEGL(egl) |
|
58 , mContext(context) |
|
59 , mPBuffer(pbuffer) |
|
60 , mTexture(texture) |
|
61 , mSRV(srv) |
|
62 {} |
|
63 |
|
64 EGLDisplay Display(); |
|
65 |
|
66 public: |
|
67 virtual ~SharedSurface_ANGLEShareHandle(); |
|
68 |
|
69 virtual void LockProdImpl() MOZ_OVERRIDE; |
|
70 virtual void UnlockProdImpl() MOZ_OVERRIDE; |
|
71 |
|
72 virtual void Fence() MOZ_OVERRIDE; |
|
73 virtual bool WaitSync() MOZ_OVERRIDE; |
|
74 |
|
75 // Implementation-specific functions below: |
|
76 ID3D10ShaderResourceView* GetSRV() { |
|
77 return mSRV; |
|
78 } |
|
79 }; |
|
80 |
|
81 |
|
82 |
|
83 class SurfaceFactory_ANGLEShareHandle |
|
84 : public SurfaceFactory_GL |
|
85 { |
|
86 protected: |
|
87 GLContext* const mProdGL; |
|
88 GLLibraryEGL* const mEGL; |
|
89 nsRefPtr<ID3D10Device1> mConsD3D; |
|
90 EGLContext mContext; |
|
91 EGLConfig mConfig; |
|
92 |
|
93 public: |
|
94 static SurfaceFactory_ANGLEShareHandle* Create(GLContext* gl, |
|
95 ID3D10Device1* d3d, |
|
96 const SurfaceCaps& caps); |
|
97 |
|
98 protected: |
|
99 SurfaceFactory_ANGLEShareHandle(GLContext* gl, |
|
100 GLLibraryEGL* egl, |
|
101 ID3D10Device1* d3d, |
|
102 const SurfaceCaps& caps); |
|
103 |
|
104 virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE { |
|
105 bool hasAlpha = mReadCaps.alpha; |
|
106 return SharedSurface_ANGLEShareHandle::Create(mProdGL, mConsD3D, |
|
107 mContext, mConfig, |
|
108 size, hasAlpha); |
|
109 } |
|
110 }; |
|
111 |
|
112 } /* namespace gfx */ |
|
113 } /* namespace mozilla */ |
|
114 |
|
115 #endif /* SHARED_SURFACE_ANGLE_H_ */ |