initial commit
authorJorge Gorbe <slack@codemaniacs.com>
Wed, 30 May 2012 15:49:00 +0000 (17:49 +0200)
committerslack <slack@mint>
Wed, 30 May 2012 15:49:00 +0000 (17:49 +0200)
34 files changed:
Android.mk [new file with mode: 0644]
AndroidManifest.xml [new file with mode: 0644]
default.properties [new file with mode: 0644]
gen/com/slackito/testwallpaper/BuildConfig.java [new file with mode: 0644]
gen/com/slackito/testwallpaper/R.java [new file with mode: 0644]
gen/com/slackito/testwallpaper/ScriptC_testwallpaper.java [new file with mode: 0644]
gen/com/slackito/testwallpaper/ScriptField_SceneFpConsts.java [new file with mode: 0644]
gen/com/slackito/testwallpaper/ScriptField_SceneVpConsts.java [new file with mode: 0644]
gen/com/slackito/testwallpaper/ScriptField_Vertex_s.java [new file with mode: 0644]
gen/com/slackito/testwallpaper/testwallpaper.d [new file with mode: 0644]
proguard.cfg [new file with mode: 0644]
project.properties [new file with mode: 0644]
res/drawable-hdpi/icon.png [new file with mode: 0644]
res/drawable-mdpi/icon.png [new file with mode: 0644]
res/drawable-nodpi/beam.png [new file with mode: 0644]
res/drawable-nodpi/dot.png [new file with mode: 0644]
res/drawable-nodpi/wallpaper_thumb.png [new file with mode: 0644]
res/drawable-xhdpi/icon.png [new file with mode: 0644]
res/layout/main.xml [new file with mode: 0644]
res/raw/.~lock.bgmesh.csv# [new file with mode: 0644]
res/raw/post_fs.glsl [new file with mode: 0644]
res/raw/post_vs.glsl [new file with mode: 0644]
res/raw/scene_fs.glsl [new file with mode: 0644]
res/raw/scene_vs.glsl [new file with mode: 0644]
res/raw/testwallpaper.bc [new file with mode: 0644]
res/values/strings.xml [new file with mode: 0644]
res/xml/wallpaper.xml [new file with mode: 0644]
res/xml/wallpaper_settings.xml [new file with mode: 0644]
src/com/slackito/testwallpaper/TestWallpaperActivity.java [new file with mode: 0644]
src/com/slackito/testwallpaper/TestWallpaperRS.java [new file with mode: 0644]
src/com/slackito/testwallpaper/TestWallpaperService.java [new file with mode: 0644]
src/com/slackito/testwallpaper/TestWallpaperSettings.java [new file with mode: 0644]
src/com/slackito/testwallpaper/TestWallpaperView.java [new file with mode: 0644]
src/com/slackito/testwallpaper/testwallpaper.rs [new file with mode: 0644]

diff --git a/Android.mk b/Android.mk
new file mode 100644 (file)
index 0000000..f81c57c
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 2010 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-subdir-java-files) $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := PhaseBeam
+LOCAL_CERTIFICATE := shared
+
+LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
+
+include $(BUILD_PACKAGE)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644 (file)
index 0000000..1bf79a1
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+      package="com.slackito.testwallpaper"
+      android:versionCode="1"
+      android:versionName="1.0">
+    <uses-sdk android:minSdkVersion="14" />
+
+    <uses-feature android:name="android.software.live_wallpaper" />
+
+    <application android:icon="@drawable/icon" android:label="@string/wallpaper_label">
+        <service
+               android:name=".TestWallpaperService"
+            android:label="@string/wallpaper_label"
+            android:permission="android.permission.BIND_WALLPAPER">
+            <intent-filter>
+                <action android:name="android.service.wallpaper.WallpaperService" />
+            </intent-filter>
+            <meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper" />
+        </service>
+    </application>
+</manifest>
\ No newline at end of file
diff --git a/default.properties b/default.properties
new file mode 100644 (file)
index 0000000..ede6e6b
--- /dev/null
@@ -0,0 +1,2 @@
+# Project target.
+target=android-14
diff --git a/gen/com/slackito/testwallpaper/BuildConfig.java b/gen/com/slackito/testwallpaper/BuildConfig.java
new file mode 100644 (file)
index 0000000..fda0e4f
--- /dev/null
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.slackito.testwallpaper;
+
+public final class BuildConfig {
+    public final static boolean DEBUG = true;
+}
\ No newline at end of file
diff --git a/gen/com/slackito/testwallpaper/R.java b/gen/com/slackito/testwallpaper/R.java
new file mode 100644 (file)
index 0000000..abc7d9a
--- /dev/null
@@ -0,0 +1,37 @@
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package com.slackito.testwallpaper;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int beam=0x7f020000;
+        public static final int dot=0x7f020001;
+        public static final int icon=0x7f020002;
+        public static final int wallpaper_thumb=0x7f020003;
+    }
+    public static final class layout {
+        public static final int main=0x7f030000;
+    }
+    public static final class raw {
+        public static final int post_fs=0x7f050000;
+        public static final int post_vs=0x7f050001;
+        public static final int scene_fs=0x7f050002;
+        public static final int scene_vs=0x7f050003;
+        public static final int testwallpaper=0x7f050004;
+    }
+    public static final class string {
+        public static final int wallpaper_author=0x7f060001;
+        public static final int wallpaper_description=0x7f060002;
+        public static final int wallpaper_label=0x7f060000;
+    }
+    public static final class xml {
+        public static final int wallpaper=0x7f040000;
+    }
+}
diff --git a/gen/com/slackito/testwallpaper/ScriptC_testwallpaper.java b/gen/com/slackito/testwallpaper/ScriptC_testwallpaper.java
new file mode 100644 (file)
index 0000000..706b92c
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: /home/slack/workspace/TestWallpaper/src/com/slackito/testwallpaper/testwallpaper.rs
+ */
+package com.slackito.testwallpaper;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptC_testwallpaper extends ScriptC {
+    // Constructor
+    public  ScriptC_testwallpaper(RenderScript rs, Resources resources, int id) {
+        super(rs, resources, id);
+    }
+
+    private final static int mExportVarIdx_gColorBuffer = 0;
+    private Allocation mExportVar_gColorBuffer;
+    public void set_gColorBuffer(Allocation v) {
+        mExportVar_gColorBuffer = v;
+        setVar(mExportVarIdx_gColorBuffer, v);
+    }
+
+    public Allocation get_gColorBuffer() {
+        return mExportVar_gColorBuffer;
+    }
+
+    private final static int mExportVarIdx_gQuadVertices = 1;
+    private ScriptField_Vertex_s mExportVar_gQuadVertices;
+    public void bind_gQuadVertices(ScriptField_Vertex_s v) {
+        mExportVar_gQuadVertices = v;
+        if (v == null) bindAllocation(null, mExportVarIdx_gQuadVertices);
+        else bindAllocation(v.getAllocation(), mExportVarIdx_gQuadVertices);
+    }
+
+    public ScriptField_Vertex_s get_gQuadVertices() {
+        return mExportVar_gQuadVertices;
+    }
+
+    private final static int mExportVarIdx_gQuadMesh = 2;
+    private Mesh mExportVar_gQuadMesh;
+    public void set_gQuadMesh(Mesh v) {
+        mExportVar_gQuadMesh = v;
+        setVar(mExportVarIdx_gQuadMesh, v);
+    }
+
+    public Mesh get_gQuadMesh() {
+        return mExportVar_gQuadMesh;
+    }
+
+    private final static int mExportVarIdx_densityDPI = 3;
+    private float mExportVar_densityDPI;
+    public void set_densityDPI(float v) {
+        mExportVar_densityDPI = v;
+        setVar(mExportVarIdx_densityDPI, v);
+    }
+
+    public float get_densityDPI() {
+        return mExportVar_densityDPI;
+    }
+
+    private final static int mExportVarIdx_xOffset = 4;
+    private float mExportVar_xOffset;
+    public void set_xOffset(float v) {
+        mExportVar_xOffset = v;
+        setVar(mExportVarIdx_xOffset, v);
+    }
+
+    public float get_xOffset() {
+        return mExportVar_xOffset;
+    }
+
+    private final static int mExportVarIdx_gSceneVP = 5;
+    private ProgramVertex mExportVar_gSceneVP;
+    public void set_gSceneVP(ProgramVertex v) {
+        mExportVar_gSceneVP = v;
+        setVar(mExportVarIdx_gSceneVP, v);
+    }
+
+    public ProgramVertex get_gSceneVP() {
+        return mExportVar_gSceneVP;
+    }
+
+    private final static int mExportVarIdx_gSceneFP = 6;
+    private ProgramFragment mExportVar_gSceneFP;
+    public void set_gSceneFP(ProgramFragment v) {
+        mExportVar_gSceneFP = v;
+        setVar(mExportVarIdx_gSceneFP, v);
+    }
+
+    public ProgramFragment get_gSceneFP() {
+        return mExportVar_gSceneFP;
+    }
+
+    private final static int mExportVarIdx_sceneVpConstants = 7;
+    private ScriptField_SceneVpConsts mExportVar_sceneVpConstants;
+    public void bind_sceneVpConstants(ScriptField_SceneVpConsts v) {
+        mExportVar_sceneVpConstants = v;
+        if (v == null) bindAllocation(null, mExportVarIdx_sceneVpConstants);
+        else bindAllocation(v.getAllocation(), mExportVarIdx_sceneVpConstants);
+    }
+
+    public ScriptField_SceneVpConsts get_sceneVpConstants() {
+        return mExportVar_sceneVpConstants;
+    }
+
+    private final static int mExportVarIdx_sceneFpConstants = 8;
+    private ScriptField_SceneFpConsts mExportVar_sceneFpConstants;
+    public void bind_sceneFpConstants(ScriptField_SceneFpConsts v) {
+        mExportVar_sceneFpConstants = v;
+        if (v == null) bindAllocation(null, mExportVarIdx_sceneFpConstants);
+        else bindAllocation(v.getAllocation(), mExportVarIdx_sceneFpConstants);
+    }
+
+    public ScriptField_SceneFpConsts get_sceneFpConstants() {
+        return mExportVar_sceneFpConstants;
+    }
+
+    private final static int mExportVarIdx_gPostVP = 9;
+    private ProgramVertex mExportVar_gPostVP;
+    public void set_gPostVP(ProgramVertex v) {
+        mExportVar_gPostVP = v;
+        setVar(mExportVarIdx_gPostVP, v);
+    }
+
+    public ProgramVertex get_gPostVP() {
+        return mExportVar_gPostVP;
+    }
+
+    private final static int mExportVarIdx_gPostFP = 10;
+    private ProgramFragment mExportVar_gPostFP;
+    public void set_gPostFP(ProgramFragment v) {
+        mExportVar_gPostFP = v;
+        setVar(mExportVarIdx_gPostFP, v);
+    }
+
+    public ProgramFragment get_gPostFP() {
+        return mExportVar_gPostFP;
+    }
+
+    private final static int mExportFuncIdx_renderScene = 0;
+    public void invoke_renderScene() {
+        invoke(mExportFuncIdx_renderScene);
+    }
+
+    private final static int mExportFuncIdx_renderPostFX = 1;
+    public void invoke_renderPostFX() {
+        invoke(mExportFuncIdx_renderPostFX);
+    }
+
+}
+
diff --git a/gen/com/slackito/testwallpaper/ScriptField_SceneFpConsts.java b/gen/com/slackito/testwallpaper/ScriptField_SceneFpConsts.java
new file mode 100644 (file)
index 0000000..327b8e4
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: /home/slack/workspace/TestWallpaper/src/com/slackito/testwallpaper/testwallpaper.rs
+ */
+package com.slackito.testwallpaper;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptField_SceneFpConsts extends android.renderscript.Script.FieldBase {
+    static public class Item {
+        public static final int sizeof = 8;
+
+        float offsetX;
+        float fracTime;
+
+        Item() {
+        }
+
+    }
+
+    private Item mItemArray[];
+    private FieldPacker mIOBuffer;
+    public static Element createElement(RenderScript rs) {
+        Element.Builder eb = new Element.Builder(rs);
+        eb.add(Element.F32(rs), "offsetX");
+        eb.add(Element.F32(rs), "fracTime");
+        return eb.create();
+    }
+
+    public  ScriptField_SceneFpConsts(RenderScript rs, int count) {
+        mItemArray = null;
+        mIOBuffer = null;
+        mElement = createElement(rs);
+        init(rs, count);
+    }
+
+    public  ScriptField_SceneFpConsts(RenderScript rs, int count, int usages) {
+        mItemArray = null;
+        mIOBuffer = null;
+        mElement = createElement(rs);
+        init(rs, count, usages);
+    }
+
+    private void copyToArrayLocal(Item i, FieldPacker fp) {
+        fp.addF32(i.offsetX);
+        fp.addF32(i.fracTime);
+    }
+
+    private void copyToArray(Item i, int index) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        mIOBuffer.reset(index * Item.sizeof);
+        copyToArrayLocal(i, mIOBuffer);
+    }
+
+    public synchronized void set(Item i, int index, boolean copyNow) {
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        mItemArray[index] = i;
+        if (copyNow)  {
+            copyToArray(i, index);
+            FieldPacker fp = new FieldPacker(Item.sizeof);
+            copyToArrayLocal(i, fp);
+            mAllocation.setFromFieldPacker(index, fp);
+        }
+
+    }
+
+    public synchronized Item get(int index) {
+        if (mItemArray == null) return null;
+        return mItemArray[index];
+    }
+
+    public synchronized void set_offsetX(int index, float v, boolean copyNow) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        if (mItemArray[index] == null) mItemArray[index] = new Item();
+        mItemArray[index].offsetX = v;
+        if (copyNow)  {
+            mIOBuffer.reset(index * Item.sizeof);
+            mIOBuffer.addF32(v);
+            FieldPacker fp = new FieldPacker(4);
+            fp.addF32(v);
+            mAllocation.setFromFieldPacker(index, 0, fp);
+        }
+
+    }
+
+    public synchronized void set_fracTime(int index, float v, boolean copyNow) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        if (mItemArray[index] == null) mItemArray[index] = new Item();
+        mItemArray[index].fracTime = v;
+        if (copyNow)  {
+            mIOBuffer.reset(index * Item.sizeof + 4);
+            mIOBuffer.addF32(v);
+            FieldPacker fp = new FieldPacker(4);
+            fp.addF32(v);
+            mAllocation.setFromFieldPacker(index, 1, fp);
+        }
+
+    }
+
+    public synchronized float get_offsetX(int index) {
+        if (mItemArray == null) return 0;
+        return mItemArray[index].offsetX;
+    }
+
+    public synchronized float get_fracTime(int index) {
+        if (mItemArray == null) return 0;
+        return mItemArray[index].fracTime;
+    }
+
+    public synchronized void copyAll() {
+        for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct);
+        mAllocation.setFromFieldPacker(0, mIOBuffer);
+    }
+
+    public synchronized void resize(int newSize) {
+        if (mItemArray != null)  {
+            int oldSize = mItemArray.length;
+            int copySize = Math.min(oldSize, newSize);
+            if (newSize == oldSize) return;
+            Item ni[] = new Item[newSize];
+            System.arraycopy(mItemArray, 0, ni, 0, copySize);
+            mItemArray = ni;
+        }
+
+        mAllocation.resize(newSize);
+        if (mIOBuffer != null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+    }
+
+}
+
diff --git a/gen/com/slackito/testwallpaper/ScriptField_SceneVpConsts.java b/gen/com/slackito/testwallpaper/ScriptField_SceneVpConsts.java
new file mode 100644 (file)
index 0000000..352276c
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: /home/slack/workspace/TestWallpaper/src/com/slackito/testwallpaper/testwallpaper.rs
+ */
+package com.slackito.testwallpaper;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptField_SceneVpConsts extends android.renderscript.Script.FieldBase {
+    static public class Item {
+        public static final int sizeof = 68;
+
+        Matrix4f MVP;
+        float scaleSize;
+
+        Item() {
+            MVP = new Matrix4f();
+        }
+
+    }
+
+    private Item mItemArray[];
+    private FieldPacker mIOBuffer;
+    public static Element createElement(RenderScript rs) {
+        Element.Builder eb = new Element.Builder(rs);
+        eb.add(Element.MATRIX_4X4(rs), "MVP");
+        eb.add(Element.F32(rs), "scaleSize");
+        return eb.create();
+    }
+
+    public  ScriptField_SceneVpConsts(RenderScript rs, int count) {
+        mItemArray = null;
+        mIOBuffer = null;
+        mElement = createElement(rs);
+        init(rs, count);
+    }
+
+    public  ScriptField_SceneVpConsts(RenderScript rs, int count, int usages) {
+        mItemArray = null;
+        mIOBuffer = null;
+        mElement = createElement(rs);
+        init(rs, count, usages);
+    }
+
+    private void copyToArrayLocal(Item i, FieldPacker fp) {
+        fp.addMatrix(i.MVP);
+        fp.addF32(i.scaleSize);
+    }
+
+    private void copyToArray(Item i, int index) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        mIOBuffer.reset(index * Item.sizeof);
+        copyToArrayLocal(i, mIOBuffer);
+    }
+
+    public synchronized void set(Item i, int index, boolean copyNow) {
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        mItemArray[index] = i;
+        if (copyNow)  {
+            copyToArray(i, index);
+            FieldPacker fp = new FieldPacker(Item.sizeof);
+            copyToArrayLocal(i, fp);
+            mAllocation.setFromFieldPacker(index, fp);
+        }
+
+    }
+
+    public synchronized Item get(int index) {
+        if (mItemArray == null) return null;
+        return mItemArray[index];
+    }
+
+    public synchronized void set_MVP(int index, Matrix4f v, boolean copyNow) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        if (mItemArray[index] == null) mItemArray[index] = new Item();
+        mItemArray[index].MVP = v;
+        if (copyNow)  {
+            mIOBuffer.reset(index * Item.sizeof);
+            mIOBuffer.addMatrix(v);
+            FieldPacker fp = new FieldPacker(64);
+            fp.addMatrix(v);
+            mAllocation.setFromFieldPacker(index, 0, fp);
+        }
+
+    }
+
+    public synchronized void set_scaleSize(int index, float v, boolean copyNow) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        if (mItemArray[index] == null) mItemArray[index] = new Item();
+        mItemArray[index].scaleSize = v;
+        if (copyNow)  {
+            mIOBuffer.reset(index * Item.sizeof + 64);
+            mIOBuffer.addF32(v);
+            FieldPacker fp = new FieldPacker(4);
+            fp.addF32(v);
+            mAllocation.setFromFieldPacker(index, 1, fp);
+        }
+
+    }
+
+    public synchronized Matrix4f get_MVP(int index) {
+        if (mItemArray == null) return null;
+        return mItemArray[index].MVP;
+    }
+
+    public synchronized float get_scaleSize(int index) {
+        if (mItemArray == null) return 0;
+        return mItemArray[index].scaleSize;
+    }
+
+    public synchronized void copyAll() {
+        for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct);
+        mAllocation.setFromFieldPacker(0, mIOBuffer);
+    }
+
+    public synchronized void resize(int newSize) {
+        if (mItemArray != null)  {
+            int oldSize = mItemArray.length;
+            int copySize = Math.min(oldSize, newSize);
+            if (newSize == oldSize) return;
+            Item ni[] = new Item[newSize];
+            System.arraycopy(mItemArray, 0, ni, 0, copySize);
+            mItemArray = ni;
+        }
+
+        mAllocation.resize(newSize);
+        if (mIOBuffer != null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+    }
+
+}
+
diff --git a/gen/com/slackito/testwallpaper/ScriptField_Vertex_s.java b/gen/com/slackito/testwallpaper/ScriptField_Vertex_s.java
new file mode 100644 (file)
index 0000000..98796fa
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * 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.
+ */
+
+/*
+ * This file is auto-generated. DO NOT MODIFY!
+ * The source Renderscript file: /home/slack/workspace/TestWallpaper/src/com/slackito/testwallpaper/testwallpaper.rs
+ */
+package com.slackito.testwallpaper;
+
+import android.renderscript.*;
+import android.content.res.Resources;
+
+/**
+ * @hide
+ */
+public class ScriptField_Vertex_s extends android.renderscript.Script.FieldBase {
+    static public class Item {
+        public static final int sizeof = 32;
+
+        Float3 position;
+        Float2 texCoord;
+
+        Item() {
+            position = new Float3();
+            texCoord = new Float2();
+        }
+
+    }
+
+    private Item mItemArray[];
+    private FieldPacker mIOBuffer;
+    public static Element createElement(RenderScript rs) {
+        Element.Builder eb = new Element.Builder(rs);
+        eb.add(Element.F32_3(rs), "position");
+        eb.add(Element.U32(rs), "#padding_1");
+        eb.add(Element.F32_2(rs), "texCoord");
+        eb.add(Element.U32(rs), "#padding_2");
+        eb.add(Element.U32(rs), "#padding_3");
+        return eb.create();
+    }
+
+    public  ScriptField_Vertex_s(RenderScript rs, int count) {
+        mItemArray = null;
+        mIOBuffer = null;
+        mElement = createElement(rs);
+        init(rs, count);
+    }
+
+    public  ScriptField_Vertex_s(RenderScript rs, int count, int usages) {
+        mItemArray = null;
+        mIOBuffer = null;
+        mElement = createElement(rs);
+        init(rs, count, usages);
+    }
+
+    private void copyToArrayLocal(Item i, FieldPacker fp) {
+        fp.addF32(i.position);
+        fp.skip(4);
+        fp.addF32(i.texCoord);
+        fp.skip(8);
+    }
+
+    private void copyToArray(Item i, int index) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        mIOBuffer.reset(index * Item.sizeof);
+        copyToArrayLocal(i, mIOBuffer);
+    }
+
+    public synchronized void set(Item i, int index, boolean copyNow) {
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        mItemArray[index] = i;
+        if (copyNow)  {
+            copyToArray(i, index);
+            FieldPacker fp = new FieldPacker(Item.sizeof);
+            copyToArrayLocal(i, fp);
+            mAllocation.setFromFieldPacker(index, fp);
+        }
+
+    }
+
+    public synchronized Item get(int index) {
+        if (mItemArray == null) return null;
+        return mItemArray[index];
+    }
+
+    public synchronized void set_position(int index, Float3 v, boolean copyNow) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        if (mItemArray[index] == null) mItemArray[index] = new Item();
+        mItemArray[index].position = v;
+        if (copyNow)  {
+            mIOBuffer.reset(index * Item.sizeof);
+            mIOBuffer.addF32(v);
+            FieldPacker fp = new FieldPacker(12);
+            fp.addF32(v);
+            mAllocation.setFromFieldPacker(index, 0, fp);
+        }
+
+    }
+
+    public synchronized void set_texCoord(int index, Float2 v, boolean copyNow) {
+        if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+        if (mItemArray == null) mItemArray = new Item[getType().getX() /* count */];
+        if (mItemArray[index] == null) mItemArray[index] = new Item();
+        mItemArray[index].texCoord = v;
+        if (copyNow)  {
+            mIOBuffer.reset(index * Item.sizeof + 16);
+            mIOBuffer.addF32(v);
+            FieldPacker fp = new FieldPacker(8);
+            fp.addF32(v);
+            mAllocation.setFromFieldPacker(index, 2, fp);
+        }
+
+    }
+
+    public synchronized Float3 get_position(int index) {
+        if (mItemArray == null) return null;
+        return mItemArray[index].position;
+    }
+
+    public synchronized Float2 get_texCoord(int index) {
+        if (mItemArray == null) return null;
+        return mItemArray[index].texCoord;
+    }
+
+    public synchronized void copyAll() {
+        for (int ct = 0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct);
+        mAllocation.setFromFieldPacker(0, mIOBuffer);
+    }
+
+    public synchronized void resize(int newSize) {
+        if (mItemArray != null)  {
+            int oldSize = mItemArray.length;
+            int copySize = Math.min(oldSize, newSize);
+            if (newSize == oldSize) return;
+            Item ni[] = new Item[newSize];
+            System.arraycopy(mItemArray, 0, ni, 0, copySize);
+            mItemArray = ni;
+        }
+
+        mAllocation.resize(newSize);
+        if (mIOBuffer != null) mIOBuffer = new FieldPacker(Item.sizeof * getType().getX()/* count */);
+    }
+
+}
+
diff --git a/gen/com/slackito/testwallpaper/testwallpaper.d b/gen/com/slackito/testwallpaper/testwallpaper.d
new file mode 100644 (file)
index 0000000..3ccb4fa
--- /dev/null
@@ -0,0 +1,19 @@
+/home/slack/workspace/TestWallpaper/res/raw/testwallpaper.bc \
+  /home/slack/workspace/TestWallpaper/gen/com/slackito/testwallpaper/ScriptC_testwallpaper.java \
+  /home/slack/workspace/TestWallpaper/gen/com/slackito/testwallpaper/ScriptField_SceneVpConsts.java \
+  /home/slack/workspace/TestWallpaper/gen/com/slackito/testwallpaper/ScriptField_Vertex_s.java \
+  /home/slack/workspace/TestWallpaper/gen/com/slackito/testwallpaper/ScriptField_SceneFpConsts.java: \
+  /home/slack/workspace/TestWallpaper/src/com/slackito/testwallpaper/testwallpaper.rs \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_core.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_types.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/clang-include/stdbool.h \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_allocation.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_atomic.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_cl.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_debug.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_math.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_matrix.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_object.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_quaternion.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_time.rsh \
+  /home/slack/android/android-sdk-linux/platform-tools/renderscript/include/rs_graphics.rsh
diff --git a/proguard.cfg b/proguard.cfg
new file mode 100644 (file)
index 0000000..b1cdf17
--- /dev/null
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+    native <methods>;
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+    public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+   public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+    public static **[] values();
+    public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+  public static final android.os.Parcelable$Creator *;
+}
diff --git a/project.properties b/project.properties
new file mode 100644 (file)
index 0000000..8937e94
--- /dev/null
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-14
diff --git a/res/drawable-hdpi/icon.png b/res/drawable-hdpi/icon.png
new file mode 100644 (file)
index 0000000..2eab6f2
Binary files /dev/null and b/res/drawable-hdpi/icon.png differ
diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png
new file mode 100644 (file)
index 0000000..63aec6f
Binary files /dev/null and b/res/drawable-mdpi/icon.png differ
diff --git a/res/drawable-nodpi/beam.png b/res/drawable-nodpi/beam.png
new file mode 100644 (file)
index 0000000..98196eb
Binary files /dev/null and b/res/drawable-nodpi/beam.png differ
diff --git a/res/drawable-nodpi/dot.png b/res/drawable-nodpi/dot.png
new file mode 100644 (file)
index 0000000..2eec7d3
Binary files /dev/null and b/res/drawable-nodpi/dot.png differ
diff --git a/res/drawable-nodpi/wallpaper_thumb.png b/res/drawable-nodpi/wallpaper_thumb.png
new file mode 100644 (file)
index 0000000..26055f1
Binary files /dev/null and b/res/drawable-nodpi/wallpaper_thumb.png differ
diff --git a/res/drawable-xhdpi/icon.png b/res/drawable-xhdpi/icon.png
new file mode 100644 (file)
index 0000000..8ea9c48
Binary files /dev/null and b/res/drawable-xhdpi/icon.png differ
diff --git a/res/layout/main.xml b/res/layout/main.xml
new file mode 100644 (file)
index 0000000..8eab2f8
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:orientation="vertical"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    >
+<TextView
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:text="@string/wallpaper_label"
+    />
+</LinearLayout>
diff --git a/res/raw/.~lock.bgmesh.csv# b/res/raw/.~lock.bgmesh.csv#
new file mode 100644 (file)
index 0000000..267767a
--- /dev/null
@@ -0,0 +1 @@
+,slack,ommadawn,13.05.2012 13:05,file:///home/slack/.libreoffice/3;
\ No newline at end of file
diff --git a/res/raw/post_fs.glsl b/res/raw/post_fs.glsl
new file mode 100644 (file)
index 0000000..3180ed6
--- /dev/null
@@ -0,0 +1,5 @@
+varying vec2 texCoord;
+
+void main() {
+    gl_FragColor = texture2D(UNI_Tex0, texCoord);
+}
diff --git a/res/raw/post_vs.glsl b/res/raw/post_vs.glsl
new file mode 100644 (file)
index 0000000..a28d632
--- /dev/null
@@ -0,0 +1,6 @@
+varying vec2 texCoord;
+
+void main() {
+    gl_Position = vec4(ATTRIB_position.x, ATTRIB_position.y, ATTRIB_position.z, 1.0);
+    texCoord = ATTRIB_texCoord;
+}
\ No newline at end of file
diff --git a/res/raw/scene_fs.glsl b/res/raw/scene_fs.glsl
new file mode 100644 (file)
index 0000000..4c7671f
--- /dev/null
@@ -0,0 +1,18 @@
+varying highp vec4 position;
+
+
+void main() {
+    //gl_FragColor = vec4(r, g, b, 1.0);
+    highp vec2 p = vec2(position.x, position.y);
+    p.x = p.x - UNI_offsetX + 0.5;
+       
+       float u = length(p);
+       float v = atan(p.y, p.x);
+       float t = (6.283*UNI_fracTime) / 0.5 + 1.0 / u;
+       
+       float intensity = abs(sin(t * 10.0 + v)+sin(v*8.0)) * .25 * u * 0.25;
+       vec3 col = vec3(-sin(v*4.0+v*2.0+6.283*UNI_fracTime), sin(u*8.0+v-6.283*UNI_fracTime), cos(u+v*3.0+6.283*UNI_fracTime))*16.0;
+       
+       gl_FragColor = vec4(col * intensity * (u * 4.0), 1.0);
+    
+}
\ No newline at end of file
diff --git a/res/raw/scene_vs.glsl b/res/raw/scene_vs.glsl
new file mode 100644 (file)
index 0000000..83c1f75
--- /dev/null
@@ -0,0 +1,7 @@
+varying highp vec4 position;
+
+void main() {
+    gl_Position = vec4(ATTRIB_position, 1.0);
+    //position = UNI_MVP * vec4(ATTRIB_position.x, ATTRIB_position.y, ATTRIB_position.z, 1.0) * UNI_scaleSize;
+    position = gl_Position;
+}
\ No newline at end of file
diff --git a/res/raw/testwallpaper.bc b/res/raw/testwallpaper.bc
new file mode 100644 (file)
index 0000000..6925d81
Binary files /dev/null and b/res/raw/testwallpaper.bc differ
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644 (file)
index 0000000..8fa4293
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="wallpaper_label">Test Wallpaper</string>
+    <string name="wallpaper_author">Jorge Gorbe</string>
+    <string name="wallpaper_description">Test wallpaper</string>
+</resources>
diff --git a/res/xml/wallpaper.xml b/res/xml/wallpaper.xml
new file mode 100644 (file)
index 0000000..71a9574
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/**
+ * Copyright (c) 2010, 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.
+ */
+-->
+
+<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
+    android:author="@string/wallpaper_author"
+    android:description="@string/wallpaper_description"
+    android:thumbnail="@drawable/wallpaper_thumb" />
diff --git a/res/xml/wallpaper_settings.xml b/res/xml/wallpaper_settings.xml
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/com/slackito/testwallpaper/TestWallpaperActivity.java b/src/com/slackito/testwallpaper/TestWallpaperActivity.java
new file mode 100644 (file)
index 0000000..903ad97
--- /dev/null
@@ -0,0 +1,16 @@
+package com.slackito.testwallpaper;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class TestWallpaperActivity extends Activity {
+
+    private TestWallpaperView mView;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mView = new TestWallpaperView(this);
+        setContentView(mView);
+    }
+}
\ No newline at end of file
diff --git a/src/com/slackito/testwallpaper/TestWallpaperRS.java b/src/com/slackito/testwallpaper/TestWallpaperRS.java
new file mode 100644 (file)
index 0000000..86d9e42
--- /dev/null
@@ -0,0 +1,241 @@
+package com.slackito.testwallpaper;
+
+import static android.renderscript.Sampler.Value.NEAREST;
+import static android.renderscript.Sampler.Value.WRAP;
+
+import android.content.res.Resources;
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.Float2;
+import android.renderscript.Matrix4f;
+import android.renderscript.Mesh;
+import android.renderscript.Program;
+import android.renderscript.Program.TextureType;
+import android.renderscript.ProgramFragment;
+import android.renderscript.ProgramFragmentFixedFunction;
+import android.renderscript.ProgramRaster;
+import android.renderscript.ProgramStore;
+import android.renderscript.ProgramVertex;
+import android.renderscript.ProgramVertexFixedFunction;
+import android.renderscript.RenderScriptGL;
+import android.renderscript.Sampler;
+import android.renderscript.Type;
+import android.renderscript.ProgramStore.BlendDstFunc;
+import android.renderscript.ProgramStore.BlendSrcFunc;
+import android.renderscript.Mesh.Primitive;
+import android.graphics.Color;
+import android.renderscript.Float3;
+import android.renderscript.Float4;
+import java.io.InputStreamReader;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import android.util.Log;
+
+public class TestWallpaperRS {
+    public static String LOG_TAG = "TestWallpaper";
+    private Resources mRes;
+    private RenderScriptGL mRS;
+    private ScriptC_testwallpaper mScript;
+    int mHeight;
+    int mWidth;
+
+    private ScriptField_SceneVpConsts mSceneVpConsts;
+    private ScriptField_SceneFpConsts mSceneFpConsts;
+
+    private ScriptField_Vertex_s mQuadVertices;
+    
+    private Allocation mColorBuffer;
+    
+    private int mDensityDPI;
+
+    boolean mInited = false;
+
+    public void init(int dpi, RenderScriptGL rs, Resources res, int width, int height) {
+        if (!mInited) {
+            mDensityDPI = dpi;
+
+            mRS = rs;
+            mRes = res;
+
+            mWidth = width;
+            mHeight = height;
+
+
+            /*
+            mDotParticles = new ScriptField_Particle(mRS, DOT_COUNT);
+            Mesh.AllocationBuilder smb2 = new Mesh.AllocationBuilder(mRS);
+            smb2.addVertexAllocation(mDotParticles.getAllocation());
+            smb2.addIndexSetType(Mesh.Primitive.POINT);
+            mDotMesh = smb2.create();
+            */
+
+
+            mScript = new ScriptC_testwallpaper(mRS, mRes, R.raw.testwallpaper);
+            //mScript.set_dotMesh(mDotMesh);
+            //mScript.bind_dotParticles(mDotParticles);
+            
+            mSceneVpConsts = new ScriptField_SceneVpConsts(mRS, 1);
+            mScript.bind_sceneVpConstants(mSceneVpConsts);
+
+            mSceneFpConsts = new ScriptField_SceneFpConsts(mRS, 1);
+            mScript.bind_sceneFpConstants(mSceneFpConsts);
+
+            createProgramVertex();
+            createProgramRaster();
+            createProgramFragmentStore();
+            createProgramFragment();
+            createBackgroundMesh();
+            loadTextures();
+            
+            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);
+            mScript.set_gColorBuffer(mColorBuffer);
+
+            mScript.set_densityDPI(mDensityDPI);
+
+            mRS.bindRootScript(mScript);
+
+            //mScript.invoke_init();
+            mInited = true;
+        }
+    }
+
+    private Matrix4f getProjectionNormalized(int w, int h) {
+        // range -1,1 in the narrow axis at z = 0.
+        Matrix4f m1 = new Matrix4f();
+        Matrix4f m2 = new Matrix4f();
+
+        if (w > h) {
+            float aspect = ((float) w) / h;
+            m1.loadFrustum(-aspect, aspect, -1, 1, 1, 100);
+        } else {
+            float aspect = ((float) h) / w;
+            m1.loadFrustum(-1, 1, -aspect, aspect, 1, 100);
+        }
+
+        
+        
+        m2.loadRotate(180, 0, 1, 0);
+        m1.loadMultiply(m1, m2);
+
+        m2.loadScale(-1, 1, 1);
+        m1.loadMultiply(m1, m2);
+
+        m2.loadTranslate(0, 0, 1);
+        m1.loadMultiply(m1, m2);
+        
+        return m1;
+    }
+
+    private void updateProjectionMatrices() {
+        Matrix4f projNorm = getProjectionNormalized(mWidth, mHeight);
+        ScriptField_SceneVpConsts.Item i = new ScriptField_SceneVpConsts.Item();
+        i.MVP = projNorm;
+        i.scaleSize = mDensityDPI / 240.0f;
+        mSceneVpConsts.set(i, 0, true);
+    }
+
+    private void createBackgroundMesh() {
+       mQuadVertices = new ScriptField_Vertex_s(mRS, 4);
+       mQuadVertices.set_position(0,  new Float3(2,-2,0),  false);
+       mQuadVertices.set_texCoord(0,  new Float2(1, 0),    false);
+       mQuadVertices.set_position(1,  new Float3(2,2,0),   false);
+       mQuadVertices.set_texCoord(1,  new Float2(1, 1),    false);
+       mQuadVertices.set_position(2,  new Float3(-2,-2,0), false);
+       mQuadVertices.set_texCoord(2,  new Float2(0, 0),    false);
+       mQuadVertices.set_position(3,  new Float3(-2,2,0),  false);
+       mQuadVertices.set_texCoord(3,  new Float2(0, 1),    false);
+       mQuadVertices.copyAll();
+       
+
+        Mesh.AllocationBuilder backgroundBuilder = new Mesh.AllocationBuilder(mRS);
+        backgroundBuilder.addIndexSetType(Primitive.TRIANGLE_STRIP);
+        backgroundBuilder.addVertexAllocation(mQuadVertices.getAllocation());
+        mScript.set_gQuadMesh(backgroundBuilder.create());
+        mScript.bind_gQuadVertices(mQuadVertices);
+    }
+
+    private Allocation loadTexture(int id) {
+        final Allocation allocation = Allocation.createFromBitmapResource(mRS, mRes, id);
+        return allocation;
+    }
+
+    private void loadTextures() {
+       /*
+        mDotAllocation = loadTexture(R.drawable.dot);
+        mBeamAllocation = loadTexture(R.drawable.beam);
+        mScript.set_textureDot(mDotAllocation);
+        mScript.set_textureBeam(mBeamAllocation);
+        */
+    }
+
+    private void createProgramVertex() {
+        updateProjectionMatrices();
+       
+       ProgramVertex.Builder backgroundBuilder = new ProgramVertex.Builder(mRS);
+        backgroundBuilder.setShader(mRes, R.raw.scene_vs);
+        backgroundBuilder.addInput(ScriptField_Vertex_s.createElement(mRS));
+        backgroundBuilder.addConstant(mSceneVpConsts.getType());
+        ProgramVertex programVertexBackground = backgroundBuilder.create();
+        programVertexBackground.bindConstants(mSceneVpConsts.getAllocation(), 0);
+        mScript.set_gSceneVP(programVertexBackground);
+
+       ProgramVertex.Builder textureBuilder = new ProgramVertex.Builder(mRS);
+        textureBuilder.setShader(mRes, R.raw.post_vs);
+        textureBuilder.addInput(ScriptField_Vertex_s.createElement(mRS));
+        textureBuilder.addConstant(mSceneVpConsts.getType());
+        ProgramVertex programVertexTexture = textureBuilder.create();
+        programVertexTexture.bindConstants(mSceneVpConsts.getAllocation(), 0);
+        mScript.set_gPostVP(programVertexTexture);
+    }
+
+    private void createProgramFragment() {
+        ProgramFragment.Builder backgroundBuilder = new ProgramFragment.Builder(mRS);
+        backgroundBuilder.setShader(mRes, R.raw.scene_fs);
+        backgroundBuilder.addConstant(mSceneFpConsts.getType());
+        ProgramFragment programFragmentBackground = backgroundBuilder.create();
+        programFragmentBackground.bindConstants(mSceneFpConsts.getAllocation(), 0);
+        mScript.set_gSceneFP(programFragmentBackground);
+
+        
+        ProgramFragment.Builder textureBuilder = new ProgramFragment.Builder(mRS);
+        textureBuilder.setShader(mRes, R.raw.post_fs);
+        textureBuilder.addTexture(TextureType.TEXTURE_2D);
+        ProgramFragment programFragmentTexture = textureBuilder.create();
+        mScript.set_gPostFP(programFragmentTexture);
+    }
+
+    private void createProgramRaster() {
+        ProgramRaster.Builder builder = new ProgramRaster.Builder(mRS);
+        builder.setPointSpriteEnabled(true);
+        ProgramRaster pr = builder.create();
+        mRS.bindProgramRaster(pr);
+    }
+
+    private void createProgramFragmentStore() {
+        ProgramStore.Builder builder = new ProgramStore.Builder(mRS);
+        builder.setBlendFunc(BlendSrcFunc.SRC_ALPHA, BlendDstFunc.ONE_MINUS_SRC_ALPHA);
+        mRS.bindProgramStore(builder.create());
+    }
+
+    public void start() {
+        mRS.bindRootScript(mScript);
+    }
+
+    public void stop() {
+        mRS.bindRootScript(null);
+    }
+
+    public void setOffset(float xOffset, float yOffset, int xPixels, int yPixels) {
+       //Log.d("TestWallpaper", "Set Xoffset = "+Float.toString(xOffset));
+        mScript.set_xOffset(xOffset);
+    }
+
+    public void resize(int w, int h) {
+       
+    }
+
+}
diff --git a/src/com/slackito/testwallpaper/TestWallpaperService.java b/src/com/slackito/testwallpaper/TestWallpaperService.java
new file mode 100644 (file)
index 0000000..c0da873
--- /dev/null
@@ -0,0 +1,119 @@
+package com.slackito.testwallpaper;
+
+import android.app.Service;
+import android.content.SharedPreferences;
+import android.graphics.PixelFormat;
+import android.os.Bundle;
+import android.renderscript.RenderScript;
+import android.renderscript.RenderScriptGL;
+import android.service.wallpaper.WallpaperService;
+import android.util.DisplayMetrics;
+import android.view.SurfaceHolder;
+import android.view.WindowManager;
+
+public class TestWallpaperService extends WallpaperService {
+       
+       public static final String SHARED_PREFS_NAME = "TestWallpaperSettings";
+
+    @Override
+    public Engine onCreateEngine() {
+        return new RenderScriptEngine();
+    }
+    
+    private class RenderScriptEngine extends Engine {
+        private RenderScriptGL mRenderScript = null;
+        private TestWallpaperRS mWallpaperRS = null;
+        private int mDensityDPI;
+
+        @Override
+        public void onCreate(SurfaceHolder surfaceHolder) {
+            super.onCreate(surfaceHolder);
+            setTouchEventsEnabled(true);
+            surfaceHolder.setSizeFromLayout();
+            surfaceHolder.setFormat(PixelFormat.RGB_332);
+
+            DisplayMetrics metrics = new DisplayMetrics();
+            ((WindowManager) getApplication().getSystemService(Service.WINDOW_SERVICE))
+                    .getDefaultDisplay().getMetrics(metrics);
+            mDensityDPI = metrics.densityDpi;
+        }
+
+        @Override
+        public void onDestroy() {
+            super.onDestroy();
+            destroyRenderer();
+        }
+
+        public void destroyRenderer() {
+            if (mWallpaperRS != null) {
+                mWallpaperRS.stop();
+                mWallpaperRS = null;
+            }
+
+            if (mRenderScript != null) {
+                mRenderScript.setSurface(null, 0, 0);
+                mRenderScript.destroy();
+                mRenderScript = null;
+            }
+        }
+
+        @Override
+        public void onSurfaceCreated(SurfaceHolder surfaceHolder) {
+            super.onSurfaceCreated(surfaceHolder);
+
+            RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
+            mRenderScript = new RenderScriptGL(TestWallpaperService.this, sc);
+            mRenderScript.setPriority(RenderScript.Priority.NORMAL);
+        }
+
+        @Override
+        public void onSurfaceDestroyed(SurfaceHolder surfaceHolder) {
+            super.onSurfaceDestroyed(surfaceHolder);
+            destroyRenderer();
+        }
+
+        @Override
+        public void onSurfaceChanged(SurfaceHolder surfaceHolder, int format, int width,
+                int height) {
+            super.onSurfaceChanged(surfaceHolder, format, width, height);
+
+            if (mRenderScript != null) {
+                mRenderScript.setSurface(surfaceHolder, width, height);
+            }
+
+            if (mWallpaperRS == null) {
+                mWallpaperRS = new TestWallpaperRS();
+                mWallpaperRS.init(mDensityDPI, mRenderScript, getResources(), width, height);
+                mWallpaperRS.start();
+            }
+
+            mWallpaperRS.resize(width, height);
+        }
+
+        @Override
+        public Bundle onCommand(String action, int x, int y, int z, Bundle extras,
+                boolean resultRequested) {
+            return null;
+        }
+
+        @Override
+        public void onVisibilityChanged(boolean visible) {
+            super.onVisibilityChanged(visible);
+            if (mWallpaperRS != null) {
+                if (visible) {
+                    mWallpaperRS.start();
+                } else {
+                    mWallpaperRS.stop();
+                }
+            }
+        }
+
+        @Override
+        public void onOffsetsChanged(float xOffset, float yOffset, float xOffsetStep,
+                float yOffsetStep, int xPixelOffset, int yPixelOffset) {
+            mWallpaperRS.setOffset(xOffset, yOffset, xPixelOffset, yPixelOffset);
+        }
+        
+    } // engine
+
+}
\ No newline at end of file
diff --git a/src/com/slackito/testwallpaper/TestWallpaperSettings.java b/src/com/slackito/testwallpaper/TestWallpaperSettings.java
new file mode 100644 (file)
index 0000000..831099b
--- /dev/null
@@ -0,0 +1,25 @@
+package com.slackito.testwallpaper;
+
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+public class TestWallpaperSettings extends PreferenceActivity
+       implements SharedPreferences.OnSharedPreferenceChangeListener
+{
+       
+       @Override
+       protected void onCreate(Bundle icicle) {
+           super.onCreate(icicle);
+           getPreferenceManager().setSharedPreferencesName(TestWallpaperService.SHARED_PREFS_NAME);
+           addPreferencesFromResource(R.xml.flash_settings);
+           getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
+       }
+
+
+       public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+                       String key) {
+               
+       }
+
+}
diff --git a/src/com/slackito/testwallpaper/TestWallpaperView.java b/src/com/slackito/testwallpaper/TestWallpaperView.java
new file mode 100644 (file)
index 0000000..431230d
--- /dev/null
@@ -0,0 +1,42 @@
+package com.slackito.testwallpaper;
+
+import android.content.Context;
+import android.renderscript.RSSurfaceView;
+import android.renderscript.RenderScriptGL;
+import android.view.SurfaceHolder;
+
+public class TestWallpaperView extends RSSurfaceView {
+
+    private RenderScriptGL mRS;
+    private TestWallpaperRS mRender;
+
+    public TestWallpaperView(Context context) {
+        super(context);
+        setFocusable(true);
+        setFocusableInTouchMode(true);
+    }
+
+    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 TestWallpaperRS();
+            mRender.init(240, mRS, getResources(), w, h);
+        }
+
+    }
+
+    @Override
+    protected void onDetachedFromWindow() {
+        if (mRS != null) {
+            mRS.setSurface(null, 0, 0);
+            mRS = null;
+            destroyRenderScriptGL();
+        }
+    }
+
+}
diff --git a/src/com/slackito/testwallpaper/testwallpaper.rs b/src/com/slackito/testwallpaper/testwallpaper.rs
new file mode 100644 (file)
index 0000000..586bb54
--- /dev/null
@@ -0,0 +1,88 @@
+#pragma version(1)
+
+#pragma rs java_package_name(com.slackito.testwallpaper)
+
+#include "rs_graphics.rsh"
+#pragma stateVertex(parent);
+#pragma stateStore(parent);
+
+//rs_allocation textureDot;
+
+//-- common stuff -----------------------------------------
+rs_allocation gColorBuffer;
+
+typedef struct Vertex_s {
+    float3 position;
+    float2 texCoord;
+} Vertex;
+Vertex *gQuadVertices;
+
+rs_mesh gQuadMesh;
+
+float densityDPI;
+
+static float screenWidth;
+static float screenHeight;
+
+float xOffset;
+
+
+//-- scene ------------------------------------------------
+rs_program_vertex gSceneVP;
+rs_program_fragment gSceneFP;
+
+typedef struct SceneVpConsts {
+    rs_matrix4x4 MVP;
+    float scaleSize;
+} SceneVpConsts_t;
+SceneVpConsts_t *sceneVpConstants;
+
+typedef struct SceneFpConsts {
+       float offsetX;
+       float fracTime;
+} SceneFpConsts_t;
+SceneFpConsts_t *sceneFpConstants;
+
+
+// post-processing ----------------------------------------
+rs_program_vertex gPostVP;
+rs_program_fragment gPostFP;
+
+
+
+void init() {
+    screenWidth = rsgGetWidth();
+    screenHeight = rsgGetHeight();
+}
+
+void renderScene()
+{
+       int64_t millis = rsUptimeMillis();
+       float f = millis/4000.0f;
+       sceneFpConstants->fracTime = fmod(f, 1.0f);
+       sceneFpConstants->offsetX = xOffset;
+    rsgBindProgramVertex(gSceneVP);
+    rsgBindProgramFragment(gSceneFP);
+
+    rsgClearColor(0.0f, 0.f, 0.f,1.0f);
+    rsgDrawMesh(gQuadMesh);
+}
+
+void renderPostFX()
+{
+    rsgBindProgramVertex(gPostVP);
+    rsgBindProgramFragment(gPostFP);
+    rsgBindTexture(gPostFP, 0, gColorBuffer);
+    rsgDrawMesh(gQuadMesh);
+}
+
+
+int root() {
+       rsgBindColorTarget(gColorBuffer, 0);
+       renderScene();
+    
+    rsgClearAllRenderTargets();
+    renderPostFX();
+
+    return 66; // render again after 66ms
+}