aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/ccpr/GrCCPathProcessor.cpp
diff options
context:
space:
mode:
authorGravatar Chris Dalton <csmartdalton@google.com>2018-01-23 14:06:50 -0700
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-23 21:29:10 +0000
commit27059d36d63284b1af2c25e0e5a52c17485c54d7 (patch)
treed2a8bb6c085dec3d800dd0f9922412ddf968ff94 /src/gpu/ccpr/GrCCPathProcessor.cpp
parent80747ef591ff3c09c2b610eb21258132d1ff4ef5 (diff)
ccpr: Use primitive restart feature on ARM
Bug: skia: Change-Id: Ia7ab55f8b6ecdd674762f5197d35e8db58f07c01 Reviewed-on: https://skia-review.googlesource.com/98180 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/ccpr/GrCCPathProcessor.cpp')
-rw-r--r--src/gpu/ccpr/GrCCPathProcessor.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/gpu/ccpr/GrCCPathProcessor.cpp b/src/gpu/ccpr/GrCCPathProcessor.cpp
index 568ceb7c69..f93a0bd631 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.cpp
+++ b/src/gpu/ccpr/GrCCPathProcessor.cpp
@@ -42,13 +42,22 @@ sk_sp<const GrBuffer> GrCCPathProcessor::FindVertexBuffer(GrOnFlushResourceProvi
kOctoEdgeNorms, gVertexBufferKey);
}
-// Index buffer for the octagon defined above.
-static uint16_t kOctoIndices[GrCCPathProcessor::kPerInstanceIndexCount] = {
+static constexpr uint16_t kRestartStrip = 0xffff;
+
+static constexpr uint16_t kOctoIndicesAsStrips[] = {
+ 1, 0, 2, 4, 3, kRestartStrip, // First half.
+ 5, 4, 6, 0, 7 // Second half.
+};
+
+static constexpr uint16_t kOctoIndicesAsTris[] = {
+ // First half.
+ 1, 0, 2,
0, 4, 2,
- 0, 6, 4,
- 0, 2, 1,
2, 4, 3,
- 4, 6, 5,
+
+ // Second half.
+ 5, 4, 6,
+ 4, 0, 6,
6, 0, 7,
};
@@ -56,12 +65,22 @@ GR_DECLARE_STATIC_UNIQUE_KEY(gIndexBufferKey);
sk_sp<const GrBuffer> GrCCPathProcessor::FindIndexBuffer(GrOnFlushResourceProvider* onFlushRP) {
GR_DEFINE_STATIC_UNIQUE_KEY(gIndexBufferKey);
- return onFlushRP->findOrMakeStaticBuffer(kIndex_GrBufferType, sizeof(kOctoIndices),
- kOctoIndices, gIndexBufferKey);
+ if (onFlushRP->caps()->usePrimitiveRestart()) {
+ return onFlushRP->findOrMakeStaticBuffer(kIndex_GrBufferType, sizeof(kOctoIndicesAsStrips),
+ kOctoIndicesAsStrips, gIndexBufferKey);
+ } else {
+ return onFlushRP->findOrMakeStaticBuffer(kIndex_GrBufferType, sizeof(kOctoIndicesAsTris),
+ kOctoIndicesAsTris, gIndexBufferKey);
+ }
+}
+
+int GrCCPathProcessor::NumIndicesPerInstance(const GrCaps& caps) {
+ return caps.usePrimitiveRestart() ? SK_ARRAY_COUNT(kOctoIndicesAsStrips)
+ : SK_ARRAY_COUNT(kOctoIndicesAsTris);
}
-GrCCPathProcessor::GrCCPathProcessor(GrResourceProvider* rp, sk_sp<GrTextureProxy> atlas,
- SkPath::FillType fillType, const GrShaderCaps& shaderCaps)
+GrCCPathProcessor::GrCCPathProcessor(GrResourceProvider* resourceProvider,
+ sk_sp<GrTextureProxy> atlas, SkPath::FillType fillType)
: INHERITED(kGrCCPathProcessor_ClassID)
, fFillType(fillType)
, fAtlasAccess(std::move(atlas), GrSamplerState::Filter::kNearest,
@@ -91,8 +110,12 @@ GrCCPathProcessor::GrCCPathProcessor(GrResourceProvider* rp, sk_sp<GrTextureProx
this->addVertexAttrib("edge_norms", kFloat4_GrVertexAttribType);
- fAtlasAccess.instantiate(rp);
+ fAtlasAccess.instantiate(resourceProvider);
this->addTextureSampler(&fAtlasAccess);
+
+ if (resourceProvider->caps()->usePrimitiveRestart()) {
+ this->setWillUsePrimitiveRestart();
+ }
}
void GrCCPathProcessor::getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder* b) const {