#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/page/Page.h"
+#include "core/paint/HTMLCanvasPainter.h"
#include "core/rendering/PaintInfo.h"
#include "core/rendering/RenderView.h"
void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- GraphicsContext* context = paintInfo.context;
-
- LayoutRect contentRect = contentBoxRect();
- contentRect.moveBy(paintOffset);
- LayoutRect paintRect = replacedContentRect();
- paintRect.moveBy(paintOffset);
-
- bool clip = !contentRect.contains(paintRect);
- if (clip) {
- // Not allowed to overflow the content box.
- paintInfo.context->save();
- paintInfo.context->clip(pixelSnappedIntRect(contentRect));
- }
-
- // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set.
- // See bug for more details: crbug.com/353716.
- InterpolationQuality interpolationQuality = style()->imageRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaultInterpolationQuality;
-
- HTMLCanvasElement* canvas = toHTMLCanvasElement(node());
- LayoutSize layoutSize = contentRect.size();
- if (style()->imageRendering() == ImageRenderingPixelated
- && (layoutSize.width() > canvas->width() || layoutSize.height() > canvas->height() || layoutSize == canvas->size())) {
- interpolationQuality = InterpolationNone;
- }
-
- InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality();
- context->setImageInterpolationQuality(interpolationQuality);
- canvas->paint(context, paintRect);
- context->setImageInterpolationQuality(previousInterpolationQuality);
-
- if (clip)
- context->restore();
+ HTMLCanvasPainter(*this).paintReplaced(paintInfo, paintOffset);
}
void RenderHTMLCanvas::canvasSizeChanged()