aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrGeometryProcessor.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-19 14:33:47 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 20:01:29 +0000
commit92be2f74db81f0ed480b55c58cbde39270f9b772 (patch)
treed2b7135f511a318f10c5c86f2537c07051c922bd /src/gpu/GrGeometryProcessor.h
parentf5ac906476cd26f2967a48340940e6af580fa71f (diff)
Revert "Revert "Change how vertex/instance attributes are handled in geometry processors.""
This reverts commit 5045e501d2aec23e5f1e4b46346033ac3202c6b0. TBR=csmartdalton@google.com Change-Id: Ifbf5f1d8f8ef340fdc69653e931b6d68d4bf0854 Reviewed-on: https://skia-review.googlesource.com/135862 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/GrGeometryProcessor.h')
-rw-r--r--src/gpu/GrGeometryProcessor.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gpu/GrGeometryProcessor.h b/src/gpu/GrGeometryProcessor.h
index a12ab0058d..5035ad0f53 100644
--- a/src/gpu/GrGeometryProcessor.h
+++ b/src/gpu/GrGeometryProcessor.h
@@ -39,7 +39,44 @@ protected:
fSampleShading = sampleShading;
}
+ /**
+ * Recursive helpers for implementing onVertexAttribute or onInstanceAttribute.
+ */
+
+ template <typename... Args>
+ static const Attribute& IthAttribute(int i, const Attribute& attr0, const Args&... attrs) {
+ SkASSERT(attr0.isInitialized());
+ return (0 == i) ? attr0 : IthAttribute(i - 1, attrs...);
+ }
+
+ static const Attribute& IthAttribute(int i) {
+ SK_ABORT("Illegal attribute Index");
+ static constexpr Attribute kBogus;
+ return kBogus;
+ }
+
+ template <typename... Args>
+ static const Attribute& IthInitializedAttribute(int i, const Attribute& attr0,
+ const Args&... attrs) {
+ if (attr0.isInitialized()) {
+ if (0 == i) {
+ return attr0;
+ }
+ i -= 1;
+ }
+ return IthInitializedAttribute(i, attrs...);
+ }
+
+ static const Attribute& IthInitializedAttribute(int i) { return IthAttribute(i); }
+
private:
+ // Since most subclasses don't use instancing provide a default implementation for that case.
+ const Attribute& onInstanceAttribute(int i) const override {
+ SK_ABORT("No instanced attributes");
+ static constexpr Attribute kBogus;
+ return kBogus;
+ }
+
bool fWillUseGeoShader;
float fSampleShading;