diff options
author | Romain Guy <romainguy@google.com> | 2010-06-24 19:30:36 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2010-06-24 19:30:36 -0700 |
commit | 9d5316e3f56d138504565ff311145ac01621dff4 (patch) | |
tree | 40c79ba098de4624fbe38cb400c6ac4fe7340673 /tests | |
parent | a18dbdf420fabebb83e7403d000384a8d98daffa (diff) | |
download | frameworks_base-9d5316e3f56d138504565ff311145ac01621dff4.zip frameworks_base-9d5316e3f56d138504565ff311145ac01621dff4.tar.gz frameworks_base-9d5316e3f56d138504565ff311145ac01621dff4.tar.bz2 |
Add colored rectangles implementation in OpenGLRenderer.
Drawing two rectangles one after the other discards the second one because of
Z buffering issues. This will be fixed in another changelist.
Change-Id: Ida1b3cde8a78e60cacc07e477abc44def527ff67
Diffstat (limited to 'tests')
-rw-r--r-- | tests/HwAccelerationTest/src/com/google/android/test/hwui/HwUiActivity.java | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/tests/HwAccelerationTest/src/com/google/android/test/hwui/HwUiActivity.java b/tests/HwAccelerationTest/src/com/google/android/test/hwui/HwUiActivity.java index d24f027..81b9357 100644 --- a/tests/HwAccelerationTest/src/com/google/android/test/hwui/HwUiActivity.java +++ b/tests/HwAccelerationTest/src/com/google/android/test/hwui/HwUiActivity.java @@ -18,14 +18,13 @@ package com.google.android.test.hwui; import android.app.Activity; import android.content.Context; -import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.os.Bundle; +import android.util.Log; import android.view.View; -import static android.util.Log.d; - +@SuppressWarnings({"UnusedDeclaration"}) public class HwUiActivity extends Activity { private static final String LOG_TAG = "HwUi"; @@ -42,15 +41,47 @@ public class HwUiActivity extends Activity { } static class DirtyBitmapView extends View { + private final Paint mPaint; + DirtyBitmapView(Context c) { super(c); + mPaint = new Paint(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - canvas.drawRGB(255, 0, 0); + canvas.drawRGB(255, 255, 255); + + mPaint.setColor(0xffff0000); + canvas.drawRect(200.0f, 0.0f, 220.0f, 20.0f, mPaint); + + canvas.save(); + canvas.clipRect(20.0f, 0.0f, 40.0f, 20.0f); + Log.d(LOG_TAG, "clipRect = " + canvas.getClipBounds()); + canvas.restore(); + + canvas.save(); + canvas.scale(2.0f, 2.0f); + canvas.clipRect(20.0f, 0.0f, 40.0f, 20.0f); + Log.d(LOG_TAG, "clipRect = " + canvas.getClipBounds()); + canvas.restore(); + + canvas.save(); + canvas.translate(20.0f, 20.0f); + canvas.clipRect(20.0f, 0.0f, 40.0f, 20.0f); + Log.d(LOG_TAG, "clipRect = " + canvas.getClipBounds()); + canvas.restore(); + + canvas.scale(2.0f, 2.0f); + canvas.clipRect(20.0f, 0.0f, 40.0f, 20.0f); + + mPaint.setColor(0xff00ff00); + canvas.drawRect(0.0f, 0.0f, 20.0f, 20.0f, mPaint); + + mPaint.setColor(0xff0000ff); + canvas.drawRect(20.0f, 0.0f, 40.0f, 20.0f, mPaint); } } } |