diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-01-11 18:35:02 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-11 18:35:17 +0000 |
commit | 000ca636e6de2e2b8bf9c82e3dee2d7ad8e1bed8 (patch) | |
tree | 16948dc5a8d38b41f6c2c85ee153289d8463c3e8 /src/gpu/ops/GrAADistanceFieldPathRenderer.cpp | |
parent | 1252ec4bdaaa2bf0d1d3b2df8df735eb879427c2 (diff) |
Revert "More fixes for distance field paths"
This reverts commit d081ff314f07104adacaadc3d0f8f13dc741f016.
Reason for revert: Failing unit tests.
Original change's description:
> More fixes for distance field paths
>
> Disables use of SDFs for very small paths (because of blurring) and
> adds a border of 1 pixel in device space to handle antialiasing.
>
> BUG=chromium:677889
>
> Change-Id: I81e49477c943d41523fd836e55abd696a985491f
> Reviewed-on: https://skia-review.googlesource.com/6832
> Commit-Queue: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
>
TBR=jvanverth@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org
BUG=chromium:677889
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I4a6a698fa2e9e58c1c98a5a89f54bed724527951
Reviewed-on: https://skia-review.googlesource.com/6890
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/gpu/ops/GrAADistanceFieldPathRenderer.cpp')
-rw-r--r-- | src/gpu/ops/GrAADistanceFieldPathRenderer.cpp | 71 |
1 files changed, 29 insertions, 42 deletions
diff --git a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp index 455d76eb46..c9b30f5154 100644 --- a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp +++ b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp @@ -38,7 +38,6 @@ static int g_NumFreedShapes = 0; #endif // mip levels -static const int kMinSize = 16; static const int kSmallMIP = 32; static const int kMediumMIP = 73; static const int kLargeMIP = 162; @@ -107,17 +106,14 @@ bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c return false; } - // Only support paths with bounds within kMediumMIP by kMediumMIP, - // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP. - // For clarity, the original or scaled path should be at least kMinSize by kMinSize. - // TODO: revisit this last criteria with Joel's patch. - // The goal is to accelerate rendering of lots of small paths that may be scaling. + // only support paths with bounds within kMediumMIP by kMediumMIP, + // scaled to have bounds within 2.0f*kLargeMIP by 2.0f*kLargeMIP + // the goal is to accelerate rendering of lots of small paths that may be scaling SkScalar maxScale = args.fViewMatrix->getMaxScale(); SkRect bounds = args.fShape->styledBounds(); SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height()); - return maxDim >= kMinSize && maxDim <= kMediumMIP && - maxDim * maxScale >= kMinSize && maxDim * maxScale <= 2.0f*kLargeMIP; + return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP; } //////////////////////////////////////////////////////////////////////////////// @@ -402,12 +398,29 @@ private: // set the bounds rect to the original bounds shapeData->fBounds = bounds; - // set up path to texture coordinate transform - shapeData->fScale = scale; + // set up texture coordinates + SkScalar texLeft = bounds.fLeft; + SkScalar texTop = bounds.fTop; + SkScalar texRight = bounds.fRight; + SkScalar texBottom = bounds.fBottom; + + // transform original path's bounds to texture space + texLeft *= scale; + texTop *= scale; + texRight *= scale; + texBottom *= scale; dx -= SK_DistanceFieldPad + kAntiAliasPad; dy -= SK_DistanceFieldPad + kAntiAliasPad; - shapeData->fTranslate.fX = atlasLocation.fX - dx; - shapeData->fTranslate.fY = atlasLocation.fY - dy; + texLeft += atlasLocation.fX - dx; + texTop += atlasLocation.fY - dy; + texRight += atlasLocation.fX - dx; + texBottom += atlasLocation.fY - dy; + + GrTexture* texture = atlas->getTexture(); + shapeData->fTexCoords.setLTRB(texLeft / texture->width(), + texTop / texture->height(), + texRight / texture->width(), + texBottom / texture->height()); fShapeCache->add(shapeData); fShapeList->addToTail(shapeData); @@ -426,15 +439,10 @@ private: const ShapeData* shapeData) const { SkPoint* positions = reinterpret_cast<SkPoint*>(offset); - // outset bounds to include ~1 pixel of AA in device space - SkRect bounds = shapeData->fBounds; - SkScalar outset = SkScalarInvert(maxScale); - bounds.outset(outset, outset); - // vertex positions // TODO make the vertex attributes a struct - positions->setRectFan(bounds.left(), bounds.top(), bounds.right(), bounds.bottom(), - vertexStride); + positions->setRectFan(shapeData->fBounds.left(), shapeData->fBounds.top(), + shapeData->fBounds.right(), shapeData->fBounds.bottom(), vertexStride); // colors for (int i = 0; i < kVerticesPerQuad; i++) { @@ -442,32 +450,11 @@ private: *colorPtr = color; } - // set up texture coordinates - SkScalar texLeft = bounds.fLeft; - SkScalar texTop = bounds.fTop; - SkScalar texRight = bounds.fRight; - SkScalar texBottom = bounds.fBottom; - - // transform original path's bounds to texture space - SkScalar scale = shapeData->fScale; - const SkVector& translate = shapeData->fTranslate; - texLeft *= scale; - texTop *= scale; - texRight *= scale; - texBottom *= scale; - texLeft += translate.fX; - texTop += translate.fY; - texRight += translate.fX; - texBottom += translate.fY; - // vertex texture coords // TODO make these int16_t SkPoint* textureCoords = (SkPoint*)(offset + sizeof(SkPoint) + sizeof(GrColor)); - GrTexture* texture = atlas->getTexture(); - textureCoords->setRectFan(texLeft / texture->width(), - texTop / texture->height(), - texRight / texture->width(), - texBottom / texture->height(), + textureCoords->setRectFan(shapeData->fTexCoords.left(), shapeData->fTexCoords.top(), + shapeData->fTexCoords.right(), shapeData->fTexCoords.bottom(), vertexStride); } |