Commit Graph

80 Commits

Author SHA1 Message Date
Florin Malita
77af386c13 [sksg] Explicit text alignment
Work around for https://bugs.chromium.org/p/skia/issues/detail?id=8252

Change-Id: Icae3f69f07a2c95302cfbb3833185517f43d326e
Reviewed-on: https://skia-review.googlesource.com/147218
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2018-08-15 21:54:05 +00:00
Florin Malita
d19fed1e29 [skottie] Eliminate some temp SkString allocations
Use the SkJSON conversion idiom instead of ParseDefault<SkString>.

Change-Id: Ieeadb86891602eaef2ecf5b68a4eb17b4897e8f7
Reviewed-on: https://skia-review.googlesource.com/147103
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
2018-08-14 17:25:20 +00:00
Florin Malita
679d05c48a [sksg] Simplify ScopedRenderContext
ScopedRenderContext tries really hard to avoid unnecessary RenderContext
initializations.

This is most likely unneeded because

  a) the structure is quite lightweight

and

  b) all ScopedRenderContext instantiation sites imediately call setters
     which require a writable context (assuming no-op args are uncommon)

Let's get rid of that over-engineered gunk.

Bug: skia:
Change-Id: Ieedc20c63c66b4d43744359e881c20639654040c
Reviewed-on: https://skia-review.googlesource.com/146761
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-10 17:54:29 +00:00
Florin Malita
73154babe5 [skottie] Avoid UB while parsing 1-based indices
Current impl can underflow int due to unchecked arithmetic.

Add a Parse<size_t> specialization and convert call sites which use
inline arithmetic.  Underflowing unsigned types should be well defined
and caught in later tests.

Bug: oss-fuzz:9798
Change-Id: Iaebe8aad4009e2511fe1d8733d336f5f119bb384
Reviewed-on: https://skia-review.googlesource.com/146648
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-09 22:05:32 +00:00
Florin Malita
e1c9d3c9e2 [skottie] Optimize color filter layerization
Use the deferred paint override mechanism, similar to opacity.

Change-Id: I78fa7f5d73ef333480ec72b0cb663819b1de2404
Reviewed-on: https://skia-review.googlesource.com/146527
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-09 21:03:12 +00:00
Ben Wagner
b2c4ea6219 Move Views into Sample and Viewer.
What is left of the SkView system is used only by samples or viewer.
As a result, move it out of the Skia source tree and re-organize so it
is a bit easier to understand and use more shared code.

Move samplecode/ClockFaceView.cpp to samplecode/SampleTextEffects.cpp,
sice that's what's actually in it.

Move SkAnimTimer.h to tools/timer, since it's actually shared between gm
and samples.

Change-Id: I55dafd94c64e4f930ddbd19168e0f812af86c455
Reviewed-on: https://skia-review.googlesource.com/146161
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2018-08-09 15:25:32 +00:00
Cary Clark
e12a090a63 make some textblob builders private for now
Move SkTextBlobBuilder::allocRunText* to private: for the time
being, to reduce the documented interface footprint.

No code is deleted; the functions may be restored when a
client is ready to call them.

Also, add SkTextBlob::MakeFromString to complement
SkTextBlob::MakeFromText.

R=halcanary@google.com,fmalita@google.com
TBR=reed@google.com
Bug: skia:6818
Change-Id: If09d4da4ce38b680d73f25d187e3d06eeb0ec652
Reviewed-on: https://skia-review.googlesource.com/146521
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
2018-08-09 15:01:31 +00:00
Florin Malita
c0132ffa64 [skottie] Optimize opacity layerization
- plumb a RenderContext RenderNode::render() argument to track pending
    opacity

  - defer opacity application until we can determine whether a layer is
    required (group with multiple children) or the opacity can be pushed
    onto the draw paint (for single/atomic draws)

Bug: skia:
Change-Id: I962ba08bad780395d5d738307bde986e9efa502b
Reviewed-on: https://skia-review.googlesource.com/146445
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-09 14:48:02 +00:00
Florin Malita
3c9929698d [skottie] Animator tweaks
* reserve SkPath storage to avoid incremental allocations
  * refactor eval() to avoid copying data when interpolation is not
    triggered

Change-Id: I467affbbfd652e8fa2a486acab7d6c7b9165d49f
Reviewed-on: https://skia-review.googlesource.com/146166
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-08 21:15:47 +00:00
Mike Reed
5edcd31f2c migrating SkTDArray towards std::vector api
fix for https://skia-review.googlesource.com/c/skia/+/146140

Change from original was to include <initializer_list>

Bug: skia:
Change-Id: Ie36426fcf7ce778a95e2b656ce80a9a394a8307c
Reviewed-on: https://skia-review.googlesource.com/146160
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2018-08-08 15:51:44 +00:00
Mike Reed
f9ecb4e67e Revert "migrating SkTDArray towards std::vector api"
This reverts commit 79884be809.

Reason for revert: broke flutter build -- initializer_list?

Original change's description:
> migrating SkTDArray towards std::vector api
> 
> push -> push_back
> add some aliases to match std::vector: count, reserve, ...
> 
> Bug: skia:
> Change-Id: I1921c31d0d6e5ed3d622a0def6054c697be2d02f
> Reviewed-on: https://skia-review.googlesource.com/145884
> Reviewed-by: Mike Klein <mtklein@google.com>
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Commit-Queue: Mike Reed <reed@google.com>

TBR=mtklein@google.com,fmalita@chromium.org,reed@google.com

Change-Id: Ib6132b725aaed7c01287e3e8c2b5a14da3d3d7e9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/146140
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2018-08-08 15:14:37 +00:00
Mike Reed
79884be809 migrating SkTDArray towards std::vector api
push -> push_back
add some aliases to match std::vector: count, reserve, ...

Bug: skia:
Change-Id: I1921c31d0d6e5ed3d622a0def6054c697be2d02f
Reviewed-on: https://skia-review.googlesource.com/145884
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2018-08-08 14:43:28 +00:00
Mike Klein
fcd1654b79 make sksg a component
Change-Id: I81fcbecb6ae002bd1b61918514f5c836660c27cb
Reviewed-on: https://skia-review.googlesource.com/145883
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Klein <mtklein@google.com>
2018-08-08 00:43:05 +00:00
Mike Reed
9adff1a89f use VectorValue consistently
Bug: skia:
Change-Id: I148bd0cac3c094b30217b30104ebbc6e080c994f
Reviewed-on: https://skia-review.googlesource.com/145885
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2018-08-08 00:43:04 +00:00
Ben Wagner
177742435e Some iwyu for SkShaper_harfbuzz.
This makes it easier to see what ties this module to Skia.

Change-Id: I392ae4f89fb1afe9193bdb2fda95036f4f5623ed
Reviewed-on: https://skia-review.googlesource.com/145882
Commit-Queue: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Auto-Submit: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2018-08-07 19:00:58 +00:00
Ben Wagner
c0c99b3a69 Add context to shaper.
This allows correct shaping across any run breaks.

Change-Id: Ib305bd974ccee2471b1dfe8bd895fb28e475177f
Reviewed-on: https://skia-review.googlesource.com/145726
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2018-08-07 18:24:14 +00:00
Florin Malita
30f4e96517 [skottie] Use animator scratch storage to avoid vector reallocations
Change-Id: Iab01c84ab83666218aa5ebc88f0d81b330858a74
Reviewed-on: https://skia-review.googlesource.com/145724
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2018-08-07 16:26:44 +00:00
Florin Malita
36216fb0ac [skottie] Initial Fill layer effect support
Overwrite the layer content color with a color filter.

TBR=
Change-Id: I39f920225affb2641cc11ab1f0c1456d89b47cb7
Reviewed-on: https://skia-review.googlesource.com/145730
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-07 15:34:34 +00:00
Florin Malita
0c8dca0f44 [skottie] ResourceManager tweaks
* pass the resource path explicitly
 * return SkData instead of a stream

Bug: skia:
Change-Id: I8a92fa34d78d5c996e2a26481fc3087e8737ec8e
Reviewed-on: https://skia-review.googlesource.com/145520
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2018-08-06 18:50:22 +00:00
Florin Malita
6e487e67a3 [Skottie] Add raw data factory
... and funnel all existing factories through the new one.

Change-Id: I01ffb95abf178eacc0ad430e730d680800a509c7
Reviewed-on: https://skia-review.googlesource.com/145428
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-06 16:29:31 +00:00
Florin Malita
270c04af1d [skottie] Avoid redundant instantiation of image asset nodes
Add an attached asset cache, and prevent unnecessary duplication of
image nodes when referenced multiple times.

TBR=
Change-Id: I3f0e8d592b1f57d71c9bc41cec7b2240bdb6d859
Reviewed-on: https://skia-review.googlesource.com/145366
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-03 18:49:04 +00:00
Florin Malita
8949c8a2f8 [skottie/sksg] Move source files list to .gni
To facilitate Chromium integration.

Change-Id: Ie6a08e90feda4c6deace9754f0baef7176882334
Reviewed-on: https://skia-review.googlesource.com/145146
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-08-02 16:29:13 +00:00
Mike Reed
6cfa297382 remove conditional flags for sksg -- not needed for a module
Bug: skia:
Change-Id: I1b73379bd8a1ba2cd4293180052ba7ad59dfe96f
Reviewed-on: https://skia-review.googlesource.com/144642
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
2018-07-31 22:27:20 +00:00
Hal Canary
f107a2fd01 SkUTF
Create new header and namespace, `SkUTF` where we are putting all of our
robust, well documented UTF-8, UTF-16, and UTF-32 functions:
`SkUTF::{Count,Next,To}UTF{8,16,32}()`.

SkUTF.h and SkUTF.cpp do not depend on the rest of Skia and are suitable
for re-use in other modules.

Some of the old UTF-{8,16} functions still live in SkUtils.h; their use
will be phased out in future CLs.

Also added more unit testing and cleaned up old tests.

Removed functions that were unused outside of tests or used only once.

Change-Id: Iaa59b8705abccf9c4ba082f855da368a0bad8380
Reviewed-on: https://skia-review.googlesource.com/143306
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2018-07-31 20:11:19 +00:00
Florin Malita
f2dd96fbbc [sksg] Fix image filter quality handling
TBR=

Change-Id: I06bd30650f1a9d70225b3e3374313f672dae3a8d
Reviewed-on: https://skia-review.googlesource.com/144343
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-30 15:38:45 +00:00
Hal Canary
4014ba6ec7 SkUtils: remove some versions of UTF routines.
Change-Id: Ib1f776ae472117c23d2145253adf25fceb412b32
Reviewed-on: https://skia-review.googlesource.com/143111
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2018-07-25 17:21:56 +00:00
Ben Wagner
d5148e3314 Move SkNoncopyable to include/private.
Change-Id: I62f60ea52faeebddecacf03d9429ac3f7c516b8e
Reviewed-on: https://skia-review.googlesource.com/141823
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-07-17 21:39:51 +00:00
Florin Malita
c45a5c5593 [skottie] Treat color properties as optional (default black)
TBR=
Change-Id: I51029b5718ec9925c214709ae4e3497dae130d37
Reviewed-on: https://skia-review.googlesource.com/141544
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-16 18:43:39 +00:00
Florin Malita
0c604ed06b [skottie] Teach skottie_tool to dump frame SKPs
Similar to saving PNG frames, now we can save SKPs.

TBR=
Change-Id: I5791b564a1d3e70424e45e62034e559e677795f1
Reviewed-on: https://skia-review.googlesource.com/141320
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-15 02:52:38 +00:00
Florin Malita
a487b0677a [skottie] Make stroke width optional
TBR=
Change-Id: I432a79b652ffd5838829f32980e2dcca55d57af4
Reviewed-on: https://skia-review.googlesource.com/141283
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-13 19:06:24 +00:00
Florin Malita
13ac194dbf [skottie] Fix matrix parenting for default/static values
When all matrix properties are static/default, we simply discard the
matrix node.  But we cannot do that in the presence of a parent matrix.

TBR=
Change-Id: I56c62216f18786249dea063690261bfae83fabec
Reviewed-on: https://skia-review.googlesource.com/141127
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-13 00:07:44 +00:00
Florin Malita
4b15dc202f [skottie] Fix polystar points distribution
Points start at bearing 0.

TBR=

Change-Id: I6798b1a5fb4709ab31b13ab76a78f49758e7eec6
Reviewed-on: https://skia-review.googlesource.com/140246
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-10 19:58:41 +00:00
Florin Malita
a7e78ee1d4 [skottie] Misc cleanup
* pass inline defaults
  * log expressions

TBR=
Change-Id: I5e3ab038d612c738abb1bcf35b4cc492b9aaa6c1
Reviewed-on: https://skia-review.googlesource.com/140240
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-10 19:58:40 +00:00
Florin Malita
4cbfb30006 [skottie] Log (unsupported) layer effects
TBR=

Change-Id: Ia35e4110cb3c02339a38e82cd0f4516c7c58a5d9
Reviewed-on: https://skia-review.googlesource.com/140251
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-10 19:53:36 +00:00
Florin Malita
7f8a073fae [skottie] Fix spurious gradient error messages
The adapter apply() method can get called before stops resolution, so
only log when some stops are present.

TBR=

Change-Id: I8e336e2cff781a0e64de31e6b63f3cf373b2daa0
Reviewed-on: https://skia-review.googlesource.com/140245
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-10 19:53:36 +00:00
Florin Malita
3be2e10ce5 [skottie] Ignore identity transforms
Some tranform properties are not optional, but many of them are static
identity.  Detect these cases and don't attach SG nodes for them.

Reduces the number of sksg::Matrix nodes by ~18%.

TBR=
Change-Id: Ia51c865d6928e8c48c73b30f6d45541caf334880
Reviewed-on: https://skia-review.googlesource.com/140186
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-10 15:07:04 +00:00
Florin Malita
418e658a69 [skottie] Apply fully opaque masks as clips
We already have a clip optimization when there is only one opaque mask.

Extend to cover multiple opaque masks, using Merge scene nodes.

TBR=
Change-Id: I24b61f0c0d080b13438c6777e98a8e2fefd09fdd
Reviewed-on: https://skia-review.googlesource.com/140002
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-10 13:28:15 +00:00
Florin Malita
502c3ffce8 [skottie] Do not discard SkPath's FillType when interpolating
The fill type is not reflected in shape keyframes, but it is tracked in
the scene graph.  Make sure we don't overwrite when interpolating.

TBR=
Change-Id: I281a61c3f4181ce34f772b36b83d0c7a64e265f6
Reviewed-on: https://skia-review.googlesource.com/139176
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-03 22:36:27 +00:00
Florin Malita
5dfd0694dc [skottie] Add support for comp time remapping
- plumb the framerate in AttachContext (needed for remapping)
  - expand CompTimeMapper to handle time remapping (in addition to
    time start, time stretch)

TBR=
Change-Id: If33bae7b4fe224f45d5a094a47899b9025827991
Reviewed-on: https://skia-review.googlesource.com/138990
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-07-02 19:32:42 +00:00
Florin Malita
8deab3ac1e [skottie] Fix 'subtract' masks
Empirically, AE applies subtract masks as inverted intersect masks: it
applies the opacity *outside* the mask geometry.

Adjust the masking logic accordingly.

TBR=
Change-Id: If8d9dedbed9ce01b623b6c86ea91e494823d5dc5
Reviewed-on: https://skia-review.googlesource.com/138580
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-06-29 17:40:27 +00:00
Florin Malita
1d7f930763 [skottie] Ensure static split-position properties are committed
We currently drop static split-position adapters without commiting the
value to the scene graph.

TBR=
Change-Id: Id5852da35345fa58ecaf6c752456ecb32e5b405a
Reviewed-on: https://skia-review.googlesource.com/136782
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-06-22 01:28:06 +00:00
Florin Malita
5361935cd0 [skottie] Simplify AttachMask
Minor cleanup: BindProperty reports whether a non-default property was
applied or bound for animation -- use this mechanism to detect
fully-opaque masks.

TBR=
Change-Id: I3bd9429842621309d0c6bd966ef748917e498c66
Reviewed-on: https://skia-review.googlesource.com/136623
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-06-21 16:52:48 +00:00
Florin Malita
8c5f9ef801 [skottie] Fix start-time/stretch-time handling
We currently apply start-time/stretch-time adjustments to the referenced
composition AND to the referencing layer local properties.  That last
part is incorrect: the adjustment should only apply to the referenced
composition.

Introduce a specialized composition time mapper to handle t adjustments,
and push the logic down to AttachCompLayer (and out of the generic
AttachLayer).

TBR=
Change-Id: I0ddb86232010a8e7cdac6524aef2eea5823e306d
Reviewed-on: https://skia-review.googlesource.com/136166
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-06-20 17:17:19 +00:00
Florin Malita
f5ac906476 [skottie] Simplify Parse<SkPoint>
Some BM versions wrap point values as single or even multi-element arrays.
Parse<SkScalar> already handles the former case - we can extend that
behavior to also cover the latter and simplify Parse<SkPoint>.

TBR=

Change-Id: I2152928944f43dc03a5d8f0d65865ac43974fd7a
Reviewed-on: https://skia-review.googlesource.com/135800
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-06-19 20:01:28 +00:00
Florin Malita
80452bee11 Fold SkJSON into Skia/utils
It's a tiny, core-ish component -- might as well treat as such to
simplify dependencies.

Change-Id: I6f31ce2d151f9a629d88bfc7f15d64891d5150c0
Reviewed-on: https://skia-review.googlesource.com/135780
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-06-19 18:23:30 +00:00
Florin Malita
fb3beb0591 [skjson] More short string micro-optimizations
When possible, load 8 chars and mask out the tag and \0 terminator.

~19% faster on a Z840, ~5% faster on a PixelC.

Change-Id: I12d4b7d86c92c887b00f5d2480d3ff05a7042df1
Reviewed-on: https://skia-review.googlesource.com/135624
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Klein <mtklein@google.com>
2018-06-19 02:50:58 +00:00
Ben Wagner
f08d1d0ce1 Stop using SkTSwap.
Use std::swap instead. It does not appear that any external user
specializes SkTSwap, but some may still use it. This removes all use in
Skia so that SkTSwap can later be removed in a smaller CL. After that
the <utility> include can be removed from SkTypes.h.

Change-Id: If03d4ee07dbecda961aa9f0dc34d171ef5168753
Reviewed-on: https://skia-review.googlesource.com/135578
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2018-06-19 02:06:31 +00:00
Florin Malita
94d4d3e20b [skottie] Fix OOB access in Parse<SkPoint>
SkJSON requires valid array indices, so callers must guard against
out-of-bounds conditions explicitly.

Bug: oss-fuzz:8956
Change-Id: I50b96b088e44a4c1a569e6911d4be5d75799b464
Reviewed-on: https://skia-review.googlesource.com/135445
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2018-06-18 17:33:18 +00:00
Florin Malita
0052a31868 [skjson] Detect end-of-input for unbalanced strings
We currently blow through string chars without checking for end-of-input.

Maybe we could avoid this upfront, when we locate the stop char: try to
determine if it's part of an unterminated string, fail immediately if
so.  Figuring out if the tail is an unterminated string seems
intractable though (requires arbitrarily deep tail parsing).

That brings us to plan B:

  * treat scope-closing tokens (} & ]) as string terminators
    (we know end-of-input points to one of these for sure)

  * adjust matchString() to check for end-of-input

Bug: oss-fuzz:8899
Change-Id: Ic0a88a405548e8724b76faca525099a7e7037341
Reviewed-on: https://skia-review.googlesource.com/135145
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
2018-06-15 21:04:35 +00:00
Florin Malita
587f5a9a30 [skjson] Catch end-of-stream for unbalanced scopes
The input is not guaranteed to contain well-formed scopes, so it's not
sufficient to check for end-of-stream only when popping the top-level
scope -- we have to check on every scope pop.

Bug: oss-fuzz:8898
Change-Id: I7399a8872187ec6714672cac2ff8fc7fbf3c2dfe
Reviewed-on: https://skia-review.googlesource.com/135059
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-06-15 13:56:44 +00:00