21 #include "include/Beatmup_Object.h"
22 #include "include/Beatmup_Visual_Android_BasicDisplay.h"
23 #include "include/Beatmup_Context.h"
24 #include "include/Beatmup_Android_Context.h"
25 #include "include/Beatmup_Object.h"
26 #include "include/Beatmup_Pipelining_CustomPipeline.h"
27 #include "include/Beatmup_Pipelining_Multitask.h"
28 #include "include/Beatmup_Pipelining_TaskHolder.h"
29 #include "include/Beatmup_Utils_Callback.h"
30 #include "include/Beatmup_Utils_ChunkAsset.h"
31 #include "include/Beatmup_Utils_ChunkCollection.h"
32 #include "include/Beatmup_Utils_ChunkFile.h"
33 #include "include/Beatmup_Utils_VariablesBundle.h"
34 #include "include/Beatmup_Sequence.h"
40 #include <android/asset_manager_jni.h>
41 #include <android/native_window_jni.h>
63 LOG_I(
"Disposing object #%lld", (
jlong)nativeObj);
85 ANativeWindow *wnd = ANativeWindow_fromSurface(
jenv,
surface);
87 LOG_E(
"Empty surface window got when switching GL display.");
93 ANativeWindow_release(wnd);
134 JNIMETHOD(jfloat, performTask, Java_Beatmup_Context, performTask)
146 JNIMETHOD(jint, submitTask, Java_Beatmup_Context, submitTask)
158 JNIMETHOD(jint, submitPersistentTask, Java_Beatmup_Context, submitPersistentTask)
170 JNIMETHOD(
void, repeatTask, Java_Beatmup_Context, repeatTask)
181 JNIMETHOD(
void, waitForJob, Java_Beatmup_Context, waitForJob)
191 JNIMETHOD(jboolean, abortJob, Java_Beatmup_Context, abortJob)
202 JNIMETHOD(
void, waitForAllJobs, Java_Beatmup_Context, waitForAllJobs)
212 JNIMETHOD(jboolean, busy, Java_Beatmup_Context, busy)
223 JNIMETHOD(
void, check, Java_Beatmup_Context, check)
253 JNIMETHOD(
jobject, scanlineSearchInt, Java_Beatmup_Context, scanlineSearchInt)(JNIEnv *
jenv,
jobject jCtx,
jlong hBitmap, jint
x, jint
y, jint
r, jint
g, jint
b, jint
a) {
265 JNIMETHOD(
jobject, scanlineSearchFloat, Java_Beatmup_Context, scanlineSearchFloat)(JNIEnv *
jenv,
jobject jCtx,
jlong hBitmap, jint
x, jint
y, jfloat
r, jfloat
g, jfloat
b, jfloat
a) {
322 LOG_I(
"Beatmup is starting up...");
335 vars->setInteger(nameStr,
val);
343 vars->setInteger(nameStr,
x,
y);
351 vars->setInteger(nameStr,
x,
y,
z);
355 JNIMETHOD(
void, setInteger4, Java_Beatmup_Utils_VariablesBundle, setInteger4)(JNIEnv *
jenv,
jobject,
jlong hInstance, jstring
name, jint
x, jint
y, jint
z, jint
w) {
359 vars->setInteger(nameStr,
x,
y,
z,
w);
367 vars->setFloat(nameStr,
val);
375 vars->setFloat(nameStr,
x,
y);
383 vars->setFloat(nameStr,
x,
y,
z);
387 JNIMETHOD(
void, setFloat4, Java_Beatmup_Utils_VariablesBundle, setFloat4)(JNIEnv *
jenv,
jobject,
jlong hInstance, jstring
name, jfloat
x, jfloat
y, jfloat
z, jfloat
w) {
391 vars->setFloat(nameStr,
x,
y,
z,
w);
403 vars->setFloatMatrix3(nameStr,
arrayData);
406 vars->setFloatMatrix4(nameStr,
arrayData);
420 vars->setFloatMatrix4(nameStr, *
mat);
459 JNIMETHOD(
jlong, insertTask, Java_Beatmup_Pipelining_CustomPipeline, insertTask)
503 return static_cast<jint
>(multitask->getRepetitionPolicy(*
taskHolder));
532 #if !defined(BEATMUP_PROFILE_NOAUDIO) || !defined(BEATMUP_PROFILE_NOVIDEO)
565 JNIMETHOD(
void, open, Java_Beatmup_Utils_ChunkCollection, open)
591 return (
jlong)collection->size();
601 return collection->chunkExists(idStr) ? JNI_TRUE :
JNI_FALSE;
605 JNIMETHOD(
jlong, chunkSize, Java_Beatmup_Utils_ChunkCollection, chunkSize)
611 return (
jlong)collection->chunkSize(idStr);
621 collection->save(filenameStr,
append == JNI_TRUE);
631 std::string
content = collection->template read<std::string>(idStr);
639 JNIMETHOD(
jlong, newChunkAsset, Java_Beatmup_Utils_ChunkAsset, newChunkAsset)
648 return (
jlong)instance;
658 JNIMETHOD(
jlong, newChunkfile, Java_Beatmup_Utils_ChunkFile, newChunkfile)
674 JNIMETHOD(
jlong, newCallbackTask, Java_Beatmup_Utils_Callback, newCallbackTask)
681 JNIMETHOD(
void, updateCallback, Java_Beatmup_Utils_Callback, updateCallback)
Handles all Java binding-related static data.
void nullifyHandle(JNIEnv *jenv, jobject obj)
Sets a handle of a java object to null.
static void throwToJava(JNIEnv *jenv, const char *exceptionClass, const char *message)
Throws a specific exception.
void removeAllJavaReferences(JNIEnv *jenv, const Beatmup::Object *bobj)
Removes all Java references to depending objects.
static const jlong INVALID_HANDLE
jobject getJavaReference(const Beatmup::Object *bobj) const
Returns a reference to the Java object which a given object depends on.
Object * getObject(JNIEnv *jenv, jlong handle)
Retrieves native object by its handle.
A very basic class for any image.
Task: an operation that can be executed by multiple threads in parallel.
static ThreadIndex validThreadCount(int number)
Valid thread count from a given integer value.
static uint64_t total()
Returns the size of total operating memory in bytes.
Task calling method of a Java object.
A key-value pair set storing pieces of arbitrary data (chunks) under string keys.
Needed for correct functioning of JNI.
An event listener (bunch of callbacks)
Basic class: task and memory management, any kind of static data.
const ThreadIndex maxAllowedWorkerCount(const PoolIndex pool=DEFAULT_POOL) const
float performTask(AbstractTask &task, const PoolIndex pool=DEFAULT_POOL)
Performs a given task.
void wait(const PoolIndex pool=DEFAULT_POOL)
Blocks until all the submitted jobs are executed.
Job submitTask(AbstractTask &task, const PoolIndex pool=DEFAULT_POOL)
Adds a new task to the jobs queue.
bool abortJob(Job job, const PoolIndex pool=DEFAULT_POOL)
Aborts a given submitted job.
GL::RecycleBin * getGpuRecycleBin() const
Job submitPersistentTask(AbstractTask &task, const PoolIndex pool=DEFAULT_POOL)
Adds a new persistent task to the jobs queue.
void check(const PoolIndex pool=DEFAULT_POOL)
Checks if a specific thread pool is doing great: rethrows exceptions occurred during tasks execution,...
EventListener * getEventListener() const
Returns current event listener (or NULL)
bool busy(const PoolIndex pool=DEFAULT_POOL)
Queries whether a given thread pool is busy with a task.
void repeatTask(AbstractTask &task, bool abortCurrent, const PoolIndex pool=DEFAULT_POOL)
Ensures a given task executed at least once.
bool isGpuQueried() const
void limitWorkerCount(ThreadIndex maxValue, const PoolIndex pool=DEFAULT_POOL)
Limits maximum number of threads (workers) when performing tasks in a given pool.
void setEventListener(EventListener *eventListener)
Installs new event listener.
void waitForJob(Job job, const PoolIndex pool=DEFAULT_POOL)
Waits until a given job finishes.
A task within a pipeline.
Custom pipeline: a sequence of tasks to be executed as a whole.
static bool run(Context &ctx, void *switchingData=nullptr)
Base class for all exceptions.
virtual const char * what() const NOEXCEPT override
Fragmented signal in time domain.
void emptyBin()
Empty the bin destroying all the items in a GPU-aware thread.
Conditional multiple tasks execution.
RepetitionPolicy
Determines when a specific task in the sequence is run when the whole sequence is invoked.
Beatmup object base class
jobject makeIntPoint(JNIEnv *jenv, const Beatmup::IntPoint)
void read(Bitmap &bitmap, Args &&... args)
Calls a Func< ReaderClass >::process(access, params), where.
unsigned char PoolIndex
number of tread pools or a pool index
4-channel floating point arithmetic
4-channel integer arithmetic
#define BEATMUP_DELETE_REFERENCE(obj)
Beatmup::AbstractBitmap * copy
jlong jstring jobject jMat
return(jlong) new Beatmup jlong jstring name
JNIEnv jlong jobject jobject jlong hWhere
jobject jlong jint jint jint jint g
jobject jlong jint jint jint jint jint b
JNIEnv jlong jint jobject jTask
jlong jint jint jint jint pixelFormat
jlong jstring jint jint jint z
return collection chunkExists(JNIEnv *jenv, jobject, jlong hCollection, jstring id)
collection save(filenameStr, append==JNI_TRUE)
BEATMUP_REFERENCE(jCtx, copy)
JNIEnv jstring jboolean openNow
jlong jint jint jint cell
jobject jlong jint jint y
return pipeline getTaskIndex * taskHolder
Beatmup::CustomPipeline::TaskHolder * newbie
return(jlong) Beatmup jobject jobject jBitmap
JNIEnv jlong jint poolIdx
JNIEnv jlong jint jint job
jlong jstring jint jint jint jint w
JNIEnv jlong jint jobject jboolean abort
JNIEnv jlong jstring filename
jobject jlong jint jint jint r
BEATMUP_CATCH({ return(jint) ctx->submitTask(*task,(Beatmup::PoolIndex) poolIdx);})
return $pool getJavaReference & pipeline(index)
jobject jlong jint jint jint jint jint jint a
Beatmup::Context::EventListener * listener
JNIMETHOD(void, disposeNative, Java_Beatmup_Object, disposeNative)(JNIEnv *jenv
JNIEnv jlong jint jint count
BeatmupJavaObjectPool $pool
JNIEnv jobject jAssetManager
ctx limitWorkerCount(Beatmup::AbstractTask::validThreadCount(count),(Beatmup::PoolIndex) poolIdx)
return ctx maxAllowedWorkerCount((Beatmup::PoolIndex) poolIdx)
jlong jstring jfloatArray array
JNIEnv jlong jstring jboolean append
return(jlong) new Beatmup jlong jstring jint val
return(jlong) new Beatmup jlong hInstance
BEATMUP_OBJ(Beatmup::Context, ctx, hCtx)
Beatmup::InternalBitmap * bitmap
Beatmup::NNets::InferenceTask * task