107 Commits

Author SHA1 Message Date
Derek Sollenberger
415a74b565 Update text alignment when using drawTextOnPath.
This is only a partial fix for the bug, but does ensure that Skia
doesn't attempt to realign the text after minikin already has.

Test: CtsGraphicsTestCases and test app in bug.
Bug: 25360203
Change-Id: I6222963b23b910f0261f562f8816604575d540fa
2018-03-14 15:03:13 -04:00
Stan Iliev
7717e22c85 Draw text with a hairline stroke as if it is fill style
Dew to a side effect of HWUI opengl pipeline, the hairline stroke
is not respected, but it is drawn as a fill style. Implement the
same behaviour for skiagl pipeline with SDK API 27 and older.
On SDK released with Android P, the hairline stroke is respected.

Bug: 72494357
Test: Ran duolingo app
Change-Id: I48bdcf3ddec4bf65b5e93e01c5002177c4e3da90
2018-02-08 23:04:47 +00:00
Mike Reed
58978e182f remove unused/deprecated flags from savelayer
Test: make

Change-Id: I39e41a80430dca7878e6983b098c1c4541904fd1
2018-02-06 16:18:47 -05:00
Derek Sollenberger
2d14213849 Initial implmentation of AnimatedImageDrawables on the RenderThread.
The current implementation schedules the next frame of the images
to be decoded after the current frame completes but potentially
schedules tasks that will result in a no-op execution if a new
frame is not yet needed.

Test: HwAccelerationTest
Change-Id: I0510cb5a1b801abd651327e924deb586af0306d6
2018-01-24 13:11:39 +00:00
Leon Scroggins III
671cce2605 Make ImageDecoder return animated Drawables
Bug: 63909536
Bug: 63908092
Test: TODO

If ImageDecoder.decodeDrawable is called with an animated image Source
(currently GIF or WebP), return an object of a new (hidden) Drawable
subclass. The new Drawable animates, and it implements Animatable (TODO:
implement Animatable2) so users have some control over the animation.

In addition to the normal features of Drawable, this new one supports
many of the features of ImageDecoder, including scaling, cropping and
PostProcess, which enables circle masks/rounded corners and other
arbitrary after-effects. It does *not* support decoding directly to a
Hardware Bitmap, since it cycles through frames and reuses the same
bitmap memory. But it could be made to use shared memory (TODO?).

TODO: Use a better number for the native allocation registry
TODO: Use the RenderThread to drive the animation, and remove decoding
on the UI thread.
TODO: Add support for modifying the loop count

Android.bp:
- build new AnimatedImageDrawable.cpp

AndroidRuntime.cpp:
- register new native methods

AnimatedImageDrawable.java
AnimatedImageDrawable.cpp:
- new Drawable that handles animated images

Canvas.h, SkiaCanvas.h/.cpp
- New virtual method and implementation for drawing SkAnimatedImages

RecordingCanvas.h/.cpp
- Stub implementation of drawing SkAnimatedImages

ImageDecoder.h/cpp
- Allow code sharing with AnimatedImageDrawable.cpp
  - postProcess
  - access the ImageDecoder struct

Depends on https://skia-review.googlesource.com/c/skia/+/94660 in Skia.

Change-Id: Ie2ec98d9c52deda4d439c6ef8e5dea2861bb93a3
2018-01-17 17:06:57 -05:00
Stan Iliev
c6c96dd86d Improve correctness of SkiaCanvas::drawLayoutOnPath
Align glyph to a tangent touching SkPath in the midle of the
symbol. Previously wrong tangent crossing the path at the
beginning of the glyph was used.

Test: Ran the test app attached to the bug
Bug: 71525360
Change-Id: I310394d11e185de314f66a6b332f804188e42ed9
2018-01-11 14:44:51 -05:00
Stan Iliev
e12d7315dd Enable fast drawing for solid color nine patch rectangles
Pass a hint to Skia, about which lattice rectangles are solid
color rectangles.

Bug: 69796044
Test: Measured ninepatch performance using sample app from the bug
Change-Id: Ib07b1b64c78ab16195f9af88a989d28682084565
2017-12-11 18:22:17 +00:00
Stan Iliev
a39b77416c Fix text encoding in some macrobench tests
Fix crash in macrobench tests, caused by incorrect text encoding.

Test: Ran macrobench tests
Change-Id: I3522004f70c7037299fb92157ac8633ebb170131
2017-11-29 13:15:45 -05:00
Derek Sollenberger
ef3b218735 If the absolute value of a sweep angle >= 360 then draw it as an oval.
Skia's drawArc API is defined to keep winding when drawing an arc
with a sweep angle > 360.  This allows for special path effects
and for points on the arc to potentially be double drawn. This is
not the case for the HWUI implementation that optimistically turns
the call into a drawOval.  This CL updates Skia's pipeline to be
in line with the HWUI implemenation.

Test: CtsGraphicsTestCases were added to cover this
Bug: 68764873
Change-Id: I22cd15a53cd2df44421518256d45a2b5d0525a86
2017-11-06 13:55:59 -05:00
John Reck
1bcacfdcab Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
2017-11-03 10:57:44 -07:00
John Reck
938e884a1f Avoid setting high contrast in every view draw
Test: high contrast text still works
Change-Id: I6674d1aca8dddf7eb9725a5346aed12ef1dbc195
2017-08-24 16:15:58 -07:00
TreeHugger Robot
9482963b80 Merge "Filter empty paths at record time" 2017-08-16 17:59:52 +00:00
Stan Iliev
6dcfdecc3a Filter empty paths at record time
Filter empty paths at record time. Quick settings pull test has
about 18% empty paths.

Test: Ran quick settings pull jank test
Bug: 64487466
Change-Id: I5b1650060ae4d157d313efb435ecda26c03d4b72
2017-08-16 10:22:15 -04:00
Derek Sollenberger
6c2a9e2bc1 Use the faster path when calling drawImageRect.
Bug: 64487466
Test: CtsGraphicsTestCases, CtsUiRenderingTestCases
Change-Id: Ib2312598b50d402b1749d62a10c6ec343eff5b89
2017-08-15 16:23:01 -04:00
Derek Sollenberger
fa3e340431 Use colorFilters when rendering to an sRGB bitmap.
Bug: 62347704
Test: CtsUiRenderingTestCases, CtsGraphicsTestCases, hwui_unit_tests
Change-Id: I3e237b64cd92217b02d4995bdd695a28d3f393ee
2017-08-07 08:43:23 -04:00
Derek Sollenberger
a7f6af2c51 Revert "Use colorFilters when rendering to an sRGB bitmap."
This reverts commit b851b197497783f894b72edcaed8f93d035ddea0.

Change-Id: I5bb8fe9bf9f5d411674e289c467b3f569f7bb068
2017-08-02 21:57:42 +00:00
Derek Sollenberger
b851b19749 Use colorFilters when rendering to an sRGB bitmap.
Bug: 62347704
Test: CtsUiRenderingTestCases, CtsGraphicsTestCases
Change-Id: I55a574ffd9305588b82345a598da7818952a131d
2017-08-02 11:37:46 -04:00
Derek Sollenberger
fb0c8fc3d5 Enable colorspace conversion while perserving legacy blending.
When requesting an SkImage from a android::Bitmap we will also
return a colorFilter that will perform the sRGB conversion at draw
time.

Bug: 62347704
Test: CtsUiRenderingTestCases, CtsGraphicsTestCases, CtsViewTestCases
Change-Id: Icc4694e2c42605e29fcc834c252bc21263bac658
2017-07-27 10:52:11 -04:00
Stan Iliev
0a3ff952a6 Improve color correctness for drawing bitmaps with Skia pipeline
Fix drawing of bitmaps with color profiles. This CL is making
ColorSpaceTests and Rgba16fTests CTS tests to pass with Skia
pipeline. Drawing bitmaps withs pixels outside SRGB range
may need more work (ColorSpaceTests#testDrawDisplayP3 test use a
a wider gamut, but the actual pixels fall into the SRGB range).

Test: Ran CtsUiRenderingTestCases with HWUI and Skia pipeline.
Bug: 62347704
Change-Id: I8d318076bb38f7d32bfde7e5492ae7a61f4731a5
2017-07-19 09:22:39 -04:00
Derek Sollenberger
0bbc82cba1 Merge "Remove round rect clipping optimization." into oc-dev am: 190fe086df
am: c421f748a9

Change-Id: I6fe0b0eabb2ad17a7dd6df8c695029f36f8b3cd6
2017-04-18 16:29:39 +00:00
Derek Sollenberger
f7d98f436c Remove round rect clipping optimization.
This optimization fails to account for inverse fill.

Test: bit CtsGraphicsTestCases.CanvasTest
Bug: 37417782
Change-Id: I04adfa93542b1bd1f5d905c64bb40e521242e29d
2017-04-17 18:05:42 +00:00
Matt Sarett
00ce770070 Merge "Bug fix: use legacy SkCanvas regardless of color space tag" into oc-dev am: 101dc265a8
am: 7e92ac449b

Change-Id: Ic50bd5fe0358390024bdb9a34e14906dba669f25
2017-04-14 19:02:54 +00:00
Matt Sarett
ca9b703b88 Bug fix: use legacy SkCanvas regardless of color space tag
Test: Added unit test. CtsGraphicsModule.

Bug: 32984164

Change-Id: If72e1e31c98e01f97f3a05d763f5d4c71cf88313
2017-04-14 16:26:50 +00:00
Matt Sarett
d0814db633 Add SkiaCanvas::captureCanvasState()
Test: Verified bug is fixed.  Wrote unit test.

Bug: 37268771

Change-Id: I9deb7db353cd2129ad245e7f65419670463bb717
2017-04-13 14:23:38 -04:00
Matt Sarett
44dc270830 Add SkiaCanvas::captureCanvasState()
Test: Verified bug is fixed.  Wrote unit test.

Bug: 37268771

Change-Id: I9deb7db353cd2129ad245e7f65419670463bb717
2017-04-13 11:11:11 -04:00
Derek Sollenberger
86a1c30a11 Merge "Change behavior of setBitmap to cleanly reset the canvas" into oc-dev am: 7944962b7e
am: 43844db75d

Change-Id: I8e362993a2fc51ce93015924d4819884301aa0c1
2017-04-12 17:59:18 +00:00
Derek Sollenberger
eb69cbbe22 Change behavior of setBitmap to cleanly reset the canvas
- identity matrix
 - no save stack
 - wide-open clip

This reverts commit 4f641d1e4586b027969052cc0ad6b65c1158e72e

Test: bit CtsGraphicsTestCases:.CanvasTest
Bug: 36218535
Change-Id: Id11deb06e37d6df61f1f171d424ab150d812a7a8
2017-04-11 14:00:25 -04:00
Romain Guy
0246a298f9 Merge "Color management, the missing pieces" into oc-dev am: 7dfa16c2ef
am: 3eafcb2d8b

Change-Id: I079d8d17982eecc022f2a53e1e6ca193dc7a3ace
2017-04-07 18:48:57 +00:00
Romain Guy
8242656f49 Color management, the missing pieces
Implement missing color management pieces for bitmaps:

- Bitmap.createBitmap(Bitmap src, ...) now creates a bitmap
  in the same color space as the source bitmap
- Bitmap.createScaledBitmap() now creates a bitmap in the
  same color space as the source bitmap
- Bitmap.createBitmap(..., ColorSpace colorSpace) to create
  bitmaps in a specific color space
- Fix copy from A8 to F16
- Copying bitmaps in F16 or with a color space does not work,
  it's currently a limitation in Skia

Bug: 36905374
Test: BitmapColorSpaceTest
Change-Id: I0092fe4432511db50daa3a9393389a9db05e0c2a
2017-04-07 07:56:14 -07:00
Matt Sarett
7c9fb6076e Merge "Xform bitmaps to sRGB on SW and PDF canvases" into oc-dev am: c29dffed16
am: fd5d5425ee

Change-Id: If960ccd900ebc2b841c2f13ca4f25820a48a950f
2017-04-06 22:16:49 +00:00
Matt Sarett
ea70d22dc8 Xform bitmaps to sRGB on SW and PDF canvases
For picture-backed canvases, we will defer the xform
until playback.

Test: Unit tests and cts test.
Bug: 32984164
Change-Id: Ib74663bcb688b74b6ba8792b403b0475126732af
2017-04-06 15:14:00 +00:00
Mike Reed
826deefda5 switch over to SkVertices object, and stop using deprecated methods.
This allows Skia to remove
  SK_SUPPORT_LEGACY_CANVAS_VERTICES
  SK_SUPPORT_LEGACY_BITMAP_SETPIXELREF
  SK_SUPPORT_LEGACY_PIXELREFFACTORY

Test: Existing CTS cover these changes

Running CtsGraphicsTestCases, there were 6 failures w/ and w/o this CL.
None of the 6 seems related to this CL.

Change-Id: I724082357d9f6cb699770df3c0b9ef555b957697
2017-04-05 14:20:38 +00:00
TreeHugger Robot
9d64a418bb Merge "Optimize Canvas::drawGlyphs" 2017-04-04 21:36:10 +00:00
Stan Iliev
0b58d99283 Optimize Canvas::drawGlyphs
Avoid one memcpy in Canvas::drawGlyphs for all pipelines.

Test: CTS passed with exception of SweepTests#testBasicDraws
shadowtext, which fails with and without this CL.
Change-Id: I0841232dc7a6173eb3b03f939dbde15a84186296
2017-04-04 15:43:12 -04:00
Mike Reed
6c9bb2408f Don't use deprecated canvas methods
Allows skia to remove SK_SUPPORT_LEGACY_CANVAS_HELPERS

Test: Existing tests cover the change.

Change-Id: I764c11f7a9bd7b87fba8563968160ee7dc9a99a2
2017-04-04 13:19:38 +00:00
Mike Reed
871cd2dd60 use SkVertices::Builder in drawBitmapLattice
override new virtual onDrawVerticesObject

Test:  CtsGraphicsTestCases

Change-Id: I38e3ee0aa2a1ee9c11474c2c5d648ee5fca20d78
2017-03-20 08:40:12 -04:00
Tony Mantler
4f641d1e45 Revert "Change behavior of setBitmap to cleanly reset the canvas - identity matrix - no save stack - wide-open clip"
https://buganizer.corp.google.com/issues/36218535

This reverts commit 269f989fbf198b17994baf9141c4640aeaf34b4e.

Change-Id: Ib2473e4fce90c9abaa39eea2b77082ae26197b80
2017-03-14 22:40:31 +00:00
Mike Reed
269f989fbf Change behavior of setBitmap to cleanly reset the canvas
- identity matrix
- no save stack
- wide-open clip

Behavior around the new bitmap is the same.

Tests : CtsGraphicsTestCases

Change-Id: Ieaf8c2a1b96262ed33940dd852a86089eb93efdb
2017-03-13 15:39:57 +00:00
Derek Sollenberger
d7f13f84f8 Prematurely optimizing a Path.
If the path had an inverse fill type we were incorrectly
converting ovals and roundRects to their primitive form
without checking to ensure the path was not inverse fill.

This CL removes these optimizations as they happen internally
within Skia.

Bug: 34245907
Test: verified broken app is fixed and that skia has existing tests
Change-Id: I8c1ff6522ae19fc6c21520adc7e9bc2473a8a4ad
2017-03-09 13:59:23 -05:00
Derek Sollenberger
792fb3252f Use SkPaint.nothingToDraw instead of PaintUtils helper.
The PaintUtils helper is now shared between all pipelines and was
missing a quick reject test for drawLoopers which are used in
view.setShadowLayer and supported in the Skia pipelines.

Bug: 35809097
Test: added hwui unit test and verified in DocumentsUI app
Change-Id: I3c4a988f1c42b7f421f78ac3659af1daee910ea2
2017-03-03 14:24:58 -05:00
Derek Sollenberger
95c1a069f2 Revert "deprecate replayClips"
This reverts commit 82d3b17f6dff9372ec531d90b5d9180671e0ee2c.

Bug: 35831173
Change-Id: I467e7204a5e4bcbab1c12d3fcf52e52188830ed5
2017-02-28 17:49:07 +00:00
Mike Reed
82d3b17f6d deprecate replayClips
replayClips is deprecated, just get the rgn instead for setBitmap

Test: ran Canvas CTS
Change-Id: Id0f0da6602d1488bb4071885704fa6e3b449ab85
2017-02-24 18:23:05 -05:00
Derek Sollenberger
b8201195df Deprecate Canvas save/saveLayer flags.
Test: compile
Bug: 14650725
Change-Id: I6424ac46bae0a7a87c4b7743e81319945dfdd087
2017-02-09 13:18:25 -05:00
Mike Reed
5e43898231 use new clipbounds api
Allows us to remove SK_SUPPORT_LEGACY_GETCLIPBOUNDS flag

Change-Id: I7c6665b4eb67c58fe747c07b8b87d58fe9b10120
2017-01-25 13:26:41 +00:00
Ben Wagner
c2d9470aa9 Remove SkDevice.h includes.
SkDevice.h is being removed from Skia. This removes these already unused
includes which mention this file.

Test: refactoring CL. Existing unit tests still pass.

Change-Id: I8340a5822ad2b75c54fe0dca1303ceab9bbee805
2017-01-13 17:03:13 -05:00
Derek Sollenberger
b29b16e542 Remove clipRegion from the public API.
This API is difficult to support for printing and has other negative
effects as it does not respect the current matrix/clip.

Test: compile
Bug: 14650725
Change-Id: I71f9bd687d446c7ce8910d755421aad8e09458db
2017-01-04 14:57:43 -05:00
Stan Iliev
68885e38b8 Modify savelayer to save matrix and clip for Skia pipeline
Modify SkiaCanvas::saveLayer to always save matrix and clip and
match HWUI behaviour. Also ensure android state tracking
behavior matches that of the Skia API (partial saves not
supported). This change is fixing SaveLayerAnimation
macrobench when buffer age is disabled.
Add a HWUI unit test that verifies clip and matrix are restored.

Test: built and ran angler-eng, ran hwui unit tests
bug:33429678
Change-Id: I62e429f9746518fef67663b0dd99ac499bf31af3
2016-12-15 16:47:34 -05:00
Mike Reed
6e49c9f007 switch over clip calls to use SkClipOp instead of SkRegion::Op
Change-Id: I67d23c487b5249bc31d96e3b2393f693c0b2bcff
2016-12-07 10:34:39 -05:00
Mike Reed
6acfe16b56 SkCanvas is no longer reference-counted
Change-Id: Ie821efe7c0a7d1301715e303aaf4d7ec86ac35e7
2016-11-28 15:11:22 -05:00
Derek Sollenberger
e547dd0b80 Cleanup asserts and remove usage of deprecated data structure.
Test: compile only
Change-Id: I9e9f1a3fb37db043d76a98a9568679e7e531e283
2016-11-09 18:04:44 +00:00