This patch addresses a major performance issue with deferred canvas rendering in chrome. It was ...
12 years, 6 months ago
(2012-05-23 15:03:24 UTC)
#1
This patch addresses a major performance issue with deferred canvas rendering in
chrome. It was underperforming when dealing with canvas to canvas copies.
These operations were triggering a deferral flush because canvas to canvas
copies needed to execute immediately since there is no guarantee that the source
canvas will remain unchaged.
This patch solves the problem by flattening the source pixels, allowing the draw
operation to be deferred. In the current implementation of SkPictureRecord,
bitmap parameter are flattened by in find() regardless of whether or not the
bitmap is a duplicate of a previously recorded bitmap. that approach is
nedlessly expensive when the pixels data is included in the flattened bitmap.
To alleviate that problem a dictionary based on generationIDs is used to find
duplicates (only for bitmaps with flattened pixel data)
Not sure what different fixes/changes are in this CL. 1. How much does the CL ...
12 years, 6 months ago
(2012-05-23 18:59:22 UTC)
#2
Not sure what different fixes/changes are in this CL.
1. How much does the CL reduce if we made the 2nd parameter have a default value
of 'false'?
2. How much does the CL reduce if we changed bitmap to always have a pixelref
(i.e. remove the raw-ptr option)?
On 2012/05/23 18:59:22, reed1 wrote: > Not sure what different fixes/changes are in this CL. ...
12 years, 6 months ago
(2012-05-23 19:05:01 UTC)
#3
On 2012/05/23 18:59:22, reed1 wrote:
> Not sure what different fixes/changes are in this CL.
>
> 1. How much does the CL reduce if we made the 2nd parameter have a default
value
> of 'false'?
Second parameter of what?
> 2. How much does the CL reduce if we changed bitmap to always have a pixelref
> (i.e. remove the raw-ptr option)?
As far as the use case of HTML 2d canvases is concerned, the raw-ptr option does
not come into play.
On 2012/05/23 19:05:01, junov1 wrote: > On 2012/05/23 18:59:22, reed1 wrote: > > Not sure ...
12 years, 6 months ago
(2012-05-24 18:01:07 UTC)
#4
On 2012/05/23 19:05:01, junov1 wrote:
> On 2012/05/23 18:59:22, reed1 wrote:
> > Not sure what different fixes/changes are in this CL.
> >
> > 1. How much does the CL reduce if we made the 2nd parameter have a default
> value
> > of 'false'?
>
> Second parameter of what?
Sorry for not being clearer. 2nd parameter to SkBitmap::flatten()
>
> > 2. How much does the CL reduce if we changed bitmap to always have a
pixelref
> > (i.e. remove the raw-ptr option)?
>
> As far as the use case of HTML 2d canvases is concerned, the raw-ptr option
does
> not come into play.
I was asking, thinking that much of the work in pictures was *because* we had
raw pixel pointers to deal with. Maybe I'm misreading the CL. Is the work solely
motivated by mutable bitmaps that *do* have a real pixelref?
On 2012/05/24 18:01:07, reed1 wrote: > On 2012/05/23 19:05:01, junov1 wrote: > > On 2012/05/23 ...
12 years, 6 months ago
(2012-05-24 18:49:34 UTC)
#5
On 2012/05/24 18:01:07, reed1 wrote:
> On 2012/05/23 19:05:01, junov1 wrote:
> > On 2012/05/23 18:59:22, reed1 wrote:
> > > Not sure what different fixes/changes are in this CL.
> > >
> > > 1. How much does the CL reduce if we made the 2nd parameter have a default
> > value
> > > of 'false'?
> >
> > Second parameter of what?
>
> Sorry for not being clearer. 2nd parameter to SkBitmap::flatten()
Ah, ok, that makes sense, also that would avoid potential API compatibility
breakage (if anyone on the outside calls flatten directly?)
>
> >
> > > 2. How much does the CL reduce if we changed bitmap to always have a
> pixelref
> > > (i.e. remove the raw-ptr option)?
> >
> > As far as the use case of HTML 2d canvases is concerned, the raw-ptr option
> does
> > not come into play.
>
> I was asking, thinking that much of the work in pictures was *because* we had
> raw pixel pointers to deal with. Maybe I'm misreading the CL. Is the work
solely
> motivated by mutable bitmaps that *do* have a real pixelref?
Exactly, mutable bitmaps that have a pixelref. The particular use case I am
optimizing is canvas to canvas copies where the source canvas has its pixels in
an SkMallocPixelRef. This has nothing to do with the recent e-mail thread where
we were discussing SkPicture having problems with raw-ptr bitmaps.
Might it make sense to add kFlattenMutableBitmaps_Flag to SkFlattenableWriteBuffer, rather than adding a parameter to ...
12 years, 6 months ago
(2012-05-24 19:28:54 UTC)
#7
Might it make sense to add kFlattenMutableBitmaps_Flag to
SkFlattenableWriteBuffer, rather than adding a parameter to SkBitmap::flatten?
Not sure, but we do have flags in the buffer already to inform our objects on
how to behave during flattening.
On Thu, May 24, 2012 at 3:28 PM, <reed@google.com> wrote: > Might it make sense ...
12 years, 6 months ago
(2012-05-24 19:54:30 UTC)
#8
On Thu, May 24, 2012 at 3:28 PM, <reed@google.com> wrote:
> Might it make sense to add kFlattenMutableBitmaps_Flag to
> SkFlattenableWriteBuffer, rather than adding a parameter to
> SkBitmap::flatten? Not sure, but we do have flags in the buffer already
> to inform our objects on how to behave during flattening.
>
>
Hmmm... That does look like a good place to put it.
And then I could put the logic in
SkFlattenableWriteBuffer::persistBitmapPixels. I think that makes for a
simpler CL. I will try it out.
>
>
http://codereview.appspot.com/**6221066/<http://codereview.appspot.com/6221066/>
>
On 2012/05/24 19:28:54, reed1 wrote: > Might it make sense to add kFlattenMutableBitmaps_Flag to > ...
12 years, 6 months ago
(2012-05-25 15:01:31 UTC)
#9
On 2012/05/24 19:28:54, reed1 wrote:
> Might it make sense to add kFlattenMutableBitmaps_Flag to
> SkFlattenableWriteBuffer, rather than adding a parameter to SkBitmap::flatten?
Done in patch 4.
12 years, 6 months ago
(2012-06-01 17:41:08 UTC)
#14
http://codereview.appspot.com/6221066/diff/17001/src/core/SkPictureRecord.h
File src/core/SkPictureRecord.h (right):
http://codereview.appspot.com/6221066/diff/17001/src/core/SkPictureRecord.h#n...
src/core/SkPictureRecord.h:100: uint32_t fKey; // SkPixelRef GenerationID.
Didn't notice this before.
In general skia only uses size_t for number-of-bytes parameters, and int for
indices. In this case, using int (or explicitly int32_t or uint32_t) might be
nice to keep this struct explicitly packed to 64bits, since we have to allocate
an array of these. Also the pow-2 means (trivially) array indexing can be shifts
instead of multiplies.
other than that, lgtm
Issue 6221066: Adding option to serialize mutable bitmaps in SkPicture
(Closed)
Created 12 years, 6 months ago by junov1
Modified 12 years, 5 months ago
Reviewers: reed1
Base URL: http://skia.googlecode.com/svn/trunk/
Comments: 6