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 "core/paint/HTMLCanvasPainter.h" | 5 #include "core/paint/HTMLCanvasPainter.h" |
6 | 6 |
7 #include "core/html/HTMLCanvasElement.h" | 7 #include "core/html/HTMLCanvasElement.h" |
8 #include "core/html/canvas/CanvasRenderingContext.h" | 8 #include "core/html/canvas/CanvasRenderingContext.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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutHTMLCanvas, | 45 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutHTMLCanvas, |
46 paintInfo.phase, contentRect); | 46 paintInfo.phase, contentRect); |
47 | 47 |
48 bool clip = !contentRect.contains(paintRect); | 48 bool clip = !contentRect.contains(paintRect); |
49 if (clip) { | 49 if (clip) { |
50 context.save(); | 50 context.save(); |
51 // TODO(chrishtr): this should be pixel-snapped. | 51 // TODO(chrishtr): this should be pixel-snapped. |
52 context.clip(FloatRect(contentRect)); | 52 context.clip(FloatRect(contentRect)); |
53 } | 53 } |
54 | 54 |
55 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast i
s set. | 55 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast |
56 // See bug for more details: crbug.com/353716. | 56 // is set. See bug for more details: crbug.com/353716. |
57 InterpolationQuality interpolationQuality = | 57 InterpolationQuality interpolationQuality = |
58 m_layoutHTMLCanvas.style()->imageRendering() == | 58 m_layoutHTMLCanvas.style()->imageRendering() == |
59 ImageRenderingOptimizeContrast | 59 ImageRenderingOptimizeContrast |
60 ? InterpolationLow | 60 ? InterpolationLow |
61 : CanvasDefaultInterpolationQuality; | 61 : CanvasDefaultInterpolationQuality; |
62 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) | 62 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) |
63 interpolationQuality = InterpolationNone; | 63 interpolationQuality = InterpolationNone; |
64 | 64 |
65 InterpolationQuality previousInterpolationQuality = | 65 InterpolationQuality previousInterpolationQuality = |
66 context.imageInterpolationQuality(); | 66 context.imageInterpolationQuality(); |
67 context.setImageInterpolationQuality(interpolationQuality); | 67 context.setImageInterpolationQuality(interpolationQuality); |
68 canvas->paint(context, paintRect); | 68 canvas->paint(context, paintRect); |
69 context.setImageInterpolationQuality(previousInterpolationQuality); | 69 context.setImageInterpolationQuality(previousInterpolationQuality); |
70 | 70 |
71 if (clip) | 71 if (clip) |
72 context.restore(); | 72 context.restore(); |
73 } | 73 } |
74 | 74 |
75 } // namespace blink | 75 } // namespace blink |
OLD | NEW |