[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49086] branches/soc-2012-swiss_cheese/ source: Adding jni folder for Blender app.

Alexander Kuznetsov kuzsasha at gmail.com
Fri Jul 20 19:24:24 CEST 2012


Revision: 49086
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49086
Author:   alexk
Date:     2012-07-20 17:24:23 +0000 (Fri, 20 Jul 2012)
Log Message:
-----------
Adding jni folder for Blender app. 
It contatins:
All copy/loader functions.
Most stuff is copied from previous main.c from aghosty-sdl
aEvent.c and aEvent.h defines event queue and list of allowed events.
Event queue don't have locks, but it is two threads safe (one read, one write)
main.c implements native java functions.
event* just put event into queue. 

Added Paths:
-----------
    branches/soc-2012-swiss_cheese/source/android/
    branches/soc-2012-swiss_cheese/source/android/app/
    branches/soc-2012-swiss_cheese/source/android/app/AndroidManifest.xml
    branches/soc-2012-swiss_cheese/source/android/app/ant.properties
    branches/soc-2012-swiss_cheese/source/android/app/deploy.sh
    branches/soc-2012-swiss_cheese/source/android/app/jni/
    branches/soc-2012-swiss_cheese/source/android/app/jni/Android.mk
    branches/soc-2012-swiss_cheese/source/android/app/jni/Application.mk
    branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.c
    branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.h
    branches/soc-2012-swiss_cheese/source/android/app/jni/main.c
    branches/soc-2012-swiss_cheese/source/android/app/lint.xml
    branches/soc-2012-swiss_cheese/source/android/app/local.properties
    branches/soc-2012-swiss_cheese/source/android/app/makesdna.sh
    branches/soc-2012-swiss_cheese/source/android/app/makesrna.sh
    branches/soc-2012-swiss_cheese/source/android/app/project.properties
    branches/soc-2012-swiss_cheese/source/android/app/res/
    branches/soc-2012-swiss_cheese/source/android/app/res/layout/
    branches/soc-2012-swiss_cheese/source/android/app/res/layout/main.xml
    branches/soc-2012-swiss_cheese/source/android/app/res/values/
    branches/soc-2012-swiss_cheese/source/android/app/res/values/strings.xml
    branches/soc-2012-swiss_cheese/source/android/app/src/
    branches/soc-2012-swiss_cheese/source/android/app/src/org/
    branches/soc-2012-swiss_cheese/source/android/app/src/org/blender/
    branches/soc-2012-swiss_cheese/source/android/app/src/org/blender/play/
    branches/soc-2012-swiss_cheese/source/android/app/src/org/blender/play/BlenderNativeAPI.java
    branches/soc-2012-swiss_cheese/source/android/app/src/org/blender/play/ControlCenterActivity.java
    branches/soc-2012-swiss_cheese/source/android/app/src/org/blender/play/CopyIntern.java
    branches/soc-2012-swiss_cheese/source/android/app/src/org/blender/play/GhostActivity.java
    branches/soc-2012-swiss_cheese/source/android/app/src/org/blender/play/makesActivity.java

Added: branches/soc-2012-swiss_cheese/source/android/app/AndroidManifest.xml
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/AndroidManifest.xml	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/AndroidManifest.xml	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+	  package="org.blender.play"
+	  android:versionCode="1"
+	  android:versionName="1.0">
+	  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+	  <uses-permission android:name="android.permission.INTERNET" />
+	  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+		  <supports-screens android:resizeable="true" android:xlargeScreens="true"
+		android:largeScreens="true" android:normalScreens="true"
+		android:anyDensity="true"></supports-screens>
+		  <uses-sdk android:minSdkVersion="9" />
+	<application android:label="@string/app_name" android:icon="@drawable/icon" android:debuggable="false">
+		
+		<activity	android:name="GhostActivity"
+					android:label="@string/app_name"
+					android:configChanges="orientation"
+					android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
+					android:launchMode="singleTask">
+			<intent-filter>
+				<action android:name="android.intent.action.MAIN" />
+			</intent-filter>
+			<intent-filter>
+				<action android:name="android.intent.action.VIEW" />
+				<category android:name="android.intent.category.DEFAULT" />
+				<category android:name="android.intent.category.BROWSABLE" />
+				<data android:scheme="file" android:host="*"
+                    android:pathPattern=".*\\.blend"/>
+			</intent-filter>
+		</activity>
+		<activity android:name="makesActivity" android:launchMode="singleTask">
+			
+						<intent-filter>	  
+			 <action android:name="android.intent.action.MAIN" />
+		   </intent-filter> 
+		</activity>
+		<activity android:name="CopyIntern"></activity>
+		<activity android:name="ControlCenterActivity">
+			<intent-filter>
+				<action android:name="android.intent.action.MAIN" />
+				<category android:name="android.intent.category.LAUNCHER" />
+			</intent-filter>
+			<intent-filter>
+				<action android:name="android.intent.action.VIEW" />
+				<category android:name="android.intent.category.DEFAULT" />
+				<category android:name="android.intent.category.BROWSABLE" />
+				<data android:scheme="file" android:host="*"
+                    android:pathPattern=".*\\.bla"/>
+			</intent-filter>
+		</activity>
+	</application>
+</manifest>

Added: branches/soc-2012-swiss_cheese/source/android/app/ant.properties
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/ant.properties	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/ant.properties	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1,19 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+#  'source.dir' for the location of your java source folder and
+#  'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+#  'key.store' for the location of your keystore and
+#  'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
+key.store=./blenderrelease.keystore
+key.alias=blenderrelease
\ No newline at end of file

Added: branches/soc-2012-swiss_cheese/source/android/app/deploy.sh
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/deploy.sh	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/deploy.sh	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1,10 @@
+#!/bin/sh
+#if !(ndk-build) then
+#echo "!!!\tStopped. Compilation failed."
+#exit
+#fi
+ant clean
+ant debug install
+adb shell am start -a android.intent.action.MAIN -n org.blender.play/.GhostActivity
+
+adb shell am start -n org.blender.play/.makesActivity --es exec /sdcard/libmakesrna.so --es par1  /sdcard/rna/ --es par2  /sdcard/rna/ 
\ No newline at end of file


Property changes on: branches/soc-2012-swiss_cheese/source/android/app/deploy.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/soc-2012-swiss_cheese/source/android/app/jni/Android.mk
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/jni/Android.mk	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/jni/Android.mk	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := main
+
+
+#LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include
+
+# Add your application source files here...
+LOCAL_SRC_FILES :=main.c aEvent.c
+
+
+LOCAL_LDLIBS := -lEGL -lGLESv2 -llog
+
+
+include $(BUILD_SHARED_LIBRARY)

Added: branches/soc-2012-swiss_cheese/source/android/app/jni/Application.mk
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/jni/Application.mk	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/jni/Application.mk	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1 @@
+APP_PLATFORM := android-9

Added: branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.c	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.c	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1,132 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "aEvent.h"
+
+#include <assert.h>
+
+
+#define SIZETOBOUND(a) ((a+3) & ~3)
+
+
+
+size_t eEventGetSize(int type)
+{
+	switch(type)
+	{
+		case ET_MOUSE:	return sizeof(aEventMouse);
+		case ET_KEY:	return sizeof(aEventKey);
+		case ET_WINDOW:	return sizeof(aEventWindow);
+		case ET_WINDOWSIZE:	return sizeof(aEventWindowSize);
+		case ET_APP:	return sizeof(aEventApp);
+		default: assert(0);
+
+	}
+}
+
+
+
+
+void aEventQueueInit(aEventQueue * q, size_t size)
+{
+	int safebound = SIZETOBOUND(sizeof(eEventAllTypes));
+	size = SIZETOBOUND(size);
+	
+	q->begin = (char*)malloc(size+safebound);
+	q->endsafe = q->begin + size;
+
+	q->readp = q->writep = q->begin;
+
+
+
+}
+
+
+static int sameSide(char * p1, char * p2, char * cp)
+{
+	if(p1 < cp && p2 < cp)
+		return 1;
+	if(p1 >= cp && p2 > cp)
+		return 1;
+
+	return 0;
+}
+
+void aEventQueueAdd(aEventQueue * q, char * event, size_t size)
+{
+	size_t boundedsize = SIZETOBOUND(size);
+
+	if(q->writep >= q->endsafe)
+		q->writep = q->begin;
+
+	if(!sameSide(q->writep, q->writep+boundedsize, q->readp))
+	{
+		//printf("Event Dropped\n");
+		return;
+		assert(0);
+	}
+
+	memcpy(q->writep, event, size);
+
+	
+	q->writep+=boundedsize;
+
+
+}
+
+int aEventQueueCheck(aEventQueue * q)
+{
+	if(q->readp != q->writep)
+		return 1;
+
+	return 0;
+}
+
+int aEventQueueRead(aEventQueue * q, char * event)
+{
+	if(aEventQueueCheck(q))
+	{
+		aEventBase * base = (aEventBase *)q->readp;
+		size_t size = eEventGetSize(base->aeventype);
+
+		memcpy(event, base, size);
+
+		size = SIZETOBOUND(size);
+
+		q->readp += size;
+
+		if(q->readp >= q->endsafe)
+			q->readp = q->begin;
+
+		return 1;
+	} else
+	{
+		return 0;
+	}
+
+
+
+}
+
+aEventQueue mq;
+
+
+void aEventQueuexFree(aEventQueue * q)
+{
+	free(q->begin);
+
+
+}
+
+
+int aEventGQueueCheck(void)
+{
+	return aEventQueueCheck(&mq);
+}
+
+int aEventGQueueRead(eEventAllTypes * event)
+{
+	return aEventQueueRead(&mq, (char*) event);
+}
+

Added: branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.h	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/jni/aEvent.h	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1,123 @@
+
+#ifndef __AEVENT_H__
+#define __AEVENT_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum aEventType {
+	ET_UNKNOWN = 0,
+	ET_MOUSE,
+	ET_KEY,
+	ET_WINDOW,
+	ET_WINDOWSIZE,
+	ET_APP
+} ;
+
+
+typedef struct aEventBase
+{
+	int aeventype;
+	int time;
+} aEventBase;
+
+typedef struct aEventMouse
+{
+	aEventBase eb;
+	float coord[2];
+	int mouseevent;
+	char oops;
+
+} aEventMouse;
+
+typedef struct aEventKey
+{
+	aEventBase eb;
+	int key;
+	int keyevent;
+
+
+} aEventKey;
+
+enum aEventWindow_type {
+	ET_WS_UNKNOWN = 0,
+	ET_WS_FOCUS,
+	ET_WS_DEFOCUS,
+	ET_WS_UPDATE
+} ;
+
+typedef struct aEventWindow
+{
+	aEventBase eb;
+	int type;
+
+
+} aEventWindow;
+
+typedef struct aEventWindowSize
+{
+	aEventBase eb;
+	int pos[2];
+	int size[2];
+
+
+} aEventWindowSize;
+
+
+enum aEventApp_action {
+	ET_APP_UNKNOWN = 0,
+	ET_APP_CLOSE
+} ;
+typedef struct aEventApp
+{
+	aEventBase eb;
+	int action;
+} aEventApp;
+
+typedef union eEventAllTypes
+{
+	aEventBase eb;
+	aEventMouse Mouse;
+	aEventKey Key;
+	aEventWindow Window;
+	aEventWindowSize WindowSize;
+	aEventApp app;
+
+} eEventAllTypes;
+
+size_t eEventGetSize(int type);
+
+typedef struct aEventQueue
+{
+	char * begin;
+	char * endsafe;
+	char * readp;
+	char * writep;
+
+
+} aEventQueue;
+
+
+void aEventQueueInit(aEventQueue * q, size_t size);
+
+void aEventQueueAdd(aEventQueue * q, char * event, size_t size);
+
+int aEventQueueCheck(aEventQueue * q);
+
+int aEventGQueueCheck(void);
+
+int aEventQueueRead(aEventQueue * q, char * event);
+
+int aEventGQueueRead(eEventAllTypes * event);
+
+void aEventQueuexFree(aEventQueue * q);
+
+void aSwapBuffers(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AEVENT_H__ */

Added: branches/soc-2012-swiss_cheese/source/android/app/jni/main.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/android/app/jni/main.c	                        (rev 0)
+++ branches/soc-2012-swiss_cheese/source/android/app/jni/main.c	2012-07-20 17:24:23 UTC (rev 49086)
@@ -0,0 +1,684 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list