Support markers (custom matrices) in SkVertices Attributes
Bug: skia:9984
Change-Id: Ie799ffa19304978e2076f9ba790e8a34c1b03adf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283225
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 15751ab..a263a4a 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1953,7 +1953,7 @@
// We expect fans to be converted to triangles when building or deserializing SkVertices.
SkASSERT(vertices->priv().mode() != SkVertices::kTriangleFan_VertexMode);
- // If the vertices contain custom attributes, ensure they line up with the paint's shader
+ // If the vertices contain custom attributes, ensure they line up with the paint's shader.
const SkRuntimeEffect* effect =
paint.getShader() ? as_SB(paint.getShader())->asRuntimeEffect() : nullptr;
if ((size_t)vertices->priv().attributeCount() != (effect ? effect->varyings().count() : 0)) {
@@ -1962,7 +1962,13 @@
if (effect) {
int attrIndex = 0;
for (const auto& v : effect->varyings()) {
- if (vertices->priv().attributes()[attrIndex++].channelCount() != v.fWidth) {
+ const SkVertices::Attribute& attr(vertices->priv().attributes()[attrIndex++]);
+ // Mismatch between the SkSL varying and the vertex shader output for this attribute
+ if (attr.channelCount() != v.fWidth) {
+ return;
+ }
+ // If we can't provide any of the asked-for matrices, we can't draw this
+ if (attr.fMarkerID && !this->findMarkedCTM(attr.fMarkerID, nullptr)) {
return;
}
}