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/LayoutHTMLCanvas.h" |
10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutHTMLCanvas, pa
intInfo.phase, contentRect); | 28 LayoutObjectDrawingRecorder drawingRecorder(*context, m_layoutHTMLCanvas, pa
intInfo.phase, contentRect); |
29 #if ENABLE(ASSERT) | 29 #if ENABLE(ASSERT) |
30 // The drawing may be in display list mode or image mode, producing differen
t pictures for the same result. | 30 // The drawing may be in display list mode or image mode, producing differen
t pictures for the same result. |
31 drawingRecorder.setUnderInvalidationCheckingMode(DrawingDisplayItem::CheckBi
tmap); | 31 drawingRecorder.setUnderInvalidationCheckingMode(DrawingDisplayItem::CheckBi
tmap); |
32 #endif | 32 #endif |
33 | 33 |
34 bool clip = !contentRect.contains(paintRect); | 34 bool clip = !contentRect.contains(paintRect); |
35 if (clip) { | 35 if (clip) { |
36 context->save(); | 36 context->save(); |
37 context->clip(contentRect); | 37 // TODO(chrishtr): this should be pixel-snapped. |
| 38 context->clip(FloatRect(contentRect)); |
38 } | 39 } |
39 | 40 |
40 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. | 41 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. |
41 // See bug for more details: crbug.com/353716. | 42 // See bug for more details: crbug.com/353716. |
42 InterpolationQuality interpolationQuality = m_layoutHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; | 43 InterpolationQuality interpolationQuality = m_layoutHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; |
43 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) | 44 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) |
44 interpolationQuality = InterpolationNone; | 45 interpolationQuality = InterpolationNone; |
45 | 46 |
46 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); | 47 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); |
47 context->setImageInterpolationQuality(interpolationQuality); | 48 context->setImageInterpolationQuality(interpolationQuality); |
48 toHTMLCanvasElement(m_layoutHTMLCanvas.node())->paint(context, paintRect); | 49 toHTMLCanvasElement(m_layoutHTMLCanvas.node())->paint(context, paintRect); |
49 context->setImageInterpolationQuality(previousInterpolationQuality); | 50 context->setImageInterpolationQuality(previousInterpolationQuality); |
50 | 51 |
51 if (clip) | 52 if (clip) |
52 context->restore(); | 53 context->restore(); |
53 } | 54 } |
54 | 55 |
55 } // namespace blink | 56 } // namespace blink |
OLD | NEW |