TextureMapperPlatformLayerBuffer.h [plain text]
#ifndef TextureMapperPlatformLayerBuffer_h
#define TextureMapperPlatformLayerBuffer_h
#include "BitmapTextureGL.h"
#include "GraphicsTypes3D.h"
#include "TextureMapperPlatformLayer.h"
#include <wtf/CurrentTime.h>
namespace WebCore {
class TextureMapperPlatformLayerBuffer : public TextureMapperPlatformLayer {
WTF_MAKE_NONCOPYABLE(TextureMapperPlatformLayerBuffer);
WTF_MAKE_FAST_ALLOCATED();
public:
TextureMapperPlatformLayerBuffer(RefPtr<BitmapTexture>&&);
TextureMapperPlatformLayerBuffer(GLuint textureID, const IntSize&, TextureMapperGL::Flags);
virtual ~TextureMapperPlatformLayerBuffer() = default;
void paintToTextureMapper(TextureMapper&, const FloatRect&, const TransformationMatrix& modelViewMatrix = TransformationMatrix(), float opacity = 1.0) final;
bool canReuseWithoutReset(const IntSize&, GC3Dint internalFormat);
BitmapTextureGL& textureGL() { return static_cast<BitmapTextureGL&>(*m_texture); }
inline void markUsed() { m_timeLastUsed = monotonicallyIncreasingTime(); }
double lastUsedTime() const { return m_timeLastUsed; }
class UnmanagedBufferDataHolder {
WTF_MAKE_NONCOPYABLE(UnmanagedBufferDataHolder);
WTF_MAKE_FAST_ALLOCATED();
public:
UnmanagedBufferDataHolder() = default;
virtual ~UnmanagedBufferDataHolder() = default;
};
bool hasManagedTexture() const { return m_hasManagedTexture; }
void setUnmanagedBufferDataHolder(std::unique_ptr<UnmanagedBufferDataHolder> holder) { m_unmanagedBufferDataHolder = WTFMove(holder); }
void setExtraFlags(TextureMapperGL::Flags flags) { m_extraFlags = flags; }
private:
RefPtr<BitmapTexture> m_texture;
double m_timeLastUsed { 0 };
GLuint m_textureID;
IntSize m_size;
TextureMapperGL::Flags m_extraFlags;
bool m_hasManagedTexture;
std::unique_ptr<UnmanagedBufferDataHolder> m_unmanagedBufferDataHolder;
};
}
#endif // TextureMapperPlatformLayerBuffer_h