drawVertices()

68 views
Skip to first unread message

Shawn Riordan

unread,
May 23, 2023, 11:40:11 AM5/23/23
to skia-discuss
This used to work in m85, but doesn't seem to work in m104 or now:

https://fiddle.skia.org/c/8b955cfce96596b5a85070cf63b90661

It used to look like this:
Untitled.png

Now it is just an empty white triangle.
What changed?

Brian Osman

unread,
May 23, 2023, 11:47:18 AM5/23/23
to skia-d...@googlegroups.com
I think that a subtle change to how the blend-mode works caused this. At one point, I believe that if there was no SkShader on the paint, then the blend-mode was ignored (it just drew using the vertex colors). Now, the specification is consistent with the rest of Skia: The blend that happens between the vertex colors and the paint ALWAYS happens. The SRC of that blend is the SkShader, if present, otherwise it's the opaque paint color. To get the old behavior (just draw with the vertex colors), you can just switch the blend mode to kDst: https://fiddle.skia.org/c/9b7036bc50b7ee261db65ced80f38bce

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/6eed66ef-143f-4f86-8d89-6b787ae5552fn%40googlegroups.com.

Shawn Riordan

unread,
May 23, 2023, 11:58:56 AM5/23/23
to skia-discuss
Thanks!  I will give it a try and let you know.

craste...@gmail.com

unread,
May 23, 2023, 12:16:19 PM5/23/23
to skia-discuss
BTW, what was the purpose of having a blendmode that is separate from the paint?
If the paint had a blendmode too, what kind of chaos would happen if one was multiply and the other was screen?

Brian Salomon

unread,
May 23, 2023, 12:31:39 PM5/23/23
to skia-d...@googlegroups.com
The paint's blend mode always refers to the blend between the final color of the thing being drawn (src) and the previous contents of the canvas (dst). This drawVertices blend mode parameter is used to reach a final src color for a thing that has two color inputs: interpolated vertex colors and a SkPaint. You may want to combine the interpolated colors and SkPaint differently than the way you combine that result with the thing you're drawing on top of.

It's analogous to using SkShaders::Blend to combine two shaders with one mode and then blending into the destination buffer with another mode.

Shawn Riordan

unread,
May 23, 2023, 7:10:37 PM5/23/23
to skia-discuss
Thanks, switching to SkBlendMode::kDst as the blendmode did the trick.
Untitled.png

As far as the explanation for the two blendmodes, I have decided to use the same approach I had when my grandmother explained the distinction between baking powder and baking soda. I will just nod sagely and carry on.

Jim Van Verth

unread,
May 24, 2023, 9:15:03 AM5/24/23
to skia-d...@googlegroups.com
Baking powder is baking soda + an acid + a buffering agent. If you use baking soda alone you need to add an acid to the mix to get proper rising.



--

Jim Van Verth |
 Software Engineer | Google.com

craste...@gmail.com

unread,
May 24, 2023, 9:54:49 AM5/24/23
to skia-discuss
Yep, yep! That is what I was thinking too...
Reply all
Reply to author
Forward
0 new messages