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

Side by Side Diff: Source/core/paint/ImagePainter.cpp

Issue 799563002: Use DrawingRecorder::canUseCachedDrawing (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "core/paint/ImagePainter.h" 6 #include "core/paint/ImagePainter.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/editing/FrameSelection.h" 10 #include "core/editing/FrameSelection.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 RenderStyle* areaElementStyle = areaElement.computedStyle(); 58 RenderStyle* areaElementStyle = areaElement.computedStyle();
59 unsigned short outlineWidth = areaElementStyle->outlineWidth(); 59 unsigned short outlineWidth = areaElementStyle->outlineWidth();
60 if (!outlineWidth) 60 if (!outlineWidth)
61 return; 61 return;
62 62
63 // FIXME: Clip path instead of context when Skia pathops is ready. 63 // FIXME: Clip path instead of context when Skia pathops is ready.
64 // https://crbug.com/251206 64 // https://crbug.com/251206
65 GraphicsContextStateSaver savedContext(*paintInfo.context); 65 GraphicsContextStateSaver savedContext(*paintInfo.context);
66 IntRect focusRect = m_renderImage.absoluteContentBox(); 66 IntRect focusRect = m_renderImage.absoluteContentBox();
67 RenderDrawingRecorder recorder(paintInfo.context, &m_renderImage, paintInfo. phase, focusRect); 67 RenderDrawingRecorder recorder(paintInfo.context, m_renderImage, paintInfo.p hase, focusRect);
68 if (recorder.canUseCachedDrawing())
69 return;
70
68 paintInfo.context->clip(focusRect); 71 paintInfo.context->clip(focusRect);
69 paintInfo.context->drawFocusRing(path, outlineWidth, 72 paintInfo.context->drawFocusRing(path, outlineWidth,
70 areaElementStyle->outlineOffset(), 73 areaElementStyle->outlineOffset(),
71 m_renderImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor)); 74 m_renderImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor));
72 } 75 }
73 76
74 void ImagePainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 77 void ImagePainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
75 { 78 {
76 LayoutUnit cWidth = m_renderImage.contentWidth(); 79 LayoutUnit cWidth = m_renderImage.contentWidth();
77 LayoutUnit cHeight = m_renderImage.contentHeight(); 80 LayoutUnit cHeight = m_renderImage.contentHeight();
78 81
79 GraphicsContext* context = paintInfo.context; 82 GraphicsContext* context = paintInfo.context;
80 83
81 if (!m_renderImage.imageResource()->hasImage()) { 84 if (!m_renderImage.imageResource()->hasImage()) {
82 if (paintInfo.phase == PaintPhaseSelection) 85 if (paintInfo.phase == PaintPhaseSelection)
83 return; 86 return;
84 87
85 if (cWidth > 2 && cHeight > 2) { 88 if (cWidth > 2 && cHeight > 2) {
86 // Draw an outline rect where the image should be. 89 // Draw an outline rect where the image should be.
87 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + m_renderImage.borderLeft() + m_renderImage.paddingLeft(), paintOffset.y() + m_r enderImage.borderTop() + m_renderImage.paddingTop(), cWidth, cHeight)); 90 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + m_renderImage.borderLeft() + m_renderImage.paddingLeft(), paintOffset.y() + m_r enderImage.borderTop() + m_renderImage.paddingTop(), cWidth, cHeight));
88 RenderDrawingRecorder recorder(context, &m_renderImage, paintInfo.ph ase, paintRect); 91 RenderDrawingRecorder recorder(context, m_renderImage, paintInfo.pha se, paintRect);
92 if (recorder.canUseCachedDrawing())
93 return;
94
89 context->setStrokeStyle(SolidStroke); 95 context->setStrokeStyle(SolidStroke);
90 context->setStrokeColor(Color::lightGray); 96 context->setStrokeColor(Color::lightGray);
91 context->setFillColor(Color::transparent); 97 context->setFillColor(Color::transparent);
92 context->drawRect(paintRect); 98 context->drawRect(paintRect);
93 } 99 }
94 } else if (cWidth > 0 && cHeight > 0) { 100 return;
chrishtr 2014/12/12 00:18:08 Why the change to get rid of the else clause?
Xianzhu 2014/12/12 00:56:49 Restored.
101 }
102
103 if (cWidth > 0 && cHeight > 0) {
95 LayoutRect contentRect = m_renderImage.contentBoxRect(); 104 LayoutRect contentRect = m_renderImage.contentBoxRect();
96 contentRect.moveBy(paintOffset); 105 contentRect.moveBy(paintOffset);
97 LayoutRect paintRect = m_renderImage.replacedContentRect(); 106 LayoutRect paintRect = m_renderImage.replacedContentRect();
98 paintRect.moveBy(paintOffset); 107 paintRect.moveBy(paintOffset);
99 RenderDrawingRecorder recorder(context, &m_renderImage, paintInfo.phase, contentRect); 108 RenderDrawingRecorder recorder(context, m_renderImage, paintInfo.phase, contentRect);
109 if (recorder.canUseCachedDrawing())
110 return;
111
100 bool clip = !contentRect.contains(paintRect); 112 bool clip = !contentRect.contains(paintRect);
101 if (clip) { 113 if (clip) {
102 context->save(); 114 context->save();
103 context->clip(contentRect); 115 context->clip(contentRect);
104 } 116 }
105 117
106 paintIntoRect(context, paintRect); 118 paintIntoRect(context, paintRect);
107 119
108 if (clip) 120 if (clip)
109 context->restore(); 121 context->restore();
(...skipping 22 matching lines...) Expand all
132 144
133 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality(); 145 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality();
134 context->setImageInterpolationQuality(interpolationQuality); 146 context->setImageInterpolationQuality(interpolationQuality);
135 context->drawImage(image.get(), alignedRect, CompositeSourceOver, m_renderIm age.shouldRespectImageOrientation()); 147 context->drawImage(image.get(), alignedRect, CompositeSourceOver, m_renderIm age.shouldRespectImageOrientation());
136 context->setImageInterpolationQuality(previousInterpolationQuality); 148 context->setImageInterpolationQuality(previousInterpolationQuality);
137 149
138 InspectorInstrumentation::didPaintImage(&m_renderImage); 150 InspectorInstrumentation::didPaintImage(&m_renderImage);
139 } 151 }
140 152
141 } // namespace blink 153 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698