diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 46f7db484b45a..5c4a15643827a 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -34,8 +34,6 @@ import android.util.AttributeSet; import android.util.Log; import android.view.RemotableViewMethod; import android.view.View; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityManager; import android.widget.RemoteViews.RemoteView; diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java index 7e01506378509..1f5b79087c3b0 100644 --- a/core/java/android/widget/StackView.java +++ b/core/java/android/widget/StackView.java @@ -16,10 +16,9 @@ package android.widget; -import android.animation.PropertyValuesHolder; import android.animation.ObjectAnimator; +import android.animation.PropertyValuesHolder; import android.content.Context; -import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BlurMaskFilter; import android.graphics.Canvas; @@ -31,15 +30,12 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.TableMaskFilter; import android.util.AttributeSet; -import android.util.DisplayMetrics; import android.util.Log; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; -import android.view.View.MeasureSpec; -import android.view.ViewGroup.LayoutParams; import android.view.animation.LinearInterpolator; import android.widget.RemoteViews.RemoteView; @@ -54,13 +50,14 @@ public class StackView extends AdapterViewAnimator { /** * Default animation parameters */ - private final int DEFAULT_ANIMATION_DURATION = 400; - private final int MINIMUM_ANIMATION_DURATION = 50; + private static final int DEFAULT_ANIMATION_DURATION = 400; + private static final int MINIMUM_ANIMATION_DURATION = 50; /** * Parameters effecting the perspective visuals */ private static float PERSPECTIVE_SHIFT_FACTOR = 0.12f; + @SuppressWarnings({"FieldCanBeLocal"}) private static float PERSPECTIVE_SCALE_FACTOR = 0.35f; /** @@ -182,7 +179,6 @@ public class StackView extends AdapterViewAnimator { // Slide item in view.setVisibility(VISIBLE); - LayoutParams lp = (LayoutParams) view.getLayoutParams(); int duration = Math.round(mStackSlider.getDurationForNeutralPosition(mYVelocity)); StackSlider animationSlider = new StackSlider(mStackSlider); @@ -195,8 +191,6 @@ public class StackView extends AdapterViewAnimator { pa.start(); } else if (fromIndex == mNumActiveViews - 2 && toIndex == mNumActiveViews - 1) { // Slide item out - LayoutParams lp = (LayoutParams) view.getLayoutParams(); - int duration = Math.round(mStackSlider.getDurationForOffscreenPosition(mYVelocity)); StackSlider animationSlider = new StackSlider(mStackSlider); @@ -730,10 +724,14 @@ public class StackView extends AdapterViewAnimator { return 0; } + // Used for animations + @SuppressWarnings({"UnusedDeclaration"}) public float getYProgress() { return mYProgress; } + // Used for animations + @SuppressWarnings({"UnusedDeclaration"}) public float getXProgress() { return mXProgress; } diff --git a/libs/hwui/Matrix.cpp b/libs/hwui/Matrix.cpp index 5502e668d33a0..1a0fcf4b0bd2c 100644 --- a/libs/hwui/Matrix.cpp +++ b/libs/hwui/Matrix.cpp @@ -87,7 +87,7 @@ void Matrix4::load(const SkMatrix& v) { data[kScaleZ] = 1.0f; - mSimpleMatrix = (v.getType() <= SkMatrix::kScale_Mask); + mSimpleMatrix = (v.getType() <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)); } void Matrix4::copyTo(SkMatrix& v) const { diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 81fa1ea521b24..0a95408ab2638 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -597,8 +597,10 @@ void OpenGLRenderer::getMatrix(SkMatrix* matrix) { } void OpenGLRenderer::concatMatrix(SkMatrix* matrix) { - mat4 m(*matrix); - mSnapshot->transform->multiply(m); + SkMatrix transform; + mSnapshot->transform->copyTo(transform); + transform.preConcat(*matrix); + mSnapshot->transform->load(transform); } /////////////////////////////////////////////////////////////////////////////// @@ -606,7 +608,8 @@ void OpenGLRenderer::concatMatrix(SkMatrix* matrix) { /////////////////////////////////////////////////////////////////////////////// void OpenGLRenderer::setScissorFromClip() { - const Rect& clip = *mSnapshot->clipRect; + Rect clip(*mSnapshot->clipRect); + clip.snapToPixelBoundaries(); glScissor(clip.left, mSnapshot->height - clip.bottom, clip.getWidth(), clip.getHeight()); } diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index df3c3ed15dfa8..196b0eb5c6451 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -39,6 +39,15 @@ + + + + + + + @@ -48,6 +57,16 @@ + + + + + + + + + + diff --git a/tests/HwAccelerationTest/res/anim/fade_out.xml b/tests/HwAccelerationTest/res/anim/fade_out.xml new file mode 100644 index 0000000000000..9832c322ff659 --- /dev/null +++ b/tests/HwAccelerationTest/res/anim/fade_out.xml @@ -0,0 +1,19 @@ + + + + diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_background.xml b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_background.xml new file mode 100644 index 0000000000000..abbb9e69af94b --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_background.xml @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png new file mode 100644 index 0000000000000..80491912d80b1 Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png new file mode 100644 index 0000000000000..c81f67582110a Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png new file mode 100644 index 0000000000000..d060b77556bb6 Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png new file mode 100644 index 0000000000000..a535678ab531f Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/widget_header.png b/tests/HwAccelerationTest/res/drawable-hdpi/widget_header.png new file mode 100644 index 0000000000000..cd9ec4488486e Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable-hdpi/widget_header.png differ diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png new file mode 100644 index 0000000000000..79615c237ffeb Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_background.xml b/tests/HwAccelerationTest/res/drawable/appwidget_background.xml new file mode 100644 index 0000000000000..abbb9e69af94b --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/appwidget_background.xml @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_bg.9.png b/tests/HwAccelerationTest/res/drawable/appwidget_bg.9.png new file mode 100644 index 0000000000000..80491912d80b1 Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable/appwidget_bg.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_bg_focus.9.png b/tests/HwAccelerationTest/res/drawable/appwidget_bg_focus.9.png new file mode 100644 index 0000000000000..c81f67582110a Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable/appwidget_bg_focus.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_bg_press.9.png b/tests/HwAccelerationTest/res/drawable/appwidget_bg_press.9.png new file mode 100644 index 0000000000000..d060b77556bb6 Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable/appwidget_bg_press.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable/green_gradient.9.png b/tests/HwAccelerationTest/res/drawable/green_gradient.9.png new file mode 100644 index 0000000000000..a535678ab531f Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable/green_gradient.9.png differ diff --git a/tests/HwAccelerationTest/res/drawable/widget_header.png b/tests/HwAccelerationTest/res/drawable/widget_header.png new file mode 100644 index 0000000000000..0297dd109bdf3 Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable/widget_header.png differ diff --git a/tests/HwAccelerationTest/res/drawable/widget_title_bg.9.png b/tests/HwAccelerationTest/res/drawable/widget_title_bg.9.png new file mode 100644 index 0000000000000..79615c237ffeb Binary files /dev/null and b/tests/HwAccelerationTest/res/drawable/widget_title_bg.9.png differ diff --git a/tests/HwAccelerationTest/res/layout/flipper_item.xml b/tests/HwAccelerationTest/res/layout/flipper_item.xml new file mode 100644 index 0000000000000..43a7bbfc2deb3 --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/flipper_item.xml @@ -0,0 +1,39 @@ + + + + + + + + + + \ No newline at end of file diff --git a/tests/HwAccelerationTest/res/layout/widget.xml b/tests/HwAccelerationTest/res/layout/widget.xml new file mode 100644 index 0000000000000..503facedbf282 --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/widget.xml @@ -0,0 +1,46 @@ + + + + + + + + + + diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/Bitmaps3dActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/Bitmaps3dActivity.java new file mode 100644 index 0000000000000..baa1cb9168645 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/Bitmaps3dActivity.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2010 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. + */ + +package com.android.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Matrix; +import android.graphics.Paint; +import android.os.Bundle; +import android.view.Gravity; +import android.view.View; +import android.widget.FrameLayout; + +@SuppressWarnings({"UnusedDeclaration"}) +public class Bitmaps3dActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + final BitmapsView view = new BitmapsView(this); + final FrameLayout layout = new FrameLayout(this); + layout.addView(view, new FrameLayout.LayoutParams(800, 400, Gravity.CENTER)); + view.setRotationX(-35.0f); + setContentView(layout); + } + + static class BitmapsView extends View { + private final Paint mBitmapPaint; + private final Bitmap mBitmap1; + private Matrix mMatrix; + + BitmapsView(Context c) { + super(c); + + mBitmap1 = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1); + mBitmapPaint = new Paint(); + + mMatrix = new Matrix(); + mMatrix.setScale(2.0f, 2.0f); + mMatrix.preTranslate(0.0f, -10.0f); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + + canvas.drawColor(0xffffffff); + + canvas.save(); + canvas.translate(120.0f, 50.0f); + + canvas.concat(mMatrix); + canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBitmapPaint); + + canvas.restore(); + } + } +} diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ViewFlipperActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewFlipperActivity.java new file mode 100644 index 0000000000000..0e244fc0a31b0 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewFlipperActivity.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010 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. + */ + +package com.android.test.hwui; + +import android.app.Activity; +import android.os.Bundle; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.ViewFlipper; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ViewFlipperActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + final LayoutInflater inflater = getLayoutInflater(); + final View widget = inflater.inflate(R.layout.widget, null); + widget.setLayoutParams(new FrameLayout.LayoutParams(180, 180, Gravity.CENTER)); + + ViewFlipper flipper = (ViewFlipper) widget.findViewById(R.id.flipper); + + View view = inflater.inflate(R.layout.flipper_item, flipper, false); + flipper.addView(view); + ((ImageView) view.findViewById(R.id.widget_image)).setImageResource(R.drawable.sunset1); + ((TextView) view.findViewById(R.id.widget_text)).setText("This is a long line of text, " + + "enjoy the wrapping and drawing"); + + view = inflater.inflate(R.layout.flipper_item, flipper, false); + flipper.addView(view); + ((ImageView) view.findViewById(R.id.widget_image)).setImageResource(R.drawable.sunset3); + ((TextView) view.findViewById(R.id.widget_text)).setText("Another very long line of text, " + + "enjoy the wrapping and drawing"); + + FrameLayout layout = new FrameLayout(this); + layout.addView(widget); + + setContentView(layout); + } +}