diff options
author | Romain Guy <romainguy@google.com> | 2013-01-18 16:42:51 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-01-18 16:42:51 -0800 |
commit | 2055abaa0a590c35e27e1ae2e7d7cfccdfb98b59 (patch) | |
tree | 1e302d08b6aa3714048a4d8435aa44f155c998c9 /tests/HwAccelerationTest/src/com/android/test | |
parent | f25febf01453733e8bdd1ac241ecd9d3bcbef475 (diff) | |
download | frameworks_base-2055abaa0a590c35e27e1ae2e7d7cfccdfb98b59.zip frameworks_base-2055abaa0a590c35e27e1ae2e7d7cfccdfb98b59.tar.gz frameworks_base-2055abaa0a590c35e27e1ae2e7d7cfccdfb98b59.tar.bz2 |
Allow layers with a stencil buffer to be resized on the fly
Bug #7146141
This change moves the resizeLayer() from LayerCache (where it should
never have been anyway) to Layer. This makes a little more sense.
Change-Id: I8b2f9c19c558e738405a58b9e71ec5799fc6be88
Diffstat (limited to 'tests/HwAccelerationTest/src/com/android/test')
-rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java | 65 |
1 files changed, 57 insertions, 8 deletions
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java index 2664977..cbbb7ef 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity5.java @@ -19,14 +19,18 @@ package com.android.test.hwui; import android.app.Activity; import android.content.Context; import android.content.res.Resources; +import android.graphics.Canvas; import android.graphics.Paint; +import android.graphics.Path; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.os.Bundle; +import android.util.AttributeSet; import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TextView; @@ -37,30 +41,75 @@ public class ViewLayersActivity5 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + + init(); + setContentView(R.layout.view_layers_5); + setupList(R.id.list1); + } + + public static class ClipFrameLayout extends FrameLayout { + private final Path mClipPath = new Path(); + private boolean mClipEnabled; + + public ClipFrameLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public ClipFrameLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public boolean isClipEnabled() { + return mClipEnabled; + } + public void setClipEnabled(boolean clipEnabled) { + mClipEnabled = clipEnabled; + invalidate(); + } + + @Override + protected void dispatchDraw(Canvas canvas) { + if (mClipEnabled) { + mClipPath.reset(); + mClipPath.addCircle(getWidth() / 2.0f, getHeight() / 2.0f, + Math.min(getWidth(), getHeight()) / 3.0f, Path.Direction.CW); + + canvas.clipPath(mClipPath); + } + super.dispatchDraw(canvas); + } + } + + private void init() { mPaint.setColorFilter(new PorterDuffColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY)); + } - setupList(R.id.list1); + public void enableClip(View v) { + ((ClipFrameLayout) findViewById(R.id.container)).setClipEnabled(true); + } + + public void disableClip(View v) { + ((ClipFrameLayout) findViewById(R.id.container)).setClipEnabled(false); } public void enableLayer(View v) { - findViewById(R.id.list1).setLayerType(View.LAYER_TYPE_HARDWARE, mPaint); + findViewById(R.id.container).setLayerType(View.LAYER_TYPE_HARDWARE, mPaint); } public void disableLayer(View v) { - findViewById(R.id.list1).setLayerType(View.LAYER_TYPE_NONE, null); + findViewById(R.id.container).setLayerType(View.LAYER_TYPE_NONE, null); } public void growLayer(View v) { - findViewById(R.id.list1).getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; - findViewById(R.id.list1).requestLayout(); + findViewById(R.id.container).getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; + findViewById(R.id.container).requestLayout(); } public void shrinkLayer(View v) { - findViewById(R.id.list1).getLayoutParams().height = 300; - findViewById(R.id.list1).requestLayout(); + findViewById(R.id.container).getLayoutParams().height = 300; + findViewById(R.id.container).requestLayout(); } private void setupList(int listId) { |