Add translation and scale to the group tag and related tests.
bug:15288554 Change-Id: Iebe176d0a9c2c566d1910674a068e65e15569829
This commit is contained in:
@ -1243,6 +1243,8 @@ package android {
|
||||
field public static final int transition = 16843743; // 0x10103df
|
||||
field public static final int transitionGroup = 16843803; // 0x101041b
|
||||
field public static final int transitionOrdering = 16843744; // 0x10103e0
|
||||
field public static final int translateX = 16843869; // 0x101045d
|
||||
field public static final int translateY = 16843870; // 0x101045e
|
||||
field public static final int translationX = 16843554; // 0x1010322
|
||||
field public static final int translationY = 16843555; // 0x1010323
|
||||
field public static final int translationZ = 16843796; // 0x1010414
|
||||
|
@ -4790,6 +4790,14 @@
|
||||
<attr name="pivotX" />
|
||||
<!-- The Y coordinate of the center of rotation of a group -->
|
||||
<attr name="pivotY" />
|
||||
<!-- The amount to translate the group on X coordinate -->
|
||||
<attr name="translateX" format="float"/>
|
||||
<!-- The amount to translate the group on Y coordinate -->
|
||||
<attr name="translateY" format="float"/>
|
||||
<!-- The amount to scale the group on X coordinate -->
|
||||
<attr name="scaleX" />
|
||||
<!-- The amount to scale the group on X coordinate -->
|
||||
<attr name="scaleY" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- Defines the path used in Vector Drawables. -->
|
||||
|
@ -2180,6 +2180,8 @@
|
||||
<public type="attr" name="paddingMode" />
|
||||
<public type="attr" name="layout_rowWeight" />
|
||||
<public type="attr" name="layout_columnWeight" />
|
||||
<public type="attr" name="translateX" />
|
||||
<public type="attr" name="translateY" />
|
||||
|
||||
<public-padding type="dimen" name="l_resource_pad" end="0x01050010" />
|
||||
|
||||
|
@ -58,7 +58,23 @@ import java.util.HashMap;
|
||||
* The size is defined using the attributes <code>android:viewportHeight</code>
|
||||
* <code>android:viewportWidth</code></dd>
|
||||
* <dt><code><group></code></dt>
|
||||
* <dd>Defines a group of paths or subgroups, plus transformation information.</dd>
|
||||
* <dd>Defines a group of paths or subgroups, plus transformation information.
|
||||
* The transformations are defined in the same coordinates as the viewport.
|
||||
* And the transformations are applied in the order of scale, rotate then translate. </dd>
|
||||
* <dt><code>android:rotation</code>
|
||||
* <dd>The degrees of rotation of the group.</dd></dt>
|
||||
* <dt><code>android:pivotX</code>
|
||||
* <dd>The X coordinate of the pivot for the scale and rotation of the group</dd></dt>
|
||||
* <dt><code>android:pivotY</code>
|
||||
* <dd>The Y coordinate of the pivot for the scale and rotation of the group</dd></dt>
|
||||
* <dt><code>android:scaleX</code>
|
||||
* <dd>The amount of scale on the X Coordinate</dd></dt>
|
||||
* <dt><code>android:scaleY</code>
|
||||
* <dd>The amount of scale on the Y coordinate</dd></dt>
|
||||
* <dt><code>android:translateX</code>
|
||||
* <dd>The amount of translation on the X coordinate</dd></dt>
|
||||
* <dt><code>android:translateY</code>
|
||||
* <dd>The amount of translation on the Y coordinate</dd></dt>
|
||||
* <dt><code><path></code></dt>
|
||||
* <dd>Defines paths to be drawn.
|
||||
* <dl>
|
||||
@ -76,12 +92,6 @@ import java.util.HashMap;
|
||||
* <dd>The width a path stroke</dd></dt>
|
||||
* <dt><code>android:strokeOpacity</code>
|
||||
* <dd>The opacity of a path stroke</dd></dt>
|
||||
* <dt><code>android:rotation</code>
|
||||
* <dd>The amount to rotation the path stroke.</dd></dt>
|
||||
* <dt><code>android:pivotX</code>
|
||||
* <dd>The X coordinate of the center of rotation of a path</dd></dt>
|
||||
* <dt><code>android:pivotY</code>
|
||||
* <dd>The Y coordinate of the center of rotation of a path</dd></dt>
|
||||
* <dt><code>android:fillOpacity</code>
|
||||
* <dd>The opacity to fill the path with</dd></dt>
|
||||
* <dt><code>android:trimPathStart</code>
|
||||
@ -457,7 +467,13 @@ public class VectorDrawable extends Drawable {
|
||||
|
||||
mMatrix.reset();
|
||||
|
||||
mMatrix.postRotate(vGroup.mRotate, vGroup.mPivotX, vGroup.mPivotY);
|
||||
// The order we apply is the same as the
|
||||
// RenderNode.cpp::applyViewPropertyTransforms().
|
||||
mMatrix.postTranslate(-vGroup.mPivotX, -vGroup.mPivotY);
|
||||
mMatrix.postScale(vGroup.mScaleX, vGroup.mScaleY);
|
||||
mMatrix.postRotate(vGroup.mRotate, 0, 0);
|
||||
mMatrix.postTranslate(vGroup.mTranslateX + vGroup.mPivotX, vGroup.mTranslateY + vGroup.mPivotY);
|
||||
|
||||
mMatrix.postScale(scale, scale, mViewportWidth / 2f, mViewportHeight / 2f);
|
||||
mMatrix.postTranslate(w / 2f - mViewportWidth / 2f, h / 2f - mViewportHeight / 2f);
|
||||
|
||||
@ -577,6 +593,10 @@ public class VectorDrawable extends Drawable {
|
||||
private float mRotate = 0;
|
||||
private float mPivotX = 0;
|
||||
private float mPivotY = 0;
|
||||
private float mScaleX = 1;
|
||||
private float mScaleY = 1;
|
||||
private float mTranslateX = 0;
|
||||
private float mTranslateY = 0;
|
||||
|
||||
private int[] mThemeAttrs;
|
||||
|
||||
@ -597,6 +617,10 @@ public class VectorDrawable extends Drawable {
|
||||
mRotate = a.getFloat(R.styleable.VectorDrawableGroup_rotation, mRotate);
|
||||
mPivotX = a.getFloat(R.styleable.VectorDrawableGroup_pivotX, mPivotX);
|
||||
mPivotY = a.getFloat(R.styleable.VectorDrawableGroup_pivotY, mPivotY);
|
||||
mScaleX = a.getFloat(R.styleable.VectorDrawableGroup_scaleX, mScaleX);
|
||||
mScaleY = a.getFloat(R.styleable.VectorDrawableGroup_scaleY, mScaleY);
|
||||
mTranslateX = a.getFloat(R.styleable.VectorDrawableGroup_translateX, mTranslateX);
|
||||
mTranslateY = a.getFloat(R.styleable.VectorDrawableGroup_translateY, mTranslateY);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@ -620,6 +644,22 @@ public class VectorDrawable extends Drawable {
|
||||
mPivotY = a.getFloat(R.styleable.VectorDrawableGroup_pivotY, mPivotY);
|
||||
}
|
||||
|
||||
if (themeAttrs == null || themeAttrs[R.styleable.VectorDrawableGroup_scaleX] == 0) {
|
||||
mScaleX = a.getFloat(R.styleable.VectorDrawableGroup_scaleX, mScaleX);
|
||||
}
|
||||
|
||||
if (themeAttrs == null || themeAttrs[R.styleable.VectorDrawableGroup_scaleY] == 0) {
|
||||
mScaleY = a.getFloat(R.styleable.VectorDrawableGroup_scaleY, mScaleY);
|
||||
}
|
||||
|
||||
if (themeAttrs == null || themeAttrs[R.styleable.VectorDrawableGroup_translateX] == 0) {
|
||||
mTranslateX = a.getFloat(R.styleable.VectorDrawableGroup_translateX, mTranslateX);
|
||||
}
|
||||
|
||||
if (themeAttrs == null || themeAttrs[R.styleable.VectorDrawableGroup_translateY] == 0) {
|
||||
mTranslateY = a.getFloat(R.styleable.VectorDrawableGroup_translateY, mTranslateY);
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="1" >
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<size
|
||||
android:height="48dp"
|
||||
|
@ -25,7 +25,24 @@
|
||||
|
||||
<group>
|
||||
<path
|
||||
android:name="house"
|
||||
android:name="background1"
|
||||
android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z"
|
||||
android:fill="#FF000000"/>
|
||||
<path
|
||||
android:name="background2"
|
||||
android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z"
|
||||
android:fill="#FF000000"/>
|
||||
</group>
|
||||
<group
|
||||
android:pivotX="100"
|
||||
android:pivotY="100"
|
||||
android:rotation="90"
|
||||
android:scaleX="0.75"
|
||||
android:scaleY="0.5"
|
||||
android:translateX="0.0"
|
||||
android:translateY="100.0">
|
||||
<path
|
||||
android:name="twoLines"
|
||||
android:pathData="M 100,10 v 90 M 10,100 h 90"
|
||||
android:stroke="#FF00FF00"
|
||||
android:strokeWidth="10" />
|
||||
|
51
tests/VectorDrawableTest/res/drawable/vector_drawable21.xml
Normal file
51
tests/VectorDrawableTest/res/drawable/vector_drawable21.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<!--
|
||||
Copyright (C) 2014 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<size
|
||||
android:height="64dp"
|
||||
android:width="64dp" />
|
||||
|
||||
<viewport
|
||||
android:viewportHeight="200"
|
||||
android:viewportWidth="200" />
|
||||
|
||||
<group>
|
||||
<path
|
||||
android:name="background1"
|
||||
android:pathData="M 0,0 l 100,0 l 0, 100 l -100, 0 z"
|
||||
android:fill="#FF000000"/>
|
||||
<path
|
||||
android:name="background2"
|
||||
android:pathData="M 100,100 l 100,0 l 0, 100 l -100, 0 z"
|
||||
android:fill="#FF000000"/>
|
||||
</group>
|
||||
<group
|
||||
android:pivotX="0"
|
||||
android:pivotY="0"
|
||||
android:rotation="90"
|
||||
android:scaleX="0.75"
|
||||
android:scaleY="0.5"
|
||||
android:translateX="100.0"
|
||||
android:translateY="100.0">
|
||||
<path
|
||||
android:name="twoLines"
|
||||
android:pathData="M 100,10 v 90 M 10,100 h 90"
|
||||
android:stroke="#FF00FF00"
|
||||
android:strokeWidth="10" />
|
||||
</group>
|
||||
|
||||
</vector>
|
@ -47,7 +47,8 @@ public class VectorDrawablePerformance extends Activity {
|
||||
R.drawable.vector_drawable17,
|
||||
R.drawable.vector_drawable18,
|
||||
R.drawable.vector_drawable19,
|
||||
R.drawable.vector_drawable20
|
||||
R.drawable.vector_drawable20,
|
||||
R.drawable.vector_drawable21
|
||||
};
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user