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 #include "GrAADistanceFieldPathRenderer.h" | 9 #include "GrAADistanceFieldPathRenderer.h" |
10 | 10 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return maxDim < 64.f && maxDim * maxScale < 256.f; | 104 return maxDim < 64.f && maxDim * maxScale < 256.f; |
105 } | 105 } |
106 | 106 |
107 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
108 | 108 |
109 // padding around path bounds to allow for antialiased pixels | 109 // padding around path bounds to allow for antialiased pixels |
110 static const SkScalar kAntiAliasPad = 1.0f; | 110 static const SkScalar kAntiAliasPad = 1.0f; |
111 | 111 |
112 class AADistanceFieldPathBatch : public GrVertexBatch { | 112 class AADistanceFieldPathBatch : public GrVertexBatch { |
113 public: | 113 public: |
| 114 DEFINE_BATCH_CLASS_ID |
| 115 |
114 typedef GrAADistanceFieldPathRenderer::PathData PathData; | 116 typedef GrAADistanceFieldPathRenderer::PathData PathData; |
115 typedef SkTDynamicHash<PathData, PathData::Key> PathCache; | 117 typedef SkTDynamicHash<PathData, PathData::Key> PathCache; |
116 typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList; | 118 typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList; |
117 | 119 |
118 struct Geometry { | 120 struct Geometry { |
119 Geometry(const SkStrokeRec& stroke) : fStroke(stroke) {} | 121 Geometry(const SkStrokeRec& stroke) : fStroke(stroke) {} |
120 SkPath fPath; | 122 SkPath fPath; |
121 SkStrokeRec fStroke; | 123 SkStrokeRec fStroke; |
122 bool fAntiAlias; | 124 bool fAntiAlias; |
123 PathData* fPathData; | 125 PathData* fPathData; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 flushInfo.fInstancesToFlush++; | 271 flushInfo.fInstancesToFlush++; |
270 } | 272 } |
271 | 273 |
272 this->flush(target, &flushInfo); | 274 this->flush(target, &flushInfo); |
273 } | 275 } |
274 | 276 |
275 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } | 277 SkSTArray<1, Geometry, true>* geoData() { return &fGeoData; } |
276 | 278 |
277 AADistanceFieldPathBatch(const Geometry& geometry, GrColor color, const SkMa
trix& viewMatrix, | 279 AADistanceFieldPathBatch(const Geometry& geometry, GrColor color, const SkMa
trix& viewMatrix, |
278 GrBatchAtlas* atlas, | 280 GrBatchAtlas* atlas, |
279 PathCache* pathCache, PathDataList* pathList) { | 281 PathCache* pathCache, PathDataList* pathList) |
280 this->initClassID<AADistanceFieldPathBatch>(); | 282 : INHERITED(ClassID()) { |
281 fBatch.fColor = color; | 283 fBatch.fColor = color; |
282 fBatch.fViewMatrix = viewMatrix; | 284 fBatch.fViewMatrix = viewMatrix; |
283 fGeoData.push_back(geometry); | 285 fGeoData.push_back(geometry); |
284 fGeoData.back().fPathData = nullptr; | 286 fGeoData.back().fPathData = nullptr; |
285 | 287 |
286 fAtlas = atlas; | 288 fAtlas = atlas; |
287 fPathCache = pathCache; | 289 fPathCache = pathCache; |
288 fPathList = pathList; | 290 fPathList = pathList; |
289 | 291 |
290 // Compute bounds | 292 // Compute bounds |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 bool fUsesLocalCoords; | 514 bool fUsesLocalCoords; |
513 bool fColorIgnored; | 515 bool fColorIgnored; |
514 bool fCoverageIgnored; | 516 bool fCoverageIgnored; |
515 }; | 517 }; |
516 | 518 |
517 BatchTracker fBatch; | 519 BatchTracker fBatch; |
518 SkSTArray<1, Geometry, true> fGeoData; | 520 SkSTArray<1, Geometry, true> fGeoData; |
519 GrBatchAtlas* fAtlas; | 521 GrBatchAtlas* fAtlas; |
520 PathCache* fPathCache; | 522 PathCache* fPathCache; |
521 PathDataList* fPathList; | 523 PathDataList* fPathList; |
| 524 |
| 525 typedef GrVertexBatch INHERITED; |
522 }; | 526 }; |
523 | 527 |
524 bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { | 528 bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) { |
525 // we've already bailed on inverse filled paths, so this is safe | 529 // we've already bailed on inverse filled paths, so this is safe |
526 if (args.fPath->isEmpty()) { | 530 if (args.fPath->isEmpty()) { |
527 return true; | 531 return true; |
528 } | 532 } |
529 | 533 |
530 if (!fAtlas) { | 534 if (!fAtlas) { |
531 fAtlas = args.fResourceProvider->createAtlas(kAlpha_8_GrPixelConfig, | 535 fAtlas = args.fResourceProvider->createAtlas(kAlpha_8_GrPixelConfig, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 geometry.fPath = GrTest::TestPath(random); | 621 geometry.fPath = GrTest::TestPath(random); |
618 geometry.fAntiAlias = random->nextBool(); | 622 geometry.fAntiAlias = random->nextBool(); |
619 | 623 |
620 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, | 624 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, |
621 gTestStruct.fAtlas, | 625 gTestStruct.fAtlas, |
622 &gTestStruct.fPathCache, | 626 &gTestStruct.fPathCache, |
623 &gTestStruct.fPathList); | 627 &gTestStruct.fPathList); |
624 } | 628 } |
625 | 629 |
626 #endif | 630 #endif |
OLD | NEW |