implement multithreaded rendering with context switch, gl state save/restore, add progress bar ui node, implement stencil texture for brush, implement multithreaded canvas load/save/export pano. Missing multithread in windows.
@@ -71,6 +71,7 @@ add_library(
|
||||
../engine/node_panel_layer.cpp
|
||||
../engine/node_panel_stroke.cpp
|
||||
../engine/node_popup_menu.cpp
|
||||
../engine/node_progress_bar.cpp
|
||||
../engine/node_settings.cpp
|
||||
../engine/node_slider.cpp
|
||||
../engine/node_stroke_preview.cpp
|
||||
@@ -82,6 +83,7 @@ add_library(
|
||||
|
||||
target_include_directories(native-lib PRIVATE
|
||||
${ANDROID_NDK}/sources/android/native_app_glue
|
||||
src/main/cpp
|
||||
../engine
|
||||
../libs/glm
|
||||
../libs/tinyxml2
|
||||
|
||||
@@ -30,7 +30,7 @@ android {
|
||||
arguments '-DANDROID_PLATFORM=android-19',
|
||||
'-DANDROID_TOOLCHAIN=clang',
|
||||
'-DANDROID_STL=gnustl_static',
|
||||
'-DCMAKE_BUILD_TYPE=Release',
|
||||
'-DCMAKE_BUILD_TYPE=Debug',
|
||||
'-DANDROID_ARM_NEON=TRUE'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:noHistory="true">
|
||||
android:noHistory="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<meta-data android:name="android.app.lib_name"
|
||||
android:value="native-lib" />
|
||||
<intent-filter>
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "app.h"
|
||||
#include "asset.h"
|
||||
#include "keymap.h"
|
||||
#include "main.h"
|
||||
|
||||
typedef void (*GLDEBUGPROC)(GLenum source,
|
||||
GLenum type,
|
||||
@@ -47,39 +48,9 @@ typedef void (*fnDebugMessageCallback)(GLDEBUGPROC callback, const void* userPar
|
||||
#define GL_DEBUG_OUTPUT 0x92E0
|
||||
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
|
||||
|
||||
/**
|
||||
* Our saved state data.
|
||||
*/
|
||||
struct saved_state {
|
||||
float angle;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
};
|
||||
|
||||
EGLDisplay g_display = EGL_NO_DISPLAY;
|
||||
EGLContext g_context = EGL_NO_CONTEXT;
|
||||
|
||||
/**
|
||||
* Shared state for our app.
|
||||
*/
|
||||
struct engine {
|
||||
struct android_app* app;
|
||||
|
||||
ASensorManager* sensorManager;
|
||||
const ASensor* accelerometerSensor;
|
||||
ASensorEventQueue* sensorEventQueue;
|
||||
|
||||
int animating;
|
||||
EGLDisplay display;
|
||||
EGLSurface surface;
|
||||
EGLContext context;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
struct saved_state state;
|
||||
};
|
||||
|
||||
std::string utf8chr(int cp)
|
||||
{
|
||||
char c[5]={ 0x00,0x00,0x00,0x00,0x00 };
|
||||
@@ -144,6 +115,32 @@ int GetUnicodeChar(struct android_app* app, int eventType, int keyCode, int meta
|
||||
return unicodeKey;
|
||||
}
|
||||
|
||||
void android_async_lock(struct engine* engine)
|
||||
{
|
||||
pthread_mutex_lock(&engine->app->mutex);
|
||||
LOG("lock");
|
||||
eglMakeCurrent(engine->display, engine->surface, engine->surface, engine->context);
|
||||
}
|
||||
|
||||
void android_async_swap(struct engine* engine)
|
||||
{
|
||||
eglSwapBuffers(engine->display, engine->surface);
|
||||
}
|
||||
|
||||
void android_async_unlock(struct engine* engine)
|
||||
{
|
||||
eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
LOG("unlock");
|
||||
pthread_mutex_unlock(&engine->app->mutex);
|
||||
}
|
||||
|
||||
struct locker
|
||||
{
|
||||
struct engine* e;
|
||||
locker(struct engine* _e){ e = _e; android_async_lock(e); }
|
||||
~locker(){ android_async_unlock(e); }
|
||||
};
|
||||
|
||||
// see https://groups.google.com/forum/#!topic/android-ndk/Tk3g00wLKhk
|
||||
void displayKeyboard(android_app* mApplication, bool pShow)
|
||||
{
|
||||
@@ -492,6 +489,7 @@ static int engine_init_display(struct engine* engine) {
|
||||
//glEnableClientState(GL_VERTEX_ARRAY);
|
||||
Asset::m_am = engine->app->activity->assetManager;
|
||||
App::I.and_app = engine->app;
|
||||
App::I.and_engine = engine;
|
||||
App::I.data_path = "/sdcard/PanoPainter";// engine->app->activity->externalDataPath;
|
||||
App::I.width = w;
|
||||
App::I.height = h;
|
||||
@@ -508,6 +506,7 @@ static int engine_init_display(struct engine* engine) {
|
||||
* Just the current frame in the display.
|
||||
*/
|
||||
static void engine_draw_frame(struct engine* engine) {
|
||||
locker _lock(engine);
|
||||
if (engine->display == NULL || !(App::I.redraw || App::I.animate))
|
||||
return;
|
||||
|
||||
@@ -543,8 +542,11 @@ static void engine_term_display(struct engine* engine) {
|
||||
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
|
||||
struct engine* engine = (struct engine*)app->userData;
|
||||
int32_t eventType = AInputEvent_getType(event);
|
||||
App::I.redraw = true;
|
||||
//LOG("event type: %d", eventType);
|
||||
|
||||
locker _locker{engine};
|
||||
App::I.redraw = true;
|
||||
|
||||
switch (eventType) {
|
||||
case AINPUT_EVENT_TYPE_MOTION:
|
||||
// switch (AInputEvent_getSource(event)) {
|
||||
|
||||
34
android/src/main/cpp/main.h
Executable file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
/**
|
||||
* Our saved state data.
|
||||
*/
|
||||
struct saved_state {
|
||||
float angle;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shared state for our app.
|
||||
*/
|
||||
struct engine {
|
||||
struct android_app* app;
|
||||
|
||||
ASensorManager* sensorManager;
|
||||
const ASensor* accelerometerSensor;
|
||||
ASensorEventQueue* sensorEventQueue;
|
||||
|
||||
int animating;
|
||||
EGLDisplay display;
|
||||
EGLSurface surface;
|
||||
EGLContext context;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
struct saved_state state;
|
||||
};
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 4.4 KiB |