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