123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- #ifndef __NV_EGL_RENDERER_H__
- #define __NV_EGL_RENDERER_H__
- #include "NvElement.h"
- #include <EGL/egl.h>
- #include <EGL/eglext.h>
- #include <GLES2/gl2.h>
- #include <GLES2/gl2ext.h>
- #include <X11/Xlib.h>
- class NvEglRenderer:public NvElement
- {
- public:
-
- static NvEglRenderer *createEglRenderer(const char *name, uint32_t width,
- uint32_t height, uint32_t x_offset,
- uint32_t y_offset);
- ~NvEglRenderer();
-
- int render(int fd);
-
- int setFPS(float fps);
-
- EGLDisplay getEGLDisplay() { return egl_display; }
-
- static int getDisplayResolution(uint32_t &width, uint32_t &height);
-
- int setOverlayText(char *str, uint32_t x, uint32_t y);
- private:
- Display * x_display;
- Window x_window;
- EGLDisplay egl_display;
- EGLContext egl_context;
- EGLSurface egl_surface;
- EGLConfig egl_config;
- uint32_t texture_id;
- GC gc;
- XFontStruct *fontinfo;
- char overlay_str[512];
-
- int create_texture();
-
- int InitializeShaders();
-
- void CreateShader(GLuint program, GLenum type, const char *source,
- int size);
- 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;
-
- NvEglRenderer(const char *name, uint32_t width, uint32_t height,
- uint32_t x_offset, uint32_t y_offset);
-
- static int initEgl();
-
- static void * renderThread(void *arg);
-
- int renderInternal();
-
- static PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR;
- static PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;
- static PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR;
- static PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR;
- static PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
- static PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
- static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES;
- static const NvElementProfiler::ProfilerField valid_fields =
- NvElementProfiler::PROFILER_FIELD_TOTAL_UNITS |
- NvElementProfiler::PROFILER_FIELD_FPS |
- NvElementProfiler::PROFILER_FIELD_LATE_UNITS;
- };
- #endif
|