OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/paint/HTMLCanvasPainter.h" | 6 #include "core/paint/HTMLCanvasPainter.h" |
7 | 7 |
8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
| 9 #include "core/layout/LayoutHTMLCanvas.h" |
9 #include "core/layout/PaintInfo.h" | 10 #include "core/layout/PaintInfo.h" |
10 #include "core/paint/RenderDrawingRecorder.h" | 11 #include "core/paint/RenderDrawingRecorder.h" |
11 #include "core/rendering/RenderHTMLCanvas.h" | |
12 #include "platform/geometry/LayoutPoint.h" | 12 #include "platform/geometry/LayoutPoint.h" |
13 #include "platform/graphics/paint/ClipRecorder.h" | 13 #include "platform/graphics/paint/ClipRecorder.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPo
int& paintOffset) | 17 void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPo
int& paintOffset) |
18 { | 18 { |
19 GraphicsContext* context = paintInfo.context; | 19 GraphicsContext* context = paintInfo.context; |
20 | 20 |
21 LayoutRect contentRect = m_renderHTMLCanvas.contentBoxRect(); | 21 LayoutRect contentRect = m_layoutHTMLCanvas.contentBoxRect(); |
22 contentRect.moveBy(paintOffset); | 22 contentRect.moveBy(paintOffset); |
23 LayoutRect paintRect = m_renderHTMLCanvas.replacedContentRect(); | 23 LayoutRect paintRect = m_layoutHTMLCanvas.replacedContentRect(); |
24 paintRect.moveBy(paintOffset); | 24 paintRect.moveBy(paintOffset); |
25 | 25 |
26 bool clip = !contentRect.contains(paintRect); | 26 bool clip = !contentRect.contains(paintRect); |
27 if (clip) { | 27 if (clip) { |
28 context->save(); | 28 context->save(); |
29 context->clip(contentRect); | 29 context->clip(contentRect); |
30 } | 30 } |
31 | 31 |
32 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. | 32 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. |
33 // See bug for more details: crbug.com/353716. | 33 // See bug for more details: crbug.com/353716. |
34 InterpolationQuality interpolationQuality = m_renderHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; | 34 InterpolationQuality interpolationQuality = m_layoutHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; |
35 if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) | 35 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) |
36 interpolationQuality = InterpolationNone; | 36 interpolationQuality = InterpolationNone; |
37 | 37 |
38 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); | 38 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); |
39 context->setImageInterpolationQuality(interpolationQuality); | 39 context->setImageInterpolationQuality(interpolationQuality); |
40 toHTMLCanvasElement(m_renderHTMLCanvas.node())->paint(context, paintRect); | 40 toHTMLCanvasElement(m_layoutHTMLCanvas.node())->paint(context, paintRect); |
41 context->setImageInterpolationQuality(previousInterpolationQuality); | 41 context->setImageInterpolationQuality(previousInterpolationQuality); |
42 | 42 |
43 if (clip) | 43 if (clip) |
44 context->restore(); | 44 context->restore(); |
45 } | 45 } |
46 | 46 |
47 } // namespace blink | 47 } // namespace blink |
OLD | NEW |