summaryrefslogtreecommitdiffstats
path: root/tests/HwAccelerationTest
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2014-05-05 19:09:33 -0700
committerChris Craik <ccraik@google.com>2014-05-15 16:36:12 -0700
commitdeeda3d337aed1eee218b89a7aba5992ced371f0 (patch)
tree15e13e84727baebce58b735e34ef5d198fd84389 /tests/HwAccelerationTest
parentfe4c1e225d147fe9cb5d7c121b7d6d11a312844e (diff)
downloadframeworks_base-deeda3d337aed1eee218b89a7aba5992ced371f0.zip
frameworks_base-deeda3d337aed1eee218b89a7aba5992ced371f0.tar.gz
frameworks_base-deeda3d337aed1eee218b89a7aba5992ced371f0.tar.bz2
Round rect outline clipping
Change-Id: Iee9cf4f719f6f1917507b69189ad114fa365917b
Diffstat (limited to 'tests/HwAccelerationTest')
-rw-r--r--tests/HwAccelerationTest/AndroidManifest.xml9
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/ClipOutlineActivity.java87
2 files changed, 96 insertions, 0 deletions
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 3e9cf43..db802c5 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -216,6 +216,15 @@
</activity>
<activity
+ android:name="ClipOutlineActivity"
+ android:label="Clip/Outline">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="com.android.test.hwui.TEST" />
+ </intent-filter>
+ </activity>
+
+ <activity
android:name="DisplayListLayersActivity"
android:label="Layers/Display Lists">
<intent-filter>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ClipOutlineActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipOutlineActivity.java
new file mode 100644
index 0000000..af448e8
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipOutlineActivity.java
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+package com.android.test.hwui;
+
+import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Outline;
+import android.graphics.Path;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+
+public class ClipOutlineActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final RegionView group = new RegionView(this);
+
+ final TextView text = new TextView(this);
+ text.setText(buildText());
+ group.addView(text);
+
+ setContentView(group);
+
+ ObjectAnimator animator = ObjectAnimator.ofFloat(group, "clipPosition", 0.0f, 1.0f);
+ animator.setDuration(3000);
+ animator.setRepeatCount(ValueAnimator.INFINITE);
+ animator.setRepeatMode(ValueAnimator.REVERSE);
+ animator.start();
+ }
+
+ private static CharSequence buildText() {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < 10; i++) {
+ buffer.append(LOREM_IPSUM);
+ }
+ return buffer;
+ }
+
+ public static class RegionView extends FrameLayout {
+ private float mClipPosition = 0.0f;
+ private Outline mOutline = new Outline();
+ private Rect mRect = new Rect();
+
+ public RegionView(Context c) {
+ super(c);
+ setClipToOutline(true);
+ }
+
+ public float getClipPosition() {
+ return mClipPosition;
+ }
+
+ public void setClipPosition(float clipPosition) {
+ mClipPosition = clipPosition;
+ int w = getWidth() / 2;
+ int h = getHeight() / 2;
+
+ mRect.set(0, 0, w, h);
+ mRect.offset((int) (clipPosition * w), getHeight() / 4);
+ mOutline.setRoundRect(mRect, w / 2);
+ setOutline(mOutline);
+ invalidate();
+ }
+ }
+
+ private static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sagittis molestie aliquam. Donec metus metus, laoreet nec sagittis vitae, ultricies sit amet eros. Suspendisse sed massa sit amet felis consectetur gravida. In vitae erat mi, in egestas nisl. Phasellus quis ipsum massa, at scelerisque arcu. Nam lectus est, pellentesque eget lacinia non, congue vitae augue. Aliquam erat volutpat. Pellentesque bibendum tincidunt viverra. Aliquam erat volutpat. Maecenas pretium vulputate placerat. Nulla varius elementum rutrum. Aenean mollis blandit imperdiet. Pellentesque interdum fringilla ligula.";
+}