Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp

Issue 1757913002: Revert of Generate Signed Distance Field directly from vector path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDistanceFieldGenFromVector.cpp ('k') | src/gpu/text/GrFontScaler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index 30d94dc4f790527e0518db09c1796315b362b86c..8525eb2fdef513928831a3cdbfa31985e6860eb7 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -1,7 +1,6 @@
/*
* Copyright 2014 Google Inc.
- * Copyright 2016 ARM Ltd.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
@@ -22,7 +21,6 @@
#include "effects/GrDistanceFieldGeoProc.h"
#include "SkDistanceFieldGen.h"
-#include "GrDistanceFieldGenFromVector.h"
#include "SkRTConf.h"
#define ATLAS_TEXTURE_WIDTH 2048
@@ -96,7 +94,7 @@
if (args.fViewMatrix->hasPerspective()) {
return false;
}
-
+
// 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
@@ -111,7 +109,7 @@
}
maxDim += extraWidth;
}
-
+
return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP;
}
@@ -155,7 +153,7 @@
const char* name() const override { return "AADistanceFieldPathBatch"; }
- void computePipelineOptimizations(GrInitInvariantOutput* color,
+ void computePipelineOptimizations(GrInitInvariantOutput* color,
GrInitInvariantOutput* coverage,
GrBatchToXPOverrides* overrides) const override {
color->setKnownFourComponents(fGeoData[0].fColor);
@@ -359,20 +357,44 @@
drawMatrix.postScale(scale, scale);
drawMatrix.postTranslate(kAntiAliasPad, kAntiAliasPad);
+ // setup bitmap backing
SkASSERT(devPathBounds.fLeft == 0);
SkASSERT(devPathBounds.fTop == 0);
-
- // setup signed distance field storage
- SkIRect sdfPathBounds = devPathBounds.makeOutset(SK_DistanceFieldPad, SK_DistanceFieldPad);
- width = sdfPathBounds.width();
- height = sdfPathBounds.height();
+ SkAutoPixmapStorage dst;
+ if (!dst.tryAlloc(SkImageInfo::MakeA8(devPathBounds.width(),
+ devPathBounds.height()))) {
+ return false;
+ }
+ sk_bzero(dst.writable_addr(), dst.getSafeSize());
+
+ // rasterize path
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setAntiAlias(antiAlias);
+
+ SkDraw draw;
+ sk_bzero(&draw, sizeof(draw));
+
+ SkRasterClip rasterClip;
+ rasterClip.setRect(devPathBounds);
+ draw.fRC = &rasterClip;
+ draw.fClip = &rasterClip.bwRgn();
+ draw.fMatrix = &drawMatrix;
+ draw.fDst = dst;
+
+ draw.drawPathCoverage(path, paint);
+
+ // generate signed distance field
+ devPathBounds.outset(SK_DistanceFieldPad, SK_DistanceFieldPad);
+ width = devPathBounds.width();
+ height = devPathBounds.height();
// TODO We should really generate this directly into the plot somehow
SkAutoSMalloc<1024> dfStorage(width * height * sizeof(unsigned char));
- // Generate signed distance field directly from SkPath
- GrGenerateDistanceFieldFromPath((unsigned char*)dfStorage.get(),
- path, drawMatrix,
- width, height, width * sizeof(unsigned char));
+ // Generate signed distance field
+ SkGenerateDistanceFieldFromA8Image((unsigned char*)dfStorage.get(),
+ (const unsigned char*)dst.addr(),
+ dst.width(), dst.height(), dst.rowBytes());
// add to atlas
SkIPoint16 atlasLocation;
@@ -543,7 +565,7 @@
// generated due to stroking it is important that the original path's id is used
// for caching.
geometry.fGenID = args.fPath->getGenerationID();
-
+
SkAutoTUnref<GrDrawBatch> batch(AADistanceFieldPathBatch::Create(geometry,
*args.fViewMatrix, fAtlas,
&fPathCache, &fPathList));
« no previous file with comments | « src/gpu/GrDistanceFieldGenFromVector.cpp ('k') | src/gpu/text/GrFontScaler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698