diff options
author | Jesse Hall <jessehall@google.com> | 2012-04-25 14:38:42 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-04-25 14:38:43 -0700 |
commit | 37264a874ff5f2c612d6481fcc90ee78d15c4ce2 (patch) | |
tree | 6aa9f766e0e4bdd1195290d0ca30f86c1769b161 /emulator | |
parent | 2f90df83d8fdd93e1a780ad6d1be3162b10db8db (diff) | |
parent | 7a712acc02282985dcd32feb81284e1f2b19ec7e (diff) | |
download | sdk-37264a874ff5f2c612d6481fcc90ee78d15c4ce2.zip sdk-37264a874ff5f2c612d6481fcc90ee78d15c4ce2.tar.gz sdk-37264a874ff5f2c612d6481fcc90ee78d15c4ce2.tar.bz2 |
Merge "Publish and use libOpenglRender interface header"
Diffstat (limited to 'emulator')
-rw-r--r-- | emulator/opengl/host/include/libOpenglRender/render_api.h | 146 | ||||
-rw-r--r-- | emulator/opengl/host/libs/libOpenglRender/render_api.cpp | 16 |
2 files changed, 85 insertions, 77 deletions
diff --git a/emulator/opengl/host/include/libOpenglRender/render_api.h b/emulator/opengl/host/include/libOpenglRender/render_api.h index 9c76b3e..1004932 100644 --- a/emulator/opengl/host/include/libOpenglRender/render_api.h +++ b/emulator/opengl/host/include/libOpenglRender/render_api.h @@ -16,12 +16,31 @@ #ifndef _OPENGL_RENDERER_RENDER_API_H #define _OPENGL_RENDERER_RENDER_API_H +/* This header and its declarations must be usable from C code. + * + * If RENDER_API_NO_PROTOTYPES is #defined before including this header, only + * the interface function pointer types will be declared, not the prototypes. + * This allows the client to use those names for its function pointer variables. + * + * All interfaces which can fail return an int, with zero indicating failure + * and anything else indicating success. + */ + #ifdef __cplusplus extern "C" { #endif #include "render_api_platform_types.h" +#if defined(RENDER_API_NO_PROTOTYPES) +#define DECL(ret, name, args) \ + typedef ret (* name##Fn) args +#else +#define DECL(ret, name, args) \ + typedef ret (* name##Fn) args ; \ + ret name args +#endif + /* If a function with this signature is passed to initOpenGLRenderer(), * it will be called by the renderer just before each new frame is displayed, * providing a copy of the framebuffer contents. @@ -54,80 +73,69 @@ extern "C" { typedef void (*OnPostFn)(void* context, int width, int height, int ydir, int format, int type, unsigned char* pixels); -// initLibrary - initialize the library and tries to load the corresponding -// GLES translator libraries. This function must be called before anything -// else to ensure that everything works. If it returns an error, then -// you cannot use the library at all (this can happen under certain -// environments where the desktop GL libraries are not available) -// -// returns true if the library could be initialized successfully; -// -bool initLibrary(void); - -// list of constants to be passed to setStreamMode, which determines -// which +/* initLibrary - initialize the library and tries to load the corresponding + * GLES translator libraries. This function must be called before anything + * else to ensure that everything works. If it returns an error, then + * you cannot use the library at all (this can happen under certain + * environments where the desktop GL libraries are not available) + */ +DECL(int, initLibrary, (void)); + +/* list of constants to be passed to setStreamMode */ #define STREAM_MODE_DEFAULT 0 #define STREAM_MODE_TCP 1 #define STREAM_MODE_UNIX 2 #define STREAM_MODE_PIPE 3 -// Change the stream mode. This must be called before initOpenGLRenderer -int setStreamMode(int mode); - -// -// initOpenGLRenderer - initialize the OpenGL renderer process. -// portNum is the tcp port number the renderer is listening to. -// width and height are the framebuffer dimensions that will be -// reported to the guest display driver. -// -// returns true if renderer has been started successfully; -// -// This function is *NOT* thread safe and should be called first -// to initialize the renderer after initLibrary(). -// -bool initOpenGLRenderer(int width, int height, int portNum, - OnPostFn onPost, void* onPostContext); - -// -// createOpenGLSubwindow - -// Create a native subwindow which is a child of 'window' -// to be used for framebuffer display. -// Framebuffer will not get displayed if a subwindow is not -// created. -// x,y,width,height are the dimensions of the rendering subwindow. -// zRot is the rotation to apply on the framebuffer display image. -// -bool createOpenGLSubwindow(FBNativeWindowType window, - int x, int y, int width, int height, float zRot); - -// -// destroyOpenGLSubwindow - -// destroys the created native subwindow. Once destroyed, -// Framebuffer content will not be visible until a new -// subwindow will be created. -// -bool destroyOpenGLSubwindow(); - -// -// setOpenGLDisplayRotation - -// set the framebuffer display image rotation in units -// of degrees around the z axis -// -void setOpenGLDisplayRotation(float zRot); - -// -// repaintOpenGLDisplay - -// causes the OpenGL subwindow to get repainted with the -// latest framebuffer content. -// -void repaintOpenGLDisplay(); - -// -// stopOpenGLRenderer - stops the OpenGL renderer process. -// This functions is *NOT* thread safe and should be called -// only if previous initOpenGLRenderer has returned true. -// -bool stopOpenGLRenderer(); +/* Change the stream mode. This must be called before initOpenGLRenderer */ +DECL(int, setStreamMode, (int mode)); + +/* initOpenGLRenderer - initialize the OpenGL renderer process. + * portNum is the tcp port number the renderer is listening to. + * width and height are the framebuffer dimensions that will be + * reported to the guest display driver. + * + * This function is *NOT* thread safe and should be called first + * to initialize the renderer after initLibrary(). + */ +DECL(int, initOpenGLRenderer, (int width, int height, int portNum, + OnPostFn onPost, void* onPostContext)); + +/* createOpenGLSubwindow - + * Create a native subwindow which is a child of 'window' + * to be used for framebuffer display. + * Framebuffer will not get displayed if a subwindow is not + * created. + * x,y,width,height are the dimensions of the rendering subwindow. + * zRot is the rotation to apply on the framebuffer display image. + */ +DECL(int, createOpenGLSubwindow, (FBNativeWindowType window, + int x, int y, int width, int height, float zRot)); + +/* destroyOpenGLSubwindow - + * destroys the created native subwindow. Once destroyed, + * Framebuffer content will not be visible until a new + * subwindow will be created. + */ +DECL(int, destroyOpenGLSubwindow, (void)); + +/* setOpenGLDisplayRotation - + * set the framebuffer display image rotation in units + * of degrees around the z axis + */ +DECL(void, setOpenGLDisplayRotation, (float zRot)); + +/* repaintOpenGLDisplay - + * causes the OpenGL subwindow to get repainted with the + * latest framebuffer content. + */ +DECL(void, repaintOpenGLDisplay, (void)); + +/* stopOpenGLRenderer - stops the OpenGL renderer process. + * This functions is *NOT* thread safe and should be called + * only if previous initOpenGLRenderer has returned true. + */ +DECL(int, stopOpenGLRenderer, (void)); #ifdef __cplusplus } diff --git a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp index c8d3e06..00dcd75 100644 --- a/emulator/opengl/host/libs/libOpenglRender/render_api.cpp +++ b/emulator/opengl/host/libs/libOpenglRender/render_api.cpp @@ -50,7 +50,7 @@ static IOStream *createRenderThread(int p_stream_buffer_size, #define RENDER_API_USE_THREAD //#endif -bool initLibrary(void) +int initLibrary(void) { // // Load EGL Plugin @@ -76,7 +76,7 @@ bool initLibrary(void) return true; } -bool initOpenGLRenderer(int width, int height, int portNum, +int initOpenGLRenderer(int width, int height, int portNum, OnPostFn onPost, void* onPostContext) { @@ -191,7 +191,7 @@ bool initOpenGLRenderer(int width, int height, int portNum, return true; } -bool stopOpenGLRenderer() +int stopOpenGLRenderer(void) { bool ret = false; @@ -224,7 +224,7 @@ bool stopOpenGLRenderer() return ret; } -bool createOpenGLSubwindow(FBNativeWindowType window, +int createOpenGLSubwindow(FBNativeWindowType window, int x, int y, int width, int height, float zRot) { if (s_renderThread) { @@ -240,7 +240,7 @@ bool createOpenGLSubwindow(FBNativeWindowType window, return false; } -bool destroyOpenGLSubwindow() +int destroyOpenGLSubwindow(void) { if (s_renderThread) { return FrameBuffer::removeSubWindow(); @@ -272,7 +272,7 @@ void setOpenGLDisplayRotation(float zRot) } } -void repaintOpenGLDisplay() +void repaintOpenGLDisplay(void) { if (s_renderThread) { FrameBuffer *fb = FrameBuffer::getFB(); @@ -352,8 +352,8 @@ setStreamMode(int mode) #endif /* _WIN32 */ default: // Invalid stream mode - return -1; + return false; } gRendererStreamMode = mode; - return 0; + return true; } |