In PDF there are two different physical encodings of strings (as a
sequence of bytes). There is the literal string encoding which is
delimited by '(' and ') which stores the bytes as-is except for '(',
')', and the escape character '\' (which can introduce octal encoded
bytes). There is also the hex string encoding delimited by '<' and '>'
and the bytes are encoded in hex pairs (with an implicit '0' at the end
for odd length encodings).
The interpretation of these bytes depends on the logical string type of
the dictionary key. There is a base abstract (well, almost abstract
except for legacy purposes) string type. The subtypes of the string type
are `text string`, `ASCII string`, and `byte string`. The `text string`
is logically further subtyped into `PDFDocEncoded string` and `UTF-16BE
with BOM`. In theory any of these logical string types may have its
encoded bytes written out in either of the two physical string
encodings.
In practice for Skia this means there are two types of string to keep
track of, since `ASCII string` and `byte string` can be treated the
same (in this change they are both treated as `byte string`). If the
type is `text string` then the bytes Skia has are interpreted as UTF-8
and may be converted to `UTF-16BE with BOM` or used directly as
`PDFDocEncoded string` if that is valid. If the type is `byte string`
then the bytes Skia has may not be converted and must be written as-is.
This means that when Skia sets a dictionary key to a string value it
must, at the very least, remember if the key's type was `text string`.
This change replaces all `String` methods with `ByteString` and
`TextString` methods and updates all the callers to the correct one
based on the key being written.
With the string handling corrected, the `/ActualText` string is now
emitted with this new common code as well for better output and to
reduce code duplication. A few no longer used public APIs involving
these strings are removed. The documentation for the URI annotation is
updated to reflect reality.
This change outputs `UTF-16BE with BOM` with the hex string encoding
only and does not attempt to fix the literal string encoding which
always escapes bytes > 0x7F. These changes may be attempted in a
separate change.
Bug: chromium:1323159
Change-Id: I00bdd5c90ad1ff2edfb74a9de41424c4eeac5ccb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543084
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
shaders.skia.org was passing in a Malloc'd TypedArray for uniforms
(to avoid unnecessary copying of that buffer on every frame).
However, CanvasKit would always take ownership of that buffer and
free it when the shader was freed. CanvasKit should only take
ownership (and clean up) the uniform buffer if it was not
copied into pre-malloc'd memory.
This also adds a handy make target that builds CanvasKit
and copies it into the proper place in the infra repository
to run the shaders app locally.
See also: https://skia-review.googlesource.com/c/buildbot/+/543436
Change-Id: I6c6b7f94f8c8571f9ce0613ccdd7fceb0f315a12
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543416
Reviewed-by: Jorge Betancourt <jmbetancourt@google.com>
Also cleans up the scattered references remaining in the code base
(including in files I thought I got already...).
Change-Id: I7004354b1e9cea9f9d9f45b791d8ab9ce557ba01
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542647
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Also makes SDFMaskFilter available.
Bug: skia:13118
Change-Id: I27ca3ed85a057267387841be5dad10d8e6c7f7bf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543079
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Bug: skia:12703
Change-Id: I913a8411ab15f61e61512012061dd9f7fdbb0740
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/540857
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Appeasing IWYU and the Gazelle-generated BUILD.bazel files is currently
annoying for devs working on non-linux environments.
I have been experimenting with removing the gazelle rules (but still
keeping our BUILD.bazel rules organized), which would alleviate
some of the burden here. Until that is finished, we can stop one
of the two jobs.
Change-Id: Id6c43bd98c6ce41e1ae9a6bfc1102ff47a6e5b1f
Bug: skia:12541
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543496
Reviewed-by: Brian Salomon <bsalomon@google.com>
Remove the need for the Slug/Blob at SubRun creation. This needed
to combine the SkGlyphRunPainterInterface for Slug and Blob.
Change-Id: I8ba1db4590a5db26d1542d025e5414a2625ad88f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543082
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
SK_SUPPORT_GPU needed to be set to 1, and SK_GRAPHITE_ENABLED should
be checked to see if it's defined, not its value.
Change-Id: Ib762c590ceaa570ec98a76558657bbcee672c254
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543080
Reviewed-by: Greg Daniel <egdaniel@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
This is a CL to make the APIs for SubRuns more Blob/Slug
agnostic. The aim is to make the process* code for Blobs and
Slug the same.
Change-Id: I087da97ea4c56e5d37619a43b2aa2458bc58914c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542648
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This is cleanup left over from a prior CL's review. We will want to
use the combination builder outside of graphite.
This CL is mainly just moving stuff around except for the addition
of the SkCombinationBuilder.buildCombinations method and CreateKey
more accessible outside of Graphite.
Bug: skia:12701
Change-Id: If2cae6fcff5670e488bc14473b7b1d2f9b1fecd7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543196
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This also adds support for making a Resources unbudgeted state when it
is pulled out of the cache to be used for an SkImage or Surface. It
then puts the resources back as budgeted when returned to the cache.
Bug: skia:12754
Change-Id: I469ace602aa6f5f708b82655e94557ff8ad45a72
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/538046
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Adds a saturated_add function that was on SkNx and used in
SkXfermode_opts, but hadn't been ported to skvx yet.
Removes the Sk4px_opts variants and simplifies some of its functions;
many were already defined skvx.
The largest change is that Sk4px does not extend skvx::byte16, since it
used to extend Sk16b. Now it just has a vector as a data type. This
was necessary so that we could define operators that were typed for
Sk4px and Wide w/o conflicting with the free operators that were
defined for the base skvx types.
Change-Id: I8c667ba86f662ccf07ad85aa32e78abfc0a8c7ae
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542645
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Bug: skia:13118
Change-Id: Id7c92b2e1af9febb3e576c244fcff3aedd27f408
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542646
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Bug: skia:12703
Change-Id: Ic24f7c29583946f29b4b500194f2e951b1037655
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/540856
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Change-Id: Ib4f2ae63ceee424eb93d098c7cd65e6ea8ac92f7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543056
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Bug: skia:12703
Change-Id: I9cc44db555a7bb03e4afeaedac4052c796349c5e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/540621
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This reverts commit f2d000328f.
Reason for revert: breaking google3 roll
Original change's description:
> Eliminate DSLPossibleExpression.
>
> The Possible(Expression|Statement) classes were added at
> http://review.skia.org/375069. These classes were responsible for
> capturing `__builtin_FILE()` and `__builtin_LINE()` when an
> expression or statement was added to a hand-authored DSL program. This
> allowed errors to be reported on the C++ file/line where they were
> encountered. This was a good feature to have, when the plan was to
> author the majority of SkSL code via DSL.
>
> Later, IRNode positions were converted from an integer line number to
> SkSL Positions at http://review.skia.org/518137. This gave us range
> tracking, but at a high memory cost (16 bytes per IRNode, versus four
> bytes when we tracked line numbers only).
>
> Positions were reduced to 8 bytes at http://review.skia.org/521005 by
> removing the filename, which was only used for hand-authored DSL. (The
> size was pared all the way back to 4 bytes at
> http://review.skia.org/533699 by packing the data more efficiently.)
>
> __builtin_FILE/LINE capturing was removed entirely at
> http://review.skia.org/528366; the filename was discarded anyway and
> the line number didn't have a range and wasn't very meaningful without
> a filename. Also, it didn't matter very much since we no longer intended
> to hand-craft our programs in DSL.
>
> At this stage, DSLPossibleExpression stopped adding value and simply
> served to move Expressions around.
>
> Change-Id: I29ac33e08dcc1804cc0619c1e8856ba28ebcc51d
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542145
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
Change-Id: I33badbdcce8760200246bf50e4932d42721ea952
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543078
Reviewed-by: Tyler Denniston <tdenniston@google.com>
Owners-Override: Kevin Lubick <kjlubick@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Tyler Denniston <tdenniston@google.com>
Change-Id: I1a5490f546a3cb046c64b114a30be991d2d9f2cc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541064
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
The Possible(Expression|Statement) classes were added at
http://review.skia.org/375069. These classes were responsible for
capturing `__builtin_FILE()` and `__builtin_LINE()` when an
expression or statement was added to a hand-authored DSL program. This
allowed errors to be reported on the C++ file/line where they were
encountered. This was a good feature to have, when the plan was to
author the majority of SkSL code via DSL.
Later, IRNode positions were converted from an integer line number to
SkSL Positions at http://review.skia.org/518137. This gave us range
tracking, but at a high memory cost (16 bytes per IRNode, versus four
bytes when we tracked line numbers only).
Positions were reduced to 8 bytes at http://review.skia.org/521005 by
removing the filename, which was only used for hand-authored DSL. (The
size was pared all the way back to 4 bytes at
http://review.skia.org/533699 by packing the data more efficiently.)
__builtin_FILE/LINE capturing was removed entirely at
http://review.skia.org/528366; the filename was discarded anyway and
the line number didn't have a range and wasn't very meaningful without
a filename. Also, it didn't matter very much since we no longer intended
to hand-craft our programs in DSL.
At this stage, DSLPossibleExpression stopped adding value and simply
served to move Expressions around.
Change-Id: I29ac33e08dcc1804cc0619c1e8856ba28ebcc51d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542145
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
~DSLStatement and ~DSLExpression previously called
`fFragBuilder->codeAppend`. ~DSLPossibleStatement and
~DSLPossibleExpression would convert themselves to DSLStatements and
DSLExpressions (if otherwise unreleased) in order to leverage this
side-effect. DSL FP support was removed at
http://review.skia.org/540301, and those side-effects were removed.
At that point, these destructors became dead code.
Change-Id: Iec801d66b9ee9ea8c93f7c851966af38c6446037
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542526
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Previously the function emitted for complex gradients looked like
if (t <= 0) {
ret = color[0]
} else {
if (t <= stop[1]) {
ret = interp(t, color[0], color[1])
} else {
if (t <= stop[2]) {
ret = interp(t, color[1], color[2])
} else {
if (t <= stop[3]) {
ret = interp(t, color[2], color[3])
} else {
if (t <= stop[4]) {
ret = interp(t, color[3], color[4])
} else {
ret = color[4]
}
}
}
}
}
So a gradient with many color stops could end up with extreme nesting of
ifelse. This could cause some viewers to reject the function due to
implementation limits. Even when not rejected the drawing would be slow
due to the linear testing of each range.
Change the function's structure to a binary search with special cases
for the begin and end ranges.
if (t <= 0) {
ret = color[0];
t = 0;
}
if (t > 0 && t <= stop[4]) {
if (t <= stop[2]) {
if (t <= stop[1]) {
ret = interp(t, color[0], color[1]);
} else {
ret = interp(t, color[1], color[2]);
}
} else {
if (t <= stop[3] {
ret = interp(t, color[2], color[3]);
} else {
ret = interp(t, color[3], color[4]);
}
}
t = 0;
}
if (t > 0) {
ret = color[4];
}
This change allows gradients with many stops to work in all known
viewers and greatly speeds up their drawing in viewers which did manage
to render with the old function. The function text is slightly larger
with this change, but minimally. If this becomes a size issue it may be
possible to size optimize gradients with few stops in the future.
Props to Bram De Cooman for suggesting this form for the function, the
initial implementation [0], and testing to make sure this approach would
resolve the issue.
[0] https://skia-review.googlesource.com/c/skia/+/540136
Bug: chromium:1316377
Co-authored-by: Bram De Cooman <bram.decooman@gmail.com>
Change-Id: Ib29cbb17220b9c32105b02222c1e1615ce0196bf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541639
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Change-Id: I4ea10bd1354d6f68a6940fd48782bfa00bb3b343
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542417
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
These tests would be expected to trigger the CFI sanitizer (skia:13339).
We don't currently support CFI sanitizers, though (skia:13338).
Tests are confirmed to fail in Linux by copying TArray unit tests into
SkSLCompiler and running Chrome unit tests:
http://screen/3cYe9r4MYSXmTTa
Change-Id: If2d9e611bc9902e2ac6e0960a38e876bb1952884
Bug: skia:13338, skia:13339
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542639
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Change-Id: I6db6a31834e55ebcc4af9064eac372281f341533
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542644
Auto-Submit: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Bug: skia:13118
Change-Id: Id4afcfeeb9a5b44a0e2cb24b70c76a81ec5daaea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542300
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Change-Id: I6db702c2d231bfe527b3fd4bf4f99beb6e58bf8a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542641
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Ravi Mistry <rmistry@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
An undocumented feature of Preview 11.0 (1033.3) is that `a n mod r eq`
(with a and n both integers, r integer or real) early aborts a function
when false would be put on the stack. Work around this by re-writing
`t 2 mod 1 eq` as `t 2 mod 0 gt`.
Bug: chromium:1316377, chromium:1170345
Change-Id: Ibb6eaaf36f276e9ef2906159622ab44b35289492
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542638
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Fix for this landed in ANGLE.
Bug: skia:13290
Cq-Include-Trybots: luci.skia.skia.primary:Test-Mac10.15.1-Clang-MacBookAir7.2-GPU-IntelHD6000-x86_64-Debug-All-ANGLE
Change-Id: Id14366c5f9fe33bf1347a9bdaad12ec38b93fa6b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542640
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
In the curve tessellating render step, a path that is only linear
segments is entirely handled by the inner triangles, so the patch
writing never actually emits any instances. This is detected after
the fact by seeing that the per-instance vertex count remains 0, so
we just skip issuing the draw call.
Change-Id: I708797484073f5afcfb5d734467378861091ce8a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542616
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Graphite will also need tokens to track draw and upload progress, so
moved the token class to a shared location, and tokens into the Plot
class.
Bug: skia:13118
Change-Id: Ib5748a7f25d79ee0aabca7427511cc9fd6e75117
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541740
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
The ShaderType enum seems like it will persist while the ShaderCombo will not.
Bug: skia:12701
Change-Id: Idf9ed89a50bac46b93a81da3e814207c83b3a1ea
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/541723
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
I've created a real bug and assigned to Joe Gregorio for now (please
reassign as you see fit).
Change-Id: I0cc1ef52b254904e545c9c266df484816de60021
Bug: skia:13344
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542636
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Joe Gregorio <jcgregorio@google.com>
Instead of taking the minimum required index/vertex count for an
instance, DynamicInstances::append() now takes a proxy. The proxy can
be used to calculate the index when it's needed at flush time, and can
accumulate its internal state to represent a worst case that
corresponds to the worst case index count as well.
Updates the tessellating RenderSteps to use a single PatchAllocator
definition that just swaps out how tess::LinearTolerances are converted
to a vertex count. This will also work seamlessly with
FixedCountStrokes.
Removes stride() function from PatchAllocator because it's clunky to
try and pass that out of DrawWriter or RenderStep to PatchWriter, and
can be re-computed from fAttribs anyways. Since it's only re-used in
PatchWriter for the deferred patch, it's one sum for every path contour
and will likely not be noticed in perf. If it is, we can have
PatchWriter remember it instead and keep PatchAllocator simple still.
Bug: skia:13056, skia:13012
Change-Id: I52a36da4df23ebb01a98246458b6538744c1815f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/540620
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>