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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 ngon.lineTo(point); | 128 ngon.lineTo(point); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 fPaths.addToTail(ngon); | 132 fPaths.addToTail(ngon); |
133 SkMatrix scaleM; | 133 SkMatrix scaleM; |
134 scaleM.setScale(1.1f, 0.4f); | 134 scaleM.setScale(1.1f, 0.4f); |
135 ngon.transform(scaleM); | 135 ngon.transform(scaleM); |
136 fPaths.addToTail(ngon); | 136 fPaths.addToTail(ngon); |
137 | 137 |
| 138 SkPath linePath; |
| 139 linePath.moveTo(5.f, 5.f); |
| 140 linePath.lineTo(6.f, 6.f); |
| 141 fPaths.addToTail(linePath); |
| 142 |
138 // integer edges | 143 // integer edges |
139 fRects.addToTail(SkRect::MakeLTRB(5.f, 1.f, 30.f, 25.f)); | 144 fRects.addToTail(SkRect::MakeLTRB(5.f, 1.f, 30.f, 25.f)); |
140 // half-integer edges | 145 // half-integer edges |
141 fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 24.5f)); | 146 fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 24.5f)); |
142 // vertically/horizontally thin rects that cover pixel centers | 147 // vertically/horizontally thin rects that cover pixel centers |
143 fRects.addToTail(SkRect::MakeLTRB(5.25f, 0.5f, 5.75f, 24.5f)); | 148 fRects.addToTail(SkRect::MakeLTRB(5.25f, 0.5f, 5.75f, 24.5f)); |
144 fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 0.75f)); | 149 fRects.addToTail(SkRect::MakeLTRB(5.5f, 0.5f, 29.5f, 0.75f)); |
145 // vertically/horizontally thin rects that don't cover pixel centers | 150 // vertically/horizontally thin rects that don't cover pixel centers |
146 fRects.addToTail(SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f)); | 151 fRects.addToTail(SkRect::MakeLTRB(5.55f, 0.5f, 5.75f, 24.5f)); |
147 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); | 152 fRects.addToTail(SkRect::MakeLTRB(5.5f, .05f, 29.5f, .25f)); |
(...skipping 20 matching lines...) Expand all Loading... |
168 return; | 173 return; |
169 } | 174 } |
170 | 175 |
171 Color color(0xff000000); | 176 Color color(0xff000000); |
172 Coverage coverage(Coverage::kSolid_Type); | 177 Coverage coverage(Coverage::kSolid_Type); |
173 LocalCoords localCoords(LocalCoords::kUnused_Type); | 178 LocalCoords localCoords(LocalCoords::kUnused_Type); |
174 SkAutoTUnref<const GrGeometryProcessor> gp( | 179 SkAutoTUnref<const GrGeometryProcessor> gp( |
175 GrDefaultGeoProcFactory::Create(color, coverage, localCoords, Sk
Matrix::I())); | 180 GrDefaultGeoProcFactory::Create(color, coverage, localCoords, Sk
Matrix::I())); |
176 | 181 |
177 SkScalar y = 0; | 182 SkScalar y = 0; |
| 183 static const SkScalar kDX = 12.f; |
178 for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart); | 184 for (PathList::Iter iter(fPaths, PathList::Iter::kHead_IterStart); |
179 iter.get(); | 185 iter.get(); |
180 iter.next()) { | 186 iter.next()) { |
181 const SkPath* path = iter.get(); | 187 const SkPath* path = iter.get(); |
182 SkScalar x = 0; | 188 SkScalar x = 0; |
183 | 189 |
184 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { | 190 for (int et = 0; et < kGrProcessorEdgeTypeCnt; ++et) { |
185 const SkMatrix m = SkMatrix::MakeTrans(x, y); | 191 const SkMatrix m = SkMatrix::MakeTrans(x, y); |
186 SkPath p; | 192 SkPath p; |
187 path->transform(m, &p); | 193 path->transform(m, &p); |
(...skipping 12 matching lines...) Expand all Loading... |
200 | 206 |
201 ConvexPolyTestBatch::Geometry geometry; | 207 ConvexPolyTestBatch::Geometry geometry; |
202 geometry.fColor = color.fColor; | 208 geometry.fColor = color.fColor; |
203 geometry.fRect = p.getBounds(); | 209 geometry.fRect = p.getBounds(); |
204 geometry.fBounds = p.getBounds(); | 210 geometry.fBounds = p.getBounds(); |
205 | 211 |
206 SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp,
geometry)); | 212 SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp,
geometry)); |
207 | 213 |
208 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui
lder, batch); | 214 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui
lder, batch); |
209 | 215 |
210 x += SkScalarCeilToScalar(path->getBounds().width() + 10.f); | 216 x += SkScalarCeilToScalar(path->getBounds().width() + kDX); |
211 } | 217 } |
212 | 218 |
213 // Draw AA and non AA paths using normal API for reference. | 219 // Draw AA and non AA paths using normal API for reference. |
214 canvas->save(); | 220 canvas->save(); |
215 canvas->translate(x, y); | 221 canvas->translate(x, y); |
216 SkPaint paint; | 222 SkPaint paint; |
217 canvas->drawPath(*path, paint); | 223 canvas->drawPath(*path, paint); |
218 canvas->translate(path->getBounds().width() + 10.f, 0); | 224 canvas->translate(path->getBounds().width() + 10.f, 0); |
219 paint.setAntiAlias(true); | 225 paint.setAntiAlias(true); |
220 canvas->drawPath(*path, paint); | 226 canvas->drawPath(*path, paint); |
(...skipping 26 matching lines...) Expand all Loading... |
247 ConvexPolyTestBatch::Geometry geometry; | 253 ConvexPolyTestBatch::Geometry geometry; |
248 geometry.fColor = color.fColor; | 254 geometry.fColor = color.fColor; |
249 geometry.fRect = rect; | 255 geometry.fRect = rect; |
250 geometry.fBounds = rect; | 256 geometry.fBounds = rect; |
251 geometry.fBounds.sort(); | 257 geometry.fBounds.sort(); |
252 | 258 |
253 SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp,
geometry)); | 259 SkAutoTUnref<GrDrawBatch> batch(ConvexPolyTestBatch::Create(gp,
geometry)); |
254 | 260 |
255 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui
lder, batch); | 261 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui
lder, batch); |
256 | 262 |
257 x += SkScalarCeilToScalar(rect.width() + 10.f); | 263 x += SkScalarCeilToScalar(rect.width() + kDX); |
258 } | 264 } |
259 | 265 |
260 // Draw rect without and with AA using normal API for reference | 266 // Draw rect without and with AA using normal API for reference |
261 canvas->save(); | 267 canvas->save(); |
262 canvas->translate(x, y); | 268 canvas->translate(x, y); |
263 SkPaint paint; | 269 SkPaint paint; |
264 canvas->drawRect(*iter.get(), paint); | 270 canvas->drawRect(*iter.get(), paint); |
265 x += SkScalarCeilToScalar(iter.get()->width() + 10.f); | 271 x += SkScalarCeilToScalar(iter.get()->width() + kDX); |
266 paint.setAntiAlias(true); | 272 paint.setAntiAlias(true); |
267 canvas->drawRect(*iter.get(), paint); | 273 canvas->drawRect(*iter.get(), paint); |
268 canvas->restore(); | 274 canvas->restore(); |
269 | 275 |
270 y += SkScalarCeilToScalar(iter.get()->height() + 20.f); | 276 y += SkScalarCeilToScalar(iter.get()->height() + 20.f); |
271 } | 277 } |
272 } | 278 } |
273 | 279 |
274 private: | 280 private: |
275 typedef SkTLList<SkPath, 1> PathList; | 281 typedef SkTLList<SkPath, 1> PathList; |
276 typedef SkTLList<SkRect, 1> RectList; | 282 typedef SkTLList<SkRect, 1> RectList; |
277 PathList fPaths; | 283 PathList fPaths; |
278 RectList fRects; | 284 RectList fRects; |
279 | 285 |
280 typedef GM INHERITED; | 286 typedef GM INHERITED; |
281 }; | 287 }; |
282 | 288 |
283 DEF_GM(return new ConvexPolyEffect;) | 289 DEF_GM(return new ConvexPolyEffect;) |
284 } | 290 } |
285 | 291 |
286 #endif | 292 #endif |
OLD | NEW |