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/paint/ClipRecorder.h" | 9 #include "core/paint/ClipRecorder.h" |
10 #include "core/paint/RenderDrawingRecorder.h" | 10 #include "core/paint/RenderDrawingRecorder.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 contentRect.moveBy(paintOffset); | 22 contentRect.moveBy(paintOffset); |
23 LayoutRect paintRect = m_renderHTMLCanvas.replacedContentRect(); | 23 LayoutRect paintRect = m_renderHTMLCanvas.replacedContentRect(); |
24 paintRect.moveBy(paintOffset); | 24 paintRect.moveBy(paintOffset); |
25 | 25 |
26 PaintInfo localPaintInfo(paintInfo); | 26 PaintInfo localPaintInfo(paintInfo); |
27 OwnPtr<ClipRecorder> clipRecorder; | 27 OwnPtr<ClipRecorder> clipRecorder; |
28 bool clip = !contentRect.contains(paintRect); | 28 bool clip = !contentRect.contains(paintRect); |
29 if (clip) | 29 if (clip) |
30 clipRecorder = adoptPtr(new ClipRecorder(m_renderHTMLCanvas, paintInfo,
contentRect)); | 30 clipRecorder = adoptPtr(new ClipRecorder(m_renderHTMLCanvas, paintInfo,
contentRect)); |
31 | 31 |
| 32 RenderDrawingRecorder recorder(context, m_renderHTMLCanvas, localPaintInfo.p
hase, pixelSnappedIntRect(paintRect)); |
| 33 if (recorder.canUseCachedDrawing()) |
| 34 return; |
| 35 |
32 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. | 36 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. |
33 // See bug for more details: crbug.com/353716. | 37 // See bug for more details: crbug.com/353716. |
34 InterpolationQuality interpolationQuality = m_renderHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; | 38 InterpolationQuality interpolationQuality = m_renderHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; |
35 if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) | 39 if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) |
36 interpolationQuality = InterpolationNone; | 40 interpolationQuality = InterpolationNone; |
37 | 41 |
38 RenderDrawingRecorder recorder(context, &m_renderHTMLCanvas, localPaintInfo.
phase, pixelSnappedIntRect(paintRect)); | |
39 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); | 42 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); |
40 context->setImageInterpolationQuality(interpolationQuality); | 43 context->setImageInterpolationQuality(interpolationQuality); |
41 toHTMLCanvasElement(m_renderHTMLCanvas.node())->paint(context, paintRect); | 44 toHTMLCanvasElement(m_renderHTMLCanvas.node())->paint(context, paintRect); |
42 context->setImageInterpolationQuality(previousInterpolationQuality); | 45 context->setImageInterpolationQuality(previousInterpolationQuality); |
43 } | 46 } |
44 | 47 |
45 } // namespace blink | 48 } // namespace blink |
OLD | NEW |