Beatmup
external_bitmap.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2020, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
21 #include <jni.h>
22 
23 
24 namespace Beatmup {
25  namespace Android {
26 
27  /**
28  Image coming from a SurfaceTexture (Camera or video decoder)
29  */
31  private:
32  int width, height;
33  JavaVM *jvm;
34  JNIEnv* persistentJEnv;
38 
39  protected:
40  virtual void prepare(GraphicPipeline& gpu);
41  void lockPixelData() {}
42  void unlockPixelData() {}
43 
44  public:
45  /**
46  * Instantiates external image.
47  * This must not be called from Beatmup internal threads.
48  */
50 
52 
53  /**
54  * Attaches the bitmap object to its Java frontend and initializes
55  * the surface texture in it.
56  */
57  void bind(JNIEnv* jenv, jobject frontend);
58 
60  return Beatmup::GL::TextureHandler::TextureFormat::OES_Ext;
61  }
62 
63  const PixelFormat getPixelFormat() const {
65  }
66 
67  const int getWidth() const {
68  return width;
69  }
70 
71  const int getHeight() const {
72  return height;
73  }
74 
75  const int getDepth() const {
76  return 1;
77  }
78 
79  const msize getMemorySize() const {
80  return 0;
81  }
82 
83  const pixbyte* getData(int x, int y) const {
84  return nullptr;
85  }
86 
87  pixbyte* getData(int x, int y) {
88  return nullptr;
89  }
90 
91  void notifyUpdate(const int width, const int height);
92  };
93 
94  }
95 }
A very basic class for any image.
Context & ctx
context managing this bitmap
Image coming from a SurfaceTexture (Camera or video decoder)
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
void lockPixelData()
Locks access to the CPU memory buffer containing pixel data.
virtual void prepare(GraphicPipeline &gpu)
Prepares (eventually uploads) texture data on GPU.
pixbyte * getData(int x, int y)
void bind(JNIEnv *jenv, jobject frontend)
Attaches the bitmap object to its Java frontend and initializes the surface texture in it.
const int getDepth() const
Depth of the texture in pixels.
const int getWidth() const
Width of the texture in pixels.
void unlockPixelData()
Unlocks access to the CPU memory buffer containing pixel data.
const Beatmup::GL::TextureHandler::TextureFormat getTextureFormat() const
Returns the texture format specifying how the shader must interpret the data.
const PixelFormat getPixelFormat() const
Pixel format of the bitmap.
const msize getMemorySize() const
Bitmap size in bytes.
const int getHeight() const
Height of the texture in pixels.
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.
Definition: context.h:59
TextureFormat
Texture format, specifies how the texture should be interpreted on the shader side.
Internal low-level GPU control API.
Definition: pipeline.h:33
uint32_t msize
memory size
Definition: basic_types.h:30
uint8_t pixbyte
Definition: basic_types.h:34
@ TripleByte
3 channels of 8 bits per pixel (like RGB), unsigned integer values
JNIEnv * jenv
JNIEnv jobject
jobject jlong jint jint y
jobject jlong jint x