1 /* GDK - The GIMP Drawing Kit 2 * 3 * gdkglcontextprivate.h: GL context abstraction 4 * 5 * Copyright © 2014 Emmanuele Bassi 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public 18 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __GDK_GL_CONTEXT_PRIVATE_H__ 22 #define __GDK_GL_CONTEXT_PRIVATE_H__ 23 24 #include "gdkglcontext.h" 25 26 G_BEGIN_DECLS 27 28 #define GDK_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_GL_CONTEXT, GdkGLContextClass)) 29 #define GDK_IS_GL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_GL_CONTEXT)) 30 #define GDK_GL_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_GL_CONTEXT, GdkGLContextClass)) 31 32 typedef struct _GdkGLContextClass GdkGLContextClass; 33 34 struct _GdkGLContext 35 { 36 GObject parent_instance; 37 }; 38 39 struct _GdkGLContextClass 40 { 41 GObjectClass parent_class; 42 43 gboolean (* realize) (GdkGLContext *context, 44 GError **error); 45 46 void (* end_frame) (GdkGLContext *context, 47 cairo_region_t *painted, 48 cairo_region_t *damage); 49 gboolean (* texture_from_surface) (GdkGLContext *context, 50 cairo_surface_t *surface, 51 cairo_region_t *region); 52 }; 53 54 typedef struct { 55 guint program; 56 guint position_location; 57 guint uv_location; 58 guint map_location; 59 guint flip_location; 60 } GdkGLContextProgram; 61 62 typedef struct { 63 guint vertex_array_object; 64 guint tmp_framebuffer; 65 guint tmp_vertex_buffer; 66 67 GdkGLContextProgram texture_2d_quad_program; 68 GdkGLContextProgram texture_rect_quad_program; 69 70 GdkGLContextProgram *current_program; 71 72 guint is_legacy : 1; 73 guint use_es : 1; 74 } GdkGLContextPaintData; 75 76 void gdk_gl_context_set_is_legacy (GdkGLContext *context, 77 gboolean is_legacy); 78 79 void gdk_gl_context_upload_texture (GdkGLContext *context, 80 cairo_surface_t *image_surface, 81 int width, 82 int height, 83 guint texture_target); 84 GdkGLContextPaintData * gdk_gl_context_get_paint_data (GdkGLContext *context); 85 gboolean gdk_gl_context_use_texture_rectangle (GdkGLContext *context); 86 gboolean gdk_gl_context_has_framebuffer_blit (GdkGLContext *context); 87 gboolean gdk_gl_context_has_frame_terminator (GdkGLContext *context); 88 gboolean gdk_gl_context_has_unpack_subimage (GdkGLContext *context); 89 void gdk_gl_context_end_frame (GdkGLContext *context, 90 cairo_region_t *painted, 91 cairo_region_t *damage); 92 93 G_END_DECLS 94 95 #endif /* __GDK_GL_CONTEXT_PRIVATE_H__ */ 96