diff --git a/build/sdk.atree b/build/sdk.atree index b23f5b396..4937fc3f2 100644 --- a/build/sdk.atree +++ b/build/sdk.atree @@ -51,11 +51,6 @@ bin/dx platform-tools/dx bin/dexdump platform-tools/dexdump framework/dx.jar platform-tools/lib/dx.jar -# Framework include for Renderscript -frameworks/rs/scriptc platform-tools/renderscript/include -external/clang/lib/Headers platform-tools/renderscript/clang-include -external/clang/LICENSE.TXT platform-tools/renderscript/clang-include/LICENSE.TXT - # API database for tools such as lint development/sdk/api-versions.xml platform-tools/api/api-versions.xml @@ -200,12 +195,6 @@ development/samples/WiFiDirectDemo samples/${PLATFORM_NAME}/WiFiDire development/samples/Wiktionary samples/${PLATFORM_NAME}/Wiktionary development/samples/WiktionarySimple samples/${PLATFORM_NAME}/WiktionarySimple development/samples/XmlAdapters samples/${PLATFORM_NAME}/XmlAdapters -development/samples/RenderScript/Balls samples/${PLATFORM_NAME}/RenderScript/Balls -development/samples/RenderScript/Fountain samples/${PLATFORM_NAME}/RenderScript/Fountain -development/samples/RenderScript/FountainFbo samples/${PLATFORM_NAME}/RenderScript/FountainFbo -development/samples/RenderScript/HelloCompute samples/${PLATFORM_NAME}/RenderScript/HelloCompute -development/samples/RenderScript/HelloWorld samples/${PLATFORM_NAME}/RenderScript/HelloWorld -development/samples/RenderScript/MiscSamples samples/${PLATFORM_NAME}/RenderScript/MiscSamples # NOTICE files are copied by build/core/Makefile from sdk.git sdk/files/sdk_files_NOTICE.txt samples/${PLATFORM_NAME}/NOTICE.txt diff --git a/samples/RenderScript/Android.mk b/samples/RenderScript/Android.mk deleted file mode 100644 index 5053e7d64..000000000 --- a/samples/RenderScript/Android.mk +++ /dev/null @@ -1 +0,0 @@ -include $(call all-subdir-makefiles) diff --git a/samples/RenderScript/Balls/Android.mk b/samples/RenderScript/Balls/Android.mk deleted file mode 100644 index b10958493..000000000 --- a/samples/RenderScript/Balls/Android.mk +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright (C) 2008 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 := optional - -LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src) - -LOCAL_PACKAGE_NAME := RsBalls - -include $(BUILD_PACKAGE) diff --git a/samples/RenderScript/Balls/AndroidManifest.xml b/samples/RenderScript/Balls/AndroidManifest.xml deleted file mode 100644 index 80e6b3984..000000000 --- a/samples/RenderScript/Balls/AndroidManifest.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/samples/RenderScript/Balls/_index.html b/samples/RenderScript/Balls/_index.html deleted file mode 100644 index 87604854d..000000000 --- a/samples/RenderScript/Balls/_index.html +++ /dev/null @@ -1 +0,0 @@ -

A brute force physics simulation that renders many balls onto the screen and moves them according to user touch and gravity.

\ No newline at end of file diff --git a/samples/RenderScript/Balls/res/drawable/flares.png b/samples/RenderScript/Balls/res/drawable/flares.png deleted file mode 100644 index 3a5c970fc..000000000 Binary files a/samples/RenderScript/Balls/res/drawable/flares.png and /dev/null differ diff --git a/samples/RenderScript/Balls/res/drawable/test_pattern.png b/samples/RenderScript/Balls/res/drawable/test_pattern.png deleted file mode 100644 index e7d145554..000000000 Binary files a/samples/RenderScript/Balls/res/drawable/test_pattern.png and /dev/null differ diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/Balls.java b/samples/RenderScript/Balls/src/com/example/android/rs/balls/Balls.java deleted file mode 100644 index 2c6558e92..000000000 --- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/Balls.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2008 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.balls; - -import android.renderscript.RSSurfaceView; -import android.renderscript.RenderScript; - -import android.app.Activity; -import android.content.res.Configuration; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.provider.Settings.System; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.Window; -import android.widget.Button; -import android.widget.ListView; - -import android.app.Activity; -import android.content.Context; -import android.os.Bundle; -import android.view.View; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; - -public class Balls extends Activity implements SensorEventListener { - //EventListener mListener = new EventListener(); - - private static final String LOG_TAG = "libRS_jni"; - private static final boolean DEBUG = false; - private static final boolean LOG_ENABLED = false; - - private BallsView mView; - private SensorManager mSensorManager; - - // get the current looper (from your Activity UI thread for instance - - - public void onSensorChanged(SensorEvent event) { - //android.util.Log.d("rs", "sensor: " + event.sensor + ", x: " + event.values[0] + ", y: " + event.values[1] + ", z: " + event.values[2]); - synchronized (this) { - if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) { - if(mView != null) { - mView.setAccel(event.values[0], event.values[1], event.values[2]); - } - } - } - } - - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); - - // Create our Preview view and set it as the content of our - // Activity - mView = new BallsView(this); - setContentView(mView); - } - - @Override - protected void onResume() { - mSensorManager.registerListener(this, - mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), - SensorManager.SENSOR_DELAY_FASTEST); - - // Ideally a game should implement onResume() and onPause() - // to take appropriate action when the activity looses focus - super.onResume(); - mView.resume(); - } - - @Override - protected void onPause() { - super.onPause(); - mView.pause(); - onStop(); - } - - @Override - protected void onStop() { - mSensorManager.unregisterListener(this); - super.onStop(); - } - - static void log(String message) { - if (LOG_ENABLED) { - Log.v(LOG_TAG, message); - } - } - - -} - diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/BallsRS.java b/samples/RenderScript/Balls/src/com/example/android/rs/balls/BallsRS.java deleted file mode 100644 index 8cab9b8a8..000000000 --- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/BallsRS.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2008 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.balls; - -import android.content.res.Resources; -import android.renderscript.*; -import android.util.Log; - -public class BallsRS { - public static final int PART_COUNT = 900; - - public BallsRS() { - } - - private Resources mRes; - private RenderScriptGL mRS; - private ScriptC_balls mScript; - private ScriptC_ball_physics mPhysicsScript; - private ProgramFragment mPFLines; - private ProgramFragment mPFPoints; - private ProgramVertex mPV; - private ScriptField_Point mPoints; - private ScriptField_VpConsts mVpConsts; - - void updateProjectionMatrices() { - mVpConsts = new ScriptField_VpConsts(mRS, 1, - Allocation.USAGE_SCRIPT | - Allocation.USAGE_GRAPHICS_CONSTANTS); - ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item(); - Matrix4f mvp = new Matrix4f(); - mvp.loadOrtho(0, mRS.getWidth(), mRS.getHeight(), 0, -1, 1); - i.MVP = mvp; - mVpConsts.set(i, 0, true); - } - - private void createProgramVertex() { - updateProjectionMatrices(); - - ProgramVertex.Builder sb = new ProgramVertex.Builder(mRS); - String t = "varying vec4 varColor;\n" + - "void main() {\n" + - " vec4 pos = vec4(0.0, 0.0, 0.0, 1.0);\n" + - " pos.xy = ATTRIB_position;\n" + - " gl_Position = UNI_MVP * pos;\n" + - " varColor = vec4(1.0, 1.0, 1.0, 1.0);\n" + - " gl_PointSize = ATTRIB_size;\n" + - "}\n"; - sb.setShader(t); - sb.addConstant(mVpConsts.getType()); - sb.addInput(mPoints.getElement()); - ProgramVertex pvs = sb.create(); - pvs.bindConstants(mVpConsts.getAllocation(), 0); - mRS.bindProgramVertex(pvs); - } - - private Allocation loadTexture(int id) { - final Allocation allocation = - Allocation.createFromBitmapResource(mRS, mRes, - id, Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_GRAPHICS_TEXTURE); - return allocation; - } - - ProgramStore BLEND_ADD_DEPTH_NONE(RenderScript rs) { - ProgramStore.Builder builder = new ProgramStore.Builder(rs); - builder.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); - builder.setBlendFunc(ProgramStore.BlendSrcFunc.ONE, ProgramStore.BlendDstFunc.ONE); - builder.setDitherEnabled(false); - builder.setDepthMaskEnabled(false); - return builder.create(); - } - - public void init(RenderScriptGL rs, Resources res, int width, int height) { - mRS = rs; - mRes = res; - - ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs); - pfb.setPointSpriteTexCoordinateReplacement(true); - pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.MODULATE, - ProgramFragmentFixedFunction.Builder.Format.RGBA, 0); - pfb.setVaryingColor(true); - mPFPoints = pfb.create(); - - pfb = new ProgramFragmentFixedFunction.Builder(rs); - pfb.setVaryingColor(true); - mPFLines = pfb.create(); - - android.util.Log.e("rs", "Load texture"); - mPFPoints.bindTexture(loadTexture(R.drawable.flares), 0); - - mPoints = new ScriptField_Point(mRS, PART_COUNT, Allocation.USAGE_SCRIPT); - - Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS); - smb.addVertexAllocation(mPoints.getAllocation()); - smb.addIndexSetType(Mesh.Primitive.POINT); - Mesh smP = smb.create(); - - mPhysicsScript = new ScriptC_ball_physics(mRS, mRes, R.raw.ball_physics); - - mScript = new ScriptC_balls(mRS, mRes, R.raw.balls); - mScript.set_partMesh(smP); - mScript.set_physics_script(mPhysicsScript); - mScript.bind_point(mPoints); - mScript.bind_balls1(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); - mScript.bind_balls2(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); - - mScript.set_gPFLines(mPFLines); - mScript.set_gPFPoints(mPFPoints); - createProgramVertex(); - - mRS.bindProgramStore(BLEND_ADD_DEPTH_NONE(mRS)); - - mPhysicsScript.set_gMinPos(new Float2(5, 5)); - mPhysicsScript.set_gMaxPos(new Float2(width - 5, height - 5)); - - mScript.invoke_initParts(width, height); - - mRS.bindRootScript(mScript); - } - - public void newTouchPosition(float x, float y, float pressure, int id) { - mPhysicsScript.invoke_touch(x, y, pressure, id); - } - - public void setAccel(float x, float y) { - mPhysicsScript.set_gGravityVector(new Float2(x, y)); - } - -} diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/BallsView.java b/samples/RenderScript/Balls/src/com/example/android/rs/balls/BallsView.java deleted file mode 100644 index b3b3756ce..000000000 --- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/BallsView.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2008 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.balls; - -import java.io.Writer; -import java.util.ArrayList; -import java.util.concurrent.Semaphore; - -import android.renderscript.RSSurfaceView; -import android.renderscript.RenderScript; -import android.renderscript.RenderScriptGL; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.os.Handler; -import android.os.Message; -import android.util.AttributeSet; -import android.util.Log; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.KeyEvent; -import android.view.MotionEvent; - -public class BallsView extends RSSurfaceView { - - public BallsView(Context context) { - super(context); - //setFocusable(true); - } - - private RenderScriptGL mRS; - private BallsRS mRender; - - public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { - super.surfaceChanged(holder, format, w, h); - if (mRS == null) { - RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); - mRS = createRenderScriptGL(sc); - mRS.setSurface(holder, w, h); - mRender = new BallsRS(); - mRender.init(mRS, getResources(), w, h); - } - mRender.updateProjectionMatrices(); - } - - @Override - protected void onDetachedFromWindow() { - if(mRS != null) { - mRS = null; - destroyRenderScriptGL(); - } - } - - - @Override - public boolean onTouchEvent(MotionEvent ev) - { - int act = ev.getActionMasked(); - if (act == ev.ACTION_UP) { - mRender.newTouchPosition(0, 0, 0, ev.getPointerId(0)); - return false; - } else if (act == MotionEvent.ACTION_POINTER_UP) { - // only one pointer going up, we can get the index like this - int pointerIndex = ev.getActionIndex(); - int pointerId = ev.getPointerId(pointerIndex); - mRender.newTouchPosition(0, 0, 0, pointerId); - return false; - } - int count = ev.getHistorySize(); - int pcount = ev.getPointerCount(); - - for (int p=0; p < pcount; p++) { - int id = ev.getPointerId(p); - mRender.newTouchPosition(ev.getX(p), - ev.getY(p), - ev.getPressure(p), - id); - - for (int i=0; i < count; i++) { - mRender.newTouchPosition(ev.getHistoricalX(p, i), - ev.getHistoricalY(p, i), - ev.getHistoricalPressure(p, i), - id); - } - } - return true; - } - - void setAccel(float x, float y, float z) { - if (mRender == null) { - return; - } - mRender.setAccel(x, -y); - } - -} - - diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/ball_physics.rs b/samples/RenderScript/Balls/src/com/example/android/rs/balls/ball_physics.rs deleted file mode 100644 index 8a3db6d76..000000000 --- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/ball_physics.rs +++ /dev/null @@ -1,146 +0,0 @@ -#pragma version(1) -#pragma rs java_package_name(com.example.android.rs.balls) - -#include "balls.rsh" - -float2 gGravityVector = {0.f, 9.8f}; - -float2 gMinPos = {0.f, 0.f}; -float2 gMaxPos = {1280.f, 700.f}; - -static float2 touchPos[10]; -static float touchPressure[10]; - -void touch(float x, float y, float pressure, int id) { - if (id >= 10) { - return; - } - - touchPos[id].x = x; - touchPos[id].y = y; - touchPressure[id] = pressure; -} - -void root(const Ball_t *ballIn, Ball_t *ballOut, const BallControl_t *ctl, uint32_t x) { - float2 fv = {0, 0}; - float2 pos = ballIn->position; - - int arcID = -1; - float arcInvStr = 100000; - - const Ball_t * bPtr = rsGetElementAt(ctl->ain, 0); - for (uint32_t xin = 0; xin < ctl->dimX; xin++) { - float2 vec = bPtr[xin].position - pos; - float2 vec2 = vec * vec; - float len2 = vec2.x + vec2.y; - - if (len2 < 10000) { - //float minDist = ballIn->size + bPtr[xin].size; - float forceScale = ballIn->size * bPtr[xin].size; - forceScale *= forceScale; - - if (len2 > 16 /* (minDist*minDist)*/) { - // Repulsion - float len = sqrt(len2); - fv -= (vec / (len * len * len)) * 20000.f * forceScale; - } else { - if (len2 < 1) { - if (xin == x) { - continue; - } - ballOut->delta = 0.f; - ballOut->position = ballIn->position; - if (xin > x) { - ballOut->position.x += 1.f; - } else { - ballOut->position.x -= 1.f; - } - //ballOut->color.rgb = 1.f; - //ballOut->arcID = -1; - //ballOut->arcStr = 0; - continue; - } - // Collision - float2 axis = normalize(vec); - float e1 = dot(axis, ballIn->delta); - float e2 = dot(axis, bPtr[xin].delta); - float e = (e1 - e2) * 0.45f; - if (e1 > 0) { - fv -= axis * e; - } else { - fv += axis * e; - } - } - } - } - - fv /= ballIn->size * ballIn->size * ballIn->size; - fv -= gGravityVector * 4.f; - fv *= ctl->dt; - - for (int i=0; i < 10; i++) { - if (touchPressure[i] > 0.1f) { - float2 vec = touchPos[i] - ballIn->position; - float2 vec2 = vec * vec; - float len2 = max(2.f, vec2.x + vec2.y); - fv -= (vec / len2) * touchPressure[i] * 300.f; - } - } - - ballOut->delta = (ballIn->delta * (1.f - 0.004f)) + fv; - ballOut->position = ballIn->position + (ballOut->delta * ctl->dt); - - const float wallForce = 400.f; - if (ballOut->position.x > (gMaxPos.x - 20.f)) { - float d = gMaxPos.x - ballOut->position.x; - if (d < 0.f) { - if (ballOut->delta.x > 0) { - ballOut->delta.x *= -0.7f; - } - ballOut->position.x = gMaxPos.x; - } else { - ballOut->delta.x -= min(wallForce / (d * d), 10.f); - } - } - - if (ballOut->position.x < (gMinPos.x + 20.f)) { - float d = ballOut->position.x - gMinPos.x; - if (d < 0.f) { - if (ballOut->delta.x < 0) { - ballOut->delta.x *= -0.7f; - } - ballOut->position.x = gMinPos.x + 1.f; - } else { - ballOut->delta.x += min(wallForce / (d * d), 10.f); - } - } - - if (ballOut->position.y > (gMaxPos.y - 20.f)) { - float d = gMaxPos.y - ballOut->position.y; - if (d < 0.f) { - if (ballOut->delta.y > 0) { - ballOut->delta.y *= -0.7f; - } - ballOut->position.y = gMaxPos.y; - } else { - ballOut->delta.y -= min(wallForce / (d * d), 10.f); - } - } - - if (ballOut->position.y < (gMinPos.y + 20.f)) { - float d = ballOut->position.y - gMinPos.y; - if (d < 0.f) { - if (ballOut->delta.y < 0) { - ballOut->delta.y *= -0.7f; - } - ballOut->position.y = gMinPos.y + 1.f; - } else { - ballOut->delta.y += min(wallForce / (d * d * d), 10.f); - } - } - - ballOut->size = ballIn->size; - - //rsDebug("physics pos out", ballOut->position); -} - diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rs b/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rs deleted file mode 100644 index dcdd586b0..000000000 --- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rs +++ /dev/null @@ -1,83 +0,0 @@ -#pragma version(1) -#pragma rs java_package_name(com.example.android.rs.balls) -#include "rs_graphics.rsh" - -#include "balls.rsh" - -#pragma stateVertex(parent) -#pragma stateStore(parent) - -rs_program_fragment gPFPoints; -rs_program_fragment gPFLines; -rs_mesh partMesh; - -typedef struct __attribute__((packed, aligned(4))) Point { - float2 position; - float size; -} Point_t; -Point_t *point; - -typedef struct VpConsts { - rs_matrix4x4 MVP; -} VpConsts_t; -VpConsts_t *vpConstants; - -rs_script physics_script; - -Ball_t *balls1; -Ball_t *balls2; - -static int frame = 0; - -void initParts(int w, int h) -{ - uint32_t dimX = rsAllocationGetDimX(rsGetAllocation(balls1)); - - for (uint32_t ct=0; ct < dimX; ct++) { - balls1[ct].position.x = rsRand(0.f, (float)w); - balls1[ct].position.y = rsRand(0.f, (float)h); - balls1[ct].delta.x = 0.f; - balls1[ct].delta.y = 0.f; - balls1[ct].size = 1.f; - - float r = rsRand(100.f); - if (r > 90.f) { - balls1[ct].size += pow(10.f, rsRand(0.f, 2.f)) * 0.07f; - } - } -} - - - -int root() { - rsgClearColor(0.f, 0.f, 0.f, 1.f); - - BallControl_t bc; - Ball_t *bout; - - if (frame & 1) { - bc.ain = rsGetAllocation(balls2); - bc.aout = rsGetAllocation(balls1); - bout = balls1; - } else { - bc.ain = rsGetAllocation(balls1); - bc.aout = rsGetAllocation(balls2); - bout = balls2; - } - - bc.dimX = rsAllocationGetDimX(bc.ain); - bc.dt = 1.f / 30.f; - - rsForEach(physics_script, bc.ain, bc.aout, &bc, sizeof(bc)); - - for (uint32_t ct=0; ct < bc.dimX; ct++) { - point[ct].position = bout[ct].position; - point[ct].size = 6.f /*+ bout[ct].color.g * 6.f*/ * bout[ct].size; - } - - frame++; - rsgBindProgramFragment(gPFPoints); - rsgDrawMesh(partMesh); - return 1; -} - diff --git a/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rsh b/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rsh deleted file mode 100644 index fc886f9fb..000000000 --- a/samples/RenderScript/Balls/src/com/example/android/rs/balls/balls.rsh +++ /dev/null @@ -1,18 +0,0 @@ - -typedef struct __attribute__((packed, aligned(4))) Ball { - float2 delta; - float2 position; - //float3 color; - float size; - //int arcID; - //float arcStr; -} Ball_t; -Ball_t *balls; - - -typedef struct BallControl { - uint32_t dimX; - rs_allocation ain; - rs_allocation aout; - float dt; -} BallControl_t; diff --git a/samples/RenderScript/Fountain/Android.mk b/samples/RenderScript/Fountain/Android.mk deleted file mode 100644 index 2049ecfa4..000000000 --- a/samples/RenderScript/Fountain/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (C) 2008 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 := optional - -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 := RsFountain - -include $(BUILD_PACKAGE) diff --git a/samples/RenderScript/Fountain/AndroidManifest.xml b/samples/RenderScript/Fountain/AndroidManifest.xml deleted file mode 100644 index d19b8c335..000000000 --- a/samples/RenderScript/Fountain/AndroidManifest.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/samples/RenderScript/Fountain/_index.html b/samples/RenderScript/Fountain/_index.html deleted file mode 100644 index 223242f73..000000000 --- a/samples/RenderScript/Fountain/_index.html +++ /dev/null @@ -1,5 +0,0 @@ -

An example that renders many dots on the screen that follow a user's touch. The dots fall -to the bottom of the screen when the user releases the finger.

- - - diff --git a/samples/RenderScript/Fountain/res/drawable/test_pattern.png b/samples/RenderScript/Fountain/res/drawable/test_pattern.png deleted file mode 100644 index e7d145554..000000000 Binary files a/samples/RenderScript/Fountain/res/drawable/test_pattern.png and /dev/null differ diff --git a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/Fountain.java b/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/Fountain.java deleted file mode 100644 index 311455ad9..000000000 --- a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/Fountain.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2008 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.fountain; - -import android.renderscript.RSSurfaceView; -import android.renderscript.RenderScript; - -import android.app.Activity; -import android.content.res.Configuration; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.provider.Settings.System; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.Window; -import android.widget.Button; -import android.widget.ListView; - -import java.lang.Runtime; - -public class Fountain extends Activity { - //EventListener mListener = new EventListener(); - - private static final String LOG_TAG = "libRS_jni"; - private static final boolean DEBUG = false; - private static final boolean LOG_ENABLED = false; - - private FountainView mView; - - // get the current looper (from your Activity UI thread for instance - - - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - // Create our Preview view and set it as the content of our - // Activity - mView = new FountainView(this); - setContentView(mView); - } - - @Override - protected void onResume() { - Log.e("rs", "onResume"); - - // Ideally a game should implement onResume() and onPause() - // to take appropriate action when the activity looses focus - super.onResume(); - mView.resume(); - } - - @Override - protected void onPause() { - Log.e("rs", "onPause"); - - // Ideally a game should implement onResume() and onPause() - // to take appropriate action when the activity looses focus - super.onPause(); - mView.pause(); - - - - //Runtime.getRuntime().exit(0); - } - - - static void log(String message) { - if (LOG_ENABLED) { - Log.v(LOG_TAG, message); - } - } - - -} - diff --git a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/FountainRS.java b/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/FountainRS.java deleted file mode 100644 index 646c807e1..000000000 --- a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/FountainRS.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2008 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.fountain; - -import android.content.res.Resources; -import android.renderscript.*; -import android.util.Log; - - -public class FountainRS { - public static final int PART_COUNT = 50000; - - public FountainRS() { - } - - private Resources mRes; - private RenderScriptGL mRS; - private ScriptC_fountain mScript; - public void init(RenderScriptGL rs, Resources res) { - mRS = rs; - mRes = res; - - ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs); - pfb.setVaryingColor(true); - rs.bindProgramFragment(pfb.create()); - - ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT);// - // Allocation.USAGE_GRAPHICS_VERTEX); - - Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS); - smb.addVertexAllocation(points.getAllocation()); - smb.addIndexSetType(Mesh.Primitive.POINT); - Mesh sm = smb.create(); - - mScript = new ScriptC_fountain(mRS, mRes, R.raw.fountain); - mScript.set_partMesh(sm); - mScript.bind_point(points); - mRS.bindRootScript(mScript); - } - - boolean holdingColor[] = new boolean[10]; - public void newTouchPosition(float x, float y, float pressure, int id) { - if (id >= holdingColor.length) { - return; - } - int rate = (int)(pressure * pressure * 500.f); - if (rate > 500) { - rate = 500; - } - if (rate > 0) { - mScript.invoke_addParticles(rate, x, y, id, !holdingColor[id]); - holdingColor[id] = true; - } else { - holdingColor[id] = false; - } - - } -} diff --git a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/FountainView.java b/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/FountainView.java deleted file mode 100644 index ba09421c0..000000000 --- a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/FountainView.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2008 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.fountain; - -import java.io.Writer; -import java.util.ArrayList; -import java.util.concurrent.Semaphore; - -import android.renderscript.RSTextureView; -import android.renderscript.RenderScript; -import android.renderscript.RenderScriptGL; - -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; -import android.graphics.drawable.Drawable; -import android.os.Handler; -import android.os.Message; -import android.util.AttributeSet; -import android.util.Log; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.KeyEvent; -import android.view.MotionEvent; - -public class FountainView extends RSTextureView { - - public FountainView(Context context) { - super(context); - //setFocusable(true); - } - - private RenderScriptGL mRS; - private FountainRS mRender; - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - android.util.Log.e("rs", "onAttachedToWindow"); - if (mRS == null) { - RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); - mRS = createRenderScriptGL(sc); - mRender = new FountainRS(); - mRender.init(mRS, getResources()); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - android.util.Log.e("rs", "onDetachedFromWindow"); - if (mRS != null) { - mRS = null; - destroyRenderScriptGL(); - } - } - - - @Override - public boolean onTouchEvent(MotionEvent ev) - { - int act = ev.getActionMasked(); - if (act == ev.ACTION_UP) { - mRender.newTouchPosition(0, 0, 0, ev.getPointerId(0)); - return false; - } else if (act == MotionEvent.ACTION_POINTER_UP) { - // only one pointer going up, we can get the index like this - int pointerIndex = ev.getActionIndex(); - int pointerId = ev.getPointerId(pointerIndex); - mRender.newTouchPosition(0, 0, 0, pointerId); - } - int count = ev.getHistorySize(); - int pcount = ev.getPointerCount(); - - for (int p=0; p < pcount; p++) { - int id = ev.getPointerId(p); - mRender.newTouchPosition(ev.getX(p), - ev.getY(p), - ev.getPressure(p), - id); - - for (int i=0; i < count; i++) { - mRender.newTouchPosition(ev.getHistoricalX(p, i), - ev.getHistoricalY(p, i), - ev.getHistoricalPressure(p, i), - id); - } - } - return true; - } -} - - diff --git a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/fountain.rs b/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/fountain.rs deleted file mode 100644 index 151b68977..000000000 --- a/samples/RenderScript/Fountain/src/com/example/android/rs/fountain/fountain.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Fountain test script -#pragma version(1) -#pragma rs_fp_relaxed - -#pragma rs java_package_name(com.example.android.rs.fountain) - -#pragma stateFragment(parent) - -#include "rs_graphics.rsh" - -static int newPart = 0; -rs_mesh partMesh; - -typedef struct __attribute__((packed, aligned(4))) Point { - float2 delta; - float2 position; - uchar4 color; -} Point_t; -Point_t *point; - -int root() { - float dt = min(rsGetDt(), 0.1f); - rsgClearColor(0.f, 0.f, 0.f, 1.f); - const float height = rsgGetHeight(); - const int size = rsAllocationGetDimX(rsGetAllocation(point)); - float dy2 = dt * (10.f); - Point_t * p = point; - for (int ct=0; ct < size; ct++) { - p->delta.y += dy2; - p->position += p->delta; - if ((p->position.y > height) && (p->delta.y > 0)) { - p->delta.y *= -0.3f; - } - p++; - } - - rsgDrawMesh(partMesh); - return 1; -} - -static float4 partColor[10]; -void addParticles(int rate, float x, float y, int index, bool newColor) -{ - if (newColor) { - partColor[index].x = rsRand(0.5f, 1.0f); - partColor[index].y = rsRand(1.0f); - partColor[index].z = rsRand(1.0f); - } - float rMax = ((float)rate) * 0.02f; - int size = rsAllocationGetDimX(rsGetAllocation(point)); - uchar4 c = rsPackColorTo8888(partColor[index]); - - Point_t * np = &point[newPart]; - float2 p = {x, y}; - while (rate--) { - float angle = rsRand(3.14f * 2.f); - float len = rsRand(rMax); - np->delta.x = len * sin(angle); - np->delta.y = len * cos(angle); - np->position = p; - np->color = c; - newPart++; - np++; - if (newPart >= size) { - newPart = 0; - np = &point[newPart]; - } - } -} - diff --git a/samples/RenderScript/FountainFbo/Android.mk b/samples/RenderScript/FountainFbo/Android.mk deleted file mode 100644 index 55a4fd83f..000000000 --- a/samples/RenderScript/FountainFbo/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (C) 2008 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 := optional - -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 := RsFountainFbo - -include $(BUILD_PACKAGE) diff --git a/samples/RenderScript/FountainFbo/AndroidManifest.xml b/samples/RenderScript/FountainFbo/AndroidManifest.xml deleted file mode 100644 index 082744b6d..000000000 --- a/samples/RenderScript/FountainFbo/AndroidManifest.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/samples/RenderScript/FountainFbo/_index.html b/samples/RenderScript/FountainFbo/_index.html deleted file mode 100644 index 550865795..000000000 --- a/samples/RenderScript/FountainFbo/_index.html +++ /dev/null @@ -1,7 +0,0 @@ -

An example that renders many dots on the screen that follow a user's touch. The dots fall -to the bottom of the screen when no touch is detected. This example modifies -the Fountain sample to include rendering to a -a framebuffer object as well as the default framebuffer.

- - - diff --git a/samples/RenderScript/FountainFbo/res/drawable/test_pattern.png b/samples/RenderScript/FountainFbo/res/drawable/test_pattern.png deleted file mode 100644 index e7d145554..000000000 Binary files a/samples/RenderScript/FountainFbo/res/drawable/test_pattern.png and /dev/null differ diff --git a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFbo.java b/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFbo.java deleted file mode 100644 index d8ba30fd1..000000000 --- a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFbo.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2008 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.fountainfbo; - -import android.app.Activity; -import android.os.Bundle; -import android.util.Log; - -public class FountainFbo extends Activity { - private static final String LOG_TAG = "libRS_jni"; - private static final boolean DEBUG = false; - private static final boolean LOG_ENABLED = false; - - private FountainFboView mView; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - /* Create our Preview view and set it as the content of our Activity */ - mView = new FountainFboView(this); - setContentView(mView); - } - - @Override - protected void onResume() { - Log.e("rs", "onResume"); - - /* Ideally a game should implement onResume() and onPause() - to take appropriate action when the activity loses focus */ - super.onResume(); - mView.resume(); - } - - @Override - protected void onPause() { - Log.e("rs", "onPause"); - - /* Ideally a game should implement onResume() and onPause() - to take appropriate action when the activity loses focus */ - super.onPause(); - mView.pause(); - } - - static void log(String message) { - if (LOG_ENABLED) { - Log.v(LOG_TAG, message); - } - } -} - diff --git a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFboRS.java b/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFboRS.java deleted file mode 100644 index 3bf3ff1f3..000000000 --- a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFboRS.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2008 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.fountainfbo; - -import android.content.res.Resources; -import android.renderscript.Allocation; -import android.renderscript.Element; -import android.renderscript.Mesh; -import android.renderscript.ProgramFragment; -import android.renderscript.ProgramFragmentFixedFunction; -import android.renderscript.RenderScriptGL; -import android.renderscript.Type; - -public class FountainFboRS { - public static final int PART_COUNT = 50000; - - public FountainFboRS() { - } - - private Resources mRes; - private RenderScriptGL mRS; - private ScriptC_fountainfbo mScript; - private Allocation mColorBuffer; - private ProgramFragment mProgramFragment; - private ProgramFragment mTextureProgramFragment; - public void init(RenderScriptGL rs, Resources res) { - mRS = rs; - mRes = res; - - ScriptField_Point points = new ScriptField_Point(mRS, PART_COUNT); - - Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS); - smb.addVertexAllocation(points.getAllocation()); - smb.addIndexSetType(Mesh.Primitive.POINT); - Mesh sm = smb.create(); - - mScript = new ScriptC_fountainfbo(mRS, mRes, R.raw.fountainfbo); - mScript.set_partMesh(sm); - mScript.bind_point(points); - - ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs); - pfb.setVaryingColor(true); - mProgramFragment = pfb.create(); - mScript.set_gProgramFragment(mProgramFragment); - - /* Second fragment shader to use a texture (framebuffer object) to draw with */ - pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE, - ProgramFragmentFixedFunction.Builder.Format.RGBA, 0); - - /* Set the fragment shader in the Renderscript runtime */ - mTextureProgramFragment = pfb.create(); - mScript.set_gTextureProgramFragment(mTextureProgramFragment); - - /* Create the allocation for the color buffer */ - Type.Builder colorBuilder = new Type.Builder(mRS, Element.RGBA_8888(mRS)); - colorBuilder.setX(256).setY(256); - mColorBuffer = Allocation.createTyped(mRS, colorBuilder.create(), - Allocation.USAGE_GRAPHICS_TEXTURE | - Allocation.USAGE_GRAPHICS_RENDER_TARGET); - - /* Set the allocation in the Renderscript runtime */ - mScript.set_gColorBuffer(mColorBuffer); - - mRS.bindRootScript(mScript); - } - - boolean holdingColor[] = new boolean[10]; - public void newTouchPosition(float x, float y, float pressure, int id) { - if (id >= holdingColor.length) { - return; - } - int rate = (int)(pressure * pressure * 500.f); - if (rate > 500) { - rate = 500; - } - if (rate > 0) { - mScript.invoke_addParticles(rate, x, y, id, !holdingColor[id]); - holdingColor[id] = true; - } else { - holdingColor[id] = false; - } - - } -} - diff --git a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFboView.java b/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFboView.java deleted file mode 100644 index 6e40da346..000000000 --- a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/FountainFboView.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2008 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.fountainfbo; - - -import android.renderscript.RSTextureView; -import android.renderscript.RenderScriptGL; -import android.content.Context; -import android.view.MotionEvent; - -public class FountainFboView extends RSTextureView { - - public FountainFboView(Context context) { - super(context); - } - - private RenderScriptGL mRS; - private FountainFboRS mRender; - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - android.util.Log.e("rs", "onAttachedToWindow"); - if (mRS == null) { - RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); - mRS = createRenderScriptGL(sc); - mRender = new FountainFboRS(); - mRender.init(mRS, getResources()); - } - } - - @Override - protected void onDetachedFromWindow() { - super.onDetachedFromWindow(); - android.util.Log.e("rs", "onDetachedFromWindow"); - if (mRS != null) { - mRS = null; - destroyRenderScriptGL(); - } - } - - - @Override - public boolean onTouchEvent(MotionEvent ev) - { - int act = ev.getActionMasked(); - if (act == ev.ACTION_UP) { - mRender.newTouchPosition(0, 0, 0, ev.getPointerId(0)); - return false; - } else if (act == MotionEvent.ACTION_POINTER_UP) { - // only one pointer going up, we can get the index like this - int pointerIndex = ev.getActionIndex(); - int pointerId = ev.getPointerId(pointerIndex); - mRender.newTouchPosition(0, 0, 0, pointerId); - } - int count = ev.getHistorySize(); - int pcount = ev.getPointerCount(); - - for (int p=0; p < pcount; p++) { - int id = ev.getPointerId(p); - mRender.newTouchPosition(ev.getX(p), - ev.getY(p), - ev.getPressure(p), - id); - - for (int i=0; i < count; i++) { - mRender.newTouchPosition(ev.getHistoricalX(p, i), - ev.getHistoricalY(p, i), - ev.getHistoricalPressure(p, i), - id); - } - } - return true; - } -} - - diff --git a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/fountainfbo.rs b/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/fountainfbo.rs deleted file mode 100644 index 763f6bacf..000000000 --- a/samples/RenderScript/FountainFbo/src/com/example/android/rs/fountainfbo/fountainfbo.rs +++ /dev/null @@ -1,106 +0,0 @@ -// Fountain test script -#pragma version(1) - -#pragma rs java_package_name(com.example.android.rs.fountainfbo) - -#pragma stateFragment(parent) - -#include "rs_graphics.rsh" - -static int newPart = 0; -rs_mesh partMesh; -rs_program_vertex gProgramVertex; - -//allocation for color buffer -rs_allocation gColorBuffer; -//fragment shader for rendering without a texture (used for rendering to framebuffer object) -rs_program_fragment gProgramFragment; -//fragment shader for rendering with a texture (used for rendering to default framebuffer) -rs_program_fragment gTextureProgramFragment; - -typedef struct __attribute__((packed, aligned(4))) Point { - float2 delta; - float2 position; - uchar4 color; -} Point_t; -Point_t *point; - -int root() { - float dt = min(rsGetDt(), 0.1f); - rsgClearColor(0.f, 0.f, 0.f, 1.f); - const float height = rsgGetHeight(); - const int size = rsAllocationGetDimX(rsGetAllocation(point)); - float dy2 = dt * (10.f); - Point_t * p = point; - for (int ct=0; ct < size; ct++) { - p->delta.y += dy2; - p->position += p->delta; - if ((p->position.y > height) && (p->delta.y > 0)) { - p->delta.y *= -0.3f; - } - p++; - } - //Tell Renderscript runtime to render to the frame buffer object - rsgBindColorTarget(gColorBuffer, 0); - - //Begin rendering on a white background - rsgClearColor(1.f, 1.f, 1.f, 1.f); - rsgDrawMesh(partMesh); - - //When done, tell Renderscript runtime to stop rendering to framebuffer object - rsgClearAllRenderTargets(); - - //Bind a new fragment shader that declares the framebuffer object to be used as a texture - rsgBindProgramFragment(gTextureProgramFragment); - - //Bind the framebuffer object to the fragment shader at slot 0 as a texture - rsgBindTexture(gTextureProgramFragment, 0, gColorBuffer); - - //Draw a quad using the framebuffer object as the texture - float startX = 10, startY = 10; - float s = 256; - rsgDrawQuadTexCoords(startX, startY, 0, 0, 1, - startX, startY + s, 0, 0, 0, - startX + s, startY + s, 0, 1, 0, - startX + s, startY, 0, 1, 1); - - //Rebind the original fragment shader to render as normal - rsgBindProgramFragment(gProgramFragment); - - //Render the main scene - rsgDrawMesh(partMesh); - - return 1; -} - -static float4 partColor[10]; -void addParticles(int rate, float x, float y, int index, bool newColor) -{ - if (newColor) { - partColor[index].x = rsRand(0.5f, 1.0f); - partColor[index].y = rsRand(1.0f); - partColor[index].z = rsRand(1.0f); - } - float rMax = ((float)rate) * 0.02f; - int size = rsAllocationGetDimX(rsGetAllocation(point)); - uchar4 c = rsPackColorTo8888(partColor[index]); - - Point_t * np = &point[newPart]; - float2 p = {x, y}; - while (rate--) { - float angle = rsRand(3.14f * 2.f); - float len = rsRand(rMax); - np->delta.x = len * sin(angle); - np->delta.y = len * cos(angle); - np->position = p; - np->color = c; - newPart++; - np++; - if (newPart >= size) { - newPart = 0; - np = &point[newPart]; - } - } -} - - diff --git a/samples/RenderScript/HelloCompute/Android.mk b/samples/RenderScript/HelloCompute/Android.mk deleted file mode 100644 index e19f35103..000000000 --- a/samples/RenderScript/HelloCompute/Android.mk +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (C) 2011 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 := optional - -LOCAL_SRC_FILES := $(call all-java-files-under, src) \ - $(call all-renderscript-files-under, src) - -LOCAL_PACKAGE_NAME := RsHelloCompute - -include $(BUILD_PACKAGE) diff --git a/samples/RenderScript/HelloCompute/AndroidManifest.xml b/samples/RenderScript/HelloCompute/AndroidManifest.xml deleted file mode 100644 index 73e1110f0..000000000 --- a/samples/RenderScript/HelloCompute/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/samples/RenderScript/HelloCompute/_index.html b/samples/RenderScript/HelloCompute/_index.html deleted file mode 100644 index abfd9784a..000000000 --- a/samples/RenderScript/HelloCompute/_index.html +++ /dev/null @@ -1,2 +0,0 @@ -

A Renderscript compute sample that filters a bitmap. No Renderscript graphics APIs are used -in this sample.

\ No newline at end of file diff --git a/samples/RenderScript/HelloCompute/res/drawable/data.jpg b/samples/RenderScript/HelloCompute/res/drawable/data.jpg deleted file mode 100644 index 81a87b172..000000000 Binary files a/samples/RenderScript/HelloCompute/res/drawable/data.jpg and /dev/null differ diff --git a/samples/RenderScript/HelloCompute/res/layout/main.xml b/samples/RenderScript/HelloCompute/res/layout/main.xml deleted file mode 100644 index 3f7de4313..000000000 --- a/samples/RenderScript/HelloCompute/res/layout/main.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - diff --git a/samples/RenderScript/HelloCompute/src/com/example/android/rs/hellocompute/HelloCompute.java b/samples/RenderScript/HelloCompute/src/com/example/android/rs/hellocompute/HelloCompute.java deleted file mode 100644 index 0d6c47be1..000000000 --- a/samples/RenderScript/HelloCompute/src/com/example/android/rs/hellocompute/HelloCompute.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2011 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.hellocompute; - -import android.app.Activity; -import android.os.Bundle; -import android.graphics.BitmapFactory; -import android.graphics.Bitmap; -import android.renderscript.RenderScript; -import android.renderscript.Allocation; -import android.widget.ImageView; - -public class HelloCompute extends Activity { - private Bitmap mBitmapIn; - private Bitmap mBitmapOut; - - private RenderScript mRS; - private Allocation mInAllocation; - private Allocation mOutAllocation; - private ScriptC_mono mScript; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - mBitmapIn = loadBitmap(R.drawable.data); - mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(), - mBitmapIn.getConfig()); - - ImageView in = (ImageView) findViewById(R.id.displayin); - in.setImageBitmap(mBitmapIn); - - ImageView out = (ImageView) findViewById(R.id.displayout); - out.setImageBitmap(mBitmapOut); - - createScript(); - } - - - private void createScript() { - mRS = RenderScript.create(this); - - mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn, - Allocation.MipmapControl.MIPMAP_NONE, - Allocation.USAGE_SCRIPT); - mOutAllocation = Allocation.createTyped(mRS, mInAllocation.getType()); - - mScript = new ScriptC_mono(mRS, getResources(), R.raw.mono); - - mScript.forEach_root(mInAllocation, mOutAllocation); - mOutAllocation.copyTo(mBitmapOut); - } - - private Bitmap loadBitmap(int resource) { - final BitmapFactory.Options options = new BitmapFactory.Options(); - options.inPreferredConfig = Bitmap.Config.ARGB_8888; - return BitmapFactory.decodeResource(getResources(), resource, options); - } -} diff --git a/samples/RenderScript/HelloCompute/src/com/example/android/rs/hellocompute/mono.rs b/samples/RenderScript/HelloCompute/src/com/example/android/rs/hellocompute/mono.rs deleted file mode 100644 index 08592f558..000000000 --- a/samples/RenderScript/HelloCompute/src/com/example/android/rs/hellocompute/mono.rs +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2011 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.hellocompute) - -const static float3 gMonoMult = {0.299f, 0.587f, 0.114f}; - -void root(const uchar4 *v_in, uchar4 *v_out) { - float4 f4 = rsUnpackColor8888(*v_in); - - float3 mono = dot(f4.rgb, gMonoMult); - *v_out = rsPackColorTo8888(mono); -} - diff --git a/samples/RenderScript/HelloWorld/Android.mk b/samples/RenderScript/HelloWorld/Android.mk deleted file mode 100644 index 2af1cdb68..000000000 --- a/samples/RenderScript/HelloWorld/Android.mk +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright (C) 2011 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 := optional - -LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src) - -LOCAL_PACKAGE_NAME := RsHelloWorld - -LOCAL_SDK_VERSION := current - -include $(BUILD_PACKAGE) diff --git a/samples/RenderScript/HelloWorld/AndroidManifest.xml b/samples/RenderScript/HelloWorld/AndroidManifest.xml deleted file mode 100644 index 1d37dc980..000000000 --- a/samples/RenderScript/HelloWorld/AndroidManifest.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - diff --git a/samples/RenderScript/HelloWorld/_index.html b/samples/RenderScript/HelloWorld/_index.html deleted file mode 100644 index 4cab73817..000000000 --- a/samples/RenderScript/HelloWorld/_index.html +++ /dev/null @@ -1 +0,0 @@ -

A Renderscript graphics application that draws the text "Hello, World!" where the user touches.

\ No newline at end of file diff --git a/samples/RenderScript/HelloWorld/res/drawable/test_pattern.png b/samples/RenderScript/HelloWorld/res/drawable/test_pattern.png deleted file mode 100644 index e7d145554..000000000 Binary files a/samples/RenderScript/HelloWorld/res/drawable/test_pattern.png and /dev/null differ diff --git a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorld.java b/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorld.java deleted file mode 100644 index 9b1697b2c..000000000 --- a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorld.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2011 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.helloworld; - -import android.app.Activity; -import android.os.Bundle; - -// Renderscript activity -public class HelloWorld extends Activity { - - // Custom view to use with RenderScript - private HelloWorldView mView; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - // Create our view and set it as the content of our Activity - mView = new HelloWorldView(this); - setContentView(mView); - } - - @Override - protected void onResume() { - // Ideally an app should implement onResume() and onPause() - // to take appropriate action when the activity loses focus - super.onResume(); - mView.resume(); - } - - @Override - protected void onPause() { - // Ideally an app should implement onResume() and onPause() - // to take appropriate action when the activity loses focus - super.onPause(); - mView.pause(); - } - -} - diff --git a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldRS.java b/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldRS.java deleted file mode 100644 index 431641173..000000000 --- a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldRS.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2011 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.helloworld; - -import android.content.res.Resources; -import android.renderscript.*; - -// This is the renderer for the HelloWorldView -public class HelloWorldRS { - private Resources mRes; - private RenderScriptGL mRS; - - private ScriptC_helloworld mScript; - - public HelloWorldRS() { - } - - // This provides us with the renderscript context and resources that - // allow us to create the script that does rendering - public void init(RenderScriptGL rs, Resources res) { - mRS = rs; - mRes = res; - initRS(); - } - - public void onActionDown(int x, int y) { - mScript.set_gTouchX(x); - mScript.set_gTouchY(y); - } - - private void initRS() { - mScript = new ScriptC_helloworld(mRS, mRes, R.raw.helloworld); - mRS.bindRootScript(mScript); - } -} - - - diff --git a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldView.java b/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldView.java deleted file mode 100644 index 557ebc5a4..000000000 --- a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/HelloWorldView.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2011 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.helloworld; - -import android.renderscript.RSSurfaceView; -import android.renderscript.RenderScriptGL; - -import android.content.Context; -import android.view.MotionEvent; - -public class HelloWorldView extends RSSurfaceView { - // Renderscipt context - private RenderScriptGL mRS; - // Script that does the rendering - private HelloWorldRS mRender; - - public HelloWorldView(Context context) { - super(context); - ensureRenderScript(); - } - - private void ensureRenderScript() { - if (mRS == null) { - // Initialize renderscript with desired surface characteristics. - // In this case, just use the defaults - RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig(); - mRS = createRenderScriptGL(sc); - // Create an instance of the script that does the rendering - mRender = new HelloWorldRS(); - mRender.init(mRS, getResources()); - } - } - - @Override - protected void onAttachedToWindow() { - super.onAttachedToWindow(); - ensureRenderScript(); - } - - @Override - protected void onDetachedFromWindow() { - // Handle the system event and clean up - mRender = null; - if (mRS != null) { - mRS = null; - destroyRenderScriptGL(); - } - } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - // Pass touch events from the system to the rendering script - if (ev.getAction() == MotionEvent.ACTION_DOWN) { - mRender.onActionDown((int)ev.getX(), (int)ev.getY()); - return true; - } - - return false; - } -} - - diff --git a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/helloworld.rs b/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/helloworld.rs deleted file mode 100644 index bcf624e20..000000000 --- a/samples/RenderScript/HelloWorld/src/com/example/android/rs/helloworld/helloworld.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2011 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) - -// Tell which java package name the reflected files should belong to -#pragma rs java_package_name(com.example.android.rs.helloworld) - -// Built-in header with graphics API's -#include "rs_graphics.rsh" - -// gTouchX and gTouchY are variables that will be reflected for use -// by the java API. We can use them to notify the script of touch events. -int gTouchX; -int gTouchY; - -// This is invoked automatically when the script is created -void init() { - gTouchX = 50.0f; - gTouchY = 50.0f; -} - -int root(void) { - - // Clear the background color - rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f); - // Tell the runtime what the font color should be - rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f); - // Introuduce ourselves to the world by drawing a greeting - // at the position user touched on the screen - rsgDrawText("Hello World!", gTouchX, gTouchY); - - // Return value tells RS roughly how often to redraw - // in this case 20 ms - return 20; -} diff --git a/samples/RenderScript/Levels/Android.mk b/samples/RenderScript/Levels/Android.mk deleted file mode 100644 index 3f1445daf..000000000 --- a/samples/RenderScript/Levels/Android.mk +++ /dev/null @@ -1,26 +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 := optional - -LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src) - -LOCAL_PACKAGE_NAME := LevelsRS - -include $(BUILD_PACKAGE) diff --git a/samples/RenderScript/Levels/AndroidManifest.xml b/samples/RenderScript/Levels/AndroidManifest.xml deleted file mode 100644 index 829404843..000000000 --- a/samples/RenderScript/Levels/AndroidManifest.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/RenderScript/Levels/res/drawable-nodpi/city.png b/samples/RenderScript/Levels/res/drawable-nodpi/city.png deleted file mode 100644 index 856eeff59..000000000 Binary files a/samples/RenderScript/Levels/res/drawable-nodpi/city.png and /dev/null differ diff --git a/samples/RenderScript/Levels/res/layout/main.xml b/samples/RenderScript/Levels/res/layout/main.xml deleted file mode 100644 index a6a075cbe..000000000 --- a/samples/RenderScript/Levels/res/layout/main.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - - - -