2013-08-09 08:23:46 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
// * This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_GFX_GRALLOCTEXTUREHOST_H
|
|
|
|
#define MOZILLA_GFX_GRALLOCTEXTUREHOST_H
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
|
|
|
|
#include "mozilla/layers/TextureHostOGL.h"
|
|
|
|
#include "mozilla/layers/ShadowLayerUtilsGralloc.h"
|
|
|
|
#include <ui/GraphicBuffer.h>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class GrallocTextureHostOGL;
|
|
|
|
|
|
|
|
class GrallocTextureSourceOGL : public NewTextureSource
|
|
|
|
, public TextureSourceOGL
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
friend class GrallocTextureHostOGL;
|
|
|
|
|
|
|
|
GrallocTextureSourceOGL(CompositorOGL* aCompositor,
|
|
|
|
android::GraphicBuffer* aGraphicBuffer,
|
|
|
|
gfx::SurfaceFormat aFormat);
|
|
|
|
|
2013-09-12 19:39:26 -07:00
|
|
|
virtual ~GrallocTextureSourceOGL();
|
|
|
|
|
2013-08-30 07:24:05 -07:00
|
|
|
virtual bool IsValid() const MOZ_OVERRIDE;
|
2013-08-09 08:23:46 -07:00
|
|
|
|
|
|
|
virtual void BindTexture(GLenum aTextureUnit) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE;
|
|
|
|
|
2013-08-30 07:24:05 -07:00
|
|
|
virtual TextureSourceOGL* AsSourceOGL() MOZ_OVERRIDE { return this; }
|
2013-08-09 08:23:46 -07:00
|
|
|
|
|
|
|
virtual GLenum GetTextureTarget() const MOZ_OVERRIDE;
|
|
|
|
|
2013-08-30 07:24:05 -07:00
|
|
|
virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE;
|
|
|
|
|
2013-08-09 08:23:46 -07:00
|
|
|
virtual GLenum GetWrapMode() const MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return LOCAL_GL_CLAMP_TO_EDGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeallocateDeviceData();
|
|
|
|
|
|
|
|
gl::GLContext* gl() const;
|
|
|
|
|
2014-01-08 11:25:52 -08:00
|
|
|
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
2013-08-09 08:23:46 -07:00
|
|
|
|
|
|
|
void ForgetBuffer()
|
|
|
|
{
|
|
|
|
mGraphicBuffer = nullptr;
|
|
|
|
}
|
|
|
|
|
2013-11-27 01:59:01 -08:00
|
|
|
TemporaryRef<gfx::DataSourceSurface> GetAsSurface();
|
2013-08-09 08:23:46 -07:00
|
|
|
|
2013-09-17 06:29:19 -07:00
|
|
|
GLuint GetGLTexture();
|
|
|
|
|
2014-03-07 13:34:04 -08:00
|
|
|
void Lock();
|
|
|
|
|
2013-08-09 08:23:46 -07:00
|
|
|
protected:
|
|
|
|
CompositorOGL* mCompositor;
|
|
|
|
android::sp<android::GraphicBuffer> mGraphicBuffer;
|
|
|
|
EGLImage mEGLImage;
|
2014-03-07 13:34:04 -08:00
|
|
|
GLuint mTexture;
|
2013-08-09 08:23:46 -07:00
|
|
|
gfx::SurfaceFormat mFormat;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GrallocTextureHostOGL : public TextureHost
|
2014-02-27 13:26:22 -08:00
|
|
|
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 17
|
2014-02-24 20:23:41 -08:00
|
|
|
, public TextureHostOGL
|
|
|
|
#endif
|
2013-08-09 08:23:46 -07:00
|
|
|
{
|
|
|
|
friend class GrallocBufferActor;
|
|
|
|
public:
|
2013-12-11 17:44:47 -08:00
|
|
|
GrallocTextureHostOGL(TextureFlags aFlags,
|
2013-08-09 08:23:46 -07:00
|
|
|
const NewSurfaceDescriptorGralloc& aDescriptor);
|
|
|
|
|
|
|
|
virtual ~GrallocTextureHostOGL();
|
|
|
|
|
|
|
|
virtual void Updated(const nsIntRegion* aRegion) MOZ_OVERRIDE {}
|
|
|
|
|
|
|
|
virtual bool Lock() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void Unlock() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual void DeallocateSharedData() MOZ_OVERRIDE;
|
|
|
|
|
2013-12-11 17:44:45 -08:00
|
|
|
virtual void ForgetSharedData() MOZ_OVERRIDE;
|
|
|
|
|
2013-08-09 08:23:46 -07:00
|
|
|
virtual void DeallocateDeviceData() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual gfx::SurfaceFormat GetFormat() const;
|
|
|
|
|
|
|
|
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
|
|
|
|
|
|
|
|
virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return mTextureSource;
|
|
|
|
}
|
|
|
|
|
2014-02-27 13:26:22 -08:00
|
|
|
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 17
|
2014-02-24 20:23:41 -08:00
|
|
|
virtual TextureHostOGL* AsHostOGL() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-11-27 01:59:01 -08:00
|
|
|
virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
|
2013-08-09 08:23:46 -07:00
|
|
|
|
2013-09-30 05:14:38 -07:00
|
|
|
virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) MOZ_OVERRIDE;
|
2013-09-12 19:39:26 -07:00
|
|
|
|
2013-08-30 07:24:05 -07:00
|
|
|
bool IsValid() const;
|
|
|
|
|
2013-09-23 04:28:40 -07:00
|
|
|
virtual const char* Name() MOZ_OVERRIDE { return "GrallocTextureHostOGL"; }
|
2013-08-09 08:23:46 -07:00
|
|
|
|
2014-02-06 17:32:29 -08:00
|
|
|
// Forget buffer actor. Used only for hacky fix for bug 966446.
|
|
|
|
virtual void ForgetBufferActor()
|
|
|
|
{
|
|
|
|
mGrallocActor = nullptr;
|
|
|
|
}
|
|
|
|
|
2013-08-09 08:23:46 -07:00
|
|
|
private:
|
|
|
|
GrallocBufferActor* mGrallocActor;
|
|
|
|
RefPtr<GrallocTextureSourceOGL> mTextureSource;
|
|
|
|
gfx::IntSize mSize; // See comment in textureClientOGL.h
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|