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: src/gpu/GrSoftwarePathRenderer.cpp

Issue 1993403002: GrSWMaskHelper and GrSoftwarePathRenderer only need the textureProvider (not GrContext) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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') | 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 /* 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 "GrContext.h"
10 #include "GrSWMaskHelper.h" 9 #include "GrSWMaskHelper.h"
10 #include "GrTextureProvider.h"
11 #include "batches/GrRectBatchFactory.h" 11 #include "batches/GrRectBatchFactory.h"
12 12
13 //////////////////////////////////////////////////////////////////////////////// 13 ////////////////////////////////////////////////////////////////////////////////
14 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { 14 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
15 return SkToBool(fContext); 15 return SkToBool(fTexProvider);
16 } 16 }
17 17
18 namespace { 18 namespace {
19 19
20 //////////////////////////////////////////////////////////////////////////////// 20 ////////////////////////////////////////////////////////////////////////////////
21 // gets device coord bounds of path (not considering the fill) and clip. The 21 // gets device coord bounds of path (not considering the fill) and clip. The
22 // path bounds will be a subset of the clip bounds. returns false if 22 // path bounds will be a subset of the clip bounds. returns false if
23 // path bounds would be empty. 23 // path bounds would be empty.
24 bool get_path_and_clip_bounds(const GrPipelineBuilder* pipelineBuilder, 24 bool get_path_and_clip_bounds(int width, int height,
25 const GrClip& clip, 25 const GrClip& clip,
26 const SkPath& path, 26 const SkPath& path,
27 const SkMatrix& matrix, 27 const SkMatrix& matrix,
28 SkIRect* devPathBounds, 28 SkIRect* devPathBounds,
29 SkIRect* devClipBounds) { 29 SkIRect* devClipBounds) {
30 // compute bounds as intersection of rt size, clip, and path 30 // compute bounds as intersection of rt size, clip, and path
31 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); 31 clip.getConservativeBounds(width, height, devClipBounds);
32 if (nullptr == rt) { 32
33 if (devClipBounds->isEmpty()) {
34 *devPathBounds = SkIRect::MakeWH(width, height);
33 return false; 35 return false;
34 } 36 }
35 37
36 clip.getConservativeBounds(rt->width(), rt->height(), devClipBounds);
37
38 if (devClipBounds->isEmpty()) {
39 *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height());
40 return false;
41 }
42
43 if (!path.getBounds().isEmpty()) { 38 if (!path.getBounds().isEmpty()) {
44 SkRect pathSBounds; 39 SkRect pathSBounds;
45 matrix.mapRect(&pathSBounds, path.getBounds()); 40 matrix.mapRect(&pathSBounds, path.getBounds());
46 SkIRect pathIBounds; 41 SkIRect pathIBounds;
47 pathSBounds.roundOut(&pathIBounds); 42 pathSBounds.roundOut(&pathIBounds);
48 *devPathBounds = *devClipBounds; 43 *devPathBounds = *devClipBounds;
49 if (!devPathBounds->intersect(pathIBounds)) { 44 if (!devPathBounds->intersect(pathIBounds)) {
50 // set the correct path bounds, as this would be used later. 45 // set the correct path bounds, as this would be used later.
51 *devPathBounds = pathIBounds; 46 *devPathBounds = pathIBounds;
52 return false; 47 return false;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 draw_non_aa_rect(target, *pipelineBuilder, clip, color, SkMatrix::I(), r ect, invert); 100 draw_non_aa_rect(target, *pipelineBuilder, clip, color, SkMatrix::I(), r ect, invert);
106 } 101 }
107 } 102 }
108 103
109 } 104 }
110 105
111 //////////////////////////////////////////////////////////////////////////////// 106 ////////////////////////////////////////////////////////////////////////////////
112 // return true on success; false on failure 107 // return true on success; false on failure
113 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { 108 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
114 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrSoftwarePathRend erer::onDrawPath"); 109 GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(), "GrSoftwarePathRend erer::onDrawPath");
115 if (nullptr == fContext) { 110 if (!fTexProvider || !args.fPipelineBuilder->getRenderTarget()) {
116 return false; 111 return false;
117 } 112 }
118 113
114 const int width = args.fPipelineBuilder->getRenderTarget()->width();
115 const int height = args.fPipelineBuilder->getRenderTarget()->height();
116
119 SkIRect devPathBounds, devClipBounds; 117 SkIRect devPathBounds, devClipBounds;
120 if (!get_path_and_clip_bounds(args.fPipelineBuilder, *args.fClip, *args.fPat h, 118 if (!get_path_and_clip_bounds(width, height, *args.fClip, *args.fPath,
121 *args.fViewMatrix, &devPathBounds, &devClipBou nds)) { 119 *args.fViewMatrix, &devPathBounds, &devClipBou nds)) {
122 if (args.fPath->isInverseFillType()) { 120 if (args.fPath->isInverseFillType()) {
123 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, *args.fCli p, args.fColor, 121 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, *args.fCli p, args.fColor,
124 *args.fViewMatrix, devClipBounds, devPathBounds ); 122 *args.fViewMatrix, devClipBounds, devPathBounds );
125 } 123 }
126 return true; 124 return true;
127 } 125 }
128 126
129 SkAutoTUnref<GrTexture> texture( 127 SkAutoTUnref<GrTexture> texture(
130 GrSWMaskHelper::DrawPathMaskToTexture(fContext, *args.fPath, *args.f Style, 128 GrSWMaskHelper::DrawPathMaskToTexture(fTexProvider, *args.fPath, *ar gs.fStyle,
131 devPathBounds, 129 devPathBounds,
132 args.fAntiAlias, args.fViewMat rix)); 130 args.fAntiAlias, args.fViewMat rix));
133 if (nullptr == texture) { 131 if (nullptr == texture) {
134 return false; 132 return false;
135 } 133 }
136 134
137 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fTarget, args.fPipeli neBuilder, 135 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fTarget, args.fPipeli neBuilder,
138 *args.fClip, args.fColor, *args.fVi ewMatrix, 136 *args.fClip, args.fColor, *args.fVi ewMatrix,
139 devPathBounds); 137 devPathBounds);
140 138
141 if (args.fPath->isInverseFillType()) { 139 if (args.fPath->isInverseFillType()) {
142 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, *args.fClip, a rgs.fColor, 140 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, *args.fClip, a rgs.fColor,
143 *args.fViewMatrix, devClipBounds, devPathBounds); 141 *args.fViewMatrix, devClipBounds, devPathBounds);
144 } 142 }
145 143
146 return true; 144 return true;
147 } 145 }
OLDNEW
« no previous file with comments | « src/gpu/GrSoftwarePathRenderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698