DescriptionWe want to give SkPixelRef a way to signal over to GrResourceCache that it's become pointless to keep around textures based on that SkPixelRef when its pixels change, so that it can be a good citizen and free those textures.
This adds an invalidation listener mechanism to SkPixelRef to let it send this message while still staying ignorant of who's listening.
These messages are tricky to deliver. The SkPixelRefs they originates from and the GrResourceCaches they ultimately end up at may be on different threads; neither class is threadsafe; their object lifetimes are totally independent; it's a many-senders-to-many-receivers relation; and neither codebase should really know about the other.
So I've added a per-message-type global message bus to broadcast messages to threadsafe inboxes. Anyone can post() a message, which will show up in all the inboxes of that type, read whenever the inbox's owner calls poll(). The implementation is _dumb_; it can be improved in several dimensions (inbox size limits, lock-free message delivery) if we find the need.
I took some care to make sure not to send the invalidation message for any SkPixelRef that's sharing a generation ID with another SkPixelRef.
BUG=
Committed: http://code.google.com/p/skia/source/detail?r=11949
Patch Set 1 #Patch Set 2 : add (C) #Patch Set 3 : sync #Patch Set 4 : reup #Patch Set 5 : gist #Patch Set 6 : reup #Patch Set 7 : reup #Patch Set 8 : tweak #Patch Set 9 : reupload #Patch Set 10 : actually purge #Patch Set 11 : reupload #Patch Set 12 : back to friend #Patch Set 13 : reup #Patch Set 14 : wip #Patch Set 15 : sync #Patch Set 16 : sync #Patch Set 17 : reupload #Patch Set 18 : reup #Patch Set 19 : reup #Patch Set 20 : gm ok #Patch Set 21 : reup #Patch Set 22 : simplify listener api #Patch Set 23 : factoring #Patch Set 24 : fix subtly broken test #Patch Set 25 : add test, tweak comments #Patch Set 26 : reup #Patch Set 27 : reup #Patch Set 28 : missing word #Patch Set 29 : tweaks #
Total comments: 43
Patch Set 30 : review changes #
Total comments: 6
Patch Set 31 : rename and update SkOnce #Patch Set 32 : drop the check #
Messages
Total messages: 13 (0 generated)
|