Logo
ApraPipes 1.0
Loading...
Searching...
No Matches
ApraNvEglRenderer.h
1/*
2 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of NVIDIA CORPORATION nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
35#ifndef __NV_EGL_RENDERER_H__
36#define __NV_EGL_RENDERER_H__
37
38#include <EGL/egl.h>
39#include <EGL/eglext.h>
40#include <GLES2/gl2.h>
41#include <GLES2/gl2ext.h>
42
43#include <X11/Xlib.h>
44
73{
74public:
96 static NvEglRenderer *createEglRenderer(const char *name, uint32_t width,
97 uint32_t height, uint32_t x_offset,
98 uint32_t y_offset , bool displayOnTop);
100
113 int render(int fd);
114
123 int setFPS(float fps);
124
130 EGLDisplay getEGLDisplay() { return egl_display; }
131
140 static int getDisplayResolution(uint32_t &width, uint32_t &height);
141 bool renderAndDrawLoop();
142 bool windowDrag();
152 int setOverlayText(char *str, uint32_t x, uint32_t y);
153public:
154 Display * x_display;
156 Window x_window;
159 uint32_t mWidth,mHeight;
160
163 bool is_dragging = false;
164 uint32_t _x_offset = 0;
165 uint32_t _y_offset = 0;
166 XEvent event;
167 bool drawBorder = false;
168
169 EGLDisplay egl_display;
170 EGLContext egl_context;
171 EGLSurface egl_surface;
172 EGLConfig egl_config;
175 uint32_t texture_id;
176 GC gc;
177 XFontStruct *fontinfo;
178 char overlay_str[512];
185 int create_texture();
192 int InitializeShaders();
202 void CreateShader(GLuint program, GLenum type, const char *source,
203 int size);
204
205 struct timespec last_render_time;
211 pthread_t render_thread;
212 pthread_mutex_t render_lock;
213 pthread_cond_t render_cond;
216 float fps;
225 NvEglRenderer(const char *name, uint32_t width, uint32_t height,
226 uint32_t x_offset, uint32_t y_offset , bool displayOnTop);
230 static int initEgl();
238 static void * renderThread(void *arg);
243 int renderInternal();
244
248 static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
249 static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
250 static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR;
251 static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR;
252 static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
253 static PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
254 static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
255};
257#endif
Definition ApraNvEglRenderer.h:73
bool windowDrag()
Definition NvEglRenderer.cpp:232
static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR
Definition ApraNvEglRenderer.h:248
static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR
Definition ApraNvEglRenderer.h:252
static void * renderThread(void *arg)
Definition NvEglRenderer.cpp:343
bool stop_thread
Definition ApraNvEglRenderer.h:209
int render_fd
Definition ApraNvEglRenderer.h:207
void CreateShader(GLuint program, GLenum type, const char *source, int size)
Definition NvEglRenderer.cpp:685
Window x_window
Definition ApraNvEglRenderer.h:156
int drag_start_y
Definition ApraNvEglRenderer.h:162
uint64_t render_time_nsec
Definition ApraNvEglRenderer.h:219
int drag_start_x
Definition ApraNvEglRenderer.h:161
uint32_t _y_offset
Definition ApraNvEglRenderer.h:165
uint64_t render_time_sec
Definition ApraNvEglRenderer.h:217
static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR
Definition ApraNvEglRenderer.h:251
pthread_t render_thread
Definition ApraNvEglRenderer.h:211
uint32_t overlay_str_x_offset
Definition ApraNvEglRenderer.h:214
XFontStruct * fontinfo
Definition ApraNvEglRenderer.h:177
bool renderAndDrawLoop()
Definition NvEglRenderer.cpp:222
GC gc
Definition ApraNvEglRenderer.h:176
uint32_t mHeight
Definition ApraNvEglRenderer.h:159
Display * x_display
Definition ApraNvEglRenderer.h:154
uint32_t _x_offset
Definition ApraNvEglRenderer.h:164
static int getDisplayResolution(uint32_t &width, uint32_t &height)
Definition NvEglRenderer.cpp:323
EGLConfig egl_config
Definition ApraNvEglRenderer.h:172
struct timespec last_render_time
Definition ApraNvEglRenderer.h:205
int InitializeShaders()
Definition NvEglRenderer.cpp:709
EGLSurface egl_surface
Definition ApraNvEglRenderer.h:171
bool drawBorder
Definition ApraNvEglRenderer.h:167
int create_texture()
Definition NvEglRenderer.cpp:786
static PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR
Definition ApraNvEglRenderer.h:253
int setFPS(float fps)
Definition NvEglRenderer.cpp:611
static int initEgl()
Definition NvEglRenderer.cpp:640
int render(int fd)
Definition NvEglRenderer.cpp:511
~NvEglRenderer()
Definition NvEglRenderer.cpp:475
uint32_t mWidth
Definition ApraNvEglRenderer.h:159
EGLDisplay egl_display
Definition ApraNvEglRenderer.h:169
pthread_mutex_t render_lock
Definition ApraNvEglRenderer.h:212
int renderInternal()
Definition NvEglRenderer.cpp:522
bool is_dragging
Definition ApraNvEglRenderer.h:163
uint32_t texture_id
Definition ApraNvEglRenderer.h:175
float fps
Definition ApraNvEglRenderer.h:216
XEvent event
Definition ApraNvEglRenderer.h:166
int setOverlayText(char *str, uint32_t x, uint32_t y)
Definition NvEglRenderer.cpp:599
static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES
Definition ApraNvEglRenderer.h:254
static NvEglRenderer * createEglRenderer(const char *name, uint32_t width, uint32_t height, uint32_t x_offset, uint32_t y_offset, bool displayOnTop)
Definition NvEglRenderer.cpp:630
EGLDisplay getEGLDisplay()
Definition ApraNvEglRenderer.h:130
EGLContext egl_context
Definition ApraNvEglRenderer.h:170
NvEglRenderer(const char *name, uint32_t width, uint32_t height, uint32_t x_offset, uint32_t y_offset, bool displayOnTop)
Definition NvEglRenderer.cpp:56
uint32_t overlay_str_y_offset
Definition ApraNvEglRenderer.h:215
char overlay_str[512]
Definition ApraNvEglRenderer.h:178
static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR
Definition ApraNvEglRenderer.h:250
static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR
Definition ApraNvEglRenderer.h:249
pthread_cond_t render_cond
Definition ApraNvEglRenderer.h:213
Definition GTKSetup.cpp:72