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

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

Issue 2081383006: Use GrShape in GrPathRenderer. (Closed) Base URL: https://chromium.googlesource.com/skia.git@shapemembers
Patch Set: Address comments 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 // Pass on any style that applies. The caller will apply the style if a suit able renderer is
18 // not found and try again with the new GrShape.
19 return !args.fShape->style().applies() && SkToBool(fTexProvider);
18 } 20 }
19 21
20 namespace { 22 namespace {
21 23
22 //////////////////////////////////////////////////////////////////////////////// 24 ////////////////////////////////////////////////////////////////////////////////
23 // gets device coord bounds of path (not considering the fill) and clip. The 25 // 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 26 // path bounds will be a subset of the clip bounds. returns false if
25 // path bounds would be empty. 27 // path bounds would be empty.
26 bool get_path_and_clip_bounds(int width, int height, 28 bool get_shape_and_clip_bounds(int width, int height,
27 const GrClip& clip, 29 const GrClip& clip,
28 const SkPath& path, 30 const GrShape& shape,
29 const SkMatrix& matrix, 31 const SkMatrix& matrix,
30 SkIRect* devPathBounds, 32 SkIRect* devShapeBounds,
31 SkIRect* devClipBounds) { 33 SkIRect* devClipBounds) {
32 // compute bounds as intersection of rt size, clip, and path 34 // compute bounds as intersection of rt size, clip, and path
33 clip.getConservativeBounds(width, height, devClipBounds); 35 clip.getConservativeBounds(width, height, devClipBounds);
34 36
35 if (devClipBounds->isEmpty()) { 37 if (devClipBounds->isEmpty()) {
36 *devPathBounds = SkIRect::MakeWH(width, height); 38 *devShapeBounds = SkIRect::MakeWH(width, height);
37 return false; 39 return false;
38 } 40 }
39 41 SkRect shapeBounds;
40 if (!path.getBounds().isEmpty()) { 42 shape.styledBounds(&shapeBounds);
41 SkRect pathSBounds; 43 if (!shapeBounds.isEmpty()) {
42 matrix.mapRect(&pathSBounds, path.getBounds()); 44 SkRect shapeSBounds;
43 SkIRect pathIBounds; 45 matrix.mapRect(&shapeSBounds, shapeBounds);
44 pathSBounds.roundOut(&pathIBounds); 46 SkIRect shapeIBounds;
45 *devPathBounds = *devClipBounds; 47 shapeSBounds.roundOut(&shapeIBounds);
46 if (!devPathBounds->intersect(pathIBounds)) { 48 *devShapeBounds = *devClipBounds;
49 if (!devShapeBounds->intersect(shapeIBounds)) {
47 // set the correct path bounds, as this would be used later. 50 // set the correct path bounds, as this would be used later.
48 *devPathBounds = pathIBounds; 51 *devShapeBounds = shapeIBounds;
49 return false; 52 return false;
50 } 53 }
51 } else { 54 } else {
52 *devPathBounds = SkIRect::EmptyIRect(); 55 *devShapeBounds = SkIRect::EmptyIRect();
53 return false; 56 return false;
54 } 57 }
55 return true; 58 return true;
56 } 59 }
57 60
58 //////////////////////////////////////////////////////////////////////////////// 61 ////////////////////////////////////////////////////////////////////////////////
59 62
60 } 63 }
61 64
62 void GrSoftwarePathRenderer::DrawNonAARect(GrDrawContext* drawContext, 65 void GrSoftwarePathRenderer::DrawNonAARect(GrDrawContext* drawContext,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 121
119 //////////////////////////////////////////////////////////////////////////////// 122 ////////////////////////////////////////////////////////////////////////////////
120 // return true on success; false on failure 123 // return true on success; false on failure
121 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { 124 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
122 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(), 125 GR_AUDIT_TRAIL_AUTO_FRAME(args.fDrawContext->auditTrail(),
123 "GrSoftwarePathRenderer::onDrawPath"); 126 "GrSoftwarePathRenderer::onDrawPath");
124 if (!fTexProvider) { 127 if (!fTexProvider) {
125 return false; 128 return false;
126 } 129 }
127 130
128 SkIRect devPathBounds, devClipBounds; 131 // 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(), 132 bool inverseFilled = false;
130 *args.fClip, *args.fPath, 133 SkTLazy<GrShape> tmpShape;
131 *args.fViewMatrix, &devPathBounds, &devClipBou nds)) { 134 SkASSERT(!args.fShape->style().applies())
132 if (args.fPath->isInverseFillType()) { 135 inverseFilled = args.fShape->inverseFilled();
136
137 SkIRect devShapeBounds, devClipBounds;
138 if (!get_shape_and_clip_bounds(args.fDrawContext->width(), args.fDrawContext ->height(),
139 *args.fClip, *args.fShape,
140 *args.fViewMatrix, &devShapeBounds, &devClipB ounds)) {
141 if (inverseFilled) {
133 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilS ettings, 142 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilS ettings,
134 *args.fClip, args.fColor, 143 *args.fClip, args.fColor,
135 *args.fViewMatrix, devClipBounds, devPathBounds); 144 *args.fViewMatrix, devClipBounds, devShapeBounds);
145
136 } 146 }
137 return true; 147 return true;
138 } 148 }
139 149
140 SkAutoTUnref<GrTexture> texture( 150 SkAutoTUnref<GrTexture> texture(
141 GrSWMaskHelper::DrawPathMaskToTexture(fTexProvider, *args.fPath, *ar gs.fStyle, 151 GrSWMaskHelper::DrawShapeMaskToTexture(fTexProvider, *args.fShape, d evShapeBounds,
142 devPathBounds, 152 args.fAntiAlias, args.fViewMa trix));
143 args.fAntiAlias, args.fViewMat rix));
144 if (nullptr == texture) { 153 if (nullptr == texture) {
145 return false; 154 return false;
146 } 155 }
147 156
148 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fDrawContext, args.fP aint, 157 GrSWMaskHelper::DrawToTargetWithShapeMask(texture, args.fDrawContext, args.f Paint,
149 args.fUserStencilSettings, 158 args.fUserStencilSettings,
150 *args.fClip, args.fColor, *args.fVi ewMatrix, 159 *args.fClip, args.fColor, *args.fV iewMatrix,
151 devPathBounds); 160 devShapeBounds);
152 161
153 if (args.fPath->isInverseFillType()) { 162 if (inverseFilled) {
154 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilSetti ngs, 163 DrawAroundInvPath(args.fDrawContext, args.fPaint, args.fUserStencilSetti ngs,
155 *args.fClip, args.fColor, 164 *args.fClip, args.fColor,
156 *args.fViewMatrix, devClipBounds, devPathBounds); 165 *args.fViewMatrix, devClipBounds, devShapeBounds);
157 } 166 }
158 167
159 return true; 168 return true;
160 } 169 }
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