Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8e15ce5
test commit
Nov 9, 2015
e94c735
test commit 2
Nov 9, 2015
8fff8c2
Merge branch 'purgatory' into aeroglass
akosmaroy Nov 9, 2015
d06a6f0
Generated
Nov 9, 2015
cf32dd7
changes for aeroglass project
Nov 10, 2015
41f9c2c
fixed character which causes issue in generated source on android stu…
Nov 10, 2015
1710d35
Generated
Nov 10, 2015
c83e3f6
added custom GL shader feature
Nov 12, 2015
6e3aef0
Generated
Nov 12, 2015
417156c
fix string empty check
Nov 12, 2015
f3c052b
Merge branch 'aeroglass-collision-avoidance' of https://github.com/gl…
Nov 12, 2015
dd287c4
Generated
Nov 12, 2015
a636407
fixed string default value
Nov 13, 2015
7ac6542
Merge branch 'aeroglass-collision-avoidance' of https://github.com/gl…
Nov 13, 2015
8f5e3d4
Generated
Nov 13, 2015
5f2a799
more changes for custom shader support
Nov 17, 2015
1e54d80
Generated
Nov 17, 2015
96dfc72
added ability to the android sql cache store to be able to contain bi…
Nov 30, 2015
1562a2c
added hooks to be able to handle custom shader's attributes and unifo…
Dec 2, 2015
e15c543
Generated
Dec 2, 2015
0226b89
changed custom shader feature internal functions into protected
Dec 2, 2015
a736448
Generated
Dec 2, 2015
ce868a1
ignore invalid uniform and attribute indices
Dec 2, 2015
11d6a84
Generated
Dec 2, 2015
c19ee8b
gpu program ignores unrecongized attributes and uniforms and characte…
Dec 2, 2015
cebce4e
Generated
Dec 2, 2015
79c746f
added feature to make sure unrecognized attributes and uniforms are i…
Dec 2, 2015
da431d6
Generated
Dec 2, 2015
48b1279
get the attribute and uniform keys properly
Dec 2, 2015
55f5d2d
Generated
Dec 2, 2015
5703cbc
key check changes again
Dec 2, 2015
ac79bd1
Generated
Dec 2, 2015
fa6303c
these are not needed because values that set nothing are already adde…
Dec 3, 2015
58db0b4
Generated
Dec 3, 2015
38d1fca
added to ignore unrecognized attributes and uniforms
Dec 3, 2015
a1758db
Generated
Dec 3, 2015
e935481
added ability to get gl feature in a gl state which includes anchestors
Dec 3, 2015
6cd9db0
Generated
Dec 3, 2015
61fa1fc
reverted tests made for java converter testing
Dec 8, 2015
7e6104a
Generated
Dec 8, 2015
f31c8a2
fix for issue with case when the internal shshaders are mistaken for …
DrakkLord Dec 12, 2015
9cddb56
Generated
Dec 12, 2015
a451d99
fix JAVA code
zoltanpillio Dec 12, 2015
7219d9d
Generated
Dec 12, 2015
40efcb9
fix fix JAVA code
zoltanpillio Dec 12, 2015
daf2ae4
Generated
Dec 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,11 @@ tools/point-cloud-octree/bin/
.settings

tools/externals/poly2tri-java/bin/

# Android-Studio
*.iml
*.idea

# Gradle
build
*/build
14 changes: 0 additions & 14 deletions Android/G3MAndroidSDK/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,4 @@

<uses-sdk android:minSdkVersion="11" />
<uses-feature android:glEsVersion="0x00020000"/>

<application
android:label="G3MAndroidSDK" >
<activity
android:name=".G3MAndroidSDKActivity"
android:label="G3MAndroidSDK" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,28 @@ public void onDrawFrame(final GL10 glUnused) {
final G3MWidget widget = _widgetAndroid.getG3MWidget();
widget.render(_width, _height);

// experimental FPS reduction - DGD
final long now = System.currentTimeMillis();
final long timeElapsedInRender = now - _startTime;
final long timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender;
if (timeLeftInMS > 0) {
// System.gc();
//
// timeElapsedInRender = System.currentTimeMillis() - _startTime;
// timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender;
// if (timeLeftInMS > 0) {
try {
//ILogger.instance().logInfo("**** sleeping OpenGL thread for " + timeLeftInMS + "ms");
Thread.sleep(timeLeftInMS);
if (!_widgetAndroid.getNoFPSReduction()) {
// experimental FPS reduction - DGD
final long now = System.currentTimeMillis();
final long timeElapsedInRender = now - _startTime;
final long timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender;
if (timeLeftInMS > 0) {
// System.gc();
//
// timeElapsedInRender = System.currentTimeMillis() - _startTime;
// timeLeftInMS = GOAL_MS_PER_FRAME - timeElapsedInRender;
// if (timeLeftInMS > 0) {
try {
//ILogger.instance().logInfo("**** sleeping OpenGL thread for " + timeLeftInMS + "ms");
Thread.sleep(timeLeftInMS);
} catch (final InterruptedException e) {
}
// }
_startTime = System.currentTimeMillis();
} else {
_startTime = now;
}
catch (final InterruptedException e) {
}
// }
_startTime = System.currentTimeMillis();
}
else {
_startTime = now;
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ public class G3MBuilder_Android

private final G3MWidget_Android _nativeWidget;


public G3MBuilder_Android(final Context context) {
public G3MBuilder_Android(final Context context, final boolean noFPSReduction) {
super();

_nativeWidget = new G3MWidget_Android(context);
_nativeWidget = new G3MWidget_Android(context, noFPSReduction);
}


Expand Down Expand Up @@ -91,6 +90,4 @@ protected IDownloader createDefaultDownloader() {
getStorage(), //
saveInBackground);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public final class G3MWidget_Android
private final OnDoubleTapListener _doubleTapListener;
private final GestureDetector _gestureDetector;
private Thread _openGLThread = null;

private final boolean _noFPSReduction;

public G3MWidget_Android(final android.content.Context context) {
this(context, null);
Expand All @@ -83,11 +83,22 @@ public final void checkOpenGLThread() {
}
}

public G3MWidget_Android(final android.content.Context context,
final boolean noFPSReduction) {
this(context, null, noFPSReduction);
}

// Needed to create widget from XML layout
public G3MWidget_Android(final android.content.Context context,
final AttributeSet attrs) {
final AttributeSet attrs) {
this(context, attrs, false);
}

public G3MWidget_Android(final android.content.Context context,
final AttributeSet attrs,
final boolean noFPSReduction) {
super(context, attrs);
_noFPSReduction = noFPSReduction;

initSingletons();

Expand Down Expand Up @@ -453,5 +464,7 @@ public G3MContext getG3MContext() {
return getG3MWidget().getG3MContext();
}


public boolean getNoFPSReduction() {
return _noFPSReduction;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

package org.glob3.mobile.specific;

import java.io.ByteArrayOutputStream;
import java.io.File;
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import org.glob3.mobile.generated.G3MContext;
import org.glob3.mobile.generated.GTask;
Expand All @@ -16,19 +21,23 @@
import org.glob3.mobile.generated.TimeInterval;
import org.glob3.mobile.generated.URL;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;


public final class SQLiteStorage_Android
extends
IStorage {

private static final long DB_RAW_DATA_EXTERNAL_THRESHOLD = 1024 * 1024; // 1 MiB
private static final String DB_EXTERNAL_TAG = "EXT:";
private static final Charset UTF8 = Charset.forName("UTF-8");

private static final String[] COLUMNS = new String[] { "contents", "expiration" };
private static final String SELECTION = "name = ?";

Expand All @@ -41,6 +50,7 @@ public final class SQLiteStorage_Android

private final BitmapFactory.Options _options;
private final byte[] _temp_storage = new byte[128 * 1024];
private final String _documentsDirectory;


private class MySQLiteOpenHelper
Expand Down Expand Up @@ -81,13 +91,7 @@ public void onUpgrade(final SQLiteDatabase db,


private String getPath() {
File f = _androidContext.getExternalCacheDir();
if ((f == null) || !f.exists()) {
f = _androidContext.getCacheDir();
}
final String documentsDirectory = f.getAbsolutePath();

final File f2 = new File(new File(documentsDirectory), _databaseName);
final File f2 = new File(new File(_documentsDirectory), _databaseName);

final String path = f2.getAbsolutePath();
Log.d("SQLiteStorage_Android", "Creating DB in " + path);
Expand All @@ -98,8 +102,14 @@ private String getPath() {

public SQLiteStorage_Android(final String path,
final android.content.Context context) {
_androidContext = context;
File f = _androidContext.getExternalCacheDir();
if ((f == null) || !f.exists()) {
f = _androidContext.getCacheDir();
}
_documentsDirectory = f.getAbsolutePath();

_databaseName = path;
_androidContext = context;

_dbHelper = new MySQLiteOpenHelper(context, getPath());
_writeDB = _dbHelper.getWritableDatabase();
Expand Down Expand Up @@ -135,21 +145,88 @@ public void run(final G3MContext context) {
}
}

private boolean writeFileToCacheFolder(final String fileName, final byte[] content) {
final File f2 = new File(new File(_documentsDirectory), fileName);
FileOutputStream fout = null;
try {
fout = new FileOutputStream(f2);
fout.write(content);
fout.flush();
return true;
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
if (fout != null) {
try {
fout.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}

private byte[] readFileFromCacheFolder(final String fileName) {
final File f2 = new File(new File(_documentsDirectory), fileName);
FileInputStream fin = null;
try {
fin = new FileInputStream(f2);
final int avail = fin.available();
if (avail == 0) {
return null;
}
final byte[] r = new byte[avail];
if (fin.read(r) != avail) {
return null;
}
return r;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
if (fin != null) {
try {
fin.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}

private synchronized void rawSave(final String table,
final String name,
final byte[] contents,
final TimeInterval timeToExpires) {

final boolean external = contents.length >= DB_RAW_DATA_EXTERNAL_THRESHOLD;
final String externalFileName = external ? (table + name).hashCode() + ".raw_cache" : null;

final ContentValues values = new ContentValues(3);
values.put("name", name);
values.put("contents", contents);
values.put("contents",
external ? (DB_EXTERNAL_TAG + externalFileName).getBytes(UTF8) : contents);
final long expiration = System.currentTimeMillis() + timeToExpires.milliseconds();
values.put("expiration", Long.toString(expiration));

if (_writeDB == null) {
ILogger.instance().logError("SQL: Can't write " + table + " in database \"%s\". _writeDB not available\n", _databaseName);
}
else {
if (external) {
if (!writeFileToCacheFolder(externalFileName, contents)) {
ILogger.instance().logError("SQL: Can't write external file for cache \"%s\"\n", name);
return;
}
}

final long rowID = _writeDB.insertWithOnConflict(table, null, values, SQLiteDatabase.CONFLICT_REPLACE);
if (rowID == -1) {
ILogger.instance().logError("SQL: Can't write " + table + " in database \"%s\"\n", _databaseName);
Expand All @@ -165,7 +242,7 @@ public IByteBufferResult readBuffer(final URL url,
boolean expired = false;
final String name = url._path;

final Cursor cursor = _readDB.query( //
final Cursor cursor = _readDB.query( //
"buffer2", //
COLUMNS, //
SELECTION, //
Expand All @@ -180,7 +257,23 @@ public IByteBufferResult readBuffer(final URL url,

expired = (expirationInterval <= System.currentTimeMillis());
if (!expired || readExpired) {
buffer = new ByteBuffer_Android(data);
if (data.length > DB_EXTERNAL_TAG.length()) {
final String extTag = new String(data, 0, DB_EXTERNAL_TAG.length(), UTF8);
if (!extTag.isEmpty() && DB_EXTERNAL_TAG.equalsIgnoreCase(extTag)) {
final byte[] cacheData = readFileFromCacheFolder(
new String(data, DB_EXTERNAL_TAG.length(), data.length - DB_EXTERNAL_TAG.length(), UTF8));
if (cacheData == null || cacheData.length == 0) {
ILogger.instance()
.logError("SQL: Can't read external file for cache \"%s\"\n", name);
cursor.close();
return new IByteBufferResult(null, expired);
}
buffer = new ByteBuffer_Android(cacheData);
}
}
if (buffer == null) {
buffer = new ByteBuffer_Android(data);
}
}
}
cursor.close();
Expand Down Expand Up @@ -251,8 +344,27 @@ public IImageResult readImage(final URL url,

expired = (expirationInterval <= System.currentTimeMillis());
if (!expired || readExpired) {
Bitmap bitmap = null;

if (data.length > DB_EXTERNAL_TAG.length()) {
final String extTag = new String(data, 0, DB_EXTERNAL_TAG.length(), UTF8);
if (!extTag.isEmpty() && DB_EXTERNAL_TAG.equalsIgnoreCase(extTag)) {
final byte[] cacheData = readFileFromCacheFolder(
new String(data, DB_EXTERNAL_TAG.length(), data.length - DB_EXTERNAL_TAG.length(), UTF8));
if (cacheData == null || cacheData.length == 0) {
ILogger.instance()
.logError("SQL: Can't read external file for cache \"%s\"\n", name);
cursor.close();
return new IImageResult(null, expired);
}
bitmap = BitmapFactory.decodeByteArray(cacheData, 0, cacheData.length, _options);
}
}

// final long start = System.currentTimeMillis();
final Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, _options);
if (bitmap == null) {
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, _options);
}
// ILogger.instance().logInfo("CACHE: Bitmap parsed in " + (System.currentTimeMillis() - start) + "ms");

if (bitmap == null) {
Expand Down
Loading