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

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

Issue 665893004: Add paint chunk recording to ImagePainter (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "core/frame/LocalFrame.h" 11 #include "core/frame/LocalFrame.h"
12 #include "core/html/HTMLAreaElement.h" 12 #include "core/html/HTMLAreaElement.h"
13 #include "core/html/HTMLImageElement.h" 13 #include "core/html/HTMLImageElement.h"
14 #include "core/inspector/InspectorInstrumentation.h" 14 #include "core/inspector/InspectorInstrumentation.h"
15 #include "core/page/Page.h" 15 #include "core/page/Page.h"
16 #include "core/paint/BoxPainter.h" 16 #include "core/paint/BoxPainter.h"
17 #include "core/paint/ViewDisplayList.h"
17 #include "core/rendering/PaintInfo.h" 18 #include "core/rendering/PaintInfo.h"
18 #include "core/rendering/RenderImage.h" 19 #include "core/rendering/RenderImage.h"
19 #include "core/rendering/RenderReplaced.h" 20 #include "core/rendering/RenderReplaced.h"
20 #include "core/rendering/TextRunConstructor.h" 21 #include "core/rendering/TextRunConstructor.h"
21 #include "platform/geometry/LayoutPoint.h" 22 #include "platform/geometry/LayoutPoint.h"
22 #include "platform/graphics/GraphicsContextStateSaver.h" 23 #include "platform/graphics/GraphicsContextStateSaver.h"
23 #include "platform/graphics/Path.h" 24 #include "platform/graphics/Path.h"
24 25
25 namespace blink { 26 namespace blink {
26 27
(...skipping 28 matching lines...) Expand all
55 return; 56 return;
56 57
57 RenderStyle* areaElementStyle = areaElement.computedStyle(); 58 RenderStyle* areaElementStyle = areaElement.computedStyle();
58 unsigned short outlineWidth = areaElementStyle->outlineWidth(); 59 unsigned short outlineWidth = areaElementStyle->outlineWidth();
59 if (!outlineWidth) 60 if (!outlineWidth)
60 return; 61 return;
61 62
62 // FIXME: Clip path instead of context when Skia pathops is ready. 63 // FIXME: Clip path instead of context when Skia pathops is ready.
63 // https://crbug.com/251206 64 // https://crbug.com/251206
64 GraphicsContextStateSaver savedContext(*paintInfo.context); 65 GraphicsContextStateSaver savedContext(*paintInfo.context);
65 paintInfo.context->clip(m_renderImage.absoluteContentBox()); 66 IntRect focusRect = m_renderImage.absoluteContentBox();
67 PaintCommandRecorder recorder(paintInfo.context, &m_renderImage, paintInfo.p hase, focusRect);
68 paintInfo.context->clip(focusRect);
66 paintInfo.context->drawFocusRing(path, outlineWidth, 69 paintInfo.context->drawFocusRing(path, outlineWidth,
67 areaElementStyle->outlineOffset(), 70 areaElementStyle->outlineOffset(),
68 m_renderImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor)); 71 m_renderImage.resolveColor(areaElementStyle, CSSPropertyOutlineColor));
69 } 72 }
70 73
71 void ImagePainter::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintO ffset) 74 void ImagePainter::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintO ffset)
72 { 75 {
73 LayoutUnit cWidth = m_renderImage.contentWidth(); 76 LayoutUnit cWidth = m_renderImage.contentWidth();
74 LayoutUnit cHeight = m_renderImage.contentHeight(); 77 LayoutUnit cHeight = m_renderImage.contentHeight();
75 78
76 GraphicsContext* context = paintInfo.context; 79 GraphicsContext* context = paintInfo.context;
77 80
78 if (!m_renderImage.imageResource()->hasImage() || m_renderImage.imageResourc e()->errorOccurred()) { 81 if (!m_renderImage.imageResource()->hasImage() || m_renderImage.imageResourc e()->errorOccurred()) {
79 if (paintInfo.phase == PaintPhaseSelection) 82 if (paintInfo.phase == PaintPhaseSelection)
80 return; 83 return;
81 84
82 if (cWidth > 2 && cHeight > 2) { 85 if (cWidth > 2 && cHeight > 2) {
83 const int borderWidth = 1; 86 const int borderWidth = 1;
84 87
85 LayoutUnit leftBorder = m_renderImage.borderLeft(); 88 LayoutUnit leftBorder = m_renderImage.borderLeft();
86 LayoutUnit topBorder = m_renderImage.borderTop(); 89 LayoutUnit topBorder = m_renderImage.borderTop();
87 LayoutUnit leftPad = m_renderImage.paddingLeft(); 90 LayoutUnit leftPad = m_renderImage.paddingLeft();
88 LayoutUnit topPad = m_renderImage.paddingTop(); 91 LayoutUnit topPad = m_renderImage.paddingTop();
89 92
90 // Draw an outline rect where the image should be. 93 // Draw an outline rect where the image should be.
94 IntRect paintRect = pixelSnappedIntRect(LayoutRect(paintOffset.x() + leftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight));
95 PaintCommandRecorder recorder(context, &m_renderImage, paintInfo.pha se, paintRect);
91 context->setStrokeStyle(SolidStroke); 96 context->setStrokeStyle(SolidStroke);
92 context->setStrokeColor(Color::lightGray); 97 context->setStrokeColor(Color::lightGray);
93 context->setFillColor(Color::transparent); 98 context->setFillColor(Color::transparent);
94 context->drawRect(pixelSnappedIntRect(LayoutRect(paintOffset.x() + l eftBorder + leftPad, paintOffset.y() + topBorder + topPad, cWidth, cHeight))); 99 context->drawRect(paintRect);
95 100
96 bool errorPictureDrawn = false; 101 bool errorPictureDrawn = false;
97 LayoutSize imageOffset; 102 LayoutSize imageOffset;
98 // When calculating the usable dimensions, exclude the pixels of 103 // When calculating the usable dimensions, exclude the pixels of
99 // the ouline rect so the error image/alt text doesn't draw on it. 104 // the ouline rect so the error image/alt text doesn't draw on it.
100 LayoutUnit usableWidth = cWidth - 2 * borderWidth; 105 LayoutUnit usableWidth = cWidth - 2 * borderWidth;
101 LayoutUnit usableHeight = cHeight - 2 * borderWidth; 106 LayoutUnit usableHeight = cHeight - 2 * borderWidth;
102 107
103 RefPtr<Image> image = m_renderImage.imageResource()->image(); 108 RefPtr<Image> image = m_renderImage.imageResource()->image();
104 109
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } else if (usableWidth >= textWidth && usableHeight >= fontMetri cs.height()) { 151 } else if (usableWidth >= textWidth && usableHeight >= fontMetri cs.height()) {
147 context->drawBidiText(font, textRunPaintInfo, textOrigin); 152 context->drawBidiText(font, textRunPaintInfo, textOrigin);
148 } 153 }
149 } 154 }
150 } 155 }
151 } else if (m_renderImage.imageResource()->hasImage() && cWidth > 0 && cHeigh t > 0) { 156 } else if (m_renderImage.imageResource()->hasImage() && cWidth > 0 && cHeigh t > 0) {
152 LayoutRect contentRect = m_renderImage.contentBoxRect(); 157 LayoutRect contentRect = m_renderImage.contentBoxRect();
153 contentRect.moveBy(paintOffset); 158 contentRect.moveBy(paintOffset);
154 LayoutRect paintRect = m_renderImage.replacedContentRect(); 159 LayoutRect paintRect = m_renderImage.replacedContentRect();
155 paintRect.moveBy(paintOffset); 160 paintRect.moveBy(paintOffset);
161 PaintCommandRecorder recorder(context, &m_renderImage, paintInfo.phase, contentRect);
156 bool clip = !contentRect.contains(paintRect); 162 bool clip = !contentRect.contains(paintRect);
157 if (clip) { 163 if (clip) {
158 context->save(); 164 context->save();
159 context->clip(contentRect); 165 context->clip(contentRect);
160 } 166 }
161 167
162 paintIntoRect(context, paintRect); 168 paintIntoRect(context, paintRect);
163 169
164 if (clip) 170 if (clip)
165 context->restore(); 171 context->restore();
(...skipping 19 matching lines...) Expand all
185 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 191 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
186 InspectorInstrumentation::willPaintImage(&m_renderImage); 192 InspectorInstrumentation::willPaintImage(&m_renderImage);
187 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality(); 193 InterpolationQuality previousInterpolationQuality = context->imageInterpolat ionQuality();
188 context->setImageInterpolationQuality(interpolationQuality); 194 context->setImageInterpolationQuality(interpolationQuality);
189 context->drawImage(image, alignedRect, compositeOperator, m_renderImage.shou ldRespectImageOrientation()); 195 context->drawImage(image, alignedRect, compositeOperator, m_renderImage.shou ldRespectImageOrientation());
190 context->setImageInterpolationQuality(previousInterpolationQuality); 196 context->setImageInterpolationQuality(previousInterpolationQuality);
191 InspectorInstrumentation::didPaintImage(&m_renderImage); 197 InspectorInstrumentation::didPaintImage(&m_renderImage);
192 } 198 }
193 199
194 } // namespace blink 200 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698