Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Issue 26734003: Proactive SkPixelRef invalidation (Closed)

Created:
7 years, 2 months ago by mtklein
Modified:
7 years, 2 months ago
Reviewers:
scroggo, bsalomon, reed1
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

We 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+381 lines, -17 lines) Patch
M gyp/core.gypi View 1 chunk +1 line, -0 lines 0 comments Download
M gyp/tests.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 2 chunks +2 lines, -0 lines 0 comments Download
M include/core/SkPixelRef.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 5 chunks +28 lines, -4 lines 0 comments Download
M include/gpu/GrContext.h View 1 2 3 4 1 chunk +4 lines, -1 line 0 comments Download
M src/core/SkBitmap.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 chunks +7 lines, -4 lines 0 comments Download
A src/core/SkMessageBus.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +115 lines, -0 lines 0 comments Download
M src/core/SkPixelRef.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 4 chunks +43 lines, -4 lines 0 comments Download
M src/gpu/GrContext.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 2 chunks +6 lines, -1 line 0 comments Download
M src/gpu/GrResourceCache.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 3 chunks +10 lines, -0 lines 0 comments Download
M src/gpu/GrResourceCache.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 2 chunks +21 lines, -0 lines 0 comments Download
M src/gpu/SkGr.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 4 chunks +38 lines, -3 lines 0 comments Download
A tests/MessageBusTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 1 chunk +57 lines, -0 lines 0 comments Download
A tests/PixelRefTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 chunk +49 lines, -0 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
mtklein
I've got the gist of this working again. Can you take a look at this ...
7 years, 2 months ago (2013-10-17 19:52:41 UTC) #1
bsalomon
On 2013/10/17 19:52:41, mtklein wrote: > I've got the gist of this working again. Can ...
7 years, 2 months ago (2013-10-17 20:24:34 UTC) #2
mtklein
On 2013/10/17 20:24:34, bsalomon wrote: > On 2013/10/17 19:52:41, mtklein wrote: > > I've got ...
7 years, 2 months ago (2013-10-17 20:26:41 UTC) #3
mtklein
7 years, 2 months ago (2013-10-22 19:19:54 UTC) #4
scroggo
https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h File include/core/SkPixelRef.h (right): https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h#newcode214 include/core/SkPixelRef.h:214: // This can be used to invalidate caches keyed ...
7 years, 2 months ago (2013-10-22 21:04:01 UTC) #5
bsalomon
https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h File include/core/SkPixelRef.h (right): https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h#newcode224 include/core/SkPixelRef.h:224: bool addingAnInvalidationListenerMakesSense() const { return fUniqueGenerationID; } MakesSense seems ...
7 years, 2 months ago (2013-10-23 13:52:57 UTC) #6
mtklein
https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h File include/core/SkPixelRef.h (right): https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h#newcode214 include/core/SkPixelRef.h:214: // This can be used to invalidate caches keyed ...
7 years, 2 months ago (2013-10-23 15:28:09 UTC) #7
bsalomon
lgtm https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h File include/core/SkPixelRef.h (right): https://codereview.chromium.org/26734003/diff/466001/include/core/SkPixelRef.h#newcode280 include/core/SkPixelRef.h:280: void invalidate(); On 2013/10/23 15:28:10, mtklein wrote: > ...
7 years, 2 months ago (2013-10-23 15:32:27 UTC) #8
scroggo
https://codereview.chromium.org/26734003/diff/466001/src/core/SkBitmap.cpp File src/core/SkBitmap.cpp (right): https://codereview.chromium.org/26734003/diff/466001/src/core/SkBitmap.cpp#newcode1059 src/core/SkBitmap.cpp:1059: dst->pixelRef()->cloneGenID(*fPixelRef); On 2013/10/23 15:28:10, mtklein wrote: > On 2013/10/23 ...
7 years, 2 months ago (2013-10-23 15:39:19 UTC) #9
mtklein
https://codereview.chromium.org/26734003/diff/466001/src/core/SkBitmap.cpp File src/core/SkBitmap.cpp (right): https://codereview.chromium.org/26734003/diff/466001/src/core/SkBitmap.cpp#newcode1059 src/core/SkBitmap.cpp:1059: dst->pixelRef()->cloneGenID(*fPixelRef); On 2013/10/23 15:39:19, scroggo wrote: > On 2013/10/23 ...
7 years, 2 months ago (2013-10-23 16:07:09 UTC) #10
scroggo
lgtm
7 years, 2 months ago (2013-10-23 16:10:59 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/mtklein@google.com/26734003/706001
7 years, 2 months ago (2013-10-24 16:14:48 UTC) #12
commit-bot: I haz the power
7 years, 2 months ago (2013-10-24 17:44:39 UTC) #13
Message was sent while issue was closed.
Change committed as 11949

Powered by Google App Engine
This is Rietveld 408576698