3896 Commits

Author SHA1 Message Date
Leon Scroggins III
10965f3922 Convert ColorLong in native code in Paint
Bug: 127580253
Test: CtsGraphicsTestCases
Perf: systrace

Follow on to I0b42c17159b290868a6bed7b90da096995504c4d, which did this
for other classes. I expect this to be more efficient due to passing
fewer JNI parameters, which appears to be the case based on the systrace
data for setColor(@ColorLong):

Duration:
(w/o this change)       (w/ this change)
avg:	0.010 ms        0.005 ms
max:	9.130 ms        0.239 ms
min:	0.002 ms        0.002 ms
std:	0.052 ms        0.004 ms

The average is twice as fast, the max is significantly shorter, and the
standard deviation is much smaller as well.

Change-Id: I241824bf2a934746df93da1063b14f3080486cb5
2019-03-14 10:59:37 -04:00
Leon Scroggins III
1a73221199 Make Paint default to filtering Bitmaps
Bug: 77949917
Test: I5737be68dccdc5ebb38291bf3515ae25553dcfc2

In P, the switch to Skia HW rendering lost a feature of HWUI's old
renderer: using a Paint with a BitmapShader resulted in filtering the
Bitmap, regardless of whether FILTER_BITMAP_FLAG was set.

This somewhat restores that behavior, in that it results in filtering
BitmapShaders so long as the client doesn't explicitly turn it off. This
also means that it continues to be possible to get a pixellated drawing
if the client *does* explicitly turn it off.

Change-Id: I62c726a0ba281de239092f066a3df041ecbcee5b
2019-03-14 14:51:22 +00:00
Leon Scroggins III
bbdb731275 Stop double-counting native memory in graphics classes
Bug: 121304803
Test: Infeasible

Previously, the NativeAllocationRegistry needed to report how much
native memory was being held onto by the Java class in order to get a
more accurate count of how much memory was in use. But recent changes
allow the system to have an even more accurate view of the native memory
with mallinfo(). Further, the AOSP change
Idccb8b50d26c8c3e93cc34040d784f74dfcdbf51 introduces new APIs that allow
distinguishing between large native malloc allocations, which should
cause more frequent mallinfo() checks, and whose sizes need be available
to ahat etc, and smaller native malloc allocations.

Bitmap and AnimatedImageDrawable use the version for large native malloc
allocations. The rest pass an implied size of 0. Note that many of the
old Registries used somewhat arbitrary sizes, reinforcing the fact that
the new way of keeping track of this is better.

Add Bitmap::pixelStorageType to differentiate between types of memory
that should be accounted for by the Registry.

Update Bitmap::getAllocationByteCount to report the actual size of
ashmem allocation.

Fix a typo in LineBreaker.java, discovered while looking to find
existing callers of Bitmap's constructor.

Change-Id: I57c407258450aeaf08b47df32432466639d9faed
2019-03-14 14:50:46 +00:00
Leon Scroggins III
03b3e236a0 Restore Paint#nSetColor(@ColorInt)
Bug: 127580253
Test: CtsGraphicsTestCases
Perf: systrace

Restored with a partial revert of "Add Paint#get(ShadowLayer)ColorLong"
(commit 6ee411010ea270351d495bf357fc294304286a70).

The original CL combined the @ColorInt and @ColorLong version for
simplicity, but required doing extra work for the @ColorInt version.
Separating them back out speeds it up at the cost of more code.
Using systrace I see the following stats:

Duration:
(w/o this change)       (w/ this change)
avg:    0.020 ms        0.001 ms
max:    9.141 ms        0.072 ms
min:    0.005 ms        0.001 ms
std:    0.074 ms        0.001 ms

This change shows a significant speed improvement. It does not do the
same for setShadowLayer, which is likely used less frequently.

Change-Id: I9021864fcad7d0149b93674f09339f805c272994
2019-03-14 10:33:57 -04:00
TreeHugger Robot
7c8b154141 Merge "Change Font.Builder#build return type from @Nullable to @NonNull" 2019-03-13 23:01:14 +00:00
TreeHugger Robot
7e8c759140 Merge "Change TabStop type from int to float" 2019-03-13 23:00:28 +00:00
TreeHugger Robot
3735f250e2 Merge "Tweak RenderNode's docs" 2019-03-13 19:36:21 +00:00
John Reck
08a68d5948 Tweak RenderNode's docs
Bug: 125026642
Test: looked at offline-sdk-docs
Change-Id: I1e03ac2291c31e79489b9cf545d2b7760fb4252d
2019-03-13 10:16:10 -07:00
Andrey Kulikov
ea23c429a1 Merge "Introduce View.getAnimationMatrix()" 2019-03-13 14:30:26 +00:00
TreeHugger Robot
c91fa25bee Merge "Always suppress font error during resource loading" 2019-03-13 01:05:39 +00:00
Seigo Nonaka
3a8254ad38 Change Font.Builder#build return type from @Nullable to @NonNull
Bug: 124794844
Test: N/A
Change-Id: Ib7a7a4605698dbda7a7f649708964b2b83916354
2019-03-12 13:18:17 -07:00
Seigo Nonaka
d5621edc35 Change TabStop type from int to float
This is from API council feedback.

Bug: 124794899
Test: atest CtsTextTestCases
Test: atest CtsGraphicsTestCases
Change-Id: Ifa95f87067239cca9c0791bf079045e4f645c3ad
2019-03-12 12:27:47 -07:00
Seigo Nonaka
96e93959fb Always suppress font error during resource loading
I suppressed the font error during resource loading only if the
targetSdkVersion is API 28 or before, but it turned out that this
makes developers hard to use font resources since:
- We don't give a list of supported font files and OEM may extend/shrink
  the font support.
- There is no way to resolve this error during layout inflation.

So, now always supress the IllegalArgumentException during building
Typeface in resource loading.

Bug: 127714175
Test: atest CtsTextTestCases
Test: atest CtsGraphicsTestCases
Test: atest FontsContractTest
Test: atest CtsWidgetTestCases
Change-Id: I08b9f27aaf25ff491fa36d0a4befb3c6e64abfcf
2019-03-12 12:13:14 -07:00
TreeHugger Robot
75f61c5919 Merge "Hide packing structure from public API" 2019-03-12 17:59:44 +00:00
Andrey Kulikov
c15c9ca54c Introduce View.getAnimationMatrix()
Adding a corresponding getter for the recently opened View.setAnimationMatrix(Matrix).

Bug: 126376184
Test: new cts tests added
Change-Id: I9d5abb1ae3606d2e3884859ce9a81c11c65613d6
2019-03-12 14:53:06 +00:00
Seigo Nonaka
fb1b479314 Hide packing structure from public API
The hyphen edit is packed into 8bit integer in native library, but this
should not be exposed to public API as API council suggested.

This CL includes:
- Removing packing structure from HyphenEdit and move constants from
  Hyphenator to Paint.
- Replace LineBreaker's getLineHyphenEdit with two separate start/end
  function.
- Replace Paint's getHyphenEdit with two separate start/end function.
- StaticLayout still relies on this packing mechanism but no longer need
  to be the same packing structure as in Minikin.

Bug: 124794844
Test: atest CtsGraphicsTestCases
Test: atest CtsTextTestCases
Change-Id: I8206061f554cf6e119b2b565162f54317eac630a
2019-03-11 16:51:47 -07:00
Nader Jawad
e756f460d0 Merge "Added @NonNull annoation to Insets.NONE static field" 2019-03-11 21:36:35 +00:00
TreeHugger Robot
b80a06a88a Merge "Address API review from the council" 2019-03-08 19:29:48 +00:00
Nader Jawad
2cd860317f Added @NonNull annoation to Insets.NONE static field
Addressing API review feedback regarding missing annotations
on Insets.NONE

Bug: 126699576
Test: N/A
Change-Id: I46748b504e04be7f29a41fa83362e9910295eafa
2019-03-07 19:21:40 -08:00
TreeHugger Robot
ad07707cac Merge "Document how RenderNode properties form the transform matrix" 2019-03-08 02:48:54 +00:00
Seigo Nonaka
de41eeaafd Address API review from the council
Here are the list this CL includes:
- Adding missing @NonNull, @Nullable, @IntRange annotations
- Added @Px annotation to Paint.set/getWordSpacing
- Change Builder classes to final.
- Change FileDescriptor to ParcelFileDescriptor as described in guideline.
- With this change, additional error handling is required in old
  Typeface.Builder but we can keep the same behavior (silently fallback to
  system fallback in error case).
- Fix comment in getLineHyphenEdit in LineBreaker.Result
- Rename setJustified to setJustificationMode in LineBreaker.Builder

Fix: 126702154
Fix: 126701272
Fix: 126701569
Fix: 126701953
Fix: 126701507
Fix: 126701667
Fix: 126700866
Fix: 126701009
Fix: 126700795
Fix: 126700292
Fix: 126699209
Fix: 124795407
Fix: 124795470
Bug: 124794844
Bug: 124794899

Test: m update-api
Test: TreeHugger

Change-Id: If6e8566b0eef9151d35d75b7f258128d7d3df358
2019-03-07 18:23:35 -08:00
John Reck
b7a14d5d51 Document how RenderNode properties form the transform matrix
Fixes: 125026642
Test: none
Change-Id: I30b12e2230ec8513eb789b82e107778ab7bce5ec
2019-03-07 15:12:54 -08:00
John Reck
d7300de54b Merge "Address API council feedback" 2019-03-07 22:09:33 +00:00
Nader Jawad
8bcc12a98f Merge "Added Nullability annotations to new Canvas APIs" 2019-03-07 22:06:32 +00:00
Nader Jawad
fbe2eabd3b Added Nullability annotations to new Canvas APIs
Added @NonNull annotation to drawDoubleRoundRect float array
parameters

Bug: 126702234
Test: N/A
Change-Id: Ib81fcc4ad6d5f2c471e4f6fb5ace4bdfc1d89b33
2019-03-07 09:43:34 -08:00
John Reck
28a1f9428e Address API council feedback
Fixes: 127532446
Test: build & checked docs
Change-Id: Ibf14ad52040694ccd503aaa187b99c19338b727a
2019-03-06 17:31:36 -08:00
TreeHugger Robot
1b042a7c6e Merge "Pass ColorSpace to AnimatedImageDrawable" 2019-03-06 03:37:23 +00:00
TreeHugger Robot
153f106109 Merge "Cleanup functor system-api surface" 2019-03-05 18:45:55 +00:00
Leon Scroggins
a3882ad859 Merge "Explain why Bitmap#setColorSpace is @NonNull" 2019-03-05 18:19:53 +00:00
TreeHugger Robot
0ab1f9250c Merge "Implemented API-review suggested changes on GradientDrawable" 2019-03-05 17:53:31 +00:00
TreeHugger Robot
6d6b53969a Merge "Added nullability annotations to StateListDrawable APIs" 2019-03-05 17:49:23 +00:00
TreeHugger Robot
3b6672deb5 Merge "Add nullability annotations to HardwareRenderer" 2019-03-05 17:37:48 +00:00
TreeHugger Robot
aa20063ef8 Merge "Add missing nullability to RenderNode" 2019-03-05 17:37:10 +00:00
Leon Scroggins III
4580ae1293 Explain why Bitmap#setColorSpace is @NonNull
Bug: 127282638
Test: No change in behavior
Change-Id: I167893b1d80ae37982804ec0dfa98b68d6eaab53
2019-03-05 10:02:12 -05:00
TreeHugger Robot
07cd0c7f3c Merge "Fix RenderNode sample" 2019-03-05 08:01:17 +00:00
Chong Zhang
58077d5d53 Add "image/heic" to supported mimes of ImageDecoder
bug: 127364815
Test: atest android.graphics.cts.ImageDecoderTest
Change-Id: I510a492b1770af70b9a36c239d043f8b09088fc2
2019-03-04 17:21:54 -08:00
Jeff Sharkey
678151592d Merge "API to determine if MIME type is supported." 2019-03-05 01:11:14 +00:00
John Reck
e9aeadb1e7 Cleanup functor system-api surface
Fixes: 127282736
Test: none
Change-Id: I5982d3f4f0671a3c351c11d8baf04aff5640e0a6
2019-03-04 10:29:40 -08:00
John Reck
ab6caf3e50 Add missing nullability to RenderNode
Fixes: 126701521
Test: none
Change-Id: I57dc2fddd28de79005a932759a05d2ddb84d28a9
2019-03-04 10:25:31 -08:00
John Reck
45d70c2bc2 Add nullability annotations to HardwareRenderer
Fixes: 126701502
Test: none
Change-Id: Ic215ffeb8decdadd1ae140c0b278b481b3eb010c
2019-03-04 10:20:27 -08:00
John Reck
c5735202fc Fix RenderNode sample
Fixes: 125027490
Test: none
Change-Id: I31dfdbe1da972f49fbf97ef2d0015b7b054139ae
2019-03-04 10:11:21 -08:00
Alan Stokes
6390339290 Merge "Fix javadoc HTML escaping." am: 693e023bac am: 4514c01068
am: 555ef78e35

Change-Id: I72faadd47fcd35ed8a5fc2e9e95cadc72cac3c27
2019-03-04 08:56:40 -08:00
Jeff Sharkey
575f065150 API to determine if MIME type is supported.
This'll help developers decide if they can try decoding an image
file directly, or if they need to convert it to a more general
format first.

Bug: 126276695
Test: atest android.graphics.cts.ImageDecoderTest
Change-Id: I6a404e3be883ac14ac2e6376247d4209f8963908
2019-03-01 11:46:15 -07:00
Ashley Rose
fa1a371750 Merge "Add nullability annotations to ColorStateListDrawable" 2019-03-01 18:37:48 +00:00
Jeff Sharkey
9e8f83db6d All Parcelable CREATOR fields are @NonNull.
If they were null, then the Parcelable would fail to work.

Bug: 126726802
Test: manual
Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014
Exempt-From-Owner-Approval: Trivial API annotations
2019-02-28 23:29:04 -07:00
Nader Jawad
abe349cda9 Added nullability annotations to StateListDrawable APIs
Addressing API review feedback to add nullability annotations to
StateListDrawable#findStateDrawableIndex getStateDrawable and
getStateSet

Bug: 126699087
Bug: 126699432
Test: N/A
Change-Id: I5a74ee9a9208800cd1430bc24856c0aeff77c61a
2019-03-01 00:15:24 +00:00
Ashley Rose
24192c806a Add nullability annotations to ColorStateListDrawable
Test: Annotation-only change, exsiting tests still pass
Change-Id: I34d56679658045aa57b93cfd6ad77b2859ce224a
Fix: 126701617
Fix: 126701492
2019-02-28 18:26:07 -05:00
TreeHugger Robot
8d6a8c5626 Merge "Mark Bitmap#getColor as @NonNull" 2019-02-28 22:50:24 +00:00
Adam Powell
b10113347d Merge "System gesture exclusion rects for Views" 2019-02-28 21:11:59 +00:00
Nader Jawad
f26382fd9c Implemented API-review suggested changes on GradientDrawable
--Added @Px annotations to pixel related parameters in added APIs
--Added @FloatRange annotation to float based APIs
(thickness/inner)Ratio
--Added error checking to invalid ratio arguments to
set(Thickness/Inner)ratio

Bug: 126375868
Bug: 126701500
Test: Added CTS tests to verify parameter validation logic
Change-Id: I8ca70f38edd18f68c168d4d6e2c93bcb9b64c488
2019-02-28 10:23:45 -08:00