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_GRALLOCTEXTUREHOST_H
7 #define MOZILLA_GFX_GRALLOCTEXTUREHOST_H
10 #include "mozilla/layers/TextureHostOGL.h"
11 #include "mozilla/layers/ShadowLayerUtilsGralloc.h"
12 #include <ui/GraphicBuffer.h>
17 class GrallocTextureHostOGL
;
19 class GrallocTextureSourceOGL
: public NewTextureSource
20 , public TextureSourceOGL
23 friend class GrallocTextureHostOGL
;
25 GrallocTextureSourceOGL(CompositorOGL
* aCompositor
,
26 android::GraphicBuffer
* aGraphicBuffer
,
27 gfx::SurfaceFormat aFormat
);
29 virtual bool IsValid() const MOZ_OVERRIDE
;
31 virtual void BindTexture(GLenum aTextureUnit
) MOZ_OVERRIDE
;
33 virtual void UnbindTexture() MOZ_OVERRIDE
{}
35 virtual gfx::IntSize
GetSize() const MOZ_OVERRIDE
;
37 virtual TextureSourceOGL
* AsSourceOGL() MOZ_OVERRIDE
{ return this; }
39 virtual GLenum
GetTextureTarget() const MOZ_OVERRIDE
;
41 virtual gfx::SurfaceFormat
GetFormat() const MOZ_OVERRIDE
;
43 virtual GLenum
GetWrapMode() const MOZ_OVERRIDE
45 return LOCAL_GL_CLAMP_TO_EDGE
;
48 void DeallocateDeviceData();
50 gl::GLContext
* gl() const;
52 void SetCompositor(CompositorOGL
* aCompositor
)
54 mCompositor
= aCompositor
;
59 mGraphicBuffer
= nullptr;
62 already_AddRefed
<gfxImageSurface
> GetAsSurface();
65 CompositorOGL
* mCompositor
;
66 android::sp
<android::GraphicBuffer
> mGraphicBuffer
;
68 gfx::SurfaceFormat mFormat
;
71 class GrallocTextureHostOGL
: public TextureHost
73 friend class GrallocBufferActor
;
75 GrallocTextureHostOGL(uint64_t aID
,
77 const NewSurfaceDescriptorGralloc
& aDescriptor
);
79 virtual ~GrallocTextureHostOGL();
81 virtual void Updated(const nsIntRegion
* aRegion
) MOZ_OVERRIDE
{}
83 virtual bool Lock() MOZ_OVERRIDE
;
85 virtual void Unlock() MOZ_OVERRIDE
;
87 virtual void SetCompositor(Compositor
* aCompositor
) MOZ_OVERRIDE
;
89 virtual void DeallocateSharedData() MOZ_OVERRIDE
;
91 virtual void DeallocateDeviceData() MOZ_OVERRIDE
;
93 virtual gfx::SurfaceFormat
GetFormat() const;
95 virtual gfx::IntSize
GetSize() const MOZ_OVERRIDE
{ return mSize
; }
97 virtual LayerRenderState
GetRenderState() MOZ_OVERRIDE
;
99 virtual NewTextureSource
* GetTextureSources() MOZ_OVERRIDE
101 return mTextureSource
;
104 virtual already_AddRefed
<gfxImageSurface
> GetAsSurface() MOZ_OVERRIDE
;
106 bool IsValid() const;
108 #ifdef MOZ_LAYERS_HAVE_LOG
109 virtual const char* Name() { return "GrallocTextureHostOGL"; }
113 GrallocBufferActor
* mGrallocActor
;
114 RefPtr
<GrallocTextureSourceOGL
> mTextureSource
;
115 gfx::IntSize mSize
; // See comment in textureClientOGL.h
118 } // namespace layers
119 } // namespace mozilla