Commit Graph

3525 Commits

Author SHA1 Message Date
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
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
Nader Jawad
5d678b6486 Update Drawable API to expose getOpticalBounds method as well as
the Insets class

Updated all Drawable implementations to remove the @hide annotation

Fixes: 78942648
Test: Re-run CtsGraphicsTestCases and updated Drawable CTS tests to
verify getOpticalBounds implementations

Change-Id: Id9b6bbbe15173e310bbf44184b4678fb29ef1cd8
2018-05-09 10:51:36 -07:00
Nader Jawad
8ed9796bd5 Merge "Updated documentation of StateListDrawable#addState in order to indicate that sharing a Drawable across multiple Views/Drawables can lead to undefined rendering behavior" 2018-05-01 22:50:38 +00:00
Nader Jawad
d5a51a82b4 Merge "Removed the @hide annotation on various StateListDrawable APIs to better match the API surface exposed in ColorStateList." 2018-05-01 21:42:30 +00:00
Nader Jawad
e44e7fd612 Updated documentation of StateListDrawable#addState in order to indicate
that sharing a Drawable across multiple Views/Drawables can lead to
undefined rendering behavior

Bug: 70594326
Test: Re-ran CtsGraphicsTestCases

Change-Id: Ia6923886c809b6d81ead43becd8c725ae79ee999
2018-05-01 14:22:53 -07:00
android-build-team Robot
f4c79874e9 Merge "Stop copying PrecomputedText buffer" 2018-05-01 17:36:09 +00:00
Seigo Nonaka
2a6fb346dc Stop copying PrecomputedText buffer
PrecomputedText already has a copy of the text. No need to copy the
buffer.

android.text.StaticLayoutPerfTest:
  draw
    PrecomputedText NoStyle: 610 -> 616: (  +6, +1.0%)
    PrecomputedText Style  : 811 -> 831: ( +20, +2.5%)
    RandomText NoStyle     : 547 -> 544: (  -3, -0.5%)
    RandomText Style       : 730 -> 744: ( +14, +1.9%)

Bug: 72461923
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
Change-Id: I4b9d1c003f127a796d7d4f0d4aecfa7d016b89f6
2018-04-30 17:18:50 -07:00
Nader Jawad
4f614c8864 Removed the @hide annotation on various StateListDrawable APIs to better
match the API surface exposed in ColorStateList.

Removed the @hide annotation for the following StateListDrawable APIs:
--getStateCount
--getStateSet
--getStateDrawable
--getStateDrawableIndex

Fixes: 30325322
Test: Re-ran StateListDrawable CTS tests and added tests to verify each
of the newly exposed APIs

Change-Id: If93a017b6cf690fc38381a234bf3bd19d0bfc675
2018-04-27 22:06:14 +00:00
Derek Sollenberger
c18bcee38f Merge "Temporarily allow StackView to use a canvas.clipRectUnion" into pi-dev am: 7a7b2369fe
am: 8f0335fdec

Change-Id: Id22c0ad948b9aecfc0844ab0ad9b0d9eb376febb
2018-04-25 11:34:51 -07:00
TreeHugger Robot
7a7b2369fe Merge "Temporarily allow StackView to use a canvas.clipRectUnion" into pi-dev 2018-04-25 17:36:47 +00:00
TreeHugger Robot
88363dfc70 Merge "Updated ColorDrawable to implement getColorFilter" 2018-04-24 20:53:29 +00:00
Leon Scroggins III
33bd4a883f Merge "Fix rounding of padding in NinePatchDrawable" into pi-dev am: eabeec49c4
am: ac2454c905

Change-Id: Ia2693ba87ed07a79315282ed5ab7f6c89cb11c6e
2018-04-24 13:42:36 -07:00
TreeHugger Robot
eabeec49c4 Merge "Fix rounding of padding in NinePatchDrawable" into pi-dev 2018-04-24 19:58:53 +00:00
Nader Jawad
1bf1d5a240 Updated ColorDrawable to implement getColorFilter
ColorDrawable previously did not implement getColorFilter despite having
a proper setColorFilter implementation. Updated ColorDrawable to support
getColorFilter returning the corresponding ColorFilter configured on
it's paint.

Change-Id: Iabc3cd1b9110f5c3ec25e26a31966e2a43f8fb16
Fixes:78476471
Test: Re-ran CtsGraphicsTest
2018-04-24 12:34:15 -07: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
Selim Cinek
dba97ba147 Merge "Made the DrawableWrapper return the right ColorFilter" into pi-dev am: cf893ac40c
am: d4c4d946ae

Change-Id: I064ead2161ed1c1a0b91141fdf828eb6c9d7ce1d
2018-04-22 19:59:01 -07:00
Selim Cinek
cf893ac40c Merge "Made the DrawableWrapper return the right ColorFilter" into pi-dev 2018-04-23 02:26:58 +00:00
Adrian Roos
4a3d9ff120 Merge "Defer resizing invisible stacks while drag resizing" into pi-dev am: 5e12ebfffd
am: 03d4aeda37

Change-Id: Ic4e21bcd38e09cd237fcf149ba308bfdbf77240d
2018-04-20 08:07:53 -07:00
Adrian Roos
a6d6aab0e0 Defer resizing invisible stacks while drag resizing
Works around a source of jank when drag resizing in split
screen mode: instead of immediately resizing the (potentially
numerous) invisible secondary stacks, we defer that until
the user lets go of the handle.

Change-Id: I3b9faa83005fa86185d4e51b2849e3a826b7f6a9
Fixes: 78214347
Test: Open a gazillion (resizeable) tasks. Enter split screen. Drag handle, verify there is no jank
Test: atest RectTest
2018-04-20 15:09:02 +02:00
Selim Cinek
c85057c14c Made the DrawableWrapper return the right ColorFilter
Previously it simply returned null

Test: atest cts/tests/tests/graphics/src/android/graphics/drawable/cts/DrawableWrapperTest.java
Change-Id: Ia4694e8dee08449262bbe1cfd719795fd86e1ee0
Fixes: 78252558
2018-04-19 10:48:02 +08:00
Derek Sollenberger
2ad19e5146 Temporarily allow StackView to use a canvas.clipRectUnion
StackView currently expands the clip of the view which is a prohibited
operation in API Level 28.  This CL currently allows this specialized
use case to work in this situation until we can update StackView
to not clip to its bounds and then just intersect with this clip
provided by its parent.

Test: CtsWidgetTestCases
Bug: 77642155
Change-Id: Icc003ad3946bb226368ec2030d4707753f4f55e9
2018-04-18 16:19:59 -04:00
Leon Scroggins III
4534745f53 Fix rounding of padding in NinePatchDrawable
Bug: 73088142
Test: Test app at https://buganizer.corp.google.com/issues/73088142#comment6
Test: GridWidgetTest.testItemDecorationAndMarginsAndOpticalBounds

In computeBitmapSize, treat padding as a size in scaleFromDensity. This
results in rounding instead of truncating. This matches the way optical
insets are handled. It also matches the padding we would have gotten if
we had scaled at decode time.

Change-Id: I7d3a83ba824b8dc81187ce9b2d9889d4a87f88ac
2018-04-13 13:12:49 -04:00
TreeHugger Robot
17133935aa Merge "Removed hidden mutable APIs from PorterDuffColorFilter" 2018-04-11 00:13:05 +00:00
Nader Jawad
85ff47e3fc Removed hidden mutable APIs from PorterDuffColorFilter
Removed PorterDuffColorFilter#setColor and PorterDuffColorFilter#setMode
as the public facing ColorFilter API is immutable. These framework
internal APIs were causing issues with Drawables as updates to state of
the ColorFilter would not be propagated up to the Drawable to cause an
invalidation.

Fixes: 77723600
Test: Ran atest on SystemUITest and CtsGraphicsTest modules

Change-Id: I935c9e35ffa225735b951bb3b1eb753ea5815a84
2018-04-10 19:37:19 +00:00
Nader Jawad
94f25a6515 Updated DrawableWrapper implementation to support the hidden setXfermode
method to delete the corresponding Xfermode to the wrapped drawable

Added coretest to verify the hidden API properly propagates the Xfermode
to the wrapped drawable

Change-Id: I1f14105b7019b57bfcdd7182bb50ea2465c91ffe
Fixes: 30840201
Test: Ran atest on coretests
2018-04-10 12:32:00 -07:00
Seigo Nonaka
9f5da23937 Merge "Add common weight name to the API description" into pi-dev am: 1cf0b6cbfd
am: 24187a720b

Change-Id: Ic9c045e3045f329185444044628d4943fdeebfab
2018-04-09 10:08:12 -07:00
Seigo Nonaka
1cf0b6cbfd Merge "Add common weight name to the API description" into pi-dev 2018-04-09 16:46:26 +00:00
Seigo Nonaka
f2944cd61b Add common weight name to the API description
Bug: 76448718
Test: m docs
Change-Id: Id0ce0b2bcbf4f6b0cf1aa97c4d2c3c5117dc62c2
2018-04-09 14:29:41 +00: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
TreeHugger Robot
9cb6759072 Merge "Never scale nine-patches in ImageDecoder" into pi-dev 2018-04-05 22:42:39 +00:00
TreeHugger Robot
4ce55ba63f Merge "Added line to mark the mGradientIsDirty flag to true in order to recompute GradientDrawable drawing bounds" 2018-04-05 21:51:47 +00:00
Leon Scroggins III
fc7f4c89ed Merge "Rename set/get-ConserveMemory" into pi-dev am: d2c218f78a
am: 844ecb325a

Change-Id: Ieb7c02b42c77230173688e493e3e2b5549279de1
2018-04-05 14:24:49 -07:00
TreeHugger Robot
d2c218f78a Merge "Rename set/get-ConserveMemory" into pi-dev 2018-04-05 20:44:58 +00:00
Nader Jawad
5a22b40803 Added line to mark the mGradientIsDirty flag to true in order to
recompute GradientDrawable drawing bounds

Updated logic in GradientDrawable#setStrokeInternal to set the
mGradientIsDirty flag to true when the stroke is changed in order to
have ensureValidRect be called and recompute the drawing bounds
configured on mRect. In the event that a stroke width is defined, the
drawing rect must be inset by half the stroke width. Otherwise the
stroke will be drawn at the edges of the boundary and be clipped.

Bug: 70915849
Test: Ran test app provided in bug and confirmed that modifying the
strokeWidth on a pre-existing GradientDrawable matches the behavior of a
brand new GradientDrawable instance used as the background on a view

Change-Id: Icaa53d936589a9b4790f89e894f1d745c6e4fe43
2018-04-05 10:43:28 -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
de80e55325 Merge "Add docs for setTargetSize and setTargetSampleSize" into pi-dev am: d9cb59629d
am: 4cd2ed6067

Change-Id: I4717b7a453469bd5c204cca2294675a2a01aa8a6
2018-04-05 06:58:01 -07:00
Leon Scroggins
d9cb59629d Merge "Add docs for setTargetSize and setTargetSampleSize" into pi-dev 2018-04-05 13:29:38 +00:00
TreeHugger Robot
b04d93366c Merge "Modified ShapeState#newDrawable to pass a deep copy of ShapeState" 2018-04-05 00:26:20 +00:00
Leon Scroggins III
ac959199e5 Rename set/get-ConserveMemory
Bug: 76448408
Test: Ie83dbdeab5cc3dcd6bd56dd874412ed67eb52c02
Change-Id: I714b159bb70a48e5644801cc7fef8e32ee93896a
2018-04-04 19:58:30 -04:00
Nader Jawad
14516dba62 Updated GradientDrawable setColor(ColorStateList) implementation to
match corresponding documentation to fall back to
setColor(Color.TRANSPARENT) in the event that null is passed as the
ColorStateList parameter

Refactored implementation to directly call setColor(Color.TRANSPARENT)
if setColor(null) is invoked, otherwise configure the solid colors and
the fill Paint color to the ColorStateList and resolved color for the
given state

Bug: 64951083
Test: Compiled, flashed an updated build of master onto taimen and
re-ran tests with updated implementation in GradientDrawableTest

Change-Id: Ia7e9a995fc78e49d601931ca6af81470d90f8439
2018-04-04 14:45:43 -07:00
Nader Jawad
a2d61be939 Modified ShapeState#newDrawable to pass a deep copy of ShapeState
Because ShapeState#newDrawable passes a reference to the existing
ShapeState instance, modifications to a single ShapeDrawable instance
affect all instances of the ShapeDrawable obtained through
ShapeState

Bug: 74570674
Test: Tested by flashing a local build onto a Taimen and running
the sample application provided in the corresponding bug to verifying
that both usages of OvalShape within the sample app produce the same
visual result

Change-Id: I10a8aac8eb51d551a13f2b6292f0cd84bff84045
2018-04-04 13:23:46 -07:00
Leon Scroggins III
d97e26428d Add docs for setTargetSize and setTargetSampleSize
Bug: 77507530
Test: No change in behavior, no new tests

Add @Px and @IntRange annotations, and be explicit that setTargetSize
refers to pixels. Add a comment to setTargetSampleSize that is like
calling setTargetSize with particular values, to try to make it clear
how the two are related.

Change-Id: Ie7e9429bc8c548f44d382358c161425f666ba82f
2018-04-03 11:59:29 -04:00
Leon Scroggins
ab600d979f Merge "Update javadocs for ImageDecoder and related" into pi-dev am: 8880a9e0b9
am: de054456f2

Change-Id: I69f828620f62848193dc14850c07ad87c20ded49
2018-04-03 08:12:58 -07:00
Leon Scroggins
8880a9e0b9 Merge "Update javadocs for ImageDecoder and related" into pi-dev 2018-04-03 14:43:01 +00:00
Derek Sollenberger
1aefca09eb Merge "Merge "Restore saveLayer APIs back into the public API." into pi-dev am: ffe1c2a266" into pi-dev-plus-aosp
am: c13bf77769

Change-Id: I1d93eb9fadc99f578e7162a6aae82d6eb612a3b8
2018-04-02 23:19:26 +00:00
TreeHugger Robot
ffe1c2a266 Merge "Restore saveLayer APIs back into the public API." into pi-dev 2018-04-02 14:28:48 +00:00
Leon Scroggins III
f648b2e6f2 Remove chaining from ImageDecoder setters am: d9b53a097d
am: fe49dd165e

Change-Id: I1ca209b9bce4c50fdaf5b5a983669f0a305d022b
2018-03-31 01:01:39 +00:00
Leon Scroggins III
d84c652a4e Update javadocs for ImageDecoder and related
Bug: 76461699
Bug: 76448408
Test: No change in behavior, no new tests

Add class level docs for ImageDecoder, including sample code. Update
wording to be more clear and less wordy. Fix broken attempts at using
sample code.

Incorporate advice at go/android-api-guidelines and
https://developers.google.com/style/api-reference-comments

Change-Id: Iaf1334993f6cd2d3f6e53d3fb70ef9c7a95c9a76
2018-03-30 20:13:39 -04:00
Leon Scroggins III
d9b53a097d Remove chaining from ImageDecoder setters
Bug: 76448408
Test: Infeasible
Change-Id: Ib0ef0a9a9b0f36481ed1bbb16ecaccd180df8915
2018-03-30 15:02:56 -04:00