gfx/layers/opengl/GrallocTextureHost.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.

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_GRALLOCTEXTUREHOST_H
michael@0 7 #define MOZILLA_GFX_GRALLOCTEXTUREHOST_H
michael@0 8 #ifdef MOZ_WIDGET_GONK
michael@0 9
michael@0 10 #include "mozilla/layers/TextureHostOGL.h"
michael@0 11 #include "mozilla/layers/ShadowLayerUtilsGralloc.h"
michael@0 12 #include <ui/GraphicBuffer.h>
michael@0 13
michael@0 14 namespace mozilla {
michael@0 15 namespace layers {
michael@0 16
michael@0 17 class GrallocTextureHostOGL;
michael@0 18
michael@0 19 class GrallocTextureSourceOGL : public NewTextureSource
michael@0 20 , public TextureSourceOGL
michael@0 21 {
michael@0 22 public:
michael@0 23 friend class GrallocTextureHostOGL;
michael@0 24
michael@0 25 GrallocTextureSourceOGL(CompositorOGL* aCompositor,
michael@0 26 android::GraphicBuffer* aGraphicBuffer,
michael@0 27 gfx::SurfaceFormat aFormat);
michael@0 28
michael@0 29 virtual ~GrallocTextureSourceOGL();
michael@0 30
michael@0 31 virtual bool IsValid() const MOZ_OVERRIDE;
michael@0 32
michael@0 33 virtual void BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) MOZ_OVERRIDE;
michael@0 34
michael@0 35 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
michael@0 36
michael@0 37 virtual TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE { return this; }
michael@0 38
michael@0 39 virtual GLenum GetTextureTarget() const MOZ_OVERRIDE;
michael@0 40
michael@0 41 virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
michael@0 42
michael@0 43 virtual GLenum GetWrapMode() const MOZ_OVERRIDE
michael@0 44 {
michael@0 45 return LOCAL_GL_CLAMP_TO_EDGE;
michael@0 46 }
michael@0 47
michael@0 48 virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE;
michael@0 49
michael@0 50 void DeallocateDeviceData();
michael@0 51
michael@0 52 gl::GLContext* gl() const;
michael@0 53
michael@0 54 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
michael@0 55
michael@0 56 void ForgetBuffer()
michael@0 57 {
michael@0 58 mGraphicBuffer = nullptr;
michael@0 59 }
michael@0 60
michael@0 61 TemporaryRef<gfx::DataSourceSurface> GetAsSurface();
michael@0 62
michael@0 63 GLuint GetGLTexture();
michael@0 64
michael@0 65 void Lock();
michael@0 66
michael@0 67 protected:
michael@0 68 CompositorOGL* mCompositor;
michael@0 69 android::sp<android::GraphicBuffer> mGraphicBuffer;
michael@0 70 EGLImage mEGLImage;
michael@0 71 GLuint mTexture;
michael@0 72 gfx::SurfaceFormat mFormat;
michael@0 73 bool mNeedsReset;
michael@0 74 };
michael@0 75
michael@0 76 class GrallocTextureHostOGL : public TextureHost
michael@0 77 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
michael@0 78 , public TextureHostOGL
michael@0 79 #endif
michael@0 80 {
michael@0 81 friend class GrallocBufferActor;
michael@0 82 public:
michael@0 83 GrallocTextureHostOGL(TextureFlags aFlags,
michael@0 84 const NewSurfaceDescriptorGralloc& aDescriptor);
michael@0 85
michael@0 86 virtual ~GrallocTextureHostOGL();
michael@0 87
michael@0 88 virtual void Updated(const nsIntRegion* aRegion) MOZ_OVERRIDE {}
michael@0 89
michael@0 90 virtual bool Lock() MOZ_OVERRIDE;
michael@0 91
michael@0 92 virtual void Unlock() MOZ_OVERRIDE;
michael@0 93
michael@0 94 virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
michael@0 95
michael@0 96 virtual void DeallocateSharedData() MOZ_OVERRIDE;
michael@0 97
michael@0 98 virtual void ForgetSharedData() MOZ_OVERRIDE;
michael@0 99
michael@0 100 virtual void DeallocateDeviceData() MOZ_OVERRIDE;
michael@0 101
michael@0 102 virtual gfx::SurfaceFormat GetFormat() const;
michael@0 103
michael@0 104 virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
michael@0 105
michael@0 106 virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
michael@0 107
michael@0 108 virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
michael@0 109 {
michael@0 110 return mTextureSource;
michael@0 111 }
michael@0 112
michael@0 113 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
michael@0 114 virtual TextureHostOGL* AsHostOGL() MOZ_OVERRIDE
michael@0 115 {
michael@0 116 return this;
michael@0 117 }
michael@0 118 #endif
michael@0 119
michael@0 120 virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
michael@0 121
michael@0 122 virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE;
michael@0 123
michael@0 124 bool IsValid() const;
michael@0 125
michael@0 126 virtual const char* Name() MOZ_OVERRIDE { return "GrallocTextureHostOGL"; }
michael@0 127
michael@0 128 // Forget buffer actor. Used only for hacky fix for bug 966446.
michael@0 129 virtual void ForgetBufferActor()
michael@0 130 {
michael@0 131 mGrallocActor = nullptr;
michael@0 132 }
michael@0 133
michael@0 134 private:
michael@0 135 GrallocBufferActor* mGrallocActor;
michael@0 136 RefPtr<GrallocTextureSourceOGL> mTextureSource;
michael@0 137 gfx::IntSize mSize; // See comment in textureClientOGL.h
michael@0 138 };
michael@0 139
michael@0 140 } // namespace layers
michael@0 141 } // namespace mozilla
michael@0 142
michael@0 143 #endif
michael@0 144 #endif

mercurial