summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2013-01-04 12:26:18 -0800
committerRomain Guy <romainguy@google.com>2013-01-04 15:15:16 -0800
commit886b275e529e44a59c54b933453d9bc902973178 (patch)
tree33ed0717b43683ba9f8a825c7012739a2146e943 /tests
parent5913148104f0b233d861fab2873befc865bf57c0 (diff)
downloadframeworks_base-886b275e529e44a59c54b933453d9bc902973178.zip
frameworks_base-886b275e529e44a59c54b933453d9bc902973178.tar.gz
frameworks_base-886b275e529e44a59c54b933453d9bc902973178.tar.bz2
Properly support ALPHA_8 bitmaps in all drawBitmap() methods
Change-Id: I869993c59e0a0d76f369c09acbae711753908f48
Diffstat (limited to 'tests')
-rw-r--r--tests/HwAccelerationTest/AndroidManifest.xml9
-rw-r--r--tests/HwAccelerationTest/res/drawable-nodpi/spot_mask.pngbin0 -> 25505 bytes
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/Alpha8BitmapActivity.java97
3 files changed, 106 insertions, 0 deletions
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index 9118aea..1974e0f 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="Alpha8BitmapActivity"
+ android:label="_Alpha8Bitmap">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ <activity
android:name="MipMapActivity"
android:label="_MipMap">
<intent-filter>
diff --git a/tests/HwAccelerationTest/res/drawable-nodpi/spot_mask.png b/tests/HwAccelerationTest/res/drawable-nodpi/spot_mask.png
new file mode 100644
index 0000000..8953759
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable-nodpi/spot_mask.png
Binary files differ
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/Alpha8BitmapActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/Alpha8BitmapActivity.java
new file mode 100644
index 0000000..5fe512e
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/Alpha8BitmapActivity.java
@@ -0,0 +1,97 @@
+/*
+ * 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.BitmapShader;
+import android.graphics.Canvas;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.graphics.Shader;
+import android.os.Bundle;
+import android.view.View;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class Alpha8BitmapActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(new BitmapsView(this));
+ }
+
+ static class BitmapsView extends View {
+ private Paint mBitmapPaint;
+ private final Bitmap mBitmap1;
+ private final float[] mVertices;
+
+ BitmapsView(Context c) {
+ super(c);
+
+ Bitmap texture = BitmapFactory.decodeResource(c.getResources(), R.drawable.spot_mask);
+ mBitmap1 = Bitmap.createBitmap(texture.getWidth(), texture.getHeight(),
+ Bitmap.Config.ALPHA_8);
+ Canvas canvas = new Canvas(mBitmap1);
+ canvas.drawBitmap(texture, 0.0f, 0.0f, null);
+
+ texture = BitmapFactory.decodeResource(c.getResources(), R.drawable.sunset1);
+ BitmapShader shader = new BitmapShader(texture,
+ Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
+
+ final float width = texture.getWidth() / 3.0f;
+ final float height = texture.getHeight() / 3.0f;
+
+ mVertices = new float[] {
+ 0.0f, 0.0f, width, 0.0f, width * 2, 0.0f, width * 3, 0.0f,
+ 0.0f, height, width, height, width * 2, height, width * 4, height,
+ 0.0f, height * 2, width, height * 2, width * 2, height * 2, width * 3, height * 2,
+ 0.0f, height * 4, width, height * 4, width * 2, height * 4, width * 4, height * 4,
+ };
+
+ mBitmapPaint = new Paint();
+ mBitmapPaint.setFilterBitmap(true);
+ mBitmapPaint.setShader(shader);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ canvas.drawColor(0xffffffff);
+ canvas.drawBitmap(mBitmap1, 0.0f, 0.0f, mBitmapPaint);
+
+ Matrix matrix = new Matrix();
+ matrix.setScale(2.0f, 2.0f);
+ matrix.postTranslate(0.0f, mBitmap1.getHeight());
+ canvas.drawBitmap(mBitmap1, matrix, mBitmapPaint);
+
+ Rect src = new Rect(0, 0, mBitmap1.getWidth() / 2, mBitmap1.getHeight() / 2);
+ Rect dst = new Rect(0, mBitmap1.getHeight() * 3, mBitmap1.getWidth(),
+ mBitmap1.getHeight() * 4);
+ canvas.drawBitmap(mBitmap1, src, dst, mBitmapPaint);
+
+ canvas.translate(0.0f, mBitmap1.getHeight() * 4);
+ canvas.drawBitmapMesh(mBitmap1, 3, 3, mVertices, 0, null, 0, mBitmapPaint);
+
+ invalidate();
+ }
+ }
+}