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

Side by Side Diff: src/gpu/GrSoftwarePathRenderer.cpp

Issue 2006643005: Start on replacing path+style with shape in patherenderer (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: rebase after breaking out more Created 4 years, 6 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 | « src/gpu/GrSoftwarePathRenderer.h ('k') | src/gpu/GrStyle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrSoftwarePathRenderer.h" 8 #include "GrSoftwarePathRenderer.h"
9 #include "GrAuditTrail.h" 9 #include "GrAuditTrail.h"
10 #include "GrClip.h" 10 #include "GrClip.h"
11 #include "GrSWMaskHelper.h" 11 #include "GrSWMaskHelper.h"
12 #include "GrTextureProvider.h" 12 #include "GrTextureProvider.h"
13 #include "batches/GrRectBatchFactory.h" 13 #include "batches/GrRectBatchFactory.h"
14 14
15 //////////////////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////////////////
16 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { 16 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
17 return SkToBool(fTexProvider); 17 return SkToBool(fTexProvider);
18 } 18 }
19 19
20 namespace { 20 namespace {
21 21
22 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
23 // gets device coord bounds of path (not considering the fill) and clip. The 23 // gets device coord bounds of path (not considering the fill) and clip. The
24 // path bounds will be a subset of the clip bounds. returns false if 24 // path bounds will be a subset of the clip bounds. returns false if
25 // path bounds would be empty. 25 // path bounds would be empty.
26 bool get_path_and_clip_bounds(int width, int height, 26 bool get_shape_and_clip_bounds(int width, int height,
27 const GrClip& clip, 27 const GrClip& clip,
28 const SkPath& path, 28 const GrShape& shape,
29 const SkMatrix& matrix, 29 const SkMatrix& matrix,
30 SkIRect* devPathBounds, 30 SkIRect* devShapeBounds,
31 SkIRect* devClipBounds) { 31 SkIRect* devClipBounds) {
32 // compute bounds as intersection of rt size, clip, and path 32 // compute bounds as intersection of rt size, clip, and path
33 clip.getConservativeBounds(width, height, devClipBounds); 33 clip.getConservativeBounds(width, height, devClipBounds);
34 34
35 if (devClipBounds->isEmpty()) { 35 if (devClipBounds->isEmpty()) {
36 *devPathBounds = SkIRect::MakeWH(width, height); 36 *devShapeBounds = SkIRect::MakeWH(width, height);
37 return false; 37 return false;
38 } 38 }
39 39 SkRect shapeBounds;
40 if (!path.getBounds().isEmpty()) { 40 shape.styledBounds(&shapeBounds);
41 SkRect pathSBounds; 41 if (!shapeBounds.isEmpty()) {
42 matrix.mapRect(&pathSBounds, path.getBounds()); 42 SkRect shapeSBounds;
43 SkIRect pathIBounds; 43 matrix.mapRect(&shapeSBounds, shapeBounds);
44 pathSBounds.roundOut(&pathIBounds); 44 SkIRect shapeIBounds;
45 *devPathBounds = *devClipBounds; 45 shapeSBounds.roundOut(&shapeIBounds);
46 if (!devPathBounds->intersect(pathIBounds)) { 46 *devShapeBounds = *devClipBounds;
47 if (!devShapeBounds->intersect(shapeIBounds)) {
47 // set the correct path bounds, as this would be used later. 48 // set the correct path bounds, as this would be used later.
48 *devPathBounds = pathIBounds; 49 *devShapeBounds = shapeIBounds;
49 return false; 50 return false;
50 } 51 }
51 } else { 52 } else {
52 *devPathBounds = SkIRect::EmptyIRect(); 53 *devShapeBounds = SkIRect::EmptyIRect();
53 return false; 54 return false;
54 } 55 }
55 return true; 56 return true;
56 } 57 }
57 58
58 //////////////////////////////////////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////////////
59 60
60 } 61 }
61 62
62 void GrSoftwarePathRenderer::DrawNonAARect(GrDrawContext* drawContext, 63 void GrSoftwarePathRenderer::DrawNonAARect(GrDrawContext* drawContext,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 119
119 //////////////////////////////////////////////////////////////////////////////// 120 ////////////////////////////////////////////////////////////////////////////////
120 // return true on success; false on failure 121 // return true on success; false on failure
121 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { 122 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
122 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 123 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
123 "GrSoftwarePathRenderer::onDrawPath"); 124 "GrSoftwarePathRenderer::onDrawPath");
124 if (!fTexProvider) { 125 if (!fTexProvider) {
125 return false; 126 return false;
126 } 127 }
127 128
128 SkIRect devPathBounds, devClipBounds; 129 // We really need to know if the shape will be inverse filled or not;
129 if (!get_path_and_clip_bounds(args.fDrawContext->width(), args.fDrawContext- >height(), 130 bool inverseFilled = false;
130 *args.fClip, *args.fPath, 131 SkTLazy<GrShape> tmpShape;
131 *args.fViewMatrix, &devPathBounds, &devClipBou nds)) { 132 const GrShape* shape = args.fShape;
132 if (args.fPath->isInverseFillType()) { 133 if (shape->mayBeInverseFilledAfterStyling()) {
134 // The "may" comes about because of arbitrary path effects. The rubber m eets the road here.
135 if (shape->style().hasNonDashPathEffect()) {
136 tmpShape.init(shape->applyStyle(GrStyle::Apply::kPathEffectOnly, 1.f ));
137 shape = tmpShape.get();
138 inverseFilled = shape->inverseFilled();
139 } else {
140 inverseFilled = true;
141 }
142 }
143
144 SkIRect devShapeBounds, devClipBounds;
145 if (!get_shape_and_clip_bounds(args.fDrawContext->width(), args.fDrawContext ->height(),
146 *args.fClip, *args.fShape,
147 *args.fViewMatrix, &devShapeBounds, &devClipB ounds)) {
148 if (inverseFilled) {
133 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilS ettings, 149 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilS ettings,
134 *args.fClip, args.fColor, 150 *args.fClip, args.fColor,
135 *args.fViewMatrix, devClipBounds, devPathBounds); 151 *args.fViewMatrix, devClipBounds, devShapeBounds);
152
136 } 153 }
137 return true; 154 return true;
138 } 155 }
139 156
140 SkAutoTUnref<GrTexture> texture( 157 SkAutoTUnref<GrTexture> texture(
141 GrSWMaskHelper::DrawPathMaskToTexture(fTexProvider, *args.fPath, *ar gs.fStyle, 158 GrSWMaskHelper::DrawShapeMaskToTexture(fTexProvider, *args.fShape, d evShapeBounds,
142 devPathBounds, 159 args.fAntiAlias, args.fViewMa trix));
143 args.fAntiAlias, args.fViewMat rix));
144 if (nullptr == texture) { 160 if (nullptr == texture) {
145 return false; 161 return false;
146 } 162 }
147 163
148 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fDrawContext, args.fP aint, 164 GrSWMaskHelper::DrawToTargetWithShapeMask(texture, args.fDrawContext, args.f Paint,
149 args.fUserStencilSettings, 165 args.fUserStencilSettings,
150 *args.fClip, args.fColor, *args.fVi ewMatrix, 166 *args.fClip, args.fColor, *args.fV iewMatrix,
151 devPathBounds); 167 devShapeBounds);
152 168
153 if (args.fPath->isInverseFillType()) { 169 if (inverseFilled) {
154 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilSetti ngs, 170 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilSetti ngs,
155 *args.fClip, args.fColor, 171 *args.fClip, args.fColor,
156 *args.fViewMatrix, devClipBounds, devPathBounds); 172 *args.fViewMatrix, devClipBounds, devShapeBounds);
157 } 173 }
158 174
159 return true; 175 return true;
160 } 176 }
OLDNEW
« no previous file with comments | « src/gpu/GrSoftwarePathRenderer.h ('k') | src/gpu/GrStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698