Current GraphicsContexts is host to an enumeration called "ColorSpace," and the GraphicsContext state keeps track of a strokeColorSpace and a fillColorSpace. The problem is that the values of ColorSpace -- SolidColorSpace, PatternColorSpace, and GradientColorSpace -- are not actually color spaces. CG is confusing, and that is how this error was made and stayed in the code for so long. I am about to add real ColorSpace support <https://bugs.webkit.org/show_bug.cgi?id=31196>, but first we think it's best to clean up GraphicsContext. I will post a patch shortly to do this.
Created attachment 42681 [details]
Darin is likely to be at least a little disappointed in this patch since it is more conservative than some other options we discussed for this cleanup. Specifically, Darin noticed that once we have a Pattern or Gradient on the GraphicsContext, we keep a pointer to it forever. I wrote code that would get rid of old Patterns and Gradients once something that is not a Pattern or Gradient is set, but a bunch of canvas pattern tests failed. I haven't investigated the failures closely enough to know whether or not clearing out the pattern is an option or not. Ultimately, it seems like that is just a bigger problem than we are trying to solve today, and I will file a follow-up bug so we can take a look at it later.
Comment on attachment 42681 [details]
Seems like a fine initial step for cleanup. r=me
(In reply to comment #1)
> Darin is likely to be at least a little disappointed in this patch since it is
> more conservative than some other options we discussed for this cleanup.
I'm pretty happy with it.
> I wrote code that would get
> rid of old Patterns and Gradients once something that is not a Pattern or
> Gradient is set, but a bunch of canvas pattern tests failed.
I'll play with that myself if I have some free time. It doesn't seem important to tackle it any time soon -- you can get on to the color space work!
Yay! Thanks Adele and Darin.
Fixed with r50614.
No Skia changes? :-\