aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2015-11-22 08:45:13 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-22 08:45:13 -0800
commit08c4bdf305b75815cff209edcaa12b9e26690186 (patch)
treefc812500633f6f3b801800a3434ba0b31ba29c22 /src
parentc64eff55049b1192052b791549a32a03be1c43e3 (diff)
Revert of Add stroking support to distance field path renderer (patchset #8 id:160001 of https://codereview.chromium.org/1460873002/ )
Reason for revert: Valgrind failures: http://build.chromium.org/p/client.skia/builders/Test-Ubuntu-GCC-ShuttleA-GPU-GTX550Ti-x86_64-Release-Valgrind/builds/420/steps/dm/logs/stdio ==7062== Use of uninitialised value of size 8 ==7062== at 0x8ECA9A: AADistanceFieldPathBatch::onPrepareDraws(GrVertexBatch::Target*) (SkTDynamicHash.h:94) ==7062== by 0x90DCF5: GrVertexBatch::onPrepare(GrBatchFlushState*) (GrVertexBatch.cpp:16) ==7062== by 0x8B592A: GrDrawTarget::prepareBatches(GrBatchFlushState*) (GrBatch.h:100) ==7062== by 0x8B51EA: GrDrawingManager::flush() (GrDrawingManager.cpp:78) ==7062== by 0x8AE568: GrContext::flush(int) (GrContext.cpp:191) ==7062== by 0x6C118A: GrContext::getTestTarget(GrTestTarget*, GrRenderTarget*) (GrTest.cpp:56) ==7062== by 0x4F4D82: GrDrawingManager::ProgramUnitTest(GrContext*, int) (GLProgramsTest.cpp:360) ==7062== by 0x4F58EC: test_GLPrograms(skiatest::Reporter*, GrContextFactory*) (GLProgramsTest.cpp:450) ==7062== by 0x40925E: run_test(skiatest::Test*) (DM.cpp:1022) ==7062== by 0x40BAC2: run_enclave_and_gpu_tests(SkTArray<Task, false>*) (DM.cpp:1033) ==7062== by 0x7621A9: SkTaskGroup::wait() (SkTaskGroup.cpp:88) ==7062== by 0x40B756: dm_main() (DM.cpp:1124) ==7062== by 0x40BA5F: main (DM.cpp:1211) ==7062== Uninitialised value was created by a stack allocation ==7062== at 0x8DB484: GrTest::TestStrokeRec(SkRandom*) (GrTestUtils.cpp:232) ==7062== { <insert_a_suppression_name_here> Memcheck:Value8 fun:_ZN24AADistanceFieldPathBatch14onPrepareDrawsEPN13GrVertexBatch6TargetE fun:_ZN13GrVertexBatch9onPrepareEP17GrBatchFlushState fun:_ZN12GrDrawTarget14prepareBatchesEP17GrBatchFlushState fun:_ZN16GrDrawingManager5flushEv fun:_ZN9GrContext5flushEi fun:_ZN9GrContext13getTestTargetEP12GrTestTargetP14GrRenderTarget fun:_ZN16GrDrawingManager15ProgramUnitTestEP9GrContexti fun:_ZL15test_GLProgramsPN8skiatest8ReporterEP16GrContextFactory fun:_ZL8run_testPN8skiatest4TestE fun:_ZL25run_enclave_and_gpu_testsP8SkTArrayI4TaskLb0EE fun:_ZN11SkTaskGroup4waitEv fun:_Z7dm_mainv fun:main } Original issue's description: > Add stroking support to distance field path renderer > > Also slightly increases sizes of paths accepted for distance field > caching. > > Committed: https://skia.googlesource.com/skia/+/5ce76efd1c847308c7bcac17bd87d567c42cd786 > > Committed: https://skia.googlesource.com/skia/+/73ee6770260dbeeabc4a78eee4f13533f0031211 TBR=robertphillips@google.com,jvanverth@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1465053002
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrPathRenderer.h1
-rw-r--r--src/gpu/batches/GrAADistanceFieldPathRenderer.cpp87
-rwxr-xr-xsrc/gpu/batches/GrAADistanceFieldPathRenderer.h23
3 files changed, 41 insertions, 70 deletions
diff --git a/src/gpu/GrPathRenderer.h b/src/gpu/GrPathRenderer.h
index 7ada6d10f7..25a2a68abb 100644
--- a/src/gpu/GrPathRenderer.h
+++ b/src/gpu/GrPathRenderer.h
@@ -115,7 +115,6 @@ public:
* fTarget The target that the path will be rendered to
* fResourceProvider The resource provider for creating gpu resources to render the path
* fPipelineBuilder The pipelineBuilder
- * fColor Color to render with
* fViewMatrix The viewMatrix
* fPath the path to draw.
* fStroke the stroke information (width, join, cap)
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
index 4eff0c4079..ee5fdb8a80 100644
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.cpp
@@ -38,7 +38,7 @@ static int g_NumFreedPaths = 0;
// mip levels
static const int kSmallMIP = 32;
-static const int kMediumMIP = 73;
+static const int kMediumMIP = 72;
static const int kLargeMIP = 162;
// Callback to clear out internal path cache when eviction occurs
@@ -84,9 +84,10 @@ GrAADistanceFieldPathRenderer::~GrAADistanceFieldPathRenderer() {
bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
// TODO: Support inverse fill
+ // TODO: Support strokes
if (!args.fShaderCaps->shaderDerivativeSupport() || !args.fAntiAlias ||
- SkStrokeRec::kHairline_Style == args.fStroke->getStyle() ||
- args.fPath->isInverseFillType() || args.fPath->isVolatile()) {
+ args.fPath->isInverseFillType() || args.fPath->isVolatile() ||
+ !args.fStroke->isFillStyle()) {
return false;
}
@@ -95,22 +96,12 @@ 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
+ // only support paths smaller than 64x64, scaled to less than 256x256
// the goal is to accelerate rendering of lots of small paths that may be scaling
SkScalar maxScale = args.fViewMatrix->getMaxScale();
const SkRect& bounds = args.fPath->getBounds();
SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
- // Approximate stroked size by adding the maximum of the stroke width or 2x the miter limit
- if (!args.fStroke->isFillStyle()) {
- SkScalar extraWidth = args.fStroke->getWidth();
- if (SkPaint::kMiter_Join == args.fStroke->getJoin()) {
- extraWidth = SkTMax(extraWidth, 2.0f*args.fStroke->getMiter());
- }
- maxDim += extraWidth;
- }
-
- return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP;
+ return maxDim < 64.f && maxDim * maxScale < 256.f;
}
////////////////////////////////////////////////////////////////////////////////
@@ -127,20 +118,8 @@ public:
typedef GrAADistanceFieldPathRenderer::PathDataList PathDataList;
struct Geometry {
- Geometry(const SkStrokeRec& stroke) : fStroke(stroke) {
- if (!stroke.needToApply()) {
- // purify unused values to ensure binary equality
- fStroke.setStrokeParams(SkPaint::kDefault_Cap, SkPaint::kDefault_Join,
- SkIntToScalar(4));
- if (fStroke.getWidth() < 0) {
- fStroke.setStrokeStyle(-1.0f);
- }
- }
- }
+ Geometry(const SkStrokeRec& stroke) : fStroke(stroke) {}
SkPath fPath;
- // The unique ID of the path involved in this draw. This may be different than the ID
- // in fPath since that path may have resulted from a SkStrokeRec::applyToPath call.
- uint32_t fGenID;
SkStrokeRec fStroke;
bool fAntiAlias;
PathData* fPathData;
@@ -246,7 +225,8 @@ private:
}
// check to see if path is cached
- PathData::Key key(args.fGenID, desiredDimension, args.fStroke);
+ // TODO: handle stroked vs. filled version of same path
+ PathData::Key key = { args.fPath.getGenerationID(), desiredDimension };
args.fPathData = fPathCache->find(key);
if (nullptr == args.fPathData || !atlas->hasID(args.fPathData->fID)) {
// Remove the stale cache entry
@@ -264,7 +244,6 @@ private:
atlas,
args.fPathData,
args.fPath,
- args.fGenID,
args.fStroke,
args.fAntiAlias,
desiredDimension,
@@ -322,9 +301,8 @@ private:
GrBatchAtlas* atlas,
PathData* pathData,
const SkPath& path,
- uint32_t genID,
- const SkStrokeRec& stroke,
- bool antiAlias,
+ const SkStrokeRec&
+ stroke, bool antiAlias,
uint32_t dimension,
SkScalar scale) {
const SkRect& bounds = path.getBounds();
@@ -355,25 +333,41 @@ private:
drawMatrix.postTranslate(kAntiAliasPad, kAntiAliasPad);
// setup bitmap backing
- SkASSERT(devPathBounds.fLeft == 0);
- SkASSERT(devPathBounds.fTop == 0);
+ // Now translate so the bound's UL corner is at the origin
+ drawMatrix.postTranslate(-devPathBounds.fLeft * SK_Scalar1,
+ -devPathBounds.fTop * SK_Scalar1);
+ SkIRect pathBounds = SkIRect::MakeWH(devPathBounds.width(),
+ devPathBounds.height());
+
SkAutoPixmapStorage dst;
- if (!dst.tryAlloc(SkImageInfo::MakeA8(devPathBounds.width(),
- devPathBounds.height()))) {
+ if (!dst.tryAlloc(SkImageInfo::MakeA8(pathBounds.width(),
+ pathBounds.height()))) {
return false;
}
sk_bzero(dst.writable_addr(), dst.getSafeSize());
// rasterize path
SkPaint paint;
- paint.setStyle(SkPaint::kFill_Style);
+ if (stroke.isHairlineStyle()) {
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(SK_Scalar1);
+ } else {
+ if (stroke.isFillStyle()) {
+ paint.setStyle(SkPaint::kFill_Style);
+ } else {
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeJoin(stroke.getJoin());
+ paint.setStrokeCap(stroke.getCap());
+ paint.setStrokeWidth(stroke.getWidth());
+ }
+ }
paint.setAntiAlias(antiAlias);
SkDraw draw;
sk_bzero(&draw, sizeof(draw));
SkRasterClip rasterClip;
- rasterClip.setRect(devPathBounds);
+ rasterClip.setRect(pathBounds);
draw.fRC = &rasterClip;
draw.fClip = &rasterClip.bwRgn();
draw.fMatrix = &drawMatrix;
@@ -409,7 +403,8 @@ private:
}
// add to cache
- pathData->fKey = PathData::Key(genID, dimension, stroke);
+ pathData->fKey.fGenID = path.getGenerationID();
+ pathData->fKey.fDimension = dimension;
pathData->fScale = scale;
pathData->fID = id;
// change the scaled rect to match the size of the inset distance field
@@ -548,17 +543,9 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
}
AADistanceFieldPathBatch::Geometry geometry(*args.fStroke);
- if (SkStrokeRec::kFill_Style == args.fStroke->getStyle()) {
- geometry.fPath = *args.fPath;
- } else {
- args.fStroke->applyToPath(&geometry.fPath, *args.fPath);
- }
+ geometry.fPath = *args.fPath;
geometry.fAntiAlias = args.fAntiAlias;
- // Note: this is the generation ID of the _original_ path. When a new path is
- // 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.fColor,
*args.fViewMatrix, fAtlas,
&fPathCache, &fPathList));
diff --git a/src/gpu/batches/GrAADistanceFieldPathRenderer.h b/src/gpu/batches/GrAADistanceFieldPathRenderer.h
index 1210cee331..469aeeb981 100755
--- a/src/gpu/batches/GrAADistanceFieldPathRenderer.h
+++ b/src/gpu/batches/GrAADistanceFieldPathRenderer.h
@@ -33,28 +33,13 @@ private:
bool onDrawPath(const DrawPathArgs&) override;
struct PathData {
- class Key {
- public:
- // default ctor needed for new of uninitialized PathData
- // since fStroke has no default ctor
- Key() : fStroke(SkStrokeRec::kFill_InitStyle) {}
- Key(uint32_t genID, uint32_t dim, const SkStrokeRec& stroke)
- : fGenID(genID)
- , fDimension(dim)
- , fStroke(stroke) {
- }
-
- bool operator==(const Key& other) const {
- return other.fGenID == fGenID && other.fDimension == fDimension &&
- fStroke.hasEqualEffect(other.fStroke);
- }
-
- private:
+ struct Key {
uint32_t fGenID;
// rendered size for stored path (32x32 max, 64x64 max, 128x128 max)
uint32_t fDimension;
- // stroking information
- SkStrokeRec fStroke;
+ bool operator==(const Key& other) const {
+ return other.fGenID == fGenID && other.fDimension == fDimension;
+ }
};
Key fKey;
SkScalar fScale;