![]() |
ApraPipes 1.0
|
#include <ApraNvEglRenderer.h>
Public Member Functions | |
~NvEglRenderer () | |
int | render (int fd) |
int | setFPS (float fps) |
EGLDisplay | getEGLDisplay () |
bool | renderAndDrawLoop () |
bool | windowDrag () |
int | setOverlayText (char *str, uint32_t x, uint32_t y) |
int | create_texture () |
int | InitializeShaders () |
void | CreateShader (GLuint program, GLenum type, const char *source, int size) |
NvEglRenderer (const char *name, uint32_t width, uint32_t height, uint32_t x_offset, uint32_t y_offset, bool displayOnTop) | |
int | renderInternal () |
Static Public Member Functions | |
static NvEglRenderer * | createEglRenderer (const char *name, uint32_t width, uint32_t height, uint32_t x_offset, uint32_t y_offset, bool displayOnTop) |
static int | getDisplayResolution (uint32_t &width, uint32_t &height) |
static int | initEgl () |
static void * | renderThread (void *arg) |
Public Attributes | |
Display * | x_display |
Window | x_window |
uint32_t | mWidth |
uint32_t | mHeight |
int | drag_start_x = 0 |
int | drag_start_y = 0 |
bool | is_dragging = false |
uint32_t | _x_offset = 0 |
uint32_t | _y_offset = 0 |
XEvent | event |
bool | drawBorder = false |
EGLDisplay | egl_display |
EGLContext | egl_context |
EGLSurface | egl_surface |
EGLConfig | egl_config |
uint32_t | texture_id |
GC | gc |
XFontStruct * | fontinfo |
char | overlay_str [512] |
struct timespec | last_render_time |
int | render_fd |
bool | stop_thread |
pthread_t | render_thread |
pthread_mutex_t | render_lock |
pthread_cond_t | render_cond |
uint32_t | overlay_str_x_offset |
uint32_t | overlay_str_y_offset |
float | fps |
uint64_t | render_time_sec |
uint64_t | render_time_nsec |
Static Public Attributes | |
static PFNEGLCREATEIMAGEKHRPROC | eglCreateImageKHR |
static PFNEGLDESTROYIMAGEKHRPROC | eglDestroyImageKHR |
static PFNEGLCREATESYNCKHRPROC | eglCreateSyncKHR |
static PFNEGLDESTROYSYNCKHRPROC | eglDestroySyncKHR |
static PFNEGLCLIENTWAITSYNCKHRPROC | eglClientWaitSyncKHR |
static PFNEGLGETSYNCATTRIBKHRPROC | eglGetSyncAttribKHR |
static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC | glEGLImageTargetTexture2DOES |
NvEglRenderer
is a helper class for rendering using EGL and OpenGL ES 2.0. The renderer requires the file descriptor (FD) of a buffer as an input. The rendering rate, in frames per second (fps), is configurable.
The renderer creates an X Window of its own. The width, height, horizontal offset, and vertical offset of the window are configurable.
All EGL calls must be made through one thread only. This class internally creates a thread which performs all EGL/GL initializations, gets EGLImage
objects from FD, renders the EGLImage
objects, and then deinitializes all the EGL/GL structures.
NvEglRenderer::~NvEglRenderer | ( | ) |
NvEglRenderer::NvEglRenderer | ( | const char * | name, |
uint32_t | width, | ||
uint32_t | height, | ||
uint32_t | x_offset, | ||
uint32_t | y_offset, | ||
bool | displayOnTop ) |
Constructor called by the wrapper createEglRenderer.
int NvEglRenderer::create_texture | ( | ) |
Creates a GL texture used for rendering.
|
static |
Creates a new EGL-based renderer named name.
This method creates a new X window for rendering, of size width and height, that is offset by x_offset and y_offset. If width or height is zero, a full screen window is created with x_offset and y_offset set to zero.
It internally initializes EGL, creates an eglContext
, an eglSurface
, a GL texture, and shaders for rendering.
[in] | name | Specifies a pointer to a unique name to identity the element instance. |
[in] | width | Specifies the width of the window in pixels. |
[in] | height | Specifies the height of the window in pixels. |
[in] | x_offset | Specifies the horizontal offset of the window in pixels. |
[in] | y_offset | Specifies the vertical offset of the window in pixels. |
NULL
in case of failure during initialization. void NvEglRenderer::CreateShader | ( | GLuint | program, |
GLenum | type, | ||
const char * | source, | ||
int | size ) |
Creates, compiles and attaches a shader to the program.
[in] | program | Specifies the GL Program ID. |
[in] | type | Specifies the type of the vertex shader. Must be either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER . |
[in] | source | Specifies the source code of the shader in form of a string. |
[in] | size | Specifies the character length of source. |
|
static |
Gets the display resolution.
[out] | width | A pointer to the full screen width, in pixels. |
[out] | height | A pointer to the full screen height, in pixels. |
|
inline |
Gets underlying EGLDisplay.
|
static |
Gets the pointers to the required EGL methods.
int NvEglRenderer::InitializeShaders | ( | void | ) |
Initializes shaders with shader programs required for drawing a buffer.
int NvEglRenderer::render | ( | int | fd | ) |
Renders a buffer.
This method waits until the rendering time of the next buffer, caluclated from the rendering time of the last buffer and the render rate in frames per second (fps). This is a blocking call.
[in] | fd | Specifies the file descriptor (FD) of the exported buffer to render. |
bool NvEglRenderer::renderAndDrawLoop | ( | ) |
int NvEglRenderer::renderInternal | ( | ) |
This method contains the actual logic of rendering a buffer and waiting until the buffer render time.
|
static |
Method executed by the renderThread.
This method continues to execute infinitely until signalled to stop with the stop_thread
variable. This method contains a while loop that calls NvEglRenderer::renderInternal().
int NvEglRenderer::setFPS | ( | float | fps | ) |
Sets the rendering rate in frames per second (fps).
[in] | fps | Specifies the render rate in fps. |
int NvEglRenderer::setOverlayText | ( | char * | str, |
uint32_t | x, | ||
uint32_t | y ) |
Sets the overlay string.
[in] | str | A pointer to the overlay text. |
[in] | x | Horizontal offset, in pixels. |
[in] | y | Vertical offset, in pixels. |
bool NvEglRenderer::windowDrag | ( | ) |
uint32_t NvEglRenderer::_x_offset = 0 |
uint32_t NvEglRenderer::_y_offset = 0 |
int NvEglRenderer::drag_start_x = 0 |
int NvEglRenderer::drag_start_y = 0 |
bool NvEglRenderer::drawBorder = false |
EGLConfig NvEglRenderer::egl_config |
Holds the EGL frame buffer configuration to be used for rendering.
EGLContext NvEglRenderer::egl_context |
Holds the EGL rendering context.
EGLDisplay NvEglRenderer::egl_display |
Holds the EGL Display connection.
EGLSurface NvEglRenderer::egl_surface |
Holds the EGL Window render surface.
|
static |
|
static |
These EGL function pointers are required by the renderer.
|
static |
|
static |
|
static |
|
static |
XEvent NvEglRenderer::event |
XFontStruct* NvEglRenderer::fontinfo |
Brush's font info
float NvEglRenderer::fps |
The render rate in frames per second.
GC NvEglRenderer::gc |
Graphic Context
|
static |
bool NvEglRenderer::is_dragging = false |
struct timespec NvEglRenderer::last_render_time |
Rendering time for the last buffer.
uint32_t NvEglRenderer::mHeight |
uint32_t NvEglRenderer::mWidth |
char NvEglRenderer::overlay_str[512] |
Overlay's text
uint32_t NvEglRenderer::overlay_str_x_offset |
Overlay text's position in horizontal direction.
uint32_t NvEglRenderer::overlay_str_y_offset |
Overlay text's position in vertical direction.
pthread_cond_t NvEglRenderer::render_cond |
Used for synchronization.
int NvEglRenderer::render_fd |
File descriptor (FD) of the next buffer to render.
pthread_mutex_t NvEglRenderer::render_lock |
Used for synchronization.
pthread_t NvEglRenderer::render_thread |
The pthread id of the rendering thread.
uint64_t NvEglRenderer::render_time_nsec |
Nanoseconds component of the time for which a frame should be displayed.
uint64_t NvEglRenderer::render_time_sec |
Seconds component of the time for which a frame should be displayed.
bool NvEglRenderer::stop_thread |
Boolean variable used to signal rendering thread to stop.
uint32_t NvEglRenderer::texture_id |
Holds the GL Texture ID used for rendering.
Display* NvEglRenderer::x_display |
Connection to the X server created using XOpenDisplay().
Window NvEglRenderer::x_window |
Holds the window to be used for rendering created using XCreateWindow().