Commit Graph

5224 Commits

Author SHA1 Message Date
John Stiles
4cd5e50c5d Add a hardwired-blend-mode version of GrBlendFragmentProcessor::Make.
When `Make<BlendOp>(src, dst)` is used, the blend mode will always be
hard-coded into the shader, instead of using a uniform to apply a
generic Porter-Duff blend.

Change-Id: I59a05eea3417b1880cef63738c0116d19f01ee3e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/525641
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2022-03-30 13:51:06 +00:00
Kevin Lubick
aab019a15e [bazel] Fix build
Most of these are pretty mechanical generated changes.

IWYU noticed one issue with DSLCore.h, which was fixed here.

Change-Id: I5629565ad3c2817daa71907c62f932d93f9d78ab
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/524617
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2022-03-28 13:56:16 +00:00
Robert Phillips
55ec347276 [graphite] Set up SkSL portion of image shader
Bug: skia:12701
Change-Id: I4d1fc66307a5c4f98f5415f95670b1ebc1622f97
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/523859
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-03-25 19:10:07 +00:00
Robert Phillips
51be21eb5a [graphite] Add makeTextureImage call to graphitestart GM
Bug: skia:12701
Change-Id: I8cca9d8ea20ed585d0021e8ea929dc136d699883
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/523423
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-03-23 14:08:33 +00:00
Kevin Lubick
0364f7b80e [bazel] Fix/update rules
This regenerates the files and fixes the harfbuzz rule so CanvasKit
compiles.

Change-Id: I2db2bddaabf793f360e8a4fa1a6a2b96222dfdf8
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522816
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-03-21 17:19:54 +00:00
Brian Salomon
6538e8905c Rename anisotropic_hq to anistropic_image_scale_mip
"High quality" filtering is no longer a concept in Skia. New variants
with other suffixes will make more sense. The existing image triaging
isn't adding value so no worries about starting over.

Bug: skia:13036
Change-Id: Iaa4d285e74de8e7c154fa15027489963124315ad
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522977
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2022-03-21 17:14:41 +00:00
Brian Salomon
38b5eb19e5 Make anisotropic GM use mip maps
This GM was originally written against the old high-quality mode.
Given that it only draws at scale or downsamples, the modern equivalent
would be to use mip maps. However, when it was converted to
SkSamplingOptions it was made to use Mitchell.

The result is pretty ugly but hopefully this will help illustrate the
benefit of anisotropic filtering in comparison.

Bug: skia:13036
Change-Id: I2e5ef2d143fa148583391aace66b44fa59b7f202
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522360
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2022-03-21 14:16:36 +00:00
Kevin Lubick
08ece0c9a0 [includes] Enforce IWYU on sksl code
PS1 regenerates the Bazel files. Use it as the base change when
    comparing patchsets.

IWYU seems to do a good job of working with MyFile.cpp and
MyFile.h, but if there is just a MyHeader.h, it doesn't always
seem to throw errors if the includes aren't correct. This was
observed with include/sksl/DSL.h This might be due to the fact
that headers are not compiled on their own, so they are never
sent directly to the IWYU binary.

This change sets enforce_iwyu_on_package() on the all sksl
packages and then fixes the includes until all those checks
are happy. There were a few files that needed fixes outside
of the sksl folder. Examples include:
 - src/gpu/effects/GrConvexPolyEffect.cpp
 - tests/SkSLDSLTest.cpp

To really enforce this, we need to add a CI/CQ job that runs
bazel build //example:hello_world_gl --config=clang \
  --sandbox_base=/dev/shm --features skia_enforce_iwyu

If that failed, a dev could make the changes described in
the logs and/or run the command locally to see those
prescribed fixes.

I had to add several entries to toolchain/IWYU_mapping.imp
in order to fix some private includes and other atypical
choices. I tried adding a rule there to allow inclusion of
SkTypes.h to make sure defines like SK_SUPPORT_GPU, but
could not get it to work for all cases, so I deferred to
using the IWYU pragma: keep (e.g. SkSLPipelineStageCodeGenerator.h)

Change-Id: I4c3e536d8e69ff7ff2d26fe61a525a6c2e80db06
Bug: skia:13052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522256
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2022-03-21 12:43:02 +00:00
Ben Wagner
b3275e1fd6 Simplify FreeType glyph paths with overlap.
With variable fonts overlapping glyph contours are now normal. However,
these do not stroke well. Simpify the glyph paths which are marked as
overlapping.

Bug: b/225044541
Change-Id: I9687e28c9274cd189f4ae8e059d8d40dd802ec41
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/521637
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2022-03-18 22:42:20 +00:00
Michael Ludwig
1094004195 Fix recently updated rrect_* GMs
https://skia-review.googlesource.com/c/skia/+/521523 added a new tile
to the GM, but made some tweaks to the clipping logic. It accidentally
only outset the clip bounds for kInverseFillAA edge types, when it
should have outset for BW and AA. This fixes the GM so that the only
meaningful changes are the new tile.

Bug: skia:10456
Change-Id: Ic6fbb1db26921173e4aa846d37ee31d523e3dbb1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522436
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-03-18 19:59:41 +00:00
Michael Ludwig
5a4709da2c Fix EllipticalRRectEffect precision for large corner radii
Modifies rrects_* GMs to draw a clipped rrect with
a large radius. The _effect case would draw with a blurry
edge before the fixes.

1. Adds scaling to the elliptical effects key and activate
it when the rrect radii are large enough. This fixes the
precision issue with the elliptical effect variant.
2. Uses SkRRectPriv::IsSimpleCircular() to choose the
circular variant over elliptical, which uses a tolerance
between X and Y radii. This avoids the issue since the
circular effect doesn't suffer in this case.

Confirmed that both fixes work independently of each other.

Cq-Do-Not-Cancel-Tryjobs: true
Bug: skia:10456
Change-Id: Ifef63356e31f46ec1546684636d9667b90bcef9b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/521523
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2022-03-18 18:30:29 +00:00
Kevin Lubick
e253cc3e55 [bazel] Use toolchain features to opt files into being IWYU compliant.
PS1 regenerates the Bazel files.

It is recommended to review this CL with a diff from PS1.

Example output when a file does not pass the test:
    tools/sk_app/CommandSet.h should add these lines:
    #include "include/core/SkTypes.h"
    #include "include/private/SkTArray.h"
    #include "tools/skui/InputState.h"
    #include "tools/skui/Key.h"
    #include "tools/skui/ModifierKey.h"
    namespace sk_app { class Window; }

    tools/sk_app/CommandSet.h should remove these lines:
    - #include "tools/sk_app/Window.h"

    The full include-list for tools/sk_app/CommandSet.h:
    #include "include/core/SkString.h"
    #include "include/core/SkTypes.h"
    #include "include/private/SkTArray.h"
    #include "tools/skui/InputState.h"
    #include "tools/skui/Key.h"
    #include "tools/skui/ModifierKey.h"
    #include <functional>
    #include <vector>
    class SkCanvas;
    namespace sk_app { class Window; }
    ---

This makes use of Bazel's toolchain features
https://bazel.build/docs/cc-toolchain-config-reference#features
to allow us to configure compiler flags when compiling
individual files. This analysis is off by default, and can
be turned on with --features skia_enforce_iwyu. When enabled,
it will only be run for files that have opted in.
Example:
    bazelisk build //example:hello_world_gl --config=clang \
       --sandbox_base=/dev/shm --features skia_enforce_iwyu

There are two ways to opt files in:
 - Add enforce_iwyu = True to a generated_cc_atom rule
 - Add enforce_iwyu_on_package() to a BUILD.bazel file
   (which enforces IWYU for all rules in that file)

Note that Bazel does not propagate features to dependencies
or dependents, so trying to enable the feature on cc_library
or cc_executable targets will only impact any files listed in
srcs or hdrs, not deps. This may be counter-intuitive when
compared to things like defines.

IWYU supports a mapping file, which we supply to help properly
handle things system headers (//toolchain/IWYU_mapping.imp)

Suggested Review Order:
 - toolchain/build_toolchain.bzl to see how we get the IWYU
   binaries into the toolchain
 - toolchain/BUILD.bazel and toolchain/IWYU_mapping.imp
   to see how the mapping file is made available for
   all compile steps
 - toolchain/clang_toolchain_config.bzl, where we define the
   skia_enforce_iwyu feature to turn on any verification at
   all and skia_opt_file_into_iwyu to enable the check for
   specific files using a define.
 - toolchain/clang_trampoline.sh, which is the toolchain is
   configured to call instead of clang directly (see line 83
   of clang_toolchain_config.bzl). This bash script used to
   just forward all arguments directly onto clang. Now it
   inspects them and either calls clang directly (if
   it does not find the define in the arguments or we are
   linking [bazel sometimes links with clang instead of ld])
   or calls clang and then include-what-you-use. In all cases,
   the trampoline sends the arguments to clang and IWYU
   unchanged).
 - //tools/sk_app/... to see enforcement enabled (and fixed)
   for select files, as an example of that method.
 - //experimental/bazel_test/... to see enforcement enabled
   for all rules in a BUILD.bazel file.
 - all other files.

Change-Id: I60a2ea9d5dc9955b6a8f166bd449de9e2b81a233
Bug: skia:13052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/519776
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Leandro Lovisolo <lovisolo@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-16 13:09:46 +00:00
Robert Phillips
44263c5d08 [graphite] Add fixed-function blending support
Bug: skia:12701
Change-Id: I1fd8dede3eb216c28408bd613119448704c0e7c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512356
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-03-14 14:21:46 +00:00
Brian Osman
4b3403e6c8 Fix image shader local matrix not being applied on CPU
We were using the shader wrapper's local matrix (which is
always identity), rather than the original (wrapped)
shader's local matrix.

Bug: skia:13047
Change-Id: I7c70d9a4d210746141633e3664cb7ba5841a732d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/519376
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-03-10 15:56:45 +00:00
Kevin Lubick
efce17de5d Reland "[includes] Remove link between SkImage.h and SkImageEncoder.h"
This is a reland of commit f60584eb0f

Client changes:
 - https://chromium-review.googlesource.com/c/chromium/src/+/3508565
 - http://cl/433225409
 - http://cl/433450799

Original change's description:
> [includes] Remove link between SkImage.h and SkImageEncoder.h
>
> According to go/chrome-includes [1], this will save about
> 210MB (0.09%) off the Chrome build. http://screen/GVdDaRRneTRuroL
>
> [1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&included=&limit=1000
>
> Change-Id: If911ec283a9ce2b07c8509768a6a05446573a215
> Bug: 242216
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512416
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Kevin Lubick <kjlubick@google.com>

Bug: 242216
Change-Id: Ic61e4ac2878e7a51f389312a3a434856e2e32be3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/518277
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-10 04:47:51 +00:00
Kevin Lubick
27be14f2ca [includes] Prepare to remove SkColor<->SkImageInfo
This breaks out the SkAlphaType and SkColorType enums into
their own files, which lets us break the dependency between
SkColor and SkImageInfo.

It does not yet sever the link, but we plan to land this
so as to migrate clients to the new enum files if necessary.

This is estimated to save Chrome 230 MB of build size [1]
(about 0.1%) http://screen/4dMqPC9rvAyCk6y

[1] https://commondatastorage.googleapis.com/chromium-browser-clang/chrome_includes_2022-03-08_182556.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkColor%5C.h%24&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkColor%5C.h%24&included=&limit=1000

Change-Id: I331d414fe2996632ab11825c1092060ff5fe2ebd
Bug: 242216
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/517678
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-09 18:40:44 +00:00
Kevin Lubick
677a12f38d [includes] Fix up transitive dependencies on SkBitmap
Change-Id: Ie1ba66881743eee01d36f7c7032307fbdca1e671
Bug: 242216
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/518496
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-09 18:25:17 +00:00
Brian Salomon
b4baebadd4 Remove setters from GrSamplerState.
The motivation is that a future change will add a factory fn that
makes an aniso samplerstate. We don't want to support arbitrary
combinations of aniso with other knobs.

Bug: skia:13036

Change-Id: Id962f89019a37763961981990d0e49e298e16064
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/516816
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2022-03-09 15:39:11 +00:00
Kevin Lubick
cbc954bf57 [includes] Remove include link between SkPath.h and SkPathRef.h
According to go/chrome-includes [1], this will save about
185MB (0.08%) off the Chrome build (some of which is handled
by https://skia-review.googlesource.com/c/skia/+/512776).
http://screen/3foDapQ5BN7srcG

This adds several forward declares and moves several
implementations from SkPath.h to SkPath.cpp.

This also removes privateSetConvexity from SkPathBuilder
because the SkPathConvexity being set to a non-zero default
value would have required moving the enum out of SkPathRef
or adding an include link. This private API was only used
in one location, so I just opted to remove it.

[1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkPath%5C.h%24&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkPath%5C.h%24&included=&limit=1000

Change-Id: Ie1f83ac3eee6eb19d7ded18a41a7532f445c13ee
Bug: 242216
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512357
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2022-03-09 00:55:54 +00:00
Kevin Lubick
7ac7413f08 [bazel] Support Vulkan
PS1 regenerates BUILD.bazel files

I suggest reviewing the deltas between PS1 and the latest
PS to focus on the interesting bits.

The changes here allow for a Vulkan-only build of HelloWorld
based on sk_app. The toughest change was properly fetching
the VisualID after removing the gl calls that used to
fill that in.

There are a few changes that fix resolution of Dawn
header files, but those won't actually be built until
a follow-on CL.

Change-Id: I54fb58b5dd7ecd4313562aed401759b3eaed53c0
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/516999
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-08 21:21:17 +00:00
Kevin Lubick
a573cbab1a Revert "[includes] Remove link between SkImage.h and SkImageEncoder.h"
This reverts commit f60584eb0f.

Reason for revert: Chrome and G3 issues

Original change's description:
> [includes] Remove link between SkImage.h and SkImageEncoder.h
>
> According to go/chrome-includes [1], this will save about
> 210MB (0.09%) off the Chrome build. http://screen/GVdDaRRneTRuroL
>
> [1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&included=&limit=1000
>
> Canary-Android-Topic: image-encoder-2
> Change-Id: If911ec283a9ce2b07c8509768a6a05446573a215
> Bug: 242216
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512416
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Kevin Lubick <kjlubick@google.com>

Bug: 242216
Change-Id: Idc906ff54d8baf49989d3ee24e045d7b0ca710df
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/517676
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Kevin Lubick <kjlubick@google.com>
2022-03-08 13:09:49 +00:00
Kevin Lubick
f60584eb0f [includes] Remove link between SkImage.h and SkImageEncoder.h
According to go/chrome-includes [1], this will save about
210MB (0.09%) off the Chrome build. http://screen/GVdDaRRneTRuroL

[1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&sort=asize&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fcore%2FSkImage%5C.h%24&included=&limit=1000

Canary-Android-Topic: image-encoder-2
Change-Id: If911ec283a9ce2b07c8509768a6a05446573a215
Bug: 242216
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512416
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-07 21:32:13 +00:00
Kevin Lubick
2d86f6f5db Reland "[includes] Remove include link between SkPathRef.h and SkRRect.h"
This is a reland of 37b8239bec

Upstack changes:
 - http://ag/17004908
 - https://github.com/flutter/engine/pull/31654

Original change's description:
> [includes] Remove include link between SkPathRef.h and SkRRect.h
>
> According to go/chrome-includes [1], this will save about
> 40MB (0.02%) off the Chrome build. http://screen/4GnPjFaYpwCVHVL
>
> I'm not quite sure why the link is so expensive, but we can
> forward declare it and move the implementation from the .h
> to the .cpp file easily enough.
>
> [1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fprivate%2FSkPathRef%5C.h%24&sort=includes&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fprivate%2FSkPathRef%5C.h%24&included=&limit=1000
>
> Canary-Chromium-CL: 3485346
> Change-Id: Ie3a5e7a735426f883a6c06ddbd3b8bf148bf1709
> Bug: 242216
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512158
> Reviewed-by: Robert Phillips <robertphillips@google.com>

Bug: 242216
Change-Id: I31288895528251fd59913427b95b9f88a871d14b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512776
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-03-07 15:15:05 +00:00
Kevin Lubick
b902658a1a [bazel] Fix Bazel build by guarding addToKey
PS1 is the automatic regenerated changes.
PS2-3 adds an #ifdef guard to the addToKey method on shaders.
The SkShaderCodeDictionary class helps generate SkSL and is
only necessary when we are building with SkSL (gpu builds and
cpu builds with SkVM).

Suggested Review order:
 - Use Gerrit to diff PS 1 and the last PS
 - src/core/BUILD.bazel adds some sources to the "only
   necessary if sksl is enabled" bucket
 - All the .cpp and .h files to see the #ifdef is added
   correctly.

Change-Id: I4d4ce61a4957ef1e0840204acff08ce7e616f9cb
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512157
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-02-24 18:10:40 +00:00
Kevin Lubick
32b1e5d861 Revert "[includes] Remove include link between SkPathRef.h and SkRRect.h"
This reverts commit 37b8239bec.

Reason for revert: Need to update clients, including Flutter

Original change's description:
> [includes] Remove include link between SkPathRef.h and SkRRect.h
>
> According to go/chrome-includes [1], this will save about
> 40MB (0.02%) off the Chrome build. http://screen/4GnPjFaYpwCVHVL
>
> I'm not quite sure why the link is so expensive, but we can
> forward declare it and move the implementation from the .h
> to the .cpp file easily enough.
>
> [1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fprivate%2FSkPathRef%5C.h%24&sort=includes&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fprivate%2FSkPathRef%5C.h%24&included=&limit=1000
>
> Canary-Chromium-CL: 3485346
> Change-Id: Ie3a5e7a735426f883a6c06ddbd3b8bf148bf1709
> Bug: 242216
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512158
> Reviewed-by: Robert Phillips <robertphillips@google.com>

Bug: 242216
Change-Id: I226c45326b67dff3eb1dc1f96c11e9ef0a12e22b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512639
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-02-24 12:55:26 +00:00
Kevin Lubick
37b8239bec [includes] Remove include link between SkPathRef.h and SkRRect.h
According to go/chrome-includes [1], this will save about
40MB (0.02%) off the Chrome build. http://screen/4GnPjFaYpwCVHVL

I'm not quite sure why the link is so expensive, but we can
forward declare it and move the implementation from the .h
to the .cpp file easily enough.

[1] https://commondatastorage.googleapis.com/chromium-browser-clang/include-analysis.html#view=edges&filter=%5Ethird_party%2Fskia%2Finclude%2Fprivate%2FSkPathRef%5C.h%24&sort=includes&reverse=&includer=%5Ethird_party%2Fskia%2Finclude%2Fprivate%2FSkPathRef%5C.h%24&included=&limit=1000

Canary-Chromium-CL: 3485346
Change-Id: Ie3a5e7a735426f883a6c06ddbd3b8bf148bf1709
Bug: 242216
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/512158
Reviewed-by: Robert Phillips <robertphillips@google.com>
2022-02-23 22:46:44 +00:00
Robert Phillips
99ba004574 [graphite] Add blendMode uniform to blend/compose shader
Bug: skia:12701
Change-Id: I648948875a2e9401c0c73cdf4c9c8053c9ba69af
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/510227
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-02-23 18:21:05 +00:00
Brian Osman
1e420a3652 Revert "Fix dithering on drawImage[Rect] calls"
This reverts commit 10241484aa.

Reason for revert: Speculative revert for b/220676062

Original change's description:
> Fix dithering on drawImage[Rect] calls
>
> Bug: skia:12516
> Change-Id: Ibb68558e0f474143df3c6a5fb0fb3d4881529226
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/508677
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

Bug: skia:12516
Change-Id: If496c6be355bbb026ffe478512f8a6334116bb66
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/511806
Commit-Queue: Brian Osman <brianosman@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-02-22 23:17:20 +00:00
Ben Wagner
0ec715d6cd Correct FreeType palette setup.
Use the override index as intended instead of the index into the
override list as the palette entry index to override. Correct the bounds
check on the override index. Modify an existing test to exercise this.

Bug: skia:12576
Change-Id: Ide8327ff0536eee252c6a83e997ad540a98ba957
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/510596
Auto-Submit: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
2022-02-18 05:08:22 +00:00
Dominik Röttsches
01be94d7f1 Support font palette overrides through SkFontArguments
Co-authored with Ben Wagner, bungeman@google.com.

Similar to how we allow configuration of variable font configurations,
provide additional SkFontArguments to select a base palette and a set
of potentially sparse color overrides.

This is required for implementing CSS font-palette.

Modify the more_samples-glyf_colr_1.ttf to have two additional palettes,
and two additional test glyphs, one that draws with COLRv0 logic, one
that draws with COLRv1 logic and has a foreground palette index dot
in the middle. See [1] & [2] for the additions to the test font.

Add a GM which tests this on the SkFontMgr_custom using makeClone() and
makeFromStreamArgs(). The test displays the two glyphs in default
palette on the left, then with palette overrides (as in the title of the
test) on the right. The first row uses a typeface created with
makeFromStreamArgs(), the second uses one created with makeClone().

[1] https://github.com/googlefonts/color-fonts/pull/91
[2] https://github.com/googlefonts/color-fonts/pull/92

Bug: skia:12730, chromium:1170794
Cq-Include-Trybots: luci.skia.skia.primary:Test-Android-Clang-GalaxyS20-GPU-MaliG77-arm64-Release-All-Android_NativeFonts,Test-Debian10-Clang-GCE-CPU-AVX2-x86_64-Debug-All-NativeFonts
Change-Id: Ia1334f069240edc78fd4791969914e8a6f4fbaf9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/479616
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2022-02-17 13:19:53 +00:00
Michael Ludwig
0b124c444e Fix mask/image filter bounds calculation for inverse-filled paths
Bug: skia:12587, skia:10959
Change-Id: I43dea5f2d2f54c7db47e778ac9c7bac53ae4998d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/509176
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2022-02-16 15:09:42 +00:00
Jim Van Verth
d6245fc4aa Rename GrSwizzle to skgpu::Swizzle
Bug: skia:12845
Change-Id: Ia03293c4efdad4c5381a713c9d7d4857b79530c7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/509398
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2022-02-16 13:30:14 +00:00
Michael Ludwig
10241484aa Fix dithering on drawImage[Rect] calls
Bug: skia:12516
Change-Id: Ibb68558e0f474143df3c6a5fb0fb3d4881529226
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/508677
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2022-02-15 18:59:02 +00:00
Kevin Lubick
7f568e968e [bazel] Update to use emsdk 3.1.4
PS1 regenerates the BUILD.bazel files

This allows us to use closure to minify the JS in canvaskit.js

Change-Id: Ib8326d2e3a19cd2168b740b6946f9165a2810133
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/509177
Reviewed-by: Ben Wagner <bungeman@google.com>
2022-02-15 17:47:03 +00:00
Michael Ludwig
ff616b89e3 Picture shaders support perspective better
Adds a new GM that draws text in an SkPicture, transformed by a
perspective matrix. When drawn directly with drawPicture() it looks
fine. When drawn calculating a scale factor manually from the matrix
and converting to an image (SkImage::MakeFromPicture + drawImageRect),
it looks nearly indistinguishable. However, when drawing using a picture
shader, the image resolution of the cached rasterization is far too low.

Originally, this is because SkPictureShader only relied on
SkMatrix::decomposeScale, which fails if there's perspective and
the picture shader's fallback is to switch to the identity scale. When
the source picture has relatively small local bounds compared to the
final destination, this results in severe sampling artifacts.

This CL switches the fallback to use SkMatrixPriv::DifferentialAreaScale,
which is what was used to compute the manual scale factor in the GM,
and is what image filters use when creating their device's coordinate
space when the canvas has perspective.

Change-Id: I856cd1277eb7cfcb43c766ff0d123ee1a667fe29
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/507917
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2022-02-14 17:47:49 +00:00
Jim Van Verth
9af3a919ce [graphite] Hook up Surface::writePixels
Bug: skia:12845
Change-Id: I8013b0068ab758e9a5e580344c62e4680f4fa48e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506176
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2022-02-11 16:37:41 +00:00
Brian Osman
a7a2324f14 Reland "Add kR8_unorm_SkColorType"
This is a reland of 3225c8cc46

Original change's description:
> Add kR8_unorm_SkColorType
>
> Change-Id: I97b5bc7f90715664f233ca7b7c41c0ecbfc29ac4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/505679
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

Change-Id: I73fa17625d57e0e58da1b70e2e59ba200383cfe7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506460
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-02-10 18:00:19 +00:00
John Stiles
39b978241b Update code to prepare for -Wformat-nonliteral.
-Wformat-nonliteral does not work with variadic templates, and requires
a constant format string.

These changes uncovered one incorrect format string (%u -> %lu for a
DWORD in dm.cpp)

Change-Id: Id54a5d6cbcb607ff32c758f4a9d346a7aba70df3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506616
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-02-10 14:17:33 +00:00
Robert Phillips
dd579d3d6e [graphite] Repurpose graphitestart GM for shader testing/debugging
Bug: skia:12701
Change-Id: I743e4717f3716717bd35e1eea0f504a1f9ac6dc4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506536
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-02-10 14:12:16 +00:00
Brian Osman
cd189e8a1d Remove default/deprecated arguments to makeShader calls
Bug: skia:12643
Change-Id: I37e1718a20283dfb814c85260257d57bac2b7b34
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506211
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
2022-02-09 20:41:23 +00:00
Kevin Lubick
0fac7baa61 Remove experimental/xform
Requires cr/427505724 to land also.

Change-Id: I88465a234b48abf4b1ac97146c8adcf9638babd0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506396
Reviewed-by: Brian Osman <brianosman@google.com>
2022-02-09 19:56:49 +00:00
Kevin Lubick
9cb74e9079 [bazel] Compile gms for wasm and WebGL
PS 1 is re-generating existing BUILD.bazel files
PS 2 is generating BUILD.bazel files for tests/gms
PS 3+ makes modifications to build all of the gms and tests.

It is recommended to view this CL with just a diff between
PS 2 and the end, due to the large amount of generated changes
in PS 1 and 2.

We make a filegroup for the gms and tests because they need
to be compiled as one large blob in order for the registries
to work. Maybe in the future we will break these up, but at least
for WASM/JS, the overhead of starting a browser for each new
test would likely grind things to a halt, so we just group them
all together for now. It's also the most similar to what we
currently do.

In gm/BUILD.bazel and tests/BUILD.bazel, we add a cc_library
that encapsulates all of the deps of the tests, so we can
easily include that the build. These were discovered via
trial and error, not anything automatic or systematic.

The is_skia_dev_build config_setting is very similar to the
GN equivalent from which it was based.

The list of gms and tests to skip (e.g. which are incompatible
with WASM) was determined by building the wasm bundle:

modules/canvaskit$ make bazel_gms_release
tools/run-wasm-gm-tests$ make run_local_debug
# Don't forget to click the button on the screen after the
# browser loads

This way of invoking the tests will be replace soon with
`bazel test <something>`. As such, I didn't bother fully
documenting the current way.

Suggested review order:
 - modules/canvaskit/BUILD.bazel taking note that we always
   use profiling-funcs to make the stacktraces human readable.
 - gm/BUILD.bazel and tests/BUILD.bazel to see the lists of
   gms/tests. Notice the tests are roughly partitioned because
   we don't support things like vulkan/PDF in the wasm build
   and we will want a way to not build certain tests for
   certain configurations
 - tools/* noting some of the cc_libraries added to make
   dependencies easier to add when needed.
 - All other files.

Change-Id: I43059cd93c28af1c4c12b93d6ebd9c46a12d381f
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506256
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2022-02-09 18:56:17 +00:00
Brian Osman
0c7f1d9919 Revert "Add kR8_unorm_SkColorType"
This reverts commit 3225c8cc46.

Reason for revert: Client code needs to handle the new enum value.

Original change's description:
> Add kR8_unorm_SkColorType
>
> Change-Id: I97b5bc7f90715664f233ca7b7c41c0ecbfc29ac4
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/505679
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Brian Osman <brianosman@google.com>

Change-Id: I1174f533600827e29131198c10c243d9cf1300ae
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/506457
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-02-09 18:46:11 +00:00
Brian Osman
3225c8cc46 Add kR8_unorm_SkColorType
Change-Id: I97b5bc7f90715664f233ca7b7c41c0ecbfc29ac4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/505679
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-02-09 17:02:57 +00:00
John Stiles
87aa7a9095 Add SK_PRINTF_LIKE to existing variadic print functions.
This shook out a handful of formatting issues:
[SkVMVisualizer]
- We were passing plain text like "width:35%;" through printf.
- One particular opcode type was printing a string as a number.
[Skottie, SortToy]
- Used wrong integer type instead of %zu for size_t

This CL does not update print functions which take printf arguments via
variadic template, as __attribute__((format)) does not support this
style. These could be converted to va_list style, but that's not done in
this CL.

(For some reason, GCC requires the attribute to be set on a prototype
for freestanding functions, so a few of these now have a prototype
immediately followed by a declaration.)

Change-Id: I63a6c2486c785cc38563028fdf8df0662ec04935
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/504698
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-02-07 14:55:39 +00:00
John Stiles
4250effcc5 Prepare to reenable unreachable-code warnings.
Adding double-parens around an `if ((false))` squelches the warning.
In other cases, you can squelch the warning by assigning the
always-constant(-on-this-machine) check into a constexpr bool.

Change-Id: I5a344fb45779c5bd2865edb3cffaf839ba9a5d85
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/504597
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-02-04 21:45:39 +00:00
Robert Phillips
78219a3551 [graphite] Add stub for image shader SkSL
Bug: skia:12701
Change-Id: I1f0817096b5eb58087494f04162dcbe42585fa57
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/503816
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-02-04 14:15:40 +00:00
Chris Dalton
92c624fe85 Use FillRRectOp in drawStrokedLine for dmsaa
This makes it so we don't trigger msaa in drawStrokedLine anymore.

Bug: skia:skia:12872
Change-Id: Id68b55ba9e3989f2a775affe9a1b20bf3186123c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/502816
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Christopher Dalton <csmartdalton@google.com>
2022-02-02 19:07:39 +00:00
Brian Osman
e09d7500c5 Add GM to demonstate skbug.com/12866
The original drew text with a specific perspective matrix. After
minification, the real problem is the stroker, where having a large
enough resScale creates an incorrect filled version of the path.

Bug: skia:12866
Change-Id: I41a104edf932f54c2db40cd6a913d303cfaa9ba3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/500377
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2022-01-27 15:24:21 +00:00
Robert Phillips
1042c00130 [graphite] Replace GrSLType with SkSLType
This is mostly mechanical. The only interesting bit is that GrSLType was in include/private while SkSLType is in src/core so some #include patterns changed.

Bug: skia:12701
Change-Id: I80bd86ee93796b145f86ded9b4cbf52f24fa59e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/497607
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
2022-01-26 17:30:12 +00:00