Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5585e36a authored by Jason Sams's avatar Jason Sams
Browse files

Balls test app.

Change-Id: I842f43e37145f8112120e2bd49925f81c588c40c
parent c75529f5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -141,6 +141,13 @@ public class RenderScriptGL extends RenderScript {
        nContextSetSurface(w, h, mSurface);
    }

    public int getHeight() {
        return mHeight;
    }

    public int getWidth() {
        return mWidth;
    }

    void pause() {
        validate();
+0 −73
Original line number Diff line number Diff line
@@ -76,78 +76,5 @@ public class ScriptC extends Script {
        rs.nScriptCSetScript(pgm, 0, pgmLength);
        return rs.nScriptCCreate();
    }

    public static class Builder extends Script.Builder {
        byte[] mProgram;
        int mProgramLength;

        public Builder(RenderScript rs) {
            super(rs);
        }

        public void setScript(String s) {
            try {
                mProgram = s.getBytes("UTF-8");
                mProgramLength = mProgram.length;
            } catch (java.io.UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
        }

        public void setScript(Resources resources, int id) {
            InputStream is = resources.openRawResource(id);
            try {
                try {
                    setScript(is);
                } finally {
                    is.close();
                }
            } catch(IOException e) {
                throw new Resources.NotFoundException();
            }
        }

        public void setScript(InputStream is) throws IOException {
            byte[] buf = new byte[1024];
            int currentPos = 0;
            while(true) {
                int bytesLeft = buf.length - currentPos;
                if (bytesLeft == 0) {
                    byte[] buf2 = new byte[buf.length * 2];
                    System.arraycopy(buf, 0, buf2, 0, buf.length);
                    buf = buf2;
                    bytesLeft = buf.length - currentPos;
                }
                int bytesRead = is.read(buf, currentPos, bytesLeft);
                if (bytesRead <= 0) {
                    break;
                }
                currentPos += bytesRead;
            }
            mProgram = buf;
            mProgramLength = currentPos;
        }

        static synchronized ScriptC internalCreate(Builder b) {
            b.mRS.nScriptCBegin();

            android.util.Log.e("rs", "len = " + b.mProgramLength);
            b.mRS.nScriptCSetScript(b.mProgram, 0, b.mProgramLength);

            int id = b.mRS.nScriptCCreate();
            ScriptC obj = new ScriptC(id, b.mRS);
            return obj;
        }

        public void addDefine(String name, int value) {}
        public void addDefine(String name, float value) {}
        public void addDefines(Class cl) {}
        public void addDefines(Object o) {}
        void addDefines(Field[] fields, int mask, Object o) {}

        public ScriptC create() {
            return internalCreate(this);
        }
    }
}
+31 −0
Original line number Diff line number Diff line
#
# 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.
#

ifneq ($(TARGET_SIMULATOR),true)

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_STATIC_JAVA_LIBRARIES := android.renderscript

LOCAL_PACKAGE_NAME := Balls

include $(BUILD_PACKAGE)

endif
+15 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.balls">
    <application 
        android:label="Balls"
        android:icon="@drawable/test_pattern">
        <activity android:name="Balls"
                  android:screenOrientation="landscape">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
+413 B
Loading image diff...
Loading