diff options
| author | Romain Guy <romainguy@google.com> | 2010-10-15 14:00:16 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-10-15 14:00:17 -0700 |
| commit | 10aca41e51934822dc492cb69b69cef37f42ad42 (patch) | |
| tree | a9954fca3fd337929a7d768d48a1287b3332d090 | |
| parent | 97d88927f28226403ff7e5befe1a5486b5fc8725 (diff) | |
| parent | e5ebcb0107a939395e03592fd44c746cd09e311d (diff) | |
| download | frameworks_base-10aca41e51934822dc492cb69b69cef37f42ad42.zip frameworks_base-10aca41e51934822dc492cb69b69cef37f42ad42.tar.gz frameworks_base-10aca41e51934822dc492cb69b69cef37f42ad42.tar.bz2 | |
Merge "Fix clipping issue in StackView."
25 files changed, 333 insertions, 16 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 46f7db4..5c4a156 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 7e01506..1f5b790 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 5502e66..1a0fcf4 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 81fa1ea..0a95408 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 df3c3ed..196b0eb 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -40,6 +40,15 @@ </activity> <activity + android:name="Bitmaps3dActivity" + android:label="_Bitmaps3d"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <activity android:name="LabelsActivity" android:label="_Labels"> <intent-filter> @@ -48,6 +57,16 @@ </intent-filter> </activity> + <activity + android:name="ViewFlipperActivity" + android:label="_ViewFlipper" + android:theme="@android:style/Theme.Translucent.NoTitleBar"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + <activity android:name="ResizeActivity" android:label="_Resize" diff --git a/tests/HwAccelerationTest/res/anim/fade_in.xml b/tests/HwAccelerationTest/res/anim/fade_in.xml new file mode 100644 index 0000000..34310f5 --- /dev/null +++ b/tests/HwAccelerationTest/res/anim/fade_in.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<alpha xmlns:android="http://schemas.android.com/apk/res/android" + android:fromAlpha="0.0" android:toAlpha="1.0" + android:duration="600" /> diff --git a/tests/HwAccelerationTest/res/anim/fade_out.xml b/tests/HwAccelerationTest/res/anim/fade_out.xml new file mode 100644 index 0000000..9832c32 --- /dev/null +++ b/tests/HwAccelerationTest/res/anim/fade_out.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<alpha xmlns:android="http://schemas.android.com/apk/res/android" + android:fromAlpha="1.0" android:toAlpha="0.0" + android:duration="600" /> 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 0000000..abbb9e6 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_background.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 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. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_window_focused="false" android:drawable="@drawable/appwidget_bg" /> + <item android:state_pressed="true" android:drawable="@drawable/appwidget_bg_press" /> + <item android:state_focused="true" android:drawable="@drawable/appwidget_bg_focus" /> + <item android:drawable="@drawable/appwidget_bg" /> +</selector> diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png Binary files differnew file mode 100644 index 0000000..8049191 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png Binary files differnew file mode 100644 index 0000000..c81f675 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_focus.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png Binary files differnew file mode 100644 index 0000000..d060b77 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg_press.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png Binary files differnew file mode 100644 index 0000000..a535678 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/widget_header.png b/tests/HwAccelerationTest/res/drawable-hdpi/widget_header.png Binary files differnew file mode 100644 index 0000000..cd9ec44 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/widget_header.png diff --git a/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png b/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png Binary files differnew file mode 100644 index 0000000..79615c2 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_background.xml b/tests/HwAccelerationTest/res/drawable/appwidget_background.xml new file mode 100644 index 0000000..abbb9e6 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/appwidget_background.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 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. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_window_focused="false" android:drawable="@drawable/appwidget_bg" /> + <item android:state_pressed="true" android:drawable="@drawable/appwidget_bg_press" /> + <item android:state_focused="true" android:drawable="@drawable/appwidget_bg_focus" /> + <item android:drawable="@drawable/appwidget_bg" /> +</selector> diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_bg.9.png b/tests/HwAccelerationTest/res/drawable/appwidget_bg.9.png Binary files differnew file mode 100644 index 0000000..8049191 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/appwidget_bg.9.png diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_bg_focus.9.png b/tests/HwAccelerationTest/res/drawable/appwidget_bg_focus.9.png Binary files differnew file mode 100644 index 0000000..c81f675 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/appwidget_bg_focus.9.png diff --git a/tests/HwAccelerationTest/res/drawable/appwidget_bg_press.9.png b/tests/HwAccelerationTest/res/drawable/appwidget_bg_press.9.png Binary files differnew file mode 100644 index 0000000..d060b77 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/appwidget_bg_press.9.png diff --git a/tests/HwAccelerationTest/res/drawable/green_gradient.9.png b/tests/HwAccelerationTest/res/drawable/green_gradient.9.png Binary files differnew file mode 100644 index 0000000..a535678 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/green_gradient.9.png diff --git a/tests/HwAccelerationTest/res/drawable/widget_header.png b/tests/HwAccelerationTest/res/drawable/widget_header.png Binary files differnew file mode 100644 index 0000000..0297dd1 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/widget_header.png diff --git a/tests/HwAccelerationTest/res/drawable/widget_title_bg.9.png b/tests/HwAccelerationTest/res/drawable/widget_title_bg.9.png Binary files differnew file mode 100644 index 0000000..79615c2 --- /dev/null +++ b/tests/HwAccelerationTest/res/drawable/widget_title_bg.9.png diff --git a/tests/HwAccelerationTest/res/layout/flipper_item.xml b/tests/HwAccelerationTest/res/layout/flipper_item.xml new file mode 100644 index 0000000..43a7bbf --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/flipper_item.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/widget_asset" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:focusable="true"> + + <ImageView android:id="@+id/widget_image" + android:layout_width="91dip" + android:layout_height="61dip" + android:layout_margin="8dip" + android:background="@android:color/white" /> + + <TextView android:id="@+id/widget_text" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_toRightOf="@id/widget_image" + android:padding="6dip" + android:textSize="12sp" + android:textColor="@android:color/black" + android:fadingEdge="vertical" + android:fadingEdgeLength="30dip" /> + +</RelativeLayout>
\ 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 0000000..503face --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/widget.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/widget_root" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:focusable="true" + android:background="@drawable/appwidget_background"> + + <ImageView + android:id="@+id/widget_top" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:background="@drawable/widget_title_bg" + android:padding="6dip" + android:src="@drawable/widget_header" + android:scaleType="center" /> + + <ViewFlipper + android:id="@+id/flipper" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:addStatesFromChildren="true" + android:flipInterval="2000" + android:autoStart="true" + android:inAnimation="@anim/fade_in" + android:outAnimation="@anim/fade_out" + android:background="@drawable/green_gradient" + android:measureAllChildren="false" /> + +</LinearLayout> 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 0000000..baa1cb9 --- /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 0000000..0e244fc --- /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); + } +} |
