aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/canvas/evas_gl.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/evas/src/lib/canvas/evas_gl.c245
1 files changed, 245 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/canvas/evas_gl.c b/libraries/evas/src/lib/canvas/evas_gl.c
new file mode 100644
index 0000000..47bb583
--- /dev/null
+++ b/libraries/evas/src/lib/canvas/evas_gl.c
@@ -0,0 +1,245 @@
1/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
2#include "evas_common.h"
3#include "evas_private.h"
4#include "Evas_GL.h"
5
6struct _Evas_GL
7{
8 DATA32 magic;
9 Evas *evas;
10
11 Eina_List *contexts;
12 Eina_List *surfaces;
13};
14
15struct _Evas_GL_Context
16{
17 void *data;
18};
19
20struct _Evas_GL_Surface
21{
22 void *data;
23};
24
25EAPI Evas_GL *
26evas_gl_new(Evas *e)
27{
28 Evas_GL *evas_gl;
29
30 MAGIC_CHECK(e, Evas, MAGIC_EVAS);
31 return NULL;
32 MAGIC_CHECK_END();
33
34 evas_gl = calloc(1, sizeof(Evas_GL));
35 if (!evas_gl) return NULL;
36
37 evas_gl->magic = MAGIC_EVAS_GL;
38 evas_gl->evas = e;
39
40 return evas_gl;
41}
42
43EAPI void
44evas_gl_free(Evas_GL *evas_gl)
45{
46 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
47 return;
48 MAGIC_CHECK_END();
49
50
51 // Delete undeleted surfaces
52 while (evas_gl->surfaces)
53 evas_gl_surface_destroy(evas_gl, evas_gl->surfaces->data);
54
55 // Delete undeleted contexts
56 while (evas_gl->contexts)
57 evas_gl_context_destroy(evas_gl, evas_gl->contexts->data);
58
59 evas_gl->magic = 0;
60 free(evas_gl);
61}
62
63EAPI Evas_GL_Surface *
64evas_gl_surface_create(Evas_GL *evas_gl, Evas_GL_Config *config, int width, int height)
65{
66 Evas_GL_Surface *surf;
67
68 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
69 return NULL;
70 MAGIC_CHECK_END();
71
72 if (!config)
73 {
74 ERR("Invalid Config\n");
75 return NULL;
76 }
77
78 surf = calloc(1, sizeof(Evas_GL_Surface));
79
80 surf->data = evas_gl->evas->engine.func->gl_surface_create(evas_gl->evas->engine.data.output, config, width, height);
81
82 if (!surf->data)
83 {
84 ERR("Failed creating a surface from the engine\n");
85 free(surf);
86 return NULL;
87 }
88
89 // Keep track of the surface creations
90 evas_gl->surfaces = eina_list_prepend(evas_gl->surfaces, surf);
91
92 return surf;
93}
94
95EAPI void
96evas_gl_surface_destroy(Evas_GL *evas_gl, Evas_GL_Surface *surf)
97{
98 // Magic
99 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
100 return;
101 MAGIC_CHECK_END();
102
103 if (!surf)
104 {
105 ERR("Trying to destroy a NULL surface pointer!\n");
106 return;
107 }
108
109 // Call Engine's Surface Destroy
110 evas_gl->evas->engine.func->gl_surface_destroy(evas_gl->evas->engine.data.output, surf->data);
111
112 // Remove it from the list
113 evas_gl->surfaces = eina_list_remove(evas_gl->surfaces, surf);
114
115 // Delete the object
116 free(surf);
117 surf = NULL;
118}
119
120EAPI Evas_GL_Context *
121evas_gl_context_create(Evas_GL *evas_gl, Evas_GL_Context *share_ctx)
122{
123 Evas_GL_Context *ctx;
124
125 // Magic
126 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
127 return NULL;
128 MAGIC_CHECK_END();
129
130 // Allocate a context object
131 ctx = calloc(1, sizeof(Evas_GL_Context));
132 if (!ctx)
133 {
134 ERR("Unable to create a Evas_GL_Context object\n");
135 return NULL;
136 }
137
138 // Call engine->gl_create_context
139 if (share_ctx)
140 {
141 ctx->data = evas_gl->evas->engine.func->gl_context_create(evas_gl->evas->engine.data.output, share_ctx->data);
142 }
143 else
144 {
145 ctx->data = evas_gl->evas->engine.func->gl_context_create(evas_gl->evas->engine.data.output, NULL);
146 }
147
148 // Set a few variables
149 if (!ctx->data)
150 {
151 ERR("Failed creating a context from the engine\n");
152 free(ctx);
153 return NULL;
154 }
155
156 // Keep track of the context creations
157 evas_gl->contexts = eina_list_prepend(evas_gl->contexts, ctx);
158
159 return ctx;
160
161}
162
163EAPI void
164evas_gl_context_destroy(Evas_GL *evas_gl, Evas_GL_Context *ctx)
165{
166
167 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
168 return;
169 MAGIC_CHECK_END();
170
171 if (!ctx)
172 {
173 ERR("Trying to destroy a NULL context pointer!\n");
174 return;
175 }
176
177 // Call Engine's destroy
178 evas_gl->evas->engine.func->gl_context_destroy(evas_gl->evas->engine.data.output, ctx->data);
179
180 // Remove it from the list
181 evas_gl->contexts = eina_list_remove(evas_gl->contexts, ctx);
182
183 // Delete the object
184 free(ctx);
185 ctx = NULL;
186}
187
188EAPI Eina_Bool
189evas_gl_make_current(Evas_GL *evas_gl, Evas_GL_Surface *surf, Evas_GL_Context *ctx)
190{
191 Eina_Bool ret;
192
193 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
194 return EINA_FALSE;
195 MAGIC_CHECK_END();
196
197 if ((!surf) || (!ctx))
198 ret = (Eina_Bool)evas_gl->evas->engine.func->gl_make_current(evas_gl->evas->engine.data.output, NULL, NULL);
199 else
200 ret = (Eina_Bool)evas_gl->evas->engine.func->gl_make_current(evas_gl->evas->engine.data.output, surf->data, ctx->data);
201
202 return ret;
203}
204
205EAPI const char *
206evas_gl_string_query(Evas_GL *evas_gl, int name)
207{
208 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
209 return EINA_FALSE;
210 MAGIC_CHECK_END();
211
212 return (const char *)evas_gl->evas->engine.func->gl_string_query(evas_gl->evas->engine.data.output, name);
213}
214
215EAPI Evas_GL_Func
216evas_gl_proc_address_get(Evas_GL *evas_gl, const char *name)
217{
218 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
219 return EINA_FALSE;
220 MAGIC_CHECK_END();
221
222 return (Evas_GL_Func)evas_gl->evas->engine.func->gl_proc_address_get(evas_gl->evas->engine.data.output, name);
223}
224
225EAPI Eina_Bool
226evas_gl_native_surface_get(Evas_GL *evas_gl, Evas_GL_Surface *surf, Evas_Native_Surface *ns)
227{
228 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
229 return EINA_FALSE;
230 MAGIC_CHECK_END();
231
232 return (Eina_Bool)evas_gl->evas->engine.func->gl_native_surface_get(evas_gl->evas->engine.data.output, surf->data, ns);
233}
234
235
236EAPI Evas_GL_API *
237evas_gl_api_get(Evas_GL *evas_gl)
238{
239 MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
240 return NULL;
241 MAGIC_CHECK_END();
242
243 return (Evas_GL_API*)evas_gl->evas->engine.func->gl_api_get(evas_gl->evas->engine.data.output);
244
245}