1 /* 2 * Cogl 3 * 4 * A Low Level GPU Graphics and Utilities API 5 * 6 * Copyright (C) 2007,2008,2009 Intel Corporation. 7 * 8 * Permission is hereby granted, free of charge, to any person 9 * obtaining a copy of this software and associated documentation 10 * files (the "Software"), to deal in the Software without 11 * restriction, including without limitation the rights to use, copy, 12 * modify, merge, publish, distribute, sublicense, and/or sell copies 13 * of the Software, and to permit persons to whom the Software is 14 * furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be 17 * included in all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 23 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 24 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 * SOFTWARE. 27 * 28 * 29 */ 30 31 #ifndef __COGL_WINSYS_PRIVATE_H 32 #define __COGL_WINSYS_PRIVATE_H 33 34 #include "cogl-renderer.h" 35 #include "cogl-onscreen.h" 36 #include "cogl-gles2.h" 37 38 #ifdef COGL_HAS_XLIB_SUPPORT 39 #include "cogl-texture-pixmap-x11-private.h" 40 #endif 41 42 #ifdef COGL_HAS_XLIB_SUPPORT 43 #include <X11/Xutil.h> 44 #include "cogl-texture-pixmap-x11-private.h" 45 #endif 46 47 #ifdef COGL_HAS_EGL_SUPPORT 48 #include "cogl-egl-private.h" 49 #endif 50 51 #include "cogl-poll.h" 52 53 uint32_t 54 _cogl_winsys_error_quark (void); 55 56 #define COGL_WINSYS_ERROR (_cogl_winsys_error_quark ()) 57 58 typedef enum { /*< prefix=COGL_WINSYS_ERROR >*/ 59 COGL_WINSYS_ERROR_INIT, 60 COGL_WINSYS_ERROR_CREATE_CONTEXT, 61 COGL_WINSYS_ERROR_CREATE_ONSCREEN, 62 COGL_WINSYS_ERROR_MAKE_CURRENT, 63 COGL_WINSYS_ERROR_CREATE_GLES2_CONTEXT, 64 } CoglWinsysError; 65 66 typedef enum 67 { 68 COGL_WINSYS_RECTANGLE_STATE_UNKNOWN, 69 COGL_WINSYS_RECTANGLE_STATE_DISABLE, 70 COGL_WINSYS_RECTANGLE_STATE_ENABLE 71 } CoglWinsysRectangleState; 72 73 typedef struct _CoglWinsysVtable 74 { 75 CoglWinsysID id; 76 CoglRendererConstraint constraints; 77 78 const char *name; 79 80 /* Required functions */ 81 82 CoglFuncPtr 83 (*renderer_get_proc_address) (CoglRenderer *renderer, 84 const char *name, 85 CoglBool in_core); 86 87 CoglBool 88 (*renderer_connect) (CoglRenderer *renderer, CoglError **error); 89 90 void 91 (*renderer_disconnect) (CoglRenderer *renderer); 92 93 void 94 (*renderer_outputs_changed) (CoglRenderer *renderer); 95 96 CoglBool 97 (*display_setup) (CoglDisplay *display, CoglError **error); 98 99 void 100 (*display_destroy) (CoglDisplay *display); 101 102 CoglBool 103 (*context_init) (CoglContext *context, CoglError **error); 104 105 void 106 (*context_deinit) (CoglContext *context); 107 108 void * 109 (*context_create_gles2_context) (CoglContext *ctx, CoglError **error); 110 111 CoglBool 112 (*onscreen_init) (CoglOnscreen *onscreen, CoglError **error); 113 114 void 115 (*onscreen_deinit) (CoglOnscreen *onscreen); 116 117 void 118 (*onscreen_bind) (CoglOnscreen *onscreen); 119 120 void 121 (*onscreen_swap_buffers_with_damage) (CoglOnscreen *onscreen, 122 const int *rectangles, 123 int n_rectangles); 124 125 void 126 (*onscreen_update_swap_throttled) (CoglOnscreen *onscreen); 127 128 void 129 (*onscreen_set_visibility) (CoglOnscreen *onscreen, 130 CoglBool visibility); 131 132 /* Optional functions */ 133 134 int64_t 135 (*context_get_clock_time) (CoglContext *context); 136 137 void 138 (*onscreen_swap_region) (CoglOnscreen *onscreen, 139 const int *rectangles, 140 int n_rectangles); 141 142 void 143 (*onscreen_set_resizable) (CoglOnscreen *onscreen, CoglBool resizable); 144 145 int 146 (*onscreen_get_buffer_age) (CoglOnscreen *onscreen); 147 148 uint32_t 149 (*onscreen_x11_get_window_xid) (CoglOnscreen *onscreen); 150 151 #ifdef COGL_HAS_WIN32_SUPPORT 152 HWND 153 (*onscreen_win32_get_window) (CoglOnscreen *onscreen); 154 #endif 155 156 #ifdef COGL_HAS_XLIB_SUPPORT 157 CoglBool 158 (*texture_pixmap_x11_create) (CoglTexturePixmapX11 *tex_pixmap); 159 void 160 (*texture_pixmap_x11_free) (CoglTexturePixmapX11 *tex_pixmap); 161 162 CoglBool 163 (*texture_pixmap_x11_update) (CoglTexturePixmapX11 *tex_pixmap, 164 CoglTexturePixmapStereoMode stereo_mode, 165 CoglBool needs_mipmap); 166 167 void 168 (*texture_pixmap_x11_damage_notify) (CoglTexturePixmapX11 *tex_pixmap); 169 170 CoglTexture * 171 (*texture_pixmap_x11_get_texture) (CoglTexturePixmapX11 *tex_pixmap, 172 CoglTexturePixmapStereoMode stereo_mode); 173 #endif 174 175 void 176 (*save_context) (CoglContext *ctx); 177 178 CoglBool 179 (*set_gles2_context) (CoglGLES2Context *gles2_ctx, CoglError **error); 180 181 void 182 (*restore_context) (CoglContext *ctx); 183 184 void 185 (*destroy_gles2_context) (CoglGLES2Context *gles2_ctx); 186 187 void * 188 (*fence_add) (CoglContext *ctx); 189 190 CoglBool 191 (*fence_is_complete) (CoglContext *ctx, void *fence); 192 193 void 194 (*fence_destroy) (CoglContext *ctx, void *fence); 195 196 } CoglWinsysVtable; 197 198 CoglBool 199 _cogl_winsys_has_feature (CoglWinsysFeature feature); 200 201 #endif /* __COGL_WINSYS_PRIVATE_H */ 202