M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#
# 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)
#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript
LOCAL_PACKAGE_NAME := Fountain
include $(BUILD_PACKAGE)
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.fountain">
<application
android:label="Fountain"
android:icon="@drawable/test_pattern">
<activity android:name="Fountain">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

@@ -0,0 +1,52 @@
// Fountain test script
#pragma version(1)
int newPart = 0;
int main(int launchID) {
int ct;
int count = Control->count;
int rate = Control->rate;
float height = getHeight();
struct point_s * p = (struct point_s *)point;
if (rate) {
float rMax = ((float)rate) * 0.005f;
int x = Control->x;
int y = Control->y;
int color = ((int)(Control->r * 255.f)) |
((int)(Control->g * 255.f)) << 8 |
((int)(Control->b * 255.f)) << 16 |
(0xf0 << 24);
struct point_s * np = &p[newPart];
while (rate--) {
vec2Rand((float *)&np->delta.x, rMax);
np->position.x = x;
np->position.y = y;
np->color = color;
newPart++;
np++;
if (newPart >= count) {
newPart = 0;
np = &p[newPart];
}
}
}
for (ct=0; ct < count; ct++) {
float dy = p->delta.y + 0.15f;
float posy = p->position.y + dy;
if ((posy > height) && (dy > 0)) {
dy *= -0.3f;
}
p->delta.y = dy;
p->position.x += p->delta.x;
p->position.y = posy;
p++;
}
uploadToBufferObject(NAMED_PartBuffer);
drawSimpleMesh(NAMED_PartMesh);
return 1;
}
@@ -0,0 +1,73 @@
// Fountain test script
#pragma version(1)
#include "rs_types.rsh"
#include "rs_math.rsh"
#include "rs_graphics.rsh"
static int newPart = 0;
typedef struct Control_s {
int x, y;
int rate;
int count;
float r, g, b;
rs_allocation partBuffer;
rs_mesh partMesh;
} Control_t;
Control_t *Control;
typedef struct Point_s{
float2 delta;
float2 position;
unsigned int color;
} Point_t;
Point_t *point;
int main(int launchID) {
int ct;
int count = Control->count;
int rate = Control->rate;
float height = getHeight();
Point_t * p = point;
if (rate) {
float rMax = ((float)rate) * 0.005f;
int x = Control->x;
int y = Control->y;
int color = ((int)(Control->r * 255.f)) |
((int)(Control->g * 255.f)) << 8 |
((int)(Control->b * 255.f)) << 16 |
(0xf0 << 24);
Point_t * np = &p[newPart];
while (rate--) {
np->delta = vec2Rand(rMax);
np->position.x = x;
np->position.y = y;
np->color = color;
newPart++;
np++;
if (newPart >= count) {
newPart = 0;
np = &p[newPart];
}
}
}
for (ct=0; ct < count; ct++) {
float dy = p->delta.y + 0.15f;
float posy = p->position.y + dy;
if ((posy > height) && (dy > 0)) {
dy *= -0.3f;
}
p->delta.y = dy;
p->position.x += p->delta.x;
p->position.y = posy;
p++;
}
uploadToBufferObject(Control->partBuffer);
drawSimpleMesh(Control->partMesh);
return 1;
}
@@ -0,0 +1,96 @@
/*
* 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.android.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.Config;
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 = DEBUG ? Config.LOGD : Config.LOGV;
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.onResume();
}
@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.onPause();
//Runtime.getRuntime().exit(0);
}
static void log(String message) {
if (LOG_ENABLED) {
Log.v(LOG_TAG, message);
}
}
}
@@ -0,0 +1,115 @@
/*
* 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.android.fountain;
import android.content.res.Resources;
import android.renderscript.*;
import android.util.Log;
public class FountainRS {
public static final int PART_COUNT = 20000;
static class SomeData {
public int x;
public int y;
public int rate;
public int count;
public float r;
public float g;
public float b;
}
public FountainRS() {
}
public void init(RenderScriptGL rs, Resources res, int width, int height) {
mRS = rs;
mRes = res;
initRS();
}
public void newTouchPosition(int x, int y, int rate) {
if (mSD.rate == 0) {
mSD.r = ((x & 0x1) != 0) ? 0.f : 1.f;
mSD.g = ((x & 0x2) != 0) ? 0.f : 1.f;
mSD.b = ((x & 0x4) != 0) ? 0.f : 1.f;
if ((mSD.r + mSD.g + mSD.b) < 0.9f) {
mSD.r = 0.8f;
mSD.g = 0.5f;
mSD.b = 1.f;
}
}
mSD.rate = rate;
mSD.x = x;
mSD.y = y;
mIntAlloc.data(mSD);
}
/////////////////////////////////////////
private Resources mRes;
private RenderScriptGL mRS;
private Allocation mIntAlloc;
private SimpleMesh mSM;
private SomeData mSD;
private Type mSDType;
private void initRS() {
mSD = new SomeData();
mSDType = Type.createFromClass(mRS, SomeData.class, 1, "SomeData");
mIntAlloc = Allocation.createTyped(mRS, mSDType);
mSD.count = PART_COUNT;
mIntAlloc.data(mSD);
Element.Builder eb = new Element.Builder(mRS);
eb.add(Element.createVector(mRS, Element.DataType.FLOAT_32, 2), "delta");
eb.add(Element.createAttrib(mRS, Element.DataType.FLOAT_32, Element.DataKind.POSITION, 2), "position");
eb.add(Element.createAttrib(mRS, Element.DataType.UNSIGNED_8, Element.DataKind.COLOR, 4), "color");
Element primElement = eb.create();
SimpleMesh.Builder smb = new SimpleMesh.Builder(mRS);
int vtxSlot = smb.addVertexType(primElement, PART_COUNT);
smb.setPrimitive(Primitive.POINT);
mSM = smb.create();
mSM.setName("PartMesh");
Allocation partAlloc = mSM.createVertexAllocation(vtxSlot);
partAlloc.setName("PartBuffer");
mSM.bindVertexAllocation(partAlloc, 0);
// All setup of named objects should be done by this point
// because we are about to compile the script.
ScriptC.Builder sb = new ScriptC.Builder(mRS);
sb.setScript(mRes, R.raw.fountain);
sb.setRoot(true);
sb.setType(mSDType, "Control", 0);
sb.setType(mSM.getVertexType(0), "point", 1);
Script script = sb.create();
script.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
script.bindAllocation(mIntAlloc, 0);
script.bindAllocation(partAlloc, 1);
mRS.contextBindRootScript(script);
}
}
@@ -0,0 +1,89 @@
/*
* 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.android.fountain;
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 FountainView extends RSSurfaceView {
public FountainView(Context context) {
super(context);
//setFocusable(true);
}
private RenderScriptGL mRS;
private FountainRS mRender;
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
if (mRS == null) {
mRS = createRenderScript(false);
mRS.contextSetSurface(w, h, holder.getSurface());
mRender = new FountainRS();
mRender.init(mRS, getResources(), w, h);
}
}
@Override
protected void onDetachedFromWindow() {
if(mRS != null) {
mRS = null;
destroyRenderScript();
}
}
@Override
public boolean onTouchEvent(MotionEvent ev)
{
int act = ev.getAction();
if (act == ev.ACTION_UP) {
mRender.newTouchPosition(0, 0, 0);
return false;
}
float rate = (ev.getPressure() * 50.f);
rate *= rate;
if(rate > 2000.f) {
rate = 2000.f;
}
mRender.newTouchPosition((int)ev.getX(), (int)ev.getY(), (int)rate);
return true;
}
}