CCCanvasLayerImpl.cpp [plain text]
#include "config.h"
#if USE(ACCELERATED_COMPOSITING)
#include "cc/CCCanvasLayerImpl.h"
#include "CanvasLayerChromium.h"
#include "GraphicsContext3D.h"
#include "LayerRendererChromium.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
CCCanvasLayerImpl::CCCanvasLayerImpl(LayerChromium* owner, int id)
: CCLayerImpl(owner, id)
, m_textureId(0)
, m_premultipliedAlpha(true)
{
}
CCCanvasLayerImpl::~CCCanvasLayerImpl()
{
}
void CCCanvasLayerImpl::draw(const IntRect&)
{
ASSERT(layerRenderer());
const CCCanvasLayerImpl::Program* program = layerRenderer()->canvasLayerProgram();
ASSERT(program && program->initialized());
GraphicsContext3D* context = layerRenderer()->context();
GLC(context, context->activeTexture(GraphicsContext3D::TEXTURE0));
GLC(context, context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId));
GC3Denum sfactor = m_premultipliedAlpha ? GraphicsContext3D::ONE : GraphicsContext3D::SRC_ALPHA;
GLC(context, context->blendFunc(sfactor, GraphicsContext3D::ONE_MINUS_SRC_ALPHA));
layerRenderer()->useShader(program->program());
GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
LayerChromium::drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
bounds().width(), bounds().height(), drawOpacity(),
program->vertexShader().matrixLocation(),
program->fragmentShader().alphaLocation());
}
void CCCanvasLayerImpl::dumpLayerProperties(TextStream& ts, int indent) const
{
writeIndent(ts, indent);
ts << "canvas layer texture id: " << m_textureId << " premultiplied: " << m_premultipliedAlpha << "\n";
CCLayerImpl::dumpLayerProperties(ts, indent);
}
}
#endif // USE(ACCELERATED_COMPOSITING)