NvEglRenderer Class Reference
[Rendering API]

NvEglRenderer is a helper class for rendering using EGL and OpenGL ES 2.0. More...

#include <NvEglRenderer.h>

Inheritance diagram for NvEglRenderer:

NvElement

List of all members.

Public Member Functions

 ~NvEglRenderer ()
int render (int fd)
 Renders a buffer.
int setFPS (float fps)
 Sets the rendering rate in frames per second (fps).
EGLDisplay getEGLDisplay ()
 Get underlying EGLDisplay.
int setOverlayText (char *str, uint32_t x, uint32_t y)
 Set Overlay string.

Static Public Member Functions

static NvEglRenderercreateEglRenderer (const char *name, uint32_t width, uint32_t height, uint32_t x_offset, uint32_t y_offset)
 Creates a new EGL-based renderer named name.
static int getDisplayResolution (uint32_t &width, uint32_t &height)
 Get Display's resolution.

Private Member Functions

int create_texture ()
 Creates a GL texture used for rendering.
int InitializeShaders ()
 Initializes shaders with shader programs required for drawing a buffer.
void CreateShader (GLuint program, GLenum type, const char *source, int size)
 Creates, compiles and attaches a shader to the program.
 NvEglRenderer (const char *name, uint32_t width, uint32_t height, uint32_t x_offset, uint32_t y_offset)
 Constructor called by the wrapper createEglRenderer.
int renderInternal ()
 This method contains the actual logic of rendering a buffer and waiting until the buffer render time.

Static Private Member Functions

static int initEgl ()
 Gets the pointers to the required EGL methods.
static void * renderThread (void *arg)
 Method executed by the renderThread.

Private Attributes

Display * x_display
 Connection to the X server created using XOpenDisplay().
Window x_window
 Holds the window to be used for rendering created using XCreateWindow().
EGLDisplay egl_display
 Holds the EGL Display connection.
EGLContext egl_context
 Holds the EGL rendering context.
EGLSurface egl_surface
 Holds the EGL Window render surface.
EGLConfig egl_config
 Holds the EGL frame buffer configuration to be usedfor rendering.
uint32_t texture_id
 Holds the GL Texture ID used for rendering.
GC gc
 Graphic Context.
XFontStruct * fontinfo
 Brush's font info.
char overlay_str [512]
 Overlay's text.
struct timespec last_render_time
 Rendering time for the last buffer.
int render_fd
 File descriptor (FD) of the next buffer to render.
bool stop_thread
 Boolean variable used to signal rendering thread to stop.
pthread_t render_thread
 The pthread id of the rendering thread.
pthread_mutex_t render_lock
 Used for synchronization.
pthread_cond_t render_cond
 Used for synchronization.
uint32_t overlay_str_x_offset
 overlay text's position in horizontal direction.
uint32_t overlay_str_y_offset
 overlay text's position in vertical direction.
float fps
 The render rate in frames per second.
uint64_t render_time_sec
 Seconds component of the time for which a frame should be displayed.
uint64_t render_time_nsec
 Nanoseconds component of the time for which a frame should be displayed.

Static Private Attributes

static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR
 These EGL function pointers are required by the renderer.
static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR
static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR
static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR
static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR
static PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR
static
PFNGLEGLIMAGETARGETTEXTURE2DOESPROC 
glEGLImageTargetTexture2DOES
static const
NvElementProfiler::ProfilerField 
valid_fields


Detailed Description

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.

Definition at line 73 of file NvEglRenderer.h.


Constructor & Destructor Documentation

NvEglRenderer::~NvEglRenderer (  ) 

Definition at line 323 of file NvEglRenderer.cpp.

NvEglRenderer::NvEglRenderer ( const char *  name,
uint32_t  width,
uint32_t  height,
uint32_t  x_offset,
uint32_t  y_offset 
) [private]

Constructor called by the wrapper createEglRenderer.

Definition at line 56 of file NvEglRenderer.cpp.


Member Function Documentation

int NvEglRenderer::create_texture (  )  [private]

Creates a GL texture used for rendering.

Returns:
0 for success, -1 otherwise.

Definition at line 672 of file NvEglRenderer.cpp.

NvEglRenderer * NvEglRenderer::createEglRenderer ( const char *  name,
uint32_t  width,
uint32_t  height,
uint32_t  x_offset,
uint32_t  y_offset 
) [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.

Parameters:
[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.
Returns:
A reference to the newly created renderer object, otherwise NULL in case of failure during initialization.

Definition at line 500 of file NvEglRenderer.cpp.

void NvEglRenderer::CreateShader ( GLuint  program,
GLenum  type,
const char *  source,
int  size 
) [private]

Creates, compiles and attaches a shader to the program.

Parameters:
[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.

Definition at line 560 of file NvEglRenderer.cpp.

int NvEglRenderer::getDisplayResolution ( uint32_t &  width,
uint32_t &  height 
) [static]

Get Display's resolution.

Parameters:
[out] Full screen width, in pixel
[out] Full screen height, in pixel
Returns:
0 for success, -1 for failure

Definition at line 157 of file NvEglRenderer.cpp.

EGLDisplay NvEglRenderer::getEGLDisplay (  )  [inline]

Get underlying EGLDisplay.

Returns:
EGLDisplay handle

Definition at line 131 of file NvEglRenderer.h.

int NvEglRenderer::initEgl (  )  [static, private]

Gets the pointers to the required EGL methods.

Definition at line 515 of file NvEglRenderer.cpp.

int NvEglRenderer::InitializeShaders ( void   )  [private]

Initializes shaders with shader programs required for drawing a buffer.

Returns:
0 for success, -1 otherwise.

Definition at line 586 of file NvEglRenderer.cpp.

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.

Parameters:
[in] fd Specifies the file descriptor (FD) of the exported buffer to render.
Returns:
0 for success, -1 otherwise.

Definition at line 359 of file NvEglRenderer.cpp.

int NvEglRenderer::renderInternal (  )  [private]

This method contains the actual logic of rendering a buffer and waiting until the buffer render time.

Definition at line 371 of file NvEglRenderer.cpp.

void * NvEglRenderer::renderThread ( void *  arg  )  [static, private]

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().

Definition at line 177 of file NvEglRenderer.cpp.

int NvEglRenderer::setFPS ( float  fps  ) 

Sets the rendering rate in frames per second (fps).

Warning:
An fps of zero is not allowed.
Parameters:
[in] fps Specifies the render rate in fps.
Returns:
0 for success, -1 otherwise.

Definition at line 480 of file NvEglRenderer.cpp.

int NvEglRenderer::setOverlayText ( char *  str,
uint32_t  x,
uint32_t  y 
)

Set Overlay string.

Parameters:
[in] str Overlay Text
[in] Horizontal offset, in pixel
[in] Vertical offset, in pixel
Returns:
0 for success, -1 for failure

Definition at line 468 of file NvEglRenderer.cpp.


Member Data Documentation

EGLConfig NvEglRenderer::egl_config [private]

Holds the EGL frame buffer configuration to be usedfor rendering.

Definition at line 163 of file NvEglRenderer.h.

EGLContext NvEglRenderer::egl_context [private]

Holds the EGL rendering context.

Definition at line 161 of file NvEglRenderer.h.

EGLDisplay NvEglRenderer::egl_display [private]

Holds the EGL Display connection.

Definition at line 160 of file NvEglRenderer.h.

EGLSurface NvEglRenderer::egl_surface [private]

Holds the EGL Window render surface.

Definition at line 162 of file NvEglRenderer.h.

PFNEGLCLIENTWAITSYNCKHRPROC NvEglRenderer::eglClientWaitSyncKHR [static, private]

Definition at line 243 of file NvEglRenderer.h.

PFNEGLCREATEIMAGEKHRPROC NvEglRenderer::eglCreateImageKHR [static, private]

These EGL function pointers are required by the renderer.

Definition at line 239 of file NvEglRenderer.h.

PFNEGLCREATESYNCKHRPROC NvEglRenderer::eglCreateSyncKHR [static, private]

Definition at line 241 of file NvEglRenderer.h.

PFNEGLDESTROYIMAGEKHRPROC NvEglRenderer::eglDestroyImageKHR [static, private]

Definition at line 240 of file NvEglRenderer.h.

PFNEGLDESTROYSYNCKHRPROC NvEglRenderer::eglDestroySyncKHR [static, private]

Definition at line 242 of file NvEglRenderer.h.

PFNEGLGETSYNCATTRIBKHRPROC NvEglRenderer::eglGetSyncAttribKHR [static, private]

Definition at line 244 of file NvEglRenderer.h.

XFontStruct* NvEglRenderer::fontinfo [private]

Brush's font info.

Definition at line 168 of file NvEglRenderer.h.

float NvEglRenderer::fps [private]

The render rate in frames per second.

Definition at line 207 of file NvEglRenderer.h.

GC NvEglRenderer::gc [private]

Graphic Context.

Definition at line 167 of file NvEglRenderer.h.

PFNGLEGLIMAGETARGETTEXTURE2DOESPROC NvEglRenderer::glEGLImageTargetTexture2DOES [static, private]

Definition at line 245 of file NvEglRenderer.h.

struct timespec NvEglRenderer::last_render_time [read, private]

Rendering time for the last buffer.

Definition at line 196 of file NvEglRenderer.h.

char NvEglRenderer::overlay_str[512] [private]

Overlay's text.

Definition at line 169 of file NvEglRenderer.h.

overlay text's position in horizontal direction.

Definition at line 205 of file NvEglRenderer.h.

overlay text's position in vertical direction.

Definition at line 206 of file NvEglRenderer.h.

pthread_cond_t NvEglRenderer::render_cond [private]

Used for synchronization.

Definition at line 204 of file NvEglRenderer.h.

int NvEglRenderer::render_fd [private]

File descriptor (FD) of the next buffer to render.

Definition at line 198 of file NvEglRenderer.h.

pthread_mutex_t NvEglRenderer::render_lock [private]

Used for synchronization.

Definition at line 203 of file NvEglRenderer.h.

pthread_t NvEglRenderer::render_thread [private]

The pthread id of the rendering thread.

Definition at line 202 of file NvEglRenderer.h.

uint64_t NvEglRenderer::render_time_nsec [private]

Nanoseconds component of the time for which a frame should be displayed.

Definition at line 210 of file NvEglRenderer.h.

uint64_t NvEglRenderer::render_time_sec [private]

Seconds component of the time for which a frame should be displayed.

Definition at line 208 of file NvEglRenderer.h.

Boolean variable used to signal rendering thread to stop.

Definition at line 200 of file NvEglRenderer.h.

uint32_t NvEglRenderer::texture_id [private]

Holds the GL Texture ID used for rendering.

Definition at line 166 of file NvEglRenderer.h.

Display* NvEglRenderer::x_display [private]

Connection to the X server created using XOpenDisplay().

Definition at line 155 of file NvEglRenderer.h.

Window NvEglRenderer::x_window [private]

Holds the window to be used for rendering created using XCreateWindow().

Definition at line 157 of file NvEglRenderer.h.


The documentation for this class was generated from the following files:

Generated on Wed Nov 9 19:52:25 2016 for NVIDIA Tegra Multimedia API Framework by  doxygen 1.5.8