#ifndef BitmapTextureGL_h
#define BitmapTextureGL_h
#if USE(TEXTURE_MAPPER_GL)
#include "BitmapTexture.h"
#include "ClipStack.h"
#include "FilterOperation.h"
#include "GraphicsContext3D.h"
#include "IntSize.h"
#include "TextureMapperGL.h"
namespace WebCore {
class TextureMapper;
class TextureMapperGL;
class FilterOperation;
class BitmapTextureGL : public BitmapTexture {
public:
static Ref<BitmapTexture> create(Ref<GraphicsContext3D>&& context3D, const Flags flags = NoFlag, GC3Dint internalFormat = GraphicsContext3D::DONT_CARE)
{
return adoptRef(*new BitmapTextureGL(WTFMove(context3D), flags, internalFormat));
}
virtual ~BitmapTextureGL();
IntSize size() const override;
bool isValid() const override;
void didReset() override;
void bindAsSurface(GraphicsContext3D*);
void initializeStencil();
void initializeDepthBuffer();
virtual uint32_t id() const { return m_id; }
uint32_t textureTarget() const { return GraphicsContext3D::TEXTURE_2D; }
IntSize textureSize() const { return m_textureSize; }
void updateContents(Image*, const IntRect&, const IntPoint&, UpdateContentsFlag) override;
void updateContents(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, UpdateContentsFlag) override;
void updateContentsNoSwizzle(const void*, const IntRect& target, const IntPoint& sourceOffset, int bytesPerLine, unsigned bytesPerPixel = 4, Platform3DObject glFormat = GraphicsContext3D::RGBA);
bool isBackedByOpenGL() const override { return true; }
RefPtr<BitmapTexture> applyFilters(TextureMapper&, const FilterOperations&) override;
struct FilterInfo {
RefPtr<FilterOperation> filter;
unsigned pass;
RefPtr<BitmapTexture> contentTexture;
FilterInfo(RefPtr<FilterOperation>&& f = nullptr, unsigned p = 0, RefPtr<BitmapTexture>&& t = nullptr)
: filter(WTFMove(f))
, pass(p)
, contentTexture(WTFMove(t))
{ }
};
const FilterInfo* filterInfo() const { return &m_filterInfo; }
ClipStack& clipStack() { return m_clipStack; }
GC3Dint internalFormat() const { return m_internalFormat; }
void copyFromExternalTexture(Platform3DObject textureID);
private:
BitmapTextureGL(RefPtr<GraphicsContext3D>&&, const Flags, GC3Dint internalFormat);
Platform3DObject m_id { 0 };
IntSize m_textureSize;
IntRect m_dirtyRect;
Platform3DObject m_fbo { 0 };
Platform3DObject m_rbo { 0 };
Platform3DObject m_depthBufferObject { 0 };
bool m_shouldClear { true };
ClipStack m_clipStack;
RefPtr<GraphicsContext3D> m_context3D;
void clearIfNeeded();
void createFboIfNeeded();
FilterInfo m_filterInfo;
GC3Dint m_internalFormat;
GC3Denum m_format;
GC3Denum m_type {
#if OS(DARWIN)
GL_UNSIGNED_INT_8_8_8_8_REV
#else
GraphicsContext3D::UNSIGNED_BYTE
#endif
};
};
BitmapTextureGL* toBitmapTextureGL(BitmapTexture*);
}
#endif // USE(TEXTURE_MAPPER_GL)
#endif // BitmapTextureGL_h