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++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */ |
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 SHARED_SURFACE_GRALLOC_H_ |
michael@0 | 7 | #define SHARED_SURFACE_GRALLOC_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include "SharedSurfaceGL.h" |
michael@0 | 10 | #include "mozilla/layers/ISurfaceAllocator.h" |
michael@0 | 11 | #include "mozilla/layers/LayersSurfaces.h" |
michael@0 | 12 | #include "mozilla/layers/TextureClient.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace layers { |
michael@0 | 16 | class ISurfaceAllocator; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | namespace gl { |
michael@0 | 20 | class GLContext; |
michael@0 | 21 | class GLLibraryEGL; |
michael@0 | 22 | |
michael@0 | 23 | class SharedSurface_Gralloc |
michael@0 | 24 | : public SharedSurface_GL |
michael@0 | 25 | { |
michael@0 | 26 | public: |
michael@0 | 27 | static SharedSurface_Gralloc* Create(GLContext* prodGL, |
michael@0 | 28 | const GLFormats& formats, |
michael@0 | 29 | const gfx::IntSize& size, |
michael@0 | 30 | bool hasAlpha, |
michael@0 | 31 | layers::ISurfaceAllocator* allocator); |
michael@0 | 32 | |
michael@0 | 33 | static SharedSurface_Gralloc* Cast(SharedSurface* surf) { |
michael@0 | 34 | MOZ_ASSERT(surf->Type() == SharedSurfaceType::Gralloc); |
michael@0 | 35 | |
michael@0 | 36 | return (SharedSurface_Gralloc*)surf; |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | protected: |
michael@0 | 40 | GLLibraryEGL* const mEGL; |
michael@0 | 41 | RefPtr<layers::ISurfaceAllocator> mAllocator; |
michael@0 | 42 | RefPtr<layers::TextureClient> mTextureClient; |
michael@0 | 43 | const GLuint mProdTex; |
michael@0 | 44 | |
michael@0 | 45 | SharedSurface_Gralloc(GLContext* prodGL, |
michael@0 | 46 | const gfx::IntSize& size, |
michael@0 | 47 | bool hasAlpha, |
michael@0 | 48 | GLLibraryEGL* egl, |
michael@0 | 49 | layers::ISurfaceAllocator* allocator, |
michael@0 | 50 | layers::TextureClient* textureClient, |
michael@0 | 51 | GLuint prodTex) |
michael@0 | 52 | : SharedSurface_GL(SharedSurfaceType::Gralloc, |
michael@0 | 53 | AttachmentType::GLTexture, |
michael@0 | 54 | prodGL, |
michael@0 | 55 | size, |
michael@0 | 56 | hasAlpha) |
michael@0 | 57 | , mEGL(egl) |
michael@0 | 58 | , mAllocator(allocator) |
michael@0 | 59 | , mTextureClient(textureClient) |
michael@0 | 60 | , mProdTex(prodTex) |
michael@0 | 61 | {} |
michael@0 | 62 | |
michael@0 | 63 | static bool HasExtensions(GLLibraryEGL* egl, GLContext* gl); |
michael@0 | 64 | |
michael@0 | 65 | public: |
michael@0 | 66 | virtual ~SharedSurface_Gralloc(); |
michael@0 | 67 | |
michael@0 | 68 | virtual void Fence() MOZ_OVERRIDE; |
michael@0 | 69 | virtual bool WaitSync() MOZ_OVERRIDE; |
michael@0 | 70 | |
michael@0 | 71 | virtual void LockProdImpl() MOZ_OVERRIDE {} |
michael@0 | 72 | virtual void UnlockProdImpl() MOZ_OVERRIDE {} |
michael@0 | 73 | |
michael@0 | 74 | virtual GLuint ProdTexture() MOZ_OVERRIDE { |
michael@0 | 75 | return mProdTex; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | layers::TextureClient* GetTextureClient() { |
michael@0 | 79 | return mTextureClient; |
michael@0 | 80 | } |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | class SurfaceFactory_Gralloc |
michael@0 | 84 | : public SurfaceFactory_GL |
michael@0 | 85 | { |
michael@0 | 86 | protected: |
michael@0 | 87 | RefPtr<layers::ISurfaceAllocator> mAllocator; |
michael@0 | 88 | |
michael@0 | 89 | public: |
michael@0 | 90 | SurfaceFactory_Gralloc(GLContext* prodGL, |
michael@0 | 91 | const SurfaceCaps& caps, |
michael@0 | 92 | layers::ISurfaceAllocator* allocator = nullptr); |
michael@0 | 93 | |
michael@0 | 94 | virtual SharedSurface* CreateShared(const gfx::IntSize& size) MOZ_OVERRIDE { |
michael@0 | 95 | bool hasAlpha = mReadCaps.alpha; |
michael@0 | 96 | if (!mAllocator) { |
michael@0 | 97 | return nullptr; |
michael@0 | 98 | } |
michael@0 | 99 | return SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha, mAllocator); |
michael@0 | 100 | } |
michael@0 | 101 | }; |
michael@0 | 102 | |
michael@0 | 103 | } /* namespace gl */ |
michael@0 | 104 | } /* namespace mozilla */ |
michael@0 | 105 | |
michael@0 | 106 | #endif /* SHARED_SURFACE_GRALLOC_H_ */ |