Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: Source/core/paint/HTMLCanvasPainter.cpp

Issue 590393004: Move paint code from RenderHTMLCanvas to HTMLCanvasPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/HTMLCanvasPainter.h ('k') | Source/core/rendering/RenderHTMLCanvas.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/paint/HTMLCanvasPainter.h"
7
8 #include "core/html/HTMLCanvasElement.h"
9 #include "core/rendering/PaintInfo.h"
10 #include "core/rendering/RenderHTMLCanvas.h"
11 #include "platform/geometry/LayoutPoint.h"
12
13 namespace blink {
14
15 void HTMLCanvasPainter::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& p aintOffset)
16 {
17 GraphicsContext* context = paintInfo.context;
18
19 LayoutRect contentRect = m_renderHTMLCanvas.contentBoxRect();
20 contentRect.moveBy(paintOffset);
21 LayoutRect paintRect = m_renderHTMLCanvas.replacedContentRect();
22 paintRect.moveBy(paintOffset);
23
24 bool clip = !contentRect.contains(paintRect);
25 if (clip) {
26 // Not allowed to overflow the content box.
27 paintInfo.context->save();
28 paintInfo.context->clip(pixelSnappedIntRect(contentRect));
29 }
30
31 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set.
32 // See bug for more details: crbug.com/353716.
33 InterpolationQuality interpolationQuality = m_renderHTMLCanvas.style()->imag eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul tInterpolationQuality;
34
35 HTMLCanvasElement* canvas = toHTMLCanvasElement(m_renderHTMLCanvas.node());
36 LayoutSize layoutSize = contentRect.size();
37 if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated
38 && (layoutSize.width() > canvas->width() || layoutSize.height() > canvas ->height() || layoutSize == canvas->size())) {
39 interpolationQuality = InterpolationNone;
40 }
41
42 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality();
43 context->setImageInterpolationQuality(interpolationQuality);
44 canvas->paint(context, paintRect);
45 context->setImageInterpolationQuality(previousInterpolationQuality);
46
47 if (clip)
48 context->restore();
49 }
50
51 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/HTMLCanvasPainter.h ('k') | Source/core/rendering/RenderHTMLCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698