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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // chain). Some testing would need to be done r.e. performance | 22 // chain). Some testing would need to be done r.e. performance |
23 // and consistency of the resulting images before removing | 23 // and consistency of the resulting images before removing |
24 // the "!antiAlias" clause from the above test | 24 // the "!antiAlias" clause from the above test |
25 return false; | 25 return false; |
26 } | 26 } |
27 | 27 |
28 return true; | 28 return true; |
29 } | 29 } |
30 | 30 |
31 GrPathRenderer::StencilSupport GrSoftwarePathRenderer::onGetStencilSupport( | 31 GrPathRenderer::StencilSupport GrSoftwarePathRenderer::onGetStencilSupport( |
32 const Sk
Path&, | 32 const SkPath&, |
33 const Sk
StrokeRec&, | 33 const SkStrokeRec&, |
34 const Gr
DrawTarget*) const { | 34 const GrDrawTarget*) const { |
35 return GrPathRenderer::kNoSupport_StencilSupport; | 35 return GrPathRenderer::kNoSupport_StencilSupport; |
36 } | 36 } |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
41 // gets device coord bounds of path (not considering the fill) and clip. The | 41 // gets device coord bounds of path (not considering the fill) and clip. The |
42 // path bounds will be a subset of the clip bounds. returns false if | 42 // path bounds will be a subset of the clip bounds. returns false if |
43 // path bounds would be empty. | 43 // path bounds would be empty. |
44 bool get_path_and_clip_bounds(const GrDrawTarget* target, | 44 bool get_path_and_clip_bounds(const GrDrawTarget* target, |
45 const SkPath& path, | 45 const SkPath& path, |
46 const SkMatrix& matrix, | 46 const SkMatrix& matrix, |
47 GrIRect* devPathBounds, | 47 SkIRect* devPathBounds, |
48 GrIRect* devClipBounds) { | 48 SkIRect* devClipBounds) { |
49 // compute bounds as intersection of rt size, clip, and path | 49 // compute bounds as intersection of rt size, clip, and path |
50 const GrRenderTarget* rt = target->getDrawState().getRenderTarget(); | 50 const GrRenderTarget* rt = target->getDrawState().getRenderTarget(); |
51 if (NULL == rt) { | 51 if (NULL == rt) { |
52 return false; | 52 return false; |
53 } | 53 } |
54 *devPathBounds = GrIRect::MakeWH(rt->width(), rt->height()); | 54 *devPathBounds = SkIRect::MakeWH(rt->width(), rt->height()); |
55 | 55 |
56 target->getClip()->getConservativeBounds(rt, devClipBounds); | 56 target->getClip()->getConservativeBounds(rt, devClipBounds); |
57 | 57 |
58 // TODO: getConservativeBounds already intersects with the | 58 // TODO: getConservativeBounds already intersects with the |
59 // render target's bounding box. Remove this next line | 59 // render target's bounding box. Remove this next line |
60 if (!devPathBounds->intersect(*devClipBounds)) { | 60 if (!devPathBounds->intersect(*devClipBounds)) { |
61 return false; | 61 return false; |
62 } | 62 } |
63 | 63 |
64 if (!path.getBounds().isEmpty()) { | 64 if (!path.getBounds().isEmpty()) { |
65 GrRect pathSBounds; | 65 SkRect pathSBounds; |
66 matrix.mapRect(&pathSBounds, path.getBounds()); | 66 matrix.mapRect(&pathSBounds, path.getBounds()); |
67 GrIRect pathIBounds; | 67 SkIRect pathIBounds; |
68 pathSBounds.roundOut(&pathIBounds); | 68 pathSBounds.roundOut(&pathIBounds); |
69 if (!devPathBounds->intersect(pathIBounds)) { | 69 if (!devPathBounds->intersect(pathIBounds)) { |
70 // set the correct path bounds, as this would be used later. | 70 // set the correct path bounds, as this would be used later. |
71 *devPathBounds = pathIBounds; | 71 *devPathBounds = pathIBounds; |
72 return false; | 72 return false; |
73 } | 73 } |
74 } else { | 74 } else { |
75 *devPathBounds = GrIRect::EmptyIRect(); | 75 *devPathBounds = SkIRect::EmptyIRect(); |
76 return false; | 76 return false; |
77 } | 77 } |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 //////////////////////////////////////////////////////////////////////////////// | 81 //////////////////////////////////////////////////////////////////////////////// |
82 void draw_around_inv_path(GrDrawTarget* target, | 82 void draw_around_inv_path(GrDrawTarget* target, |
83 const GrIRect& devClipBounds, | 83 const SkIRect& devClipBounds, |
84 const GrIRect& devPathBounds) { | 84 const SkIRect& devPathBounds) { |
85 GrDrawState::AutoViewMatrixRestore avmr; | 85 GrDrawState::AutoViewMatrixRestore avmr; |
86 if (!avmr.setIdentity(target->drawState())) { | 86 if (!avmr.setIdentity(target->drawState())) { |
87 return; | 87 return; |
88 } | 88 } |
89 GrRect rect; | 89 SkRect rect; |
90 if (devClipBounds.fTop < devPathBounds.fTop) { | 90 if (devClipBounds.fTop < devPathBounds.fTop) { |
91 rect.iset(devClipBounds.fLeft, devClipBounds.fTop, | 91 rect.iset(devClipBounds.fLeft, devClipBounds.fTop, |
92 devClipBounds.fRight, devPathBounds.fTop); | 92 devClipBounds.fRight, devPathBounds.fTop); |
93 target->drawSimpleRect(rect, NULL); | 93 target->drawSimpleRect(rect, NULL); |
94 } | 94 } |
95 if (devClipBounds.fLeft < devPathBounds.fLeft) { | 95 if (devClipBounds.fLeft < devPathBounds.fLeft) { |
96 rect.iset(devClipBounds.fLeft, devPathBounds.fTop, | 96 rect.iset(devClipBounds.fLeft, devPathBounds.fTop, |
97 devPathBounds.fLeft, devPathBounds.fBottom); | 97 devPathBounds.fLeft, devPathBounds.fBottom); |
98 target->drawSimpleRect(rect, NULL); | 98 target->drawSimpleRect(rect, NULL); |
99 } | 99 } |
(...skipping 19 matching lines...) Expand all Loading... |
119 bool antiAlias) { | 119 bool antiAlias) { |
120 | 120 |
121 if (NULL == fContext) { | 121 if (NULL == fContext) { |
122 return false; | 122 return false; |
123 } | 123 } |
124 | 124 |
125 GrDrawState* drawState = target->drawState(); | 125 GrDrawState* drawState = target->drawState(); |
126 | 126 |
127 SkMatrix vm = drawState->getViewMatrix(); | 127 SkMatrix vm = drawState->getViewMatrix(); |
128 | 128 |
129 GrIRect devPathBounds, devClipBounds; | 129 SkIRect devPathBounds, devClipBounds; |
130 if (!get_path_and_clip_bounds(target, path, vm, | 130 if (!get_path_and_clip_bounds(target, path, vm, |
131 &devPathBounds, &devClipBounds)) { | 131 &devPathBounds, &devClipBounds)) { |
132 if (path.isInverseFillType()) { | 132 if (path.isInverseFillType()) { |
133 draw_around_inv_path(target, devClipBounds, devPathBounds); | 133 draw_around_inv_path(target, devClipBounds, devPathBounds); |
134 } | 134 } |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 SkAutoTUnref<GrTexture> texture( | 138 SkAutoTUnref<GrTexture> texture( |
139 GrSWMaskHelper::DrawPathMaskToTexture(fContext, path, stroke, | 139 GrSWMaskHelper::DrawPathMaskToTexture(fContext, path, stroke, |
140 devPathBounds, | 140 devPathBounds, |
141 antiAlias, &vm)); | 141 antiAlias, &vm)); |
142 if (NULL == texture) { | 142 if (NULL == texture) { |
143 return false; | 143 return false; |
144 } | 144 } |
145 | 145 |
146 GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, devPathBounds); | 146 GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, devPathBounds); |
147 | 147 |
148 if (path.isInverseFillType()) { | 148 if (path.isInverseFillType()) { |
149 draw_around_inv_path(target, devClipBounds, devPathBounds); | 149 draw_around_inv_path(target, devClipBounds, devPathBounds); |
150 } | 150 } |
151 | 151 |
152 return true; | 152 return true; |
153 } | 153 } |
OLD | NEW |