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 74 of file NvEglRenderer.h.
Public Member Functions | |
~NvEglRenderer () | |
int | render (int fd) |
Renders a buffer. More... | |
int | setFPS (float fps) |
Sets the rendering rate in frames per second (fps). More... | |
EGLDisplay | getEGLDisplay () |
Gets underlying EGLDisplay. More... | |
int | setOverlayText (char *str, uint32_t x, uint32_t y) |
Sets the overlay string. More... | |
virtual int | isInError () |
Indicates whether the element encountered an error during its operation. More... | |
void | getProfilingData (NvElementProfiler::NvElementProfilerData &data) |
Gets profiling data for the element. More... | |
void | printProfilingStats (std::ostream &out_stream=std::cout) |
Prints profiling data for the element to an output stream. More... | |
virtual void | enableProfiling () |
Enables profiling for the element. More... | |
bool | isProfilingEnabled () |
Checks whether profiling is enabled for the element. More... | |
Static Public Member Functions | |
static NvEglRenderer * | createEglRenderer (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. More... | |
static int | getDisplayResolution (uint32_t &width, uint32_t &height) |
Gets the display resolution. More... | |
Protected Attributes | |
int | is_in_error |
Indicates if an error was encountered during the operation of the element. More... | |
const char * | comp_name |
Specifies the name of the component, for debugging. More... | |
NvElementProfiler | profiler |
Profiler for the element. More... | |
NvEglRenderer::~NvEglRenderer | ( | ) |
|
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.
|
virtualinherited |
Enables profiling for the element.
Reimplemented in NvV4l2Element.
|
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.
Definition at line 132 of file NvEglRenderer.h.
|
inherited |
Gets profiling data for the element.
|
inlinevirtualinherited |
Indicates whether the element encountered an error during its operation.
Reimplemented in NvV4l2Element.
Definition at line 72 of file NvElement.h.
References NvElement::is_in_error.
|
inherited |
Checks whether profiling is enabled for the element.
|
inherited |
Prints profiling data for the element to an output stream.
[in] | out_stream | Output stream of type std::ostream to print the data to. It takes the default value std::cout if not specified. |
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. |
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. |
|
protectedinherited |
Specifies the name of the component, for debugging.
Definition at line 122 of file NvElement.h.
|
protectedinherited |
Indicates if an error was encountered during the operation of the element.
Definition at line 120 of file NvElement.h.
Referenced by NvElement::isInError().
|
protectedinherited |
Profiler for the element.
Definition at line 124 of file NvElement.h.