Remove GrMiddleOutCubicShader::kMaxResolveLevel

This should have been removed already. Everybody can just use
GrTessellationPathRenderer::kMaxResolveLevel instead.

Bug: skia:10419
Change-Id: If38e499ce6f74a7b052219c2cac2a402d3d05d8c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298901
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
Chris Dalton 2020-06-25 06:57:20 -06:00 committed by Skia Commit-Bot
parent adac288da5
commit 768adaa3c2
3 changed files with 9 additions and 11 deletions

View File

@ -9,7 +9,7 @@
#define GrResolveLevelCounter_DEFINED
#include "src/core/SkPathPriv.h"
#include "src/gpu/tessellate/GrStencilPathShader.h"
#include "src/gpu/tessellate/GrTessellationPathRenderer.h"
#include "src/gpu/tessellate/GrWangsFormula.h"
// This class helps bin cubics by log2 "resolveLevel" when we don't use hardware tessellation. It is
@ -47,7 +47,7 @@ public:
// Cubics with 2^0=1 segments are empty (zero area). We ignore them completely.
return;
}
resolveLevel = std::min(resolveLevel, GrMiddleOutCubicShader::kMaxResolveLevel);
resolveLevel = std::min(resolveLevel, GrTessellationPathRenderer::kMaxResolveLevel);
if (!fInstanceCounts[resolveLevel]++) {
++fTotalCubicIndirectDrawCount;
}
@ -57,7 +57,7 @@ public:
int operator[](int resolveLevel) const {
SkASSERT(fHasCalledReset);
SkASSERT(resolveLevel > 0); // Empty cubics with 2^0=1 segments do not need to be drawn.
SkASSERT(resolveLevel <= GrMiddleOutCubicShader::kMaxResolveLevel);
SkASSERT(resolveLevel <= GrTessellationPathRenderer::kMaxResolveLevel);
return fInstanceCounts[resolveLevel];
}
int totalCubicInstanceCount() const { return fTotalCubicInstanceCount; }
@ -65,7 +65,7 @@ public:
private:
SkDEBUGCODE(bool fHasCalledReset = false;)
int fInstanceCounts[GrMiddleOutCubicShader::kMaxResolveLevel + 1];
int fInstanceCounts[GrTessellationPathRenderer::kMaxResolveLevel + 1];
int fTotalCubicInstanceCount = 0;
int fTotalCubicIndirectDrawCount = 0;
};

View File

@ -14,7 +14,7 @@
// Wang's formula for cubics (1985) gives us the number of evenly spaced (in the
// parametric sense) line segments that are guaranteed to be within a distance of
// "MAX_LINEARIZATION_ERROR" from the actual curve.
constexpr char kWangsFormulaCubicFn[] = R"(
constexpr static char kWangsFormulaCubicFn[] = R"(
#define MAX_LINEARIZATION_ERROR 0.25 // 1/4 pixel
float wangs_formula_cubic(vec2 p0, vec2 p1, vec2 p2, vec2 p3) {
float k = (3.0 * 2.0) / (8.0 * MAX_LINEARIZATION_ERROR);
@ -24,7 +24,7 @@ constexpr char kWangsFormulaCubicFn[] = R"(
})";
// Evaluate our point of interest using numerically stable mix() operations.
constexpr char kEvalCubicFn[] = R"(
constexpr static char kEvalCubicFn[] = R"(
vec2 eval_cubic(mat4x2 P, float T) {
vec2 ab = mix(P[0], P[1], T);
vec2 bc = mix(P[1], P[2], T);
@ -226,6 +226,8 @@ SkString GrTessellateWedgeShader::getTessEvaluationShaderGLSL(
return code;
}
constexpr static int kMaxResolveLevel = GrTessellationPathRenderer::kMaxResolveLevel;
GR_DECLARE_STATIC_UNIQUE_KEY(gMiddleOutIndexBufferKey);
sk_sp<const GrGpuBuffer> GrMiddleOutCubicShader::FindOrMakeMiddleOutIndexBuffer(

View File

@ -91,10 +91,6 @@ private:
// sort the instance buffer by resolveLevel for efficient batching of indirect draws.
class GrMiddleOutCubicShader : public GrStencilPathShader {
public:
// Each resolveLevel linearizes the curve into 2^resolveLevel line segments. The finest
// supported resolveLevel is therefore 2^12=4096 line segments.
constexpr static int kMaxResolveLevel = GrTessellationPathRenderer::kMaxResolveLevel;
// How many vertices do we need to draw in order to triangulate a cubic with 2^resolveLevel
// line segments?
constexpr static int NumVerticesAtResolveLevel(int resolveLevel) {
@ -111,7 +107,7 @@ public:
static GrDrawIndexedIndirectCommand MakeDrawCubicsIndirectCmd(int resolveLevel,
uint32_t instanceCount,
uint32_t baseInstance) {
SkASSERT(resolveLevel > 0 && resolveLevel <= kMaxResolveLevel);
SkASSERT(resolveLevel > 0 && resolveLevel <= GrTessellationPathRenderer::kMaxResolveLevel);
// Starting at baseIndex=3, the index buffer triangulates a cubic with 2^kMaxResolveLevel
// line segments. Each index value corresponds to a parametric T value on the curve. Since
// the triangles are arranged in "middle-out" order, we can conveniently control the