diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-08-07 09:00:46 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-07 15:21:30 +0000 |
commit | b072bb6a5c84fecf652ab5f32a197247219efca2 (patch) | |
tree | d9c476eb632464efd2d28c34999104fa2e07fae8 /samplecode/SampleCCPRGeometry.cpp | |
parent | 399b3c2a01cb34c8b9e444ccb5fe5ef3153074c0 (diff) |
CCPR: Process quadratic flat edges without soft msaa
The artifacts previously thought to require msaa can be handled by
(1) converting near-linear quadratics into lines, and (2) ensuring all
quadratic segments are monotonic with respect to the vector of their
closing edge [P2 -> P0].
No. 1 was already in effect.
No. 2 is implemented by this change.
Now we only fall back on soft msaa for the two corner pixels.
This change also does some generic housekeeping in the quadratic
processor.
Bug: skia:
Change-Id: Ib3309c2ed86d3d8bec5f451125a69326e82eeb1c
Reviewed-on: https://skia-review.googlesource.com/29721
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'samplecode/SampleCCPRGeometry.cpp')
-rw-r--r-- | samplecode/SampleCCPRGeometry.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index a6a71af792..d1cb2b5b57 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -10,6 +10,7 @@ #if SK_SUPPORT_GPU #include "GrContextPriv.h" +#include "GrPathUtils.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetContextPriv.h" #include "GrResourceProvider.h" @@ -155,7 +156,6 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { void CCPRGeometryView::updateGpuData() { int vertexCount = num_points(fMode); - int instanceCount = 1; fGpuPoints.reset(); fGpuInstances.reset(); @@ -171,7 +171,7 @@ void CCPRGeometryView::updateGpuData() { } } - instanceCount = chops.count() + 1; + int instanceCount = chops.count() + 1; SkPoint chopped[10]; SkChopCubicAt(fPoints, chopped, chops.begin(), chops.count()); @@ -196,22 +196,33 @@ void CCPRGeometryView::updateGpuData() { if (fMode >= Mode::kLoopInsets && SkCubicType::kLoop != type) { fMode = (Mode) ((int) fMode - 2); } - } else { - // Endpoints. - fGpuPoints.push_back(fPoints[0]); - fGpuPoints.push_back(fPoints[3]); - // Control points. - fGpuPoints.push_back(fPoints[1]); - } - if (4 == vertexCount) { int controlPointsIdx = instanceCount + 1; for (int i = 0; i < instanceCount; ++i) { fGpuInstances.push_back().fCubicData = {controlPointsIdx + i * 4, i}; } } else if (is_curve(fMode)) { - fGpuInstances.push_back().fQuadraticData = {2, 0}; + SkPoint P[3] = {fPoints[0], fPoints[1], fPoints[3]}; + SkPoint chopped[5]; + fGpuPoints.push_back(P[0]); + if (GrPathUtils::chopMonotonicQuads(P, chopped)) { + // Endpoints. + fGpuPoints.push_back(chopped[2]); + fGpuPoints.push_back(chopped[4]); + // Control points. + fGpuPoints.push_back(chopped[1]); + fGpuPoints.push_back(chopped[3]); + fGpuInstances.push_back().fQuadraticData = {3, 0}; + fGpuInstances.push_back().fQuadraticData = {4, 1}; + } else { + fGpuPoints.push_back(P[2]); + fGpuPoints.push_back(P[1]); + fGpuInstances.push_back().fQuadraticData = {2, 0}; + } } else { + fGpuPoints.push_back(fPoints[0]); + fGpuPoints.push_back(fPoints[3]); + fGpuPoints.push_back(fPoints[1]); fGpuInstances.push_back().fTriangleData = {0, 2, 1}; // Texel buffer has endpoints first. } |