summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-08-08 16:05:42 -0700
committerRomain Guy <romainguy@google.com>2012-08-08 16:05:42 -0700
commit320d46bf844b84351cb80c5d4a4768d86447ac81 (patch)
treefee65370216aee9df6116a46ebae0edfd8de1272 /tests
parentc89b14bba0f6cc2c91629080617f7ed215f697f3 (diff)
downloadframeworks_base-320d46bf844b84351cb80c5d4a4768d86447ac81.zip
frameworks_base-320d46bf844b84351cb80c5d4a4768d86447ac81.tar.gz
frameworks_base-320d46bf844b84351cb80c5d4a4768d86447ac81.tar.bz2
Reduce gradients textures size whenever possible
Change-Id: Ifd58625ee62edac3b5d20b77553cb98b6fa2b46e
Diffstat (limited to 'tests')
-rw-r--r--tests/HwAccelerationTest/AndroidManifest.xml9
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/TextPathActivity.java77
2 files changed, 86 insertions, 0 deletions
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index fad5993..1857033 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -33,6 +33,15 @@
<meta-data android:name="android.graphics.renderThread" android:value="true" />
<activity
+ android:name="TextPathActivity"
+ android:label="_TextPath">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
android:name="GradientStopsActivity"
android:label="_GradientStops">
<intent-filter>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextPathActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextPathActivity.java
new file mode 100644
index 0000000..35a1fc9
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextPathActivity.java
@@ -0,0 +1,77 @@
+/*
+ * 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.Canvas;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.ScrollView;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class TextPathActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ ScrollView scroller = new ScrollView(this);
+ scroller.addView(new CustomTextView(this));
+ setContentView(scroller);
+ }
+
+ static class CustomTextView extends View {
+ private final Paint mHugePaint;
+
+ CustomTextView(Context c) {
+ super(c);
+
+ mHugePaint = new Paint();
+ mHugePaint.setAntiAlias(true);
+ mHugePaint.setColor(0xff000000);
+ mHugePaint.setTextSize(300f);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 3000);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ canvas.drawRGB(255, 255, 255);
+
+ Path path = new Path();
+
+ canvas.translate(100.0f, 300.0f);
+ drawTextAsPath(canvas, "Hello", path);
+
+ canvas.translate(0.0f, 400.0f);
+ drawTextAsPath(canvas, "OpenGL", path);
+ }
+
+ private void drawTextAsPath(Canvas canvas, String text, Path path) {
+ int count = text.length();
+ mHugePaint.getTextPath(text, 0, count, 0, 0, path);
+ path.close();
+ canvas.drawPath(path, mHugePaint);
+ }
+ }
+}