summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2013-02-22 13:53:44 -0800
committerJason Sams <jsams@google.com>2013-02-22 13:53:44 -0800
commitfc0fd4f52c3f025d40af135a5790366a6f859da5 (patch)
treeaad9f4f8d37aaff23517ea984c900b17f9ae64fa /tests/RenderScriptTests
parent72226e0543461133b9e177a3e78ae50b0c65e797 (diff)
downloadframeworks_base-fc0fd4f52c3f025d40af135a5790366a6f859da5.zip
frameworks_base-fc0fd4f52c3f025d40af135a5790366a6f859da5.tar.gz
frameworks_base-fc0fd4f52c3f025d40af135a5790366a6f859da5.tar.bz2
Remove surfaceTextureOpaque test.
This test was for an API we decided not to expose publically and have removed. Change-Id: Ic2b8449b286c8d1fb1432ccc2db47f96ad43cc4b
Diffstat (limited to 'tests/RenderScriptTests')
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/Android.mk29
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/AndroidManifest.xml21
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/res/drawable/test_pattern.pngbin307 -> 0 bytes
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/CameraCapture.java234
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaque.java71
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueRS.java83
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueView.java60
-rw-r--r--tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/sto.rs58
8 files changed, 0 insertions, 556 deletions
diff --git a/tests/RenderScriptTests/SurfaceTexture/Android.mk b/tests/RenderScriptTests/SurfaceTexture/Android.mk
deleted file mode 100644
index d5262ee..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (C) 2012 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
-
-# TODO: build fails with this set
-# LOCAL_SDK_VERSION := current
-
-LOCAL_PACKAGE_NAME := RsSurfaceTextureOpaque
-
-include $(BUILD_PACKAGE)
diff --git a/tests/RenderScriptTests/SurfaceTexture/AndroidManifest.xml b/tests/RenderScriptTests/SurfaceTexture/AndroidManifest.xml
deleted file mode 100644
index 8aaa239..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/AndroidManifest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.rs.sto">
- <uses-sdk android:minSdkVersion="14" />
- <uses-permission android:name="android.permission.CAMERA" />
- <uses-feature android:name="android.hardware.camera" />
- <uses-feature android:name="android.hardware.camera.autofocus" />
-
- <application
- android:label="RsSurfaceTextureOpaque"
- android:hardwareAccelerated="true"
- android:icon="@drawable/test_pattern">
-
- <activity android:name="SurfaceTextureOpaque">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/tests/RenderScriptTests/SurfaceTexture/res/drawable/test_pattern.png b/tests/RenderScriptTests/SurfaceTexture/res/drawable/test_pattern.png
deleted file mode 100644
index e7d1455..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/res/drawable/test_pattern.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/CameraCapture.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/CameraCapture.java
deleted file mode 100644
index afdab41..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/CameraCapture.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.sto;
-
-import android.graphics.SurfaceTexture;
-import android.hardware.Camera;
-import android.os.SystemClock;
-import android.util.Log;
-
-import java.io.IOException;
-import java.util.List;
-
-public class CameraCapture {
-
- public interface CameraFrameListener {
- public void onNewCameraFrame();
- }
-
- static final int FRAMES_PER_SEC = 30;
-
- private Camera mCamera;
- private SurfaceTexture mSurfaceTexture;
-
- private int mProgram;
-
- private int mCameraTransformHandle;
- private int mTexSamplerHandle;
- private int mTexCoordHandle;
- private int mPosCoordHandle;
-
- private float[] mCameraTransform = new float[16];
-
- private int mCameraId = 0;
- private int mWidth;
- private int mHeight;
-
- private long mStartCaptureTime = 0;
-
- private boolean mNewFrameAvailable = false;
- private boolean mIsOpen = false;
-
- private CameraFrameListener mListener;
-
- public synchronized void beginCapture(int cameraId, int width, int height,
- SurfaceTexture st) {
- mCameraId = cameraId;
- mSurfaceTexture = st;
-
- // Open the camera
- openCamera(width, height);
-
- // Start the camera
- mStartCaptureTime = SystemClock.elapsedRealtime();
- mCamera.startPreview();
- mIsOpen = true;
- }
-
- public void getCurrentFrame() {
- if (checkNewFrame()) {
- if (mStartCaptureTime > 0 && SystemClock.elapsedRealtime() - mStartCaptureTime > 2000) {
- // Lock white-balance and exposure for effects
- Log.i("CC", "Locking white-balance and exposure!");
- Camera.Parameters params = mCamera.getParameters();
- params.setAutoWhiteBalanceLock(true);
- params.setAutoExposureLock(true);
- //mCamera.setParameters(params);
- mStartCaptureTime = 0;
- }
-
- mSurfaceTexture.updateTexImage();
- mSurfaceTexture.getTransformMatrix(mCameraTransform);
-
- // display it here
- }
- }
-
- public synchronized boolean hasNewFrame() {
- return mNewFrameAvailable;
- }
-
- public synchronized void endCapture() {
- mIsOpen = false;
- if (mCamera != null) {
- mCamera.release();
- mCamera = null;
- mSurfaceTexture = null;
- }
- }
-
- public synchronized boolean isOpen() {
- return mIsOpen;
- }
-
- public int getWidth() {
- return mWidth;
- }
-
- public int getHeight() {
- return mHeight;
- }
-
- public void setCameraFrameListener(CameraFrameListener listener) {
- mListener = listener;
- }
-
- private void openCamera(int width, int height) {
- // Setup camera
- mCamera = Camera.open(mCameraId);
- mCamera.setParameters(calcCameraParameters(width, height));
-
- // Create camera surface texture
- try {
- mCamera.setPreviewTexture(mSurfaceTexture);
- } catch (IOException e) {
- throw new RuntimeException("Could not bind camera surface texture: " +
- e.getMessage() + "!");
- }
-
- // Connect SurfaceTexture to callback
- mSurfaceTexture.setOnFrameAvailableListener(onCameraFrameAvailableListener);
- }
-
- private Camera.Parameters calcCameraParameters(int width, int height) {
- Camera.Parameters params = mCamera.getParameters();
- params.setPreviewSize(mWidth, mHeight);
-
- // Find closest size
- int closestSize[] = findClosestSize(width, height, params);
- mWidth = closestSize[0];
- mHeight = closestSize[1];
- params.setPreviewSize(mWidth, mHeight);
-
- // Find closest FPS
- int closestRange[] = findClosestFpsRange(FRAMES_PER_SEC, params);
-
- params.setPreviewFpsRange(closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
- closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
-
- return params;
- }
-
- private int[] findClosestSize(int width, int height, Camera.Parameters parameters) {
- List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();
- int closestWidth = -1;
- int closestHeight = -1;
- int smallestWidth = previewSizes.get(0).width;
- int smallestHeight = previewSizes.get(0).height;
- for (Camera.Size size : previewSizes) {
- // Best match defined as not being larger in either dimension than
- // the requested size, but as close as possible. The below isn't a
- // stable selection (reording the size list can give different
- // results), but since this is a fallback nicety, that's acceptable.
- if ( size.width <= width &&
- size.height <= height &&
- size.width >= closestWidth &&
- size.height >= closestHeight) {
- closestWidth = size.width;
- closestHeight = size.height;
- }
- if ( size.width < smallestWidth &&
- size.height < smallestHeight) {
- smallestWidth = size.width;
- smallestHeight = size.height;
- }
- }
- if (closestWidth == -1) {
- // Requested size is smaller than any listed size; match with smallest possible
- closestWidth = smallestWidth;
- closestHeight = smallestHeight;
- }
- int[] closestSize = {closestWidth, closestHeight};
- return closestSize;
- }
-
- private int[] findClosestFpsRange(int fps, Camera.Parameters params) {
- List<int[]> supportedFpsRanges = params.getSupportedPreviewFpsRange();
- int[] closestRange = supportedFpsRanges.get(0);
- int fpsk = fps * 1000;
- int minDiff = 1000000;
- for (int[] range : supportedFpsRanges) {
- int low = range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX];
- int high = range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX];
- if (low <= fpsk && high >= fpsk) {
- int diff = (fpsk - low) + (high - fpsk);
- if (diff < minDiff) {
- closestRange = range;
- minDiff = diff;
- }
- }
- }
- Log.i("CC", "Found closest range: "
- + closestRange[Camera.Parameters.PREVIEW_FPS_MIN_INDEX] + " - "
- + closestRange[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]);
- return closestRange;
- }
-
- private synchronized void signalNewFrame() {
- mNewFrameAvailable = true;
- if (mListener != null) {
- mListener.onNewCameraFrame();
- }
- }
-
- private synchronized boolean checkNewFrame() {
- if (mNewFrameAvailable) {
- mNewFrameAvailable = false;
- return true;
- }
- return false;
- }
-
- private SurfaceTexture.OnFrameAvailableListener onCameraFrameAvailableListener =
- new SurfaceTexture.OnFrameAvailableListener() {
- @Override
- public void onFrameAvailable(SurfaceTexture surfaceTexture) {
- signalNewFrame();
- }
- };
-}
diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaque.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaque.java
deleted file mode 100644
index a51edaa..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaque.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.sto;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.provider.Settings.System;
-import android.util.Log;
-import android.view.View;
-import android.graphics.SurfaceTexture;
-
-import java.lang.Runtime;
-
-public class SurfaceTextureOpaque extends Activity {
- private SurfaceTextureOpaqueView mView;
- CameraCapture mCC;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- mView = new SurfaceTextureOpaqueView(this);
- setContentView(mView);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mView.resume();
- startCamera();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- mView.pause();
- mCC.endCapture();
- }
-
- cfl mCFL;
- public void startCamera() {
- mCC = new CameraCapture();
- mCFL = new cfl();
-
- mCC.setCameraFrameListener(mCFL);
-
- mCC.beginCapture(1, 640, 480, mView.getST());
- }
-
- public class cfl implements CameraCapture.CameraFrameListener {
- public void onNewCameraFrame() {
- mView.mRender.newFrame();
- }
- }
-
-}
-
diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueRS.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueRS.java
deleted file mode 100644
index b638b7d..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueRS.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.sto;
-
-import android.content.res.Resources;
-import android.renderscript.*;
-import android.graphics.SurfaceTexture;
-import android.util.Log;
-
-
-public class SurfaceTextureOpaqueRS {
- static final private int NUM_CAMERA_PREVIEW_BUFFERS = 2;
-
- public SurfaceTextureOpaqueRS() {
- }
-
- private Resources mRes;
- private RenderScriptGL mRS;
- private ScriptC_sto mScript;
- private SurfaceTexture mST;
- private Allocation mSto;
- private Allocation mSto2;
- private Allocation mRto;
- private ProgramFragment mPF;
-
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
-
- Type.Builder tb = new Type.Builder(mRS, Element.RGBA_8888(mRS));
- tb.setX(640);
- tb.setY(480);
- mSto = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_GRAPHICS_TEXTURE |
- Allocation.USAGE_IO_INPUT);
- mRto = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_GRAPHICS_RENDER_TARGET |
- Allocation.USAGE_IO_OUTPUT);
- mSto2 = Allocation.createTyped(mRS, tb.create(), Allocation.USAGE_GRAPHICS_TEXTURE |
- Allocation.USAGE_IO_INPUT);
- mST = mSto.getSurfaceTexture();
- mRto.setSurfaceTexture(mSto2.getSurfaceTexture());
-
- ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs);
- pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
- ProgramFragmentFixedFunction.Builder.Format.RGBA, 0);
- mPF = pfb.create();
- mPF.bindSampler(Sampler.CLAMP_NEAREST(mRS), 0);
- rs.bindProgramFragment(mPF);
-
- mScript = new ScriptC_sto(mRS, mRes, R.raw.sto);
- mScript.set_sto(mSto);
- mScript.set_rto(mRto);
- mScript.set_sto2(mSto2);
- mScript.set_pf(mPF);
-
- mRS.bindRootScript(mScript);
-
-
- android.util.Log.v("sto", "Init complete");
- }
-
- SurfaceTexture getST() {
- return mST;
- }
-
- public void newFrame() {
- mSto.ioReceive();
- }
-
-}
diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueView.java b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueView.java
deleted file mode 100644
index f5e49f2..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/SurfaceTextureOpaqueView.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 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.example.android.rs.sto;
-
-
-import android.renderscript.RSSurfaceView;
-import android.renderscript.RenderScriptGL;
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.SurfaceTexture;
-import android.util.Log;
-
-public class SurfaceTextureOpaqueView extends RSSurfaceView {
-
- public SurfaceTextureOpaqueView(Context context) {
- super(context);
- }
-
- RenderScriptGL mRS;
- SurfaceTextureOpaqueRS mRender;
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- SurfaceTexture getST() {
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- mRender = new SurfaceTextureOpaqueRS();
- mRender.init(mRS, getResources());
- return mRender.getST();
- }
-
-}
-
-
diff --git a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/sto.rs b/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/sto.rs
deleted file mode 100644
index efa901a..0000000
--- a/tests/RenderScriptTests/SurfaceTexture/src/com/example/android/rs/sto/sto.rs
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-#pragma version(1)
-#pragma rs java_package_name(com.example.android.rs.sto)
-
-#pragma stateFragment(parent)
-
-#include "rs_graphics.rsh"
-
-
-rs_program_fragment pf;
-rs_allocation sto; // camera in
-rs_allocation sto2;
-rs_allocation rto; // render target
-
-int root() {
- rsgBindTexture(pf, 0, sto);
-
-#if 1
- rsgBindColorTarget(rto, 0);
-
- rsgClearColor(0.f, 1.f, 0.f, 1.f);
- rsgDrawQuadTexCoords(0, 0, 0, 0,0,
- 0,500,0, 1,0,
- 500,500,0, 1, 1,
- 500, 0, 0, 0, 1 );
- rsgClearColorTarget(0);
-
- // io ops
- rsAllocationIoSend(rto);
- rsAllocationIoReceive(sto2);
-
- rsgBindTexture(pf, 0, sto2);
-#endif
-
- rsgClearColor(0.f, 1.f, 0.f, 1.f);
- rsgDrawQuadTexCoords(0, 0, 0, 0,0,
- 0,500,0, 1,0,
- 500,500,0, 1, 1,
- 500, 0, 0, 0, 1 );
-
- return 1;
-}
-