Commit Graph

9852 Commits

Author SHA1 Message Date
Robert Phillips
17dc658f29 Move Software and Small PathRenderers to skgpu::v1 namespace
Bug: skia:11837
Change-Id: Ia34f1840aaa7360ea9a3ca40fef5cb96b68c6ca3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439781
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-17 16:52:47 +00:00
John Stiles
059798f40e Test that Runtime Effects cannot use non-ES2 types.
Surprisingly, we didn't actually have a preexisting test covering this.
Error reporting is lackluster in this CL but will be improved in the
followup.

Change-Id: I0b1cdb5a82f066af6b9d3fd9c39748080c2e18c0
Bug: skia:12348
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439996
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-17 15:10:02 +00:00
Brian Salomon
3dbd159d09 Fix a couple Wshadow warnings
Change-Id: I04da5871c668b1ed9ca8db7fdcbfe06a70ee227f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/440079
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-17 15:09:14 +00:00
Robert Phillips
168296b5a2 Reroute SurfaceContext factories through RecordingContextPriv
Bug: skia:11837
Change-Id: Ib00ccc78d6394ad85781dc1de090c2fe0e83c01f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439736
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-17 13:36:57 +00:00
Brian Osman
eb0f29dba2 SkSL: Allow invoking children (shaders, etc) like functions
Previously, you would declare child objects (shaders, colorFilters, etc.)
and "sample" them like this:

    uniform shader input;
    uniform colorFilter filter;
    half4 main(float2 coord) {
        half4 inColor = sample(input, coord);
        return sample(filter, inColor);
    }

With the new syntax, those child objects become directly callable,
reflecting the way that Skia assembles all parts of the paint (as functions)
in the overall fragment shader:

    uniform shader input;
    uniform colorFilter filter;
    half4 main(float2 coord) {
        half4 inColor = input(coord);
        return filter(inColor);
    }

Bug: skia:12302
Change-Id: Ia12351964dc5d2300660187933188e738671cd83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436517
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-16 14:52:51 +00:00
John Stiles
c18ee4e55a Honor component type in Metal matrix helper functions.
Right now, Metal forces types to full precision. The matrix helper
functions previously baked in that assumption by hard-coding "floatX".
Now, they honor the component type; if this->typeName() started
returning "half", our helper functions would be named with "halfX". This
would allow half-precision and full-precision helpers to coexist.

Change-Id: I1679e6e76d2cf3c27fd69c42a92fb24bff6b69ec
Bug: skia:12339
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439396
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-08-16 14:34:15 +00:00
Greg Daniel
e56d31fd56 Update LazySurfaceDesc to take a GrTextureType.
Bug: skia:12342
Change-Id: Ic57f3f30bc7d0a9d932eb4ac1c28b87b3b544ce4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439282
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-08-16 14:17:58 +00:00
Greg Daniel
0e9d34d33c Reland "Remove GrBackendFormat's textureType use from isFormatTexturable call."
This reverts commit d90777ada3.

Reason for revert: relanding with fix to GrBackendTexture

Original change's description:
> Revert "Remove GrBackendFormat's textureType use from isFormatTexturable call."
>
> This reverts commit 832c817bc8.
>
> Reason for revert: uninitialized value in GrBackendTexture
>
> Original change's description:
> > Remove GrBackendFormat's textureType use from isFormatTexturable call.
> >
> > The goal of this change was to remove the use of GrBackendFormat::textureType()
> > from GrCaps::isFormatTexturable call. Instead we will always pass in a
> > GrTextureType into this call.
> >
> > To do this a lot of plumbing of GrTextureType was added to various call
> > sites. However, this CL halts the plubming up at the proxy level where we
> > get it from the GrBackendFormat still. Future CLs will continue removing
> > these call sites and others that use GrBackendFormat::textureType().
> >
> > Bug: skia:12342
> > Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: I354bbbf00be7a86c480009f3e7b36a8777a6bf3a
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:12342
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439338
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:12342
Change-Id: I151196f149f9e191d2975b8fe81334f4f8720744
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439339
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-08-13 22:37:13 +00:00
Ethan Nicholas
4a5e22a8c8 Further unified error handling between SkSL and DSL
This eliminates the SkSL ErrorReporter class and funnels everything
through the DSL ErrorHandler. Since the DSL error handler can be
changed, this required a number of updates to ensure that things work
properly in the face of custom error handlers. There is probably more
work to be done in that area, but this at least passes all existing
tests.

Change-Id: Iaee27b79fc4ed426c484ccab257c09d28619ead5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438116
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-13 22:26:10 +00:00
John Stiles
1049d82061 Add ES3 Angle and Trigonometry methods to sksl_public.
This adds sinh, cosh, tanh, asinh, acosh, and atanh. We now also support
compile-time optimization for the arc functions.

Change-Id: I688f579b50403db534622b82926aa20d1f445341
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439319
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-13 20:57:44 +00:00
Greg Daniel
d90777ada3 Revert "Remove GrBackendFormat's textureType use from isFormatTexturable call."
This reverts commit 832c817bc8.

Reason for revert: uninitialized value in GrBackendTexture

Original change's description:
> Remove GrBackendFormat's textureType use from isFormatTexturable call.
>
> The goal of this change was to remove the use of GrBackendFormat::textureType()
> from GrCaps::isFormatTexturable call. Instead we will always pass in a
> GrTextureType into this call.
>
> To do this a lot of plumbing of GrTextureType was added to various call
> sites. However, this CL halts the plubming up at the proxy level where we
> get it from the GrBackendFormat still. Future CLs will continue removing
> these call sites and others that use GrBackendFormat::textureType().
>
> Bug: skia:12342
> Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I354bbbf00be7a86c480009f3e7b36a8777a6bf3a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439338
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-08-13 20:05:32 +00:00
Greg Daniel
832c817bc8 Remove GrBackendFormat's textureType use from isFormatTexturable call.
The goal of this change was to remove the use of GrBackendFormat::textureType()
from GrCaps::isFormatTexturable call. Instead we will always pass in a
GrTextureType into this call.

To do this a lot of plumbing of GrTextureType was added to various call
sites. However, this CL halts the plubming up at the proxy level where we
get it from the GrBackendFormat still. Future CLs will continue removing
these call sites and others that use GrBackendFormat::textureType().

Bug: skia:12342
Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-08-13 19:03:21 +00:00
John Stiles
4e2494870d Allow derivatives in Runtime Effects when ES3 restrictions are off.
We can now add functions to sksl_public.sksl with an $es3 prefix. These
will be allowed in a Runtime Effect when strict-ES2 mode is disabled.
Note that the CPU backend still doesn't have support for these calls,
and will fail ungracefully (assertion, nonsense result) if these
intrinsics are used.

The testing here is limited, due to an unrelated bug in SPIR-V
(skia:12340)

Change-Id: I9c911bc2b77f5051e80844607e7fd08ad386ee56
Bug: skia:12202, skia:12340
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439058
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-13 16:45:17 +00:00
John Stiles
fa088a665c Fix additional cases of variable shadowing in /tests/.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: Ia92c86a902acc6864f3252431faeb157628b509e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439156
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-08-13 16:13:27 +00:00
Michael Ludwig
68e4e20fae Add unit test to cover incorrect image filter layer bounds bug
Pulls the matrix and layer bounds from the captured skp that was
originally clipped, and asserts that both SkMatrix and SkM44's
separate mapRect functions don't regress.

Bug: skia:12335
Change-Id: I092d60b8a38fcd3cb70a8123802d730644cffda1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439276
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
2021-08-13 14:25:14 +00:00
John Stiles
efde90d973 Add $es3 modifier to SkSL.
This modifier is currently allowed on built-in functions only.

The presence of this modifier will be used to indicate intrinsics which
are ES3-specific (and therefore, not allowed in user code under typical
circumstances).

Change-Id: Ice6be8d9d1b2bf0c8f07f2a89f335bb2f90f6681
Bug: skia:12202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439057
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-13 14:07:40 +00:00
John Stiles
b05f03db32 Increase baked-in offset of RTFlip in skslc.
The value of 32 was causing errors when other uniforms were present, as
the SPIR-V code generator would detect overlapping uniform offsets and
fail.

Change-Id: I7bb1cf1244e54c39596c3a39e9f6972c6a47899c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439059
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-12 21:04:45 +00:00
John Stiles
9765973380 Fix cases of variable shadowing in /tests/.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: Ib8b92275c5da71c4ee48540d434f3afdc45f4067
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438819
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
2021-08-12 16:11:39 +00:00
Robert Phillips
06273bcb8a Prepare headers for making all ops V1-only
Basically, ensure all the headers about to become V1-only only appear in contexts that are currently or will soon be V1-only.

This is almost all fallout from retracting some of the moving headers from other headers i.e.:

GrMeshDrawOp.h from GrOpFlushState.h
GrDrawOp.h from GrOpsRenderPass.h
GrDrawOp.h from GrOpsTask.h
GrSimpleMeshDrawOpHelper.h from GrTessellationShader.h


Bug: skia:11837
Change-Id: I939f5c82c3042e9ab00571b5796ab82dbe968085
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438677
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-12 15:09:11 +00:00
Michael Ludwig
423990db1b Decrease w epsilon to avoid incorrect bounds calculations
Bug: skia:12335
Change-Id: I0106c30d875a7a88431a6e068a82d2d987fc62b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438738
Commit-Queue: Florin Malita <fmalita@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
2021-08-12 13:19:39 +00:00
Brian Osman
50fe857dd3 Revert "In SkCanvas destructor, discard (rather than blit) unbalanced layers"
This reverts commit 879b2f2e6e.

Reason for revert: UAF

Original change's description:
> In SkCanvas destructor, discard (rather than blit) unbalanced layers
>
> Bug: skia:12267
> Change-Id: I6808f62b2385a3466b1a93db905041a6529f58cb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433360
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Florin Malita <fmalita@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Mike Reed <reed@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: skia:12267
Change-Id: I616e6c65c1eb3b6d3f67b2dde6be3db4de6db18a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438739
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-08-12 02:22:14 +00:00
John Stiles
b7f2215bbb Fix cases of variable shadowing in test code.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: I571931e01b0b95d85a7b566fc785ac219e8e731f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438697
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-11 20:38:09 +00:00
John Stiles
8a412325c4 Split up Codec 'check' into multiple helper functions.
This function was already divided into several different tests, but each
part relied on various bits and pieces from the others. This CL splits
it apart into smaller functions which should be easier to reason about.

This CL also fixes a handful of variable shadowing issues in the code.

Change-Id: Icfe189ae5fdf29913c1d94a6b5df9432442d648c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438658
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2021-08-11 20:04:43 +00:00
Brian Salomon
4895946078 Move ProgramImpl definitions into Processor subclass headers.
Move ProgramImpl function definitions into Processor subclass cpp files.

Delete separate h/cpp files.

Modify GrGLSLVaryingHandler::addPassThroughAttribute to break #include
cycle. It now takes a ShaderVar rather than a GP::Attribute, making
it slightly more flexible as the input can be any variable defined
in the vertex shader.

Bug: skia:11358
Change-Id: I94ee8cd44d29e194216592ecae5fd28de785c975
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438596
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-11 19:45:56 +00:00
Brian Salomon
bab2d11891 Improve consistency of GP::ProgramImpl subclasses
Named "Impl" and nested in GP or makeProgramImpl definition.

Remove unused INHERITED typedefs.

Remove GenKey pattern.

Bug: skia:11358
Change-Id: Icb4d5a0844184f51d92135de6cee6f6e77f57a5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438478
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-11 16:52:09 +00:00
Herb Derby
f0efa1d8e7 Reland "Reland "uniform Ptr (UPtr) is a sub class of Ptr""
This is a reland of ea17e2499d

Original change's description:
> Reland "uniform Ptr (UPtr) is a sub class of Ptr"
>
> This is a reland of cef047a490
>
> Fix strides in SkVMTest to be the right size.
>
> Original change's description:
> > uniform Ptr (UPtr) is a sub class of Ptr
> >
> > A pointer for a Uniform (UPtr) is a sub type of a Ptr. Everywhere you
> > can use a Ptr a UPtr will work, but you can't use Ptr where you need
> > a UPtr. All the UPtr instructions uniformF, gather32, etc are expected
> > to be hoisted and therefore loaded only once. While the varyings
> > instructions like load32, etc. are expected to remain in the body
> > of the loop, and be evaluated each time through the loop.
> >
> > Change-Id: I4fe6458c2a4614872ed67cda1e81b05ea8a9e69e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436297
> > Commit-Queue: Herb Derby <herb@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Change-Id: I858fa1224452ec801b6186fede353849edc895b5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436564
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I774e710724c99a41d0d160e88a2b723f66e03861
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436821
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2021-08-11 16:42:10 +00:00
Robert Phillips
643f481b15 Cruft leftover from GrSurfaceContext hierarchy v1/v2 split
Non-substantive changes that didn't fit any earlier CL in the chain.

Bug: skia:11837
Change-Id: Ic9b7c05c014b03ab5b30532098fb8cd2da846d9a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/428958
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-11 14:17:49 +00:00
Brian Salomon
b25560a1e1 Consistency among GrFP::ProgramImpl subclasses
Remove GL or GLSL from names of subclasses. Make nearly all subclasses
nested either in FP class or its onMakeProgramImpl() function.

Make onSetData private rather than protected.

Remove unused INHERITED typedefs.

Embrace idea that Impl is part of FP private implementation:
direct member access rather than getters and no GenKey pattern.

Other random consistency updates, modernatizations, stylistic changes.

Bug: skia:11358
Change-Id: I0d94e00a146abdd38e094ca550fc3b9608bd433d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438056
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-11 13:59:46 +00:00
John Stiles
adb3eac15c Add tests for array assignment with narrowing conversions.
An assignment like `mediump int a[2] = myHighpIntArray;` should succeed
now that the previous CLs have landed; originally, this would have
caused a type-mismatch error.

Change-Id: I86ffe6a21d0c7fbe289eef95aebc2605412566aa
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437740
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-11 12:56:40 +00:00
John Stiles
26487162fe Add support for array-cast syntax in SkSL.
Compiling a program with "allow narrowing conversions" actually fixes up
narrowing casts in the program by inserting casts wherever they would be
needed for type-correctness. For instance, compiling the statement
    `half h = myFloat;`
inserts an appropriate narrowing cast:
    `half h = half(myFloat);`.

The Pipeline stage code generator relies on this behavior, as when it
re-emits a runtime effect into a complete SkSL program, the narrowing-
conversions flag will no longer be set, but that is okay, because the
emitted code now contains typecasts anywhere they would be necessary.

Logically, this implies that anything which supports narrowing
conversions must be castable between high and low precision. In GLSL and
SPIR-V, such a cast is trivial, because the types are the same and the
precision qualifiers are treated as individual hints on each variable.
In Metal, we dodge the issue by only emitting full-precision types. But
we also need to emit raw SkSL from an SkSL program (that is what the
Pipeline stage generator does).

SkSL already supported every typical cast, but GLSL lacked any syntax
for casting an array to a different type. This meant SkSL had no array
casting syntax as well. SkSL now has array-cast syntax, but it is only
allowed for casting low/high-precision arrays to the same base type.
(You can't cast an int array to float, or a signed array to unsigned.)

Change-Id: Ia20933541c3bd4a946c1ea38209f93008acdb9cb
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437687
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-11 12:56:40 +00:00
Ethan Nicholas
57709e14e2 Added prototypes for DSLFunction
Previously, there was no way to create a forward declaration for a DSL
function. To avoid introducing new API and make this work in an
intuitive fashion, we now create prototypes for all DSL functions and
remove them when the function is promptly defined.

Change-Id: Ief36164ceb303a3d76a57dc073f2e9b8409bb45f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436562
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-10 21:16:01 +00:00
John Stiles
82d4c12dd9 Reland "Fix array-of-matrix/struct comparisons in Metal."
This is a reland of 23d8f94535

Original change's description:
> Fix array-of-matrix/struct comparisons in Metal.
>
> Metal needs helper functions in order to compare arrays, structs, and
> matrices. Depending on the input code, it was possible for the
> array-comparison helper to be emitted before a matrix-comparison
> or struct-comparison helper. If this occurred, array comparisons of that
> matrix or struct type would fail, because the operator== for the array's
> inner type was defined after array==, and Metal (like C++) parses
> top-to-bottom and only considers functions declared above the current
> function.
>
> We now emit prototypes for all the array, struct and matrix helper
> function. These prototypes are emitted above any helper functions. This
> ensures visibility no matter how your comparisons are organized.
>
> Change-Id: Ib3d8828c301fd0fa6c209788f9ea60800371edbe
> Bug: skia:12326
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437739
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12326
Change-Id: Ife68020f6b01fae973b97f76099c6d5e8215636c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438296
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-08-10 21:05:20 +00:00
Mike Reed
879b2f2e6e In SkCanvas destructor, discard (rather than blit) unbalanced layers
Bug: skia:12267
Change-Id: I6808f62b2385a3466b1a93db905041a6529f58cb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433360
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-08-10 20:27:10 +00:00
Robert Phillips
53eaa64873 Rename GrSurfaceContext -> skgpu::SurfaceContext
Almost entirely mechanical.

Bug: skia:11837
Change-Id: I984339097fdeeae2eccb6c1d790d510020511961
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438177
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-10 19:24:53 +00:00
John Stiles
e076c3803a Reland "Fix array-of-vector comparisons in Metal."
This reverts commit ef9a1b66d0.

Reason for revert: not broken after all

Original change's description:
> Revert "Fix array-of-vector comparisons in Metal."
>
> This reverts commit 130338c9e1.
>
> Reason for revert: SkSL_ArrayComparison test causes Adreno 630/640 to crash in Vulkan
>
> Original change's description:
> > Fix array-of-vector comparisons in Metal.
> >
> > Comparing `vec1 == vec2` returns a bvec in Metal, so the result must be
> > wrapped in `all()` in order to boil it down to a single boolean result.
> > Our array-comparison helper function did not do this. Fortunately,
> > `all(scalar)` is a no-op, so we can just wrap the result unilaterally.
> >
> > Change-Id: I4f1f09a6832164ae2e6577d53b317f561332d581
> > Bug: skia:12324
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437736
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: Ic76a5527a8339c8201f52df08d43041d7dcbeb61
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:12324
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438077
> Reviewed-by: John Stiles <johnstiles@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:12324
Change-Id: I3da699b8d1113800efb27e162d0c6315f0aeaa49
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438176
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-10 18:09:42 +00:00
John Stiles
7b2b858bef Avoid short/ushort in MSL code generator.
The Metal code generator has historically avoided low-precision types in
the final output in order to dodge a variety of type-coercion issues.
However, the workaround was only coded for half/float. Extended the
workaround to cover int/short and uint/ushort as well.

Change-Id: I16e3a387ba2baef1ef2de7742e1b0d27786fee0e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437688
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-10 18:08:25 +00:00
John Stiles
3c991fd72c Fix duplicated array types in SPIR-V.
Previously, SPIR-V would generate two separate SpvIds for array types if
they differed in SkSL, even if they matched in SPIR-V. For instance,
`half[10]` and `float[10]` are the same SPIR-V type, so they should
reuse the same SpvId. (The RelaxedPrecision decoration doesn't go on the
type.)

This is important because OpLoad and OpStore require the same SpvId on a
variable; you can't OpLoad from one type SpvId and OpStore to a
different type SpvId, even if the underlying type behind the SpvId is
the same.

(A slightly simpler fix exists at http://review.skia.org/437237, but
this triggered a memory pooling bug that I can't properly debug from
this machine.)

Change-Id: I7669a95a2c946dde1eeff73474a3a0fb9d180512
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437683
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-08-10 18:04:49 +00:00
Michael Ludwig
b23630c509 Reland "Remove SkTLList"
This reverts commit 14b1d56a2b.

Reason for revert: fix emplace_back() usage

Original change's description:
> Revert "Remove SkTLList"
>
> This reverts commit e1d523d70f.
>
> Reason for revert: breaking old stdlib versions (< c17)
>
> Original change's description:
> > Remove SkTLList
> >
> > Change-Id: I198678b5cb298cf51872fbb8d4fd5d705a6b684e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437339
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=brianosman@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: I8e02e4cd2f293e7530f842be783de10f69be2ef4
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438078
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

# Not skipping CQ checks because this is a reland.

Change-Id: Ied33ce81a8312963ff0713c4660cdb8541a02180
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438080
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-10 17:57:41 +00:00
Michael Ludwig
14b1d56a2b Revert "Remove SkTLList"
This reverts commit e1d523d70f.

Reason for revert: breaking old stdlib versions (< c17)

Original change's description:
> Remove SkTLList
>
> Change-Id: I198678b5cb298cf51872fbb8d4fd5d705a6b684e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437339
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=brianosman@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I8e02e4cd2f293e7530f842be783de10f69be2ef4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438078
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-10 14:53:52 +00:00
Brian Salomon
f95940bc23 Rename GrGLSLGeometryProcessor to GrGeometryProcessor::ProgramImpl
return from GrGP by unique_ptr, rename factory function to
makeProgramImpl()

Bug: skia:11358

Change-Id: I61dd36f770d2fc0b54de0e0e7b78ac4d3fbd119a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437741
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-10 14:36:40 +00:00
Michael Ludwig
e1d523d70f Remove SkTLList
Change-Id: I198678b5cb298cf51872fbb8d4fd5d705a6b684e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437339
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-10 14:36:07 +00:00
John Stiles
ef9a1b66d0 Revert "Fix array-of-vector comparisons in Metal."
This reverts commit 130338c9e1.

Reason for revert: SkSL_ArrayComparison test causes Adreno 630/640 to crash in Vulkan

Original change's description:
> Fix array-of-vector comparisons in Metal.
>
> Comparing `vec1 == vec2` returns a bvec in Metal, so the result must be
> wrapped in `all()` in order to boil it down to a single boolean result.
> Our array-comparison helper function did not do this. Fortunately,
> `all(scalar)` is a no-op, so we can just wrap the result unilaterally.
>
> Change-Id: I4f1f09a6832164ae2e6577d53b317f561332d581
> Bug: skia:12324
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437736
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: Ic76a5527a8339c8201f52df08d43041d7dcbeb61
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12324
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438077
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-10 14:31:30 +00:00
John Stiles
80c256e027 Revert "Fix array-of-matrix/struct comparisons in Metal."
This reverts commit 23d8f94535.

Reason for revert: SkSL_ArrayComparison test causes Adreno 630/640 to crash in Vulkan

Original change's description:
> Fix array-of-matrix/struct comparisons in Metal.
>
> Metal needs helper functions in order to compare arrays, structs, and
> matrices. Depending on the input code, it was possible for the
> array-comparison helper to be emitted before a matrix-comparison
> or struct-comparison helper. If this occurred, array comparisons of that
> matrix or struct type would fail, because the operator== for the array's
> inner type was defined after array==, and Metal (like C++) parses
> top-to-bottom and only considers functions declared above the current
> function.
>
> We now emit prototypes for all the array, struct and matrix helper
> function. These prototypes are emitted above any helper functions. This
> ensures visibility no matter how your comparisons are organized.
>
> Change-Id: Ib3d8828c301fd0fa6c209788f9ea60800371edbe
> Bug: skia:12326
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437739
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I9e0fc69c46e1b4f63133e21e130e527ca4f0b31a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12326
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/438076
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-10 14:30:55 +00:00
John Stiles
23d8f94535 Fix array-of-matrix/struct comparisons in Metal.
Metal needs helper functions in order to compare arrays, structs, and
matrices. Depending on the input code, it was possible for the
array-comparison helper to be emitted before a matrix-comparison
or struct-comparison helper. If this occurred, array comparisons of that
matrix or struct type would fail, because the operator== for the array's
inner type was defined after array==, and Metal (like C++) parses
top-to-bottom and only considers functions declared above the current
function.

We now emit prototypes for all the array, struct and matrix helper
function. These prototypes are emitted above any helper functions. This
ensures visibility no matter how your comparisons are organized.

Change-Id: Ib3d8828c301fd0fa6c209788f9ea60800371edbe
Bug: skia:12326
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437739
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-10 13:49:27 +00:00
John Stiles
130338c9e1 Fix array-of-vector comparisons in Metal.
Comparing `vec1 == vec2` returns a bvec in Metal, so the result must be
wrapped in `all()` in order to boil it down to a single boolean result.
Our array-comparison helper function did not do this. Fortunately,
`all(scalar)` is a no-op, so we can just wrap the result unilaterally.

Change-Id: I4f1f09a6832164ae2e6577d53b317f561332d581
Bug: skia:12324
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437736
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-10 13:44:44 +00:00
John Stiles
307f8f525a Simplify the boilerplate of cloning a fragment processor.
GrFragmentProcessor now provides an (explicit) copy constructor which
clones all child processors and flags from the passed-in FP. Since we no
longer have flags which propagate up to the root node of the FP tree,
all flags are now safe to copy, since a cloned FP also clones all of its
children.

Change-Id: Ia9f80e0ec540ed1056d25dbb1861a174a1d55f4b
Bug: skia:12299
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437836
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-08-09 20:36:14 +00:00
Michael Ludwig
e1d0040c54 Delete GrClipStackClip and GrReducedClip
Bug: skia:10205
Change-Id: Iafee804751d69e98241a7825664f3be04b20eb14
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436566
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-09 18:53:58 +00:00
Brian Salomon
3176e868c4 Rename GrGLSLFragmentProcessor to GrFragmentProcessor::ProgramImpl
Bug: skia:11358

Change-Id: Ic179ddd9d52dca3fc0bd85b61db49097390b7f58
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437681
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-09 17:43:59 +00:00
Mike Reed
22cada0a38 Clean up unflattening paints
Attempting reland after breaking G3
-- fixed by updating layerdrawlooper

Change-Id: I9013baae4ff2acad2040741ba53188d616f2920c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437679
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2021-08-09 17:43:37 +00:00
William Hesse
3c2461126b Fix rMoveTo to be relative to the start of a closed path
Other relative PathOps were fixed in
https://chromiumcodereview.appspot.com/22681006/

Fiddle: https://fiddle.skia.org/c/58ab5cfea29432c432ea7b467c1266ac
Bug: skia:1474
Change-Id: I6c3381087c81b2c28030c8158f5fa5662e5bfa7b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436477
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-09 14:59:14 +00:00
Robert Phillips
f76768d73c Revert "Clean up unflattening paints"
This reverts commit 717ef9472b.

Reason for revert: Blocking the G3 roll

Original change's description:
> Clean up unflattening paints
>
> Just removing legacy cruft for fonts, and also change to return by
> value (cleaner).
>
> Change-Id: If120931119c32542e06801da2b6d60ba84ba2186
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437676
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=bungeman@google.com,fmalita@chromium.org,reed@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: If735d0212412c0262a6ccb52e7dd224a255906cf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437678
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-09 14:06:25 +00:00
Brian Salomon
13b287386a Remove GLSL from name of functions that builds GrProcessor keys.
Bug: skia:11358
Change-Id: Ie70e45b18c12126c8e86700ad1040bc319be385a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436998
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-09 14:01:13 +00:00
Mike Reed
717ef9472b Clean up unflattening paints
Just removing legacy cruft for fonts, and also change to return by
value (cleaner).

Change-Id: If120931119c32542e06801da2b6d60ba84ba2186
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437676
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2021-08-09 13:26:22 +00:00
Michael Ludwig
a0438e6604 Remove SK_SUPPORT_DEPRECATED_CLIPOPS and expanding clip op defs
Bug: skia:10209
Change-Id: I72639b7e768742dcdec810a5a714ce21ff0f6e0a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436565
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-06 19:15:13 +00:00
Ethan Nicholas
a40ddcd63d Pass dsl::PositionInfo by value
We were previously using a mix of pass-by-value and pass-by-pointer (to
allow for explicitly null PositionInfo). Being able to pass a null
PositionInfo didn't really add much, since we can just use a nullary-
constructor PositionInfo instead, so these have all been migrated to
by-value.

Change-Id: Ia31e252cac94f64c4b38c29a54e6e7f752e70672
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437276
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-08-06 18:10:41 +00:00
Michael Ludwig
a3a67ae303 Reland "Avoid expanding clip ops in tests that will remain after feature removal"
This reverts commit b942d4b436.

Reason for revert: dependent cl no longer blocking android roll, so 
this can be relanded.

Original change's description:
> Revert "Avoid expanding clip ops in tests that will remain after feature removal"
>
> This reverts commit d1c51b2572.
>
> Reason for revert: blocking revert that might be breaking android
>
> Original change's description:
> > Avoid expanding clip ops in tests that will remain after feature removal
> >
> > Bug: skia:10208
> > Change-Id: I4fb2c8181bfb8cac3c8ab95c833094c98f8ee6fc
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436159
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
>
> TBR=robertphillips@google.com,reed@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: Ib62cc03f99793f8f1cb0180145b7557101a23ead
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10208
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436957
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:10208
Change-Id: Iff6e5b2b245426a76b92e895434613fe16ba717c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437277
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-06 17:07:31 +00:00
Michael Ludwig
d59d3e179d Reland "Add SkClipStack::replaceClip() separate from deprecated clip op"
This reverts commit 8ba1e71a1f.

Reason for revert: had missed a few places where GrReducedClip needed to
use the equivalent region op, not skClipOp + replace bool.

TBR=robertphillips@google.com,brianosman@google.com,csmartdalton@google.com

Original change's description:
> Revert "Add SkClipStack::replaceClip() separate from deprecated clip op"
>
> This reverts commit 68587ae274.
>
> Reason for revert: breaking path clipping tests in Android?
>
> Original change's description:
> > Add SkClipStack::replaceClip() separate from deprecated clip op
> >
> > The replaceClip functionality was added to allow Android to move off of
> > generalized expanding clips. At the time, SkClipStack simply used the
> > kReplace_SkClipOp to handle it. In order to remove those expanding ops,
> > SkClipStack will need a proper implementation of replaceClip().
> >
> > The clip elements have an additional field to mark if
> > it's a replace (and it's op will be kIntersect). Adds a temporary
> > getRegionOp() function to unify elements that use this field vs.
> > elements that use the deprecated clip op (i.e. if they were deserialized
> > from an SKP that recorded an expanding op).
> >
> > Clients of SkClipOp that checked for replace ops use the new function
> > instead of referring to the enum value directly.
> >
> > Bug: skia:10209
> > Change-Id: I1c16c87fadb2becfe181db717c05e240ac87fd34
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436158
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> > Reviewed-by: Chris Dalton <csmartdalton@google.com>
>
> TBR=robertphillips@google.com,brianosman@google.com,csmartdalton@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com
>
> Change-Id: If3f99a7d2f2df99c2b99d431d494ca28da66b1d8
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10209
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436956
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:10209
Change-Id: I9feb0f3571ec26580bcdf0fe541f43f2ee8cf8d2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436959
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-06 14:44:39 +00:00
Mike Reed
09746be8de Set SkPath.fLastMoveToIndex field from SkPathBuilder
This is a "legacy" field in SkPath, and only needed for editing the
path (in funny cases, such as a relative verb or missing moveto).
When we finally make SkPath immutable, we won't need this field at all.

Note: this CL "fixes" the last 2 columns in path_append_extend gm.
They should appear the same as the previous 2 columns.

Change-Id: Ia5f2e8ec586b5f5189fc3ac2cd513fe89d31cd22
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436958
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2021-08-06 14:12:11 +00:00
John Stiles
2195f94a0c Add unit test for array narrowing conversions.
Change-Id: Ibadda2a10e19984c7a0efb66fd3187f280666445
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436996
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-06 13:05:35 +00:00
John Stiles
e3f85e07fa Add improved regression test for oss-fuzz:36655.
Most of the code generated by the fuzzer is nonsense, but there is a
method to its madness. The crash is only triggered under specific
conditions:
- The runtime effect has enough helper functions to mostly fill up the
  call graph hash-map. It won't rehash until it gets close to capacity.
- There must be several calls to built-in functions, in order to add
  elements to the call graph to force a rehash.

The fuzzer-generated code manages to satisfy both these requirements.

Change-Id: I9a1d7535557fedd4e9bfece3930ac86ede291ffe
Bug: oss-fuzz:36655
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437118
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-08-06 13:03:32 +00:00
John Stiles
e3ae968f5f Enable comparison of arrays of different precision types.
GLSL allows an array of `lowp float` to be compared against `highp
float` seamlessly because the types are considered to be the same. SkSL,
however, treats these as different types, so we need to coerce the types
to allow this comparison to work.

In other words, these comparisons can cause an array to be implicitly
casted. The expression `myHalf2Array == float[2](a, b)` should be
allowed when narrowing conversions are enabled. To allow this to work,
we need a dedicated IR node representing this type coercion.

We now allow implicit coercion of array types when the array's component
types would be implicitly coercible, and have a new IR node representing
that implicit conversion.

This CL fixes array comparisons, but array assignment needs additional
fixes. It currently results in:
    "type mismatch: '=' cannot operate on (types)".

Bug: skia:12248
Change-Id: I99062486c081f748f65be4b36a3a52e95b559812
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436571
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-06 12:57:10 +00:00
Robert Phillips
7386dc7941 Ensure default SkPaints w/ dither don't get dithered
Skipping dithering of const paints was originally added in:

https://skia-review.googlesource.com/c/skia/+/19880/

Change-Id: Icebca1c3ef779bb103030deac12621619f5ce248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437116
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-05 22:04:28 +00:00
John Stiles
9ae6ea0711 Fix fuzzer-discovered error with swizzling matrices.
The optimization logic for swizzling a constructor assumed that every
argument to the constructor was a scalar or vector. When it was written,
this assumption was true. However, we recently added support for casting
mat2x2 to float4 which violates the assumption.

We now check every argument and do not attempt to optimize if a
non-scalar, non-vector arg is found.

Change-Id: Ia2b297bd62dfdf4af56712164fbc80c29c9611eb
Bug: oss-fuzz:36852
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437017
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-05 21:59:23 +00:00
John Stiles
ded41aafb2 Fix fuzzer-discovered error with SPIR-V interface arrays.
OSSFuzz discovered a minor variation of oss-fuzz:36770 which tickled a
different bug in SPIR-V RTFlip handling; we did not properly handle the
case where the InterfaceBlock is an array. SPIR-V does not support this
at all, but the IRGenerator allows it, and we don't detect it an an
error until later in the compilation process.

Change-Id: I80bd67a13dad878717dc122462132a2ed675532d
Bug: oss-fuzz:36850
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437018
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-05 21:44:16 +00:00
John Stiles
628777c9ed Fix cases of variable shadowing in SkSL.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: Ic582c59b9f7dfee2d7e90e50bfb36c57e958c673
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436641
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-05 21:39:12 +00:00
Michael Ludwig
8ba1e71a1f Revert "Add SkClipStack::replaceClip() separate from deprecated clip op"
This reverts commit 68587ae274.

Reason for revert: breaking path clipping tests in Android?

Original change's description:
> Add SkClipStack::replaceClip() separate from deprecated clip op
>
> The replaceClip functionality was added to allow Android to move off of
> generalized expanding clips. At the time, SkClipStack simply used the
> kReplace_SkClipOp to handle it. In order to remove those expanding ops,
> SkClipStack will need a proper implementation of replaceClip().
>
> The clip elements have an additional field to mark if
> it's a replace (and it's op will be kIntersect). Adds a temporary
> getRegionOp() function to unify elements that use this field vs.
> elements that use the deprecated clip op (i.e. if they were deserialized
> from an SKP that recorded an expanding op).
>
> Clients of SkClipOp that checked for replace ops use the new function
> instead of referring to the enum value directly.
>
> Bug: skia:10209
> Change-Id: I1c16c87fadb2becfe181db717c05e240ac87fd34
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436158
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Chris Dalton <csmartdalton@google.com>

TBR=robertphillips@google.com,brianosman@google.com,csmartdalton@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: If3f99a7d2f2df99c2b99d431d494ca28da66b1d8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10209
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436956
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-05 14:47:41 +00:00
Michael Ludwig
b942d4b436 Revert "Avoid expanding clip ops in tests that will remain after feature removal"
This reverts commit d1c51b2572.

Reason for revert: blocking revert that might be breaking android

Original change's description:
> Avoid expanding clip ops in tests that will remain after feature removal
>
> Bug: skia:10208
> Change-Id: I4fb2c8181bfb8cac3c8ab95c833094c98f8ee6fc
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436159
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

TBR=robertphillips@google.com,reed@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: Ib62cc03f99793f8f1cb0180145b7557101a23ead
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10208
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436957
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-05 14:46:42 +00:00
Derek Sollenberger
337e484839 Revert "Reland "uniform Ptr (UPtr) is a sub class of Ptr""
This reverts commit ea17e2499d.

Reason for revert: blocking the android roll on a build failure

Original change's description:
> Reland "uniform Ptr (UPtr) is a sub class of Ptr"
>
> This is a reland of cef047a490
>
> Fix strides in SkVMTest to be the right size.
>
> Original change's description:
> > uniform Ptr (UPtr) is a sub class of Ptr
> >
> > A pointer for a Uniform (UPtr) is a sub type of a Ptr. Everywhere you
> > can use a Ptr a UPtr will work, but you can't use Ptr where you need
> > a UPtr. All the UPtr instructions uniformF, gather32, etc are expected
> > to be hoisted and therefore loaded only once. While the varyings
> > instructions like load32, etc. are expected to remain in the body
> > of the loop, and be evaluated each time through the loop.
> >
> > Change-Id: I4fe6458c2a4614872ed67cda1e81b05ea8a9e69e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436297
> > Commit-Queue: Herb Derby <herb@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Change-Id: I858fa1224452ec801b6186fede353849edc895b5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436564
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

TBR=herb@google.com,brianosman@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I0ffc93a04f5329838d422ad9e42aba09b9ba0064
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436639
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
2021-08-05 01:11:41 +00:00
John Stiles
b806da4501 Honor lowp/mediump/highp precision qualifiers in IRGenerator.
This CL does not update the DSLParser to honor these precision
qualifiers; that will be done in a followup.

Change-Id: Ib629bc99c0e6c7afb550a381d4e3b6ccc26aa64e
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436337
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-04 21:29:10 +00:00
John Stiles
020143148f Add parser support for highp/mediump Tokens in vardecls.
These parse into new modifier bits; the IR generator does not yet
support these bits. That's coming in a followup CL.

Change-Id: I362e9227694f9b862eaad100f6afca45a9b62a01
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436336
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-08-04 21:11:14 +00:00
Herb Derby
ea17e2499d Reland "uniform Ptr (UPtr) is a sub class of Ptr"
This is a reland of cef047a490

Fix strides in SkVMTest to be the right size.

Original change's description:
> uniform Ptr (UPtr) is a sub class of Ptr
>
> A pointer for a Uniform (UPtr) is a sub type of a Ptr. Everywhere you
> can use a Ptr a UPtr will work, but you can't use Ptr where you need
> a UPtr. All the UPtr instructions uniformF, gather32, etc are expected
> to be hoisted and therefore loaded only once. While the varyings
> instructions like load32, etc. are expected to remain in the body
> of the loop, and be evaluated each time through the loop.
>
> Change-Id: I4fe6458c2a4614872ed67cda1e81b05ea8a9e69e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436297
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Change-Id: I858fa1224452ec801b6186fede353849edc895b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436564
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-08-04 20:51:14 +00:00
Robert Phillips
f3868628f9 Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions (take 2)
The only really interesting parts are:
  src/gpu/SurfaceFillContext.*
  src/gpu/v1/SurfaceFillContext.*

Everything else is mostly mechanical.

TBR=michaelludwig@google.com
Bug: skia:11837
Change-Id: Ia208e9a73d1529804c06d4f805d8ca3674851496
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436558
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-08-04 19:40:55 +00:00
Michael Ludwig
d1c51b2572 Avoid expanding clip ops in tests that will remain after feature removal
Bug: skia:10208
Change-Id: I4fb2c8181bfb8cac3c8ab95c833094c98f8ee6fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436159
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-08-04 19:11:40 +00:00
Michael Ludwig
3b39b7f5c6 Alias canComputeFastBounds to affectsTransparentBlack
This moves SkImageFilter's API closer to SkColorFilter's, and also
updates SkRecordDraw's PaintMayAffectTransparentBlack to be less
conservative.

Originally:
-canComputeFastBounds() handled aggregating behavior of the entire graph
  but it's a public API
-affectsTransparentBlack() was the private virtual for a specific node

Now:
-affectsTransparentBlack() handles aggregating behavior of the graph and
  is part of SkImageFilter_Base (mirroring SkColorFilter_Base).
-added onAffectsTransparentBlack() to clarify the per-node virtual that
  they can override.
-canComputeFastBounds() simply returns !affectsTransparentBlack().

There are some usages in our code that I kept using canComputeFastBounds
(e.g. SkPaint's computefastBounds) because it kept naming consistent.
In other places I updated to use affectsTransparentBlack since I thought
that made it clearer why we were checking that behavior.

Bug: skia:12282
Change-Id: I7b58372c127b4d8d9097d6c0de64486e822d2342
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436296
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-04 19:11:19 +00:00
John Stiles
9fdcc517b2 Write test demonstrating bug with array narrowing conversions.
We don't currently support this. There's no explicit syntax to cast an
array's type, but it can be implicitly required in some situations, like
`halfArray == floatArray` (when fAllowNarrowingConversions is on).

Change-Id: I00fe0ddd4f2682b2950e828dd78bb941d5f0430e
Bug: skia:12248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436560
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-04 18:34:18 +00:00
Michael Ludwig
68587ae274 Add SkClipStack::replaceClip() separate from deprecated clip op
The replaceClip functionality was added to allow Android to move off of
generalized expanding clips. At the time, SkClipStack simply used the
kReplace_SkClipOp to handle it. In order to remove those expanding ops,
SkClipStack will need a proper implementation of replaceClip().

The clip elements have an additional field to mark if
it's a replace (and it's op will be kIntersect). Adds a temporary
getRegionOp() function to unify elements that use this field vs.
elements that use the deprecated clip op (i.e. if they were deserialized
from an SKP that recorded an expanding op).

Clients of SkClipOp that checked for replace ops use the new function
instead of referring to the enum value directly.

Bug: skia:10209
Change-Id: I1c16c87fadb2becfe181db717c05e240ac87fd34
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436158
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2021-08-04 18:17:11 +00:00
Derek Sollenberger
b00cbc704d Revert "uniform Ptr (UPtr) is a sub class of Ptr"
This reverts commit cef047a490.

Reason for revert: DM test failures on some Windows/Linux devices

Original change's description:
> uniform Ptr (UPtr) is a sub class of Ptr
>
> A pointer for a Uniform (UPtr) is a sub type of a Ptr. Everywhere you
> can use a Ptr a UPtr will work, but you can't use Ptr where you need
> a UPtr. All the UPtr instructions uniformF, gather32, etc are expected
> to be hoisted and therefore loaded only once. While the varyings
> instructions like load32, etc. are expected to remain in the body
> of the loop, and be evaluated each time through the loop.
>
> Change-Id: I4fe6458c2a4614872ed67cda1e81b05ea8a9e69e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436297
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

TBR=herb@google.com,brianosman@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I785973be1493643e7d5a3da482bc4ab07d186865
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436559
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
2021-08-04 17:26:34 +00:00
Derek Sollenberger
40b82c6b5c Revert "Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions"
This reverts commit af844c79d5.

Reason for revert: breaking chrome roller

Original change's description:
> Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions
>
> The only really interesting parts are:
>   src/gpu/SurfaceFillContext.*
>   src/gpu/v1/SurfaceFillContext.*
>
> Everything else is mostly mechanical.
>
> Bug: skia:11837
> Change-Id: If2945f30dadd6ad0cccf6ff2b53e4a92b1dc6cbc
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436099
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>

TBR=robertphillips@google.com,michaelludwig@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I3b2d1d4a30e253a107f55dc3c5ecaaee5386e6e8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11837
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436557
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Derek Sollenberger <djsollen@google.com>
2021-08-04 17:15:45 +00:00
Herb Derby
cef047a490 uniform Ptr (UPtr) is a sub class of Ptr
A pointer for a Uniform (UPtr) is a sub type of a Ptr. Everywhere you
can use a Ptr a UPtr will work, but you can't use Ptr where you need
a UPtr. All the UPtr instructions uniformF, gather32, etc are expected
to be hoisted and therefore loaded only once. While the varyings
instructions like load32, etc. are expected to remain in the body
of the loop, and be evaluated each time through the loop.

Change-Id: I4fe6458c2a4614872ed67cda1e81b05ea8a9e69e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436297
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-04 16:00:10 +00:00
Robert Phillips
af844c79d5 Fission GrSurfaceFillContext into skgpu:: and skgpu::v1:: versions
The only really interesting parts are:
  src/gpu/SurfaceFillContext.*
  src/gpu/v1/SurfaceFillContext.*

Everything else is mostly mechanical.

Bug: skia:11837
Change-Id: If2945f30dadd6ad0cccf6ff2b53e4a92b1dc6cbc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436099
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-04 14:30:10 +00:00
John Stiles
68f5606831 Fix cases of variable shadowing in rasterization.
If we manage to fix all the existing cases of variable shadowing, we
could enable -Wshadow.

Change-Id: I169ff3bac8517869132297c8e98bd9bd4248a349
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436100
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2021-08-03 19:00:58 +00:00
Michael Ludwig
2f6e2f8410 Use SkClipOp::kFoo instead of kFoo_SkClipOp from SkClipOpPriv
The SkClipOpPriv.h header will be going away soon, but a number of
places still use its kIntersect_SkClipOp definitions instead of the
equivalent SkClipOp::kIntersect. Besides updating these references,
a number of unnecessary includes to SkClipOpPriv.h are removed and
some test cases exercising expanding clip ops are deleted since they
will be unnecessary shortly.

Bug: skia:10208
Change-Id: I2bbdd6bb39869134c6a80ef2b4482e6cabdeb0b7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436157
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-08-03 18:08:21 +00:00
John Stiles
e9dcbfdaa1 Add test for Runtime Effects and narrowing conversions.
This code intentionally mixes half4s and float4s everywhere. Before
http://review.skia.org/435916 landed, this resulted in a compile error.

Change-Id: I852fef6ee99a8b78623e0e9ddeee2ad84a8c0504
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/436058
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-03 15:58:46 +00:00
Robert Phillips
a3f206e0b8 Non-substantive changes for making v1::SurfaceDrawContext V1-only
Bug: skia:11837
Change-Id: I60112e370c95e6f9d9bc12cb9b05d40dd2220bc9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435279
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-02 19:22:58 +00:00
Brian Salomon
66b500a07c Remove explicit sample flag from GrFP.
Instead expand the map that is computed by GrGLSLGP to include a bool
that indicates whether each FP requires coords or not.

Now GrGLSLGP is solely responsible for determining which FPs take coords
and inserting any varyings. The rest of the system follows its lead when
generating FP functions and call sites.

Bug: skia:12198

Change-Id: I3471867fb64e94c7775c0b6209998159abeb6714
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435018
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-02 17:41:45 +00:00
John Stiles
d7437eec2e Fix for fuzzer-discovered error in SPIR-V with RTFlip.
SPIR-V code generation synthesizes some extra variables that don't
actually exist in the Program. Checking the ProgramUsage of these
variables would fail; ProgramUsage::get doesn't know about these
variables, so it asserts (and would consider them as dead even if it
didn't assert). We now track our SPIR-V bonus variables in a separate
set, and always report them as live.

Change-Id: If2f681470654025abf7ca4b3ec8126de2eb01297
Bug: oss-fuzz:36770
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435625
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-08-02 17:13:50 +00:00
Robert Phillips
33bf2b56f9 Pipe all SDC creation through the recording context
In the new GrSurfaceContext class hierarchy we can get either a v1 or v2 SFC/SDC depending on the context options setting.

Bug: skia:11837
Change-Id: Ia25bc10b58bbbaf65a484b323d9d0eee471bb7ef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435276
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-08-02 16:04:52 +00:00
Brian Salomon
2957885548 Reland "Fix check in GrGLGpu for whether PBO 0 is bound"
This is a reland of 62d42db282

Check for PBO support before binding PBO 0.

Original change's description:
> Fix check in GrGLGpu for whether PBO 0 is bound
>
> Found in OOP-R canvas in Chrome. Most likely async read followed by
> sync read with an intervening resetContext().
>
> Bug: chromium:1208212
>
> Change-Id: Ibf85f070d0a4cd389f67e9b249655b0ef667c66e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435277
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Auto-Submit: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

Bug: chromium:1208212
Change-Id: I0da48fa9a1f31ec15827f9bef980e9d5a7d70d26
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435622
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-02 15:06:04 +00:00
Brian Salomon
751de92cf1 Revert "Fix check in GrGLGpu for whether PBO 0 is bound"
This reverts commit 62d42db282.

Reason for revert: d3d9 angle tests failing

Original change's description:
> Fix check in GrGLGpu for whether PBO 0 is bound
>
> Found in OOP-R canvas in Chrome. Most likely async read followed by
> sync read with an intervening resetContext().
>
> Bug: chromium:1208212
>
> Change-Id: Ibf85f070d0a4cd389f67e9b249655b0ef667c66e
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435277
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Robert Phillips <robertphillips@google.com>
> Auto-Submit: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: chromium:1208212
Change-Id: I85c89a4d0dd63aaafd80d7572c5643cfa547498b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435617
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-08-02 13:59:19 +00:00
Brian Salomon
62d42db282 Fix check in GrGLGpu for whether PBO 0 is bound
Found in OOP-R canvas in Chrome. Most likely async read followed by
sync read with an intervening resetContext().

Bug: chromium:1208212

Change-Id: Ibf85f070d0a4cd389f67e9b249655b0ef667c66e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/435277
Commit-Queue: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-07-30 22:38:47 +00:00
John Stiles
ce9a5c953d Allow sampling from SkBlenders.
Runtime shaders, color filters, and blenders are all able to sample from
a blender. These use the blend-function signature; both a src-color and
dst-color must be passed to sample. i.e.: sample(blender, s, d)

Change-Id: I3738e6b0b4af6d1d79e62ca1815c80d6a1ae9d6f
Bug: skia:12257
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/432056
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-30 16:41:54 +00:00
Robert Phillips
1a2e7de8ea Update tests for a V1-only skgpu::v1::SurfaceDrawContext
Bug: skia:11837
Change-Id: If8dd864d6cd8bc5ab9569fbab40866e1810dbc27
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434162
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-30 16:33:41 +00:00
John Stiles
131410a7d1 Add regression test for oss-fuzz:36655.
Change-Id: I7b53df1eae83a596c4d1f3620e7f9bd146f68af2
Bug: oss-fuzz:36655
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434465
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-29 15:22:20 +00:00
Brian Osman
7fd83ebd39 Fix SkTLList::popTail
Change-Id: Id3e4d10456be6e0e0329600f05641034f3ffdb8b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/434336
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-07-28 20:23:38 +00:00
Robert Phillips
4dca83162b Rename GrSurfaceDrawContext to skgpu::v1::SurfaceDrawContext
This CL is mostly mechanical. It:

replaces "src/gpu/GrSurfaceDrawContext.h" #includes with
         "src/gpu/v1/SurfaceDrawContext_v1.h" and reorders

replaces "class GrSurfaceDrawContext;" with
         "namespace skgpu { namespace v1 { class SurfaceDrawContext; }}"

replaces "GrSurfaceDrawContext*" with "auto" where possible
replaces "rtc" with "sdc"
replaces "surfaceDrawContext" with "sdc"
replaces GrSurfaceDrawContext with skgpu::v1::SurfaceDrawContext
reflows parameters as needed

This CL does not try to:

make skgpu::v1::SurfaceDrawContext V1-only
minimize the skgpu and/or skgpu::v1 prefixes

Those two tasks will be accomplished in follow up CLs. This CL is just trying to get the bulk of the mechanical changes comprehensibly landed.

Bug: skia:11837
Change-Id: I6fe59080249d585df8f5d27c6b67569cdc35842f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433156
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-07-28 20:12:10 +00:00
Herb Derby
a4953515af add array to the Uniforms
Note: I have changed from using a byte offset for index to
an ordinary array index at the builder interface, but the
builder converts this to a byte offset for the instruction.
This makes the API easier to use.

I've added pushArray, and pushArrayF to the Uniforms, and
convenience methods on the builder to take Uniforms.

I've expanded the tests to use the new API.

Change-Id: Id538e826a96d4d242ae6482acc711d84c9041239
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/432036
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-27 15:48:06 +00:00
Herb Derby
a37001e2ca Reland "Reland "add op array32 for indirect uniform access""
Forgot to load the pointer to the array in the arm64 case.

This is a reland of fe2506f3ca

Bug=skia:11822

Original change's description:
> Reland "add op array32 for indirect uniform access"
>
> This is a reland of ac2d053ccf
>
> The original CL was reverted because of a bug in the hash
> function.
>
> Bug=skia:11822
>
> Original change's description:
> > add op array32 for indirect uniform access
> >
> > Change-Id: I6249594a2348c7b24e4f057cce2f4e8a6a2c4409
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431676
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Herb Derby <herb@google.com>
>
> Change-Id: I94604f5589c72d342c39cad44540d810ed7f31a1
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/432797
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I185fc9554dcb6aa7ce367814ce2c69603074c434
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433356
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-07-27 15:04:50 +00:00
Brian Osman
ae8e0634a8 Reject degenerate quads in AA hairline path renderer
Includes unit test that reproduces the original bug.

Bug: chromium:1232834
Change-Id: Iae2f52b42d35f0774c4cf9fa686df7aaf57c130a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433279
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-27 14:30:42 +00:00
Herb Derby
2c5b922e7a Revert "Reland "add op array32 for indirect uniform access""
This reverts commit fe2506f3ca.

Reason for revert: Breaks unit test on M1 mac

Original change's description:
> Reland "add op array32 for indirect uniform access"
>
> This is a reland of ac2d053ccf
>
> The original CL was reverted because of a bug in the hash
> function.
>
> Bug=skia:11822
>
> Original change's description:
> > add op array32 for indirect uniform access
> >
> > Change-Id: I6249594a2348c7b24e4f057cce2f4e8a6a2c4409
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431676
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Herb Derby <herb@google.com>
>
> Change-Id: I94604f5589c72d342c39cad44540d810ed7f31a1
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/432797
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

TBR=herb@google.com,brianosman@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com

Change-Id: I3dccc04dc5a867bb45a99044991056b22f5b6fe3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/433278
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-07-27 12:50:12 +00:00
Herb Derby
fe2506f3ca Reland "add op array32 for indirect uniform access"
This is a reland of ac2d053ccf

The original CL was reverted because of a bug in the hash
function.

Bug=skia:11822

Original change's description:
> add op array32 for indirect uniform access
>
> Change-Id: I6249594a2348c7b24e4f057cce2f4e8a6a2c4409
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/431676
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Herb Derby <herb@google.com>

Change-Id: I94604f5589c72d342c39cad44540d810ed7f31a1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/432797
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-07-26 22:42:15 +00:00