2013-10-11 06:16:44 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* 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 TEXTUREIMAGEEGL_H_
|
|
|
|
#define TEXTUREIMAGEEGL_H_
|
|
|
|
|
|
|
|
#include "GLTextureImage.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2014-08-05 10:33:55 -07:00
|
|
|
class TextureImageEGL MOZ_FINAL
|
2013-10-11 06:16:44 -07:00
|
|
|
: public TextureImage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TextureImageEGL(GLuint aTexture,
|
|
|
|
const nsIntSize& aSize,
|
|
|
|
GLenum aWrapMode,
|
|
|
|
ContentType aContentType,
|
|
|
|
GLContext* aContext,
|
|
|
|
Flags aFlags = TextureImage::NoFlags,
|
|
|
|
TextureState aTextureState = Created,
|
2014-01-23 10:26:40 -08:00
|
|
|
TextureImage::ImageFormat aImageFormat = gfxImageFormat::Unknown);
|
2013-10-11 06:16:44 -07:00
|
|
|
|
|
|
|
virtual ~TextureImageEGL();
|
|
|
|
|
|
|
|
virtual void GetUpdateRegion(nsIntRegion& aForRegion);
|
|
|
|
|
2014-02-13 10:00:01 -08:00
|
|
|
virtual gfx::DrawTarget* BeginUpdate(nsIntRegion& aRegion);
|
2013-10-11 06:16:44 -07:00
|
|
|
|
|
|
|
virtual void EndUpdate();
|
|
|
|
|
2014-02-13 08:25:55 -08:00
|
|
|
virtual bool DirectUpdate(gfx::DataSourceSurface* aSurf, const nsIntRegion& aRegion, const gfx::IntPoint& aFrom = gfx::IntPoint(0,0));
|
|
|
|
|
2013-10-11 06:16:44 -07:00
|
|
|
virtual void BindTexture(GLenum aTextureUnit);
|
|
|
|
|
|
|
|
virtual GLuint GetTextureID()
|
|
|
|
{
|
|
|
|
// Ensure the texture is allocated before it is used.
|
|
|
|
if (mTextureState == Created) {
|
|
|
|
Resize(mSize);
|
|
|
|
}
|
|
|
|
return mTexture;
|
|
|
|
};
|
|
|
|
|
2014-02-13 10:00:01 -08:00
|
|
|
virtual bool InUpdate() const { return !!mUpdateDrawTarget; }
|
2013-10-11 06:16:44 -07:00
|
|
|
|
2013-12-13 09:32:06 -08:00
|
|
|
virtual void Resize(const gfx::IntSize& aSize);
|
2013-10-11 06:16:44 -07:00
|
|
|
|
|
|
|
bool BindTexImage();
|
|
|
|
|
|
|
|
bool ReleaseTexImage();
|
|
|
|
|
|
|
|
virtual bool CreateEGLSurface(gfxASurface* aSurface)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void DestroyEGLSurface(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
typedef gfxImageFormat ImageFormat;
|
|
|
|
|
|
|
|
GLContext* mGLContext;
|
|
|
|
|
|
|
|
nsIntRect mUpdateRect;
|
2014-02-13 10:00:01 -08:00
|
|
|
gfx::SurfaceFormat mUpdateFormat;
|
|
|
|
RefPtr<gfx::DrawTarget> mUpdateDrawTarget;
|
2013-10-11 06:16:44 -07:00
|
|
|
EGLImage mEGLImage;
|
|
|
|
GLuint mTexture;
|
|
|
|
EGLSurface mSurface;
|
|
|
|
EGLConfig mConfig;
|
|
|
|
TextureState mTextureState;
|
|
|
|
|
|
|
|
bool mBound;
|
|
|
|
};
|
|
|
|
|
2013-12-03 10:44:38 -08:00
|
|
|
already_AddRefed<TextureImage>
|
|
|
|
CreateTextureImageEGL(GLContext *gl,
|
2013-12-13 09:32:06 -08:00
|
|
|
const gfx::IntSize& aSize,
|
2013-12-03 10:44:38 -08:00
|
|
|
TextureImage::ContentType aContentType,
|
|
|
|
GLenum aWrapMode,
|
|
|
|
TextureImage::Flags aFlags,
|
|
|
|
TextureImage::ImageFormat aImageFormat);
|
|
|
|
|
|
|
|
already_AddRefed<TextureImage>
|
|
|
|
TileGenFuncEGL(GLContext *gl,
|
|
|
|
const nsIntSize& aSize,
|
|
|
|
TextureImage::ContentType aContentType,
|
|
|
|
TextureImage::Flags aFlags,
|
|
|
|
TextureImage::ImageFormat aImageFormat);
|
2013-10-11 06:16:44 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-08 20:07:18 -08:00
|
|
|
#endif // TEXTUREIMAGEEGL_H_
|