OLD | NEW |
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 #include "GrVertexBuffer.h" | 12 #include "GrVertexBuffer.h" |
13 | 13 |
14 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
15 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { | 15 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { |
16 if (NULL == fContext) { | 16 if (nullptr == fContext) { |
17 return false; | 17 return false; |
18 } | 18 } |
19 if (args.fStroke->isDashed()) { | 19 if (args.fStroke->isDashed()) { |
20 return false; | 20 return false; |
21 } | 21 } |
22 return true; | 22 return true; |
23 } | 23 } |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
28 // gets device coord bounds of path (not considering the fill) and clip. The | 28 // gets device coord bounds of path (not considering the fill) and clip. The |
29 // path bounds will be a subset of the clip bounds. returns false if | 29 // path bounds will be a subset of the clip bounds. returns false if |
30 // path bounds would be empty. | 30 // path bounds would be empty. |
31 bool get_path_and_clip_bounds(const GrDrawTarget* target, | 31 bool get_path_and_clip_bounds(const GrDrawTarget* target, |
32 const GrPipelineBuilder* pipelineBuilder, | 32 const GrPipelineBuilder* pipelineBuilder, |
33 const SkPath& path, | 33 const SkPath& path, |
34 const SkMatrix& matrix, | 34 const SkMatrix& matrix, |
35 SkIRect* devPathBounds, | 35 SkIRect* devPathBounds, |
36 SkIRect* devClipBounds) { | 36 SkIRect* devClipBounds) { |
37 // compute bounds as intersection of rt size, clip, and path | 37 // compute bounds as intersection of rt size, clip, and path |
38 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); | 38 const GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); |
39 if (NULL == rt) { | 39 if (nullptr == rt) { |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 pipelineBuilder->clip().getConservativeBounds(rt, devClipBounds); | 43 pipelineBuilder->clip().getConservativeBounds(rt, devClipBounds); |
44 | 44 |
45 if (devClipBounds->isEmpty()) { | 45 if (devClipBounds->isEmpty()) { |
46 *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height()); | 46 *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
47 return false; | 47 return false; |
48 } | 48 } |
49 | 49 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 devClipBounds.fRight, devClipBounds.fBottom); | 98 devClipBounds.fRight, devClipBounds.fBottom); |
99 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, inve
rt); | 99 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, inve
rt); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 } | 103 } |
104 | 104 |
105 //////////////////////////////////////////////////////////////////////////////// | 105 //////////////////////////////////////////////////////////////////////////////// |
106 // return true on success; false on failure | 106 // return true on success; false on failure |
107 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { | 107 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { |
108 if (NULL == fContext) { | 108 if (nullptr == fContext) { |
109 return false; | 109 return false; |
110 } | 110 } |
111 | 111 |
112 SkIRect devPathBounds, devClipBounds; | 112 SkIRect devPathBounds, devClipBounds; |
113 if (!get_path_and_clip_bounds(args.fTarget, args.fPipelineBuilder, *args.fPa
th, | 113 if (!get_path_and_clip_bounds(args.fTarget, args.fPipelineBuilder, *args.fPa
th, |
114 *args.fViewMatrix, &devPathBounds, &devClipBou
nds)) { | 114 *args.fViewMatrix, &devPathBounds, &devClipBou
nds)) { |
115 if (args.fPath->isInverseFillType()) { | 115 if (args.fPath->isInverseFillType()) { |
116 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, args.fColo
r, | 116 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, args.fColo
r, |
117 *args.fViewMatrix, devClipBounds, devPathBounds
); | 117 *args.fViewMatrix, devClipBounds, devPathBounds
); |
118 } | 118 } |
119 return true; | 119 return true; |
120 } | 120 } |
121 | 121 |
122 SkAutoTUnref<GrTexture> texture( | 122 SkAutoTUnref<GrTexture> texture( |
123 GrSWMaskHelper::DrawPathMaskToTexture(fContext, *args.fPath, *args.f
Stroke, | 123 GrSWMaskHelper::DrawPathMaskToTexture(fContext, *args.fPath, *args.f
Stroke, |
124 devPathBounds, | 124 devPathBounds, |
125 args.fAntiAlias, args.fViewMat
rix)); | 125 args.fAntiAlias, args.fViewMat
rix)); |
126 if (NULL == texture) { | 126 if (nullptr == texture) { |
127 return false; | 127 return false; |
128 } | 128 } |
129 | 129 |
130 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fTarget, args.fPipeli
neBuilder, | 130 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fTarget, args.fPipeli
neBuilder, |
131 args.fColor, *args.fViewMatrix, dev
PathBounds); | 131 args.fColor, *args.fViewMatrix, dev
PathBounds); |
132 | 132 |
133 if (args.fPath->isInverseFillType()) { | 133 if (args.fPath->isInverseFillType()) { |
134 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, args.fColor, *
args.fViewMatrix, | 134 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, args.fColor, *
args.fViewMatrix, |
135 devClipBounds, devPathBounds); | 135 devClipBounds, devPathBounds); |
136 } | 136 } |
137 | 137 |
138 return true; | 138 return true; |
139 } | 139 } |
OLD | NEW |