2686 Commits

Author SHA1 Message Date
Alan Viverette
61ffc199f2 Merge "Apply VectorDrawable density scaling before applying theme" 2015-11-19 14:50:40 +00:00
Alan Viverette
d633ca417d Apply VectorDrawable density scaling before applying theme
Refactors density handling to look more similar to GradientDrawable's
implementation, which should make things easier to maintain. We no
longer update density directly in updateStateFromTypedArray, instead
handling it in applyTheme() and inflate().

Lazily calculates local density-dependent dimensions and invalidates
when the constant state density changes, which should ensure a random
call to applyTheme() will still result in the correct intrinsic
dimensions.

Change-Id: I726878a6cd75d38a550637e3e7a7b6bc68bcaf6d
2015-11-19 09:47:09 -05:00
Doris Liu
804618d086 VectorDrawable native rendering - Step 2 of MANY
Introduced PathData in Java, which is effectively a thin layer around the
native instance. PathData holds the verbs and points which is being used
in path morphing/interpolation. The verbs and points can be interpreted
into skia path commands, which is now done in native and therefore saves
a handful of JNI calls during path creation.

Removed the old PathDataNode mechanism and changed the PathEvaluator
to use PathData instead.

Also added tests and a microbench. Also ran CTS tests for VectorDrawable
and AnimatedVectorDrawable, and passed all of the existing tests.

Change-Id: Ia166f5172ff031fe18b154327967f911a62caec1
2015-11-18 13:38:23 -08:00
Alan Viverette
477f3d092d Obtain cached drawables using the correct Resources object
Previously we were discarding the Resources when forwarding from the
two-arg factory method to the one-arg method. This CL also updates the
documentation for ConstantState to be slightly more comprehensive.

Bug: 25688078
Change-Id: I4fbbf43f95fe792fa6f0bf9db8fd9a7cbfa51d1d
2015-11-16 10:12:44 -05:00
Alan Viverette
b6181565e5 Merge "Return correct intrinsic dimensions for inset colors" 2015-11-13 15:48:23 +00:00
Alan Viverette
76165b2a4b Return correct intrinsic dimensions for inset colors
Also updates documentation for getIntrinsicWidth/Height to accurately
reflect the behavior of the existing implementations and provide an
explanation of what "intrinsic" means.

Bug: 25646242
Change-Id: I11daf57e598148adfda922cfc1ba31ed48a16bd7
2015-11-12 10:47:53 -05:00
Alan Viverette
bd5294bcb8 Pass densityDpi into RippleComponent, store as densityScale
Fixes a regression where the foreground was created against the density
in DPI rather than as a scale factor.

Bug: 25602850
Change-Id: Ia871aa5def4319682a73228efb599f31b65afdb6
2015-11-11 12:51:10 -05:00
Alan Viverette
9db60f4e5b Merge "Mutate DrawableContainer children immediately after inflation" 2015-11-06 21:17:36 +00:00
Alan Viverette
9b4bdeff6d Mutate DrawableContainer children immediately after inflation
Previously we would only mutate children when they were displayed, so
applyTheme() calls would be applied to the shared constant state. Now
we mutate() immediately after obtaining the child, which ensures we
have a clean constant state. This also allows us to remove extra
mutate() calls, since we know all child drawables are already mutated.

Bug: 25081461
Change-Id: I52390db268690a8e181f5b9bbe612b7ed6ce9359
2015-11-06 15:22:43 -05:00
Alan Viverette
22e27ccf79 Merge "Correctly handle child drawables with no intrinsic size" 2015-11-06 19:41:59 +00:00
Alan Viverette
1259f616c2 Use ConstantState directly instead of ConstantStateFuture
All of the functionality of ConstantStateFuture has been moved into
prepareDrawable. We don't need the extra wrapper class.

Change-Id: I452b13320a838a23c8ec0dd486a89bf383142d7b
2015-11-05 14:34:44 -05:00
Riley Andrews
29869c3893 Merge "Convert ashmem bitmap thresholds to constants." into mnc-dr-dev am: c8bb39d98d am: 2c740f1dcf am: 6c1144dc0f
am: 132bb1e4b1

* commit '132bb1e4b10755d2bc0810135511fd999badbe4b':
  Convert ashmem bitmap thresholds to constants.
2015-11-04 20:43:38 +00:00
Riley Andrews
132bb1e4b1 Merge "Convert ashmem bitmap thresholds to constants." into mnc-dr-dev am: c8bb39d98d am: 2c740f1dcf
am: 6c1144dc0f

* commit '6c1144dc0f8b2452ca2a204ca471e2d23339d5a3':
  Convert ashmem bitmap thresholds to constants.
2015-11-04 20:37:18 +00:00
Alan Viverette
ab099c496b Correctly handle child drawables with no intrinsic size
If a child drawable has no intrinsic width or height, don't attempt to
apply padding and insets to the child during the parent layer drawable's
intrinsic width and height calculations.

Bug: 25461370
Change-Id: Idf616bde0449231f38156da53feb858e1ae41c47
2015-11-04 09:54:50 -05:00
Riley Andrews
0394a0c399 Convert ashmem bitmap thresholds to constants.
Bug 25256717

Change-Id: I23e2795ef8798d83bf60dcbd6ff2e7093fcaa9b0
Signed-off-by: Riley Andrews <riandrews@google.com>
2015-11-03 23:52:17 -08:00
Ian Pedowitz
18896e0893 Merge "Limit persistent ashmem backed fds to a minimum of 128kB." into mnc-dr-dev am: 966d6040c6 am: 95fc53b029 am: d6f3e38738
am: 87455c7397

* commit '87455c7397605fba4bf3ad04af8df3c599a7a6ba':
  Limit persistent ashmem backed fds to a minimum of 128kB.
2015-11-03 23:34:54 +00:00
Ian Pedowitz
87455c7397 Merge "Limit persistent ashmem backed fds to a minimum of 128kB." into mnc-dr-dev am: 966d6040c6 am: 95fc53b029
am: d6f3e38738

* commit 'd6f3e38738c88821b28b2571d034fc1b189a35de':
  Limit persistent ashmem backed fds to a minimum of 128kB.
2015-11-03 22:21:48 +00:00
Alan Viverette
4d47d2595e If LayerDrawable child doesn't have constant state, use shallow copy
Avoid NPE if mutate() is called on a LayerDrawable with a child that
doesn't support constant state.

Bug: 25438651
Change-Id: I6bf5a90484fda44a7b5fd10ce7b798eaa799b68e
2015-11-03 15:39:15 -05:00
Riley Andrews
8cee7c1711 Limit persistent ashmem backed fds to a minimum of 128kB.
Bug 25256717

Change-Id: Ieb356006df0a6545b89de44d3d8fd4b46312b3b8
Signed-off-by: Riley Andrews <riandrews@google.com>
2015-11-03 17:46:15 +00:00
Alan Viverette
36555baa55 Merge "Support for changing density of GradientDrawable" 2015-11-02 18:36:09 +00:00
Alan Viverette
ce52037e0a Support for changing density of GradientDrawable
Refactors density resolution and offset/size scaling into static
helper methods.

Also fixes VectorDrawbale insets to be treated as offset-type pixels
rather than size-type.

Bug: 25081461
Change-Id: I10fcb9ebb6c67f853a27ca0ee008c31af4b85da0
2015-10-30 11:07:35 -04:00
Alan Viverette
7e3ede2889 Support for changing density of DrawableWrapper subclasses
Includes a refactoring of DrawableWrapper classes so that the wrapper
super class handles both drawable management and inflation. This allows
us to immediately call through to super() in inflate and applyTheme,
which simplifies density management.

Bug: 25081461
Change-Id: I8c157d340fd1f28a3a2b786c56850a67cdd452e4
2015-10-28 16:57:57 -04:00
Alan Viverette
0cacad7023 Apply density scaling in LayerDrawable and subclasses
Bug: 25081461
Change-Id: I48e62caf5017ff2dd84cf62b68a828f4542b6ae5
2015-10-28 16:37:25 -04:00
Filip Gruszczynski
b6e6662462 Improve infrastructure for replacing windows.
We need to be more precise when removing the window that is being
replaced. We used to depend on the fact that we can remove it after
the first draw of the new added window. However, due to resizing the
old window might reset its draw state and that will trigger a removal
of that window.

We need to add an information about the window that is replacing the
old one and only when this new window draws itself, we remove the old
one.

This improves the transition after maximizing docked window. This is
a situation where first resize operation finishes and immediately
after we have a replacement operation.

Bug: 24914011
Change-Id: Ia8e5bb7872787e663ba23f26588f9c4db1a5e574
2015-10-26 14:11:32 -07:00
Roozbeh Pournader
e1e654d09e Merge "Pass the whole locale list down to Minikin." 2015-10-23 01:39:28 +00:00
Roozbeh Pournader
f036ead2a2 Pass the whole locale list down to Minikin.
Also, compute LocaleList's string representation at construction.
This is to further push the cost of doing costly operations related
to LocaleLists to construction time.

Change-Id: Ia55b8ce66b1088ff54cb42eb1e11149b5bd10f17
2015-10-22 13:14:13 -07:00
Alan Viverette
8cab9b5f1d Merge "Reset constant width/height when DrawableContainer density changes" 2015-10-22 15:02:32 +00:00
Alan Viverette
f1f5f6fcaa Reset constant width/height when DrawableContainer density changes
Bug: 25081461
Change-Id: I9661e964e1d0bacd337e31073faf870d37939b51
2015-10-21 17:14:27 -04:00
Alan Viverette
4a94faa0c7 Scale density correctly on VectorDrawable.applyTheme()
Bug: 25081461
Change-Id: I012e0932e67bc51502dc00e11131218af1377115
2015-10-21 15:15:23 -04:00
Alan Viverette
a3ee41b633 Apply density scaling when updating from typed array
Ensures that density scaling is applied to default dimension values
where needed. Previously, scaling was only applied when a drawable
was loaded from cached constant state; however, drawables that were
preloaded against a different density and first loaded in some other
density were not scaled.

Bug: 25081461
Change-Id: I0f8058cc01e2fe8d6bd7e255eba40485f3cbe48b
2015-10-20 17:15:27 -04:00
Alan Viverette
02f633d4cf Clean up VectorDrawable usage of stroke and fill color state lists
Only store stateful CSLs; otherwise, just use the default (e.g. the
only available) color.

Bug: 25074102
Change-Id: I050c89841d4c6bf22473a66c713a845b0358dc94
2015-10-19 15:18:53 -04:00
Filip Gruszczynski
2a6a2c2de8 Change WindowState.mShownFrame to WindowState.mShownPosition.
We never use this field as a rectangle, we only depend on its left-top
corner. Using a frame is only confusing about the purpose of this field.

Change-Id: I5d6e6321db4fa3203bb7e0f1975ae6ddd1ec09bb
2015-10-14 12:17:11 -07:00
John Reck
dbffd25000 Fix Paint's JNI
Bug: 22409077
Change-Id: I99e1a11bf14f5b62c41107528f573eaf9f2d4b2f
2015-10-02 09:27:10 -07:00
Keisuke Kuroyanagi
3089211ce6 Merge "Add tests: Paint#measureText for bidirectional text." 2015-10-01 20:11:49 +00:00
Keisuke Kuroyanagi
2c53a07597 Merge "Consolidate native methods for text measurement." 2015-09-29 21:31:56 +00:00
Keisuke Kuroyanagi
536afe6ef7 Consolidate native methods for text measurement.
Bug: 24505153

Change-Id: I6a00b0516442f7d6108ed0598516365310bd85e8
2015-09-29 13:52:45 -07:00
Keisuke Kuroyanagi
57bbbaca0b Merge "Add tests for Paint#getTextRunAdvances" 2015-09-29 20:07:25 +00:00
Keisuke Kuroyanagi
05de8fb29a Add tests: Paint#measureText for bidirectional text.
Bug: 22408712
Change-Id: Idff949fcabf360c994a0e3397cf6ec90d3a31162
2015-09-29 12:37:32 -07:00
Keisuke Kuroyanagi
2779b5978f Add tests for Paint#getTextRunAdvances
Bug: 24308179
Change-Id: Ic979e67c10fb18c1333963d8b27352968977f28f
2015-09-29 12:37:26 -07:00
Alan Viverette
e72a703a95 Add attribute for specifying initial ScaleDrawable level
Bug: 19182305
Change-Id: Ic1f183db6183017352babc6dc190fdb9124c285a
2015-09-23 10:20:59 -04:00
Alan Viverette
50c29cd92f Allow color state list for vector drawable fill and stroke
Removes unnecessary invalidateSelf() from VD.onStateChange(). This is
handled by the view hosting the drawable.

Bug: 22984152
Change-Id: Idf11a0ffef392cb1d8452aa3f5f836b35027a756
2015-09-22 15:03:50 -04:00
Alan Viverette
a02d2748be Clean up DrawableContainer.selectDrawable() docs, params
Change-Id: Ic38cbb4a21dab452950ba0e308ceba3cbe966363
2015-09-16 17:08:58 -04:00
Alan Viverette
6fe1ea778c Merge "Revert "Use floating-point value for Drawable level"" 2015-09-14 17:04:09 +00:00
Alan Viverette
0b6cfe22fd Revert "Use floating-point value for Drawable level"
This reverts commit 3da32b768899e7dabe3a16333edf5eca2b9ebe93.

Change-Id: Ie75ce0c285e0f59a7a086f64c0cfe088edb5df04
2015-09-14 16:59:49 +00:00
Hans Boehm
28aa456ac8 am 1d815272: am 58c27e3e: am c0ce6c42: Merge "Reduce risk of memory corruption due to finalization."
* commit '1d8152726b7ef2094f2e99619581c2abd2117381':
  Reduce risk of memory corruption due to finalization.
2015-09-09 23:50:45 +00:00
Hans Boehm
1d8152726b am 58c27e3e: am c0ce6c42: Merge "Reduce risk of memory corruption due to finalization."
* commit '58c27e3e53ef64072412515792433e570a176f15':
  Reduce risk of memory corruption due to finalization.
2015-09-09 23:44:37 +00:00
Hans Boehm
58c27e3e53 am c0ce6c42: Merge "Reduce risk of memory corruption due to finalization."
* commit 'c0ce6c422cfe089e7a8e209ac924e37bed3ca770':
  Reduce risk of memory corruption due to finalization.
2015-09-09 22:41:42 +00:00
Hans Boehm
ffa84e008c Reduce risk of memory corruption due to finalization.
Many classes in graphics/java and elsewhere deallocate native memory
in a finalizer on the assumption that instance methods can no longer
be called once the finalizer has been called.  This is incorrect if
the object can be used, possibly indirectly, from another finalizer,
possibly one in the application.

This is the initial installment of a patch to cause such post-finalization
uses to at least see a null pointer rather than causing memory corruption
by accessing deallocated native memory. This should make it possible to
identify and fix such finalization ordering issues.

There are more graphics classes that need this treatment, and probably
many more in other subsystems.

This solution is < 100% effective if finalizers can be invoked
concurrently.  We currently promise that they aren't.

(In my opinion, the real cause here is a language spec bug.  But that ship
has sailed.)

Bug: 18178237
Change-Id: I844cf1e0fbb190407389c4f8e8f072752cca6198
2015-09-08 18:27:36 -07:00
Alan Viverette
660383cfa7 Merge "Use floating-point value for Drawable level" 2015-09-04 14:21:26 +00:00
Snild Dolkow
a72f59a858 Update mFillPaint color on GradientDrawable inflation
When a GradientDrawable is loaded from scratch, initializeWithState()
is called with mColors == null. This sets mFillPaint's color to
0x00000000 -- transparent. mColors is then properly set in inflate(),
but mFillPaint is not updated there. It will be updated eventually
through a mutate() or ensureValidRect() call, but that's sometimes too
late.

In our case, a wrapping StateListDrawable called getOpacity(), and
since it caches the result, it never got updated.

This doesn't cause any problems on preloaded GradientDrawables, since
the new GradientDrawable created when fetching a preload will call
initializeWithState() in its constructor, fixing the GradientState.

Change-Id: Ic8caa7c6a7c1d4dae5ff31ae943831bd2e014f79
2015-09-04 10:08:46 +02:00