Commit Graph

852 Commits

Author SHA1 Message Date
Brian Salomon
7508b54af3 Reland "Add GrRuntimeFPBuilder"
This is a reland of 4b39aaf2cb

Original change's description:
> Add GrRuntimeFPBuilder
>
> Like SkRuntimeShaderBuilder but for internal use for creating FPs.
>
> Currently it requires that the code be a static string so it can
> easily make a static SkRuntimeEffect instance for each effect.
>
> Bug: skia:11771
>
> Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Bug: skia:11771
Cq-Include-Trybots: luci.skia.skia.primary:Build-Debian10-GCC-x86_64-Release-Shared_Docker,Build-Win-Clang-x86_64-Release-Shared,Build-Win-MSVC-x86_64-Release-Shared
Change-Id: I10a7974aa209f9cd63a5dc1ef21a36822b49bda3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388097
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-03-23 14:08:48 +00:00
Brian Osman
c18a645bf5 Implement constantOutputForConstantInput on GrSkSLFP
Bug: skia:11770
Change-Id: I118a85e58a5422ff42c693fd8f85af098d8f8a25
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387816
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-03-22 22:18:37 +00:00
Brian Salomon
50af8c2656 Revert "Add GrRuntimeFPBuilder"
This reverts commit 4b39aaf2cb.

Reason for revert: DLL fail

Original change's description:
> Add GrRuntimeFPBuilder
>
> Like SkRuntimeShaderBuilder but for internal use for creating FPs.
>
> Currently it requires that the code be a static string so it can
> easily make a static SkRuntimeEffect instance for each effect.
>
> Bug: skia:11771
>
> Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

Change-Id: I13e22674a1bcb07b86342189bab84fc6cbb357e9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:11771
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387817
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-03-22 18:24:18 +00:00
Brian Salomon
4b39aaf2cb Add GrRuntimeFPBuilder
Like SkRuntimeShaderBuilder but for internal use for creating FPs.

Currently it requires that the code be a static string so it can
easily make a static SkRuntimeEffect instance for each effect.

Bug: skia:11771

Change-Id: I18148eb33e7d28c804e4a13bcef88c89c06b2c9b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/386889
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-22 15:57:36 +00:00
Mike Reed
501ca219f6 Remove dead matrixfilter factory
Bug: skia:7650
Change-Id: I340d3072f23fc9ca275ac4b0f00919938b39b5dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/387516
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-03-21 15:23:38 +00:00
Brian Osman
9e6fc64988 Add SkColorFilterBase::onFilterColor4f virtual, optimize runtime CF
The non-virtual filterColor4f handles premul and unpremul at the API
boundary. onFilterColor4f always works on premul colors.

To get the performance benefits, all color filters in a chain need
to override the virtual. For now, WorkingFormatColorFilter is the
other target, as builtin filters that use runtime effects are always
wrapped with that.

Net effect on matrix_filterColor4f timing:
  before: 10000 ns
  after :   380 ns

Bug: skia:11730
Change-Id: I43d06f22c082636c4eca9e58dc3bc8225d09c910
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/383705
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-03-12 17:50:06 +00:00
Mike Reed
1cf56817f8 Remove supported for (removed) inheriting paint filter-quality
Bug: skia:7650
Change-Id: Ia4414d32b63b686b9987a7d1424c89fe57bd1afe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/380836
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Auto-Submit: Mike Reed <reed@google.com>
2021-03-09 00:58:09 +00:00
Brian Osman
c7206ccb30 Revert "Reland "Reland "export SkRuntimeShaderBuilder"""
This reverts commit 2960b6a62c.

Reason for revert: Android is invoking copy constructor.

Original change's description:
> Reland "Reland "export SkRuntimeShaderBuilder""
>
> This is a reland of a950fef9db
> ... with copy/move ctors/operators deleted for Clang warning.
>
> Original change's description:
> > Reland "export SkRuntimeShaderBuilder"
> >
> > This is a reland of f1a937f141
> >
> > Original change's description:
> > > export SkRuntimeShaderBuilder
> > >
> > > ... like we do SkRuntimeEffect.
> > >
> > > Change-Id: I024f1716b2f818d24b002213c02fa83d2b271123
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377757
> > > Commit-Queue: Mike Klein <mtklein@google.com>
> > > Commit-Queue: Brian Osman <brianosman@google.com>
> > > Auto-Submit: Mike Klein <mtklein@google.com>
> > > Reviewed-by: Brian Osman <brianosman@google.com>
> >
> > Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared
> > Change-Id: I82c440be4ea53e21c6c3d2b6999d832f71563d83
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377859
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Mike Klein <mtklein@google.com>
>
> Change-Id: I29aaa84b6ff995b4226f2b9b34a94f4d2e9964dd
> Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared,Build-Win-Clang-x86_64-Release-Shared
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377867
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>

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

Change-Id: Iba51d1823bbee084c6a9055d7f41b09786b5418e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared
Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-Clang-x86_64-Release-Shared
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/378316
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-03-02 14:33:14 +00:00
Mike Klein
2960b6a62c Reland "Reland "export SkRuntimeShaderBuilder""
This is a reland of a950fef9db
... with copy/move ctors/operators deleted for Clang warning.

Original change's description:
> Reland "export SkRuntimeShaderBuilder"
>
> This is a reland of f1a937f141
>
> Original change's description:
> > export SkRuntimeShaderBuilder
> >
> > ... like we do SkRuntimeEffect.
> >
> > Change-Id: I024f1716b2f818d24b002213c02fa83d2b271123
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377757
> > Commit-Queue: Mike Klein <mtklein@google.com>
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Auto-Submit: Mike Klein <mtklein@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared
> Change-Id: I82c440be4ea53e21c6c3d2b6999d832f71563d83
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377859
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>

Change-Id: I29aaa84b6ff995b4226f2b9b34a94f4d2e9964dd
Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared,Build-Win-Clang-x86_64-Release-Shared
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377867
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-03-01 23:27:42 +00:00
Mike Klein
f1af57cf0a Revert "Reland "export SkRuntimeShaderBuilder""
This reverts commit a950fef9db.

Reason for revert: sigh, Build-Win-Clang-x86_64-Release-Shared too

Original change's description:
> Reland "export SkRuntimeShaderBuilder"
>
> This is a reland of f1a937f141
>
> Original change's description:
> > export SkRuntimeShaderBuilder
> >
> > ... like we do SkRuntimeEffect.
> >
> > Change-Id: I024f1716b2f818d24b002213c02fa83d2b271123
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377757
> > Commit-Queue: Mike Klein <mtklein@google.com>
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Auto-Submit: Mike Klein <mtklein@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared
> Change-Id: I82c440be4ea53e21c6c3d2b6999d832f71563d83
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377859
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>

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

Change-Id: Ia0f2da7a6761cad2020449d2d1be2f844f629f9c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377866
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-03-01 21:45:33 +00:00
Mike Klein
a950fef9db Reland "export SkRuntimeShaderBuilder"
This is a reland of f1a937f141

Original change's description:
> export SkRuntimeShaderBuilder
>
> ... like we do SkRuntimeEffect.
>
> Change-Id: I024f1716b2f818d24b002213c02fa83d2b271123
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377757
> Commit-Queue: Mike Klein <mtklein@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Auto-Submit: Mike Klein <mtklein@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

Cq-Include-Trybots: luci.skia.skia.primary:Build-Win-MSVC-x86_64-Release-Shared
Change-Id: I82c440be4ea53e21c6c3d2b6999d832f71563d83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377859
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-03-01 19:40:21 +00:00
Mike Klein
135500d33d Revert "export SkRuntimeShaderBuilder"
This reverts commit f1a937f141.

Reason for revert: Build-Win-*-x86_64-Release-Shared

Original change's description:
> export SkRuntimeShaderBuilder
>
> ... like we do SkRuntimeEffect.
>
> Change-Id: I024f1716b2f818d24b002213c02fa83d2b271123
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377757
> Commit-Queue: Mike Klein <mtklein@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Auto-Submit: Mike Klein <mtklein@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

Change-Id: I594c123c5161102e8341033d7a62c4bb98ab3835
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377858
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-03-01 16:08:02 +00:00
Mike Klein
f1a937f141 export SkRuntimeShaderBuilder
... like we do SkRuntimeEffect.

Change-Id: I024f1716b2f818d24b002213c02fa83d2b271123
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/377757
Commit-Queue: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-01 15:03:00 +00:00
Michael Ludwig
6c406b8270 Remove deprecated tile filter header
Also removes the now-empty SkImageFilters::RegisterFlattenables()
function (was public, but is private-use only, so no one should be using
it anyways).

The remainder of SkImageFilters.cpp will be cleaned up in a follow-up CL

Bug: skia:11230
Change-Id: Ibdccff70d37e78e935cadcaff2ac90384e27c990
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372120
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-02-25 19:09:49 +00:00
Brian Osman
a443dc380c Reland "Remove (unused) gpuType from SkRuntimeEffect::Uniform"
This reverts commit 0fdcaa5757.

Reason for revert: Fix landed in Android

Original change's description:
> Revert "Remove (unused) gpuType from SkRuntimeEffect::Uniform"
>
> This reverts commit cc80a47566.
>
> Reason for revert:  IWYU cleanup broke less IWYU-clean Android,
>
> frameworks/native/libs/renderengine/skia/filters/BlurFilter.cpp:180:17: error: variable has incomplete type 'SkRRect'
>         SkRRect roundedRect;
>                 ^
> external/skia/include/core/SkCanvas.h:58:7: note: forward declaration of 'SkRRect'
> class SkRRect;
>
>
> Original change's description:
> > Remove (unused) gpuType from SkRuntimeEffect::Uniform
> >
> > Also remove some unnecessary includes, then IWYU.
> >
> > Change-Id: I41e88f0e661c59e75cb26e28768801b811fe8ee8
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371140
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Reviewed-by: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,brianosman@google.com,johnstiles@google.com
>
> Change-Id: Id655a6835ebffdb4f5f82474c287c09a69a737df
> No-Tree-Checks: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371941
> Reviewed-by: Mike Klein <mtklein@google.com>
> Commit-Queue: Mike Klein <mtklein@google.com>

# Not skipping CQ checks because this is a reland.

Change-Id: I67deaee08f1dfea8d91121b3e665d2e6036b6139
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372216
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-02-19 17:53:47 +00:00
Michael Ludwig
91bfda0ac8 Rename SkImageSource to SkImageImageFilter
Also deletes the unnecessary old header file.

Bug: skia:11230
Change-Id: Ie7c3926fe635a37e617e5e1fcac7c05eb576bbf1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368617
Reviewed-by: Robert Phillips <robertphillips@google.com>
2021-02-18 22:42:37 +00:00
Mike Klein
0fdcaa5757 Revert "Remove (unused) gpuType from SkRuntimeEffect::Uniform"
This reverts commit cc80a47566.

Reason for revert:  IWYU cleanup broke less IWYU-clean Android,

frameworks/native/libs/renderengine/skia/filters/BlurFilter.cpp:180:17: error: variable has incomplete type 'SkRRect'
        SkRRect roundedRect;
                ^
external/skia/include/core/SkCanvas.h:58:7: note: forward declaration of 'SkRRect'
class SkRRect;


Original change's description:
> Remove (unused) gpuType from SkRuntimeEffect::Uniform
>
> Also remove some unnecessary includes, then IWYU.
>
> Change-Id: I41e88f0e661c59e75cb26e28768801b811fe8ee8
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371140
> Commit-Queue: Brian Osman <brianosman@google.com>
> Reviewed-by: John Stiles <johnstiles@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>

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

Change-Id: Id655a6835ebffdb4f5f82474c287c09a69a737df
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371941
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-02-18 13:16:33 +00:00
Brian Osman
cc80a47566 Remove (unused) gpuType from SkRuntimeEffect::Uniform
Also remove some unnecessary includes, then IWYU.

Change-Id: I41e88f0e661c59e75cb26e28768801b811fe8ee8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/371140
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-02-17 20:33:28 +00:00
Mike Reed
ff0cd8c506 Remove old factory for Image()
Bug: skia:7650
Change-Id: I044c25206885669ae2e60cccb7a1cb4ef3a1430f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370796
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-02-16 19:26:33 +00:00
Brian Salomon
ed76e8109b Reenable Wdeprecated-copy-dtor
Change-Id: Id28ed827c4a896805c6d4eead339146fdd49e35f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/359560
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-02-16 17:53:28 +00:00
Mike Reed
7cb0f6e970 Don't define legacy flag
Change-Id: I0c0b5012af81647e75c5bbaab9f7d69dade53a8b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370476
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-02-15 14:25:13 +00:00
Mike Reed
708dc4f8ca Hide legacy imagefilters::image using filter-quality
Small diffs in a GM -- due to the dual nature of kMedium (cpu and gpu)
Another reason to stop using it, and switch to the more-explicit
sampling.

Bug: skia:7650
Change-Id: Ie7575071b19778626da7f94804abaaa11861a050
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370259
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-02-14 14:58:00 +00:00
Mike Klein
7a2ff98ce6 clean up SK_SUPPORT_LEGACY_RUNTIME_EFFECTS
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Change-Id: I4475982f0a5b17bcc4bae4b3f75557969cc70fd2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369856
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-02-13 22:01:14 +00:00
John Stiles
1f19ce2272 Reland "Remove deprecated form of SkRuntimeEffect::Make."
This reverts commit e89b50ae05.

Reason for revert: landed Android fix at http://ag/13544365 (master) and
http://ag/13554983 (sc-dev)

Original change's description:
> Android roll broke with a compilation error:
> frameworks/base/libs/hwui/jni/Shader.cpp:243:37: error: no matching function for call to 'get'
>     sk_sp<SkRuntimeEffect> effect = std::get<0>(result)
>
> Revert "Remove deprecated form of SkRuntimeEffect::Make."
>
> This reverts commit 1cda194366.
>
> Reason for revert: <INSERT REASONING HERE>
>
> Original change's description:
> > Remove deprecated form of SkRuntimeEffect::Make.
> >
> > Chromium has migrated to the new API at https://crrev.com/c/2675855.
> >
> > Change-Id: Id4af77db2c462348e8031d28f56e543ad619c19c
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367060
> > Reviewed-by: Brian Osman <brianosman@google.com>
> > Commit-Queue: Brian Osman <brianosman@google.com>
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
>
> TBR=mtklein@google.com,brianosman@google.com,johnstiles@google.com
>
> Change-Id: Ie18f865f3b7f5b0263db1e52b19cf6faa0500fdd
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368616
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>

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

Change-Id: I9d679013cb275dc80aaaa977b7f1f4da31f36d1e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369037
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-12 20:57:50 +00:00
Jose Dapena Paz
69b27b55d1 GOLD: workaround static constexpr linking problem with SkImageFilters::CropRect::kNoCropRect
Skia linking fails in GOLD because of missing instanciation of kNoCropRect
in SkImageFilters::CropRect. This breaks compilation of skia_renderer
service. More details of this kind of issue in GOLD can be seen in
https://chromium-review.googlesource.com/c/chromium/src/+/2436824

To workaround this, we move the declaration from being a member of
a struct to a namespace constexpr.

bug: chromium:819294
Change-Id: I52e98be440d05236df886b6ff83b84f29cbe7edd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335537
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2021-02-11 14:27:26 +00:00
Stan Iliev
e89b50ae05 Android roll broke with a compilation error:
frameworks/base/libs/hwui/jni/Shader.cpp:243:37: error: no matching function for call to 'get'
    sk_sp<SkRuntimeEffect> effect = std::get<0>(result)

Revert "Remove deprecated form of SkRuntimeEffect::Make."

This reverts commit 1cda194366.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Remove deprecated form of SkRuntimeEffect::Make.
>
> Chromium has migrated to the new API at https://crrev.com/c/2675855.
>
> Change-Id: Id4af77db2c462348e8031d28f56e543ad619c19c
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367060
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>

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

Change-Id: Ie18f865f3b7f5b0263db1e52b19cf6faa0500fdd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368616
Reviewed-by: Stan Iliev <stani@google.com>
Commit-Queue: Stan Iliev <stani@google.com>
2021-02-10 00:05:10 +00:00
John Stiles
1cda194366 Remove deprecated form of SkRuntimeEffect::Make.
Chromium has migrated to the new API at https://crrev.com/c/2675855.

Change-Id: Id4af77db2c462348e8031d28f56e543ad619c19c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/367060
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-02-09 21:27:34 +00:00
Mike Reed
1d62221553 Hide (unused) SkDrawLooper
Bug: skia:8672
Change-Id: Ib8b614d94925b3cc7d02be422dbb7e96ea4c26b6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366338
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2021-02-07 12:49:53 +00:00
Brian Osman
236ddb3e1d Detach pipeline-stage generator from SkSL compiler
This is now structured like the VM generator: Just a function that does
the conversion. Moved all relevant types and constants out of the
compiler, too. The key thing is that we don't need/want an error
handler, because it's too late to fail. We *must* catch all errors
during IR generation.

This is also another step along the path of directly emitting to the
fragment shader builder, rather than generating strings with
placeholders.

Bug: skia:11127
Change-Id: I18591270aa6e56dae1f040275a4b7d4a245007db
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366956
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-06 16:25:32 +00:00
Brian Osman
d76d1863f9 Remove 'f' prefix on SkRuntimeEffect::Uniform struct
Change-Id: Ibb48d30b9c0d80db3bf7b92d8c4a60bd9ce6839d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365696
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-02-04 01:57:53 +00:00
Brian Osman
f863721ccc Remove 'f' prefix on SkRuntimeEffect::Varying struct
Change-Id: I10184e60617f65a513980e5389f226f2ebe3eb46
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/365656
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2021-02-03 22:28:48 +00:00
John Stiles
20e92f77e2 Update SkRuntimeEffect::Make to take an Options struct.
This allows us to control the inline threshold of runtime effects in a
thread-safe way.

The new Make API now returns a struct, for readability; the old Make API
continues to return a tuple.

The old Make function is deprecated and subject to removal. You can
migrate to the new API by passing a default-constructed Options struct.
In this case there will be no difference in behavior.

Change-Id: Ic62d6f294f596d0a61095e35a87ccdbbe0b1cf93
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363785
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2021-02-03 18:03:49 +00:00
Mike Reed
c858554f38 Hide filter-quality from imagefilter::shader
Bug: skia:7650
Change-Id: Ia16f169efdb6be2ce381b9ab3b7f6fcecda26312
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363799
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2021-02-02 17:06:14 +00:00
Mike Reed
9223665316 Guard legacy matrixtransforms, and expose new one
Bug: skia:11236
Bug: skia:11235
Change-Id: I53fc0532a6067c5b30fc0345ded95d50d9955d38
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363098
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2021-02-01 22:10:39 +00:00
Michael Ludwig
747c31e296 Hide SkImageFilter::CropRect
Moves the (SkRect + flags) struct into SkImageFilter_Base with protected
access only. Base constructor and all src/effects/imagefilters Make
functions now take a "const SkRect*" instead. CropRect is still what's
stored and used by filter implementations during filterImage(), but it's
no longer publicly available.

The SkImageFilters factory implementations now can go straight to the
Make functions in src/effects/imagefilters instead of wrapping its
"const SkRect*" in an SkImageFilter::CropRect.

Bug: skia:9296, skia:11230
Change-Id: I2c62f42031910ec405623d4519c8a434cd2b3bdd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361496
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
2021-01-30 16:10:29 +00:00
Michael Ludwig
ed552f8702 Move deprecated image filter headers out of include/ and into src/
Bug: skia:9310
Change-Id: I387f0251f05a2b6f2bc5a759f608d5766ed11ce2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357285
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2021-01-28 00:41:21 +00:00
Brian Salomon
04aef10c64 Add SkRuntimeEffect::makeImage()
Allows creation of an image directly from a RTE. Caller provides the
effect input bindings, image info for the image, and optional local
matrix.

The info's alpha type and colorspace are tags for the output image. No
alpha type or color space conversions are applied to the output of RTE.

CPU does not yet support making kUnpremul images.

Bug: chromium:1151490

Change-Id: I69babc9dbbce4431d756cd7a3eef4753e727d6fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357284
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-01-23 17:40:23 +00:00
Derek Sollenberger
9e1cedda63 Add generic uniform setter function to SkRuntimeShaderBuilder
Change-Id: Idab539a4b39fe5ceab54948c99c0dcd6d19fd345
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352743
Commit-Queue: Derek Sollenberger <djsollen@google.com>
Auto-Submit: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2021-01-14 14:38:18 +00:00
Brian Salomon
4878b3e33c Remove Improved Perlin Noise
Is not used by a major client and can be implemented using runtime
effects for users who want this noise.

Bug: skia:10536
Change-Id: Iaa06e6e1406b808c7f8dc0f76621fecf2becabf5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/352057
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2021-01-11 15:27:26 +00:00
Brian Osman
0a442b71b0 New SkSL code generator that emits directly to skvm
Still TODO:
- Function calls. Can do these by inlining everything (recursively).
- Additional flow control: ES2 for loops can be supported (via
  unrolling), and switch() can be implemented. (Was never done in
  ByteCode).
- Uniforms and params have been set up to work very generically (caller
  just supplies IDs, the generator collates everything into a master
  working list). Builtins should work the same way (caller supplies a
  map of builtin ID -> skvm::Val[]?), so that we don't need a special
  case for device coord.
- Figure out integer type policy. Today, it's a mix of only supporting
  signed integers, and just treating all integers as signed, even if
  they're not.
- Now that defining intrinsics is *much* simpler, stop defining so many
  of them in sksl_public.sksl, and just implement them here.

Change-Id: Id9771444ce54ccf8e6e408c44ebb3780c1170435
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/341980
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-12-17 19:16:25 +00:00
Michael Ludwig
a2c40206c6 Preserve dithering for SkImageFilters::Shader
Migrating chromium code to use SkImageFilters::Shader over
SkPaintImageFilter requires dithering to be preserved for its gradient
fills.

I debated always forcing it to true, but dithering was never turned on
for the turbulence filter and it's not necessary for const color shaders
Given that, I opted to just make it a parameter to the filter factory,
which seems okay since we're unlikely to embed dithering into SkShader
itself, it's a shading-related parameter of SkPaint, and if we migrate
to always dithering, then we can remove it.

Bug: skia:9310
Change-Id: I86f14969e2446f3a84e71e687cb263bcd44cf9d9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338156
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-25 19:41:37 +00:00
Michael Ludwig
4757a60871 Accept SkFilterQuality in SkImageFilters::Shader
This is needed to help ease the migration from SkImageFilters::Paint,
until image shaders always force you to embed sampling options.

Change-Id: Id8dc8c3196a7935073677a5fbb8d35c3bd22f9ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333757
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-13 22:46:20 +00:00
Brian Osman
d7e7659cad Move GrShaderCaps from Program::Settings to Compiler
This ties the caps to the compiler instance, paving the way for
pre-optimizing the shared code. Most of the time, the compiler is
created and owned the GPU instance, so this is fine. For runtime
effects, we now use the shared (device-agnostic) compiler instance
for the first compile, even on GPU. It's configured with caps that
apply no workarounds. We pass the user's SkSL to the backend as
cleanly as possible, and then apply any workarounds once it's part
of the full program.

Bug: skia:10905
Bug: skia:10868
Change-Id: Ifcf8d7ebda5d43ad8e180f06700a261811da83de
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331493
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-11-04 19:38:33 +00:00
Michael Ludwig
01b93eabe2 Add SkImageFilters::Blend rename for Xfermode filter
This better matches SkShaders::Blend and SkColorFilters::Blend factories.

Bug: skia:9310
Change-Id: I02a3fe488a446b803df96518caacff1fdf536e9f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324623
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2020-10-13 14:28:26 +00:00
Michael Ludwig
c98d5b6250 Expand image filter factories to accept more types for crop rects
The original SkIRect* crop rect argument was a little too onerous.
First, as a pointer, it required you to declare your crop rect separately
just to take a pointer to it. Now, you can pass an SkIRect or SkRect in
directly when you are explicitly constructing a cropped filter.

Second, the crop rect is transformed by the same matrix as the other
filter parameters, so it can be scaled and translated. Allowing SkRect
instead of just SkIRect gives more precision and flexibility for local
coordinate systems. Now a crop rect could be defined to be from [-.5, .5]
and still map to real pixels after transformation (this was a request
from the skia-discuss mailing list, and also better matches the SVG spec).

The crop rect argument was always meant to be a convenience, since I
plan to refactor cropping into an indenendent image filter that will
give more explicit control over when the crop is applied in the DAG.
To maintain the convenience for the factories, the constructors of
the new CropRect type are not explicit so that callers don't ever need
to concern themselves with it.

Bug: skia:9296
Change-Id: I29a684cb925f1fca4dabc803114ab2b125660aaa
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324622
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-10-12 20:25:43 +00:00
Michael Ludwig
7d0f853158 Add SkImageFilters::Shader in place of Paint factory
SkImageFilters::Paint did not use every slot of the SkPaint, with only
its color, alpha, color filter, and shader having a meaningful effect on
the image filter result. It was always blended into a transparent dst,
so blend mode wasn't very relevant, and it was always filled to whatever
required geometry, so stroke style, path effect, and mask filters were
ignored or not well specified.

Color, alpha, and color filter can all be combined into an SkShader, so
a more constrained SkImageFilters::Shader provides the same useful
capabilities without as many surprises.

SkImageFilters::Paint still exists, but is deprecated to be removed
once I've confirmed clients aren't depending on it.

Bug: skia:9310
Change-Id: I11a82bda1a5d440726cf4e2b5bfaae4929568679
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323680
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-10-08 22:51:13 +00:00
John Stiles
7571f9e490 Replace 'typedef xxxxx INHERITED' with 'using INHERITED = xxxx;'.
Mechanically updated via Xcode "Replace Regular Expression":

  typedef (.*) INHERITED;
    -->
  using INHERITED = $1;

The ClangTidy approach generated an even larger CL which would have
required a significant amount of hand-tweaking to be usable.

Change-Id: I671dc9d9efdf6d60151325c8d4d13fad7e10a15b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314999
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-09-03 03:41:26 +00:00
Brian Osman
a73c9d7606 Make some internal runtime effect API private
No public user needs these.

Change-Id: Ieeb519a0778b01697c9bbb3b91ce8423eaa94e57
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314316
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2020-09-01 14:51:29 +00:00
Brian Osman
b6bd0d2094 Make SkRuntimeShaderBuilder safe for reuse
Previously, if you snapped off a shader and then changed uniforms
(without drawing & flushing), we'd trigger the SkData assert about
calling writeable_data when not-uniquely-owned. Now we lazily copy the
SkData when necessary.

Includes unit test that previously failed.

Bug: skia:10667
Change-Id: If8d9dd8106d41e66560d760cb36ed83371791fc7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/313678
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-08-27 16:09:37 +00:00
Brian Osman
a4b9169fb6 Remove 'in' variables from SkRuntimeEffect
Runtime effects previously allowed two kinds of global input variables:
'in' variables could be bool, int, or float. 'uniform' could be float,
vector, or matrix. Uniform variables worked like you'd expect, but 'in'
variables were baked into the program statically. There was a large
amount of machinery to make this work, and it meant that 'in' variables
needed to have values before we could make decisions about program
caching, and before we could catch some errors. It was also essentially
syntactic sugar over the client just inserting the value into their SkSL
as a string. Finally: No one was using the feature.

To simplify the mental model, and make the API much more predictable,
this CL removes 'in' variables entirely. We no longer need to
"specialize" runtime effect programs, which means we can catch more
errors up front (those not detected until optimization). All of the API
that referred to "inputs" (the previous term that unified 'in' and
'uniform') now just refers to "uniforms".

Bug: skia:10593
Change-Id: I971f620d868b259e652b3114f0b497c2620f4b0c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/309050
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-08-10 22:00:44 +00:00
Brian Osman
871aa74797 Add support for children to runtime color filters
Like shaders, sampling a null child will return the input color (in
this case, the output of the skia shader stage). This gives us a path
to removing the implicit input color passed to main, which is the real
goal. Using this to create more interesting color filters is also
possible, although we need to add the versions of sample() that take a
color to really unlock the potential.

Change-Id: I6a7506055120756497d7583f14d6f928180825fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308515
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-08-07 14:50:36 +00:00
John Stiles
a6841be235 Enable ClangTidy check llvm-namespace-comment.
This fixes a large number of SkSL namespaces which were labeled as if
they were anonymous, and also a handful of other mislabeled namespaces.
Missing namespace-end comments have been added throughout.
A number of diffs are just indentation-related (adjusting 1- or 3-
space indents to 2-space).

Change-Id: I6c62052a0d3aea4ae12ca07e0c2a8587b2fce4ec
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308503
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2020-08-06 19:07:52 +00:00
Brian Osman
92aac1e1b3 Disallow runtime effect color filters that depend on position
Some of these checks are currently redundant (we don't allow color
filters to have children right now). But the next CL will re-add that
capability, and the unit tests here will ensure we don't re-break things
by allowing child-sampling to violate the color filter invariant.

Change-Id: I54c10d8b1d1e376c13347296765185d42b9f644a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/308285
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-08-06 16:06:47 +00:00
Brian Salomon
d007281c9a Fix clang 12 Wsuggest-override and Wsuggest-destructor-override
Change-Id: Ic44e24057b95bb014504f02a736fb4341afc8971
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304856
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-07-22 01:11:36 +00:00
Brian Osman
48a643daac SkRuntimeEffect: Always include GrTypesPriv, clean up variable type code
GrTypesPriv seems safe to include even without the GPU backend, which
lets us remove the condition from the struct layout. Hoisting and
reformatting the type conversion code just to make the core of the
factory easier to read. (More of this is coming).

Change-Id: I6e36b92789debc7b2630117c285c592ca7cbc37b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/304001
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2020-07-20 16:33:03 +00:00
Brian Osman
1298bc46ac Change SampleMatrix to SampleUsage
It now tracks all sample calls of a child (matrix, explicit coords,
pass through). There is now just one registerChild() call, and the
sampling pattern of that child is fully determined by the SampleUsage
parameter.

Change-Id: Iaadcd325fca64a59f24192aadd06923c66362181
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/299875
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-07-01 16:37:43 +00:00
Brian Osman
be1b837505 Support sample(matrix) with runtime effects
Added sksl_sample_chaining, which draws identically to
fp_sample_chaining, but uses runtime effects that implement each
strategy.

Change-Id: Ib54fbe4fc6d98b4a8e91cf0e3ae6b7e19283ad37
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/299076
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-06-26 16:27:50 +00:00
Michael Ludwig
e88320baec Update how sample(matrix) calls are invoked in SkSL
This removes the kMixed type of SkSL::SampleMatrix. All analysis of FP
sampling due to parent-child relationships is tracked in flags on
GrFragmentProcessor now.

The sample strategy is tracked as follows:
- An FP marks itself as using the local coordinate builtin directly (automatically done for .fp code based on reference to sk_TransformedCoords2D[0]).
- This state propagates up the parent towards the root, marking FPs as using coordinates indirectly. We stop the propagation when we hit a parent FP that explicitly samples the child because it becomes the source of the child's coordinates.
   - If that parent references its local coordinates directly, that kicks off its own upwards propagation.
- Being sampled explicitly propagates down to all children, and effectively disables vertex-shader evaluation of transforms.
   - A variable matrix automatically marks this flag as well, since it's essentially a shortcut to (matrix expression) * coords.
- The matrix type also propagates down, but right now that's only for whether or not there's perspective.
   - This doesn't affect FS coord evaluation since each FP applies its action independently.
   - But for VS-promoted transforms, the child's varying may inherit perspective (or other more general matrix types) from the parent and switch from a float2 to a float3.
- A SampleMatrix no longer tracks a base or owner, GrFragmentProcessor exposes its parent FP. An FP's sample matrix is always owned by its immediate parent.
   - This means that you can have a hierarchy from root to leaf like: [uniform, none, none, uses local coords], and that leaf will have a SampleMatrix of kNone type. However, because of parent tracking, the coordinate generation can walk up to the root and detect the proper transform expression it needs to produce, and automatically de-duplicate across children.

Currently, all FP's that are explicitly sampled have a signature of (color, float2 coord). FP's that don't use local coords, or whose coords are promoted to a varying have a signature of (color).
   - In this case, the shader builder either updates args.fLocalCoords to point to the varying directly, or adds a float2 local to the function body that includes the perspective divide.

GrFragmentProcessor automatically pretends it has an identity coord transform if the FP is marked as referencing the local coord builtin. This allows these FPs to still be processed as part of GrGLSLGeometryProcessor::collectTransforms, but removes the need for FP implementations to declare an identity GrCoordTransform.
   - To test this theory, GrTextureEffect and GrSkSLFP no longer have coord transforms explicitly.
   - Later CLs can trivially remove them from a lot of the other effects.
   - The coord generation should not change because it detects in both cases that the coord transform matrices were identity.

GrGLSLGeometryProcessor's collectTransforms and emitTransformCode has been completely overhauled to recurse up an FP's parent pointers and collect the expressions that affect the result. It de-duplicates expressions between siblings, and is able to produce a single varying for the base local coord (either when there are no intervening transforms, or the root FP needs an explicit coordinate to start off with).


This also adds the fp_sample_chaining GM from Brian, with a few more configurations to fill out the cells.

Bug: skia:10396
Change-Id: I86acc0c34c9f29d6371b34370bee9a18c2acf1c1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297868
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-06-25 14:48:34 +00:00
Mike Reed
b11e627644 Move impl into SkColorFilterBase
No expected changes to results (or public call-sites)

Change-Id: Ia0c5cfe2dc3beda82d91454527eda2e68287afb6
Bug: skia:10426
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298559
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2020-06-25 00:26:11 +00:00
Ethan Nicholas
77968f0d32 Revert "fixed sample(..., matrix) with runtime effects"
This reverts commit fb5ede576d.

Reason for revert: major performance regression due to constant shader recompilation

Original change's description:
> fixed sample(..., matrix) with runtime effects
> 
> Change-Id: Id5b7f1b5e992c587be000e112706bedfe00c90fd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294697
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>

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

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

Change-Id: Ica8322e0eab8f00bfc1d4f6d33778eb6493b278f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/295835
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
2020-06-11 22:25:53 +00:00
Ethan Nicholas
fb5ede576d fixed sample(..., matrix) with runtime effects
Change-Id: Id5b7f1b5e992c587be000e112706bedfe00c90fd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294697
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-06-10 13:59:15 +00:00
Mike Reed
fd9745eee9 SkDrawLooper has not been supported by Skia for a while. Update dox and remove examples
Change-Id: I7ff5d06f85b5100947089c4376d98a2ab144a016
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292076
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-27 01:22:06 +00:00
Mike Reed
3e84312c0f add new patheffect for stroke-and-fill
Change-Id: I2212e547d3d15c65c20f2f8e10fda5f2ef832187
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291041
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2020-05-20 15:01:26 +00:00
Brian Osman
28590d54f5 Add 'shader' as an alias for 'fragmentProcessor'
Change-Id: I2d95c63de18125e6258709b48b03abd7904b7537
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278596
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-05-15 13:52:15 +00:00
Brian Osman
b32d66b296 Add layout(srgb_unpremul) to SkSL
For 3 and 4 channel float uniforms, this states that the data supplied
is unpremul sRGB, and transforms that data to the destination color
space (still unpremul) automatically.

Change-Id: I1b420d2fd10640963fa8e6736af3747cfc6e7d5b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286656
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-05-01 20:12:43 +00:00
Brian Osman
d9bde07f1e Add SkRuntimeShaderBuilder, clean up SkRuntimeEffect API a bit
Utility class for getting named access to uniforms and children of an
SkRuntimeEffect (also functions as an example of using the
SkRuntimeEffect public API).

Moved several internal SkRuntimeEffect functions to private, and added
findInput/findChild helpers.

Change-Id: I8c2e7745ea81670a49b7ab2f51ce44a8d8169278
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/286516
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2020-05-01 20:02:35 +00:00
Brian Osman
f59a961dc9 Add layout(marker) to SkSL
Allows for uniforms to be automatically populated with
marked canvas matrices:

SkSL:
  layout (marker=localToWorld) uniform float4x4 localToWorldMatrix;

C++:
  canvas->concat(...);
  canvas->markCTM("localToWorld");
  canvas->concat(...);
  canvas->drawFoo(...);

Any runtime effects created with that SkSL will have their
localToWorldMatrix uniform filled in with the CTM, ignoring
any transformation that happened before/above the markCTM
call. The marker needs to be a sequence of alphanumeric or
underscore characters, and match the string used in markCTM.

The marker can also be of the form "normals(<string>)", in
which case the uniform will be filled in with the transpose
of the inverse of the upper-left 3x3 portion of the CTM
identified by <string>. This is helpful for transforming
normal vectors, as is often done in lighting.

Change-Id: I7d1ca4dc3f8fabbe91b9bd2c8632013f26d2321a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/285376
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-04-30 13:44:40 +00:00
Mike Reed
b6af407d67 change Overdraw colorfilter to be pure sksl
About same speed on CPU as pipeline-callback

Change-Id: If8769bebb3c51b5ea61fc34d76dde0cfc16b8473
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283871
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-04-16 19:15:01 +00:00
Ben Wagner
cc81e202b4 Take MorphologyImageFilter radii as SkScalar.
The morphology image filters work on pixels, so took the radii as
integers. However, these radii will be mapped through the CTM, so any
rounding should happen as late as possible or the effect will be overly
discretized.

Bug: skia:10110
Change-Id: I62ab6c37d0b4612690addc48c9bc473099ac36b9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282636
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-04-09 18:27:17 +00:00
Florin Malita
0022f5cf1b [SkTrimPathEffect] Preserve wrap-around continuity
In inverted mode (Mode::kInverted), the trim result represents the
logical segment [stop..start] (wrapping around at the path's end).

We currently emit two segments [0..start] and [stop..1], in that
exact order.  This behavior breaks continuity for single closed
contour paths.

Update SkTrimPath to

1) emit the segments in the correct order ([stop..1],[0..start])

2) skip the connecting moveTo for closed paths

Bug: skia:10107
Change-Id: Icd280554ba7291c985f504793feff104df2a4a99
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281882
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2020-04-07 14:40:17 +00:00
Mike Klein
a9741ee25a first sksl on skvm
Exactly enough implemented to run

    fm --skvm -b cpu -s runtime_shader -w foo

This shader

     0: 0077 load2 0
    10: 00a2 pushimmediate 998277249(0.0039215688593685627)
    22: 0070 dup
    31: 0094 multiplyf2
    40: 0080 loaduniform 2
    50: 00a2 pushimmediate 1065353216(1.0)
    62: 00c1 store4 2
    71: 00b4 return 0

becomes this blitter, including matrix, blending, asserts, etc:

    17 registers, 57 instructions:
    0	r0 = uniform32 arg(0) 4
    1	r0 = to_f32 r0
    2	r1 = splat 3F000000 (0.5)
    3	r0 = add_f32 r0 r1
    4	r2 = uniform32 arg(0) 2C
    5	r3 = uniform32 arg(0) 28
    6	r2 = fma_f32 r0 r3 r2
    7	r3 = uniform32 arg(0) 0
    8	r4 = uniform32 arg(0) 24
    9	r5 = splat 3F800000 (1)
    10	r6 = uniform32 arg(0) 38
    11	r6 = min_f32 r6 r5
    12	r7 = splat 0 (0)
    13	r6 = max_f32 r7 r6
    14	r8 = splat 437F0000 (255)
    15	r9 = mul_f32 r6 r8
    16	r9 = round r9
    17	r10 = splat FF (3.5733111e-43)
    18	r10 = pack r9 r10 8
    19	r9 = splat 3B808081 (0.0039215689)
    20	r11 = uniform32 arg(0) 20
    21	r12 = uniform32 arg(0) 1C
    22	r11 = fma_f32 r0 r12 r11
    23	r12 = uniform32 arg(0) 18
    24	r0 = splat 3F800001 (1.0000001)
    25	r13 = min_f32 r6 r0
    26	r14 = splat B4000000 (-1.1920929e-07)
    27	r13 = max_f32 r14 r13
    28	r13 = eq_f32 r6 r13
    29	assert_true r13 r6
    loop:
    30	    r6 = index
    31	    r6 = sub_i32 r3 r6
    32	    r6 = to_f32 r6
    33	    r6 = add_f32 r6 r1
    34	    r13 = fma_f32 r6 r4 r2
    35	    r13 = mul_f32 r9 r13
    36	    r6 = fma_f32 r6 r12 r11
    37	    r13 = min_f32 r13 r5
    38	    r13 = max_f32 r7 r13
    39	    r15 = mul_f32 r13 r8
    40	    r15 = round r15
    41	    r6 = mul_f32 r9 r6
    42	    r6 = min_f32 r6 r5
    43	    r6 = max_f32 r7 r6
    44	    r16 = mul_f32 r6 r8
    45	    r16 = round r16
    46	    r15 = pack r16 r15 8
    47	    r15 = pack r15 r10 16
    48	    store32 arg(1) r15
    49	    r15 = min_f32 r13 r0
    50	    r15 = max_f32 r14 r15
    51	    r15 = eq_f32 r13 r15
    52	    assert_true r15 r13
    53	    r13 = min_f32 r6 r0
    54	    r13 = max_f32 r14 r13
    55	    r13 = eq_f32 r6 r13
    56	    assert_true r13 r6

And that JITs using 11 ymm registers.

Change-Id: Ib45b5fa6aee427f290b77d8900f10d433ad81133
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281746
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2020-04-06 17:32:28 +00:00
Brian Osman
ffd11f4ab3 Adding attribute types to SkVertices
Adds structure to the per-vertex (now custom) data.
Attributes currently just have a type, but the next
step is to augment that with semantic flags to handle
transformation logic in the vertex shader.

Added unit tests and GMs that exercise attributes of
varying float counts, as well as normalized bytes.

Bug: skia:9984
Change-Id: I02402d40b66a6e15b39f71125004efb98bc06295
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/280338
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-04-01 23:23:26 +00:00
Mike Reed
ea1d105648 onProgram for overdraw-colorfilter
+ add Builder: min(I32), max(I32), gatherF()

Incidental bench timings (iMac Pro):
- RP:          350
- gatherF:     210
- unpack_8888: 187

Change-Id: I1d09f76206e89cd595a9e42c4b96bbf2f53ab86c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/279736
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-03-27 17:02:26 +00:00
Brian Osman
3c358420df Support for custom vertex data in SkSL and drawVertices
Adds a 'varying' modifier to the SkSL frontend. Only valid
for pipeline stage (runtime effect) SkSL programs, and only
on variables that are float, or float[2-4].

Runtime effect SkSL can declare varyings. The effect gathers
and reflects them. The GPU backend uses SkShader_Base's new
asRuntimeEffect() to get this data.

GrDrawVerticesOp and its GP get the shader's effect, if any.
They use this to add vertex attributes, varyings, and global
variables (in the fragment shader) of the appropriate width.
The globals have procedurally generated names, based on
their index in the list ("_vtx_attr_%d"). The GP's fragment
code copies the varyings to the globals.

When PipelineStageCodeGenerator sees a varying reference,
it just replaces that with the procedurally generated name
that matches the logic in the op.

Change-Id: I0effbc4f3425d452cb7d62e51e268f3b48fa3c74
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275962
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-03-23 19:52:53 +00:00
Kevin Lubick
4765da43c5 Add fiddle example for MakeLinear
See live at https://fiddle.skia.org/c/4dbc499d0c9fdf7e732e512d90039acd

Change-Id: I06920e61b902c37c9c00ce3addd3e7cbf1c880bf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277602
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-03-18 17:53:11 +00:00
Mike Klein
276a78573e rearrange to emphasize most salient params
Move (x,y) up front for shaders, Color for color filters.

I did think about wrapping the other params in a struct, but
for now I still find it less error prone (while admittedly
more tedious) to have all those params in my face when adding,
removing, or refactoring parameters or effects.

Change-Id: I5e124f1ecea3eff9366872d5e77ddfbadc0302e3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277111
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-03-15 20:14:58 +00:00
Mike Reed
9a4ac6e865 add programs to compose, lerp and luma colorfilters
Small diffs in affected gms, but doesn't seem wrong.

Change-Id: I6577943f924d682e9ad4ff195ab98ca2168fd527
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/277064
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2020-03-15 19:29:40 +00:00
Brian Osman
bd4f872d69 Handle runtime effect shader errors better
- Expose shader error handler on GrBaseContextPriv
- Use that to report errors that happen during (late) SkSL conversion
- Remove various asserts. We expect these functions not to fail, but
  they absolutely can for any kind of error that gets past the first
  compile in SkRuntimeEffect::Make. We'll still make a GLSLFP, but it
  won't inject any code, so the resulting shader will *also* fail to
  compile. Injecting our own errors first gives the user a better idea
  what's actually broken.
- SkSLSlide also reports errors via the error handler now, too.

Change-Id: I4b871cdaa5e3217b042ebf000bb7474afaeab04c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/275679
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-03-06 21:32:31 +00:00
Brian Osman
6fa47769cb In SkRuntimeEffect, use a single shared Compiler instance
I've been increasingly concerned about the CPU and memory costs of
creating and holding on to many Compiler instances. Given that they're
use infrequently, having a shared (guarded) instance seems fine.

We can still look at reducing the startup cost of a single instance, but
this removes a large blocker to wider usage of SkRuntimeEffect.

Change-Id: Ia6dc721c73fdf8c9c4c7a8c1af5f350d2c028b22
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/272466
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-21 20:25:04 +00:00
Brian Osman
d3b3bf3567 Reland "Move runtime shader/colorfilter into SkRuntimeEffect.cpp"
This reverts commit 7281a86237.

Change-Id: I1759358ede39e2466362cc4d3f0b9530eff08c9e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271656
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2020-02-19 15:29:09 +00:00
Brian Osman
7281a86237 Revert "Move runtime shader/colorfilter into SkRuntimeEffect.cpp"
This reverts commit 8980acd623.

Reason for revert: Win-Shared

Original change's description:
> Move runtime shader/colorfilter into SkRuntimeEffect.cpp
> 
> Better organization that lets us share a bunch of code between these
> (very similar) objects.
> 
> Change-Id: Ie559d6e144d8588b98a95d4170e2e6c19d9623bd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270736
> Reviewed-by: Mike Reed <reed@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

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

Change-Id: Ic13d85b7c4f2d593a6c15dde067f118ea5753eb6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271600
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-18 19:31:14 +00:00
Brian Osman
8980acd623 Move runtime shader/colorfilter into SkRuntimeEffect.cpp
Better organization that lets us share a bunch of code between these
(very similar) objects.

Change-Id: Ie559d6e144d8588b98a95d4170e2e6c19d9623bd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270736
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-18 19:15:05 +00:00
Mike Reed
2c5ee18724 remove legacy factory for overdrawcolorfilter
Change-Id: I19453c51bf275050d6426b82a1ad717348a3ea56
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271136
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-02-15 16:53:39 +00:00
Mike Reed
528998dfd5 Fix impl for OverdrawColorFilter to not rely on details of pmcolor,
esp. during serialization. We now store/serialize SkColor, which is
stable.

Change-Id: Ib453920a9a06647f44b33c9ae8af33936d6ead33
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270997
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-02-14 18:38:18 +00:00
Brian Osman
f989aeaa01 Support children in SkRuntimeEffect::makeColorFilter
Change-Id: Icf8c69464a44341a08df16dce53aebedc2826bfd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/270064
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-11 16:20:07 +00:00
Mike Reed
dc2782c380 Update OverdrawColorFilter to clarify how it interprets its input array.
1. Document that Make() takes RGBA_premul
2. Change impl so that CPU matches this behavior/definition
3. Offer a clearer factory that takes SkColor
   (perhaps migrate clients to this one in the future)

Bug: skia:9896
Change-Id: I0a81dda45834a2fbf2b28b711ba7e6b83f360aff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269906
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2020-02-11 10:58:36 +00:00
Brian Osman
194dfdea3a Add comment explaining memset in ArithmeticFPInputs
Change-Id: I1541e3f4629a117eee3f244c0209e442b705b67b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268844
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-05 20:03:28 +00:00
Brian Osman
0a3c57f1ad Ensure that ArithmeticFPInputs is fully initialized
Change-Id: Ia5e94704955aba33e07592711656fbeefef15912
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268840
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-05 18:52:17 +00:00
Brian Osman
3225306f82 In SkRuntimeEffect, just use hash of SkSL as the ID
Change-Id: I2ce210889452756d5d100fbb15f578bb72e2af2a
Bug: skia:9813
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268687
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-05 17:52:48 +00:00
Brian Osman
9bfd5956de In GrSkSLFP, store inputs as SkData. Tighten size checks.
Simplifies interaction with users who already have inputs in this form,
and doesn't really add any overhead to other clients.

Change-Id: I6e137e02a65e007621adf481ffb994665117caf4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268836
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-02-05 16:19:08 +00:00
Brian Osman
504032e575 SkRuntimeEffect: Fix 'in' variables in CPU backend
We were never calling specialize() to bake in the values of ins,
so do that. Add uniformSize() to get the size of just the uniform
values. (The interpreter asserts that the size of the uniforms
being passed in matches the expected size from the ByteCode,
so these need to match up).

Added a unit test that uses both 'in' and 'uniform'.

Change-Id: I595822171211d35a17d5977fa790de0d1bbd6c78
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/263519
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-10 15:46:22 +00:00
Brian Osman
f72deddb89 Expose the Input variable and Child name collections in SkRuntimeEffect
Add framework for unit tests that draw (CPU and GPU) with a runtime
shader, as well as couple example tests.

Change-Id: I43b3b39e86634ec55521a2689a4c55c21939dce5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262809
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-08 19:23:13 +00:00
Brian Osman
ee426f223f Move SkRuntimeEffect.h to include/effects
Change-Id: I0b11d4210c6e663cfb4854fc33e1396fd79fe9a4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/261780
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-01-02 17:37:46 +00:00
Brian Osman
d927bd246d Runtime SkSL: Reflect inputs in SkRuntimeEffect
Adds a new structure to describe the inputs, including type,
shape, name, etc. This removes any references to the type
variables in the compiler's context, and centralizes the
logic for parsing those type variables.

Also normalizes the rules for what types are supported.
(This was inconsistent among the various functions before).

Now:
  - bool and int must be 'in'
  - float may be 'in' or 'uniform'
  - float[2-4] and matrices must be 'uniform'

Includes a new Slide that allows for interactive editing
of a runtime shader.

Change-Id: Ic2af68a80c8bb645ba96417c430da24de0a9c2d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/260497
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-12-18 17:37:55 +00:00
Brian Osman
e36d030016 SkColorMatrix cleanup
Remove the RGB/YUV helpers (use SkYUVMath instead), along with the
unused get20/set20.

Change-Id: Id83467a1b7f33657869e0a933af75387a4e36a88
Bug: skia:9543
Change-Id: Id83467a1b7f33657869e0a933af75387a4e36a88
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252188
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2019-11-04 15:20:15 +00:00
Brian Salomon
4bc0c1fc4b Rename GrColorSpaceInfo -> GrColorInfo
Add version SkImageInfo::Make() that takes SkISize instead of separate
width and height.

Change-Id: I42aa79d23b19e22f5405631728c245b04bce0559
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/245172
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-09-30 21:53:24 +00:00
Michael Ludwig
bf8439d7e2 Fix GMs broken during API porting
Bugs:
morphology GM: Had swapped Erode and Dilate
imagefilterscropexpand GM: Was applying the filter to the wrong rectangle
imagefilterstransformed, filterfastbounds, et al GMs: The new
SkImageFilters::Image() factory had defaulted to using kNone for quality,
since it appeared to keep a 1-to-1 scale. However, it actually draws the
image from srcRect into the dstRect, mapped by the CTM, so if there's a
scaling factor in the CTM the filter no longer is 1-to-1 and kNone leads
to weird scaling artifacts. So switched back to the original kHigh default.
Change-Id: I30ee455008720048fb27eaed1c2c42915d222c97
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/232396
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-08-05 14:53:45 +00:00
Michael Ludwig
06eacf44d5 Add new SkImageFilters factory API
In preparation for moving the filter-specific headers from include/effects and into src/effects/imagefilters, this exposes a more convenient API where all filters provided by Skia are accessible from the same factory.

It also only exposes the factories that take the shared enums (SkColorChannel, SkTileMode), so the per-filter enums can be phased out (SkBlurImageFilter::TileMode, etc.). It also accepts an SkIRect* instead of an SkImageFilter::CropRect* since all uses seem to be for integer rectangles and flags are either always on or always off. This will allow us to later remove the CropRect type.

Bug: skia:9280
Change-Id: I71f77ff44b573f87b837d6523b9eb565521f0f36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230876
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-08-02 13:33:35 +00:00
Michael Ludwig
c711a86493 Combine erode and dilate implementations
Combine the GPU and Raster morph type and direction enums, and have the
morphology base class accept the type as an argument instead of a virtual.
Adds somewhat complex deserialization code to be backwards compatible with
the old erode and dilate create procs.

Also updates SkXfermodeImageFilter's implementation to be named with the
"Impl" suffix instead of _Base, and updates both filters to have the common
code layout for image filter implementations.

Change-Id: I5082914f9754c2be71becfceb0c7d9a8fd06f569
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/231099
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-08-01 17:24:10 +00:00
Michael Ludwig
d668f7f061 Hide SkImageFilter subclasses in CPP files
Bug: skia:9280
Change-Id: Ice3624467f5e643f9d3d81da72d77911eeac963e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230198
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2019-07-30 18:39:22 +00:00