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

Commit 584a375d authored by Romain Guy's avatar Romain Guy
Browse files

First pass at implementing the Grass live wallpaper in RenderScript.

This change also adds second(), minute() and hour() to the RS library.
parent 1a20bae1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -139,6 +139,7 @@ public class RenderScript {
    native private void nScriptCSetClearColor(float r, float g, float b, float a);
    native private void nScriptCSetClearDepth(float depth);
    native private void nScriptCSetClearStencil(int stencil);
    native private void nScriptCSetTimeZone(byte[] timeZone);
    native private void nScriptCAddType(int type);
    native private void nScriptCSetRoot(boolean isRoot);
    native private void nScriptCSetScript(byte[] script, int offset, int length);
@@ -670,6 +671,15 @@ public class RenderScript {
        nScriptCBegin();
    }

    public void scriptCSetTimeZone(String timeZone) {
        try {
            byte[] bytes = timeZone.getBytes("UTF-8");
            nScriptCSetTimeZone(bytes);            
        } catch (java.io.UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
    
    public void scriptCSetClearColor(float r, float g, float b, float a) {
        nScriptCSetClearColor(r, g, b, a);
    }
+19 −1
Original line number Diff line number Diff line
@@ -586,7 +586,7 @@ static void
nScriptCSetClearDepth(JNIEnv *_env, jobject _this, jfloat d)
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    LOG_API("nScriptCSetClearColor, con(%p), depth(%f)", con, d);
    LOG_API("nScriptCSetClearDepth, con(%p), depth(%f)", con, d);
    rsScriptCSetClearDepth(d);
}

@@ -598,6 +598,23 @@ nScriptCSetClearStencil(JNIEnv *_env, jobject _this, jint stencil)
    rsScriptCSetClearStencil(stencil);
}

static void
nScriptCSetTimeZone(JNIEnv *_env, jobject _this, jbyteArray timeZone)
{
    RsContext con = (RsContext)(_env->GetIntField(_this, gContextId));
    LOG_API("nScriptCSetTimeZone, con(%p), timeZone(%s)", con, timeZone);

    jint length = _env->GetArrayLength(timeZone);
    jbyte* timeZone_ptr;
    timeZone_ptr = (jbyte *) _env->GetPrimitiveArrayCritical(timeZone, (jboolean *)0);

    rsScriptCSetTimeZone((const char *)timeZone_ptr, length);

    if (timeZone_ptr) {
        _env->ReleasePrimitiveArrayCritical(timeZone, timeZone_ptr, 0);
    }
}

static void
nScriptCAddType(JNIEnv *_env, jobject _this, jint type)
{
@@ -1052,6 +1069,7 @@ static JNINativeMethod methods[] = {
{"nScriptCSetClearColor",          "(FFFF)V",                              (void*)nScriptCSetClearColor },
{"nScriptCSetClearDepth",          "(F)V",                                 (void*)nScriptCSetClearDepth },
{"nScriptCSetClearStencil",        "(I)V",                                 (void*)nScriptCSetClearStencil },
{"nScriptCSetTimeZone",            "([B)V",                                (void*)nScriptCSetTimeZone },
{"nScriptCAddType",                "(I)V",                                 (void*)nScriptCAddType },
{"nScriptCSetRoot",                "(Z)V",                                 (void*)nScriptCSetRoot },
{"nScriptCSetScript",              "([BII)V",                              (void*)nScriptCSetScript },
+25 −0
Original line number Diff line number Diff line
#
# Copyright (C) 2009 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_SRC_FILES := $(call all-java-files-under, src)
#LOCAL_STATIC_JAVA_LIBRARIES := android.renderscript

LOCAL_PACKAGE_NAME := GrassRS

include $(BUILD_PACKAGE)
+20 −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.grass.rs">

    <application android:label="GrassRS">

        <activity
            android:name="Grass"
            android:theme="@android:style/Theme.NoTitleBar">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

    </application>

</manifest>
+64.2 KiB
Loading image diff...
Loading