aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/convexpaths.cpp44
-rw-r--r--gm/pathfill.cpp55
-rw-r--r--src/core/SkMathPriv.h24
-rw-r--r--src/gpu/ops/GrAADistanceFieldPathRenderer.cpp52
4 files changed, 45 insertions, 130 deletions
diff --git a/gm/convexpaths.cpp b/gm/convexpaths.cpp
index 766a6cee18..50939f9183 100644
--- a/gm/convexpaths.cpp
+++ b/gm/convexpaths.cpp
@@ -260,29 +260,29 @@ protected:
virtual void onDraw(SkCanvas* canvas) {
this->makePaths();
- SkPaint paint;
- paint.setAntiAlias(true);
- SkRandom rand;
- canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
-
- // As we've added more paths this has gotten pretty big. Scale the whole thing down.
- canvas->scale(2 * SK_Scalar1 / 3, 2 * SK_Scalar1 / 3);
-
- for (int i = 0; i < fPaths.count(); ++i) {
- canvas->save();
- // position the path, and make it at off-integer coords.
- canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 10,
- SK_Scalar1 * 200 * (i / 5) + 9 * SK_Scalar1 / 10);
- SkColor color = rand.nextU();
- color |= 0xff000000;
- paint.setColor(color);
-#if 0 // This hitting on 32bit Linux builds for some paths. Temporarily disabling while it is
- // debugged.
- SkASSERT(fPaths[i].isConvex());
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkRandom rand;
+ canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1);
+
+ // As we've added more paths this has gotten pretty big. Scale the whole thing down.
+ canvas->scale(2 * SK_Scalar1 / 3, 2 * SK_Scalar1 / 3);
+
+ for (int i = 0; i < fPaths.count(); ++i) {
+ canvas->save();
+ // position the path, and make it at off-integer coords.
+ canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 10,
+ SK_Scalar1 * 200 * (i / 5) + 9 * SK_Scalar1 / 10);
+ SkColor color = rand.nextU();
+ color |= 0xff000000;
+ paint.setColor(color);
+#if 0 // This hitting on 32bit Linux builds for some paths. Temporarily disabling while it is
+ // debugged.
+ SkASSERT(fPaths[i].isConvex());
#endif
- canvas->drawPath(fPaths[i], paint);
- canvas->restore();
- }
+ canvas->drawPath(fPaths[i], paint);
+ canvas->restore();
+ }
}
private:
diff --git a/gm/pathfill.cpp b/gm/pathfill.cpp
index 66a31b5b70..2562e7c9a5 100644
--- a/gm/pathfill.cpp
+++ b/gm/pathfill.cpp
@@ -140,7 +140,7 @@ static SkScalar make_line(SkPath* path) {
return SkIntToScalar(40);
}
-static void make_info(SkPath* path) {
+static SkScalar make_info(SkPath* path) {
path->moveTo(24, 4);
path->cubicTo(12.94999980926514f,
4,
@@ -179,49 +179,8 @@ static void make_info(SkPath* path) {
path->lineTo(26, 14);
path->lineTo(26, 18);
path->close();
-}
-static void make_accessibility(SkPath* path) {
- path->moveTo(12, 2);
- path->cubicTo(13.10000038146973f,
- 2,
- 14,
- 2.900000095367432f,
- 14,
- 4);
- path->cubicTo(14,
- 5.099999904632568f,
- 13.10000038146973f,
- 6,
- 12,
- 6);
- path->cubicTo(10.89999961853027f,
- 6,
- 10,
- 5.099999904632568f,
- 10,
- 4);
- path->cubicTo(10,
- 2.900000095367432f,
- 10.89999961853027f,
- 2,
- 12,
- 2);
- path->close();
- path->moveTo(21, 9);
- path->lineTo(15, 9);
- path->lineTo(15, 22);
- path->lineTo(13, 22);
- path->lineTo(13, 16);
- path->lineTo(11, 16);
- path->lineTo(11, 22);
- path->lineTo(9, 22);
- path->lineTo(9, 9);
- path->lineTo(3, 9);
- path->lineTo(3, 7);
- path->lineTo(21, 7);
- path->lineTo(21, 9);
- path->close();
+ return SkIntToScalar(44);
}
constexpr MakePathProc gProcs[] = {
@@ -243,15 +202,13 @@ class PathFillGM : public skiagm::GM {
SkPath fPath[N];
SkScalar fDY[N];
SkPath fInfoPath;
- SkPath fAccessibilityPath;
protected:
void onOnceBeforeDraw() override {
for (size_t i = 0; i < N; i++) {
fDY[i] = gProcs[i](&fPath[i]);
}
- make_info(&fInfoPath);
- make_accessibility(&fAccessibilityPath);
+ (void) make_info(&fInfoPath);
}
@@ -272,15 +229,9 @@ protected:
canvas->translate(SkIntToScalar(0), fDY[i]);
}
- canvas->save();
canvas->scale(0.300000011920929f, 0.300000011920929f);
canvas->translate(50, 50);
canvas->drawPath(fInfoPath, paint);
- canvas->restore();
-
- canvas->scale(2, 2);
- canvas->translate(5, 15);
- canvas->drawPath(fAccessibilityPath, paint);
}
private:
diff --git a/src/core/SkMathPriv.h b/src/core/SkMathPriv.h
index 5ef0cb25e4..14ebeb17b7 100644
--- a/src/core/SkMathPriv.h
+++ b/src/core/SkMathPriv.h
@@ -132,16 +132,6 @@ static inline int SkNextPow2(int value) {
}
/**
-* Returns the largest power-of-2 that is <= the specified value. If value
-* is already a power of 2, then it is returned unchanged. It is undefined
-* if value is <= 0.
-*/
-static inline int SkPrevPow2(int value) {
- SkASSERT(value > 0);
- return 1 << (32 - SkCLZ(value >> 1));
-}
-
-/**
* Returns the log2 of the specified value, were that value to be rounded up
* to the next power of 2. It is undefined to pass 0. Examples:
* SkNextLog2(1) -> 0
@@ -155,20 +145,6 @@ static inline int SkNextLog2(uint32_t value) {
return 32 - SkCLZ(value - 1);
}
-/**
-* Returns the log2 of the specified value, were that value to be rounded down
-* to the previous power of 2. It is undefined to pass 0. Examples:
-* SkPrevLog2(1) -> 0
-* SkPrevLog2(2) -> 1
-* SkPrevLog2(3) -> 1
-* SkPrevLog2(4) -> 2
-* SkPrevLog2(5) -> 2
-*/
-static inline int SkPrevLog2(uint32_t value) {
- SkASSERT(value != 0);
- return 32 - SkCLZ(value >> 1);
-}
-
///////////////////////////////////////////////////////////////////////////////
/**
diff --git a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp
index e1a04396eb..f817f86357 100644
--- a/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp
+++ b/src/gpu/ops/GrAADistanceFieldPathRenderer.cpp
@@ -10,7 +10,6 @@
#include "GrBuffer.h"
#include "GrContext.h"
-#include "GrDistanceFieldGenFromVector.h"
#include "GrDrawOpTest.h"
#include "GrOpFlushState.h"
#include "GrPipelineBuilder.h"
@@ -21,10 +20,10 @@
#include "effects/GrDistanceFieldGeoProc.h"
#include "ops/GrMeshDrawOp.h"
+#include "SkPathOps.h"
#include "SkAutoMalloc.h"
#include "SkDistanceFieldGen.h"
-#include "SkMathPriv.h"
-#include "SkPathOps.h"
+#include "GrDistanceFieldGenFromVector.h"
#define ATLAS_TEXTURE_WIDTH 2048
#define ATLAS_TEXTURE_HEIGHT 2048
@@ -40,12 +39,9 @@ static int g_NumFreedShapes = 0;
#endif
// mip levels
-static const int kMinMIP = 16;
-static const int kMinMIPLog = 4;
-static const int kMaxMIP = 162;
-
-static const int kMaxDim = 73;
-static const int kMaxSize = 2*kMaxMIP;
+static const int kSmallMIP = 32;
+static const int kMediumMIP = 73;
+static const int kLargeMIP = 162;
// Callback to clear out internal path cache when eviction occurs
void GrAADistanceFieldPathRenderer::HandleEviction(GrDrawOpAtlas::AtlasID id, void* pr) {
@@ -111,14 +107,14 @@ bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
return false;
}
- // Only support paths with bounds within kMaxDim by kMaxDim,
- // scaled to have bounds within kMaxSize by kMaxSize.
+ // 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 <= kMaxDim && maxDim * maxScale <= kMaxSize;
+ return maxDim <= kMediumMIP && maxDim * maxScale <= 2.0f*kLargeMIP;
}
////////////////////////////////////////////////////////////////////////////////
@@ -245,28 +241,20 @@ private:
const SkRect& bounds = args.fShape.bounds();
SkScalar maxDim = SkMaxScalar(bounds.width(), bounds.height());
SkScalar size = maxScale * maxDim;
- // We try to create the DF at a power of two scaled path resolution (1/2, 1, 2, 4, etc)
- // In the majority of cases this will yield a crisper rendering.
- SkScalar mipScale = 1.0f;
- // for small paths, scale up to a min size between kMinMIP and 2*kMinMIP
- if (maxDim < kMinMIP) {
- mipScale = SkIntToScalar(1 << (kMinMIPLog - SkPrevLog2(maxDim)));
- // for larger paths, initial scale is half the original
- // gives us a size between kMinMIP and kMaxDim/2 (or close to (kMinMIP, 2*kMinMIP])
- } else if (maxDim > 2*kMinMIP) {
- mipScale = 0.5f;
- }
- SkScalar smallMipSize = mipScale*maxDim;
-
SkScalar desiredDimension;
- if (size <= smallMipSize) {
- desiredDimension = smallMipSize;
- } else if (size <= 2*smallMipSize) {
- desiredDimension = 2*smallMipSize;
- } else if (size <= 4*smallMipSize) {
- desiredDimension = 4*smallMipSize;
+ // For minimizing (or the common case of identity) transforms, we try to
+ // create the DF at the appropriately sized native src-space path resolution.
+ // In the majority of cases this will yield a crisper rendering.
+ if (size <= maxDim && maxDim < kSmallMIP) {
+ desiredDimension = maxDim;
+ } else if (size <= kSmallMIP) {
+ desiredDimension = kSmallMIP;
+ } else if (size <= maxDim) {
+ desiredDimension = maxDim;
+ } else if (size <= kMediumMIP) {
+ desiredDimension = kMediumMIP;
} else {
- desiredDimension = kMaxMIP;
+ desiredDimension = kLargeMIP;
}
// check to see if path is cached