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

Issue 160103002: Work in progress to make SkShader immutable. (Closed)

Created:
6 years, 10 months ago by scroggo
Modified:
6 years, 8 months ago
Reviewers:
Dominik Grewe, reed1
CC:
skia-review_googlegroups.com
Base URL:
https://skia.googlesource.com/skia.git@master
Visibility:
Public.

Description

Work in progress to make SkShader immutable. Currently, SkShader is modified by each draw call. SkShader::setContext is called with information about the the current state (device, matrix paint). Each SkShader subclass caches information about that state, which is later used by the various flavors of shadeSpan (or a ShadeProc). In this CL, the caches are moved from the SkShader to a new object, called SkShader::Context. setContext, no longer a virtual function, now creates a Context. It then asks its subclass how much extra space is needed for drawing. It allocates (or places in existing storage) enough space for the subclass on the Context, and passes it to the subclass via onSetContext. The new virtual function onSetContext does the work of the old setContext, only it places its subclass specific info on the Context. Now, each version of shadeSpan takes the Context as a parameter, so the SkShader can get its cached information for drawing. endContext now takes the Context as a parameter (and deletes it). The Context is stored on the SkBlitter, which takes care of passing it to each shadeSpan and finally calling endContext. BUG=skia:1976

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+264 lines, -121 lines) Patch
M include/core/SkComposeShader.h View 2 chunks +8 lines, -5 lines 0 comments Download
M include/core/SkShader.h View 3 chunks +113 lines, -30 lines 0 comments Download
M src/core/SkBlitter.cpp View 8 chunks +29 lines, -16 lines 0 comments Download
M src/core/SkBlitter_ARGB32.cpp View 16 chunks +21 lines, -19 lines 0 comments Download
M src/core/SkComposeShader.cpp View 5 chunks +46 lines, -24 lines 0 comments Download
M src/core/SkShader.cpp View 7 chunks +47 lines, -27 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
scroggo
This doesn't build yet (an earlier version did, which included lots of similar changes for ...
6 years, 10 months ago (2014-02-11 22:01:21 UTC) #1
Dominik Grewe
On 2014/02/11 22:01:21, scroggo wrote: > The current approach (more details in the CL itself...) ...
6 years, 10 months ago (2014-02-12 12:24:56 UTC) #2
Dominik Grewe
What about this? Use Context subclasses, so each subclass of SkShader returns the correct type ...
6 years, 10 months ago (2014-02-14 12:31:30 UTC) #3
scroggo
On 2014/02/14 12:31:30, Dominik Grewe wrote: > What about this? > Use Context subclasses, so ...
6 years, 10 months ago (2014-02-14 14:59:48 UTC) #4
scroggo
On 2014/02/14 14:59:48, scroggo wrote: > On 2014/02/14 12:31:30, Dominik Grewe wrote: > > What ...
6 years, 9 months ago (2014-03-06 19:28:34 UTC) #5
Dominik Grewe
Yeah, I guess it's not any simpler than what we had before. And with your ...
6 years, 9 months ago (2014-03-07 15:52:24 UTC) #6
scroggo
On 2014/03/07 15:52:24, Dominik Grewe wrote: > Yeah, I guess it's not any simpler than ...
6 years, 9 months ago (2014-03-13 21:29:32 UTC) #7
scroggo
6 years, 8 months ago (2014-04-17 14:12:06 UTC) #8
On 2014/03/13 21:29:32, scroggo wrote:
> On 2014/03/07 15:52:24, Dominik Grewe wrote:
> > Yeah, I guess it's not any simpler than what we had before. And with your
> > initial version we can at least avoid the extra copy and the awkwardness of
> > context being neither a proper class nor a struct.
> > 
> > I'm still not very keen on all of this manual memory management, but I can't
> see
> > an alternative that wouldn't add overhead or may create uninitialized
context
> > objects (though you can argue that the extra context data in fStorage is
> > uninitialized if something fails...).
> 
> I've been working on this some more, and I'm beginning to agree with you on
> using
> subclasses. The problem we need to solve is being able to fail on bad data. So
> I'm
> going to pull that out into a separate function, which gets called first. If
the
> data won't work, then we can create the context, which should always succeed.
I
> have the beginnings of a CL up at https://codereview.chromium.org/198193005.

Replaced with https://codereview.chromium.org/207683004/

Powered by Google App Engine
This is Rietveld 408576698