It is possible for a single glyph to have multiple representations. In a
COLRv0 or COLRv1 font the outlines of the sub glyphs must be used as
layers or clips. Ensure that bitmaps and SVG representations are
explicitly excluded when loading glyphs with the express purpose of
retrieving any available outline.
Note that this does not touch the flags used in generatePath because in
that case a path should only be loaded if the glyph representation for
rendering is actually outline based.
Change-Id: I499e23aa20dacead81c7f76980039f139fa8edce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530676
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Now that getType no longer needs it, this was only used to see if two
types matched (modulo precision).
Change-Id: Icdf507573f03a8caf2b202465a83e50359eb6446
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530570
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Commit-Queue: Arman Uguray <armansito@google.com>
Previously, we would determine the operandType by calling
`getActualType`. This function converts half-precision types to full-
precision ones, which seems to have been unintentional. Fortunately, the
operand type is not actually emitted into the SPIR-V by most code paths
(most paths use the resultType instead) so it was not a significant
impact in practice. A few matrix-based paths emitted ops using this type
and these paths now emit RelaxedPrecision as expected.
Change-Id: I32f4c0327427476fee6b78953284818b7970b6e8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530543
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
This now uses existing logic from `nextId` rather than reinventing the
wheel.
Change-Id: I2879fa42e8df6d70936ce7e322d48e4990d79319
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530540
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Arman Uguray <armansito@google.com>
Commit-Queue: Arman Uguray <armansito@google.com>
The COLRv1 bounding box is currently computed without the subpixel
offset. This can lead to cropping of a row or column at the edge of the
rendering. Apply the subpixel offset to the base bounding boxes.
This is simplified by always converting the FT_BBox to an SkRect as
early as is convenient and unifying the COLRv1, COLRv0, outline, and
bitmap application of subpixel positioning and conversion of bounds to
glyph bounds.
This also fixes a long standing issue where it is possible for subpixel
positioned empty (space) glyphs to have non-zero bounds since rounding
out a non-integer aligned empty SkRect to an SkIRect will produce a unit
SkIRect.
Change-Id: I634783250942d0cd45cf28e81d5fd695982547cf
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530523
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
SkFindQuadMaxCurvature returns either a value in [0, 1) or NaN.
split_conic uses this to determine where to chop a conic, but doesn't
check for NaN, and passing NaN to conic.chopAt() will assert. Inverting
the if statement and checking to see if t is in (0,1) rather than that
t == 0 || t == 1 will cover the NaN case, since NaN comparisons are
always false.
Bug: skia:1310167
Change-Id: I401f586d9b4cb9f05332027627f9fac9dc7dee15
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530519
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
We will need this in a followup, because we can apply optimizations to
function-class LValues that wouldn't make sense for other classes.
Change-Id: I99855961cfb8c5bfac0068e33e20e2e687f5aefe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530537
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Bug: skia:13212
Change-Id: I8fc8bcd01181fcfb9955119984afa4bfbb1f73e5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529756
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Previously, we only handled the simple case of extracting from an
OpConstantComposite. Now we also handle the complex case of extracting
from an OpCompositeConstruct, where vectors can be composed of other
vectors.
This is particularly challenging because OpCompositeConstruct can
contain SpvIds from almost any other instruction, so we need to be
able to decode those instructions and figure out their type. For
instance:
%5 = OpFAdd Vec2 %1 %2
%6 = OpFAdd Scalar %3 %4
%7 = OpCompositeConstruct FloatVec3 %5 %6
%8 = OpCompositeExtract %7 2
The %8 (OpCompositeExtract) could be replaced with %6 but we need to
peek at the type in *both* OpFAdd instructions to decode this. It
only works when the affected instructions are in-cache, so many
opportunities are currently not optimized because their code still
uses the original, uncached form of writeInstruction.
Change-Id: I5719ae6284f32e1d6f2c898eca282c22b94fc764
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529743
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Change-Id: I3a9e9e90b0ac1b1099830eaca06506bcce794144
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530055
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Previously just the base level was uploaded and the level contents
were generated on the GPU.
showmiplevels_explicit now works on GPU.
Bug: skia:11983
Change-Id: I96ed8a7ad90a8252f55a736cb6146eec9b2a3ad1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/521356
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
We don't need deduplication on struct types, but we do want the ability
to look up a SpvId and determine that it is a struct type. (An oversight
from quickly assembling the reland at http://review.skia.org/529748)
Change-Id: Iffd42e4f37c0a585beb6ba0a37d69a92a1759ca6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529752
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Bug: skia:13219
Change-Id: I57c5c2aa40e6eb85d5e6045d6f3374d0379efd39
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530337
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This removes the assert from the SPIR-V generator so the
tests compile. The generated SPIR-V is incorrect. The next
CL fixes the generator, and restores the assert.
Change-Id: I77b507cf7fb5eac481322887000bd1c73cd5c899
Bug: skia:13219
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530336
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
The current code assumes that the glyph loaded into the FT_Face has
outline format. However, nothing is actually checking this, it is
possible to get here which an SVG or bitmap backed glyph. Check that
glyph actually has an outline before trying to convert to SkPath.
Change-Id: I24f9f06a4ba6a3323a310a559a1548ff76cfdffb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530051
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This code was added to diagnose problems with RawDraw. It is suppose
to hold for all OOP-R drawing, but the fuzzer in the bug below seems
to trigger this invariant checking. Disable on the off chance this
triggers in the field.
Bug: chromium:1316440
Change-Id: I36aff480741535e87de0e88b5f90491819ba1eff
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529833
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Change-Id: I1964f2d8edaae67c03f86653b93657828208cd32
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529832
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
It is possible to create a font which claims to have a very large bitmap
glyph and for that glyph to be scaled even larger. Catch this and don't
draw the glyph.
Bug: chromium:1308164
Change-Id: Ie66aa8ca64afba2c642b6fb594203756be2d41ee
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529831
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
There seems to be a copy-paste issue with the documentation for the
return value of SkFont::countText. SkFont::countText returns the number
of glyphs, measureText returns the sum of the default advances.
Change-Id: Id3c9008c20e7b4b8ad4f1d834df19183a9b2bf1e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/530046
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Previously SkFontMgr_Fuchsia could be leaked because it kept cache of
loaded fonts and these fonts kept reference to SkFontMgr_Fuchsia. Fixed
this issue by moving SkData caching logic to a separate class, which
breaks the loop.
Bug: chromium:1287367
Change-Id: I09208502d61273c86bb6d06ecf7affd5f18ffb7e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529937
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Staticaly define what the tests will be to make it easier to add more
and tweak them when testing.
Also remove the attempt at left aligning the drawing. This was actually
a bit confusing since it caused positioning differences between the
bitmap and outline versions of the font.
Change-Id: Idc6da6f4628755154d186cc1e62daed28a65aaf5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529750
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
When using a COLR glyph representation there is no need to load the base
glyph to draw. If COLR glyph representation was chosen for metrics, the
image and drawable generation should use the same format. Separate the
drawing of COLR glyphs with Skia and drawing other glyphs with FreeType
data.
This is not intended to change behavior. However, this does incidentally
fix an issue where previously a COLRv0 glyph would use the metrics of
its last component instead of the metrics of the base glyph. The
specification requires that all COLRv0 layers have the same advance
width and the test fonts do this. However, other code like the FreeType
autohinter may kick in and cause the value to be slightly different.
Since COLRv1 requires that the base glyph advance be used, this change
standardizes on using the base glyph.
[0] https://docs.microsoft.com/en-us/typography/opentype/spec/colr#metrics-for-color-glyphs-using-version-0-formats
Change-Id: I0258c82d83076327cfb2c68954b9bb2683599e9c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529804
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This is a reland of commit 60ff0facbf
Structs are now deduplicated using a [Type*, SpvId] map.
Original change's description:
> Use op cache when emitting types.
>
> We no longer need to maintain a separate `fTypeMap` for mapping types
> to SpvIds, since the op cache handles this automatically.
>
> We also now support deduplicating instructions that don't have a result,
> such as decorations. (In particular, we needed to avoid emitting the
> SpvDecorationArrayStride op every time the array type was accessed, but
> this op doesn't have a result ID.)
>
> Change-Id: I779b8c8e3de5973b8f487b28c0a8ece9a1041845
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529732
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
Change-Id: I9f6a78d58e8af38a1fd690a8860d8b5aa3193be6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529748
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Now that Skia has vulkan-tools (and vulkan-tools has had its internal GN
issues fixed), this should unblock the roller again.
Bug: dawn:1365
Change-Id: I1ce3b8aeffda57a742655fa5eddc50d3242f2ca5
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529749
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
Change-Id: I800fa2a1fb0e64ad478c76ea2d5cda176ea8f48b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529746
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This reverts commit 60ff0facbf.
Reason for revert: Broke D3D bots
Original change's description:
> Use op cache when emitting types.
>
> We no longer need to maintain a separate `fTypeMap` for mapping types
> to SpvIds, since the op cache handles this automatically.
>
> We also now support deduplicating instructions that don't have a result,
> such as decorations. (In particular, we needed to avoid emitting the
> SpvDecorationArrayStride op every time the array type was accessed, but
> this op doesn't have a result ID.)
>
> Change-Id: I779b8c8e3de5973b8f487b28c0a8ece9a1041845
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529732
> Reviewed-by: Brian Osman <brianosman@google.com>
> Commit-Queue: John Stiles <johnstiles@google.com>
> Auto-Submit: John Stiles <johnstiles@google.com>
Change-Id: I0e2187f88f2a945fd6f88ce75ff815e03d2f7df5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529747
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>
This is a reland of commit acb8770918
Original change's description:
> skif:LayerSpace<SkRect>::roundOut/In have epsilon tolerance.
>
> Adds a little tolerance so that e.g. left=30.999994 with roundOut
> will still round to 31 not 30. Helps avoid cases where imprecision
> leads to including an entire unwanted row/column of an input image
> to an image filter.
>
> This Chrome change must land first:
> https://chromium-review.googlesource.com/c/chromium/src/+/3577185/
>
> Bug: chromium:1313579
> Change-Id: I143c8f99b90413a6b610f2b3a5e54e648777ca68
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528652
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: chromium:1313579
Change-Id: Ia827c6fc01542fa3d56f560cde517570b8f0021d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/529744
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>