Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
6 #ifndef MOZILLA_GFX_TEXTURECLIENTOGL_H
7 #define MOZILLA_GFX_TEXTURECLIENTOGL_H
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
17 namespace mozilla {
18 namespace gfx {
19 class SurfaceStream;
20 }
21 }
23 namespace mozilla {
24 namespace layers {
26 class CompositableForwarder;
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);
37 ~SharedTextureClientOGL();
39 virtual bool IsAllocated() const MOZ_OVERRIDE;
41 virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
43 virtual bool Lock(OpenMode mode) MOZ_OVERRIDE;
45 virtual void Unlock() MOZ_OVERRIDE;
47 virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; }
49 virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; }
51 void InitWith(gl::SharedTextureHandle aHandle,
52 gfx::IntSize aSize,
53 gl::SharedTextureShareType aShareType,
54 bool aInverted = false);
56 virtual gfx::IntSize GetSize() const { return mSize; }
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 }
67 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
68 {
69 return gfx::SurfaceFormat::UNKNOWN;
70 }
72 virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE
73 {
74 return false;
75 }
77 protected:
78 gl::SharedTextureHandle mHandle;
79 gfx::IntSize mSize;
80 gl::SharedTextureShareType mShareType;
81 bool mInverted;
82 bool mIsLocked;
83 };
85 /**
86 * A TextureClient implementation to share SurfaceStream.
87 */
88 class StreamTextureClientOGL : public TextureClient
89 {
90 public:
91 StreamTextureClientOGL(TextureFlags aFlags);
93 ~StreamTextureClientOGL();
95 virtual bool IsAllocated() const MOZ_OVERRIDE;
97 virtual bool Lock(OpenMode mode) MOZ_OVERRIDE;
99 virtual void Unlock() MOZ_OVERRIDE;
101 virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; }
103 virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
105 virtual TextureClientData* DropTextureData() MOZ_OVERRIDE { return nullptr; }
107 virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return false; }
109 void InitWith(gfx::SurfaceStream* aStream);
111 virtual gfx::IntSize GetSize() const { return gfx::IntSize(); }
113 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE
114 {
115 return gfx::SurfaceFormat::UNKNOWN;
116 }
118 virtual bool AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags) MOZ_OVERRIDE
119 {
120 return false;
121 }
123 protected:
124 bool mIsLocked;
125 RefPtr<gfx::SurfaceStream> mStream;
126 RefPtr<gl::GLContext> mGL;
127 };
129 } // namespace
130 } // namespace
132 #endif