Minor cleanups for CCPR
Bug: skia: Change-Id: Ic4838f0e242ded0c3d0cb5c86715ed67d8152f5c Reviewed-on: https://skia-review.googlesource.com/44520 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
6f0751e50f
commit
a640c49b7e
@ -29,6 +29,8 @@ using TriangleInstance = GrCCPRCoverageProcessor::TriangleInstance;
|
||||
using CurveInstance = GrCCPRCoverageProcessor::CurveInstance;
|
||||
using Mode = GrCCPRCoverageProcessor::Mode;
|
||||
|
||||
static constexpr float kDebugBloat = 40;
|
||||
|
||||
static int num_points(Mode mode) {
|
||||
return mode >= Mode::kSerpentineHulls ? 4 : 3;
|
||||
}
|
||||
@ -156,10 +158,10 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) {
|
||||
gridPaint.setStyle(SkPaint::kStroke_Style);
|
||||
gridPaint.setStrokeWidth(0);
|
||||
gridPaint.setAntiAlias(true);
|
||||
for (int y = 0; y < this->height(); y += GrCCPRCoverageProcessor::kDebugBloat) {
|
||||
for (int y = 0; y < this->height(); y += kDebugBloat) {
|
||||
canvas->drawLine(0, y, this->width(), y, gridPaint);
|
||||
}
|
||||
for (int x = 0; x < this->width(); x += GrCCPRCoverageProcessor::kDebugBloat) {
|
||||
for (int x = 0; x < this->width(); x += kDebugBloat) {
|
||||
canvas->drawLine(x, 0, x, this->height(), outlinePaint);
|
||||
}
|
||||
#endif
|
||||
@ -220,9 +222,7 @@ void CCPRGeometryView::updateGpuData() {
|
||||
|
||||
GrCCPRGeometry geometry;
|
||||
geometry.beginContour(fPoints[0]);
|
||||
geometry.cubicTo(fPoints[1], fPoints[2], fPoints[3],
|
||||
GrCCPRCoverageProcessor::kDebugBloat / 2,
|
||||
GrCCPRCoverageProcessor::kDebugBloat / 2);
|
||||
geometry.cubicTo(fPoints[1], fPoints[2], fPoints[3], kDebugBloat/2, kDebugBloat/2);
|
||||
geometry.endContour();
|
||||
fGpuPoints.push_back_n(geometry.points().count(), geometry.points().begin());
|
||||
int ptsIdx = 0;
|
||||
@ -305,7 +305,7 @@ void CCPRGeometryView::Op::onExecute(GrOpFlushState* state) {
|
||||
SkBlendMode::kSrcOver);
|
||||
|
||||
GrCCPRCoverageProcessor ccprProc(fView->fMode, pointsBuffer.get());
|
||||
SkDEBUGCODE(ccprProc.enableDebugVisualizations();)
|
||||
SkDEBUGCODE(ccprProc.enableDebugVisualizations(kDebugBloat);)
|
||||
|
||||
GrMesh mesh(4 == vertexCount ? GrPrimitiveType::kLinesAdjacency : GrPrimitiveType::kTriangles);
|
||||
mesh.setInstanced(instanceBuffer.get(), fView->fInstanceCount, 0, vertexCount);
|
||||
|
@ -166,8 +166,21 @@ enum class SkCubicType {
|
||||
kQuadratic,
|
||||
kLineOrPoint
|
||||
};
|
||||
constexpr bool SkCubicIsDegenerate(SkCubicType type) {
|
||||
return type >= SkCubicType::kQuadratic;
|
||||
|
||||
static inline bool SkCubicIsDegenerate(SkCubicType type) {
|
||||
switch (type) {
|
||||
case SkCubicType::kSerpentine:
|
||||
case SkCubicType::kLoop:
|
||||
case SkCubicType::kLocalCusp:
|
||||
case SkCubicType::kCuspAtInfinity:
|
||||
return false;
|
||||
default:
|
||||
SK_ABORT("Invalid SkCubicType");
|
||||
// fallthru
|
||||
case SkCubicType::kQuadratic:
|
||||
case SkCubicType::kLineOrPoint:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the cubic classification.
|
||||
|
@ -159,8 +159,8 @@ void PrimitiveProcessor::emitGeometryShader(const GrCCPRCoverageProcessor& proc,
|
||||
g->codeAppendf("highp float2 bloat = %f * abs(%s.xz);", kAABloatRadius, rtAdjust);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
if (proc.debugVisualizations()) {
|
||||
g->codeAppendf("bloat *= %f;", GrCCPRCoverageProcessor::kDebugBloat);
|
||||
if (proc.debugVisualizationsEnabled()) {
|
||||
g->codeAppendf("bloat *= %f;", proc.debugBloat());
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -324,7 +324,7 @@ void PrimitiveProcessor::emitCoverage(const GrCCPRCoverageProcessor& proc, GrGLS
|
||||
f->codeAppendf("%s = float4(1);", outputCoverage);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
if (proc.debugVisualizations()) {
|
||||
if (proc.debugVisualizationsEnabled()) {
|
||||
f->codeAppendf("%s = float4(-%s.a, %s.a, 0, 1);", outputColor, outputColor, outputColor);
|
||||
}
|
||||
#endif
|
||||
|
@ -92,12 +92,12 @@ public:
|
||||
void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
|
||||
|
||||
static constexpr float kDebugBloat = 50;
|
||||
#ifdef SK_DEBUG
|
||||
// Increases the 1/2 pixel AA bloat by a factor of kDebugBloat and outputs color instead of
|
||||
// Increases the 1/2 pixel AA bloat by a factor of debugBloat and outputs color instead of
|
||||
// coverage (coverage=+1 -> green, coverage=0 -> black, coverage=-1 -> red).
|
||||
void enableDebugVisualizations() { fDebugVisualizations = true; }
|
||||
bool debugVisualizations() const { return fDebugVisualizations; }
|
||||
void enableDebugVisualizations(float debugBloat) { fDebugBloat = debugBloat; }
|
||||
bool debugVisualizationsEnabled() const { return fDebugBloat > 0; }
|
||||
float debugBloat() const { SkASSERT(this->debugVisualizationsEnabled()); return fDebugBloat; }
|
||||
|
||||
static void Validate(GrRenderTargetProxy* atlasProxy);
|
||||
#endif
|
||||
@ -105,10 +105,10 @@ public:
|
||||
class PrimitiveProcessor;
|
||||
|
||||
private:
|
||||
const Mode fMode;
|
||||
const Attribute& fInstanceAttrib;
|
||||
BufferAccess fPointsBufferAccess;
|
||||
SkDEBUGCODE(bool fDebugVisualizations = false;)
|
||||
const Mode fMode;
|
||||
const Attribute& fInstanceAttrib;
|
||||
BufferAccess fPointsBufferAccess;
|
||||
SkDEBUGCODE(float fDebugBloat = false;)
|
||||
|
||||
typedef GrGeometryProcessor INHERITED;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user