summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-07-07 21:28:41 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-07 21:28:41 -0700
commite92096fa6ad01eb022386d2ca536d99bc068e817 (patch)
treeba91f71972ba7d5e9bfc9856b796e4f84b650048 /tests
parent7024e0b9020e4ec2d544d687c98c30bd21c2526c (diff)
parentec19b4a764d512091a780fc93ced567dfbf80914 (diff)
downloadframeworks_base-e92096fa6ad01eb022386d2ca536d99bc068e817.zip
frameworks_base-e92096fa6ad01eb022386d2ca536d99bc068e817.tar.gz
frameworks_base-e92096fa6ad01eb022386d2ca536d99bc068e817.tar.bz2
Merge "Use NEAREST filtering mode for TextureView.getBitmap()."
Diffstat (limited to 'tests')
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java27
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java3
2 files changed, 26 insertions, 4 deletions
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index e1ca756..f471f3e 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -16,6 +16,8 @@
package com.android.test.hwui;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.Activity;
@@ -40,6 +42,10 @@ import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL;
+import java.io.BufferedOutputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
@@ -57,6 +63,25 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa
mTextureView = new TextureView(this);
mTextureView.setSurfaceTextureListener(this);
+ mTextureView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Bitmap b = mTextureView.getBitmap(600, 350);
+ BufferedOutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream("/sdcard/out.png"));
+ b.compress(Bitmap.CompressFormat.PNG, 100, out);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } finally {
+ if (out != null) try {
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
setContentView(mTextureView, new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT,
@@ -77,7 +102,7 @@ public class GLTextureViewActivity extends Activity implements TextureView.Surfa
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- ((View) mTextureView.getParent()).invalidate();
+ mTextureView.invalidate();
}
});
animator.start();
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
index 95b84c4..634e7e3 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
@@ -16,7 +16,6 @@
package com.android.test.hwui;
-import android.animation.AnimatorSet;
import android.app.Activity;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
@@ -34,7 +33,6 @@ public class TextureViewActivity extends Activity implements TextureView.Surface
private Camera mCamera;
private TextureView mTextureView;
private FrameLayout mContent;
- private AnimatorSet mAnimatorSet;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -53,7 +51,6 @@ public class TextureViewActivity extends Activity implements TextureView.Surface
@Override
public void onClick(View v) {
if (mAdded) {
- if (mAnimatorSet != null) mAnimatorSet.cancel();
mContent.removeView(mTextureView);
} else {
mContent.addView(mTextureView);