CanvasLayerTextureUpdater.cpp [plain text]
#include "config.h"
#if USE(ACCELERATED_COMPOSITING)
#include "CanvasLayerTextureUpdater.h"
#include "GraphicsContext.h"
#include "LayerPainterChromium.h"
#include "PlatformContextSkia.h"
#include "TraceEvent.h"
namespace WebCore {
CanvasLayerTextureUpdater::CanvasLayerTextureUpdater(PassOwnPtr<LayerPainterChromium> painter)
: m_painter(painter)
{
}
CanvasLayerTextureUpdater::~CanvasLayerTextureUpdater()
{
}
void CanvasLayerTextureUpdater::paintContents(GraphicsContext& context, PlatformContextSkia& platformContext, const IntRect& contentRect, float contentsScale, IntRect& resultingOpaqueRect)
{
context.translate(-contentRect.x(), -contentRect.y());
{
TRACE_EVENT("LayerTextureUpdaterCanvas::paint", this, 0);
IntRect scaledContentRect = contentRect;
if (contentsScale != 1.0) {
context.save();
context.scale(FloatSize(contentsScale, contentsScale));
FloatRect rect = contentRect;
rect.scale(1 / contentsScale);
scaledContentRect = enclosingIntRect(rect);
}
AffineTransform canvasToContentTransform = context.getCTM().inverse();
m_painter->paint(context, scaledContentRect);
ASSERT(canvasToContentTransform.isInvertible());
ASSERT(canvasToContentTransform.preservesAxisAlignment());
FloatRect opaqueCanvasRect = platformContext.opaqueRegion().asRect();
resultingOpaqueRect = enclosedIntRect(canvasToContentTransform.mapRect(opaqueCanvasRect));
if (contentsScale != 1.0)
context.restore();
}
m_contentRect = contentRect;
}
} #endif // USE(ACCELERATED_COMPOSITING)