OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #include "GrAADistanceFieldPathRenderer.h" | 8 #include "GrAADistanceFieldPathRenderer.h" |
10 | 9 |
11 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 args.fPath->isInverseFillType() || args.fPath->isVolatile() || | 88 args.fPath->isInverseFillType() || args.fPath->isVolatile() || |
90 // We don't currently apply the dash or factor it into the DF key. (skbu
g.com/5082) | 89 // We don't currently apply the dash or factor it into the DF key. (skbu
g.com/5082) |
91 args.fStroke->isDashed()) { | 90 args.fStroke->isDashed()) { |
92 return false; | 91 return false; |
93 } | 92 } |
94 | 93 |
95 // currently don't support perspective | 94 // currently don't support perspective |
96 if (args.fViewMatrix->hasPerspective()) { | 95 if (args.fViewMatrix->hasPerspective()) { |
97 return false; | 96 return false; |
98 } | 97 } |
99 | 98 |
100 // only support paths with bounds within kMediumMIP by kMediumMIP, | 99 // only support paths with bounds within kMediumMIP by kMediumMIP, |
101 // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP | 100 // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP |
102 // the goal is to accelerate rendering of lots of small paths that may be sc
aling | 101 // the goal is to accelerate rendering of lots of small paths that may be sc
aling |
103 SkScalar maxScale = args.fViewMatrix->getMaxScale(); | 102 SkScalar maxScale = args.fViewMatrix->getMaxScale(); |
104 const SkRect& bounds = args.fPath->getBounds(); | 103 const SkRect& bounds = args.fPath->getBounds(); |
105 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); | 104 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); |
106 // Approximate stroked size by adding the maximum of the stroke width or 2x
the miter limit | 105 // Approximate stroked size by adding the maximum of the stroke width or 2x
the miter limit |
107 if (!args.fStroke->isFillStyle()) { | 106 if (!args.fStroke->isFillStyle()) { |
108 SkScalar extraWidth = args.fStroke->getWidth(); | 107 SkScalar extraWidth = args.fStroke->getWidth(); |
109 if (SkPaint::kMiter_Join == args.fStroke->getJoin()) { | 108 if (SkPaint::kMiter_Join == args.fStroke->getJoin()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 bool fAntiAlias; | 147 bool fAntiAlias; |
149 }; | 148 }; |
150 | 149 |
151 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat
rix, | 150 static GrDrawBatch* Create(const Geometry& geometry, const SkMatrix& viewMat
rix, |
152 GrBatchAtlas* atlas, PathCache* pathCache, PathDa
taList* pathList) { | 151 GrBatchAtlas* atlas, PathCache* pathCache, PathDa
taList* pathList) { |
153 return new AADistanceFieldPathBatch(geometry, viewMatrix, atlas, pathCac
he, pathList); | 152 return new AADistanceFieldPathBatch(geometry, viewMatrix, atlas, pathCac
he, pathList); |
154 } | 153 } |
155 | 154 |
156 const char* name() const override { return "AADistanceFieldPathBatch"; } | 155 const char* name() const override { return "AADistanceFieldPathBatch"; } |
157 | 156 |
158 void computePipelineOptimizations(GrInitInvariantOutput* color, | 157 void computePipelineOptimizations(GrInitInvariantOutput* color, |
159 GrInitInvariantOutput* coverage, | 158 GrInitInvariantOutput* coverage, |
160 GrBatchToXPOverrides* overrides) const ove
rride { | 159 GrBatchToXPOverrides* overrides) const ove
rride { |
161 color->setKnownFourComponents(fGeoData[0].fColor); | 160 color->setKnownFourComponents(fGeoData[0].fColor); |
162 coverage->setUnknownSingleComponent(); | 161 coverage->setUnknownSingleComponent(); |
163 } | 162 } |
164 | 163 |
165 private: | 164 private: |
166 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { | 165 void initBatchTracker(const GrXPOverridesForBatch& overrides) override { |
167 // Handle any color overrides | 166 // Handle any color overrides |
168 if (!overrides.readsColor()) { | 167 if (!overrides.readsColor()) { |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 geometry.fPath = *args.fPath; | 562 geometry.fPath = *args.fPath; |
564 } else { | 563 } else { |
565 args.fStroke->applyToPath(&geometry.fPath, *args.fPath); | 564 args.fStroke->applyToPath(&geometry.fPath, *args.fPath); |
566 } | 565 } |
567 geometry.fColor = args.fColor; | 566 geometry.fColor = args.fColor; |
568 geometry.fAntiAlias = args.fAntiAlias; | 567 geometry.fAntiAlias = args.fAntiAlias; |
569 // Note: this is the generation ID of the _original_ path. When a new path i
s | 568 // Note: this is the generation ID of the _original_ path. When a new path i
s |
570 // generated due to stroking it is important that the original path's id is
used | 569 // generated due to stroking it is important that the original path's id is
used |
571 // for caching. | 570 // for caching. |
572 geometry.fGenID = args.fPath->getGenerationID(); | 571 geometry.fGenID = args.fPath->getGenerationID(); |
573 | 572 |
574 SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry, | 573 SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry, |
575 *args.fView
Matrix, fAtlas, | 574 *args.fView
Matrix, fAtlas, |
576 &fPathCache
, &fPathList)); | 575 &fPathCache
, &fPathList)); |
577 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); | 576 args.fTarget->drawBatch(*args.fPipelineBuilder, batch); |
578 | 577 |
579 return true; | 578 return true; |
580 } | 579 } |
581 | 580 |
582 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 581 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
583 | 582 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 geometry.fAntiAlias = random->nextBool(); | 647 geometry.fAntiAlias = random->nextBool(); |
649 geometry.fGenID = random->nextU(); | 648 geometry.fGenID = random->nextU(); |
650 | 649 |
651 return AADistanceFieldPathBatch::Create(geometry, viewMatrix, | 650 return AADistanceFieldPathBatch::Create(geometry, viewMatrix, |
652 gTestStruct.fAtlas, | 651 gTestStruct.fAtlas, |
653 &gTestStruct.fPathCache, | 652 &gTestStruct.fPathCache, |
654 &gTestStruct.fPathList); | 653 &gTestStruct.fPathList); |
655 } | 654 } |
656 | 655 |
657 #endif | 656 #endif |
OLD | NEW |