aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2018-02-13 21:46:17 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-14 17:21:17 +0000
commit84403d7f53d88b2449fd19415538ba1479fe300b (patch)
treef8df6e8845b72bebafc1a06fa60ed8868d2ce78b /samplecode
parent7d79e7b588e8286edee853e2c274a6daa48d88d1 (diff)
ccpr: Tessellate fans for very large and/or simple paths
This increases CPU work, but reduces overdraw on the GPU as compared to Redbook fanning. TBR=bsalomon@google.com Change-Id: I396b887075d4422531908c2361ee1e26f076d5c3 Reviewed-on: https://skia-review.googlesource.com/107141 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleCCPRGeometry.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp
index 5a2da7f02b..a0c5d7be7a 100644
--- a/samplecode/SampleCCPRGeometry.cpp
+++ b/samplecode/SampleCCPRGeometry.cpp
@@ -26,8 +26,8 @@
#include "gl/GrGLGpu.cpp"
#include "ops/GrDrawOp.h"
-using TriangleInstance = GrCCCoverageProcessor::TriangleInstance;
-using CubicInstance = GrCCCoverageProcessor::CubicInstance;
+using TriPointInstance = GrCCCoverageProcessor::TriPointInstance;
+using QuadPointInstance = GrCCCoverageProcessor::QuadPointInstance;
using RenderPass = GrCCCoverageProcessor::RenderPass;
static constexpr float kDebugBloat = 40;
@@ -66,8 +66,8 @@ private:
SkPoint fPoints[4] = {
{100.05f, 100.05f}, {400.75f, 100.05f}, {400.75f, 300.95f}, {100.05f, 300.95f}};
- SkTArray<TriangleInstance> fTriangleInstances;
- SkTArray<CubicInstance> fCubicInstances;
+ SkTArray<TriPointInstance> fTriPointInstances;
+ SkTArray<QuadPointInstance> fQuadPointInstances;
typedef SampleView INHERITED;
};
@@ -190,8 +190,8 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) {
}
void CCPRGeometryView::updateGpuData() {
- fTriangleInstances.reset();
- fCubicInstances.reset();
+ fTriPointInstances.reset();
+ fQuadPointInstances.reset();
if (GrCCCoverageProcessor::RenderPassIsCubic(fRenderPass)) {
double t[2], s[2];
@@ -210,7 +210,7 @@ void CCPRGeometryView::updateGpuData() {
ptsIdx += 2;
continue;
case GrCCGeometry::Verb::kMonotonicCubicTo:
- fCubicInstances.push_back().set(&geometry.points()[ptsIdx], 0, 0);
+ fQuadPointInstances.push_back().set(&geometry.points()[ptsIdx], 0, 0);
ptsIdx += 3;
continue;
default:
@@ -234,11 +234,11 @@ void CCPRGeometryView::updateGpuData() {
continue;
}
SkASSERT(GrCCGeometry::Verb::kMonotonicQuadraticTo == verb);
- fTriangleInstances.push_back().set(&geometry.points()[ptsIdx], Sk2f(0, 0));
+ fTriPointInstances.push_back().set(&geometry.points()[ptsIdx], Sk2f(0, 0));
ptsIdx += 2;
}
} else {
- fTriangleInstances.push_back().set(fPoints[0], fPoints[1], fPoints[3], Sk2f(0, 0));
+ fTriPointInstances.push_back().set(fPoints[0], fPoints[1], fPoints[3], Sk2f(0, 0));
}
}
@@ -253,27 +253,28 @@ void CCPRGeometryView::Op::onExecute(GrOpFlushState* state) {
return;
}
- GrCCCoverageProcessor proc(rp, fView->fRenderPass, state->caps());
+ GrCCCoverageProcessor proc(rp, fView->fRenderPass,
+ GrCCCoverageProcessor::WindMethod::kCrossProduct);
SkDEBUGCODE(proc.enableDebugVisualizations(kDebugBloat));
SkSTArray<1, GrMesh> mesh;
if (GrCCCoverageProcessor::RenderPassIsCubic(fView->fRenderPass)) {
sk_sp<GrBuffer> instBuff(rp->createBuffer(
- fView->fCubicInstances.count() * sizeof(CubicInstance), kVertex_GrBufferType,
- kDynamic_GrAccessPattern,
+ fView->fQuadPointInstances.count() * sizeof(QuadPointInstance),
+ kVertex_GrBufferType, kDynamic_GrAccessPattern,
GrResourceProvider::kNoPendingIO_Flag | GrResourceProvider::kRequireGpuMemory_Flag,
- fView->fCubicInstances.begin()));
- if (!fView->fCubicInstances.empty() && instBuff) {
- proc.appendMesh(instBuff.get(), fView->fCubicInstances.count(), 0, &mesh);
+ fView->fQuadPointInstances.begin()));
+ if (!fView->fQuadPointInstances.empty() && instBuff) {
+ proc.appendMesh(instBuff.get(), fView->fQuadPointInstances.count(), 0, &mesh);
}
} else {
sk_sp<GrBuffer> instBuff(rp->createBuffer(
- fView->fTriangleInstances.count() * sizeof(TriangleInstance), kVertex_GrBufferType,
+ fView->fTriPointInstances.count() * sizeof(TriPointInstance), kVertex_GrBufferType,
kDynamic_GrAccessPattern,
GrResourceProvider::kNoPendingIO_Flag | GrResourceProvider::kRequireGpuMemory_Flag,
- fView->fTriangleInstances.begin()));
- if (!fView->fTriangleInstances.empty() && instBuff) {
- proc.appendMesh(instBuff.get(), fView->fTriangleInstances.count(), 0, &mesh);
+ fView->fTriPointInstances.begin()));
+ if (!fView->fTriPointInstances.empty() && instBuff) {
+ proc.appendMesh(instBuff.get(), fView->fTriPointInstances.count(), 0, &mesh);
}
}