diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-03-08 15:55:58 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-08 15:56:02 +0000 |
commit | baf3e78092243210ca4489e51134df6fc8a90eee (patch) | |
tree | 41d16430ad639f72787a148f04476ee079e9ad56 /samplecode/SampleCCPRGeometry.cpp | |
parent | fe462efbcb105914e4c4bbf689525b530a438773 (diff) |
Revert "ccpr: Draw curves in a single pass"
This reverts commit df04ce29490a24f9d5b4f5caafd8f6a3368a19e0.
Reason for revert: Going to revisit AAA quality
Original change's description:
> ccpr: Draw curves in a single pass
>
> Throws out the complicated MSAA curve corner shaders, and instead just
> ramps coverage to zero at bloat vertices that fall outside the curve.
>
> Updates SampleCCPRGeometry to better visualize this new geometry by
> clearing to black and drawing with SkBlendMode::kPlus.
>
> Bug: skia:
> Change-Id: Ibe86cbc741d8b015127b10dd43e3b52e7cb35732
> Reviewed-on: https://skia-review.googlesource.com/112626
> Commit-Queue: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com
Change-Id: I014baa60b248d870717f5ee8794e0bed66da86e6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/113181
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'samplecode/SampleCCPRGeometry.cpp')
-rw-r--r-- | samplecode/SampleCCPRGeometry.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index 2a7d6640a6..a90ece09a1 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -32,6 +32,10 @@ using RenderPass = GrCCCoverageProcessor::RenderPass; static constexpr float kDebugBloat = 40; +static int is_quadratic(RenderPass pass) { + return pass == RenderPass::kQuadratics || pass == RenderPass::kQuadraticCorners; +} + /** * This sample visualizes the AA bloat geometry generated by the ccpr geometry shaders. It * increases the AA bloat by 50x and outputs color instead of coverage (coverage=+1 -> green, @@ -115,13 +119,14 @@ static void draw_klm_line(int w, int h, SkCanvas* canvas, const SkScalar line[3] } void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { - canvas->clear(SK_ColorBLACK); + SkAutoCanvasRestore acr(canvas, true); + canvas->setMatrix(SkMatrix::I()); SkPath outline; outline.moveTo(fPoints[0]); - if (RenderPass::kCubics == fRenderPass) { + if (GrCCCoverageProcessor::RenderPassIsCubic(fRenderPass)) { outline.cubicTo(fPoints[1], fPoints[2], fPoints[3]); - } else if (RenderPass::kQuadratics == fRenderPass) { + } else if (is_quadratic(fRenderPass)) { outline.quadTo(fPoints[1], fPoints[3]); } else { outline.lineTo(fPoints[1]); @@ -130,7 +135,7 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { } SkPaint outlinePaint; - outlinePaint.setColor(0x80ffffff); + outlinePaint.setColor(0x30000000); outlinePaint.setStyle(SkPaint::kStroke_Style); outlinePaint.setStrokeWidth(0); outlinePaint.setAntiAlias(true); @@ -154,7 +159,7 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { if (GrRenderTargetContext* rtc = canvas->internal_private_accessTopLayerRenderTargetContext()) { rtc->priv().testingOnly_addDrawOp(skstd::make_unique<Op>(this)); caption.appendf("RenderPass_%s", GrCCCoverageProcessor::RenderPassName(fRenderPass)); - if (RenderPass::kCubics == fRenderPass) { + if (GrCCCoverageProcessor::RenderPassIsCubic(fRenderPass)) { caption.appendf(" (%s)", SkCubicTypeName(fCubicType)); } } else { @@ -166,7 +171,7 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { pointsPaint.setStrokeWidth(8); pointsPaint.setAntiAlias(true); - if (RenderPass::kCubics == fRenderPass) { + if (GrCCCoverageProcessor::RenderPassIsCubic(fRenderPass)) { int w = this->width(), h = this->height(); canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, fPoints, pointsPaint); draw_klm_line(w, h, canvas, &fCubicKLM[0], SK_ColorYELLOW); @@ -179,7 +184,7 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { SkPaint captionPaint; captionPaint.setTextSize(20); - captionPaint.setColor(SK_ColorWHITE); + captionPaint.setColor(SK_ColorBLACK); captionPaint.setAntiAlias(true); canvas->drawText(caption.c_str(), caption.size(), 10, 30, captionPaint); } @@ -188,7 +193,7 @@ void CCPRGeometryView::updateGpuData() { fTriPointInstances.reset(); fQuadPointInstances.reset(); - if (RenderPass::kCubics == fRenderPass) { + if (GrCCCoverageProcessor::RenderPassIsCubic(fRenderPass)) { double t[2], s[2]; fCubicType = GrPathUtils::getCubicKLM(fPoints, &fCubicKLM, t, s); GrCCGeometry geometry; @@ -212,7 +217,7 @@ void CCPRGeometryView::updateGpuData() { continue; } } - } else if (RenderPass::kQuadratics == fRenderPass) { + } else if (is_quadratic(fRenderPass)) { GrCCGeometry geometry; geometry.beginContour(fPoints[0]); geometry.quadraticTo(fPoints[1], fPoints[3]); @@ -249,7 +254,7 @@ void CCPRGeometryView::Op::onExecute(GrOpFlushState* state) { SkDEBUGCODE(proc.enableDebugVisualizations(kDebugBloat)); SkSTArray<1, GrMesh> mesh; - if (RenderPass::kCubics == fView->fRenderPass) { + if (GrCCCoverageProcessor::RenderPassIsCubic(fView->fRenderPass)) { sk_sp<GrBuffer> instBuff(rp->createBuffer( fView->fQuadPointInstances.count() * sizeof(QuadPointInstance), kVertex_GrBufferType, kDynamic_GrAccessPattern, @@ -270,11 +275,11 @@ void CCPRGeometryView::Op::onExecute(GrOpFlushState* state) { } GrPipeline pipeline(state->drawOpArgs().fProxy, GrPipeline::ScissorState::kDisabled, - SkBlendMode::kPlus); + SkBlendMode::kSrcOver); if (glGpu) { glGpu->handleDirtyContext(); - // GR_GL_CALL(glGpu->glInterface(), PolygonMode(GR_GL_FRONT_AND_BACK, GR_GL_LINE)); + GR_GL_CALL(glGpu->glInterface(), PolygonMode(GR_GL_FRONT_AND_BACK, GR_GL_LINE)); GR_GL_CALL(glGpu->glInterface(), Enable(GR_GL_LINE_SMOOTH)); } @@ -313,7 +318,7 @@ private: SkView::Click* CCPRGeometryView::onFindClickHandler(SkScalar x, SkScalar y, unsigned) { for (int i = 0; i < 4; ++i) { - if (RenderPass::kCubics != fRenderPass && 2 == i) { + if (!GrCCCoverageProcessor::RenderPassIsCubic(fRenderPass) && 2 == i) { continue; } if (fabs(x - fPoints[i].x()) < 20 && fabsf(y - fPoints[i].y()) < 20) { @@ -337,7 +342,7 @@ bool CCPRGeometryView::onQuery(SkEvent* evt) { } SkUnichar unichar; if (SampleCode::CharQ(*evt, &unichar)) { - if (unichar >= '1' && unichar <= '4') { + if (unichar >= '1' && unichar <= '6') { fRenderPass = RenderPass(unichar - '1'); this->updateAndInval(); return true; |