380 Commits

Author SHA1 Message Date
Xavier Ducrohet
0de1607093 LayoutLib: fix XmlUtils.convertValueToInt
It looks like the device implementation of Integer.parseInt
is able to handle converting hexa value > 80000000 while the
desktop VM cannot.

This patch provide a fix for this.

While implementing it and running the TestDegates test I realized
that some delegate methods for Region were mising, so this adds them
too.

Change-Id: Ifee1efd47c8c52adc2f4658ec4fc8bd55adb84b4
2011-01-11 12:15:15 -08:00
Xavier Ducrohet
b3830b8978 LayoutLib: only support animator-type animations.
Change-Id: Ia3609fc5d11555190bc323d61a3577144a4692fd
2011-01-11 10:54:12 -08:00
Xavier Ducrohet
eb87b3bb53 LayoutLib: fix some issue with resource resolution.
TypedArray.getResourceId() is not only about id/foo,
it can be any type of resources.

Change-Id: Ia5e147bc078bb349a3fa500a04c596ae44ea34ce
2011-01-10 21:51:55 -08:00
Xavier Ducrohet
419e8296ea LayoutLib: move asserts around.
Change-Id: I6fcfcf2e6fad1d9fa172b9a8c20c72fa2533e7fa
2011-01-10 11:57:49 -08:00
Xavier Ducrohet
c77515e590 LayoutLib: display warning when a resource reference fails to resolve.
Also fixed some warnings where a field hid one from a parent class.

Change-Id: I04ed19ebc49ae0bb0abdb0b25bc1c182fa0db440
2011-01-09 18:11:54 -08:00
Xavier Ducrohet
479101a9b4 LayoutLib: Fix moveChild animation.
Only support animation for view move inside
the same layout.

Also fix animation thread to property support multiple
animation running at once.

Change-Id: I45cad84e7b9f3a4f281c956d32934eb74e807afb
2011-01-09 14:57:20 -08:00
Xavier Ducrohet
b6e53f4812 LayoutLib: add a few misc implementations.
Change-Id: I586f1d5ecc4f254fc04ea1171eb499d06ac592eb
2011-01-07 18:37:49 -08:00
Xavier Ducrohet
46a329244d LayoutLib: finish Typeface and unload them in dispose.
Change-Id: I3a48f84678f62d669d303fc73b041bb3fe5f333b
2011-01-07 18:16:43 -08:00
Xavier Ducrohet
7550ec1d8e LayoutLib: remove fade in/out transition on moveChild.
Change-Id: I69a70ecb165f19feca55fc30a3f48ebea896daa3
2011-01-07 17:14:36 -08:00
Xavier Ducrohet
d7cc1244d7 LayoutLib: fix moveChild again.
Change-Id: Ib69a06e44be1e332f0f43c36c795c86270cb1b71
2011-01-07 16:16:21 -08:00
Xavier Ducrohet
2b9c38ab62 LayoutLib: fix animated moveChild.
The child can only be added to the new viewgroup
after it's been removed from the previous one, which
is delayed if there's an animation.

Change-Id: I9123a2670d0d17b3eb6f8f89085ebab8ca2b800f
2011-01-07 12:49:49 -08:00
Xavier Ducrohet
10af738336 LayoutLib: Finish the matrix delegate.
Change-Id: Ife70a4707c113f4a2aed18e303cb2f221c73db2a
2011-01-06 19:20:03 -08:00
Xavier Ducrohet
a7cac5e054 LayoutLib: fix clipping issues.
There were two issues:
- Graphics2D.setClip only works on rectangular shapes.
  This means doing a setClip on a non rectangular shape should
  basically reset the clip and intersect with the new shape.

- the current clip can be null, so the combineShape method
  must handle it.

Change-Id: Id2cd7475e991d8b533ff2e8850cc2c27663f9e52
2011-01-06 18:13:49 -08:00
Xavier Ducrohet
29c288da52 Cherry-pick 9b53dd9d60a01ddb1307177c296c7b4fd6114753 from master
Change-Id: I670872542feb62c47fe693eb183b19e2eef2b20d
LayoutLib: use new API with log in init method.
2011-01-06 11:11:05 -08:00
Xavier Ducrohet
c226e571fd LayoutLib: Misc javadoc fixes.
Change-Id: Iabe081c20b361b034c2e66b975b8756c0fdcd3d1
2011-01-03 03:28:20 -08:00
Xavier Ducrohet
b44b43b157 LayoutLib: Support Region through delegates.
also finish supporting some clip operation
on the canvas.

Change-Id: I743b9e52a7aa6e9340506f1c904cc1cfbf3ff81f
2010-12-24 00:21:51 -08:00
Xavier Ducrohet
d43909c750 LayoutLib: add support for unsupported drawing modifiers.
DrawFilter, Rasterizer, ColorFilter and MaskFilter
are not supported but we need to provide their
JNI counterparts anyway, to at least display warnings
when they are used.

Also improved the API to query Paint for Shaders
and PathEffects, and clean up some code by
moving asserts into the DelegateManager.

Change-Id: I8942514565d28576d5608c6373bda25d86d42ff2
2010-12-24 00:21:51 -08:00
Xavier Ducrohet
2080534329 LayoutLib: Fix Canvas layer support with 2+ layers
- When drawing is not clipped to the top layers,
  drawing should not happen automatically on all
  existing layers. Instead each layer's flags dictate
  whether drawing should happen on layers beneath, starting
  with the top layer.
- upon restore, the same mechanism is taken. Only blit
  a layer into the layer beneath if it was drawn into
  using the logic above.

Also fixed:
- saveLayer() does not, in fact, always save matrix
  and clip info. The flag dictate this, the same way
  it does in save()
- drawing code didn't properly detect the case of drawing
  into layers if a save() was called after saveLayer().
  Now the code only looks at the layer list which provide
  all the needed info (flags mostly), and doesn't rely
  on mLocalLayer (which is used during restore only now).
- Properly handle HAS_ALPHA_LAYER_SAVE_FLAG (or lack
  thereof) when creating the BufferedImage for the layer.

Change-Id: I2fbbcc0f5d3a3dd208763705bc23e6658fd4e573
2010-12-24 00:21:50 -08:00
Xavier Ducrohet
b1da1afa74 LayoutLib: improve bitmap support.
Change-Id: I703c2bdf51380b54fd5c20b08d3bc74833d9bc6e
2010-12-22 10:30:53 -08:00
Xavier Ducrohet
d38e776a3c LayoutLib: support for layers.
Layers require that drawing methods potentially
draw in more than one bitmaps.

To handle this this patch offers the following:
- move all drawing methods to use Drawable
- Drawables are now handled by GcSnapshot since
  its the one handling the layers
- moved Canvas_Delegate.createCustomGraphics to
  GcSnapshot which does not expose the Graphics2D
  objects anymore so its draw() methods are the only
  way to draw.
- handles creating layers in GcSnapshot.save() and
  blitting them in restore()

Other changes:
- Clean up the create/save API in GcSnapshot
- Fixed drawing bitmaps with alpha and other
  composite modes.

Change-Id: I1e230087493d044a10de71f4b6d29083e3f3bf64
2010-12-22 10:30:53 -08:00
Xavier Ducrohet
63fd87113c LayoutLib: Misc rendering fixes.
- always set up the stroke. Paint may not have the proper
  style when drawing lines. stroke should still be setup.

- Fixed vertical linear gradient. Old code generated
  a gradient ratio of NaN

- Fixed alpha rendering when using shaders. In that
  case the alpha channel from the paint color should be
  used in conjunction with the shader.

- Fixed miter limit. Java expects the value to be multiplied
  by the stroke width

- Fixed support for drawing ALPHA_8 bitmaps. Java2D doesn't
  have bitmaps with only alpha channels, so we keep using
  ARGB bitmaps but when drawing them into a bitmap we erase
  the color information.

Change-Id: I4f04341fc843e3f7dadd1fdbf709b11a4f1e24b9
2010-12-21 10:43:18 -08:00
Xavier Ducrohet
d348b6eaa9 LayoutLib: support for Path and BitmapShader using delegates.
Also created delegates for all missing shader, xfermode
and patheffect classes. Moved the logic of the xfermode,
and patheffects that was in Canvas_Delegate into the
xfermode/patheffect classes, and added support (in all
3 clases) for knowing if the shader/xfermode/patheffect
is actually supported or not. Make use of fidelityWarning
in LayoutLog if they are not.
2010-12-21 10:43:18 -08:00
Xavier Ducrohet
19a021038f LayoutLib: Update layoutlib with revised API.
Change-Id: I78929df621f48e85d9cbefe1f5590f9ce99bbaff
2010-12-21 10:43:17 -08:00
Patrick Dubroy
f890fab5a6 Ensure bitmaps aren't freed while referenced from a display list
Also removes the reference queue finalizers. They aren't necessary
anymore now that Bitmaps are allocated in the heap.
2010-12-20 17:02:15 -08:00
Xavier Ducrohet
cfdc784b6c LayoutLib: replace the stack of Graphics2D with custom snapshots.
The first step is to allow the canvas to save only the matrix or
the clip. Previously, since the graphics2D were created completely
new on each save, everything was saved.

Also allows to set transform/clip on the Canvas when no bitmap
has been set (and therefore no Graphics2D exists).

This is required by BitmapFactory.

Change-Id: I37eff6dde1ca708d58ba317b40e9b3236f3ef3d0
2010-12-15 13:44:03 -08:00
Patrick Dubroy
22ff4ef09f Fix build break due to additional arg in Bitmap ctor 2010-12-14 17:26:27 -08:00
Xavier Ducrohet
d9c64369cf LayoutLib: Fix gradient rendering.
- fully support canvas transform
- fully support shader local transform
- fix repeat/mirror issue in the negative values.

Change-Id: Ib2aa7ade1c2702da4364cbda9a5a3ae72c1d3174
2010-12-14 14:49:55 -08:00
Xavier Ducrohet
f1416e4dff LayoutLib: Misc fix to rendering.
Change-Id: Ia73fab1be3c01e6ce5791973e636e45a0f75ceb6
2010-12-14 12:00:14 -08:00
Xavier Ducrohet
90c6b7e639 LayoutLib: Use the new ninepatch API to suppor density.
LayoutLib now compiles against a prebuilt of ninepatch.

Change-Id: I0a1ca60af90933c171ab3aa456b47f0329df2f55
2010-12-13 19:08:38 -08:00
Xavier Ducrohet
8da36314fd LayoutLib: implement more of Canvas/Paint.
Change-Id: I8e2a7a3bddbce08db5eb641b5075bedd75f7be27
2010-12-13 16:42:01 -08:00
Xavier Ducrohet
6735cffc1d LayoutLib: parsed resources were always set as platform res.
I broke this last week when adding the support for
layout params in moveChild.

Change-Id: Iaaf9b9f685ca301638d4037e98428ea0a00279c9
2010-12-10 16:58:56 -08:00
Xavier Ducrohet
ffb42f6c50 LayoutLib: Adapt to new LayoutLib
API now uses ResourceValue instead of IResourceValue
Capabilities renamed Capability

Change-Id: Ia5d2b6c8d536e020a1f5496fb2285f67fc4346c4
2010-12-10 11:40:27 -08:00
Xavier Ducrohet
8d74c978bb LayoutLib: explicitely override PropertyValuesHolder native code.
Change-Id: Ic7dd9efc990d01b20db144117cb11eb130349048
2010-12-07 12:10:51 -08:00
Xavier Ducrohet
864f33a9f8 Merge "LayoutLib: Update font object when text info changes in paint delegate" 2010-12-06 11:32:43 -08:00
Xavier Ducrohet
b5ddf041d6 LayoutLib: Update font object when text info changes in paint delegate
Change-Id: I6ff7e1ec4513918256aee99acc5ea298a5fdb8a8
2010-12-06 11:12:47 -08:00
Xavier Ducrohet
168677c9e2 LayoutLib: Fix logging.
- Use the new logging API
- remove log object reference everywhere but in Bridge
- all logging code accesses Bridge.getLog()
- prepareScene sets the current scene log object in Bridge.

Change-Id: Ib0517ccd6454c4baf218b6baa978a126f91671e7
2010-12-06 10:11:44 -08:00
Xavier Ducrohet
e1179ea065 LayoutLib: Animation support in insert/move/removeChild actions.
Also update to use the new SceneResult API.

Change-Id: Iaac6df0c250fbefc8758310c37e0cf47cae6875d
2010-12-03 11:50:36 -08:00
Xavier Ducrohet
01811aa862 LayoutLib: Create new layoutparams when moving a child
Change-Id: Ie2183490e8d26ef194030a9d87fe7745f24f1d83
2010-12-02 18:58:25 -08:00
Xavier Ducrohet
3c78f2de35 LayoutLib: Update to use the new moveChild API.
Also, return supported capabilities.

Change-Id: I824120d50f2865a667dc6c81d455ae19321966b6
2010-12-02 17:49:11 -08:00
Xavier Ducrohet
c8aec064f9 Layoutlib: update with new add/movechild API.
Change-Id: I33e3a07cd7db7fe996d1f52b84b4b3bf21065a51
2010-12-02 12:26:23 -08:00
Xavier Ducrohet
9eb6d412af LayoutLib: Reuse canvas when possible.
Also moved the prepare/cleanupThread methods to Bridge
as they are not really specific to the scene anymore.

Change-Id: I7b93821913ce4d2fcbe3d8be489be6533ff87e57
2010-12-02 10:58:19 -08:00
Xavier Ducrohet
c14e7dd8ba LayoutLib: implement insert/move/removeChild.
Change-Id: I1c05ff4dc80e5ee4ea67d322acaf9c94276f84e1
2010-12-01 16:14:38 -08:00
Xavier Ducrohet
30c77d689e LayoutLib: get AWT image from new image factory.
Change-Id: Ib760af8a77fefac2571b8b4e48b4728e158aab2f
2010-11-29 21:10:24 -08:00
Xavier Ducrohet
2eea6fab1c Layoutlib: Animation support.
New locking mechanims to prevent concurrent renderings.

There's now a thread specific prepareThread() method (only
prepares the looper) and its associated cleanupThread().

For the rendering itself, acquire must be called before doing
any type of Android specific work on the scene (inflate or rendering)
After instantiation, init() must be called, which also acts as acquire.

Added a lot of checks to make sure method aren't called without
acquire or if scenes try to be rendered while acquire was called
from the same thread but on another scene.

Animation implementation:
- Handler delegate to use our own queue (since the animation runs
  through handler messages). This uses a callback to process
  the message. This callback is per-thread and only used in
  animation threads.
- SystemClock delegate to provide clock implementation.
- AnimationThread to handle playing the animation and calling back
  to the animation listener.

Change-Id: Ia39aba7ed476759df1da3200e413fe3e92590d15
2010-11-29 12:05:43 -08:00
Xavier Ducrohet
2d56b273ef Layoutlib: use default nine patch classes.
Move away from using our own implementation of NinePatchDrawable.
Now use native delegate for a few methods of NinePatch.

The byte[] used to describe the 9-patch chunk is entirely controlled
by the delegate. Therefore, while the default version (JNI) use the
array as a representation of a C struct, this version uses the array
as a serialized version of NinePatchChunk.

A cache mechanism using SoftReferences allows us to not deserialize
the array every time rendering needs to access the chunk itself.

The Bridge-level cache mechanism for bitmaps and nine-patches as
changed. Since the new nine-patches doesn't hold the bitmap
data anymore (it's stored in a normal Android bitmap which
is cached itself through the cache), then the nine-patch cache
has been changed to only contain the nine patch chunk.

Also initialize the canvas with the display metrics to prepare
for correct scaling when density of the assets don't match the target
density.

Still to come: actual density support in the 9-patch drawing code.

Change-Id: Ibefcccf4432e1986e8436e0c41a0107741593536
2010-11-23 11:54:25 -08:00
Xavier Ducrohet
9223b6737c Layoutlib: support for editing embedded layouts.
When Resources.getLayout(int) is called to return a parser
for an embedded layout, this queries the current parser for
a custom parser (Eclipse will provide one on top of the current
XML model being edited)

Change-Id: Ia9e837358f67daed0a835e1b3f4f50c0516ceee9
2010-11-19 16:17:27 -08:00
Xavier Ducrohet
fb25cae191 LayoutLib: use the new expand API.
Change-Id: I248de70ebe97aa6fb1cbcb5b6572a4a46c5ca1ba
2010-11-19 14:27:37 -08:00
Xavier Ducrohet
d73868859b LayoutLib: fix some tests
Change-Id: Iacd641e2fac663ff12fe2a08ba093c4eaa2e8862
2010-11-19 12:53:20 -08:00
Xavier Ducrohet
55acd60be3 Layoutlib: support viewkey in include nodes.
When an include tag is parsed, the custom bridge
code never has access to both parsers at the same
time.
The child parser is created out of an in (representing
the layout id), and the code inflating the content of
the include layout doesn't see the parent parser either.

This changeset adds a parser stack in the BridgeContext
in order to allow access to the parent parser when setting
the viewkey. This is only used if the current parser depth
is 1 (top node), as we only want to set the include
node to the top node of the included layout.

Change-Id: I2ac3b72a0c84a269d9019f44f98cbc0b615ab959
2010-11-18 22:17:14 -08:00
Xavier Ducrohet
755b46d597 Layoutlib: use int[] wrapper to use as map keys.
This fixes the SlidingDrawer that failed to load.

For some reason, in case of the SlidingDrawer, when the constructor
uses android.R.styleable.SlidingDrawer it's the same values but not
the same instance as the array read from android.R through reflection.

So what works for all other widgets, and has worked since the very first
layoutlib isn't working anymore, and we'll now have to use a wrapper
similarly to what we use in ADT in the project callback.

We should probably provide a single int[] wrapper class in layoutlib
API for all to use.

Change-Id: I4d7d038540f8a24541a588696f1059a020b589e5
2010-11-18 19:51:30 -08:00