Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
NvEglRenderer Class Reference

#include <ApraNvEglRenderer.h>

Collaboration diagram for NvEglRenderer:
Collaboration graph

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 NvEglRenderercreateEglRenderer (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
 

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.

Constructor & Destructor Documentation

◆ ~NvEglRenderer()

NvEglRenderer::~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.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ create_texture()

int NvEglRenderer::create_texture ( )

Creates a GL texture used for rendering.

Returns
0 for success, -1 otherwise.
Here is the caller graph for this function:

◆ createEglRenderer()

NvEglRenderer * NvEglRenderer::createEglRenderer ( const char * name,
uint32_t width,
uint32_t height,
uint32_t x_offset,
uint32_t y_offset,
bool displayOnTop )
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]nameSpecifies a pointer to a unique name to identity the element instance.
[in]widthSpecifies the width of the window in pixels.
[in]heightSpecifies the height of the window in pixels.
[in]x_offsetSpecifies the horizontal offset of the window in pixels.
[in]y_offsetSpecifies 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateShader()

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

Creates, compiles and attaches a shader to the program.

Parameters
[in]programSpecifies the GL Program ID.
[in]typeSpecifies the type of the vertex shader. Must be either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
[in]sourceSpecifies the source code of the shader in form of a string.
[in]sizeSpecifies the character length of source.
Here is the caller graph for this function:

◆ getDisplayResolution()

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

Gets the display resolution.

Parameters
[out]widthA pointer to the full screen width, in pixels.
[out]heightA pointer to the full screen height, in pixels.
Returns
0 for success, -1 otherwise.
Here is the caller graph for this function:

◆ getEGLDisplay()

EGLDisplay NvEglRenderer::getEGLDisplay ( )
inline

Gets underlying EGLDisplay.

Returns
EGLDisplay handle

◆ initEgl()

int NvEglRenderer::initEgl ( )
static

Gets the pointers to the required EGL methods.

Here is the caller graph for this function:

◆ InitializeShaders()

int NvEglRenderer::InitializeShaders ( void )

Initializes shaders with shader programs required for drawing a buffer.

Returns
0 for success, -1 otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ render()

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]fdSpecifies the file descriptor (FD) of the exported buffer to render.
Returns
0 for success, -1 otherwise.

◆ renderAndDrawLoop()

bool NvEglRenderer::renderAndDrawLoop ( )
Here is the caller graph for this function:

◆ renderInternal()

int NvEglRenderer::renderInternal ( )

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

Here is the caller graph for this function:

◆ renderThread()

void * NvEglRenderer::renderThread ( void * arg)
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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFPS()

int NvEglRenderer::setFPS ( float fps)

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

Warning
An fps of zero is not allowed.
Parameters
[in]fpsSpecifies the render rate in fps.
Returns
0 for success, -1 otherwise.
Here is the caller graph for this function:

◆ setOverlayText()

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

Sets the overlay string.

Parameters
[in]strA pointer to the overlay text.
[in]xHorizontal offset, in pixels.
[in]yVertical offset, in pixels.
Returns
0 for success, -1 otherwise.

◆ windowDrag()

bool NvEglRenderer::windowDrag ( )
Here is the caller graph for this function:

Member Data Documentation

◆ _x_offset

uint32_t NvEglRenderer::_x_offset = 0

◆ _y_offset

uint32_t NvEglRenderer::_y_offset = 0

◆ drag_start_x

int NvEglRenderer::drag_start_x = 0

◆ drag_start_y

int NvEglRenderer::drag_start_y = 0

◆ drawBorder

bool NvEglRenderer::drawBorder = false

◆ egl_config

EGLConfig NvEglRenderer::egl_config

Holds the EGL frame buffer configuration to be used for rendering.

◆ egl_context

EGLContext NvEglRenderer::egl_context

Holds the EGL rendering context.

◆ egl_display

EGLDisplay NvEglRenderer::egl_display

Holds the EGL Display connection.

◆ egl_surface

EGLSurface NvEglRenderer::egl_surface

Holds the EGL Window render surface.

◆ eglClientWaitSyncKHR

PFNEGLCLIENTWAITSYNCKHRPROC NvEglRenderer::eglClientWaitSyncKHR
static

◆ eglCreateImageKHR

PFNEGLCREATEIMAGEKHRPROC NvEglRenderer::eglCreateImageKHR
static

These EGL function pointers are required by the renderer.

◆ eglCreateSyncKHR

PFNEGLCREATESYNCKHRPROC NvEglRenderer::eglCreateSyncKHR
static

◆ eglDestroyImageKHR

PFNEGLDESTROYIMAGEKHRPROC NvEglRenderer::eglDestroyImageKHR
static

◆ eglDestroySyncKHR

PFNEGLDESTROYSYNCKHRPROC NvEglRenderer::eglDestroySyncKHR
static

◆ eglGetSyncAttribKHR

PFNEGLGETSYNCATTRIBKHRPROC NvEglRenderer::eglGetSyncAttribKHR
static

◆ event

XEvent NvEglRenderer::event

◆ fontinfo

XFontStruct* NvEglRenderer::fontinfo

Brush's font info

◆ fps

float NvEglRenderer::fps

The render rate in frames per second.

◆ gc

GC NvEglRenderer::gc

Graphic Context

◆ glEGLImageTargetTexture2DOES

PFNGLEGLIMAGETARGETTEXTURE2DOESPROC NvEglRenderer::glEGLImageTargetTexture2DOES
static

◆ is_dragging

bool NvEglRenderer::is_dragging = false

◆ last_render_time

struct timespec NvEglRenderer::last_render_time

Rendering time for the last buffer.

◆ mHeight

uint32_t NvEglRenderer::mHeight

◆ mWidth

uint32_t NvEglRenderer::mWidth

◆ overlay_str

char NvEglRenderer::overlay_str[512]

Overlay's text

◆ overlay_str_x_offset

uint32_t NvEglRenderer::overlay_str_x_offset

Overlay text's position in horizontal direction.

◆ overlay_str_y_offset

uint32_t NvEglRenderer::overlay_str_y_offset

Overlay text's position in vertical direction.

◆ render_cond

pthread_cond_t NvEglRenderer::render_cond

Used for synchronization.

◆ render_fd

int NvEglRenderer::render_fd

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

◆ render_lock

pthread_mutex_t NvEglRenderer::render_lock

Used for synchronization.

◆ render_thread

pthread_t NvEglRenderer::render_thread

The pthread id of the rendering thread.

◆ render_time_nsec

uint64_t NvEglRenderer::render_time_nsec

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

◆ render_time_sec

uint64_t NvEglRenderer::render_time_sec

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

◆ stop_thread

bool NvEglRenderer::stop_thread

Boolean variable used to signal rendering thread to stop.

◆ texture_id

uint32_t NvEglRenderer::texture_id

Holds the GL Texture ID used for rendering.

◆ x_display

Display* NvEglRenderer::x_display

Connection to the X server created using XOpenDisplay().

◆ x_window

Window NvEglRenderer::x_window

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


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