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

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

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

Description

Work (in progress) to make SkShader immutable. Rename SkShader to SkShaderGenerator (not positive we should stick with the new name, but it's a better way to think about the way it works now). The object will eventually be immutable, and it will create the object that does the work at draw time: a ShaderImpl. Replace setContext with a series of calls: validContext() - returns false if the old setContext call would have. shaderImplSize() - returns the size needed by the SkShader subclass. createShaderImpl() - return a new ShaderImpl object, which holds many of the functions that were previously on SkShader. This should always succeed if validContext() returned true (I think... need to look at all shaders just in case). It has a const reference to the SkShaderGenerator, so data need not be duplicated between the two. createShaderImpl will place the new object in storage provided by an SkSmallAllocator, in general. BUG=skia:1976

Patch Set 1 #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+552 lines, -421 lines) Patch
M include/core/SkColorShader.h View 2 chunks +33 lines, -17 lines 0 comments Download
M include/core/SkComposeShader.h View 3 chunks +29 lines, -9 lines 0 comments Download
M include/core/SkEmptyShader.h View 2 chunks +14 lines, -11 lines 0 comments Download
M include/core/SkShader.h View 7 chunks +110 lines, -87 lines 0 comments Download
M src/core/SkBitmapProcShader.h View 1 chunk +2 lines, -2 lines 0 comments Download
M src/core/SkBlitter.cpp View 9 chunks +146 lines, -104 lines 0 comments Download
M src/core/SkBlitter_A8.cpp View 4 chunks +9 lines, -8 lines 0 comments Download
M src/core/SkBlitter_ARGB32.cpp View 23 chunks +28 lines, -30 lines 0 comments Download
M src/core/SkBlitter_RGB16.cpp View 19 chunks +40 lines, -37 lines 0 comments Download
M src/core/SkComposeShader.cpp View 6 chunks +56 lines, -30 lines 0 comments Download
M src/core/SkCoreBlitters.h View 4 chunks +9 lines, -5 lines 0 comments Download
M src/core/SkShader.cpp View 10 chunks +76 lines, -81 lines 5 comments Download

Messages

Total messages: 7 (0 generated)
Dominik Grewe
I really prefer this to what we had before. I'm wondering if we can make ...
6 years, 9 months ago (2014-03-14 16:00:40 UTC) #1
scroggo
https://codereview.chromium.org/198193005/diff/1/src/core/SkShader.cpp File src/core/SkShader.cpp (right): https://codereview.chromium.org/198193005/diff/1/src/core/SkShader.cpp#newcode53 src/core/SkShader.cpp:53: fTotalInverseClass = (uint8_t)ComputeMatrixClass(fTotalInverse); On 2014/03/14 16:00:40, Dominik Grewe wrote: ...
6 years, 9 months ago (2014-03-17 15:11:56 UTC) #2
Dominik Grewe
I looked into SkBitmapProcShader. Afaict we can use a similar method there, but validation is ...
6 years, 9 months ago (2014-03-17 16:07:07 UTC) #3
scroggo
On 2014/03/17 16:07:07, Dominik Grewe wrote: > I looked into SkBitmapProcShader. Afaict we can use ...
6 years, 9 months ago (2014-03-19 05:01:01 UTC) #4
Dominik Grewe
On 2014/03/19 05:01:01, scroggo wrote: > On 2014/03/17 16:07:07, Dominik Grewe wrote: > > I ...
6 years, 9 months ago (2014-03-19 09:54:27 UTC) #5
Dominik Grewe
On 2014/03/19 09:54:27, Dominik Grewe wrote: > On 2014/03/19 05:01:01, scroggo wrote: > > On ...
6 years, 9 months ago (2014-03-19 15:06:57 UTC) #6
scroggo
6 years, 8 months ago (2014-04-17 14:11:45 UTC) #7
On 2014/03/19 15:06:57, Dominik Grewe wrote:
> On 2014/03/19 09:54:27, Dominik Grewe wrote:
> > On 2014/03/19 05:01:01, scroggo wrote:
> > > On 2014/03/17 16:07:07, Dominik Grewe wrote:
> > > > I looked into SkBitmapProcShader. Afaict we can use a similar method
> there,
> > > but
> > > > validation is quite complex. Hopefully not too expensive... I think we'd
> > have
> > > to
> > > > create a temporary SkBitmapProcState and try setting it up via
chooseProcs
> > > > (possibly we can have a more light-weight validation method that only
does
> > as
> > > > much setup as needed to verify the parameters).
> > > 
> > > If we allow createShaderImpl to return NULL even if validation fails,
> > > SkBitmapProcShader
> > > won't need any major changes.
> > 
> > But where would you store the SkBitmapProcState? If it's part of the
> ShaderImpl
> > you may end up with a half-constructed object (just what we're trying to
> avoid).
> > The only other option I see is to allocate a separate object on the stack
> inside
> > createShaderImpl and copy that, if created successfully, into ShaderImpl
> (would
> > require a deep copy or passing ownership of pointers).
> 
> Or are you okay with half-constructed objects as long as they're never
returned?
> That would certainly simplify the code a lot and it would avoid having to
> recompute things.

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

Powered by Google App Engine
This is Rietveld 408576698