Commit Graph

257 Commits

Author SHA1 Message Date
Florin Malita
96b95f911c [skottie] Initial animated text properties support
Limitations:

  - no range selectors (applies to the whole text)
  - only position, fill color and stroke color for now

Change-Id: I91e88a6107c5f66687c1c27f27a71be3914bde25
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217386
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Ben Wagner <bungeman@google.com>
2019-05-31 18:41:13 +00:00
Florin Malita
1e8f6e2372 [skottie] Add kBottom text alignment extension
Introduce a new Shaper::Valign enum to support aligning the shaped text
visual bottom with the text box bottom.

This option corresponds to JSON prop sk_vj: 2.

kResizeToFit (used to be sk_vj: 2) is now bumped to sk_vj: 3.

Change-Id: Ib1621a21a42bfc21c99826e203c587a3fdc663dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/215821
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-05-24 15:28:01 +00:00
Brian Salomon
201700fa86 Initial version of rescaling async readback API
This is implemented at backend-neutral level and so misses some
opportunities to reduce the number of passes in the GPU backend.

Filter quality is interpreted as:
none - single nearest neighbor resampling
low - chain of bilinear resamplings. 2x up/down except for one
step which may be smaller than 2x.
medium - same as low
high - when both scale factors are up then same as low but with bicubic
filtering rather than linear. Otherwise, same as low.

Bug: skia:8962

Change-Id: I4467636c14b802d6a0d9b5c363c1ad9e87a1a44b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/213831
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
2019-05-17 16:39:10 +00:00
Brian Osman
4c63a1eada Particles + Interpreter: Bind particle's SkRandom to "rand"
Update sample effects to use that (and remove the need for the
hacky workaround "random -> frame" affector I was using).

Current perf on my workstation, 6k particles updating:
native: 0.67 ms
interp: 0.97 ms

Change-Id: I3a2168c210d7431ffffe2b87ab6adade69f1dce7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214190
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-05-17 14:29:22 +00:00
Brian Osman
c04cadbb6e Prototype interpreter particle affector
Change-Id: Ib440570ecbd46b5bc98d346592cbbb72f58ae85a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212500
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2019-05-09 18:37:46 +00:00
Florin Malita
4f6eb15178 [skottie] Add resize-to-fit text alignment extension
Introduce a new SkottieShaper VAlign option (kResizeToFit), to scale the text
size for the best box fit.

The basic idea is to perform a binary search on the font size, until
the shaped text fits snuggly within the specified box.  The search is
focused on height, as horizontal fitting is assumed to be handled in
SkShaper.

Change-Id: I56269e02dda7a34e4ef3b79c205ea651b909f370
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212962
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-05-09 16:03:39 +00:00
Florin Malita
a50484a570 [skottie] Text line height support
Change-Id: Id5b52e7586aa42400162fd227add28d6ebf3ac11
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212728
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2019-05-08 19:27:52 +00:00
Hal Canary
56947a7fa3 Shaper Tests: make a macro, rename test resources.
Change-Id: Ic7bfd4784d9b2031fdcbf57e730b8c738b9ac9d3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211990
Auto-Submit: Hal Canary <halcanary@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2019-05-03 17:16:36 +00:00
Florin Malita
8b7768d206 [skottie] Relocate "GMs" to resources/
... to make them available on test bots.

TBR=mtklein@google.com

Change-Id: I107a042fbd20c673e964273291ce8c060c522a59
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/211991
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-05-03 16:14:46 +00:00
Ben Wagner
8dce054179 Add planet emoji font.
This allows for testing falling into various buckets in the gpu
fallbacks.

Change-Id: Ia0c319a6bdd03c5cdece1ce83ab228c1a3a7c46d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/199420
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2019-03-19 17:49:22 +00:00
Hal Canary
8751512aaa Revert "Revert "Compile all fiddle examples locally""
This reverts commit 37575bf3ca.

Change-Id: Ia31abbd4906ddeed406f3da1128bc4d4177abf24
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201603
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-03-16 00:48:09 +00:00
Hal Canary
37575bf3ca Revert "Compile all fiddle examples locally"
This reverts commit 83c2f70b51.

Reason for revert: broke some builders

Original change's description:
> Compile all fiddle examples locally
> [......]
> 
> Change-Id: I14a31348a9ccaaa31f65424b91e3a3533d2583a7
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198824
> Commit-Queue: Hal Canary <halcanary@google.com>
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Joe Gregorio <jcgregorio@google.com>

TBR=hcm@google.com,halcanary@google.com,bungeman@google.com,jcgregorio@google.com,scroggo@google.com

Change-Id: I8a6aa444d7f62aa73565ca4a7393e050872b6ecc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201600
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-03-15 17:39:01 +00:00
Hal Canary
83c2f70b51 Compile all fiddle examples locally
Motivation: it would be a good idea if the API documentation examples
were checked into the skia repository, so we could make sure they
compile as part of the commit queue.

Fiddle would make/update a named fiddle each time it gets a new
commit of Skia, extracted from the code in the examples/ directory.
The docs would point at those named fiddles.  Named fiddles have urls
in the form:

    https://fiddle.skia.org/c/@Bitmap_000

Then we would stick a link to the example into the header documentation
like this:

    /** Allocates the pixel memory for the bitmap, given its dimensions
        and SkColorType. Returns true on success, where success means
        either setPixels() or setPixelRef() was called.

        @param bitmap  SkBitmap containing SkImageInfo as input, and
                       SkPixelRef as output
        @return        true if SkPixelRef was allocated

        @example       https://fiddle.skia.org/c/@Bitmap_000
    */
    bool allocPixelRef(SkBitmap* bitmap) override;

There are still around 200 disabled examples that need to be fixed
(these result from API changes since the author left).

Change-Id: I14a31348a9ccaaa31f65424b91e3a3533d2583a7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/198824
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2019-03-15 15:19:18 +00:00
Kevin Lubick
966348413f [particles] Clean up build - remove test deps
Bug: skia:
Change-Id: I499262277ac1c8d92a39a66f6e846e248b102aef
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/197767
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
2019-03-05 20:44:10 +00:00
Brian Osman
bdcdf1a7c3 Add SkParticleValue to allow further customization of curve behavior
All curves (and path affectors) are driven by an SkParticleValue. The
value can derive its value from the current defaults (age of particle
or effect), or explicitly choose the other one, a random value, or any
other particle value. Values can be range adjusted and support repeat,
clamp, and mirror tiling.

Also fixed some more issues related to resource path in the slide GUI.

Bug: skia:
Change-Id: I4755018d5b57ae2d5ec400d541055ca4fb542978
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/196760
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-03-04 22:04:17 +00:00
Brian Osman
3d76d1bf46 Particles: Removed emitters, added more full-featured position affectors
Bug: skia:
Change-Id: Ie6485a11bb57fecef470d727dcf3b4fe5dff0b90
Reviewed-on: https://skia-review.googlesource.com/c/195582
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-02-28 21:16:02 +00:00
Brian Osman
34d1331323 Particles: Improvements to SkCurve
Added explicit Linear segment type, merge math evaluation helpers for
scalar and color curves. Add logic to visitFields that cuts down on the
serialized size of simple curves, and makes the GUI easier to work with.

Remove the curve plot from the GUI. It was incorrect (wrong points at
cubic handle locations), not terribly helpful, and difficult to
maintain.

Bug: skia:
Change-Id: I190cb5d118b1f4b910984e4df50ee3351c8be895
Reviewed-on: https://skia-review.googlesource.com/c/195884
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-02-27 16:46:29 +00:00
Brian Osman
e5d532edae Particles: remove non-stable random, add better enum reflection
The other generator was never used (or useful). String-based serialization
of enums is quite helpful, though.

Bug: skia:
Change-Id: Ic9d58f8d20cfe7aba47722bd74f1e6f8f0f219e5
Reviewed-on: https://skia-review.googlesource.com/c/195368
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-02-26 20:29:56 +00:00
Brian Osman
0c48681e58 Few more particle features and some generalization work
Add particle "frame" enum, to allow effects relative to local, world,
or velocity. Remove the "orient along velocity" and replace with a much
more general orientation affector (angle curve + frame). Add an angular
velocity affector to mirror the behavior of the linear velocity affector.

Bug: skia:
Change-Id: Ibbaaeb352c9547d00d81c7916d00148dd65ed2b9
Reviewed-on: https://skia-review.googlesource.com/c/195361
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-02-26 15:56:24 +00:00
Brian Osman
d5c57fe289 Add local vs world flag for particle velocity
Adjust reference frame for affector to be consistent (so angles are
counted clockwise from "up" in both local and world modes).

Bug: skia:
Change-Id: I643e1484bc0a58d1f1c0cfe35ac2ab37dc2ea409
Reviewed-on: https://skia-review.googlesource.com/c/194189
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-02-22 17:45:25 +00:00
Brian Osman
d8e1ee9a66 Refactor particle age logic
Move to a model that only needs floats, and puts the age in the
SkParticleState struct. Add a better test case for spawn affector
animation, to verify that things are still working.

Bug: skia:
Change-Id: I97d99de5f5d4cb302b76116e67ecc93368fb1677
Reviewed-on: https://skia-review.googlesource.com/c/193580
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-02-20 19:55:20 +00:00
Brian Osman
125daa4d1a Refactor and further generalization of particle model
- Collapsed the per-particle data into a single struct, and
  use that to communicate with drawables, too. Let the drawables
  manage allocation of xforms, colors, etc. Helpful for non-atlas
  drawables, and just to keep the effect code simpler.
- Having all of the params in a single struct allows us to move
  the remaining animated behaviors into affectors (color/frame).
- Added SkColorCurve, which works like SkCurve for SkColor4f.
  Use that to create a color affector (rather than simple
  start/end colors in the effect params).
- Also put the stable random in SkParticleState. This is going
  to be necessary if/when we change affectors to operate on all
  particles (rather than one at a time). Still need to move t
  value into the particle struct (or eval it from the lifetime
  params on demand).

Change-Id: Icf39116acbfd5d6e8eb91e9affbd8898d106211d
Reviewed-on: https://skia-review.googlesource.com/c/193473
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-02-20 18:01:00 +00:00
Brian Osman
543d2e2f2e Moved image params out to SkParticleDrawable
Added a simpler circle drawable, moved drawing code out so that frame
calculation is handled by the drawable. Fixed all the sample effects,
including some size adjustments to better create the intended effect.

Bug: skia:
Change-Id: I60af9cd6262ff98352ca8ceaf6768aef9c7e164c
Reviewed-on: https://skia-review.googlesource.com/c/193029
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-02-15 20:07:43 +00:00
Brian Osman
8b6283fc98 New SkCurve type with multiple curve segments
- Converted all linear force stuff into a single affector,
  used at either spawn or update time appropriately.
  The new affector can either set or adjust velocity.
- Converted lifetime to a curve.
- Removed SkRangedFloat, initial velocity params, etc.

Looks like a large addition, but that's mostly down to the
JSON getting bigger. There's a net reduction in LoC.

Bug: skia:
Change-Id: Iac7417f15f96d0313efd08c4b26dc3250b80fa77
Reviewed-on: https://skia-review.googlesource.com/c/192102
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-02-15 14:10:39 +00:00
Brian Osman
5c1f8eb094 Various particle system improvements
Effects now have a duration, and can be played looped
or one-shot. Added a second list of affectors that are
applied at spawn vs. update.

Effects grab and store the SkRandom at construction,
so it no longer needs to be passed to update().

Bug: skia:
Change-Id: Ib54d60466e162e4d4b70fa64c1215fc01680d47a
Reviewed-on: https://skia-review.googlesource.com/c/191722
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2019-02-14 20:19:08 +00:00
Hal Canary
8130afa1c2 resources: add text for testing shaper
No-Try: true
Change-Id: I84559846fd22a877c689b51b934386073c3121a0
Reviewed-on: https://skia-review.googlesource.com/c/192425
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-02-14 16:15:05 +00:00
Brian Osman
7c979f52c3 Experimental Particle System
This adds a new "Particles" slide to viewer, that allows
editing, loading, and saving particle effects. All of the
particle system code is in modules/particles.

There are many rough edges and some not-yet-finished changes
to generalize the model[1]. A rough overview:

- SkReflected.h implements a lightweight reflection system
  for classes derived from SkReflected. Adding a new class
  involves deriving from SkReflected, adding a macro to the
  class declaration, and implementing visitFields(), which
  simply calls a virtual on an SkFieldVisitor for each field.
  Currently, emitters and affectors use this mechanism.

- SkParticleSerialization.h demonstrates two useful field
  visitors - for serializing to and from JSON. The driver
  code that uses those is directly in ParticlesSlide.

- SkParticleData.h and SkCurve.h define a variety of helper
  types for talking about particles, both for parameterizing
  individual values, and communicating about the state of a
  particle among the effect, affectors, and emitters.

- SkParticleEffect.h defines the static data definition of
  an effect (SkParticleEffectParams), as well as a running
  instance of an effect (SkParticleEffect). The effect has
  simple update() and draw() methods.

- ParticlesSlide.cpp adds a third field visitor to generate
  GUIs for interactively editing the running effect.

---

1: The critical change I'd like to make is to remove all
special case behavior over time and at spawn (setting sprite
frames, size over time, color over time, etc...). Integration
is the only fixed function behavior. Everything else is driven
by two lists of affectors. One is applied at spawn time, using
the effect's lifetime to evaluate curves. This allows spawning
particles with different colors as the effect ages out, for
example. The second list is applied every frame to update
existing particles, and is driven by the particle's lifetime.
This allows particles to change color after being spawned, for
example.

With a small set of affectors using a single expressive curve
primitive (keyframed list of cubic curve segments), we can
have affectors that update color, size, velocity, position,
sprite frame, etc., and implement many complex behaviors.

Bug: skia:
Change-Id: Id9402bef22825d55d021c5a2f9e5e41791aabaf4
Reviewed-on: https://skia-review.googlesource.com/c/181404
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2019-02-12 18:53:41 +00:00
Florin Malita
8ac81b7fb5 [skottie] Add a custom property manager util class
To facilitate demo code consolidation, introduce a custom property
manager which filters for node names starting with '$' and treats all
properties sharing the same name unitarily.

Update the Colorize GM to use this new helper.

Also revisit the PropertyObserver interface:

 * aliases for client-facing value types
 * introduce a new (decomposed) TransformPropertyValue, to replace component-wise setters
 * consolidate the PropertyHandle interface to only expose get()/set()

Bug: skia:
Change-Id: I9aa9ee80c1fb57bbfbacab0fc3f017da909b24d9
Reviewed-on: https://skia-review.googlesource.com/c/173220
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-11-28 17:12:07 +00:00
Ben Wagner
9f0d8c24c8 Add support for fallbackFor in Android parser.
Change-Id: Id328c67b6ad5d76584030f480316425f25979ebf
Reviewed-on: https://skia-review.googlesource.com/c/171644
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2018-11-27 20:20:38 +00:00
Leon Scroggins III
f05626bf96 Test a GIF with an out of range transparent index
Bug: skia:8461

According to skbug.com/7069, we should allow GIFs to use a transparent
index outside of the range of the color table. Add a test to verify
support for this.

The GIF is 2x2 with the following pixels:
-------------------------------------------------
|   black            |          white           |
-------------------------------------------------
|   transparent      |      transparent         |
-------------------------------------------------

The color table only has 2 entries (black and white), and the
transparent index is 2.

Change-Id: I16574a61e2982b6628c3eca96cb7b3e1f57d3b2a
Reviewed-on: https://skia-review.googlesource.com/c/161561
Reviewed-by: Nigel Tao <nigeltao@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
Auto-Submit: Leon Scroggins <scroggo@google.com>
2018-10-12 14:20:02 +00:00
Florin Malita
62c6bd910a [skottie] Multi-frame image support
Extend the image asset provider API to support animated/multi-frame images.

Add a GM based on SkAnimCodecPlayer + animated public domain GIF
(source: https://giphy.com/explore/public-domain).

Bug: skia:
Change-Id: Iaa596e01a7626ca6574db1ebc90632f5a9a02bdc
Reviewed-on: https://skia-review.googlesource.com/159162
Commit-Queue: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
2018-10-03 19:02:35 +00:00
Florin Malita
17282da3aa [skottie] Add a property setter sample/GM
skottie_colorize: press 'c' to cycle through stroke/fill colors.
Change-Id: I7fa9dcd67822df37e97cafabe088c4b9ded9c622
TBR=
Reviewed-on: https://skia-review.googlesource.com/156882
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-09-26 16:43:49 +00:00
Florin Malita
268707284d [skottie] GM exercising external font loading
Sets up a fake web font loader which serves a local/resource font to
the sample text animation.

Also rename resources/skotty/skotty_* -> resources/skottie/skottie_*.

Change-Id: I4af5b24fc3cc5c63c78801979f9be56744047134
Reviewed-on: https://skia-review.googlesource.com/155881
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-09-20 19:05:35 +00:00
Leon Scroggins III
36f7e3298e Reland "Switch SkCodec to use skcms plus fixes""
This reverts commit 83988edfd3.

The CTS failure was actually due to another CL.

TBR=brianosman@google.com
TBR=djsollen@google.com

Bug: skia:6839
Bug: skia:8052
Bug: skia:8278
Change-Id: Id9f152ec2c66467d90f49df223cb9b7c168ac2ac
Reviewed-on: https://skia-review.googlesource.com/149483
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-08-27 16:16:14 +00:00
Leon Scroggins
83988edfd3 Revert "Reland "Switch SkCodec to use skcms" plus fixes"
This reverts commit 49894f450f.

Reason for revert: Breaking a CTS test on the Android roll:

java.lang.AssertionError: expected:<67043583> but was:<50266367>
	at org.junit.Assert.fail(Assert.java:88)
	at org.junit.Assert.failNotEquals(Assert.java:834)
	at org.junit.Assert.assertEquals(Assert.java:645)
	at org.junit.Assert.assertEquals(Assert.java:631)
	at android.graphics.cts.BitmapColorSpaceTest.verifyGetPixel(BitmapColorSpaceTest.java:301)
	at android.graphics.cts.BitmapColorSpaceTest.inColorSpaceP3ToSRGB(BitmapColorSpaceTest.java:612)

Expected: 3FF00FF Actual: 2FF00FF

Original change's description:
> Reland "Switch SkCodec to use skcms" plus fixes
> 
> This reverts commit 33d5394d08,
> relanding 81886e8f94 as well as
> "Fix CMYK handling in JPEG codec" (commit
> f8ae5ce20c)
> 
> Add a test based on the CTS test that failed in the original commit.
> purple-displayprofile.png is the image used in the CTS test, with the
> Android license.
> 
> This also adds a fix for SkAndroidCodec, ensuring that we continue to
> use a wide gamut SkColorSpace for images that do not have a numerical
> transfer function and have a wide gamut. This includes a test, with
> wide-gamut.png, which was created with Photoshop and the profile
> "sRGB_Calibrated_Homogeneous.icc" from the skcms tree.
> 
> Bug: skia:6839
> Bug: skia:8052
> Bug: skia:8278
> 
> TBR=djsollen@google.com
> As with the original, no API change
> 
> Change-Id: I4e5bba6a3151f9dc6491e8eda73d4de0535bd692
> Reviewed-on: https://skia-review.googlesource.com/149043
> Commit-Queue: Leon Scroggins <scroggo@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
> Reviewed-by: Leon Scroggins <scroggo@google.com>

TBR=djsollen@google.com,mtklein@google.com,scroggo@google.com,brianosman@google.com

Change-Id: Ie71e1fecc26de8225d2fe603765c1e1e0d738634
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:6839, skia:8052, skia:8278
Reviewed-on: https://skia-review.googlesource.com/149262
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-08-24 21:41:37 +00:00
Leon Scroggins III
49894f450f Reland "Switch SkCodec to use skcms" plus fixes
This reverts commit 33d5394d08,
relanding 81886e8f94 as well as
"Fix CMYK handling in JPEG codec" (commit
f8ae5ce20c)

Add a test based on the CTS test that failed in the original commit.
purple-displayprofile.png is the image used in the CTS test, with the
Android license.

This also adds a fix for SkAndroidCodec, ensuring that we continue to
use a wide gamut SkColorSpace for images that do not have a numerical
transfer function and have a wide gamut. This includes a test, with
wide-gamut.png, which was created with Photoshop and the profile
"sRGB_Calibrated_Homogeneous.icc" from the skcms tree.

Bug: skia:6839
Bug: skia:8052
Bug: skia:8278

TBR=djsollen@google.com
As with the original, no API change

Change-Id: I4e5bba6a3151f9dc6491e8eda73d4de0535bd692
Reviewed-on: https://skia-review.googlesource.com/149043
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2018-08-24 17:46:25 +00:00
Leon Scroggins III
33d5394d08 Revert "Switch SkCodec to use skcms" and follow on change
This reverts commit 81886e8f94 and
f8ae5ce20c
("Fix CMYK handling in JPEG codec")

This fixes the Android build, which was failing a CTS test with this
change.

Bug: skia:6839
Bug: skia:8052

TBR=djsollen@google.com
As with the original, no API change

Change-Id: Ic744a610e9f431707f871de44f9f64040bc60d14
Reviewed-on: https://skia-review.googlesource.com/148810
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-08-22 21:13:50 +00:00
Leon Scroggins III
81886e8f94 Switch SkCodec to use skcms
Bug: skia:6839
Bug: skia:8052

Create an skcms_Profile instead of an SkColorSpace when creating an
SkCodec. Eventually we'll move the SkImageInfo (and its SkColorSpace)
entirely to clients (e.g. SkAndroidCodec, SkCodecImageGenerator), but
for now, create it with SkEncodedInfo::makeImageInfo.

Create new SkEncodedInfo::Colors for the special PNG cases that we
want to map to specific SkColorTypes.

SkEncodedInfo:
- Add ICCProfile, which owns an skcms_ICCProfile
 - FIXME: maybe we should have a single instance for
  SRGB like SkColorSpace?
- Add kXAlpha_Color, for kAlpha_8. Since I'm not longer creating
  an SkImageInfo (at least in SkPngCodec), it needs a way to pass
  this info to the caller.
- Add k565_Color, for the same reason. Matt originally had this in
  https://codereview.chromium.org/2212563003/#ps120001, but didn't
  land that version. I like it though. Mike didn't like the bits
  per component for 565, but it seems like a sensible hack, much
  like the existing one for kAlpha_8
- Add width and height. These were removed for redundancy with
  SkImageInfo, but it makes sense to have them here without it.
BUILD.gn:
- Build the new SkEncodedInfo.cpp
SkCodec:
- Remove the constructor with an SkImageInfo. Edit the other one
  to drop width and height (now in SkEncodedInfo) and take a RHS
  reference to SkEncodedInfo
- Create the SkImageInfo from fEncodedInfo (for now)
- Consolidate choosing skcms_AlphaFormat for Transform here
- Call conversionSupported from initializeColorXform, with a new
  parameter for whether there is a color Xform, allowing SkJpegCodec
  and SkHeifCodec to override that method instead of having another
  method.
SkBmpCodec (etc)
- Adapt to the changes above
- Create a new SkEncodedInfo w/o profile for the swizzler.
SkPngCodec:
- use the new SkEncodedInfo::Colors rather than a custom SkImageInfo
SkRawCodec:
- Remove SkEncodedInfo from SkDngImage, which doesn't actually need it.
  This is helpful since we don't know all the info yet.
- Rewrite gAdobeRGB_toXYZD50 as an skcms_Matrix3x3
SkWebpCodec:
- Remove premul_step computation, and simplify to just rely on
  the base class' handling of applying the transform.
SkSwizzler:
- Add cases for the new SkEncodedInfo::Colors

TBR=reed@google.com
No public API changes. Only private/public members of SkCodec.h are
modified.

Change-Id: Ic0d3bb752b03f13be886b80331987aa5a5713fc0
Reviewed-on: https://skia-review.googlesource.com/136062
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2018-08-22 18:16:20 +00:00
Brian Osman
ccb21bffeb Add sRGB profile to mandrill images
Bug: skia:
Change-Id: Ic0e0ae23c88f86885583a304d90d1ce874ff14ed
Reviewed-on: https://skia-review.googlesource.com/139960
Auto-Submit: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2018-07-09 23:02:39 +00:00
Brian Osman
bbf80d6e1e Update mandrill PNGs to be sRGB (rather than gamma 2.2)
This eliminates many GM diffs between gl and glsrgb.

Bug: skia:
Change-Id: Ia35ae9db3f9dba03c227f82d2ad7ab602100d2e9
Reviewed-on: https://skia-review.googlesource.com/139861
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
2018-07-09 17:56:17 +00:00
Ruiqi Mao
f510149da8 skeletal animation support added to API and software backend
SkCanvas::drawVertices now supports overloads that take an array of bone deformation matrices.
SkVertices::MakeCopy and SkVertices::Builder now support two additional optional attributes, boneIndices and boneWeights.

Bug: skia:
Change-Id: I30a3b11691e7cdb13924907cc1401ff86d127aea
Reviewed-on: https://skia-review.googlesource.com/137221
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Ruiqi Mao <ruiqimao@google.com>
2018-06-29 19:34:28 +00:00
Leon Scroggins III
665949a3ec Update libjpeg-turbo to pre-2.0.0 (from 1.5.3)
jpeg_skip_scanlines was incorrectly incrementing an internal counter,
resulting in an infinite loop. (This only occurs for certain types of
progressive images, using certain sample sizes.)

The fix is at 26f109290d.
This is included in tip-of-tree, which is unofficially 2.0.0, so go ahead and
update to it.

Add a test based on the original bug.

Bug: b/78329453
Change-Id: I5ade9924812324d58668c26f71cd622ef93f40a7
Reviewed-on: https://skia-review.googlesource.com/129459
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2018-06-26 15:22:12 +00:00
Ruiqi Mao
9ac1b729f1 fixed NIMA deformed vertices rendering
Bug: skia:
Change-Id: I43c1a86eead7701db052451c446f9ad59467f909
Reviewed-on: https://skia-review.googlesource.com/136610
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ruiqi Mao <ruiqimao@google.com>
2018-06-21 17:40:17 +00:00
Brian Osman
c069a57301 added NIMA sample to showcase animations
improved third_party template to include headers as system headers for non-Windows machines

Bug: skia:
Change-Id: Id2fa74fc31b49f9b07cc83e7f60477c7ab4f8d83
Reviewed-on: https://skia-review.googlesource.com/135450
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2018-06-19 20:30:28 +00:00
Mike Klein
8fcfcc5686 update ColorSpaceTest.cpp to remove MakeICC
The upperLeft and upperRight profiles are A2B/B2A-only, and so cannot be
represented as SkColorSpace using SkColorSpace::Make(skcms_ICCProfile).
They do parse fine, of course.

Change-Id: Iaf51911c2b06b985037d3d5e74b043fb344e320e
Reviewed-on: https://skia-review.googlesource.com/129653
Commit-Queue: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
2018-05-23 17:11:11 +00:00
Ben Wagner
d6de89bebd Update SampleLua and lua files.
The lua files were moved at one point without the internal path
references being updated. This updates them so that the SampleLua slides
can be seen in their full glory.

Change-Id: I4dd09c847be48d80fa61d3b9864d34a4aa9bb2f5
Reviewed-on: https://skia-review.googlesource.com/129515
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2018-05-22 15:51:25 +00:00
Ben Wagner
97182cc8f6 Add color fonts.
BUG=skia:7624

Change-Id: I68a6bb4c6fa541ffad565d970438d93ff1bd8ed6
Reviewed-on: https://skia-review.googlesource.com/109521
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-on: https://skia-review.googlesource.com/116541
Reviewed-on: https://skia-review.googlesource.com/116984
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-03-28 20:14:44 +00:00
Ben Wagner
3560b58de3 Revert "Add color fonts."
This reverts commit d3b933f3e0.

Reason for revert: we're not mirroring experimental/ everywhere.

Original change's description:
> Add color fonts.
> 
> BUG=skia:7624
> 
> Change-Id: I1d0974282adce2fd7b13a003309e63593b6e1a9c
> Reviewed-on: https://skia-review.googlesource.com/109521
> Commit-Queue: Ben Wagner <bungeman@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>
> Reviewed-by: Herb Derby <herb@google.com>
> Reviewed-on: https://skia-review.googlesource.com/116541

TBR=mtklein@google.com,bungeman@google.com,herb@google.com

Change-Id: Ic2d763244cbce663a23eb53321ac45201c466501
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7624
Reviewed-on: https://skia-review.googlesource.com/116680
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2018-03-27 18:16:04 +00:00
Ben Wagner
d3b933f3e0 Add color fonts.
BUG=skia:7624

Change-Id: I1d0974282adce2fd7b13a003309e63593b6e1a9c
Reviewed-on: https://skia-review.googlesource.com/109521
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-on: https://skia-review.googlesource.com/116541
2018-03-27 16:49:14 +00:00
Jim Van Verth
af78a94217 Revert "Add color fonts."
This reverts commit c912d6133c.

Reason for revert: Causing TSAN issues.

Original change's description:
> Add color fonts.
> 
> BUG=skia:7624
> 
> Change-Id: Id2b7449048591892ff802484d5e3745a7e1402bb
> Reviewed-on: https://skia-review.googlesource.com/109521
> Commit-Queue: Ben Wagner <bungeman@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>
> Reviewed-by: Herb Derby <herb@google.com>

TBR=mtklein@google.com,bungeman@google.com,herb@google.com

Change-Id: I2ccd1f00e91bb92b7059323c95da0dd3de954164
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7624
Reviewed-on: https://skia-review.googlesource.com/116141
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2018-03-23 14:39:51 +00:00
Ben Wagner
c912d6133c Add color fonts.
BUG=skia:7624

Change-Id: Id2b7449048591892ff802484d5e3745a7e1402bb
Reviewed-on: https://skia-review.googlesource.com/109521
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2018-03-22 20:55:05 +00:00
Ben Wagner
03cd6e6dec Avoid serializing to 'typ1' on Mac.
CoreGraphics does not provide a means to get the original font data for a
CGFont, only the tables. As a result, Skia pieces the font data back
together when requested. The most awkward part of this is choosing the
first four bytes, and the CTFont suggestion seems to often be wrong.

This change doublechecks the selection of 'typ1', prefering to use 'OTTO'
if there are no 'TYP1' or 'CID ' tables. These sorts of fonts are
extremely old and unlikely to be in current use. It appears that CTFont
may report that it has this format if it is an 'OTTO' font with very few
glyphs. If Skia serializes such a font with 'typ1' as the first four
bytes, CoreGraphics will not create a CGFont from the resulting font data.

BUG=chromium:809763,skia:7630

Change-Id: I9979b9f0ebdd27c4ad0903e8ee6237241e755541
Reviewed-on: https://skia-review.googlesource.com/113306
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2018-03-09 15:03:20 +00:00
Leon Scroggins III
9e8a594905 Support pngs with incorrect CMF bytes
Bug: chromium:807324

Though these pngs are technically incorrect, many such PNGs exist, and
they are supported in Chromium. Ensure that users of SkCodec (e.g.
Android, Flutter) display them as well.

Change-Id: I2f1e573b4b7039cea81f96397cc0aa4cbc9461c3
Reviewed-on: https://skia-review.googlesource.com/111082
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
2018-02-28 21:46:03 +00:00
Florin Malita
1022f74375 [skottie] Nested animation support
Extend composition layers to support referencing external .json
animations ("$"<PATH> syntax).

This is a custom extension (not supported in BM/Lottie).

Also make skottie::Animation ref-counted, to facilitate sharing.

TBR=

Change-Id: I062d031e5868d759f3930dea9b261f9b3ec81684
Reviewed-on: https://skia-review.googlesource.com/109806
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2018-02-23 19:15:26 +00:00
Leon Scroggins III
31476b7c94 Update piex and add test image
Bug: oss-fuzz:6347

Change-Id: Iacf8c7a1677f2651e5c211cffb09eecb388a5f8a
Reviewed-on: https://skia-review.googlesource.com/109400
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-02-22 21:32:48 +00:00
Leon Scroggins III
cbf66a2213 Ensure all rows of a gif are initialized
Bug: oss-fuzz:6274

Even if a frame does not have enough LZW blocks to decode all rows,
(which is unknown until we actually decode them), it is marked complete
once there are no more LZW blocks.

When decoding, even if we've decoded all LZW blocks, check fRowsDecoded
to determine whether we've actually all the rows. Report the number of
rows decoded so that SkCodec can fill in the remaining ones.

Change-Id: I1d6e0c29e3c37649725836cf24a4a239e3266b76
Reviewed-on: https://skia-review.googlesource.com/106964
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
2018-02-16 17:26:56 +00:00
Leon Scroggins III
ce6d93a815 Check for min int in BMP header
Bug: os-fuzz:6288

Negating it is undefined, so don't try.

Change-Id: I055520b8036dd8b355e744114717e08d76206bc1
Reviewed-on: https://skia-review.googlesource.com/107062
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-02-15 15:36:19 +00:00
Leon Scroggins III
fee7cbaf44 Check the length of marker before reading it
Bug: os-fuzz:6295
Change-Id: I0ea9a3c54d61d41f21f2e9b945ab83fa2beb00d8
Reviewed-on: https://skia-review.googlesource.com/107025
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-02-13 22:05:53 +00:00
Leon Scroggins III
da3e9ad894 Make SkAndroidCodec (optionally) respect origin
Bug: b/63909536

ImageDecoder will respect the origin, but BitmapFactory will maintain
its current behavior of not respecting it. Add an option to respect it.

In addition, add support for reading the EXIF data from a WEBP. This
seems to be an uncommon use case, but is occasionally used when
converting from a JPEG. Add 8 WEBPs, all converted (with cwebp) from
their analogous JPEG files already checked in.

Change-Id: I38afca58c86fa99ee9ab7d1dc83aaa4f23132c11
Reviewed-on: https://skia-review.googlesource.com/95300
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-01-26 22:13:34 +00:00
Leon Scroggins III
2e0fadb06c Add a GM and images to test SkEncodedOrigin
Bug: skia:7138
Change-Id: I4800bcffc6a397cb688e63a505dd36145e423fa2
Reviewed-on: https://skia-review.googlesource.com/95083
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2018-01-17 16:14:16 +00:00
Florin Malita
e8750e1078 [skotty] Fix path close handling
... and add a transform animation sample

TBR=
Change-Id: I27a67d7861dffb9ca22a5e7155ee0eba3b4575f6
Reviewed-on: https://skia-review.googlesource.com/90023
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2017-12-31 00:07:39 +00:00
Florin Malita
094ccde238 Initial Lottie loader impl (Skotty)
Coarse workflow:

* Construction

  1) build a Json tree
  2) collect asset IDs (for preComp/image layer resolution)
  3) "attach" pass
     - traverse the Json tree
     - build an SkSG dom, one fragment at a time
     - attach "animator" objects to the dom, for each animated prop
  4) done, we can throw away the Json tree

* For each animation tick

  1) iterate over active animators and poke their respective dom nodes/attributes
  2) revalidate the SkSG dom
  3) draw the SkSG dom

Note: post construction, things are super-simple - we just poke SkSG DOM attributes
with interpolated values, and everything else is handled by SkSG (invalidation,
revalidation, render).

Change-Id: I96a02be7eb4fb4cb3831f59bf2b3908ea190c0dd
Reviewed-on: https://skia-review.googlesource.com/89420
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
2017-12-30 22:55:39 +00:00
Brian Osman
a12f795f4a Fix Adobe RGB color space in Skia
Our runtime definition of the XYZ matrix was fairly inaccurate. It also
didn't round-trip through ICC fixed point correctly. Now, constructing the
color space at runtime produces exactly the same matrix as constructing
the space from the ICC profile. And the values can then be serialized back
to ICC exactly. This eliminates the need for the snapping logic, too.

Bug: skia:
Change-Id: I69f4a9bfec3eeef153935e21ab3a0630794b1607
Reviewed-on: https://skia-review.googlesource.com/84840
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-12-20 14:09:34 +00:00
Hal Canary
c465d13e6f resources: orgainize directory.
Should make it easier to ask just for images.

Change-Id: If821743dc924c4bfbc6b2b2d29b14affde7b3afd
Reviewed-on: https://skia-review.googlesource.com/82684
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2017-12-08 17:16:00 +00:00
Ben Wagner
f1729a7937 Extract Android FontMgr part of Typeface test.
Part of the Typeface test is Android specific and tests that the Android
legacyMakeTypeface returns nullptr when called with a non-null family
name and there is no match. A new FontMgrAndroidLegacyMakeTypeface test
is introduced to test this and also properly test creating one with
SkFontMgr_Android_CustomFonts.

Change-Id: Iceb8b9b5490f5eeeaeac30a68daf2c4daac53c86
Reviewed-on: https://skia-review.googlesource.com/70660
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Ben Wagner <bungeman@google.com>
2017-11-13 17:00:31 +00:00
Leon Scroggins III
4cdbf6056d Avoid uninitialized memory in readByteArrayAsData
Bug: 769134

readByteArray can fail (due to not having enough available or due to the
wrong alignment). If it does, do not return an uninitialized block of
memory.

Further, drop the initial size check, which is covered by readByteArray.

Add a test.

Change-Id: Ia101697c5bb1ca3ae3df1795f37a74b2f602797d
Reviewed-on: https://skia-review.googlesource.com/52742
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2017-09-28 19:51:32 +00:00
Jim Van Verth
712fe73caf Add animated cowboy sample from WebKit tests, and fix.
Bug: chromium:712455
Change-Id: Ic9bb9b862abe01f112cc41d28589733460b15bc1
Reviewed-on: https://skia-review.googlesource.com/50181
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-09-25 21:14:09 +00:00
Ben Wagner
aee878d767 Move lang to list in Android font manager.
Change-Id: Ia4af2769f4761e6b444ed0c232c48199872f3acc
Reviewed-on: https://skia-review.googlesource.com/33480
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2017-08-14 19:29:05 +00:00
Ben Wagner
c6c10b4518 Remove SkTypeface::Style from fuzzers and lua.
Change-Id: I53be039e21a4c11ec3a4bc54c1424cd3e15afc6a
Reviewed-on: https://skia-review.googlesource.com/31643
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2017-08-08 15:27:19 +00:00
Leon Scroggins III
fc4ee229a6 Fix double delete in SkBmpCodec
Previously, if ReadHeader returned false, it deleted the input stream.
But there are a couple of cases where ReadHeader creates an SkCodec and
then returns false. The SkCodec deletes the stream, and then so does
NewFromStream.

Make sure that we do not double delete by only deleting if no SkCodec
was created.

Add a test, so such a double delete will be caught by the bots.

Bug: b/37623797
Change-Id: I787422c9af58f0b92ad9e9ef9ad87c54a12f5e31
Reviewed-on: https://skia-review.googlesource.com/23620
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2017-07-14 16:25:54 +00:00
Leon Scroggins III
33deb7ed4d Make SkCodec more flexible about its required frame
SkCodec sets fRequiredFrame to be the earliest possible frame that a
given frame can depend on. e.g.

- Frame A fills the screen, Keep
- Frame B does not cover A, Keep
- Frame C covers B but not A, and is opaque

Frame C can depend on either A or B. SkCodec already reports that C
depends on A. This CL allows a client of SkCodec to use either A or
B to create C.

Also expose the DisposalMethod. Since any frame between A and C can
be used to create C except for DisposePrevious frames, the client
needs to be able to know the disposal method so they do not try to
use such a frame to create C.

Further, the disposal method can be used to give the client a better
idea whether they will continue to need a frame. (e.g. if frame i is
DisposePrevious and depends on i-1, the client may not want to steal
i-1 to create i, since i+1 may also depend on i-1.)

TODO: Share code for decoding prior frames between GIF and WEBP

Change-Id: I91a5ae22ba3d8dfbe0bde833fa67ae3da0d81ed6
Reviewed-on: https://skia-review.googlesource.com/13722
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Chris Blume <cblume@chromium.org>
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2017-06-07 20:15:17 +00:00
Leon Scroggins III
12a4dc985b Defend against ICOs with large BMPs embedded
If the ICO reports that it has a large BMP file embedded, do not
crash if we attempt to allocate too much memory.

Bug: b/38116746
Change-Id: I70eb66f5e4ffc15587007b398bbe843665eae500
Reviewed-on: https://skia-review.googlesource.com/18447
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2017-06-05 18:28:19 +00:00
Matt Sarett
d16084ffdc Better image for copyTo4444 test
This one produces noticeable differences if we fail to dither.

Bug:720105
Change-Id: I208d0c8147f4cca1b484f2f55edc09ce1bef2dcb
Reviewed-on: https://skia-review.googlesource.com/18036
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Klein <mtklein@chromium.org>
2017-06-01 17:01:53 +00:00
Jim Van Verth
37aca928c5 Add ship.png for DrawShip sample
Bug: skia:5526
Change-Id: I12bd44c7dabd72f215a34ce9e733bb7a29d3fc68
Reviewed-on: https://skia-review.googlesource.com/17763
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
2017-05-23 20:35:17 +00:00
Jim Van Verth
623fadf8be Add Material Design shadow reference sample
Change-Id: I889a3f508407178c457f675c321880d869caf9ea
Reviewed-on: https://skia-review.googlesource.com/17717
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-05-23 18:12:15 +00:00
Leon Scroggins III
557fbbe05b Add animation support to SkWebpCodec
TBR=reed@google.com
(No change to the public API, but changed a header file)

SkWebpCodec:
- Implement onGetFrameCount, onGetFrameInfo, and onGetRepetitionCount
- Respect the alpha reported by libwebp. Although the spec states that
  it is only a hint, the libwebp encoder uses it properly. Respecting
  allows us to draw opaque images faster and decode them to 565. This
  also matches other SkCodecs (and Chromium).
- onGetPixels:
  - Decode the frame requested, recursively decoding required frame if
    necessary
  - When blending with a prior frame, use SkRasterPipeline

SkCodec:
- Move check for negative index to getFrameInfo
- Reset the colorXform if one is not needed

SkCodecAnimation:
- Add new blend enum, for WebP's (and APNG's) non-blending option

SkFrameHolder:
- New base classes for frames and the owner of the frames, allowing
  code sharing between SkWebpCodec and SkGifCodec (particularly for
  determining whether a frame has alpha and what frame it depends on)
- When moving items from SkGIFFrameContext, use Skia conventions (i.e.
  int instead of unsigned)
- Rename "delay time" to "duration", to match e.g. SkFrameInfo::
  fDuration

SkGifImageReader:
- Move pieces to SkFrameHolder, and adapt to changes made in the
  process
- Make setAlphaAndRequiredFrame (now on the base class SkFrameHolder)
  more general to support webp, and add support for frames that do not
  blend
- Change SkGIFFrameContext from a struct to a class, to match how we
  use the distinction elsewhere (i.e. struct is a small object with
  public fields)
- Rework hasTransparentPixel (now hasTransparency, since it returns true
  in some cases where there is not a transparent pixel) to better fit
  with the modified setAlphaAndRequiredFrame. Also be more consistent
  when there is no transparent pixel but no color map.
- Simplify an if condition that was previously simplified in 2d61e717
  but accidentally got reverted in a4db9be6

CodecAnimTest:
- Test new animated webp files
- Rearrange the test to more cleanly print alpha type mismatches for
  the first frame

resources:
- webp-animated.webp
  - animated webp from Chromium
- blendBG.webp
  - new webp file using bits of webp-animated-semitransparent4.webp
    from Chromium
  - tests required frame and alpha when using the non-blending mode
  - frames have the following properties:
    - Frame 0: no alpha, fills screen
    - Frame 1: alpha, fills screen
    - Frame 2: no alpha, fills screen
    - Frame 3: alpha, fills screen, blendBG
    - Frame 4: no alpha, fills screen, blendBG
    - Frame 5: alpha, blendBG
    - Frame 6: covers 4, has alpha, blendBG
  - also used to test decoding to 565 if the new frame data has alpha
    but blends onto an opaque frame

DM.cpp:
- Test animated images to non-native 8888 and unpremul

DMSrcSink.cpp:
- Do not test non-native 8888 decodes to f16 dst
- Test unpremul decodes to f16
- Copy a frame of an animated image prior to drawing, since in unpremul
  mode, the DM code will premultiply first.

Bug: skia: 3315
Change-Id: I4e55ae2ee5bc095b37a743bdcfac644be603b980
Reviewed-on: https://skia-review.googlesource.com/16707
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2017-05-23 15:28:37 +00:00
Matt Sarett
9f1c403362 Add tool to create test images with interesting color profiles
Bug: skia:
Change-Id: Ia4f892368fceda4a99490f5bd29851837a7a6927
Reviewed-on: https://skia-review.googlesource.com/17212
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
2017-05-17 18:15:20 +00:00
Matt Sarett
2e61b182da Add jpeg encoder alpha handling option
This instructs us on how to encode jpegs when the src
image has alpha.  The original behavior is to ignore
the alpha channel.  This CL adds the option to blend
the pixels onto opaque black.

Note that kBlendOnBlack and kIgnore are identical
unless the input alpha type is kUnpremul.

Bug: 713862
Bug: skia:1501
Change-Id: I4891c70bb0ccd83f7974c359bd40a2143b5c49ac
Reviewed-on: https://skia-review.googlesource.com/15817
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
2017-05-09 18:32:04 +00:00
Matt Sarett
9d687dfa3e Avoid interpolating color lut with less than 2 points
Bug: 717935
Change-Id: Ibf15b815891eef5a0239bc408bcbfe7c8b1507c5
Reviewed-on: https://skia-review.googlesource.com/15301
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
2017-05-05 15:18:03 +00:00
Matt Sarett
d59948a171 SkPngCodec: Do not return kInvalidConversion on corrupt png
In this case, the fuzzer thinks there is a bug because we are
returning kInvalidConversion for a corrupt png file.

Bug: skia:6550
Change-Id: I33f588442f5eaa8a4d642e9328750779f9a9ef5d
Reviewed-on: https://skia-review.googlesource.com/14324
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2017-04-26 17:43:38 +00:00
Leon Scroggins III
7d22a33e21 Add a test for getFrameInfo on truncated data
Prior to e132e7be5f, calling getFrameInfo
on an SkGifCodec which was truncated before fully parsing the local
color map of the first frame would hit an assert. Add a test to verify
that the problem has been fixed.

Modify box.gif to use a local color map for the first (and only) frame.

Change-Id: I905afe60c0c6ecc82e251e00ef82b2e5b22975a3
Reviewed-on: https://skia-review.googlesource.com/13320
Reviewed-by: Chris Blume <cblume@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2017-04-17 16:35:35 +00:00
Leon Scroggins III
a4db9be6a2 Correct GIF frame dependencies and track alpha
Add SkCodec::FrameInfo::fAlphaType. The SkImageInfo for the SkCodec
specifies the SkAlphaType for the first frame, but the opacity can vary
from frame to frame.

When determining the required frame, also compute whether a frame has
alpha. Update how we determine the required frame, which had bugs.
(Update a test that had an incorrect required frame as a result.)

Add new test images covering cases that have been fixed:
- randPixelsAnim2.gif
It has the following frames:
A (keep)
B (keep) (subset)
C (disposePrevious) (covers B)
D (any) (does *not* cover B)

B and C depend on A, but D depends on B, since after disposing C, B
should be visible again.

- alphabetAnim.gif
Includes frames which fill the image size, with different disposal
methods and transparencies.

Change-Id: Ie086167711c4cac4931ed8c4ddaeb9c9b0b91fdb
Reviewed-on: https://skia-review.googlesource.com/9810
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2017-04-11 15:05:05 +00:00
Leon Scroggins III
0354c62e0b Set a limit on the size for BMP images
This limit matches the limit used by Chromium. I am not aware of any
real world BMPs that are larger than this (or even close to it), but
there are some invalid BMPs that are larger than this, leading to
crashes when we try to read a row.

BUG:34778578
BUG=skia:3617

Change-Id: I0f662e8d0d7bc0b084e86d0c9288b831e1b296d7
Reviewed-on: https://skia-review.googlesource.com/8966
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2017-02-24 21:25:44 +00:00
Matt Sarett
5c49617f3d Reland "Respect canvas size and frame offset in webp decoder"
Original Change Reviewed At:
https://skia-review.googlesource.com/c/7800

CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN

BUG=skia:6185

Change-Id: I1a7732832d37920545c1775d7c7c65b43ed810f9
Reviewed-on: https://skia-review.googlesource.com/8157
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
2017-02-07 22:40:13 +00:00
Matt Sarett
2bb94e8147 Revert "Reland "Respect canvas size and frame offset in webp decoder""
This reverts commit 604971e39a.

Reason for revert: Strange vk failures

Original change's description:
> Reland "Respect canvas size and frame offset in webp decoder"
> 
> Original Change Reviewed At:
> https://skia-review.googlesource.com/c/7800
> 
> CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN
> 
> BUG=skia:6185
> 
> Change-Id: I92baa9070e15ef3c62dd347c08c906c2715dda10
> Reviewed-on: https://skia-review.googlesource.com/8050
> Reviewed-by: Matt Sarett <msarett@google.com>
> Commit-Queue: Matt Sarett <msarett@google.com>
> 

TBR=msarett@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:6185
CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN

Change-Id: Ice93b62c55ea13fce83140567be16225ff0e2fdb
Reviewed-on: https://skia-review.googlesource.com/8123
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2017-02-07 16:39:39 +00:00
Matt Sarett
604971e39a Reland "Respect canvas size and frame offset in webp decoder"
Original Change Reviewed At:
https://skia-review.googlesource.com/c/7800

CQ_INCLUDE_TRYBOTS=skia.primary:Test-Ubuntu-Clang-GCE-CPU-AVX2-x86_64-Debug-MSAN

BUG=skia:6185

Change-Id: I92baa9070e15ef3c62dd347c08c906c2715dda10
Reviewed-on: https://skia-review.googlesource.com/8050
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
2017-02-06 18:55:41 +00:00
Robert Phillips
b3050b91f0 Revert "Respect canvas size and frame offset in webp decoder"
This reverts commit 0f33970c8d.

Reason for revert: msan complaint

Original change's description:
> Respect canvas size and frame offset in webp decoder
> 
> BUG=skia:6185
> 
> Change-Id: Id543cb689a5e33b800ebbc18f4a234e78a4c4298
> Reviewed-on: https://skia-review.googlesource.com/7800
> Commit-Queue: Matt Sarett <msarett@google.com>
> Reviewed-by: Leon Scroggins <scroggo@google.com>
> 

TBR=borenet@google.com,msarett@google.com,scroggo@google.com,reviews@skia.org
# Not skipping CQ checks because original CL landed > 1 day ago.
BUG=skia:6185

Change-Id: Ie01dc7d7ebfebe36a235335d0d8cb28bccb2ecff
Reviewed-on: https://skia-review.googlesource.com/8046
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
2017-02-06 13:43:16 +00:00
Matt Sarett
0f33970c8d Respect canvas size and frame offset in webp decoder
BUG=skia:6185

Change-Id: Id543cb689a5e33b800ebbc18f4a234e78a4c4298
Reviewed-on: https://skia-review.googlesource.com/7800
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2017-02-03 21:45:30 +00:00
Leon Scroggins III
b3b24538e0 Use fixed size buffer for RLE bmps
An RLE bmp reports how many bytes it should contain. This number may be
incorrect, or it may be a very large number. Previously, we buffered
all bytes in a single allocation. Instead, use a fixed size buffer and
only read what fits into the buffer. We already have code to refill the
buffer if there is more data, so rely on that to keep reading.

Choose an arbitrary size for the buffer. It is larger than the maximum
possible number of bytes we need to read at once.

Add a test with a test image that reports a very large number for
the number of bytes it should contain. With the old method, we would
allocate 4 gigs of memory to decode this image, which is unnecessary
and may result in OOM.

BUG=b/33251605

Change-Id: I6d66eace626002725f62237617140cab99ce42f3
Reviewed-on: https://skia-review.googlesource.com/7028
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2017-01-19 14:21:02 +00:00
Leon Scroggins III
b0b625b796 GIF: Better check for frame dependency
If a frame does not have a valid transparent index and it covers the
prior frame, it does not really depend on that frame. Instead, it
depends on the frame that the prior frame depends on.

Determine this once we have parsed the local color map (if any), so a
transparent index out of range of the color map is not considered
valid.

Share code that determines whether a frame has a transparent pixel.

Add a test that we compute the dependencies correctly. randPixelsAnim.gif
has 13 frames. After the first, the frames cover all combinations of

- Whether the prior frame was keep, restoreBG or restoreToPrevious
- Whether the new frame covers the prior frame
- Whether the new frame has a transparent pixel

(It only does so when using a global color table. It may make sense to
expand the test to also cover using local color tables.)

The test caught a bug where we incorrectly reused an existing
SkColorTable for a different frame. Fix that bug by keeping track of
the transparent index associated with the current SkColorTable.

Change-Id: I3cf6be7f612990fa7a00d9e74d116d31bd227526
Reviewed-on: https://skia-review.googlesource.com/6402
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2017-01-03 19:07:41 +00:00
Leon Scroggins III
4cd68653e3 Only attempt index8 if underlying GIF is index8
Recent changes (crrev.com/2045293002) made it so that a GIF may not
support index 8. In that case, make SkAndroidCodec not suggest index 8.

Add a test and a new test file. randPixelsOffset.gif is the same as
randPixels.gif, except its frame is offset. Since it does not have a
transparent index, we have to decode to kN32.

Change-Id: I1c09ab9094083de3dfc436632b3c26dbde1dccbd
Reviewed-on: https://skia-review.googlesource.com/6196
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2016-12-16 19:51:52 +00:00
Leon Scroggins III
0b24cbd9db Stop supporting kUnknown_BmpHeaderType
In SkBmpCodec, if the header size does not match a known header,
stop trying to create an SkCodec. We do not know of any BMPs with
arbitrarily sized headers, so this should not cause any real
regressions.

In addition, this fixes a bug where we attempt to read too much data
from a file. Since we attempt to read the header size in one read,
and a size reported by the "BMP" may be larger than SSIZE_MAX, this
will crash when reading from a file.

Add a test.

BUG:b/33651913

Change-Id: I0f3292db3124dc5ac5cbdbc07196bda130a49ba7
Reviewed-on: https://skia-review.googlesource.com/6150
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2016-12-15 21:48:03 +00:00
Leon Scroggins III
56e3209c70 SkGifCodec: intersect frameRect with image size
When clearing due to SkCodecAnimation::RestoreBGColor_DisposalMethod,
intersect the frameRect with the image size to prevent clearing outside
the bounds of the allocated memory.

Add a test image, created by the fuzzer.

BUG=skia:6046

Change-Id: I43676d28f82abf093ef801752f3a9e881580924c
Reviewed-on: https://skia-review.googlesource.com/5860
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2016-12-13 14:00:17 +00:00
Leon Scroggins III
d87fbee775 Do not create an SkRawCodec with zero dimensions
Add a test

BUG=skia:3534
BUG=b/33300701

Change-Id: Ifb3a824a36998c5e626c4ad58466845f49d18ebf
Reviewed-on: https://skia-review.googlesource.com/5568
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2016-12-02 22:23:35 +00:00
Matt Sarett
dbdf6d210b Fail jpeg decodes on too many progressive scans
BUG:642462

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4560

Change-Id: I22891ce1e0b3a1bedefc34dadd5cf34dfc301b79
Reviewed-on: https://skia-review.googlesource.com/4560
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
2016-11-08 21:39:15 +00:00
scroggo
e71b1a1496 Report repetition count in SkCodec
Add a new accessor to retrieve the repetition count.

Remove constants (and corresponding copyright) in SkCodecAnimation.
These may make sense for the calling code, but are not needed here.

kRepetitionCountInfinite corresponds to Blink's kAnimationLoopInfinite.
Move cLoopCountNotSeen to private. It is used to determine whether we
still need to parse. Add a new enum to the parse query - only parse
enough to determine the repetition count.

Unlike Chromium, SkGifCodec does not account for deleting the reader
(which SkGifCodec does not do) or failed decodes.

Add a test.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2447863002

Review-Url: https://codereview.chromium.org/2447863002
2016-11-01 08:28:28 -07:00
Leon Scroggins III
fc49b403eb Use correct color table for prior GIF frames
While investigating skbug.com/5883 I noticed that we use the color
table for the current frame even while recursively decoding frames that
the current frame depends on.

This CL updates fCurrColorTable, fCurrColorTableIsReal and fSwizzler
before decoding prior frames, and then sets them back afterwards.

Move telling the client about the color table into prepareToDecode,
since the other callers do not need to do so. (That is only necessary
for decoding to index 8, which is unsupported for frames with
dependencies.)

Add a test that exposes the bug. colorTables.gif has a local color
table in its second frame that does not match the global table used by
the first frame.

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4208

Change-Id: Id2dc9e3283adfd92801d2f38726afa74574b1955
Reviewed-on: https://skia-review.googlesource.com/4208
Reviewed-by: Joost Ouwerling <joostouwerling@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
2016-10-31 19:23:10 +00:00
Matt Sarett
0186661e85 Reject non-D50 matrices from ICC profiles
BUG:660838

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4200

Change-Id: Ib57eb3705d6fe638e3a9cb56788937fc7e282847
Reviewed-on: https://skia-review.googlesource.com/4200
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
2016-10-31 18:06:24 +00:00
Matt Sarett
8a4e9c51f4 SkGifCodec: do not write off the end of memory when repeatCount > 1
BUG=skia:5887

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3940

Change-Id: I9e3ed6153a73277896ac067ef73918a41a0546b8
Reviewed-on: https://skia-review.googlesource.com/3940
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
2016-10-26 00:43:27 +00:00
raftias
9488833428 Refactored SkColorSpace and added in a Lab PCS GM
The refactoring breaks off A2B0 tag support into a separate
subclass of SkColorSpace_Base, while keeping the current
(besides CLUT) functionality in a XYZTRC subclass.

ICC profile loading is now aware of this and creates the A2B0
subclass when SkColorSpace::NewICC() is called on a profile
in need of the A2B0 functionality.

The LabPCSDemo GM loads a .icc profile containing a LAB PCS and
then runs a Lab->XYZ conversion on an image using it so we can
display it and test out the A2B0 SkColorSpace functionality,
sans a/b/m-curves, as well as the Lab->XYZ conversion code.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2389983002

Review-Url: https://codereview.chromium.org/2389983002
2016-10-18 10:02:52 -07:00