Subversion Repositories Kolibri OS

Rev

Rev 6137 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #ifndef __GL_RENDER_H__
  2. #define __GL_RENDER_H__
  3.  
  4. #define EGL_EGLEXT_PROTOTYPES
  5. #define GL_GLEXT_PROTOTYPES
  6.  
  7. #include "EGL/egl.h"
  8. #include "EGL/eglext.h"
  9. #include "EGL/eglmesaext.h"
  10. #include "GL/gl.h"
  11.  
  12. enum wl_drm_format {
  13.     WL_DRM_FORMAT_C8 = 0x20203843,
  14.     WL_DRM_FORMAT_RGB332 = 0x38424752,
  15.     WL_DRM_FORMAT_BGR233 = 0x38524742,
  16.     WL_DRM_FORMAT_XRGB4444 = 0x32315258,
  17.     WL_DRM_FORMAT_XBGR4444 = 0x32314258,
  18.     WL_DRM_FORMAT_RGBX4444 = 0x32315852,
  19.     WL_DRM_FORMAT_BGRX4444 = 0x32315842,
  20.     WL_DRM_FORMAT_ARGB4444 = 0x32315241,
  21.     WL_DRM_FORMAT_ABGR4444 = 0x32314241,
  22.     WL_DRM_FORMAT_RGBA4444 = 0x32314152,
  23.     WL_DRM_FORMAT_BGRA4444 = 0x32314142,
  24.     WL_DRM_FORMAT_XRGB1555 = 0x35315258,
  25.     WL_DRM_FORMAT_XBGR1555 = 0x35314258,
  26.     WL_DRM_FORMAT_RGBX5551 = 0x35315852,
  27.     WL_DRM_FORMAT_BGRX5551 = 0x35315842,
  28.     WL_DRM_FORMAT_ARGB1555 = 0x35315241,
  29.     WL_DRM_FORMAT_ABGR1555 = 0x35314241,
  30.     WL_DRM_FORMAT_RGBA5551 = 0x35314152,
  31.     WL_DRM_FORMAT_BGRA5551 = 0x35314142,
  32.     WL_DRM_FORMAT_RGB565 = 0x36314752,
  33.     WL_DRM_FORMAT_BGR565 = 0x36314742,
  34.     WL_DRM_FORMAT_RGB888 = 0x34324752,
  35.     WL_DRM_FORMAT_BGR888 = 0x34324742,
  36.     WL_DRM_FORMAT_XRGB8888 = 0x34325258,
  37.     WL_DRM_FORMAT_XBGR8888 = 0x34324258,
  38.     WL_DRM_FORMAT_RGBX8888 = 0x34325852,
  39.     WL_DRM_FORMAT_BGRX8888 = 0x34325842,
  40.     WL_DRM_FORMAT_ARGB8888 = 0x34325241,
  41.     WL_DRM_FORMAT_ABGR8888 = 0x34324241,
  42.     WL_DRM_FORMAT_RGBA8888 = 0x34324152,
  43.     WL_DRM_FORMAT_BGRA8888 = 0x34324142,
  44.     WL_DRM_FORMAT_XRGB2101010 = 0x30335258,
  45.     WL_DRM_FORMAT_XBGR2101010 = 0x30334258,
  46.     WL_DRM_FORMAT_RGBX1010102 = 0x30335852,
  47.     WL_DRM_FORMAT_BGRX1010102 = 0x30335842,
  48.     WL_DRM_FORMAT_ARGB2101010 = 0x30335241,
  49.     WL_DRM_FORMAT_ABGR2101010 = 0x30334241,
  50.     WL_DRM_FORMAT_RGBA1010102 = 0x30334152,
  51.     WL_DRM_FORMAT_BGRA1010102 = 0x30334142,
  52.     WL_DRM_FORMAT_YUYV = 0x56595559,
  53.     WL_DRM_FORMAT_YVYU = 0x55595659,
  54.     WL_DRM_FORMAT_UYVY = 0x59565955,
  55.     WL_DRM_FORMAT_VYUY = 0x59555956,
  56.     WL_DRM_FORMAT_AYUV = 0x56555941,
  57.     WL_DRM_FORMAT_NV12 = 0x3231564e,
  58.     WL_DRM_FORMAT_NV21 = 0x3132564e,
  59.     WL_DRM_FORMAT_NV16 = 0x3631564e,
  60.     WL_DRM_FORMAT_NV61 = 0x3136564e,
  61.     WL_DRM_FORMAT_YUV410 = 0x39565559,
  62.     WL_DRM_FORMAT_YVU410 = 0x39555659,
  63.     WL_DRM_FORMAT_YUV411 = 0x31315559,
  64.     WL_DRM_FORMAT_YVU411 = 0x31315659,
  65.     WL_DRM_FORMAT_YUV420 = 0x32315559,
  66.     WL_DRM_FORMAT_YVU420 = 0x32315659,
  67.     WL_DRM_FORMAT_YUV422 = 0x36315559,
  68.     WL_DRM_FORMAT_YVU422 = 0x36315659,
  69.     WL_DRM_FORMAT_YUV444 = 0x34325559,
  70.     WL_DRM_FORMAT_YVU444 = 0x34325659,
  71. };
  72.  
  73. struct bitmap
  74. {
  75.     uint32_t    width;
  76.     uint32_t    height;
  77.     uint32_t    pitch;
  78.     void       *buffer;
  79.     GLuint      tex;
  80.     GLuint      handle;
  81.     GLuint      name;
  82.     EGLImageKHR image;
  83. };
  84.  
  85. struct planar
  86. {
  87.     uint32_t    width;
  88.     uint32_t    height;
  89.     GLuint      name;
  90.     int         num_planes;
  91.     EGLImageKHR planar_image;
  92.     EGLImageKHR image[3];
  93.     GLuint      offset[3];
  94.     GLuint      pitch[3];
  95.     GLuint      tex[3];
  96. };
  97.  
  98. enum
  99. {
  100.     TEX_SCREEN = 0,
  101.     TEX_MASK   = 1
  102. };
  103.  
  104. struct shader
  105. {
  106.     GLuint blit_prog;
  107.     GLint sampler0;             /* rgba or y texture */
  108.     GLint sampler1;             /* u or uv   texture */
  109.     GLint sampler2;             /* v texture         */
  110.     GLint sm_mask;              /* alpha texture     */
  111. };
  112.  
  113. struct render
  114. {
  115.     int fd;
  116.     EGLDisplay dpy;
  117.     EGLContext context;
  118.     EGLint dx;
  119.     EGLint dy;
  120.     EGLint width;
  121.     EGLint height;
  122.     EGLint scr_width;
  123.     EGLint scr_height;
  124.     GLuint texture[2];
  125.     GLuint framebuffer;
  126.     EGLImageKHR screen;
  127.     struct bitmap mask;
  128.  
  129.     int    mask_size;
  130.     struct shader shader_rgba;
  131.     struct shader shader_y_uv;
  132.  
  133.     float vertices[8],tc_src[8];
  134. };
  135.  
  136. int egl_initialize(EGLDisplay *dpy, EGLConfig *config, EGLContext *context);
  137. void egl_destroy(EGLDisplay dpy, EGLContext context);
  138.  
  139. #define ENTER()   printf("enter %s\n",__FUNCTION__)
  140. #define LEAVE()   printf("leave %s\n",__FUNCTION__)
  141. #define FAIL()    printf("fail %s\n",__FUNCTION__)
  142.  
  143. #ifdef DEBUG
  144. #define DBG(...) do {                   \
  145.     fprintf(stderr, __VA_ARGS__);       \
  146. } while (0)
  147. #else
  148. #define DBG(...)
  149. #endif
  150.  
  151. #endif  /* __GL_RENDER_H__ */
  152.