We know expressions can't contain @if or @switch statements inside of
them, so we can avoid recursing into them and run this check slightly
faster.
Change-Id: I60cd6dd40ddda74f7af259fd13e5ea0779982384
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370076
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
We now interpret any statement of the form `Type identifier...` as a
var-declaration and report errors as such. Previously, if a var-decl
statement generated an error during parse, we'd report errors as if it
were an expression-statement, which meant that slightly-invalid code
could return out-of-context, misleading errors.
Bug: skia:11287
Change-Id: I2c6cf2984760eb34593c80cb30f8c4e007d42027
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370036
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Bug: skia:11314
Change-Id: I66476543462ae378a5bfb6cbd902dfa2f5fc45f5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369917
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
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>
In this case, unpremul() hits a divide-by-zero here,
F32 invA = 1.0f / a
but then fixes it (and divide-by-tiny) after the fact,
invA = select(invA < inf, invA, 0)
Bug: oss-fuzz:30887
Change-Id: Id2da801e04bd21df2138d3db110eedb238e28c43
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369936
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>
Submitting without additional flushing and syncing GPU/CPU is achievable
with public APIs. Moreover, this testing-only method bypasses code and
can lead to bugs.
Change-Id: I03bd0fa65e5ba88ba6181521947243ba84ab9696
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369876
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
All of a join's information can fit in a single float value:
Negative => Round Join
Zero => Bevel Join
Positive => Miter join, and the value is also the miter limit
Bug: chromium:1172543
Bug: skia:10419
Change-Id: I50bd822a735987cf21537164267d00e3f34badc5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369457
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Ternaries are not assignable in GLSL/SkSL. This code should never have
been reached; no tests are affected.
Change-Id: I7d0139531062c27d7af395553e0d225247a70b48
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369878
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Move the contrast pin to Make() so it affects all implementations.
Bug: oss-fuzz:30859
Change-Id: Iaf7854701bc6a148976f653066d7bf8f27080d2f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369698
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Change-Id: I974571e7e0e9d0170f92b970d425d9ce530e312e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369716
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
We don't need to do these tests every time we run CFG optimization; we
can do them once at the end of optimization, as a separate step.
Change-Id: If0e72fbacb938b62387fd2ffdbf34d1153bf3bd4
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369481
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This allocator is made specifically to handle the memory after
the class of a textblob. It is lighter weight than ArenaAlloc,
easier to calculate needed memory.
Change-Id: Ie9f94e08e2ffd4041712dd3025296a830e940eb3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356317
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
The CL at http://review.skia.org/366399 introduced a bug with
LValue::getPointer. Specifically, getPointer used to return zero when
no pointer is available. (This happens when the LValue is a swizzle.)
That CL changed the error code to -1. However, it did not fix up all
the call sites that checked the return value of getPointer().
This CL fixes up those call sites to use -1 consistently, and adds
TODOs in spots which do not check the result from getPointer() at all
(instead assuming it cannot fail). This will allow swizzled out-
parameters to work in SPIR-V as they did before. (Except in intrinsics,
where they seem to have been broken all along, but those are now marked
with a TODO at least.)
Note that we still do not fully emulate GLSL semantics for out
parameters, as out-parameters should only be copied back to the original
variable at the end of the function call to be fully GLSL compliant.
(This CL also replaces a tuple with a named struct for readability.)
Change-Id: I708dc7a69296a4244ba9ceb85c3e68d1f331bbc9
Bug: skia:11052
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368618
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This also deletes the type conversions between the legacy
tile mode and SkTileMode and cleans up the serialization
logic around that just a little bit.
Bug: skia:11230
Change-Id: If404a73e13f42055a0fe7638dcd9f58cf7e9b896
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368243
Reviewed-by: Robert Phillips <robertphillips@google.com>
Since review.skia.org/366716 this is unused and it makes our life
a whole lot simpler. And a little faster.
Bug: skia:10877
Change-Id: Ib7205bae57ce282f0e4f33c7c780a4c3e5159ea5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369436
Commit-Queue: Adlai Holler <adlai@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
GrBagOfBytes parcels out bytes with a given size and alignment.
It is very careful about checking all values coming so that
no calculations overflows.
If the current block is not big enough to satisfy the request
bytes, a new block will be allocated to satisfy the
requested bytes.
Change-Id: If7b5e812f903b51ba4936605cd0dc298dda8821a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368117
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
CPU already does this. Forcing it this way ensures that optimizations
related to opaqueness are correct.
Change-Id: Iaec3990ec0102b4c11f942774361239d3583adfd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369323
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Implement support for COLRv1 color gradient vector forms. COLR v1 is an
extension to the OpenType COLR tables that introduces support for
gradients, transforms and compositing. [1]
COLRv1 fonts contain an OpenType COLR table with format v1. In a COLR v1
table, glyphs are defined by a directed, acyclic graph of Paint
operations. The task for the Skia implementation is to extract the COLR
v1 information from the font using FreeType's COLRv1 API, then traverse
the glyph graph and translate information from the font into Skia
operations on SkCanvas.
Care needs to be taken for transformations to work correctly. FreeType
sends a top level transform that includes the scaling from font units to
actual glyph size, as well as optional transforms configured on FreeType
using FT_Set_Transform. This is set up as the starting transform at the
beginning of drawing a COLRv1 glyph. At the stage of setting a clip for
a PaintGlyph operation, the glyph outline is retrieved from FreeType
unscaled and untransformed. Since the starting transformation is applied
to the SkCanvas, the unscaled glyph is properly scaled and positioned.
Similarly, computing the initial bounding box for the COLRv1 glyph needs
to consider transformations. COLRv1 glyphs have a base glyph entry in
the glyf table which can use a minimum of two points for defining a
bounding box. This bounding box is an imaged rectangle enclosing those
two points at the identity transform. We need to compute the bounding
box scaled, but at identity transform, then make a rectangle from it,
that we then transform so that we get a large enough area to paint
in. If those two points from the glyf table would be transformed first,
then we would compute the bounding box, the resulting bounding box ends
up too small.
As a test font, add a version of the samples-glyf_colr_1.ttf from [2]
with one glyph added for testing PaintColrGlyph functionality and
compositions.
Add a basic GM test that produces color glyphs untransformed, with
skew and with rotation and combinations of those.
[1] https://github.com/googlefonts/colr-gradients-spec/
[2] https://github.com/googlefonts/color-fonts
Bug: skia:11264
Change-Id: I8357cd0c7ac0039bb2eac18f21fa343bf61871eb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300558
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
Auto-Submit: Dominik Röttsches <drott@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
This moves transfer upload buffers to the new better specific memory
usage and removes the CPU buffer used on android for writing to gpu
buffers. The later will hopefully have some perf wins.
Bug: skia:11207
Change-Id: I581e179b155bdadcae5d3f881b5a479338e01240
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369479
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
This will make it accessible from the IR generator (in a future CL) and
is more in line with how we typically manage settings.
Change-Id: I478d617119cba079d1124b2b9c26d5573c7d6ae3
Bug: skia:11319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369480
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
I think this is good to go.
Originally I had been careful to treat nullptr dst as gamma=2, but then
seeing the GPU impl treating all colorspaces as gamma=2 made me realize
it's can't be that important to preserve pixel-exact results here. It's
not possible with a single codebase... in many situations the existing
CPU and GPU backends draw differently with identical settings.
Beyond that sort of obvious intentional difference, I've also tried to
port as few bugs forward from the old implementations as possible. The
one I notice most clearly is in the GPU code,
@if (invertBrightness) {
color = half4(1) - color;
}
which I think probably should be `color.rgb = 1 - color.rgb`, leaving
alpha alone.
Change-Id: I098cdced4772445c70ce4577bdd1c93c2e42824c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368276
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Uses the pipeline-stage callback mechanism. It mangles the type name
(with a test to verify that this works), and then calls defineStruct
with the entire SkSL struct definition string.
Bug: skia:10939
Change-Id: If14cf1b11faaa80ad8d4086cdacf68532bac43fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368809
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This avoids creating a Setting object (only to then
replace it during optimization). More importantly,
it makes it possible to disable optimization without
leaving un-resolved settings in the IR.
Settings in the pre-load modules are still loaded
as Setting objects, and those are resolved during
the one-time optimization pass of those modules,
whether or not per-program optimization is run.
Change-Id: Idf560a49f936edc683463dc8a60771d0624b45d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369325
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This will make it easier to add "dynamic" attribs like stroke width or
color.
Bug: chromium:1172543
Bug: skia:10419
Change-Id: Ia8326c80fb2fe3ab630b03e9bfdc6368385176b0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368956
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Also deletes the old header under the deprecated name.
Bug: skia:11230
Change-Id: Iac42d2b980d3306a544077719ca62903a673210a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368242
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This also adds the relevant Start() / End() calls so that the DSL
is put into the correct state.
Change-Id: I844b0ab5dff06e3f7b0a69458bf4442a5da0f33e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/364857
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
https://docs.google.com/document/d/1z9ZODlZX4XXbfOjh2t1-1Z7FJcCCcOfbrEjiFzPE4vg/edit?usp=sharing&resourcekey=0-Io-07D1zm1yKMQN2UAiYBw
This approach lets us write color filters that want to work in
particular color spaces and alpha formats and adapt them to our normal
pipeline. It should work with pre-canned and runtime effects, and we
can do the same sort of thing for shaders too.
Some features are designed for using this with the high-contrast filter:
- ability to change working tf and gamut separately: as written the
HC effect only wants to work in linear space without changing
gamut, which is I bet will be a common desired mode. But other
effects may want to fully change the working color space, e.g. to
sRGB or XYZ.
- adapting the alpha type to unpremul is mostly a flourish: you could
do it yourself in sksl, but we might as well do it if doing other
transforms anyway (it's cheaper this way than doing it yourself),
and this may make it easier to adapt non-runtime effects.
(I bet most color filters actually want to be unpremul.)
I briefly also included a knob to control how this effect treats a
nullptr dst color space, but I've come back around to that not being a
parameter. I think this is a situation where we know best.
New GM to demo.
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Change-Id: I420e3a2aa648f314c019a98bfdcd44e810a3dac6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368336
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Stores it on the ResolveLevelCounter instead. This will allow
different paths to have different stroke widths.
Bug: chromium:1172543
Bug: skia:10419
Change-Id: I0ff68b7287027a22d9374826b3c57290192489bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/368937
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
On batch failure we're rerunning every source in the batch, while we
really only need to rerun sources that we don't know succeeded.
If for example we run sources "foo", "bar", and "baz", and foo produces
a known hash, then bar crashes, we only need to rerun bar and baz. The
batch run was enough to demonstrate foo's good.
Change-Id: I17634a6095906bcc2ad0bd33bb78eba000654b5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369456
Reviewed-by: Eric Boren <borenet@google.com>
The optimization which replaces unnecessarily nested constructors is
creating a new constructor from whole cloth, obliterating the original
constructor and its arguments. This can invalidate the definition map.
For now, this is fixed by forcing a rescan when this optimization is
applied.
Change-Id: I8a46bccf3b6422282eaf95409cd4fa50b8ad3187
Bug: oss-fuzz:29994
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369324
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Change-Id: I80652861841ec4f049336f1759c1c26a934c309a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369261
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Move definition of Work struct until just before it's used,
and show one of the sources as an example at kickoff-level step.
These are just cosmetic/refactors.
Change-Id: Ib23b9379683b9867e097c8d68ef8736013719cee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369356
Reviewed-by: Eric Boren <borenet@google.com>
60ba8fe9e7..54c5ad5c92
Includes changes required for COLR v1 support.
No changes to ftoption.h or ftmodule.h.
Change-Id: Id7fff0437144ad4e8318d8b462470bb0c4d6c02d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/369336
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Previously we were ignoring the conic weight and using the regular
quadratic Wang's formula for conic segments. This CL uses the new
specialized formula for conics.
Bug: skia:10419
Change-Id: I2929135decc539b9ecf27516a0d9d231be3f7494
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/366405
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Tyler Denniston <tdenniston@google.com>