Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: third_party/WebKit/Source/core/paint/HTMLCanvasPainter.cpp

Issue 1391753005: (WIP) Invalidation during painting (for synchronized painting) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/layout/LayoutHTMLCanvas.h" 8 #include "core/layout/LayoutHTMLCanvas.h"
9 #include "core/paint/LayoutObjectDrawingRecorder.h" 9 #include "core/paint/LayoutObjectDrawingRecorder.h"
10 #include "core/paint/PaintInfo.h" 10 #include "core/paint/PaintInfo.h"
11 #include "platform/geometry/LayoutPoint.h" 11 #include "platform/geometry/LayoutPoint.h"
12 #include "platform/graphics/paint/ClipRecorder.h" 12 #include "platform/graphics/paint/ClipRecorder.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPo int& paintOffset) 16 void HTMLCanvasPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPo int& paintOffset)
17 { 17 {
18 GraphicsContext& context = paintInfo.context; 18 GraphicsContext& context = paintInfo.context;
19 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou tHTMLCanvas, paintInfo.phase, paintOffset)) 19 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, m_layou tHTMLCanvas, paintInfo.phase))
20 return; 20 return;
21 21
22 LayoutRect contentRect = m_layoutHTMLCanvas.contentBoxRect(); 22 LayoutRect contentRect = m_layoutHTMLCanvas.contentBoxRect();
23 contentRect.moveBy(paintOffset); 23 contentRect.moveBy(paintOffset);
24 LayoutRect paintRect = m_layoutHTMLCanvas.replacedContentRect(); 24 LayoutRect paintRect = m_layoutHTMLCanvas.replacedContentRect();
25 paintRect.moveBy(paintOffset); 25 paintRect.moveBy(paintOffset);
26 26
27 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutHTMLCanvas, pai ntInfo.phase, contentRect, paintOffset); 27 LayoutObjectDrawingRecorder drawingRecorder(context, m_layoutHTMLCanvas, pai ntInfo.phase, contentRect);
28 #if ENABLE(ASSERT) 28 #if ENABLE(ASSERT)
29 // The drawing may be in display list mode or image mode, producing differen t pictures for the same result. 29 // The drawing may be in display list mode or image mode, producing differen t pictures for the same result.
30 drawingRecorder.setUnderInvalidationCheckingMode(DrawingDisplayItem::CheckBi tmap); 30 drawingRecorder.setUnderInvalidationCheckingMode(DrawingDisplayItem::CheckBi tmap);
31 #endif 31 #endif
32 32
33 bool clip = !contentRect.contains(paintRect); 33 bool clip = !contentRect.contains(paintRect);
34 if (clip) { 34 if (clip) {
35 context.save(); 35 context.save();
36 // TODO(chrishtr): this should be pixel-snapped. 36 // TODO(chrishtr): this should be pixel-snapped.
37 context.clip(FloatRect(contentRect)); 37 context.clip(FloatRect(contentRect));
38 } 38 }
39 39
40 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set. 40 // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set.
41 // See bug for more details: crbug.com/353716. 41 // See bug for more details: crbug.com/353716.
42 InterpolationQuality interpolationQuality = m_layoutHTMLCanvas.style()->imag eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul tInterpolationQuality; 42 InterpolationQuality interpolationQuality = m_layoutHTMLCanvas.style()->imag eRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaul tInterpolationQuality;
43 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated) 43 if (m_layoutHTMLCanvas.style()->imageRendering() == ImageRenderingPixelated)
44 interpolationQuality = InterpolationNone; 44 interpolationQuality = InterpolationNone;
45 45
46 InterpolationQuality previousInterpolationQuality = context.imageInterpolati onQuality(); 46 InterpolationQuality previousInterpolationQuality = context.imageInterpolati onQuality();
47 context.setImageInterpolationQuality(interpolationQuality); 47 context.setImageInterpolationQuality(interpolationQuality);
48 toHTMLCanvasElement(m_layoutHTMLCanvas.node())->paint(context, paintRect); 48 toHTMLCanvasElement(m_layoutHTMLCanvas.node())->paint(context, paintRect);
49 context.setImageInterpolationQuality(previousInterpolationQuality); 49 context.setImageInterpolationQuality(previousInterpolationQuality);
50 50
51 if (clip) 51 if (clip)
52 context.restore(); 52 context.restore();
53 } 53 }
54 54
55 } // namespace blink 55 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/FrameSetPainter.cpp ('k') | third_party/WebKit/Source/core/paint/ImagePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698