#ifndef WebGLTexture_h
#define WebGLTexture_h
#include "bindings/v8/ScriptWrappable.h"
#include "core/html/canvas/WebGLSharedObject.h"
#include "wtf/PassRefPtr.h"
#include "wtf/Vector.h"
namespace WebCore {
class WebGLTexture FINAL : public WebGLSharedObject, public ScriptWrappable {
public:
enum TextureExtensionFlag {
NoTextureExtensionEnabled = 0,
TextureFloatLinearExtensionEnabled = 1 << 0,
TextureHalfFloatLinearExtensionEnabled = 1 << 1
};
virtual ~WebGLTexture();
static PassRefPtr<WebGLTexture> create(WebGLRenderingContextBase*);
void setTarget(GLenum target, GLint maxLevel);
void setParameteri(GLenum pname, GLint param);
void setParameterf(GLenum pname, GLfloat param);
GLenum getTarget() const { return m_target; }
int getMinFilter() const { return m_minFilter; }
void setLevelInfo(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum type);
bool canGenerateMipmaps();
void generateMipmapLevelInfo();
GLenum getInternalFormat(GLenum target, GLint level) const;
GLenum getType(GLenum target, GLint level) const;
GLsizei getWidth(GLenum target, GLint level) const;
GLsizei getHeight(GLenum target, GLint level) const;
bool isValid(GLenum target, GLint level) const;
static bool isNPOT(GLsizei, GLsizei);
bool isNPOT() const;
bool needToUseBlackTexture(TextureExtensionFlag) const;
bool hasEverBeenBound() const { return object() && m_target; }
static GLint computeLevelCount(GLsizei width, GLsizei height);
protected:
WebGLTexture(WebGLRenderingContextBase*);
virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, Platform3DObject) OVERRIDE;
private:
class LevelInfo {
public:
LevelInfo()
: valid(false)
, internalFormat(0)
, width(0)
, height(0)
, type(0)
{
}
void setInfo(GLenum internalFmt, GLsizei w, GLsizei h, GLenum tp)
{
valid = true;
internalFormat = internalFmt;
width = w;
height = h;
type = tp;
}
bool valid;
GLenum internalFormat;
GLsizei width;
GLsizei height;
GLenum type;
};
virtual bool isTexture() const OVERRIDE { return true; }
void update();
int mapTargetToIndex(GLenum) const;
const LevelInfo* getLevelInfo(GLenum target, GLint level) const;
GLenum m_target;
GLenum m_minFilter;
GLenum m_magFilter;
GLenum m_wrapS;
GLenum m_wrapT;
Vector<Vector<LevelInfo> > m_info;
bool m_isNPOT;
bool m_isCubeComplete;
bool m_isComplete;
bool m_needToUseBlackTexture;
bool m_isFloatType;
bool m_isHalfFloatType;
};
}
#endif