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

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

Issue 1220583004: Refactor DrawingRecorders to check for cached drawings earlier (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 5 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 "config.h" 5 #include "config.h"
6 #include "core/paint/SVGShapePainter.h" 6 #include "core/paint/SVGShapePainter.h"
7 7
8 #include "core/layout/svg/LayoutSVGPath.h" 8 #include "core/layout/svg/LayoutSVGPath.h"
9 #include "core/layout/svg/LayoutSVGResourceMarker.h" 9 #include "core/layout/svg/LayoutSVGResourceMarker.h"
10 #include "core/layout/svg/LayoutSVGShape.h" 10 #include "core/layout/svg/LayoutSVGShape.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 FloatRect boundingBox = m_layoutSVGShape.paintInvalidationRectInLocalCoordin ates(); 51 FloatRect boundingBox = m_layoutSVGShape.paintInvalidationRectInLocalCoordin ates();
52 if (!paintInfo.intersectsCullRect(m_layoutSVGShape.localTransform(), boundin gBox)) 52 if (!paintInfo.intersectsCullRect(m_layoutSVGShape.localTransform(), boundin gBox))
53 return; 53 return;
54 54
55 PaintInfo paintInfoBeforeFiltering(paintInfo); 55 PaintInfo paintInfoBeforeFiltering(paintInfo);
56 // Shapes cannot have children so do not call updateCullRectForSVGTransform. 56 // Shapes cannot have children so do not call updateCullRectForSVGTransform.
57 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_lay outSVGShape, m_layoutSVGShape.localTransform()); 57 TransformRecorder transformRecorder(*paintInfoBeforeFiltering.context, m_lay outSVGShape, m_layoutSVGShape.localTransform());
58 { 58 {
59 SVGPaintContext paintContext(m_layoutSVGShape, paintInfoBeforeFiltering) ; 59 SVGPaintContext paintContext(m_layoutSVGShape, paintInfoBeforeFiltering) ;
60 if (paintContext.applyClipMaskAndFilterIfNecessary()) { 60 if (paintContext.applyClipMaskAndFilterIfNecessary() && !LayoutObjectDra wingRecorder::useCachedDrawingIfPossible(*paintContext.paintInfo().context, m_la youtSVGShape, paintContext.paintInfo().phase)) {
61 LayoutObjectDrawingRecorder recorder(*paintContext.paintInfo().conte xt, m_layoutSVGShape, paintContext.paintInfo().phase, boundingBox); 61 LayoutObjectDrawingRecorder recorder(*paintContext.paintInfo().conte xt, m_layoutSVGShape, paintContext.paintInfo().phase, boundingBox);
62 if (!recorder.canUseCachedDrawing()) { 62 const SVGComputedStyle& svgStyle = m_layoutSVGShape.style()->svgStyl e();
63 const SVGComputedStyle& svgStyle = m_layoutSVGShape.style()->svg Style();
64 63
65 bool shouldAntiAlias = svgStyle.shapeRendering() != SR_CRISPEDGE S; 64 bool shouldAntiAlias = svgStyle.shapeRendering() != SR_CRISPEDGES;
66 65
67 for (int i = 0; i < 3; i++) { 66 for (int i = 0; i < 3; i++) {
68 switch (svgStyle.paintOrderType(i)) { 67 switch (svgStyle.paintOrderType(i)) {
69 case PT_FILL: { 68 case PT_FILL: {
70 SkPaint fillPaint; 69 SkPaint fillPaint;
71 if (!SVGPaintContext::paintForLayoutObject(paintContext. paintInfo(), m_layoutSVGShape.styleRef(), m_layoutSVGShape, ApplyToFillMode, fil lPaint)) 70 if (!SVGPaintContext::paintForLayoutObject(paintContext.pain tInfo(), m_layoutSVGShape.styleRef(), m_layoutSVGShape, ApplyToFillMode, fillPai nt))
71 break;
72 fillPaint.setAntiAlias(shouldAntiAlias);
73 fillShape(paintContext.paintInfo().context, fillPaint, fillR uleFromStyle(paintContext.paintInfo(), svgStyle));
74 break;
75 }
76 case PT_STROKE:
77 if (svgStyle.hasVisibleStroke()) {
78 GraphicsContextStateSaver stateSaver(*paintContext.paint Info().context, false);
79 AffineTransform nonScalingTransform;
80 const AffineTransform* additionalPaintServerTransform = 0;
81
82 if (m_layoutSVGShape.hasNonScalingStroke()) {
83 nonScalingTransform = m_layoutSVGShape.nonScalingStr okeTransform();
84 if (!setupNonScalingStrokeContext(nonScalingTransfor m, stateSaver))
85 return;
86
87 // Non-scaling stroke needs to reset the transform b ack to the host transform.
88 additionalPaintServerTransform = &nonScalingTransfor m;
89 }
90
91 SkPaint strokePaint;
92 if (!SVGPaintContext::paintForLayoutObject(paintContext. paintInfo(), m_layoutSVGShape.styleRef(), m_layoutSVGShape, ApplyToStrokeMode, s trokePaint, additionalPaintServerTransform))
72 break; 93 break;
73 fillPaint.setAntiAlias(shouldAntiAlias); 94 strokePaint.setAntiAlias(shouldAntiAlias);
74 fillShape(paintContext.paintInfo().context, fillPaint, f illRuleFromStyle(paintContext.paintInfo(), svgStyle)); 95
75 break; 96 StrokeData strokeData;
97 SVGLayoutSupport::applyStrokeStyleToStrokeData(strokeDat a, m_layoutSVGShape.styleRef(), m_layoutSVGShape);
98 strokeData.setupPaint(&strokePaint);
99
100 strokeShape(paintContext.paintInfo().context, strokePain t);
76 } 101 }
77 case PT_STROKE: 102 break;
78 if (svgStyle.hasVisibleStroke()) { 103 case PT_MARKERS:
79 GraphicsContextStateSaver stateSaver(*paintContext.p aintInfo().context, false); 104 paintMarkers(paintContext.paintInfo(), boundingBox);
80 AffineTransform nonScalingTransform; 105 break;
81 const AffineTransform* additionalPaintServerTransfor m = 0; 106 default:
82 107 ASSERT_NOT_REACHED();
83 if (m_layoutSVGShape.hasNonScalingStroke()) { 108 break;
84 nonScalingTransform = m_layoutSVGShape.nonScalin gStrokeTransform();
85 if (!setupNonScalingStrokeContext(nonScalingTran sform, stateSaver))
86 return;
87
88 // Non-scaling stroke needs to reset the transfo rm back to the host transform.
89 additionalPaintServerTransform = &nonScalingTran sform;
90 }
91
92 SkPaint strokePaint;
93 if (!SVGPaintContext::paintForLayoutObject(paintCont ext.paintInfo(), m_layoutSVGShape.styleRef(), m_layoutSVGShape, ApplyToStrokeMod e, strokePaint, additionalPaintServerTransform))
94 break;
95 strokePaint.setAntiAlias(shouldAntiAlias);
96
97 StrokeData strokeData;
98 SVGLayoutSupport::applyStrokeStyleToStrokeData(strok eData, m_layoutSVGShape.styleRef(), m_layoutSVGShape);
99 strokeData.setupPaint(&strokePaint);
100
101 strokeShape(paintContext.paintInfo().context, stroke Paint);
102 }
103 break;
104 case PT_MARKERS:
105 paintMarkers(paintContext.paintInfo(), boundingBox);
106 break;
107 default:
108 ASSERT_NOT_REACHED();
109 break;
110 }
111 } 109 }
112 } 110 }
113 } 111 }
114 } 112 }
115 113
116 if (m_layoutSVGShape.style()->outlineWidth()) { 114 if (m_layoutSVGShape.style()->outlineWidth()) {
117 PaintInfo outlinePaintInfo(paintInfoBeforeFiltering); 115 PaintInfo outlinePaintInfo(paintInfoBeforeFiltering);
118 outlinePaintInfo.phase = PaintPhaseSelfOutline; 116 outlinePaintInfo.phase = PaintPhaseSelfOutline;
119 LayoutRect layoutObjectBounds(boundingBox); 117 LayoutRect layoutObjectBounds(boundingBox);
120 LayoutRect visualOverflowRect = ObjectPainter::outlineBounds(layoutObjec tBounds, m_layoutSVGShape.styleRef()); 118 LayoutRect visualOverflowRect = ObjectPainter::outlineBounds(layoutObjec tBounds, m_layoutSVGShape.styleRef());
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 position = nonScalingTransform.mapPoint(position); 254 position = nonScalingTransform.mapPoint(position);
257 FloatRect subpathRect = LayoutSVGPath::zeroLengthSubpathRect(position, m _layoutSVGShape.strokeWidth()); 255 FloatRect subpathRect = LayoutSVGPath::zeroLengthSubpathRect(position, m _layoutSVGShape.strokeWidth());
258 if (m_layoutSVGShape.style()->svgStyle().capStyle() == SquareCap) 256 if (m_layoutSVGShape.style()->svgStyle().capStyle() == SquareCap)
259 context->drawRect(subpathRect, fillPaint); 257 context->drawRect(subpathRect, fillPaint);
260 else 258 else
261 context->drawOval(subpathRect, fillPaint); 259 context->drawOval(subpathRect, fillPaint);
262 } 260 }
263 } 261 }
264 262
265 } // namespace blink 263 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/SVGRootInlineBoxPainter.cpp ('k') | Source/core/paint/ScrollableAreaPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698