OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 SkScalar x = 0; | 120 SkScalar x = 0; |
121 | 121 |
122 for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) { | 122 for (int et = 0; et < kGrEffectEdgeTypeCnt; ++et) { |
123 GrTestTarget tt; | 123 GrTestTarget tt; |
124 context->getTestTarget(&tt); | 124 context->getTestTarget(&tt); |
125 if (NULL == tt.target()) { | 125 if (NULL == tt.target()) { |
126 SkDEBUGFAIL("Couldn't get Gr test target."); | 126 SkDEBUGFAIL("Couldn't get Gr test target."); |
127 return; | 127 return; |
128 } | 128 } |
129 GrDrawState* drawState = tt.target()->drawState(); | 129 GrDrawState* drawState = tt.target()->drawState(); |
130 drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs),
sizeof(SkPoint)); | |
131 | 130 |
132 SkMatrix m; | 131 SkMatrix m; |
133 SkPath p; | 132 SkPath p; |
134 m.setTranslate(x, y); | 133 m.setTranslate(x, y); |
135 path->transform(m, &p); | 134 path->transform(m, &p); |
136 | 135 |
137 GrEffectEdgeType edgeType = (GrEffectEdgeType) et; | 136 GrEffectEdgeType edgeType = (GrEffectEdgeType) et; |
138 SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeTyp
e, p)); | 137 SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeTyp
e, p)); |
139 if (!effect) { | 138 if (!effect) { |
140 continue; | 139 continue; |
141 } | 140 } |
142 drawState->addCoverageEffect(effect, 1); | 141 drawState->addCoverageEffect(effect); |
143 drawState->setIdentityViewMatrix(); | 142 drawState->setIdentityViewMatrix(); |
144 drawState->setRenderTarget(rt); | 143 drawState->setRenderTarget(rt); |
145 drawState->setColor(0xff000000); | 144 drawState->setColor(0xff000000); |
146 | 145 |
147 SkPoint verts[4]; | 146 SkPoint verts[4]; |
148 SkRect bounds = p.getBounds(); | 147 SkRect bounds = p.getBounds(); |
149 // Make sure any artifacts around the exterior of path are visib
le by using overly | 148 // Make sure any artifacts around the exterior of path are visib
le by using overly |
150 // conservative bounding geometry. | 149 // conservative bounding geometry. |
151 bounds.outset(5.f, 5.f); | 150 bounds.outset(5.f, 5.f); |
152 bounds.toQuad(verts); | 151 bounds.toQuad(verts); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 185 } |
187 SkRect rect = *iter.get(); | 186 SkRect rect = *iter.get(); |
188 rect.offset(x, y); | 187 rect.offset(x, y); |
189 GrEffectEdgeType edgeType = (GrEffectEdgeType) et; | 188 GrEffectEdgeType edgeType = (GrEffectEdgeType) et; |
190 SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeTyp
e, rect)); | 189 SkAutoTUnref<GrEffect> effect(GrConvexPolyEffect::Create(edgeTyp
e, rect)); |
191 if (!effect) { | 190 if (!effect) { |
192 continue; | 191 continue; |
193 } | 192 } |
194 | 193 |
195 GrDrawState* drawState = tt.target()->drawState(); | 194 GrDrawState* drawState = tt.target()->drawState(); |
196 drawState->setVertexAttribs<kAttribs>(SK_ARRAY_COUNT(kAttribs),
sizeof(SkPoint)); | 195 drawState->addCoverageEffect(effect); |
197 drawState->addCoverageEffect(effect, 1); | |
198 drawState->setIdentityViewMatrix(); | 196 drawState->setIdentityViewMatrix(); |
199 drawState->setRenderTarget(rt); | 197 drawState->setRenderTarget(rt); |
200 drawState->setColor(0xff000000); | 198 drawState->setColor(0xff000000); |
201 | 199 |
202 SkPoint verts[4]; | 200 SkPoint verts[4]; |
203 SkRect bounds = rect; | 201 SkRect bounds = rect; |
204 bounds.outset(5.f, 5.f); | 202 bounds.outset(5.f, 5.f); |
205 bounds.toQuad(verts); | 203 bounds.toQuad(verts); |
206 | 204 |
207 tt.target()->setVertexSourceToArray(verts, 4); | 205 tt.target()->setVertexSourceToArray(verts, 4); |
(...skipping 21 matching lines...) Expand all Loading... |
229 SkTLList<SkPath> fPaths; | 227 SkTLList<SkPath> fPaths; |
230 SkTLList<SkRect> fRects; | 228 SkTLList<SkRect> fRects; |
231 | 229 |
232 typedef GM INHERITED; | 230 typedef GM INHERITED; |
233 }; | 231 }; |
234 | 232 |
235 DEF_GM( return SkNEW(ConvexPolyEffect); ) | 233 DEF_GM( return SkNEW(ConvexPolyEffect); ) |
236 } | 234 } |
237 | 235 |
238 #endif | 236 #endif |
OLD | NEW |