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

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

Issue 858343002: Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits Created 5 years, 11 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/GrStencilAndCoverPathRenderer.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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrSoftwarePathRenderer.h" 9 #include "GrSoftwarePathRenderer.h"
10 #include "GrContext.h" 10 #include "GrContext.h"
11 #include "GrSWMaskHelper.h" 11 #include "GrSWMaskHelper.h"
12 12
13 //////////////////////////////////////////////////////////////////////////////// 13 ////////////////////////////////////////////////////////////////////////////////
14 bool GrSoftwarePathRenderer::canDrawPath(const GrDrawTarget*, 14 bool GrSoftwarePathRenderer::canDrawPath(const GrDrawTarget*,
15 const GrDrawState*, 15 const GrPipelineBuilder*,
16 const SkMatrix& viewMatrix, 16 const SkMatrix& viewMatrix,
17 const SkPath&, 17 const SkPath&,
18 const SkStrokeRec&, 18 const SkStrokeRec&,
19 bool antiAlias) const { 19 bool antiAlias) const {
20 if (NULL == fContext) { 20 if (NULL == fContext) {
21 return false; 21 return false;
22 } 22 }
23 23
24 return true; 24 return true;
25 } 25 }
26 26
27 GrPathRenderer::StencilSupport 27 GrPathRenderer::StencilSupport
28 GrSoftwarePathRenderer::onGetStencilSupport(const GrDrawTarget*, 28 GrSoftwarePathRenderer::onGetStencilSupport(const GrDrawTarget*,
29 const GrDrawState*, 29 const GrPipelineBuilder*,
30 const SkPath&, 30 const SkPath&,
31 const SkStrokeRec&) const { 31 const SkStrokeRec&) const {
32 return GrPathRenderer::kNoSupport_StencilSupport; 32 return GrPathRenderer::kNoSupport_StencilSupport;
33 } 33 }
34 34
35 namespace { 35 namespace {
36 36
37 //////////////////////////////////////////////////////////////////////////////// 37 ////////////////////////////////////////////////////////////////////////////////
38 // gets device coord bounds of path (not considering the fill) and clip. The 38 // gets device coord bounds of path (not considering the fill) and clip. The
39 // path bounds will be a subset of the clip bounds. returns false if 39 // path bounds will be a subset of the clip bounds. returns false if
40 // path bounds would be empty. 40 // path bounds would be empty.
41 bool get_path_and_clip_bounds(const GrDrawTarget* target, 41 bool get_path_and_clip_bounds(const GrDrawTarget* target,
42 const GrDrawState* drawState, 42 const GrPipelineBuilder* pipelineBuilder,
43 const SkPath& path, 43 const SkPath& path,
44 const SkMatrix& matrix, 44 const SkMatrix& matrix,
45 SkIRect* devPathBounds, 45 SkIRect* devPathBounds,
46 SkIRect* devClipBounds) { 46 SkIRect* devClipBounds) {
47 // compute bounds as intersection of rt size, clip, and path 47 // compute bounds as intersection of rt size, clip, and path
48 const GrRenderTarget* rt = drawState->getRenderTarget(); 48 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
49 if (NULL == rt) { 49 if (NULL == rt) {
50 return false; 50 return false;
51 } 51 }
52 *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height()); 52 *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height());
53 53
54 target->getClip()->getConservativeBounds(rt, devClipBounds); 54 target->getClip()->getConservativeBounds(rt, devClipBounds);
55 55
56 // TODO: getConservativeBounds already intersects with the 56 // TODO: getConservativeBounds already intersects with the
57 // render target's bounding box. Remove this next line 57 // render target's bounding box. Remove this next line
58 if (!devPathBounds->intersect(*devClipBounds)) { 58 if (!devPathBounds->intersect(*devClipBounds)) {
(...skipping 12 matching lines...) Expand all
71 } 71 }
72 } else { 72 } else {
73 *devPathBounds = SkIRect::EmptyIRect(); 73 *devPathBounds = SkIRect::EmptyIRect();
74 return false; 74 return false;
75 } 75 }
76 return true; 76 return true;
77 } 77 }
78 78
79 //////////////////////////////////////////////////////////////////////////////// 79 ////////////////////////////////////////////////////////////////////////////////
80 void draw_around_inv_path(GrDrawTarget* target, 80 void draw_around_inv_path(GrDrawTarget* target,
81 GrDrawState* drawState, 81 GrPipelineBuilder* pipelineBuilder,
82 GrColor color, 82 GrColor color,
83 const SkMatrix& viewMatrix, 83 const SkMatrix& viewMatrix,
84 const SkIRect& devClipBounds, 84 const SkIRect& devClipBounds,
85 const SkIRect& devPathBounds) { 85 const SkIRect& devPathBounds) {
86 SkMatrix invert; 86 SkMatrix invert;
87 if (!viewMatrix.invert(&invert)) { 87 if (!viewMatrix.invert(&invert)) {
88 return; 88 return;
89 } 89 }
90 90
91 SkRect rect; 91 SkRect rect;
92 if (devClipBounds.fTop < devPathBounds.fTop) { 92 if (devClipBounds.fTop < devPathBounds.fTop) {
93 rect.iset(devClipBounds.fLeft, devClipBounds.fTop, 93 rect.iset(devClipBounds.fLeft, devClipBounds.fTop,
94 devClipBounds.fRight, devPathBounds.fTop); 94 devClipBounds.fRight, devPathBounds.fTop);
95 target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert); 95 target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &inv ert);
96 } 96 }
97 if (devClipBounds.fLeft < devPathBounds.fLeft) { 97 if (devClipBounds.fLeft < devPathBounds.fLeft) {
98 rect.iset(devClipBounds.fLeft, devPathBounds.fTop, 98 rect.iset(devClipBounds.fLeft, devPathBounds.fTop,
99 devPathBounds.fLeft, devPathBounds.fBottom); 99 devPathBounds.fLeft, devPathBounds.fBottom);
100 target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert); 100 target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &inv ert);
101 } 101 }
102 if (devClipBounds.fRight > devPathBounds.fRight) { 102 if (devClipBounds.fRight > devPathBounds.fRight) {
103 rect.iset(devPathBounds.fRight, devPathBounds.fTop, 103 rect.iset(devPathBounds.fRight, devPathBounds.fTop,
104 devClipBounds.fRight, devPathBounds.fBottom); 104 devClipBounds.fRight, devPathBounds.fBottom);
105 target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert); 105 target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &inv ert);
106 } 106 }
107 if (devClipBounds.fBottom > devPathBounds.fBottom) { 107 if (devClipBounds.fBottom > devPathBounds.fBottom) {
108 rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, 108 rect.iset(devClipBounds.fLeft, devPathBounds.fBottom,
109 devClipBounds.fRight, devClipBounds.fBottom); 109 devClipBounds.fRight, devClipBounds.fBottom);
110 target->drawRect(drawState, color, SkMatrix::I(), rect, NULL, &invert); 110 target->drawRect(pipelineBuilder, color, SkMatrix::I(), rect, NULL, &inv ert);
111 } 111 }
112 } 112 }
113 113
114 } 114 }
115 115
116 //////////////////////////////////////////////////////////////////////////////// 116 ////////////////////////////////////////////////////////////////////////////////
117 // return true on success; false on failure 117 // return true on success; false on failure
118 bool GrSoftwarePathRenderer::onDrawPath(GrDrawTarget* target, 118 bool GrSoftwarePathRenderer::onDrawPath(GrDrawTarget* target,
119 GrDrawState* drawState, 119 GrPipelineBuilder* pipelineBuilder,
120 GrColor color, 120 GrColor color,
121 const SkMatrix& viewMatrix, 121 const SkMatrix& viewMatrix,
122 const SkPath& path, 122 const SkPath& path,
123 const SkStrokeRec& stroke, 123 const SkStrokeRec& stroke,
124 bool antiAlias) { 124 bool antiAlias) {
125 125
126 if (NULL == fContext) { 126 if (NULL == fContext) {
127 return false; 127 return false;
128 } 128 }
129 129
130 SkIRect devPathBounds, devClipBounds; 130 SkIRect devPathBounds, devClipBounds;
131 if (!get_path_and_clip_bounds(target, drawState, path, viewMatrix, 131 if (!get_path_and_clip_bounds(target, pipelineBuilder, path, viewMatrix,
132 &devPathBounds, &devClipBounds)) { 132 &devPathBounds, &devClipBounds)) {
133 if (path.isInverseFillType()) { 133 if (path.isInverseFillType()) {
134 draw_around_inv_path(target, drawState, color, viewMatrix, devClipBo unds,devPathBounds); 134 draw_around_inv_path(target, pipelineBuilder, color, viewMatrix, dev ClipBounds,
135 devPathBounds);
135 } 136 }
136 return true; 137 return true;
137 } 138 }
138 139
139 SkAutoTUnref<GrTexture> texture( 140 SkAutoTUnref<GrTexture> texture(
140 GrSWMaskHelper::DrawPathMaskToTexture(fContext, path, stroke, 141 GrSWMaskHelper::DrawPathMaskToTexture(fContext, path, stroke,
141 devPathBounds, 142 devPathBounds,
142 antiAlias, &viewMatrix)); 143 antiAlias, &viewMatrix));
143 if (NULL == texture) { 144 if (NULL == texture) {
144 return false; 145 return false;
145 } 146 }
146 147
147 GrDrawState copy = *drawState; 148 GrPipelineBuilder copy = *pipelineBuilder;
148 GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, &copy, color, view Matrix, 149 GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, &copy, color, view Matrix,
149 devPathBounds); 150 devPathBounds);
150 151
151 if (path.isInverseFillType()) { 152 if (path.isInverseFillType()) {
152 draw_around_inv_path(target, drawState, color, viewMatrix, devClipBounds , devPathBounds); 153 draw_around_inv_path(target, pipelineBuilder, color, viewMatrix, devClip Bounds,
154 devPathBounds);
153 } 155 }
154 156
155 return true; 157 return true;
156 } 158 }
OLDNEW
« no previous file with comments | « src/gpu/GrSoftwarePathRenderer.h ('k') | src/gpu/GrStencilAndCoverPathRenderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698