| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #ifdef DF_PATH_TRACKING | 78 #ifdef DF_PATH_TRACKING |
| 79 SkDebugf("Cached paths: %d, freed paths: %d\n", g_NumCachedPaths, g_NumFreed
Paths); | 79 SkDebugf("Cached paths: %d, freed paths: %d\n", g_NumCachedPaths, g_NumFreed
Paths); |
| 80 #endif | 80 #endif |
| 81 } | 81 } |
| 82 | 82 |
| 83 //////////////////////////////////////////////////////////////////////////////// | 83 //////////////////////////////////////////////////////////////////////////////// |
| 84 bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
onst { | 84 bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
onst { |
| 85 | 85 |
| 86 // TODO: Support inverse fill | 86 // TODO: Support inverse fill |
| 87 // TODO: Support strokes | 87 // TODO: Support strokes |
| 88 if (!args.fTarget->caps()->shaderCaps()->shaderDerivativeSupport() || !args.
fAntiAlias || | 88 if (!args.fShaderCaps->shaderDerivativeSupport() || !args.fAntiAlias || |
| 89 args.fPath->isInverseFillType() || args.fPath->isVolatile() || | 89 args.fPath->isInverseFillType() || args.fPath->isVolatile() || |
| 90 !args.fStroke->isFillStyle()) { | 90 !args.fStroke->isFillStyle()) { |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // currently don't support perspective | 94 // currently don't support perspective |
| 95 if (args.fViewMatrix->hasPerspective()) { | 95 if (args.fViewMatrix->hasPerspective()) { |
| 96 return false; | 96 return false; |
| 97 } | 97 } |
| 98 | 98 |
| 99 // only support paths smaller than 64x64, scaled to less than 256x256 | 99 // only support paths smaller than 64x64, scaled to less than 256x256 |
| 100 // the goal is to accelerate rendering of lots of small paths that may be sc
aling | 100 // the goal is to accelerate rendering of lots of small paths that may be sc
aling |
| 101 SkScalar maxScale = args.fViewMatrix->getMaxScale(); | 101 SkScalar maxScale = args.fViewMatrix->getMaxScale(); |
| 102 const SkRect& bounds = args.fPath->getBounds(); | 102 const SkRect& bounds = args.fPath->getBounds(); |
| 103 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); | 103 SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); |
| 104 return maxDim < 64.f && maxDim * maxScale < 256.f; | 104 return maxDim < 64.f && maxDim * maxScale < 256.f; |
| 105 } | 105 } |
| 106 | 106 |
| 107 GrPathRenderer::StencilSupport | |
| 108 GrAADistanceFieldPathRenderer::onGetStencilSupport(const GrDrawTarget*, | |
| 109 const GrPipelineBuilder*, | |
| 110 const SkPath&, | |
| 111 const GrStrokeInfo&) const { | |
| 112 return GrPathRenderer::kNoSupport_StencilSupport; | |
| 113 } | |
| 114 | |
| 115 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
| 116 | 108 |
| 117 // padding around path bounds to allow for antialiased pixels | 109 // padding around path bounds to allow for antialiased pixels |
| 118 static const SkScalar kAntiAliasPad = 1.0f; | 110 static const SkScalar kAntiAliasPad = 1.0f; |
| 119 | 111 |
| 120 class AADistanceFieldPathBatch : public GrBatch { | 112 class AADistanceFieldPathBatch : public GrBatch { |
| 121 public: | 113 public: |
| 122 typedef GrAADistanceFieldPathRenderer::PathData PathData; | 114 typedef GrAADistanceFieldPathRenderer::PathData PathData; |
| 123 typedef SkTDynamicHash<PathData, PathData::Key> PathCache; | 115 typedef SkTDynamicHash<PathData, PathData::Key> PathCache; |
| 124 typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList; | 116 typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList; |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 geometry.fPath = GrTest::TestPath(random); | 617 geometry.fPath = GrTest::TestPath(random); |
| 626 geometry.fAntiAlias = random->nextBool(); | 618 geometry.fAntiAlias = random->nextBool(); |
| 627 | 619 |
| 628 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, | 620 return AADistanceFieldPathBatch::Create(geometry, color, viewMatrix, |
| 629 gTestStruct.fAtlas, | 621 gTestStruct.fAtlas, |
| 630 &gTestStruct.fPathCache, | 622 &gTestStruct.fPathCache, |
| 631 &gTestStruct.fPathList); | 623 &gTestStruct.fPathList); |
| 632 } | 624 } |
| 633 | 625 |
| 634 #endif | 626 #endif |
| OLD | NEW |