26 using namespace Android;
43 glGenTextures(1, &textureHandle);
52 return TaskDeviceRequirement::GPU_ONLY;
78 jclass externalBitmapClass =
jenv->FindClass(
"Beatmup/Android/ExternalBitmap");
79 jclass surfaceTextureClass =
jenv->FindClass(
"android/graphics/SurfaceTexture");
82 if (!externalBitmapClass) {
87 if (!surfaceTextureClass) {
94 jfieldID surfaceTextureFieldId =
jenv->GetFieldID(externalBitmapClass,
"surfaceTexture",
"Landroid/graphics/SurfaceTexture;");
96 if (!surfaceTextureFieldId) {
97 BEATMUP_DEBUG_E(
"Cannot find field surfaceTexture in Beatmup.Android.ExternalImage");
103 jmethodID surfaceTextureConstructor =
jenv->GetMethodID(surfaceTextureClass,
"<init>",
"(I)V");
106 if (!surfaceTextureConstructor) {
118 jobject newSurfaceTextureObject =
jenv->NewObject(surfaceTextureClass, surfaceTextureConstructor, this->
textureHandle);
120 if (!newSurfaceTextureObject) {
130 jenv->SetObjectField(frontend, surfaceTextureFieldId, newSurfaceTextureObject);
133 jenv->DeleteLocalRef(externalBitmapClass);
134 jenv->DeleteLocalRef(surfaceTextureClass);
141 jvm->AttachCurrentThread(&
jenv,
nullptr);
155 TextureHandler::prepare(gpu);
166 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
167 glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
A very basic class for any image.
Task: an operation that can be executed by multiple threads in parallel.
TaskDeviceRequirement
Specifies which device (CPU and/or GPU) is used to run the task.
jmethodID updateTexImageMethodId
virtual void prepare(GraphicPipeline &gpu)
Prepares (eventually uploads) texture data on GPU.
void bind(JNIEnv *jenv, jobject frontend)
Attaches the bitmap object to its Java frontend and initializes the surface texture in it.
ExternalBitmap(Beatmup::Context &ctx)
Instantiates external image.
void notifyUpdate(const int width, const int height)
Basic class: task and memory management, any kind of static data.
float performTask(AbstractTask &task, const PoolIndex pool=DEFAULT_POOL)
Performs a given task.
Internal low-level GPU control API.
Task generating a valid OpenGL texture handle.
Beatmup::GL::handle_t textureHandle
bool process(TaskThread &thread)
Executes the task on CPU within a given thread.
TaskDeviceRequirement getUsedDevices() const
Communicates devices (CPU and/or GPU) the task is run on.
bool processOnGPU(GraphicPipeline &gpu, TaskThread &)
Executes the task on GPU.
static Beatmup::GL::handle_t makeHandle(Context &ctx)
TextureHandleFactory(Context &ctx)
#define BEATMUP_DEBUG_E(...)
unsigned int handle_t
A reference to a GPU resource.