diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-12-08 10:59:58 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-08 20:13:18 +0000 |
commit | be4ffab4e208ec47b4298621b9c9e8456f31717e (patch) | |
tree | 28bee87fec500acab63c2e72c77a6b7a4fd53ba1 /samplecode/SampleCCPRGeometry.cpp | |
parent | 3f39bf8fe596f87120d189dbec2889b644f07e2d (diff) |
CCPR: Combine loops and serpentines back into a single shader
Bug: skia:
Change-Id: I945471ccd2580a2d39afd9c80acb8d9e5e196435
Reviewed-on: https://skia-review.googlesource.com/82460
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'samplecode/SampleCCPRGeometry.cpp')
-rw-r--r-- | samplecode/SampleCCPRGeometry.cpp | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index a8f0d9e02c..424485db76 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -31,8 +31,8 @@ using RenderPass = GrCCPRCoverageProcessor::RenderPass; static constexpr float kDebugBloat = 40; -static int is_quadratic(RenderPass renderPass) { - return renderPass >= RenderPass::kQuadraticHulls && renderPass < RenderPass::kSerpentineHulls; +static int is_quadratic(RenderPass pass) { + return pass == RenderPass::kQuadraticHulls || pass == RenderPass::kQuadraticCorners; } /** @@ -61,6 +61,7 @@ private: void updateGpuData(); RenderPass fRenderPass = RenderPass::kTriangleHulls; + SkCubicType fCubicType; SkMatrix fCubicKLM; SkPoint fPoints[4] = { @@ -161,12 +162,16 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { } #endif - const char* caption = "Use GPU backend to visualize geometry."; - + SkString caption; if (GrRenderTargetContext* rtc = canvas->internal_private_accessTopLayerRenderTargetContext()) { rtc->priv().testingOnly_addDrawOp(skstd::make_unique<Op>(this)); - caption = GrCCPRCoverageProcessor::GetRenderPassName(fRenderPass); + caption.appendf("RenderPass_%s", GrCCPRCoverageProcessor::RenderPassName(fRenderPass)); + if (GrCCPRCoverageProcessor::RenderPassIsCubic(fRenderPass)) { + caption.appendf(" (%s)", SkCubicTypeName(fCubicType)); + } + } else { + caption = "Use GPU backend to visualize geometry."; } SkPaint pointsPaint; @@ -189,7 +194,7 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { captionPaint.setTextSize(20); captionPaint.setColor(SK_ColorBLACK); captionPaint.setAntiAlias(true); - canvas->drawText(caption, strlen(caption), 10, 30, captionPaint); + canvas->drawText(caption.c_str(), caption.size(), 10, 30, captionPaint); } void CCPRGeometryView::updateGpuData() { @@ -198,20 +203,7 @@ void CCPRGeometryView::updateGpuData() { if (GrCCPRCoverageProcessor::RenderPassIsCubic(fRenderPass)) { double t[2], s[2]; - SkCubicType type = GrPathUtils::getCubicKLM(fPoints, &fCubicKLM, t, s); - if (RenderPass::kSerpentineHulls == fRenderPass && SkCubicType::kLoop == type) { - fRenderPass = RenderPass::kLoopHulls; - } - if (RenderPass::kSerpentineCorners == fRenderPass && SkCubicType::kLoop == type) { - fRenderPass = RenderPass::kLoopCorners; - } - if (RenderPass::kLoopHulls == fRenderPass && SkCubicType::kLoop != type) { - fRenderPass = RenderPass::kSerpentineHulls; - } - if (RenderPass::kLoopCorners == fRenderPass && SkCubicType::kLoop != type) { - fRenderPass = RenderPass::kSerpentineCorners; - } - + fCubicType = GrPathUtils::getCubicKLM(fPoints, &fCubicKLM, t, s); GrCCPRGeometry geometry; geometry.beginContour(fPoints[0]); geometry.cubicTo(fPoints[1], fPoints[2], fPoints[3], kDebugBloat/2, kDebugBloat/2); @@ -225,8 +217,7 @@ void CCPRGeometryView::updateGpuData() { case GrCCPRGeometry::Verb::kMonotonicQuadraticTo: ptsIdx += 2; continue; - case GrCCPRGeometry::Verb::kMonotonicSerpentineTo: - case GrCCPRGeometry::Verb::kMonotonicLoopTo: + case GrCCPRGeometry::Verb::kMonotonicCubicTo: fCubicInstances.push_back().set(&geometry.points()[ptsIdx], 0, 0); ptsIdx += 3; continue; @@ -362,11 +353,6 @@ bool CCPRGeometryView::onQuery(SkEvent* evt) { if (SampleCode::CharQ(*evt, &unichar)) { if (unichar >= '1' && unichar <= '7') { fRenderPass = RenderPass(unichar - '1'); - if (fRenderPass >= RenderPass::kLoopHulls) { - // '6' -> kSerpentineHulls, '7' -> kSerpentineCorners. updateGpuData converts to - // kLoop* if needed. - fRenderPass = RenderPass(int(fRenderPass) + 1); - } this->updateAndInval(); return true; } |