TextureMapperPlatformLayerBuffer.cpp [plain text]
#include "config.h"
#include "TextureMapperPlatformLayerBuffer.h"
namespace WebCore {
TextureMapperPlatformLayerBuffer::TextureMapperPlatformLayerBuffer(RefPtr<BitmapTexture>&& texture)
: m_texture(WTFMove(texture))
, m_textureID(0)
, m_extraFlags(0)
, m_hasManagedTexture(true)
{
}
TextureMapperPlatformLayerBuffer::TextureMapperPlatformLayerBuffer(GLuint textureID, const IntSize& size, TextureMapperGL::Flags flags)
: m_textureID(textureID)
, m_size(size)
, m_extraFlags(flags)
, m_hasManagedTexture(false)
{
}
bool TextureMapperPlatformLayerBuffer::canReuseWithoutReset(const IntSize& size, GC3Dint internalFormat)
{
return m_texture && (m_texture->size() == size) && (static_cast<BitmapTextureGL*>(m_texture.get())->internalFormat() == internalFormat || internalFormat == GraphicsContext3D::DONT_CARE);
}
void TextureMapperPlatformLayerBuffer::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& modelViewMatrix, float opacity)
{
TextureMapperGL& texmapGL = static_cast<TextureMapperGL&>(textureMapper);
if (m_hasManagedTexture) {
ASSERT(m_texture);
BitmapTextureGL* textureGL = static_cast<BitmapTextureGL*>(m_texture.get());
texmapGL.drawTexture(textureGL->id(), m_extraFlags, textureGL->size(), targetRect, modelViewMatrix, opacity);
return;
}
ASSERT(m_textureID);
texmapGL.drawTexture(m_textureID, m_extraFlags, m_size, targetRect, modelViewMatrix, opacity);
}
}