Commit Graph

11324 Commits

Author SHA1 Message Date
Chris Dalton
475c9758eb Move the DMSAA surface flag into the public API
Bug: skia:11396
Change-Id: Iad175ea9727e0b18b94a7af341c831e03da46880
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427484
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-07-13 19:21:00 +00:00
Tyler Denniston
f8b7c1ac5f Pass CTM to path effects (experimental)
Add an overload to SkPathEffect that can be used when the CTM is known
at the callsite. GPU callsites are not handled here, that will be
tackled in a separate CL.

Path effects must implement the filterPath virtual that accepts the CTM,
although they are not obligated to use it. If a path effect does
use the CTM, the output geometry must be in the original coordinate
space, not device space.

Bug: skia:11957
Change-Id: I01615985599fe2736de954bb10dac881b0554ae7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420239
Commit-Queue: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-07-13 18:42:55 +00:00
John Stiles
82bbe606ec Add static to global nullopt symbol.
This should hopefully make the code safer in C++14 by not violating
the ODR.

(bungeman@: "I think in C++14 we will in fact get multiple definitions
of this symbol, though in C++17 we won't. Maybe we should mark this as
'static' so each TU gets its own zero byte copy in C++14 but in C++17
the 'static' will also be implicitly 'static inline' and we'll only get
one?)

Change-Id: I3570421fcf2be314e1baccff0783ded4a1078666
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427037
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-07-13 14:00:03 +00:00
Robert Phillips
a92913e169 Make GrAuditTrail V1-only
This CL has some rough edges since some classes that use it (e.g., GrOpsTask) aren't yet V1-only. That said, the big CL has to be broken up somehow.

Bug: skia:11837
Change-Id: I41ed9982ca4664f893e447ba23c7aec59f42c964
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426416
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-13 13:56:53 +00:00
John Stiles
2d25d28e51 Fix typo in doc-comments.
There is no "text" parameter. There is one called "tex".

Change-Id: Id8245a8222438c60f6c7bde0638e82bdfda0aa20
Bug: skia:12168
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427338
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-07-13 13:48:19 +00:00
Mike Reed
63ec43cf55 Hide deprecated filterquality
Change-Id: Ia320f07c3836a077d6feafb4a59a7c89325f9fcd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425057
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-07-13 00:45:12 +00:00
Mike Reed
5643e55f09 Add flag for filterquality in flutter
Change-Id: I8612d58efcfac82b7924c680fd8fa91b6d48614f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426956
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-07-12 20:09:30 +00:00
John Stiles
526b0b92c9 Use value_or in getBlendMode_or.
Support for `value_or` was recently added to skstd::optional. (Thanks
herb@!)

Change-Id: Ie343f8d06f8a26bcd111af8334757c203944b052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/427036
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-07-12 17:50:40 +00:00
Ethan Nicholas
ebc9fadf35 Fixed some fixups not being applied to DSL code
Change-Id: I11c473a7a683282d6bd4f73d2c90f23de63f8cc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426557
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-07-12 14:25:38 +00:00
Mike Reed
c98dbc6410 Hide deprecated SkPaint::getBlendMode
Callers should use asBlendMode or getBlendMode_or

Bug: skia:12173
Change-Id: I8b62527a2ae11c9bf0c1473c4fffa53b38aa7017
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425756
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Yegor Jbanov <yjbanov@google.com>
2021-07-11 17:14:21 +00:00
Brian Osman
50f0dadb7f Remove GrSharedEnums.h
Change-Id: I3f2e927001da10652b2965687e31aa8452c9dfc6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425997
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-07-09 15:32:46 +00:00
Robert Phillips
5e1aa8b665 Misc skgpu cleanup
This CL:
  finishes off some renaming I missed earlier
  removes some extraneous #includes from headers

TBR=bsalomon@google.com
Bug: skia:11837
Change-Id: If7163435a44d4067dac041a7f9e68b1ad63432d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/426037
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-09 15:06:16 +00:00
Brian Osman
c9145f3402 Remove enum support from SkSL
Bug: skia:11296
Change-Id: I7d41614957d6fa535faadebbeca890b54b6977ac
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425996
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-07-09 14:03:15 +00:00
Ethan Nicholas
e6ed3c280d Added DSL support for interface blocks
Change-Id: I5b770252eb5daa29844ac75ee4be81e503c2907f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424039
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-07-08 17:18:37 +00:00
Mike Reed
26ea975e6c Arithmetic blender
... to aid in removing special ArithmeticImageFilter.

Can we use something like this to reimpl the ArithmeticImageFilter
--> BlenderImageFilter?

I see some special checking in filterBounds for ArithIF -- is that
required? Is that generalizable for any BlenderImageFilter?
If we can generalize blend[er]imagefilter, let's just move this
logic into Chrome -- no need for Arithmetic to appear in Skia
in any form!

Re: https://skia-review.googlesource.com/c/skia/+/424436

Change-Id: Ifa0ff2fa25de6385f6f60505e73ecc28463a80b3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424417
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-07-08 17:06:17 +00:00
Brian Osman
8c26479048 Remove large swaths of code related to .fp files
Change-Id: Id2061ebe7873aa8b9480a2d8b0133c2fb79e79bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424098
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-08 16:53:47 +00:00
Herb Derby
d390c642ac add value_or to optional
Add full compliment of operator*, have them assert in debug,
but not throw in release as per c++ spec.

Add full compliment of value() have them crash if there is
no value as per the c++ spec.

Add value_or.

Add test for value_or.

Change-Id: Ib0d9a01fba367768e66d00fbc61b471397e8582c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425476
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-07-07 23:08:17 +00:00
Mike Reed
90f4e9f5f7 Hide getBlendMode()
... since it mysteriously returns something even if the blender doesn't
map to any enum. Clients should use asBlendMode() or getBlendMode_or().

Change-Id: I5dc5aea51f47f297ef9b2a89535d47ac58aea9bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425177
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-07-07 20:55:26 +00:00
Brian Osman
4c886ee15a Revert "Revert "Convert GrConfigConversionEffect to a runtime FP""
This reverts commit 1c467774e5.

Change-Id: Iad409002ddd71f0c26117e5a0814bf021fba8178
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425186
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-07 20:17:26 +00:00
Mike Reed
26489dc674 value_or variant for getBlendMode.
... to ease clients into the blender world. Will be used in subsequent
CLs to migrate skia and its clients.

Change-Id: I253b333dca65876b45c3d424f5d0456a09460e6d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425356
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-07-07 18:48:37 +00:00
Brian Salomon
d8d85b9b89 Reland "Don't key progams/pipelines on origin.""
Reland works around Adreno issue with this formulation of sk_Clockwise:
 (sk_RTFlip.y < 0.0 ? !gl_FrontFacing : gl_FrontFacing)

and instead adds this to the top of the function:
 bool sk_Clockwise = gl_FrontFacing;
 if (sk_RTFlip.y < 0.0) {
      sk_Clockwise = !sk_Clockwise;
 }

Original description:

SkSL language features that are origin sensitive now use a uniform
to conditionally flip their result rather than generating different
code.

Previously we would insert a "rt height" uniform if sk_FragCoord needed
to be flipped. sk_FragCoord,y was implemented as "realFragCoord.y" or
"rtHeight - realFragCoord.y" depending on SkSL::ProgramSettings::fFlipY.

Now we instead use a two component vector rtFlip and sk_FragCoord.y is
always "rtFlip.x + rtFlip.y*realFragCoord.y". We configure rtFlip as
either (0, 1) or (rtHeight, -1). sk_Clockwise and dFdy simiarly use
rtFlip.y to emit code that always works with either origin.

Bug: skia:12037
Change-Id: I3a2ad6f5667eb4dcd823b939abd5698f89b58929
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425178
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-07-07 14:50:10 +00:00
Brian Salomon
40242241c3 Revert "Don't key progams/pipelines on origin."
This reverts commit 943108b0b2.

Reason for revert: clockwise GM bad on android.

Original change's description:
> Don't key progams/pipelines on origin.
>
> SkSL language features that are origin sensitive now use a uniform
> to conditionally flip their result rather than generating different
> code.
>
> Previously we would insert a "rt height" uniform if sk_FragCoord needed
> to be flipped. sk_FragCoord,y was implemented as "realFragCoord.y" or
> "rtHeight - realFragCoord.y" depending on SkSL::ProgramSettings::fFlipY.
>
> Now we instead use a two component vector rtFlip and sk_FragCoord.y is
> always "rtFlip.x + rtFlip.y*realFragCoord.y". We configure rtFlip as
> either (0, 1) or (rtHeight, -1). sk_Clockwise and dFdy simiarly use
> rtFlip.y to emit code that always works with either origin.
>
> Bug: skia:12037
>
> Change-Id: I7a09d0caac60a58d72b76645ff31bcabde4086b6
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414796
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,ethannicholas@google.com

Change-Id: I91cc0d86be216f6c32e453a231de088c991be4b2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12037
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/425056
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-07-06 19:21:26 +00:00
Brian Salomon
943108b0b2 Don't key progams/pipelines on origin.
SkSL language features that are origin sensitive now use a uniform
to conditionally flip their result rather than generating different
code.

Previously we would insert a "rt height" uniform if sk_FragCoord needed
to be flipped. sk_FragCoord,y was implemented as "realFragCoord.y" or
"rtHeight - realFragCoord.y" depending on SkSL::ProgramSettings::fFlipY.

Now we instead use a two component vector rtFlip and sk_FragCoord.y is
always "rtFlip.x + rtFlip.y*realFragCoord.y". We configure rtFlip as
either (0, 1) or (rtHeight, -1). sk_Clockwise and dFdy simiarly use
rtFlip.y to emit code that always works with either origin.

Bug: skia:12037

Change-Id: I7a09d0caac60a58d72b76645ff31bcabde4086b6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414796
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-07-06 18:08:06 +00:00
Mike Reed
3037d9f322 Make setBlender the real name
Change-Id: Ifd590a3653760c5d3967c0b1bcf00d0be1a7658f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424396
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2021-07-06 16:08:14 +00:00
Mike Reed
a8ac441411 Move Mode() factory into SkBlender
This frees the SkBlenders names for optional effects, and better
reflects the fact that the "core" relies on this Mode() factory.

... and makes this clearer:
https://skia-review.googlesource.com/c/skia/+/424417

Maybe this isn't important. I see SkShaders is in core header, but
SkImageFilters is in effects, so I guess we don't have a consistent
notion for this naming yet. What I do think is semi-important is
that core headers include effects that core uses, so in this case
a Mode() factory does make sense to be in a core header, just have to
decide/bikeshed how to scope it.

Change-Id: I94da47cfaa6c1ea22894bf66a48604d3722b4062
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424416
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-07-06 13:39:05 +00:00
Brian Osman
04d79fc594 GrSkSLFP: Avoid making a global copy of inColor most of the time
We still need *a* copy, to satisfy SkSL that mutates the input color
parameter, but it almost never needs to be global, unless there are
calls to sample() from a function other than main.

With that tweak, we generate much better SkSL/GLSL code from every one
of our effects, avoiding the proliferation of global variables.

Bug: skia:12140
Change-Id: I5c3bd42df34a095969abcbbc60e69c653a08087a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424299
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-02 21:06:21 +00:00
Brian Osman
e9ab391765 Reland "Convert GrDitherEffect to a runtime FP"
This reverts commit 3dd52c758b.

Change-Id: Ie873ad570ffc57b3edd6ffe8612cbc2c73d40450
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424259
Reviewed-by: Brian Osman <brianosman@google.com>
2021-07-02 17:33:15 +00:00
Brian Osman
1c467774e5 Revert "Convert GrConfigConversionEffect to a runtime FP"
This reverts commit 4a77813008.

Reason for revert: Memory regression in Chrome.

Original change's description:
> Convert GrConfigConversionEffect to a runtime FP
>
> Change-Id: I7f22447cf3356b1558d73665ff3e9b61639ebe83
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423576
> Auto-Submit: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=bsalomon@google.com,brianosman@google.com,ethannicholas@google.com

Change-Id: I05497295b88b378f0aa236f18118fe676bbf05c9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424256
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-02 13:11:40 +00:00
Brian Osman
3dd52c758b Revert "Convert GrDitherEffect to a runtime FP"
This reverts commit 2fa843abc2.

Reason for revert: Oops, SkSL error in the ES2 path.

Original change's description:
> Convert GrDitherEffect to a runtime FP
>
> Includes a change so that we can create non-ES2 runtime effects, even
> outside of tests/tools. It's still locked to a private API, so clients
> can't access the functionality.
>
> Change-Id: Ie0643da2071bd223fccf05b35f3a7b6f7bbc4876
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423578
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

TBR=bsalomon@google.com,brianosman@google.com,ethannicholas@google.com,michaelludwig@google.com

Change-Id: Icff68da3cadd00868c94b84fbb39e470a7bf45d0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424100
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-01 22:36:09 +00:00
Brian Osman
2fa843abc2 Convert GrDitherEffect to a runtime FP
Includes a change so that we can create non-ES2 runtime effects, even
outside of tests/tools. It's still locked to a private API, so clients
can't access the functionality.

Change-Id: Ie0643da2071bd223fccf05b35f3a7b6f7bbc4876
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423578
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-07-01 20:58:54 +00:00
Robert Phillips
7cef6789fd Change architecture #defines to be SK_GPU_V1 and SK_GPU_V2
A strictly mechanical CL

Bug: skia:11837
Change-Id: Id794d1fefe261d685b19e5d4d599cdab5e021cf7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/424038
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-07-01 18:42:53 +00:00
Robert Phillips
1a82a4ea49 Remove GrResourceProvider.h from all other header files
According to
https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html
these account for 583,146,886 bytes of input to the compiler, or roughly
0.25% of the input used to build Chrome.

Bug: chromium:242216
Change-Id: I2d5b73db770dba296df18c02a251da21e82b9ec0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423836
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2021-07-01 15:25:14 +00:00
Brian Osman
4a77813008 Convert GrConfigConversionEffect to a runtime FP
Change-Id: I7f22447cf3356b1558d73665ff3e9b61639ebe83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/423576
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-07-01 14:35:33 +00:00
Mike Reed
55b401ed9e Make blender the source-of-truth
- blendmode is no longer stored in paint
- no perf change expected (should take all special cases we did before)
- no pixel changes expected

Prev CL this builds upon:
https://skia-review.googlesource.com/c/skia/+/419576

Change-Id: Ifb21298c26de3e0773431a58d2aaa8530cc77654
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421997
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-06-29 21:47:55 +00:00
Brian Osman
4716a7681e SkRuntimeEffect: Don't keep two copies of SkSL source around
Change-Id: I98fcaa0e83e574cdbdd767abbedcf6763c0fdce4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/422521
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-29 16:52:46 +00:00
Mike Reed
40fefb239e Make SkTOptional C++14 safe
Change-Id: Ib8e872ecd1b5d2b3702a12bae73f1a7a1b3a2f4e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/422519
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-28 20:00:08 +00:00
Ethan Nicholas
549c6b8739 Added Poison values to SkSL to improve DSL error handling
This also tightens up the rules around releasing DSL objects.

Bug: skia:12133
Change-Id: I11a6d8fbcec58374f7b5ed5ced1c5c112e2b7cc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421323
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-28 19:15:16 +00:00
Mike Reed
9f745d90d0 Remove SkMatrix44
Change-Id: I4b33603f7318bc5881929b50258bf166c8a5cb04
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420818
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-06-26 01:51:45 +00:00
John Stiles
7bf799956d Reland "Add format-specifier warnings to SkDebugf."
This is a reland of e58831cd95

Original change's description:
> Add format-specifier warnings to SkDebugf.
>
> This CL fixes up many existing format-specifier violations in Skia.
> Note that GCC has a warning for formatting nothing, so existing calls to
> `SkDebugf("")` have been removed, or replaced with `SkDebugf("%s", "")`.
> These were apparently meant to be used as a place to set a breakpoint.
>
> Some of our clients also use SkDebug with bad format specifiers, so this
> check is currently only enabled when SKIA_IMPLEMENTATION is true.
>
> Change-Id: I8177a1298a624c6936adc24e0d8f481362a356d0
> Bug: skia:12143
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420902
> Auto-Submit: John Stiles <johnstiles@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12143
Change-Id: Id3c0c21436ebd13899908d5ed5d44c42a0e23921
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421918
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-25 17:57:43 +00:00
Herb Derby
d253088fc2 Fix float to bool implicit cast
Simple fix as request by Cobalt...
https://lbshell-internal-review.git.corp.google.com/c/third_party/skia/+/100156/1/include/core/SkMatrix.h

Change-Id: Iac3de1d674aec6693b10a85db2f3cd4e36365687
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421538
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-06-25 15:36:39 +00:00
Mike Reed
f74eea7488 Refactor textToGlyphs closer to the source
Bug: skia:12113
Change-Id: I61c5789885a31d23c583227481afa87e7e784c7a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421919
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-25 15:22:50 +00:00
John Stiles
bef379ba62 Add SkBlendModeBlender class.
This is an SkBlender type which represents a traditional Skia blend mode
(from the SkBlendMode enum).

Change-Id: I7c74395be70584e11a5f1445b7f6cacfff35c532
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420817
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-06-25 13:55:59 +00:00
Tyler Denniston
283dba5785 Revert "Add format-specifier warnings to SkDebugf."
This reverts commit e58831cd95.

Reason for revert: looks like breaking a few build bots

Original change's description:
> Add format-specifier warnings to SkDebugf.
>
> This CL fixes up many existing format-specifier violations in Skia.
> Note that GCC has a warning for formatting nothing, so existing calls to
> `SkDebugf("")` have been removed, or replaced with `SkDebugf("%s", "")`.
> These were apparently meant to be used as a place to set a breakpoint.
>
> Some of our clients also use SkDebug with bad format specifiers, so this
> check is currently only enabled when SKIA_IMPLEMENTATION is true.
>
> Change-Id: I8177a1298a624c6936adc24e0d8f481362a356d0
> Bug: skia:12143
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420902
> 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

Change-Id: I07848c1bf8992925c9498e916744d0840355a077
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12143
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421917
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
2021-06-25 13:33:10 +00:00
John Stiles
e58831cd95 Add format-specifier warnings to SkDebugf.
This CL fixes up many existing format-specifier violations in Skia.
Note that GCC has a warning for formatting nothing, so existing calls to
`SkDebugf("")` have been removed, or replaced with `SkDebugf("%s", "")`.
These were apparently meant to be used as a place to set a breakpoint.

Some of our clients also use SkDebug with bad format specifiers, so this
check is currently only enabled when SKIA_IMPLEMENTATION is true.

Change-Id: I8177a1298a624c6936adc24e0d8f481362a356d0
Bug: skia:12143
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420902
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-25 11:05:59 +00:00
Greg Daniel
0b04b6b16f Reland "Fix texture barriers on DMSAA"
This reverts commit 9a2d3d1e19.

Reason for revert: relanding with fix

Original change's description:
> Revert "Fix texture barriers on DMSAA"
>
> This reverts commit 1a3f4ab490.
>
> Reason for revert: breaking dmsaa test on intel hd405, https://ci.chromium.org/raw/build/logs.chromium.org/skia/54538c41f1c1b111/+/annotations
>
> Original change's description:
> > Fix texture barriers on DMSAA
> >
> > Bug: skia:11396
> > Change-Id: Iad74958c05ed086fe85656b9dc5418d5ab4589e7
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419838
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Chris Dalton <csmartdalton@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com
>
> Change-Id: I8be8107a98584dfb7f831a296078753fecfcebcf
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11396
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421056
> 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:11396
Change-Id: I6c65a3639e87b32a30774f33445bb3174a4fdffa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421058
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-06-25 01:35:42 +00:00
Chris Dalton
83420eb817 Rewrite tessellation atlases as normal render tasks
Rewrites tessellation atlases as normal render tasks instead of
"onFlush" tasks. These tasks get inserted into the DAG upfront, lay
out their atlases as dependent tasks get built and reference them, and
finally add their ops to render themselves during onMakeClosed. Doing it
this way allows us to pause the flush and re-render the atlas whenever
it runs out of room.

Bug: b/188794626
Bug: chromium:928984
Change-Id: Id59a5527924c63d5ff7c5bce46a88368e79fc3ef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420556
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Adlai Holler <adlai@google.com>
2021-06-24 01:44:19 +00:00
Greg Daniel
9a2d3d1e19 Revert "Fix texture barriers on DMSAA"
This reverts commit 1a3f4ab490.

Reason for revert: breaking dmsaa test on intel hd405, https://ci.chromium.org/raw/build/logs.chromium.org/skia/54538c41f1c1b111/+/annotations

Original change's description:
> Fix texture barriers on DMSAA
>
> Bug: skia:11396
> Change-Id: Iad74958c05ed086fe85656b9dc5418d5ab4589e7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419838
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Chris Dalton <csmartdalton@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com

Change-Id: I8be8107a98584dfb7f831a296078753fecfcebcf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11396
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/421056
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-06-23 22:36:20 +00:00
Greg Daniel
1a3f4ab490 Fix texture barriers on DMSAA
Bug: skia:11396
Change-Id: Iad74958c05ed086fe85656b9dc5418d5ab4589e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419838
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-06-23 19:30:38 +00:00
Ethan Nicholas
d0f4d0d5d4 Switched more DSL APIs over to skstd::string_view
Change-Id: I87defa005fab8b1be92a700bf38c91b92c0ab8a7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420616
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-23 18:59:16 +00:00
Ethan Nicholas
b4f8b7a9f2 Cleaned up DSL error handling
This unifies various chunks of error handling code and makes the DSL
more gracefully handle failed object construction.

Change-Id: I4edc581c9eba276ce2ee2a17125ea7bd6057134a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420237
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-23 15:22:35 +00:00
John Stiles
e2c4e7e62d Add comparison operators to skstd::optional.
This involves a significant number of overloads, as optionals can be
compared against other optionals, or nullopt, or a value; either side
can mix and match as desired.

Change-Id: I26b8420e417300d32569fc76a55bcfd8e01eb322
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420576
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-22 21:11:15 +00:00
John Stiles
e53cf99728 Add nullopt to skstd::optional.
Change-Id: Ie0ed256fce79e2a03fcd468c820f468dc8bf25b5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420536
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2021-06-22 17:19:55 +00:00
Brian Osman
be545c9554 Verify that most runtime color filters support filtering a single color
When writing runtime FPs, this lets us confirm that we're going to get
the constant output for constant input optimization.

Change-Id: I358507585423e5b15c92a0b2e9278b16f8727fe8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419798
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-06-21 20:14:07 +00:00
Adlai Holler
4ff6072351 Enable reduceOpsTaskSplitting by default
Chrome does not rely on the default – this option is under a finch trial
named "ReduceOpsTaskSplitting." See crbug.com/1210578.

Android does not rely on the default – the flag is controlled by a
property named "renderthread.skia.reduceopstasksplitting", and enabled
by default. See b/183612348.

Flutter does not rely on the default – they explicitly disable the
option. See https://github.com/flutter/engine/pull/26568.

Our tools do not rely on the default – they enable the flag unless the
user passes --dontReduceOpsTaskSplitting on command line. Our bots
run with the flag enabled except the NUC5PPYH, for the sake of coverage.

The flag has no effect for Adreno 620 and 640, on drivers older than
v571, due to a driver bug.

Bug: skia:10877
Change-Id: Iafc84f3463194f0cf6cf135b2be05ec8eb08e446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419836
Auto-Submit: Adlai Holler <adlai@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-21 16:32:13 +00:00
Chris Dalton
685e09b31a Reland "Purge ccpr"
This is a reland of 7bf6bc0d06

Original change's description:
> Purge ccpr
>
> Now that the clip atlas has been successfully migrated to
> tessellation, we don't need this code anymore!
>
> Change-Id: Ic97f50cff7c4ee59f4476f8410f0b30a32df4e90
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419857
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>

Change-Id: If0be86902e7cc4755eba91a89be1ec1a6a4b54b2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419720
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-19 18:42:38 +00:00
Brian Osman
fe83ab6706 Revert "Purge ccpr"
This reverts commit 7bf6bc0d06.

Reason for revert: Android build references kCoverageCounting

Original change's description:
> Purge ccpr
>
> Now that the clip atlas has been successfully migrated to
> tessellation, we don't need this code anymore!
>
> Change-Id: Ic97f50cff7c4ee59f4476f8410f0b30a32df4e90
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419857
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Chris Dalton <csmartdalton@google.com>

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

Change-Id: I01d99287978f848eb8bf900c07cba90ceb3b6edc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419898
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-06-19 15:13:19 +00:00
Chris Dalton
7bf6bc0d06 Purge ccpr
Now that the clip atlas has been successfully migrated to
tessellation, we don't need this code anymore!

Change-Id: Ic97f50cff7c4ee59f4476f8410f0b30a32df4e90
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419857
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-06-18 21:46:36 +00:00
Mike Reed
12923c4696 Move more virtuals into ...Base to hide them from public api
Bug: skia:12111

Change-Id: I35601e0504e8e1186314e19bf53f01274bfc0ae0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419357
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-18 20:20:06 +00:00
Brian Osman
f62632c7c3 Remove SkShaders::Lerp
It's entirely unused, and trivial for clients to create with SkSL.

Change-Id: I197986232d3706f5af3a197f0fb8e744e1009e5f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419796
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-06-18 16:40:08 +00:00
Mike Reed
2e303cb532 Expose Deserialize, so we can wean clients off of flattenable api
Follow-on CL:
https://chromium-review.googlesource.com/c/chromium/src/+/2969803

Bug: skia:12111
Change-Id: Ia64433536186bb4276e5705d7bda022e0bb8bc6f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419360
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-17 18:30:53 +00:00
Robert Phillips
294723d690 Move GrOp::VisitProxyFunc to GrTypesPriv.h GrVisitProxyFunc
This is almost purely a query/replace CL (% the #include juggling).
The VisitProxyFunc is used by more than just the Ops and will probably
still be required in the NGA.

This is a prelude to making all the remaining GrOp-derived classes OGA-only.

Bug: skia:11837
Change-Id: If1c127e5c126c676be529ed2a61dd7953abb03d0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419162
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-17 17:23:35 +00:00
John Stiles
9c2fccbbee Add SkBlender setters and getters to SkPaint.
In this CL, the SkBlender field on the paint is inert; it is not honored
by any of our drawing code. Only setting/getting/hashing the field is
supported. Flattening the SkPaint will not yet preserve the SkBlender.

Change-Id: I69a7a6d20a4c8cc679a3627efbe050bb29e5588c
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419236
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-06-17 16:07:14 +00:00
Brian Osman
cc2d073020 Remove SkPaint::getHash
This was a particularly bad hash (A == B didn't imply
hash(A) == hash(B)). It was also entirely unused.

Change-Id: Id923bf1035effce04e12b1cc01d1c6aa4d11fdb6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419336
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-06-17 14:59:23 +00:00
John Stiles
491282486e Reland "Add SkRuntimeBlender class."
This is a reland of 6034941cc2

Original change's description:
> Add SkRuntimeBlender class.
>
> This class is returned by SkRuntimeEffect::makeBlender when a runtime
> blend is returned. SkRuntimeBlendBuilder is also added as a convenience
> class to simplify creation and uniform setup.
>
> Our ability to add tests is limited in this CL because the SkPaint does
> not contain an SkBlender yet. We do have one test which builds an
> SkBlender, but there's not much we can do with it. Testing will be
> bulked up in the next CL.
>
> Change-Id: Ib2d7d04186690ec0d2238fc990a19d9e6b786ce3
> Bug: skia:12080
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417006
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:12080
Change-Id: Ie41be141ba3787452f9d5c72946ebc748a5d6176
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419160
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-17 12:54:01 +00:00
Kevin Lubick
be03ef1565 Remove ableist language
Change-Id: Ie9ef50a14906c9350adbe16720291dca944ad7fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418738
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
2021-06-16 21:37:21 +00:00
Mike Reed
5837aad590 Expose bounds for maskfilters
Bug: skia:12094
Change-Id: Ia0dfa15fef2cd2f5fe7e024e085e56880c12224b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419098
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-16 21:24:30 +00:00
John Stiles
c804b740b8 Revert "Add SkRuntimeBlender class."
This reverts commit 6034941cc2.

Reason for revert: breaking MSVC build 

Original change's description:
> Add SkRuntimeBlender class.
>
> This class is returned by SkRuntimeEffect::makeBlender when a runtime
> blend is returned. SkRuntimeBlendBuilder is also added as a convenience
> class to simplify creation and uniform setup.
>
> Our ability to add tests is limited in this CL because the SkPaint does
> not contain an SkBlender yet. We do have one test which builds an
> SkBlender, but there's not much we can do with it. Testing will be
> bulked up in the next CL.
>
> Change-Id: Ib2d7d04186690ec0d2238fc990a19d9e6b786ce3
> Bug: skia:12080
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417006
> 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,johnstiles@google.com

Change-Id: Id916f7458b827cbfdbc951c8f02aed16e2f44935
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419159
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-06-16 20:59:42 +00:00
John Stiles
6034941cc2 Add SkRuntimeBlender class.
This class is returned by SkRuntimeEffect::makeBlender when a runtime
blend is returned. SkRuntimeBlendBuilder is also added as a convenience
class to simplify creation and uniform setup.

Our ability to add tests is limited in this CL because the SkPaint does
not contain an SkBlender yet. We do have one test which builds an
SkBlender, but there's not much we can do with it. Testing will be
bulked up in the next CL.

Change-Id: Ib2d7d04186690ec0d2238fc990a19d9e6b786ce3
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417006
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-16 20:34:50 +00:00
John Stiles
8f9f763ec5 Remove unreferenced TODO function.
Change-Id: I2de7d90504c2030f9d2ce2694899d350362ebb5c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/419056
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-06-16 18:45:18 +00:00
John Stiles
9300391a77 Add Make functions for runtime blends.
This does basic plumbing work, but lacks a real implementation for the
custom blend subclass. That subclass is added in the followup CL of this
CL chain.

Change-Id: I8db0eb42737a739b49741ffd6f4a283a2c0a9d62
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417005
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-06-16 18:19:57 +00:00
John Stiles
2d8b835cad Add SkBlender class; thread into SkVMBlitter.
Like SkColorFilter, SkShader, etc., this has a public-facing component
(SkBlender) and a private subclass (SkBlenderBase) which can be
obtained via a helper function (as_BB). At present there are no public-
facing methods, but the type needs to be exposed to be usable by the
outside world.

These classes exist for SkRuntimeEffect to subclass. The blender base
provides a `program` method with the parameters that blending will use.

Change-Id: I75c772fd4108a9c21fbda84201a8b23d3750a0df
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416916
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-16 17:35:38 +00:00
John Stiles
af8047dbb8 Rename existing 'Blend' enums/names to 'BlendFilter'.
Change-Id: I17c624e9145d7152f65695ca3ce4592a11bb09a2
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418637
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-15 22:51:40 +00:00
Peter Kasting
95b00157a4 Fix -Wc++11-narrowing for Skia.
Bug: chromium:1216696
Change-Id: I11221c55e2d64c1b47082e36aa44637c411f426f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417116
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-06-15 17:49:08 +00:00
Ethan Nicholas
4f3e6a261b Moved DSLWriter::ReleaseProgram into DSLCore.
This makes the API accessible from the upcoming DSLParser.

Change-Id: I0ee31c7648e35dfeaa50285cf93dcdb9dd4872bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417678
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-15 14:08:07 +00:00
Robert Phillips
fa0e5bc2d2 Actually make GrContextOptions::fUseNGA GR_TEST_UTILS-only
I accidentally left this out of:

https://skia-review.googlesource.com/c/skia/+/415796 (Add option to switch between OGA and NGA SkGpuDevices)

Bug: skia:11837
Change-Id: I49730b1f338f081512a7fca2d0ca6e1d4cf086be
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417536
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-15 12:58:33 +00:00
Mike Reed
d6c51edd52 PixelRef is not a flattenable
Change-Id: Idbc64a11c29e3bffcf788ec99cf157b9c5fd0226
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/418056
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-12 22:52:40 +00:00
Mike Reed
cd33e4accd purge unused flattenable enums
... on the assumption that we don't need stable values

related: https://skia-review.googlesource.com/c/skia/+/417979

Change-Id: I483309052bc34733a8abe87fb188278d203cd6cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417978
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-06-12 21:59:48 +00:00
Ethan Nicholas
08ac524b43 Added operator= on DSLCase
Needed by DSLParser, and should have been defined anyway.

Change-Id: Ieaabe493a8caef80dda30f2ab35068f358901885
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417677
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-10 22:29:24 +00:00
Ethan Nicholas
c94457c4bc Added missing declaration to DSLBlock.h
DSLBlock references SymbolTable without declaring it, getting away with
it only because it was normally imported by other headers.

Change-Id: Iead5c65656604d1c5b65ac3231ee3172350d28ed
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417676
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-10 22:23:14 +00:00
Michael Ludwig
9d1cc05100 Add scratch-only version of performDeferredCleanup
Change-Id: I5707d1da1b69ab1ffaa77d7a391a187ac3e8eba1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417267
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-10 18:13:23 +00:00
Ethan Nicholas
962dec40cb Removed StringFragment alias in favor of skstd::string_view
Change-Id: I026a8a6b452d4cb8adce4d5d4908aaf2e71f2555
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417516
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-10 18:07:03 +00:00
Ethan Nicholas
2919bbdab8 Added DSLSymbols
These are new APIs to manage symbols and symbol tables from DSL code,
needed for the upcoming DSLParser.

Change-Id: Ic8d86aebfbcdeb84bd872d8727cdfafbb8db2fd6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414907
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-10 17:07:36 +00:00
Ethan Nicholas
d2e0960696 Removed SkSL::StringFragment in favor of string_view
This CL preserves the "StringFragment" name as an alias for
string_view to reduce the impact. The StringFragment alias
will be removed in a followup CL.

Change-Id: I89209bc626b0be0d0190823b6217f4c83cafe1bc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416736
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-10 16:08:13 +00:00
Brian Osman
6285d64027 Support mixing shaders and color filters in runtime effects
Needs more testing, but includes a GM that demonstrates the ultimate
benefit of this: our 3D color LUT demo working as a color filter.

Bug: skia:11813
Change-Id: I97c129c54bcf2cb788c0806b5d9e907ff058bb69
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406296
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-06-10 14:57:49 +00:00
Robert Phillips
7b931f8f78 Add possibility of not compiling OGA files
The plan is to be able to compile and test NGA-only, OGA-only and both

Bug: skia:11837
Change-Id: Ib79cc2c2c437c72def8649392b345648f49300fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416799
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-10 13:10:19 +00:00
Ethan Nicholas
9173b3ff9a Fixed constructor signature in skstd::string_view
Prior to this change, creating a string_view from a string was broken.
We would copy the string, take a reference to the copy's characters,
and then drop the copy on the floor, causing a use-after-free.

Change-Id: Ieef05c2df5d64c7993a572f490c7096d02bd22fa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/417096
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-09 16:27:19 +00:00
John Stiles
f7f36ae077 Add ProgramKind::kRuntimeBlend for Runtime Blend functions.
Runtime Blend effects always take two input colors--source and
destination--instead of one. This CL adds a new ProgramKind for blend
effects, a new program module (empty for now), and adds a test to
confirm that the signature for blend functions is checked. Currently
these are only accessible via skslc; there's no Runtime Effect API to
create one and the dest color isn't hooked up to anything.

Change-Id: I5272a811d2d76b878cfdf3429efa78c9c8b3fd97
Bug: skia:12080
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416798
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-08 19:34:39 +00:00
Ethan Nicholas
eaa9e07e1c Marked String(string_view) explicit
Change-Id: I56cc7477860a76059f60e78c658622a8daa65441
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416699
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-08 15:22:46 +00:00
Ethan Nicholas
f07b4ce437 Converted DSL APIs to use skstd::string_view.
This is a prerequisite for DSLParser, which will be using
string_view. This CL also adds a new string_view-based DSLType
constructor which will be used by DSLParser..

Change-Id: I228fba32efb0c680455149712a944489b9168bf4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414906
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-06-08 13:49:35 +00:00
Greg Daniel
87fab9f72a Changing dst sample type to flags.
Instead of having an enum that says how to sample the dst in the shader
(or lack of dst sampling), we now rely on whether or not we have a valid
proxy in the GrDstProxyView to know whether we are sampling the dst at
all. Then if so we additionally have GrDstSampleFlags to say whether we
need to use a texture barrier and whether we are sampling from an input
attachment.

Change-Id: Id0390a8ad57ec52674922807f6c050d59b7e75a2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416416
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-06-08 13:22:55 +00:00
Ethan Nicholas
2c9a6ec3a0 Added skstd::string_view
Change-Id: Id02ed33b4fe60663327cc50d79db2bf876ad6df7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415458
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-06-07 21:48:37 +00:00
Brian Osman
443b5da2d2 Remove GrRuntimeFPBuilder, SkRuntimeEffect::makeFP
All callsites moved to the new templated GrSkSLFP factory

Change-Id: If8d0419379c96b5a52b2576a5da1b0a3da8cccbf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415916
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-06-07 18:50:47 +00:00
Brian Salomon
dc03537758 Reland "Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH"
This is a reland of 7788b3a62f

Original change's description:
> Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH
>
> Previously we blocked all PBO->texture transfers.
>
> Bug: angleproject:5542
>
> Change-Id: I1decfbc9293c03da125716c73e6d635e2ab9cb1d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406997
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

Bug: angleproject:5542
Change-Id: Id2474a47bdab368d36ddfbed335a8c58d5567fad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416477
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>
2021-06-07 18:23:17 +00:00
Robert Phillips
516405c5b0 Add option to switch between OGA and NGA SkGpuDevices
Bug: skia:11837
Change-Id: Id52f05a055c97cd2644bc70d600e9313766f6730
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415796
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-07 15:23:40 +00:00
Chris Dalton
fc8cf91cee Revert "Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH"
This reverts commit 7788b3a62f.

Reason for revert: May be the cause of TransferPixelsToTextureTest failures

Original change's description:
> Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH
>
> Previously we blocked all PBO->texture transfers.
>
> Bug: angleproject:5542
>
> Change-Id: I1decfbc9293c03da125716c73e6d635e2ab9cb1d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406997
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>

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

Bug: angleproject:5542
Change-Id: I5f1047e110aebe36800a7f807dba832ba27a8b3d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/416056
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2021-06-07 12:49:21 +00:00
Nathaniel Nifong
a306dbf5db Allow reduced shader mode to be enabled outside tests.
Bug: b/187535297

Change-Id: I221319713beebc2fdf67fc7d9d2536563f4ba8a1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415760
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
2021-06-04 20:50:07 +00:00
Brian Salomon
7788b3a62f Limit ANGLE PBO workaround to blocking use of GL_UNPACK_ROW_LENGTH
Previously we blocked all PBO->texture transfers.

Bug: angleproject:5542

Change-Id: I1decfbc9293c03da125716c73e6d635e2ab9cb1d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406997
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-06-04 16:40:54 +00:00
Robert Phillips
fa8af0a545 Add methods to access the top device's render target proxy
While the SDC-accessing versions have to stick around due to their
usage in unit tests, they will return null when exercising the NGA.
The render-target-proxy versions will work in both the OGA and NGA
and should, thus, be prefered.

Bug: skia:11837
Change-Id: I36213472e46e9da3ae6561f80d413090ceb6ad3e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/415058
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-06-03 18:16:27 +00:00
Michael Ludwig
0b0ae67e27 Reland "Reland "Draw image filters directly under non-axis-aligned transforms""
This reverts commit 1fe2b80dc7.

Reason for revert: TODO investigating chrome unit test failures

Original change's description:
> Revert "Reland "Draw image filters directly under non-axis-aligned transforms""
>
> This reverts commit 7712db9c24.
>
> Reason for revert: blink unittests and maybe vulkan+skiarenderer masks appear broken. The blink unittests had actually failed with original CL, but was missed because of focus on Android. Not sure what's going on yet.
>
> Original change's description:
> > Reland "Draw image filters directly under non-axis-aligned transforms"
> >
> > This reverts commit 6cafdc069b.
> >
> > Reason for revert: Fixes unit test failure in Android
> >
> > In the original version, this internalSaveLayer() returned early if the
> > strategy was kNoLayer. This diverged from the old code that updated the
> > canvas' clip bounds and then returned before making the layer. A comment
> > had suggested this was maybe okay to switch to this early out, but it
> > turns out that's not the case.
> >
> > In Android's unit tests, it queries the clip bounds on a recording canvas
> > which always uses a no-layer strategy. However, we do need to set the
> > clip bounds of these types of canvas' (or virtual wrappers of a real
> > canvas) so that they stay consistent with a real canvas.
> >
> > The unit tests had two failures, first the bounds and second a color
> > mismatch after reading back. However, the bounds test was an ASSERT_EQ
> > inside an SkDrawable function. ASSERT_EQ aborts the current function, so
> > it never ran the drawRect that sets the color to green. The later
> > readback is outside the drawable function, so that test still happened
> > and failed. The only real issue to fix is the clip bounds tracking; once
> > that unit test succeeds, the color readback will work properly.
> >
> > Original change's description:
> > > Revert "Draw image filters directly under non-axis-aligned transforms"
> > >
> > > This reverts commit f8f23b2030.
> > >
> > > Reason for revert: b/172617382 is creating issues for Android's Webview
> > >
> > > Original change's description:
> > > > Draw image filters directly under non-axis-aligned transforms
> > > >
> > > > This removes hacking the canvas CTM and wrapping the paint's image
> > > > filter in a special MatrixTransform that computed a post-transform
> > > > instead of its documented pre-transform effect. Performance-wise, the
> > > > computed layer sizes should be about the same, but we avoid one less
> > > > render target switch because we apply the transformation while drawing
> > > > to the dst device, vs. transforming into another temporary layer and
> > > > then drawing that to the dst device.
> > > >
> > > > Several important changes in behavior here:
> > > > 1. The DeviceCM record no longer has a stashed matrix to restore and
> > > >    holds its restoration paint directly.
> > > > 2. Devices for image filter inputs can now have device-to-global
> > > >    transforms that are not integer translates.
> > > > 3. The MatrixTransform hack punted when there was perspective because it
> > > >    could produce excessively large temporary images, but the new version
> > > >    appears to work around that. We now impose a maximum layer size to
> > > >    protect against that and automatically scale the layer to prevent it.
> > > >    Perspective image filters otherwise now draw correctly.
> > > > 6. Updated layer sizing code to use the new image filter APIs
> > > > 7. Updated backdrop filter and restore filters to go through the same
> > > >    code paths, although restore filters skip the intermediate image
> > > >    transform.
> > > >     - layer bounds and transforms now go through the updated skif API
> > > >       and is hopefully more straight forward to understand.
> > > > 8. Now we can optimize root color filter nodes of a filter DAG, even if
> > > >    the entire DAG can't be represented as a color filter. The last node
> > > >    is pulled off and composed with the restoration paint instead.
> > > >
> > > > Bug: skia:9074,skia:9283
> > > > Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I098d0e4b8ee067b436400eb9fea047e629544eec
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:9074
> > > Bug: skia:9283
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332737
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: skia:9074
> > Bug: skia:9283
> > Change-Id: Ifd5fed708d05a64ddccbd096fbf29896a44ef9f5
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333123
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
>
> Change-Id: I7758641e0279ab5af44794d70cd381bc0a69f956
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:9074
> Bug: skia:9283
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333756
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com

# Not skipping CQ checks because this is a reland.

Bug: skia:9074
Bug: skia:9283
Change-Id: Ifc0b962d0db8ef5c52fd31689306caca03420702
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334040
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-06-03 13:09:57 +00:00
Ethan Nicholas
8f73edeaf6 Added more SkTOptional APIs
This adds copy constructors / assignment operator, reset(), value(), and
has_value() to SkTOptional.

Change-Id: I564552a75a4c612685cdaa8e80e4359b394b64a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414338
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-06-01 18:54:13 +00:00
Chris Dalton
569c01bfa2 Simplify heuristics for selecting path tessellators
Now that hardware tessellators chop, support raw triangles, and can
handle any path, we don't need complicated logic anymore to determine
when we can't use them. This CL simplifies the criteria for selecting
a tessellation algorithm and adds a fAlwaysPreferHardwareTessellation
context option to override it.

Bug: skia:10419
Change-Id: I8492e8f285ff27eb9d0dd6b1e9817dbeeb386c63
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411496
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
2021-05-25 17:23:02 +00:00
Ethan Nicholas
4ed2baa981 Added skstd::optional
This is needed by the upcoming DSLParser.

Change-Id: I54a0714e55feeb78894df766b14c795970f2c2d4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411308
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-25 14:10:11 +00:00
Brian Osman
1042334c6e Add SkFilterColorProgram
This extracts the logic for SkRuntimeEffect's one-at-a-time handling of
colors, and also makes it more capable. We can now execute color filters
that invoke children with literals, or with the results of other
children (eg, compose color filter).

Change-Id: I53c6db0316a7162c32f2a7b86b35c947cccb42ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408117
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-05-24 15:06:42 +00:00
Mike Reed
ec9d0e865d Move patheffect details to (private) base subclass
bug: skia:11957
Change-Id: Iceaa0ac1d7a3f049d2725629d78c755ad03a2862
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411302
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-05-22 01:55:43 +00:00
Chris Dalton
8447f13c6d Chop tessellated curves that don't fit in a patch
Previously we would completely disable hardware tessellation for a path
if there was any chance of a curve requiring more segments than
supported by the hardware. This CL updates the tessellators to simply
chop paths until they fit in patches, allowing us to finally draw any
path using hardware tessellation.

Bug: skia:10419
Change-Id: I5c9f78cda3e30b8810aff3cb908235965706f2d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410977
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
2021-05-21 23:01:43 +00:00
Mike Reed
8f4e924181 Move class into impl
I think this finishes all public subclasses, so we can proceed next with
moving the virtuals themselves to a private subclass.

Change-Id: I490f3cf6497a6bdcafc1ce756cfdeb32eab18585
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411239
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-05-21 18:06:53 +00:00
Brian Osman
b1e9cb08c1 Remove fExpression (matrix expression) from SampleUsage
Other than GMs, there is exactly one use of matrix-sampling
(GrMatrixEffect). It is always uniform (not literal or an
expression containing a uniform). The uniform always has the
same name. Bake these simplifications in, which also shrinks
SampleUsage quite a bit.

Change-Id: I0d5e32069d710af475ccc1030e2988c5fc965a98
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411296
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-21 18:04:03 +00:00
Eric Boren
465819d7c2 Update Skia milestone to 93
Change-Id: Ib9a9832dbd63b6a306f5c955f4528b195c29c71f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/411278
Reviewed-by: Eric Boren <borenet@google.com>
2021-05-21 15:29:03 +00:00
Mike Reed
ec87dc1b76 Just expose factories for patheffects
bug: skia:11957
Change-Id: If2983fcd1b520a7ae77650d7e5ab226af9db52e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410782
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Tyler Denniston <tdenniston@google.com>
2021-05-20 23:01:45 +00:00
Brian Osman
1391170bee More ctype cleanup in SkSL
- Remove ctypes that were entirely unused
- Remove explicit selection of default ctypes
- After that, only two ctype tokens are needed (SkPMColor4f and SkV4)
  ... remove all of the others from the parser

Change-Id: I2322aab73a19127b3b26850aefdad6140ea0f7e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410057
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-20 19:46:05 +00:00
Brian Salomon
d6584bd999 Add GrColorFormatDesc GrBackendFormat::desc()
Will be used to figure out an appropriate SkColorType for
YUVA images made of texture planes.

Bug: chromium:1113801
Change-Id: I5e1733292a84e082068c9c3557f629856b7aea84
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410097
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-19 16:06:25 +00:00
Brian Osman
c23386ca39 Remove layout(override_coverage)
This was only used in the context of sk_SampleMask, which was removed
recently.

Change-Id: Id70d7af8b3a100ff157c2984bad4131f1b92f317
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/410056
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-18 19:39:54 +00:00
Brian Osman
3adc091af8 Remove layout(tracked) from SkSL
Change-Id: I6019418526def09c6c9f4b22567a2c76542d043c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409876
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-18 17:44:54 +00:00
Ethan Nicholas
55a63afc5f Make it possible to use the DSL from within the compiler itself
The DSL would not previously function within the compiler, because it
expected to be in charge of everything itself. The compiler and DSL also
disagreed about how to handle some things, such as the DSL not
respecting the compiler's override flags.

This CL moves responsibility for much of the setup process into
DSL::Start(), which the compiler now invokes. DSL::Start() now also
takes a ProgramSettings instead of DSL-specific flags, and the
externalFunctions vector has been moved into ProgramSettings.

Change-Id: I283ed8366e25d67f02c43833743c5f8afdedaefc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408136
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-18 15:10:53 +00:00
Brian Salomon
5696bcd0f7 GrColorTypeDesc -> GrColorFormatDesc
Want to also  use this to use this for texture formats so remove
"ColorType" from name.

Also class rather than struct.

Bug: chromium:1113801
Change-Id: Ieb08a3d81c465b92b956d9bc04b39c5783715ea8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/409476
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-05-18 12:56:33 +00:00
Mike Reed
81e2f9355b Expose intercepts on SkFont
Already exposed (on TextBlob), so this makes it available for clients
that may use drawGlyphs directly. (including canvaskit/flutter)

Change-Id: I8b4bd51e13827dc3970d5a6d06f0e0d3031af13c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408638
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-05-14 14:50:42 +00:00
Herb Derby
82fdab48ab reject sizes that will overflow in SkSpan
Change-Id: Ie1eac40fe678529410f3ae4ab0cc7460dedfa4c2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408296
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2021-05-13 19:42:43 +00:00
Brian Osman
43ee3f5930 Fix implicit signedness change warnings in private includes
Both SkColorData.h and SkNx_sse.h are in include/private, but not
(currently) included by any public headers. Adding them to a public
header reveals warnings about implicit conversion changing signedness
(-Wsign-conversion), enforced in our public headers warnings check.

Bug: skia:11995
Change-Id: Iee44b24a6df031431113e2d25e42f0a8dd55a5c0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408056
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2021-05-13 17:10:44 +00:00
Ethan Nicholas
22dcb738b0 Revert "Revert "Added DSL flags""
This reverts commit 9eb0bb6256.

TBR=brianosman@google.com,johnstiles@google.com

Change-Id: I685478018bf48e5c06a57e9ca5542501d41c2b27
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407458
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-05-12 17:50:22 +00:00
Michael Ludwig
9ec377e999 Reland "Simplify quickReject implementation in SkCanvas"
This is a reland of 0a0f4f5c35

This change makes SkCanvas::quickReject always reject empty draw bounds,
whereas previously scale+translate CTMs allowed bounds with w or h == 0
but otherwise contained in the clip to be drawn. This uncovered some
bugs in Skia where bounds shouldn't be empty, and in Flutter where
bounds were legit empty but not expected by the test.

No code changes needed. The issues that required its revert have been
fixed with:
1. https://github.com/flutter/engine/pull/26053 so that platforms that
use an empty typeface, leading to empty draws are just skipped.
2. https://skia-review.googlesource.com/c/skia/+/406140 so that path
effects update bounds so that Android's 1D dash path effect applied to
a horizontal line is properly not rejected.

Based on the period of time where the original CL was landed, some perf
data was collected.
- There were no significant changes in most SKPs or SVGs, except for a
Flutter page flip skp, which saw a 10% net improvement (perhaps the
flip is drawn with perspective?)
- A 10-20% regression in the motionmark paths skp, but dominated by the MSVC
compiler, so I'm not too concerned about that.
- Perspective microbenchmarks for drawing rectangles are 1.5-2x faster.
- quickReject microbenchmarks are about 2x slower.

The last two microbenchmark results aren't surprising since perspective
was the largest improvement in perf for SkM44::MapRect vs.
SkMatrix::mapRect, and the scale+translate specializations in Skmatrix
were maybe 50% faster than SkM44's. That would account for some of the
slow downs, and the rest could be explained by moving away from the
SIMD rect intersection and nan test.

Since these microreductions don't seem to bleed into more complex
benchmarks, I'm inclined to keep the code simple and not bring back the
custom intrinsics.

Original change's description:
> Simplify quickReject implementation in SkCanvas
>
>  - SkCanvas no longer keeps fIsScaleTranslate bool that has to stay in
>    sync with the type of the matrix.
>  - No more fast or slow path for quickReject, the Sk4f code has been
>    completely removed.
>  - Uses SkM44::mapRect instead of SkMatrix::mapRect. This is slightly
>    slower for S+T, but much faster for other transforms. I'm hopeful we
>    won't notice the regression in the grand scheme for S+T, since the
>    code is a lot simpler now.
>  - The final isFinite() and intersects() check for quickReject uses
>    SkRect's functions instead of hand-written SSE/NEON. If we think this
>    is optimization is necessary, I'm hoping we can rewrite it in terms
>    of skvx instead of specific instructions.
>  - Consolidated how the quick-reject bounds outsetting into
>    computeDeviceClipBounds, and added an option to skip outsetting for
>    the one call site that doesn't want it.
>
> Bug: skia:10987
> Change-Id: I3cf2a73636cdeed06d12cab4548cfb94d1eb074a
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405198
> Commit-Queue: Mike Reed <reed@google.com>
> Auto-Submit: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Mike Reed <reed@google.com>

Bug: skia:10987
Change-Id: Id0d4b4ecebf0b83ae30f7e1a263961ab25de28dd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407358
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-05-12 15:46:12 +00:00
Brian Osman
a5842bc903 Move SkSpan to include/, for use in public API
Change-Id: I674f038600afd6d49316c1ece515941ee5579068
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406939
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-12 13:19:32 +00:00
Brian Osman
9eb0bb6256 Revert "Added DSL flags"
This reverts commit 71430593f0.

Reason for revert: Clang-tidy bot unhappy. (Not sure how this slipped by).

Original change's description:
> Added DSL flags
>
> This adds some basic flags to the DSL initialization which allows us to
> toggle things like optimization and validation.
>
> Change-Id: I35b10526af1678c88901eaacd5a2c4a9f5cd21a7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406896
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>

TBR=brianosman@google.com,ethannicholas@google.com,johnstiles@google.com

Change-Id: I7512b8bcc6e94707949904eec42c396faa7fdaf8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407176
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-11 22:04:10 +00:00
Ethan Nicholas
71430593f0 Added DSL flags
This adds some basic flags to the DSL initialization which allows us to
toggle things like optimization and validation.

Change-Id: I35b10526af1678c88901eaacd5a2c4a9f5cd21a7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406896
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-11 20:44:29 +00:00
Ethan Nicholas
b22fcaf627 Added DSL layout() support
Change-Id: I698dd607ff4676b6fb29be0a718c6073b66dc7c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406336
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-05-11 19:52:59 +00:00
Florin Malita
4882f97829 [svgcanvas] Add support for relative path encoding
- expand SkParsePath to support relative path encoding
 - introduce a new SkSVGCanvas flag for clients to opt into relative
   encoding

Bug: skia:11981
Change-Id: I2d6c63254df23311f1a86dee9481bde9531c3b61
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406876
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
2021-05-11 17:44:59 +00:00
Michael Ludwig
4e1c1a77ad Implement computeFastBounds for PathEffects
Makes computeFastBounds not part of the public API, it's only accessible
to subclasses of SkPathEffect, GrStyle, and SkPaint. Subclasses can
invoke it other path effects using SkPathEffectPriv::ComputeFastBounds.

Changes the internal function to
  bool computeFastBounds(SkRect* bounds) const;

Subclasses of SkPathEffect must implement this, and can choose to return
false when fast bounds aren't computable.

Provides implementations of computeFastBounds() for path effects
bundled with Skia.

Bug: skia:11974
Change-Id: I545ccf99b4e669d3af9df13acfac28573306fab8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406140
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-05-11 17:01:59 +00:00
Ethan Nicholas
614fb1ef9c Removed early_fragment_tests layout qualifier
This layout qualifier is not actually used anywhere.

Change-Id: I817c9affdd00e492c70f251eb52680644b7ff3f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406141
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-10 23:21:34 +00:00
Brian Osman
a372429440 Align SkSpan API with std::span
SkSpan is a convenient type to use on API boundaries - callers can have
their collection in a stack-allocated array, or any contiguous container
(std::vector, etc). Those will all implicitly convert to SkSpan, making
call-sites easy to read/write.

Before making it part of Skia's public API, this CL removes parts of the
API that aren't present in std::span -- when Skia moves to C++20, this
should allow us to use std::span instead, and remove SkSpan entirely.

The most disruptive change is the removal of `int count()`. That's
replaced by a new free function `SkCount` that works on any container,
and incorporates the overflow check from SkTo<int>.

Change-Id: I86cdfad1700f341da3b81a965b396ca9d8b79df9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405816
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-10 17:41:52 +00:00
Ben Wagner
51308f145c SkTHashTable assert key self equal.
Add an assert in SkTHashTable::uncheckedSet that each added key is equal
to itself. This is an implied precondition which is easy to get wrong if
the key contains floating point values which may become NaN.

Motivated by https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30314
which would have been much easier to track down with this assert, since
the issue would have been discovered at insertion instead of much later
on removal.

Change-Id: I4eabb6892d2bff1e7bc33c04fd6b297b189a3b02
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405695
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-05-10 15:51:02 +00:00
Jorge Betancourt
062793401d [androidkit] optimize JNI calls in AndroidKit.Matrix transformations
Note: Shouldn't add or change the Skia API, only accepts an optional z value to preScale()

Change-Id: Ic73c723ebc2b75acca1fce5395953434ef1582e6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404376
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Jorge Betancourt <jmbetancourt@google.com>
2021-05-07 16:17:09 +00:00
Greg Daniel
daa02f4021 Revert "Simplify quickReject implementation in SkCanvas"
This reverts commit 0a0f4f5c35.

Reason for revert: possible cause of flutter roll failure

Original change's description:
> Simplify quickReject implementation in SkCanvas
>
>  - SkCanvas no longer keeps fIsScaleTranslate bool that has to stay in
>    sync with the type of the matrix.
>  - No more fast or slow path for quickReject, the Sk4f code has been
>    completely removed.
>  - Uses SkM44::mapRect instead of SkMatrix::mapRect. This is slightly
>    slower for S+T, but much faster for other transforms. I'm hopeful we
>    won't notice the regression in the grand scheme for S+T, since the
>    code is a lot simpler now.
>  - The final isFinite() and intersects() check for quickReject uses
>    SkRect's functions instead of hand-written SSE/NEON. If we think this
>    is optimization is necessary, I'm hoping we can rewrite it in terms
>    of skvx instead of specific instructions.
>  - Consolidated how the quick-reject bounds outsetting into
>    computeDeviceClipBounds, and added an option to skip outsetting for
>    the one call site that doesn't want it.
>
> Bug: skia:10987
> Change-Id: I3cf2a73636cdeed06d12cab4548cfb94d1eb074a
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405198
> Commit-Queue: Mike Reed <reed@google.com>
> Auto-Submit: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Mike Reed <reed@google.com>

TBR=mtklein@google.com,reed@google.com,michaelludwig@google.com

Change-Id: I1a373740ee167827b9a6a2eee9afb7f814641fb0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10987
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405616
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-05-07 12:55:19 +00:00
Michael Ludwig
0a0f4f5c35 Simplify quickReject implementation in SkCanvas
- SkCanvas no longer keeps fIsScaleTranslate bool that has to stay in
   sync with the type of the matrix.
 - No more fast or slow path for quickReject, the Sk4f code has been
   completely removed.
 - Uses SkM44::mapRect instead of SkMatrix::mapRect. This is slightly
   slower for S+T, but much faster for other transforms. I'm hopeful we
   won't notice the regression in the grand scheme for S+T, since the
   code is a lot simpler now.
 - The final isFinite() and intersects() check for quickReject uses
   SkRect's functions instead of hand-written SSE/NEON. If we think this
   is optimization is necessary, I'm hoping we can rewrite it in terms
   of skvx instead of specific instructions.
 - Consolidated how the quick-reject bounds outsetting into
   computeDeviceClipBounds, and added an option to skip outsetting for
   the one call site that doesn't want it.

Bug: skia:10987
Change-Id: I3cf2a73636cdeed06d12cab4548cfb94d1eb074a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405198
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-05-06 20:45:17 +00:00
Michael Ludwig
97f85bb7fd Remove SkTextBlobDiffCanvas, use tracking device directly with base SkCanvas
Chromium has been updated to use makeAnalysisCanvas directly and there are
no more references to SkTextBlobDiffCanvas as a type in its code base.

Since the GlyphTrackingDevice extends SkNoPixelsDevice, any SkCanvas that
uses it is effectively a "no-draw" canvas. However, by returning a base
SkCanvas the text tracking now automatically happens in the context of
the base's AutoLayerForImageFilter handling it applies on every draw. This
means that drawing a text blob with an image filter that modifies the
transform state will now be analyzed in that context automatically
(simplifying code in chrome after this lands).

Another behavioral change is that all non-text draws will still go through
the base SkCanvas' virtuals and invoke the device function. Since it's an
SkNoPixelsDevice, it'll still be a no-op, it just happens a little later.
This won't really impact performance because oop-r already inspects their
operations and only plays back text and transform related ones to the
analysis canvas, so we shouldn't really see non-text draws being invoked
anyways.

Bug: chromium:1187246
Change-Id: I83f86571300751f385b3065dfe889f218fa1edc6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/405196
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2021-05-06 16:11:57 +00:00
Ethan Nicholas
722cb67b09 Improved DSL APIs in preparation for DSLParser
This includes several new array variants of existing APIs, DSLBlock now
supporting SymbolTables, and a couple of other minor changes needed by
the upcoming DSLParser.

Change-Id: I71feb268feb27cf7ff453cc59046091779bffe06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404779
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-06 15:46:47 +00:00
Brian Osman
c9125aa8f3 Reland "Better first-class shader & color filter support in runtime effects"
This is a reland of adadb95a9f
... adds a temporary workaround for some Android framework code.

Original change's description:
> Better first-class shader & color filter support in runtime effects
>
> This does a few things, because they're all intertwined:
>
> 1) SkRuntimeEffect's API now includes details about children (which Skia
>    stage was declared, not just the name). The factories verify that the
>    declared types in the SkSL match up with the C++ types being passed.
>    Today, we still only support adding children of the same type, so the
>    checks are simple. Once we allow mixing types, we'll be testing the
>    declared type against the actual C++ type supplied for each slot.
> 2) Adds sample variants that supply the input color to the child. This
>    is now the only way to invoke a colorFilter child. Internally, we
>    support passing a color when invoking a child shader, but I'm not
>    exposing that. It's not clearly part of the semantics of the Skia
>    pipeline, and is almost never useful. It also exposes users to
>    several inconsistencies (skbug.com/11942).
> 3) Because of #2, it's possible that we can't compute a reusable program
>    to filter individual colors. In that case, we don't set the constant
>    output for constant input optimization, and filterColor4f falls back
>    to the slower base-class implementation.
>
> Bug: skia:11813 skia:11942
> Change-Id: I06c41e1b35056e486f3163a72acf6b9535d7fed4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401917
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>

Bug: skia:11813 skia:11942
Change-Id: I2c31b147ed86fa8c4dddefb7066bc1d07fe0d285
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404637
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-05-05 22:06:46 +00:00
Michael Ludwig
daa9b8e4d9 Add mapRect function and RectToRect constructor to SkM44
The SkM44::RectToRect function matches the semantics of
SkMatrix::RectToRect(kFill_ScaleToFit). No other ScaleToFit variants are
ported over to SkM44.

skottie uses some instances of kCenter_ScaleToFit so that functionality
may need to be added in the future (in SkM44 or in skottie). There are
no current usages of the kStart and kEnd_ScaleToFit semantics.

The SkM44::mapRect() function is implemented to correspond to the
SkMatrix::mapRect() that returns the mapped rect (instead of modifying a
pointer) and always has ApplyPerspectiveClip::kYes. This was chosen to
keep its behavior simple and because perspective clipping is almost
always the right thing to do. In the new implementation there is no
longer a performance cliff to worry about (see below). For the timebeing
mapRect is hidden behind SkMatrixPriv::MapRect().

Performance:
I added benchmarks for mapRect() on SkM44 and SkMatrix that use the same
matrices to get a fair comparison on their different specializations.
SkMatrix has a very efficient mapRect when it's scale+translate or
simpler, then another impl. for affine matrices, and then falls back to
SkPath clipping when there's perspective. On the other hand, SkM44 only
has 2 modes: affine and perspective.

On my desktop, with a Ryzen 9 3900X, here are the times for 100,000 calls
to mapRect for different types of matrices:
                         SkMatrix    SkM44
scale+translate           0.35 ms    0.42 ms
rotate                    1.70 ms    0.42 ms
perspective              63.90 ms    0.66 ms
clipped-perspective      138.0 ms    0.96 ms

To summarize, the SkM44::mapRect is almost as fast as the s+t specialization
in SkMatrix, but for all non-perspective matrices. For perspective matrices
it's only 2x slower than that specialization when no vertices are clipped,
and still almost 2x faster than the affine specialization when vertices are
clipped (and 100x faster than falling back to SkPath).

Given that, there's the open question of whether or not keeping an affine
specialization is worth it for SkM44's code size.

Bug: skia:11720
Change-Id: I6771956729ed64f3b287a9de503513375c9f42a0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402957
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
2021-05-05 19:57:26 +00:00
Greg Daniel
4fc3a01159 Move all GrTFlagsMask operators into bitfield macro definitions.
This removes the templated versions of these operators. This should help
the case where clients would get compiler errors in their code with
errors claiming failed matches to these ganesh operators. The errors were
correct, but would be confusing for clients to see. Now with this change
the various operators are defined for specific types so a client shouldn't
get errors for their own enums anymore.

Bug: chromium:1204688
Change-Id: Ie3450834da7734a161af303ca6c8f458dd173513
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403596
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-05-04 20:02:15 +00:00
Ethan Nicholas
371f6e18e5 Refactored SkSL function creation and error handling
This breaks up the giant IRGenerator::convertFunction method into more-
manageable chunks, moves the functionality into FunctionDeclaration,
and funnels the DSL through it so it receives the same error checking.

Change-Id: Icf2ac650ab3d5276d8c0134062a4e7e220f9bf32
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402778
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-04 19:25:25 +00:00
Ethan Nicholas
a1a0b92b04 Added DSLWrapper so DSL classes can be used in containers
This will be used by the upcoming DSLParser, which needs to be able to
put DSLExpression and DSLVar into containers such as std::vector and
std::optional.

Change-Id: I8d367cfd0b3a852a368c69a5b3be6c0eaa41d74a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404156
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-05-04 17:19:35 +00:00
Greg Daniel
c2cca5a8a0 Revert "Better first-class shader & color filter support in runtime effects"
This reverts commit adadb95a9f.

Reason for revert: breaking android

Original change's description:
> Better first-class shader & color filter support in runtime effects
>
> This does a few things, because they're all intertwined:
>
> 1) SkRuntimeEffect's API now includes details about children (which Skia
>    stage was declared, not just the name). The factories verify that the
>    declared types in the SkSL match up with the C++ types being passed.
>    Today, we still only support adding children of the same type, so the
>    checks are simple. Once we allow mixing types, we'll be testing the
>    declared type against the actual C++ type supplied for each slot.
> 2) Adds sample variants that supply the input color to the child. This
>    is now the only way to invoke a colorFilter child. Internally, we
>    support passing a color when invoking a child shader, but I'm not
>    exposing that. It's not clearly part of the semantics of the Skia
>    pipeline, and is almost never useful. It also exposes users to
>    several inconsistencies (skbug.com/11942).
> 3) Because of #2, it's possible that we can't compute a reusable program
>    to filter individual colors. In that case, we don't set the constant
>    output for constant input optimization, and filterColor4f falls back
>    to the slower base-class implementation.
>
> Bug: skia:11813 skia:11942
> Change-Id: I06c41e1b35056e486f3163a72acf6b9535d7fed4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401917
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>

TBR=mtklein@google.com,bsalomon@google.com,brianosman@google.com

Change-Id: I94ba57e73305b2302f86fd0c1d76f667d4e45b92
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11813 skia:11942
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/404117
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-05-04 13:36:26 +00:00
Ethan Nicholas
b83199e289 Added unsigned types and type query functions to DSL
Change-Id: I721825d1a38e9f6846b94f84d14cb8c85b7a7519
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403601
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-05-04 13:14:15 +00:00
Ethan Nicholas
0cb3b8280b Improved DSLType constructor signatures
Being able to Construct() arbitrary types is necessary for the upcoming
DSLParser.

Change-Id: I2d439b4a1db7a460043efa5f0e9207b6073e9f1f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/403696
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-05-04 13:08:05 +00:00
Brian Osman
adadb95a9f Better first-class shader & color filter support in runtime effects
This does a few things, because they're all intertwined:

1) SkRuntimeEffect's API now includes details about children (which Skia
   stage was declared, not just the name). The factories verify that the
   declared types in the SkSL match up with the C++ types being passed.
   Today, we still only support adding children of the same type, so the
   checks are simple. Once we allow mixing types, we'll be testing the
   declared type against the actual C++ type supplied for each slot.
2) Adds sample variants that supply the input color to the child. This
   is now the only way to invoke a colorFilter child. Internally, we
   support passing a color when invoking a child shader, but I'm not
   exposing that. It's not clearly part of the semantics of the Skia
   pipeline, and is almost never useful. It also exposes users to
   several inconsistencies (skbug.com/11942).
3) Because of #2, it's possible that we can't compute a reusable program
   to filter individual colors. In that case, we don't set the constant
   output for constant input optimization, and filterColor4f falls back
   to the slower base-class implementation.

Bug: skia:11813 skia:11942
Change-Id: I06c41e1b35056e486f3163a72acf6b9535d7fed4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401917
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-05-04 01:29:57 +00:00
Chris Dalton
5dfb3f4068 Collect DMSAA stats
Adds counters for the number of render passes, number of MSAA render
passes, and each op that either does or would trigger MSAA. Adds a
bot that collects stats on the html (not svg) skps.

Bug: skia:11396
Change-Id: Ic48263d6310670d8f0d09ec4c4bf6a2b83fc7d02
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/401636
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2021-05-01 00:46:22 +00:00
Ethan Nicholas
e9c2c5a4c3 Added support for DSL global variables
This adds an explicit DeclareGlobal call, which must now be called for
variables that were previously implicitly global.

Change-Id: Iaf838880d1033ee52aac9246e31e3bda9a3b36f0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402399
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-30 18:05:19 +00:00
Ethan Nicholas
8a6537d87e Added DSL support for static if & switch statements
Change-Id: If11443997ae29266bf46da77c1e4f9583fa3f5a5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402577
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-30 17:31:49 +00:00
Ethan Nicholas
a60cc3ea41 Fix DSL handling of doubles
Previously, "x = 1.0" (as opposed to 1.0f) would fail with an ambiguous
operator resolution.

Change-Id: I9bcb4115d209a2aadb3fc4c237b61c345b25ca00
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/400619
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2021-04-30 13:47:18 +00:00
Brian Osman
552fcb9a1b Remove flexible runtime effects entirely
All internal usage has migrated to MakeFor..., this removes the old
program kind, and updates some tests.

Bug: skia:11813
Change-Id: I56733b071270e1ae3fab5d851e23acf6c02e3361
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402536
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-04-29 16:02:27 +00:00
Brian Osman
83dae92318 Remove SkSL sample-with-matrix implementation
Simplifies SampleUsage quite a bit (no need to track multiple kinds of
sampling, variable matrices don't exist any more, etc...).

Change-Id: I58b8de7218d00c4d882d2650672e5fe01892a062
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402177
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-04-29 12:46:57 +00:00
John Stiles
65d7ab2c07 Loosen ES3 restrictions in Runtime Effects for debugging.
This CL adds a RuntimeEffect option flag which skips over the various
`strictES2Mode` checks sprinkled throughout IR generation.

Runtime Effects still won't allow a lot of ES3 things (the Pipeline
stage will reject unsupported statement types, SkVM doesn't support most
non-ES2 constructs, etc). However, this change will give us the ability
to test many more features involving arrays and structs that previously
were off-limits due to ES2 restrictions, and will shore up some
legitimate gaps in our testing. This is a useful starting point to allow
for improved test coverage.

Change-Id: I4a5bc43914e65fc7e59f1cecb76a0ec5a7f05f2f
Bug: skia:11209
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/402157
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-04-28 19:59:36 +00:00