| 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 14 matching lines...) Expand all Loading... |
| 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 // 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_renderHTMLCanvas.style()->imag
eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul
tInterpolationQuality; |
| 35 | 35 if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) |
| 36 HTMLCanvasElement* canvas = toHTMLCanvasElement(m_renderHTMLCanvas.node()); | |
| 37 LayoutSize layoutSize = contentRect.size(); | |
| 38 if (m_renderHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated | |
| 39 && (layoutSize.width() > canvas->width() || layoutSize.height() > canvas
->height() || layoutSize == canvas->size())) { | |
| 40 interpolationQuality = InterpolationNone; | 36 interpolationQuality = InterpolationNone; |
| 41 } | |
| 42 | 37 |
| 43 RenderDrawingRecorder recorder(context, &m_renderHTMLCanvas, localPaintInfo.
phase, pixelSnappedIntRect(paintRect)); | 38 RenderDrawingRecorder recorder(context, &m_renderHTMLCanvas, localPaintInfo.
phase, pixelSnappedIntRect(paintRect)); |
| 44 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); | 39 InterpolationQuality previousInterpolationQuality = context->imageInterpolat
ionQuality(); |
| 45 context->setImageInterpolationQuality(interpolationQuality); | 40 context->setImageInterpolationQuality(interpolationQuality); |
| 46 canvas->paint(context, paintRect); | 41 toHTMLCanvasElement(m_renderHTMLCanvas.node())->paint(context, paintRect); |
| 47 context->setImageInterpolationQuality(previousInterpolationQuality); | 42 context->setImageInterpolationQuality(previousInterpolationQuality); |
| 48 } | 43 } |
| 49 | 44 |
| 50 } // namespace blink | 45 } // namespace blink |
| OLD | NEW |