[Webkit-unassigned] [Bug 106842] adding support for DiscardablePixelRef for caching lazily decoded images

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jan 17 23:47:35 PST 2013


https://bugs.webkit.org/show_bug.cgi?id=106842





--- Comment #24 from Hin-Chung Lam <hclam at google.com>  2013-01-17 23:49:21 PST ---
(In reply to comment #23)
> This actually confused me for a while too. Let me attempt to explain as I got to understanding it.... maybe the way I understand this isn't how the patch panned out, but its what I have in my head:
> 
> 1. WebCore paint inserts SkBitmaps(LazyPixelRef) into the deferred canvas
> 2. When we rasterize the canvas, we discover lazy pixel ref and go find its CacheEntries. Recall, there may be multiple, because each CacheEntry is for a different decode/resize scale.
> 
> Thus, you may have the following situation for a single bitmap inserted into the deferred canvas:
> 
>    foo.png <Lazy, raw size 512x512>
>        CacheEntry:  foo.png <decoded to 128x128, then scaled to 100x100>
>        CacheEntry:  foo.png <decoded to 512x512, not scaled>
> 
> 
> The cache entry need to store each decoded bitmap data, plus its size/stride/blahblah. So, void* plus a bunch of fields... instead of duplicating those fields, we use a SkBitmap.
> 
> Since this cache entry bitmap is the one omnomnoming at memory, its the one we want to die a violent death under memory pressure. So, we replace the SkBitmap-backed-by-void* with a SkBitmap-backed-by-a-WebDiscardable. In an 2D api that used subclassing, the cache entry would have a SkDiscardableBitmap and it'd be easier to grok.

Pretty much!

Here's another view:

As recorded the relationship of classes:

SkPicture -> SkBitmap -> SkPixelRef (LazyDecodingPixelRef)

When rasterizing LazyDecodingPixelRef, it goes like this:

LazyDecodingPixelRef -> ImageDecodingStore -> CacheEntry -> ScaledImageFragment -> (*) SkBitmap (actually carry the decoded bits)

We would like to make the SkBitmap, marked by (*) as discardable on capable platforms. So we replace the guts of (*) SkBitmap such that it contains:

(*) SkBitmap -> DiscardablePixelRef -> WebDiscardable

In the non-discardable case (i.e. normal case), SkBitmap has the following content:

(*) SkBitmap -> SkMallocPixelRef -> void* (a piece of memory)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list