-
Notifications
You must be signed in to change notification settings - Fork 386
/
Copy pathgdkandroidglcontext.c
135 lines (112 loc) · 4.49 KB
/
gdkandroidglcontext.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Copyright (c) 2024-2025 Marvin Wissfeld
* Copyright (c) 2025 Florian "sp1rit" <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "config.h"
#include "gdkglcontextprivate.h"
#include "gdkdisplayprivate.h"
#include "gdkandroid.h"
#include "gdkandroidinit-private.h"
#include "gdkandroidsurface-private.h"
#include "gdkandroiddnd-private.h"
#include "gdkandroidglcontext-private.h"
#include <epoxy/egl.h>
struct _GdkAndroidGLContext
{
GdkGLContext parent_instance;
};
struct _GdkAndroidGLContextClass
{
GdkGLContextClass parent_class;
};
G_DEFINE_TYPE (GdkAndroidGLContext, gdk_android_gl_context, GDK_TYPE_GL_CONTEXT)
static void
gdk_android_gl_context_begin_frame (GdkDrawContext *draw_context,
gpointer context_data,
GdkMemoryDepth depth,
cairo_region_t *region,
GdkColorState **out_color_state,
GdkMemoryDepth *out_depth)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
g_return_if_fail (GDK_IS_ANDROID_DRAG_SURFACE (surface) == FALSE);
GDK_DRAW_CONTEXT_CLASS (gdk_android_gl_context_parent_class)->begin_frame (draw_context, context_data, depth, region, out_color_state, out_depth);
}
static void
gdk_android_gl_context_end_frame (GdkDrawContext *draw_context,
gpointer context_data,
cairo_region_t *painted)
{
GdkSurface *surface = gdk_draw_context_get_surface (draw_context);
g_return_if_fail (GDK_IS_ANDROID_DRAG_SURFACE (surface) == FALSE);
GDK_DRAW_CONTEXT_CLASS (gdk_android_gl_context_parent_class)->end_frame (draw_context, context_data, painted);
}
static void
gdk_android_gl_context_empty_frame (GdkDrawContext *draw_context)
{}
static GLuint
gdk_android_gl_context_get_default_framebuffer (GdkGLContext *gl_context)
{
GdkSurface *surface = gdk_gl_context_get_surface (gl_context);
g_return_val_if_fail (GDK_IS_ANDROID_DRAG_SURFACE (surface) == FALSE, 0);
return GDK_GL_CONTEXT_CLASS (gdk_android_gl_context_parent_class)->get_default_framebuffer (gl_context);
}
static GdkGLAPI
gdk_android_gl_context_realize (GdkGLContext *gl_context,
GError **error)
{
GdkSurface *surface = gdk_gl_context_get_surface (gl_context);
if (GDK_IS_ANDROID_DRAG_SURFACE (surface))
{
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE,
"%s does currently not support OpenGL", G_OBJECT_TYPE_NAME (surface));
return 0;
}
return GDK_GL_CONTEXT_CLASS (gdk_android_gl_context_parent_class)->realize (gl_context, error);
}
static void
gdk_android_gl_context_class_init (GdkAndroidGLContextClass *class)
{
GdkDrawContextClass *draw_context_class = GDK_DRAW_CONTEXT_CLASS (class);
GdkGLContextClass *gl_context_class = GDK_GL_CONTEXT_CLASS (class);
draw_context_class->begin_frame = gdk_android_gl_context_begin_frame;
draw_context_class->end_frame = gdk_android_gl_context_end_frame;
draw_context_class->empty_frame = gdk_android_gl_context_empty_frame;
gl_context_class->backend_type = GDK_GL_EGL;
gl_context_class->get_default_framebuffer = gdk_android_gl_context_get_default_framebuffer;
gl_context_class->realize = gdk_android_gl_context_realize;
}
static void
gdk_android_gl_context_init (GdkAndroidGLContext *self)
{}
/**
* gdk_android_display_get_egl_display:
* @display: (transfer none): the display
*
* Retrieves the EGL display connection object for the given GDK display.
*
* Returns: (nullable): the EGL display
*
* Since: 4.18
*/
gpointer
gdk_android_display_get_egl_display (GdkAndroidDisplay *display)
{
g_return_val_if_fail (GDK_IS_ANDROID_DISPLAY (display), NULL);
return gdk_display_get_egl_display ((GdkDisplay *)display);
}