| 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 23 matching lines...) Expand all Loading... |
| 34 context, m_layoutHTMLCanvas, DisplayItem::ForeignLayerCanvas, | 34 context, m_layoutHTMLCanvas, DisplayItem::ForeignLayerCanvas, |
| 35 layer, pixelSnappedRect.location(), pixelSnappedRect.size()); | 35 layer, pixelSnappedRect.location(), pixelSnappedRect.size()); |
| 36 return; | 36 return; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou
tHTMLCanvas, paintInfo.phase)) | 40 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou
tHTMLCanvas, paintInfo.phase)) |
| 41 return; | 41 return; |
| 42 | 42 |
| 43 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutHTMLCanvas, pai
ntInfo.phase, contentRect); | 43 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutHTMLCanvas, pai
ntInfo.phase, contentRect); |
| 44 #if ENABLE(ASSERT) | |
| 45 // The drawing may be in display list mode or image mode, producing differen
t pictures for the same result. | |
| 46 drawingRecorder.setUnderInvalidationCheckingMode(DrawingDisplayItem::CheckBi
tmap); | |
| 47 #endif | |
| 48 | 44 |
| 49 bool clip = !contentRect.contains(paintRect); | 45 bool clip = !contentRect.contains(paintRect); |
| 50 if (clip) { | 46 if (clip) { |
| 51 context.save(); | 47 context.save(); |
| 52 // TODO(chrishtr): this should be pixel-snapped. | 48 // TODO(chrishtr): this should be pixel-snapped. |
| 53 context.clip(FloatRect(contentRect)); | 49 context.clip(FloatRect(contentRect)); |
| 54 } | 50 } |
| 55 | 51 |
| 56 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. | 52 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast
is set. |
| 57 // See bug for more details: crbug.com/353716. | 53 // See bug for more details: crbug.com/353716. |
| 58 InterpolationQuality interpolationQuality = m_layoutHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; | 54 InterpolationQuality interpolationQuality = m_layoutHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; |
| 59 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) | 55 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) |
| 60 interpolationQuality = InterpolationNone; | 56 interpolationQuality = InterpolationNone; |
| 61 | 57 |
| 62 InterpolationQuality previousInterpolationQuality = context.imageInterpolati
onQuality(); | 58 InterpolationQuality previousInterpolationQuality = context.imageInterpolati
onQuality(); |
| 63 context.setImageInterpolationQuality(interpolationQuality); | 59 context.setImageInterpolationQuality(interpolationQuality); |
| 64 canvas->paint(context, paintRect); | 60 canvas->paint(context, paintRect); |
| 65 context.setImageInterpolationQuality(previousInterpolationQuality); | 61 context.setImageInterpolationQuality(previousInterpolationQuality); |
| 66 | 62 |
| 67 if (clip) | 63 if (clip) |
| 68 context.restore(); | 64 context.restore(); |
| 69 } | 65 } |
| 70 | 66 |
| 71 } // namespace blink | 67 } // namespace blink |
| OLD | NEW |