Commit Graph

1521 Commits

Author SHA1 Message Date
Ben Wagner
9f1730c4b9 Merge "Update sk_sp use for explicit." 2018-05-29 21:02:08 +00:00
Ben Wagner
6b62ac0a32 Update sk_sp use for explicit.
Skia's sk_sp class is moving from operator pointer to field to
explicit operator bool. As a result a few uses need to be updated.

Test: refactoring CL. Existing unit tests still pass.
Change-Id: I97ca0647c7c490554da7dd626c99b3447d7cbc84
2018-05-29 14:17:08 -04:00
Seigo Nonaka
0ca492fb4d Follow minikin header structure changes
Bug: N/A
Test: minikin_tests
Test: hwui_unit_tests
Change-Id: I2e3fd1a549fe3e9703d2ef93d03a5923005d4caa
2018-05-25 14:52:22 -07:00
TreeHugger Robot
5d4c20e752 Merge "Cleanup Bitmap#recycle" 2018-05-25 13:36:21 +00:00
Leon Scroggins III
5078c92245 Remove unused refSkPixelRef
Test: Build

Change-Id: Iac21b08217113787765b5be611f7e1e66b317904
2018-05-25 12:48:08 +00:00
Leon Scroggins III
f8adae1b33 Cleanup Bitmap#recycle
Test: Build, CTS

mNativePtr can never be 0 (it is final, and the constructor prevents
setting it to 0), so do not check for it. nativeRecycle only ever
returns true, so make it return void.

Change-Id: Ib94c0304ca7303d6899f085e64be7c051908d173
2018-05-24 15:31:20 -04:00
Leon Scroggins III
117f0c2833 Merge "AnimatedImageDrawable: Eliminate unnecessary calls to redraw" into pi-dev am: a2113aa4ad
am: 6353ff5bb5

Change-Id: I5258721b49834aba58e9bf19162e6a4588f68f0f
2018-05-17 13:16:13 -07:00
TreeHugger Robot
a2113aa4ad Merge "AnimatedImageDrawable: Eliminate unnecessary calls to redraw" into pi-dev 2018-05-17 19:54:50 +00:00
Leon Scroggins III
4afdd1caa4 AnimatedImageDrawable: Eliminate unnecessary calls to redraw
Bug: 78866720
Test: Manual + systrace; existing CTS

Previously, we set hasAnimations to true when the AnimatedImageDrawable,
so that we would get a call to redraw. But if the image does not need to
show its next frame yet, the redraw was unnecessary.

Instead, add a new field to TreeInfo::Out, representing the delay time
until the image will need to be redrawn - i.e. when the duration of the
current frame has passed. Each call to prepareTree will post at most one
message to redraw, in time for the earliest animated image to be
redrawn. Post the message for one rendered frame ahead of time, so that
when it is time to show the next frame, the image has already gotten the
message to update.

On a screen with a single animated image, this drops the number of calls
to dispatchFrameCallbacks to as infrequent as possible. It is called
only when we need to draw a new frame of the image. On a screen with
multiple animated images, the calls may be redundant, but they will not
be more frequent than they would be without this change.

Switch to nsecs_t and systemTime internally, matching the rest of HWUI.

Remove mDidDraw and related. Its purpose was to prevent advancing the
animation while the image is not being drawn. But it isn't really
necessary. If it's not drawn, onDraw is not called, which is where we
trigger decoding. And onDraw already has a defense against getting too
far ahead - if its timer indicates that it should skip a frame or show
it very briefly, it will back up its timer. More importantly, mDidDraw
caused a bug, when combined with less frequent redraws. If the display
list containing the drawable doesn't need to be redrawn for other
reasons, the drawable's timer never advanced, so its animation stopped.

Fix software drawing. Compute the milliseconds in the future to draw the
next frame, and add that to SystemClock.uptimeMillis() to compute the
time to pass to scheduleSelf.

Change-Id: I13aab49922fa300f73b327be25561d7120c09ec4
2018-05-16 18:51:07 -04:00
Leon Scroggins
4127417bcb Merge "Allow ImageDecoder to read SkFILEStream directly" into pi-dev am: b9790fd184
am: 2648615308

Change-Id: I3b31e298517327f2400d5e060fb09e79f393fc0f
2018-05-09 16:10:22 -07:00
Leon Scroggins
f7a1403f36 Merge "Allow AssetStreamAdaptor to be seekable" into pi-dev am: b69f7c9e0b
am: 341ade0d5a

Change-Id: I79e724492884ff9f993d07da3f36cd84b4aaa2eb
2018-05-09 10:16:01 -07:00
Leon Scroggins III
0c699add01 Allow ImageDecoder to read SkFILEStream directly
Bug: 78866720
Test: Manual

If the input stream is seekable, SkGifCodec will read from it directly.
If not, it has to copy (parts of) the input in order re-decode when it
loops. Directly use the seekable SkFILEStream so that SkGifCodec skips
the copy, saving memory proportional to the size of the file.

Depends on a change in upstream Skia which allows SkFILEStream to treat
the initial offset as the beginning of the file:
https://skia-review.googlesource.com/c/skia/+/126511

Change-Id: Iefb58785157ba684ad3603778175b3dba97567b2
2018-05-07 16:28:16 -04:00
Leon Scroggins III
0492eefece Allow AssetStreamAdaptor to be seekable
Bug: 78866720
Test: Manual

It already supports rewinding, and the underlying Asset supports
seeking. Allow it to be seeked so that SkGifCodec can read directly from
it rather than copying data it needs for internal use.

Change-Id: I0765dcf4a507724878a5a700a770d35802c4b7be
2018-05-07 11:02:17 -04:00
android-build-team Robot
404632bcf2 Merge "Pass full context to Minikin" 2018-05-04 19:34:57 +00:00
Mike Reed
8cafcc628f remove (dead) caches from hwui
Test: make

Change-Id: I18bfe51896672272ce7d471eaead69b651399368
2018-05-03 13:23:40 -04:00
Seigo Nonaka
3a4217fb74 Pass full context to Minikin
Bug: 72461923
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
Test: minikin_tests
Test: hwui_unit_tests

Change-Id: Ic0827a85dbf1ab2b38d44514e400f524686748d2
2018-05-02 16:43:58 -07:00
Mike Reed
441e02e91b don't reference (dead) DevKern
This field is not respected in Android, so we want to remove it from Skia.

Test: make

Change-Id: If410265a31c04f283098ac55727c4a12bf717ac1
2018-05-01 20:03:13 +00:00
Nader Jawad
e7b5129c1e Updated Bitmap mutablity documentation and removed Bitmap#mIsMutable
flag

Updated Bitmap java and native implementation to redirect queries of
mutability to the native implementation provided by Skia. Updated
documentation of Bitmap.createBitmap method to accurately describe
mutability of the Bitmap result based on various inputs.
Removed flag from Bitmap class in favor of querying jni API directly.
Updated Bitmap constructor to no longer utilize mutable parameter
provided by jni call. Created hidden setImmutable method that invokes
corresponding native method to flip the Bitmap's mutability flag.

Fixes: 65560449
Test: Re-ran CTS tests and updated Bitmap tests to verify mutability of
all creation methods

Change-Id: I1b0b9de2fc15369b4e3f83512b866915387ac926
2018-04-22 22:12:48 -07:00
Leon Scroggins III
366e1e716d Merge "Never scale nine-patches in ImageDecoder" into pi-dev am: 9cb6759072
am: c13c945b19

Change-Id: I437c33c878db8c6bc4cbd3cd3d6989908bc6ff89
2018-04-05 16:19:52 -07:00
Leon Scroggins III
7d940ba43d Never scale nine-patches in ImageDecoder
Bug: 76448902
Bug: 70889348
Test: Manual + CtsThemeHostTestCases
(Ica5e7e81848c3880accee922ee6f1cc9e26262ca)

Scaling a nine-patch requires scaling its divs. When the scale factor is
not an integer, we have to round. This gets out of sync with the way the
decoder scaled the image, resulting in stretching or keeping fixed the
wrong portions of the image. Making this worse, when we scale down, we
end up with divs colliding with each other, and we have to arbitrarily
adjust them further so they do not collide.

NinePatchDrawable and the drawing code already know how to handle
drawing from the originally-sized image and do a better job stretching
appropriately, so allow them to do their job.

We already do something similar for Bitmaps created by ImageDecoder on
apps targeting P and above - instead of scaling them up, we allow the
BitmapDrawable's scaling code to handle density differences. We
preserved the old behavior (scale up) on apps targeting pre-P because
those apps may rely on the size of the Bitmap contained in a
BitmapDrawable without accounting for its density (see Bug: 74061412).
But that is not an issue for NinePatchDrawables, which do not allow
peeking at their internal Bitmaps.

Rewrite ImageDecoder.computeDensity. There is no need for it to be
static, since it takes an ImageDecoder as a parameter and reads its
fields, including the new field mIsNinePatch. Set mIsNinePatch in the
constructor to avoid another down call into native. Split up the
conditions that result in returning srcDensity without calling
setTargetSize for clarity.

Remove ImageDecoder constructor from the graylist. It was accidentally
added due to the fact that it is called transitively from public APIs.

Change-Id: I3c5ddd67f3352c991515f30ce1c477c9a608833f
2018-04-05 12:50:32 -04:00
Leon Scroggins
2542ce4f2b Merge "Add in/out ColorSpace to ImageDecoder" into pi-dev am: bf1fe9aecd
am: 8f935b0fbb

Change-Id: I1a0d03fb9ca51276dc1907fd4cd2d2685fc46a46
2018-03-29 21:55:38 +00:00
Leon Scroggins
bf1fe9aecd Merge "Add in/out ColorSpace to ImageDecoder" into pi-dev 2018-03-29 20:27:43 +00:00
Leon Scroggins III
1a69f4598f Add in/out ColorSpace to ImageDecoder
Bug: 76448408
Test: I851173b771668f0e6712bebfe06bfb8559801199

Add ImageInfo.getColorSpace() for retrieving the default ColorSpace.
This matches BitmapFactory.Options.outColorSpace.

Add ImageDecoder.setTargetColorSpace() for choosing a new ColorSpace.
This matches BitmapFactory.Options.inPreferredColorSpace.

Rename setSampleSize to setTargetSampleSize to match setTargetSize and
setTargetColorSpace.

Change-Id: If2f4e755dfc163f754849f896de24659198973db
2018-03-29 13:44:22 -04:00
John Reck
98d1b8b2d1 Merge "Move Path to NAR" into pi-dev am: 9434b66bf7
am: 6541c42146

Change-Id: I6cf9880e75ade2430af26eda7d9777ce81250168
2018-03-29 17:34:00 +00:00
John Reck
205d83e108 Move Path to NAR
Bug: 74686528
Test: PathTest#testUseAfterFinalize
Change-Id: Ic1c9df6f1b63ea5795a6c3a54b8fc50fdaf0a5f4
2018-03-28 14:36:58 -07:00
Leon Scroggins
547a528421 Merge changes from topics "DecodeException_ERROR", "AID_autoStart", "onPartialImage" into pi-dev am: ceb14e015b
am: fbe597e850

Change-Id: I2a70864001a9e6cf21692bcbcb5c2cc81361f0bf
2018-03-23 00:57:54 +00:00
Leon Scroggins III
1564d3070f Re-write onPartialImage API am: 1d2bf2b846
am: 1a82348834

Change-Id: Icd8be0239571f543ae815f51d162eb1485567eec
2018-03-23 00:51:26 +00:00
Leon Scroggins III
1a82348834 Re-write onPartialImage API
am: 1d2bf2b846

Change-Id: I7436bbe89b9efd9a406958b14f79294e982c5b3a
2018-03-22 23:34:41 +00:00
Leon Scroggins
ceb14e015b Merge changes from topics "DecodeException_ERROR", "AID_autoStart", "onPartialImage" into pi-dev
* changes:
  Rename ImageDecoder.ERRORs
  Add the ability to autoStart AID from xml
  Re-write onPartialImage API
2018-03-22 21:53:05 +00:00
Leon Scroggins III
cf7294fda6 Rename ImageDecoder.ERRORs
Bug: 73788969
Test: I501e8b76aacd785cb994165ab01dc1b39fea3a1c

Move them into ImageDecoder.DecodeException, which is where they are
actually used. This also provides some more context, so that the prefix
"ERROR_" is no longer necessary, fixing the redundancy/awkwardness in
ERROR_SOURCE_ERROR. Further rename that to SOURCE_MALFORMED_DATA, which
is more descriptive, and does not imply a Java Error.

Change-Id: Ied17ad343650f9c33d9a35b0f9d00ccc22264bd6
2018-03-22 13:09:02 -04:00
John Reck
1257885131 Merge "Merge "Fix wrong SafeUnref type" into pi-dev am: b09f2b5926" into pi-dev-plus-aosp
am: 9eecfb03fd

Change-Id: I7c08e82c93d169cb097c73d60b617ed7bd20b01e
2018-03-21 23:56:02 +00:00
TreeHugger Robot
b09f2b5926 Merge "Fix wrong SafeUnref type" into pi-dev 2018-03-21 21:34:10 +00:00
John Reck
97c7f4b84b Fix wrong SafeUnref type
Test: builds
Change-Id: I5a03551c408736722802ba0e8692c3d85e375112
Fixes: 76029886
2018-03-21 10:50:47 -07:00
Leon Scroggins
442522d112 Merge "Report native allocation size of AnimatedImageDrawable" into pi-dev am: d848f75f99
am: 6413aebc02

Change-Id: Id1a101b08f8f9b9b53875bd9c784dea04a5b4110
2018-03-21 17:46:16 +00:00
Leon Scroggins III
1d2bf2b846 Re-write onPartialImage API
Bug: 73788969
Test: If9e27a6ce2604128a619bc4843d62711f94b4d87

Add a new Exception subclass that contains information about the type of
error, and the original Exception, if any. Remove the old
IncompleteException class. If the decode creates a partial image, pass
the information up to Java, where we create the new Exception and pass
it to the callback and/or throw it. Rewrite nDecodeBitmap to always take
the ImageDecoder as a parameter for this callback, and simply use a
boolean to determine whether to call onPostProcess

Check for exceptions in some overlooked cases in native code, and
route to the new type.

Remove FIXME to avoid parsing the whole image. In my limited testing,
it didn't seem to speed anything up, and this should be called in a
background thread anyway. Parsing now also ensures that we've read the
stream when we can have a chance to handle the exception from the right
place.

Remove fixme for b/70626068, which has been marked as WontFix.

Add a TestApi for testing an Exception thrown by an InputStream.

Remove onPartialImage from hiddenapi-light-greylist.txt to fix the build
error this change introduces. onPartialImage was erroneously added to
the list.

Change-Id: I12f69857328e63c993bd669412b06addeb6a74f1
2018-03-21 12:55:46 -04:00
Leon Scroggins
d848f75f99 Merge "Report native allocation size of AnimatedImageDrawable" into pi-dev 2018-03-21 16:48:19 +00:00
Leon Scroggins III
eb3b38e22c Report native allocation size of AnimatedImageDrawable
Bug: 73641604
Test: infeasible

Fix nNativeByteSize's return value to be jlong, instead of long.
Add up the bytes used by the SkAnimatedImage and SkPictures and store
them on the AnimatedImageDrawable for registration.
Note that this is an approximation, and it assumes it will be drawn to a
hardware canvas and animated.
2018-03-21 09:28:00 -04:00
Philip P. Moltmann
d6ec6c2203 Merge "Handle PDFium API change" into pi-dev am: 173d0e9b34
am: 9449d80441

Change-Id: I8ce1328234178baa790cf9c56526afe43fdf2af8
2018-03-20 23:39:03 +00:00
TreeHugger Robot
173d0e9b34 Merge "Handle PDFium API change" into pi-dev 2018-03-20 20:07:11 +00:00
Leon Scroggins III
2b0e828b63 Merge "Work around incorrect Skia gamma" into pi-dev am: c45c2d65a5
am: 2a23ef3785

Change-Id: I8e70a674fd222070b1782f40b74e5a36b7b141a4
2018-03-20 04:41:20 +00:00
Philip P. Moltmann
e8800b232d Handle PDFium API change
It now does not flip coordinate system anymore.

Bug: 72134075
Test: atest CtsPdfTestCases
Change-Id: I4dce299738f24a44478c06fa7179306a4904b5d5
2018-03-19 16:01:34 -07:00
TreeHugger Robot
c45c2d65a5 Merge "Work around incorrect Skia gamma" into pi-dev 2018-03-19 22:10:31 +00:00
Leon Scroggins III
d10f7573e5 Merge "Move computation of decodeColor- Type and Space" into pi-dev am: 6d39e55020
am: 9ec6c3af9e

Change-Id: I26508380412a313dbd7a52e924bb044ca4404b33
2018-03-15 23:52:32 +00:00
TreeHugger Robot
6d39e55020 Merge "Move computation of decodeColor- Type and Space" into pi-dev 2018-03-15 21:26:24 +00:00
Seigo Nonaka
a7a62d0b81 Merge "Remove mtOffset from drawTextRun" into pi-dev am: bc20993e4b
am: 17abcf0b76

Change-Id: Ib0dbce1bc5efe12193d0d9770830ed046c08869d
2018-03-15 06:49:49 +00:00
Seigo Nonaka
83143d005b Remove mtOffset from drawTextRun
Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: Ia886c1ce9f7387559d7fe00b34ce03378d56ecec
2018-03-15 04:09:19 +00:00
Leon Scroggins III
ce89a6e656 Work around incorrect Skia gamma
Bug: 74408046
Test: Ic6acdc4a1a16840ec6ad9b13b4926c643d0f81ae

Skia incorrectly sets the gamma for LINEAR_EXTENDED_SRGB to 0 as a
misguided optimization attempt. As a result, a HARDWARE Bitmap which
natively has this color space does not match it properly. (Note that we
already catch an F16 Bitmap, above.) Add a workaround in
Bitmap.getColorSpace() to check for the color space explicitly.

Change-Id: Id595e365d1c8d572cfcea214d230a8ce1decdc01
2018-03-13 15:39:39 -04:00
Mike Reed
1b9eeb161d update call-sites to use SkMaskFilter::MakeBlur
Blur is now part of the core, so SkBlurMaskFilter.h is deprecated

Test: make

Change-Id: I06dd34972f34151e3c7f1e9d384ab2bd39890a56
2018-03-13 15:53:32 +00:00
Leon Scroggins III
8d592f9a7d Move computation of decodeColor- Type and Space
Bug: 70846442
Test: I5110881203c000474116a94a48f2afc9a9b62001

Delay computing decodeColorType until right before we may change it (and
delay reinterpreting the pointer along with it). More interestingly,
defer computing decodeColorSpace until *after* we may have changed the
decodeColorType. Along with a change in Skia, this allows us to match
the color type of inBitmap, as intended.

Change-Id: If0ca4a61d338a13473a96faf900c84010ae46d41
2018-03-12 16:03:29 -04:00
Leon Scroggins III
4856210398 Encode F16 Bitmaps to 8-bit P3
Bug: 73743812
Bug: 71430152
Test: If2c3ee0f32eff77b11ce5a7fe82c02811ed1beb3

This matches how we handle decoding images with a wide gamut. For WebP
and JPEG, we cannot encode with more precision anyway. For PNG, we could
in theory encode to 16 bit linear PNGs. This would be more precise, but
would still throw away information due to normalization. Using 8-bit P3
matches the behavior for the other formats, so it is nice to be
consistent.

Change-Id: I69a44a3eff70e26448a75ecc63ed7604b9c74a95
2018-03-12 14:01:57 -04:00