summaryrefslogtreecommitdiffstats
path: root/tests/HwAccelerationTest
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-09-20 17:53:08 -0700
committerRomain Guy <romainguy@google.com>2010-09-20 17:54:17 -0700
commitee916f14cbd1fe1422c063ce2ef7b185e2bc5c6f (patch)
tree4fd53bcd273d42fa1aebb064b18563aa293467b1 /tests/HwAccelerationTest
parentb5ab4173e0927e4668a45298c9900cd8007584e1 (diff)
downloadframeworks_base-ee916f14cbd1fe1422c063ce2ef7b185e2bc5c6f.zip
frameworks_base-ee916f14cbd1fe1422c063ce2ef7b185e2bc5c6f.tar.gz
frameworks_base-ee916f14cbd1fe1422c063ce2ef7b185e2bc5c6f.tar.bz2
Add support for SweepGradient in the GL renderer.
Change-Id: I7aa397ed4e34655ead9ba1f5b4ce087665e0f022
Diffstat (limited to 'tests/HwAccelerationTest')
-rw-r--r--tests/HwAccelerationTest/AndroidManifest.xml11
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/AdvancedGradientsActivity.java96
2 files changed, 106 insertions, 1 deletions
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 8a08c48..af71a0f 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -31,6 +31,15 @@
</activity>
<activity
+ android:name="AdvancedGradientsActivity"
+ android:label="_Advanced Gradients">
+ <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"
android:windowSoftInputMode="adjustResize">
@@ -250,7 +259,7 @@
<activity
android:name="AdvancedBlendActivity"
- android:label="_AdvancedBlend">
+ android:label="_Advanced Blend">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/AdvancedGradientsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/AdvancedGradientsActivity.java
new file mode 100644
index 0000000..e232021
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/AdvancedGradientsActivity.java
@@ -0,0 +1,96 @@
+/*
+ * 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.Matrix;
+import android.graphics.Paint;
+import android.graphics.RadialGradient;
+import android.graphics.Shader;
+import android.graphics.SweepGradient;
+import android.os.Bundle;
+import android.view.View;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class AdvancedGradientsActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(new GradientsView(this));
+ }
+
+ static class GradientsView extends View {
+ private final Paint mPaint;
+ private final SweepGradient mSweepGradient;
+ private final RadialGradient mRadialGradient;
+ private final Matrix mMatrix;
+ private final Matrix mMatrix2;
+
+ GradientsView(Context c) {
+ super(c);
+
+ mSweepGradient = new SweepGradient(100.0f, 100.0f, 0xff000000, 0xffffffff);
+ mRadialGradient = new RadialGradient(100.0f, 100.0f, 100.0f, 0xff000000, 0xffffffff,
+ Shader.TileMode.MIRROR);
+
+ mMatrix = new Matrix();
+ mMatrix.setTranslate(50.0f, 50.0f);
+
+ mMatrix2 = new Matrix();
+ mMatrix2.setScale(2.0f, 2.0f);
+
+ mPaint = new Paint();
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ canvas.drawRGB(255, 255, 255);
+
+ // Bitmap shaders
+ canvas.save();
+ canvas.translate(130.0f, 100.0f);
+
+ mSweepGradient.setLocalMatrix(null);
+ mPaint.setShader(mSweepGradient);
+ canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint);
+
+ canvas.translate(400.0f, 000.0f);
+
+ mPaint.setShader(mRadialGradient);
+ canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint);
+
+ canvas.translate(400.0f, 000.0f);
+
+ mSweepGradient.setLocalMatrix(mMatrix);
+ mPaint.setShader(mSweepGradient);
+ canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint);
+
+ canvas.translate(-800.0f, 300.0f);
+
+ mSweepGradient.setLocalMatrix(mMatrix2);
+ mPaint.setShader(mSweepGradient);
+ canvas.drawRect(0.0f, 0.0f, 200.0f, 200.0f, mPaint);
+
+
+ canvas.restore();
+ }
+ }
+}