Fix clipping issue in StackView.
Change-Id: I7ec28f25c3993a2bd7ef6399ba1923839d239905
@@ -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;
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,15 @@
|
||||
</intent-filter>
|
||||
</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">
|
||||
@@ -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"
|
||||
|
||||
19
tests/HwAccelerationTest/res/anim/fade_in.xml
Normal file
@@ -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" />
|
||||
19
tests/HwAccelerationTest/res/anim/fade_out.xml
Normal file
@@ -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" />
|
||||
@@ -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>
|
||||
BIN
tests/HwAccelerationTest/res/drawable-hdpi/appwidget_bg.9.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
BIN
tests/HwAccelerationTest/res/drawable-hdpi/green_gradient.9.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
tests/HwAccelerationTest/res/drawable-hdpi/widget_header.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
tests/HwAccelerationTest/res/drawable-hdpi/widget_title_bg.9.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
@@ -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>
|
||||
BIN
tests/HwAccelerationTest/res/drawable/appwidget_bg.9.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
tests/HwAccelerationTest/res/drawable/appwidget_bg_focus.9.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
tests/HwAccelerationTest/res/drawable/appwidget_bg_press.9.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
tests/HwAccelerationTest/res/drawable/green_gradient.9.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
tests/HwAccelerationTest/res/drawable/widget_header.png
Normal file
|
After Width: | Height: | Size: 6.0 KiB |
BIN
tests/HwAccelerationTest/res/drawable/widget_title_bg.9.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
39
tests/HwAccelerationTest/res/layout/flipper_item.xml
Normal file
@@ -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>
|
||||
46
tests/HwAccelerationTest/res/layout/widget.xml
Normal file
@@ -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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||