gfx/gl/SharedSurfaceGralloc.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial