aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl/host/libs
diff options
context:
space:
mode:
Diffstat (limited to 'emulator/opengl/host/libs')
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp38
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h6
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/render_api.cpp26
3 files changed, 48 insertions, 22 deletions
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
index fde82a1..2f7cd61 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
@@ -101,7 +101,7 @@ void FrameBuffer::finalize(){
}
}
-bool FrameBuffer::initialize(int width, int height, OnPostFn onPost, void* onPostContext)
+bool FrameBuffer::initialize(int width, int height)
{
if (s_theFrameBuffer != NULL) {
return true;
@@ -110,7 +110,7 @@ bool FrameBuffer::initialize(int width, int height, OnPostFn onPost, void* onPos
//
// allocate space for the FrameBuffer object
//
- FrameBuffer *fb = new FrameBuffer(width, height, onPost, onPostContext);
+ FrameBuffer *fb = new FrameBuffer(width, height);
if (!fb) {
ERR("Failed to create fb\n");
return false;
@@ -335,17 +335,6 @@ bool FrameBuffer::initialize(int width, int height, OnPostFn onPost, void* onPos
fb->initGLState();
//
- // Allocate space for the onPost framebuffer image
- //
- if (onPost) {
- fb->m_fbImage = (unsigned char*)malloc(4 * width * height);
- if (!fb->m_fbImage) {
- delete fb;
- return false;
- }
- }
-
- //
// Cache the GL strings so we don't have to think about threading or
// current-context when asked for them.
//
@@ -363,8 +352,7 @@ bool FrameBuffer::initialize(int width, int height, OnPostFn onPost, void* onPos
return true;
}
-FrameBuffer::FrameBuffer(int p_width, int p_height,
- OnPostFn onPost, void* onPostContext) :
+FrameBuffer::FrameBuffer(int p_width, int p_height) :
m_width(p_width),
m_height(p_height),
m_eglDisplay(EGL_NO_DISPLAY),
@@ -381,8 +369,8 @@ FrameBuffer::FrameBuffer(int p_width, int p_height,
m_eglContextInitialized(false),
m_statsNumFrames(0),
m_statsStartTime(0LL),
- m_onPost(onPost),
- m_onPostContext(onPostContext),
+ m_onPost(NULL),
+ m_onPostContext(NULL),
m_fbImage(NULL),
m_glVendor(NULL),
m_glRenderer(NULL),
@@ -396,6 +384,22 @@ FrameBuffer::~FrameBuffer()
free(m_fbImage);
}
+void FrameBuffer::setPostCallback(OnPostFn onPost, void* onPostContext)
+{
+ android::Mutex::Autolock mutex(m_lock);
+ m_onPost = onPost;
+ m_onPostContext = onPostContext;
+ if (m_onPost && !m_fbImage) {
+ m_fbImage = (unsigned char*)malloc(4 * m_width * m_height);
+ if (!m_fbImage) {
+ ERR("out of memory, cancelling OnPost callback");
+ m_onPost = NULL;
+ m_onPostContext = NULL;
+ return;
+ }
+ }
+}
+
bool FrameBuffer::setupSubWindow(FBNativeWindowType p_window,
int p_x, int p_y,
int p_width, int p_height, float zRot)
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
index 89a708b..de0b71c 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
@@ -46,7 +46,7 @@ struct FrameBufferCaps
class FrameBuffer
{
public:
- static bool initialize(int width, int height, OnPostFn onPost, void* onPostContext);
+ static bool initialize(int width, int height);
static bool setupSubWindow(FBNativeWindowType p_window,
int x, int y,
int width, int height, float zRot);
@@ -59,6 +59,8 @@ public:
int getWidth() const { return m_width; }
int getHeight() const { return m_height; }
+ void setPostCallback(OnPostFn onPost, void* onPostContext);
+
void getGLStrings(const char** vendor, const char** renderer, const char** version) const {
*vendor = m_glVendor;
*renderer = m_glRenderer;
@@ -96,7 +98,7 @@ public:
}
private:
- FrameBuffer(int p_width, int p_height, OnPostFn onPost, void* onPostContext);
+ FrameBuffer(int p_width, int p_height);
~FrameBuffer();
HandleType genHandle();
bool bindSubwin_locked();
diff --git a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
index 7d7a981..72cd9ba 100644
--- a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp
@@ -76,8 +76,7 @@ int initLibrary(void)
return true;
}
-int initOpenGLRenderer(int width, int height, int portNum,
- OnPostFn onPost, void* onPostContext)
+int initOpenGLRenderer(int width, int height, int portNum)
{
//
@@ -94,7 +93,7 @@ int initOpenGLRenderer(int width, int height, int portNum,
// initialize the renderer and listen to connections
// on a thread in the current process.
//
- bool inited = FrameBuffer::initialize(width, height, onPost, onPostContext);
+ bool inited = FrameBuffer::initialize(width, height);
if (!inited) {
return false;
}
@@ -191,6 +190,27 @@ int initOpenGLRenderer(int width, int height, int portNum,
return true;
}
+void setPostCallback(OnPostFn onPost, void* onPostContext)
+{
+#ifdef RENDER_API_USE_THREAD // should be defined for mac
+ FrameBuffer* fb = FrameBuffer::getFB();
+ if (fb) {
+ fb->setPostCallback(onPost, onPostContext);
+ }
+#else
+ if (onPost) {
+ // onPost callback not supported with separate renderer process.
+ //
+ // If we ever revive separate process support, we could make the choice
+ // between thread and process at runtime instead of compile time, and
+ // choose the thread path if an onPost callback is requested. Or, the
+ // callback could be supported with a separate process using shmem or
+ // other IPC mechanism.
+ return false;
+ }
+#endif
+}
+
void getHardwareStrings(const char** vendor, const char** renderer, const char** version)
{
FrameBuffer* fb = FrameBuffer::getFB();