|
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_MACIOSURFACETEXTUREHOST_BASIC_H |
|
7 #define MOZILLA_GFX_MACIOSURFACETEXTUREHOST_BASIC_H |
|
8 |
|
9 #include "mozilla/layers/TextureHostBasic.h" |
|
10 |
|
11 class MacIOSurface; |
|
12 |
|
13 namespace mozilla { |
|
14 namespace layers { |
|
15 |
|
16 class BasicCompositor; |
|
17 |
|
18 /** |
|
19 * A texture source meant for use with BasicCompositor. |
|
20 * |
|
21 * It does not own any GL texture, and attaches its shared handle to one of |
|
22 * the compositor's temporary textures when binding. |
|
23 */ |
|
24 class MacIOSurfaceTextureSourceBasic |
|
25 : public TextureSourceBasic, |
|
26 public NewTextureSource |
|
27 { |
|
28 public: |
|
29 MacIOSurfaceTextureSourceBasic(BasicCompositor* aCompositor, |
|
30 MacIOSurface* aSurface); |
|
31 virtual ~MacIOSurfaceTextureSourceBasic(); |
|
32 |
|
33 virtual TextureSourceBasic* AsSourceBasic() MOZ_OVERRIDE { return this; } |
|
34 |
|
35 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
|
36 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; |
|
37 virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) MOZ_OVERRIDE; |
|
38 |
|
39 virtual void DeallocateDeviceData() MOZ_OVERRIDE { } |
|
40 |
|
41 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
|
42 |
|
43 protected: |
|
44 BasicCompositor* mCompositor; |
|
45 RefPtr<MacIOSurface> mSurface; |
|
46 RefPtr<gfx::SourceSurface> mSourceSurface; |
|
47 }; |
|
48 |
|
49 /** |
|
50 * A TextureHost for shared MacIOSurface |
|
51 * |
|
52 * Most of the logic actually happens in MacIOSurfaceTextureSourceBasic. |
|
53 */ |
|
54 class MacIOSurfaceTextureHostBasic : public TextureHost |
|
55 { |
|
56 public: |
|
57 MacIOSurfaceTextureHostBasic(TextureFlags aFlags, |
|
58 const SurfaceDescriptorMacIOSurface& aDescriptor); |
|
59 |
|
60 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; |
|
61 |
|
62 virtual bool Lock() MOZ_OVERRIDE; |
|
63 |
|
64 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE; |
|
65 |
|
66 virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE |
|
67 { |
|
68 return mTextureSource; |
|
69 } |
|
70 |
|
71 virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE |
|
72 { |
|
73 return nullptr; // XXX - implement this (for MOZ_DUMP_PAINTING) |
|
74 } |
|
75 |
|
76 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE; |
|
77 |
|
78 #ifdef MOZ_LAYERS_HAVE_LOG |
|
79 virtual const char* Name() { return "MacIOSurfaceTextureHostBasic"; } |
|
80 #endif |
|
81 |
|
82 protected: |
|
83 BasicCompositor* mCompositor; |
|
84 RefPtr<MacIOSurfaceTextureSourceBasic> mTextureSource; |
|
85 RefPtr<MacIOSurface> mSurface; |
|
86 }; |
|
87 |
|
88 } |
|
89 } |
|
90 |
|
91 #endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_BASIC_H |