|
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
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 MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H |
|
7 #define MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H |
|
8 |
|
9 #include "mozilla/layers/TextureHostOGL.h" |
|
10 |
|
11 class MacIOSurface; |
|
12 |
|
13 namespace mozilla { |
|
14 namespace layers { |
|
15 |
|
16 /** |
|
17 * A texture source meant for use with MacIOSurfaceTextureHostOGL. |
|
18 * |
|
19 * It does not own any GL texture, and attaches its shared handle to one of |
|
20 * the compositor's temporary textures when binding. |
|
21 */ |
|
22 class MacIOSurfaceTextureSourceOGL : public NewTextureSource |
|
23 , public TextureSourceOGL |
|
24 { |
|
25 public: |
|
26 MacIOSurfaceTextureSourceOGL(CompositorOGL* aCompositor, |
|
27 MacIOSurface* aSurface); |
|
28 virtual ~MacIOSurfaceTextureSourceOGL(); |
|
29 |
|
30 virtual TextureSourceOGL* AsSourceOGL() { return this; } |
|
31 |
|
32 virtual void BindTexture(GLenum activetex, gfx::Filter aFilter) MOZ_OVERRIDE; |
|
33 |
|
34 virtual bool IsValid() const MOZ_OVERRIDE { return !!gl(); } |
|
35 |
|
36 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
|
37 |
|
38 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; |
|
39 |
|
40 virtual GLenum GetTextureTarget() const { return LOCAL_GL_TEXTURE_RECTANGLE_ARB; } |
|
41 |
|
42 virtual GLenum GetWrapMode() const MOZ_OVERRIDE { return LOCAL_GL_CLAMP_TO_EDGE; } |
|
43 |
|
44 // MacIOSurfaceTextureSourceOGL doesn't own any gl texture |
|
45 virtual void DeallocateDeviceData() {} |
|
46 |
|
47 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
|
48 |
|
49 gl::GLContext* gl() const; |
|
50 |
|
51 protected: |
|
52 CompositorOGL* mCompositor; |
|
53 RefPtr<MacIOSurface> mSurface; |
|
54 }; |
|
55 |
|
56 /** |
|
57 * A TextureHost for shared MacIOSurface |
|
58 * |
|
59 * Most of the logic actually happens in MacIOSurfaceTextureSourceOGL. |
|
60 */ |
|
61 class MacIOSurfaceTextureHostOGL : public TextureHost |
|
62 { |
|
63 public: |
|
64 MacIOSurfaceTextureHostOGL(TextureFlags aFlags, |
|
65 const SurfaceDescriptorMacIOSurface& aDescriptor); |
|
66 |
|
67 // SharedTextureHostOGL doesn't own any GL texture |
|
68 virtual void DeallocateDeviceData() MOZ_OVERRIDE {} |
|
69 |
|
70 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
|
71 |
|
72 virtual bool Lock() MOZ_OVERRIDE; |
|
73 |
|
74 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; |
|
75 |
|
76 virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE |
|
77 { |
|
78 return mTextureSource; |
|
79 } |
|
80 |
|
81 virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE |
|
82 { |
|
83 return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING) |
|
84 } |
|
85 |
|
86 gl::GLContext* gl() const; |
|
87 |
|
88 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
|
89 |
|
90 #ifdef MOZ_LAYERS_HAVE_LOG |
|
91 virtual const char* Name() { return "MacIOSurfaceTextureHostOGL"; } |
|
92 #endif |
|
93 |
|
94 protected: |
|
95 CompositorOGL* mCompositor; |
|
96 RefPtr<MacIOSurfaceTextureSourceOGL> mTextureSource; |
|
97 RefPtr<MacIOSurface> mSurface; |
|
98 }; |
|
99 |
|
100 } |
|
101 } |
|
102 |
|
103 #endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H |