gfx/layers/opengl/TextureClientOGL.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:8084ac9e0a65
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_TEXTURECLIENTOGL_H
7 #define MOZILLA_GFX_TEXTURECLIENTOGL_H
8
9 #include "GLContextTypes.h" // for SharedTextureHandle, etc
10 #include "gfxTypes.h"
11 #include "mozilla/Attributes.h" // for MOZ_OVERRIDE
12 #include "mozilla/gfx/Point.h" // for IntSize
13 #include "mozilla/layers/CompositorTypes.h"
14 #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor
15 #include "mozilla/layers/TextureClient.h" // for TextureClient, etc
16
17 namespace mozilla {
18 namespace gfx {
19 class SurfaceStream;
20 }
21 }
22
23 namespace mozilla {
24 namespace layers {
25
26 class CompositableForwarder;
27
28 /**
29 * A TextureClient implementation to share TextureMemory that is already
30 * on the GPU, for the OpenGL backend.
31 */
32 class SharedTextureClientOGL : public TextureClient
33 {
34 public:
35 SharedTextureClientOGL(TextureFlags aFlags);
36
37 ~SharedTextureClientOGL();
38
39 virtual bool IsAllocated() const MOZ_OVERRIDE;
40
41 virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
42
43 virtual bool Lock(OpenMode mode) MOZ_OVERRIDE;
44
45 virtual void Unlock() MOZ_OVERRIDE;
46
47 virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; }
48
49 virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; }
50
51 void InitWith(gl::SharedTextureHandle aHandle,
52 gfx::IntSize aSize,
53 gl::SharedTextureShareType aShareType,
54 bool aInverted = false);
55
56 virtual gfx::IntSize GetSize() const { return mSize; }
57
58 virtual TextureClientData* DropTextureData() MOZ_OVERRIDE
59 {
60 // XXX - right now the code paths using this are managing the shared texture
61 // data, although they should use a TextureClientData for this to ensure that
62 // the destruction sequence is race-free.
63 MarkInvalid();
64 return nullptr;
65 }
66
67 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
68 {
69 return gfx::SurfaceFormat::UNKNOWN;
70 }
71
72 virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE
73 {
74 return false;
75 }
76
77 protected:
78 gl::SharedTextureHandle mHandle;
79 gfx::IntSize mSize;
80 gl::SharedTextureShareType mShareType;
81 bool mInverted;
82 bool mIsLocked;
83 };
84
85 /**
86 * A TextureClient implementation to share SurfaceStream.
87 */
88 class StreamTextureClientOGL : public TextureClient
89 {
90 public:
91 StreamTextureClientOGL(TextureFlags aFlags);
92
93 ~StreamTextureClientOGL();
94
95 virtual bool IsAllocated() const MOZ_OVERRIDE;
96
97 virtual bool Lock(OpenMode mode) MOZ_OVERRIDE;
98
99 virtual void Unlock() MOZ_OVERRIDE;
100
101 virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; }
102
103 virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
104
105 virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; }
106
107 virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; }
108
109 void InitWith(gfx::SurfaceStream* aStream);
110
111 virtual gfx::IntSize GetSize() const { return gfx::IntSize(); }
112
113 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
114 {
115 return gfx::SurfaceFormat::UNKNOWN;
116 }
117
118 virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE
119 {
120 return false;
121 }
122
123 protected:
124 bool mIsLocked;
125 RefPtr<gfx::SurfaceStream> mStream;
126 RefPtr<gl::GLContext> mGL;
127 };
128
129 } // namespace
130 } // namespace
131
132 #endif

mercurial