Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9ad54e8 authored by ztenghui's avatar ztenghui Committed by Android (Google) Code Review
Browse files

Merge "Add translation and scale to the group tag and related tests."

parents 33787172 452f6ece
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
+8 −0
Original line number Diff line number Diff line
@@ -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. -->
+2 −0
Original line number Diff line number Diff line
@@ -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" />

+48 −8
Original line number Diff line number Diff line
@@ -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>&lt;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>&lt;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();
        }

+1 −2
Original line number Diff line number Diff line
@@ -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"
Loading