* @}
*/
+static void vigs_gl_backend_batch_start(struct vigs_backend *backend)
+{
+ struct vigs_gl_backend *gl_backend = (struct vigs_gl_backend*)backend;
+
+ if (!gl_backend->make_current(gl_backend, true)) {
+ VIGS_LOG_CRITICAL("make_current failed");
+ }
+}
+
/*
* vigs_gl_surface.
* @{
VIGS_LOG_TRACE("x = %u, y = %u, width = %u, height = %u",
x, y, width, height);
- if (!gl_backend->make_current(gl_backend, true)) {
- return;
- }
-
if (!ws_sfc->tex) {
VIGS_LOG_TRACE("skipping blank read");
goto out;
out:
gl_backend->BindFramebuffer(GL_FRAMEBUFFER, 0);
-
- gl_backend->make_current(gl_backend, false);
}
static void vigs_gl_surface_draw_pixels(struct vigs_surface *sfc,
struct vigs_winsys_gl_surface *ws_sfc = get_ws_sfc(gl_sfc);
uint32_t i;
- if (!gl_backend->make_current(gl_backend, true)) {
- return;
- }
-
if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
goto out;
}
pixels);
}
- gl_backend->Finish();
-
out:
gl_backend->BindFramebuffer(GL_FRAMEBUFFER, 0);
-
- gl_backend->make_current(gl_backend, false);
}
static void vigs_gl_surface_copy(struct vigs_surface *dst,
GLfloat *vert_coords;
GLfloat *tex_coords;
- if (!gl_backend->make_current(gl_backend, true)) {
- return;
- }
-
if (!vigs_winsys_gl_surface_create_texture(ws_dst, &ws_dst->tex)) {
goto out;
}
gl_backend->DisableClientState(GL_TEXTURE_COORD_ARRAY);
gl_backend->DisableClientState(GL_VERTEX_ARRAY);
- gl_backend->Finish();
-
out:
gl_backend->BindFramebuffer(GL_FRAMEBUFFER, 0);
-
- gl_backend->make_current(gl_backend, false);
}
static void vigs_gl_surface_solid_fill(struct vigs_surface *sfc,
GLubyte red, green, blue, alpha;
GLfloat sfc_h;
- if (!gl_backend->make_current(gl_backend, true)) {
- return;
- }
-
if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
goto out;
}
gl_backend->DisableClientState(GL_VERTEX_ARRAY);
- gl_backend->Finish();
-
out:
gl_backend->BindFramebuffer(GL_FRAMEBUFFER, 0);
-
- gl_backend->make_current(gl_backend, false);
}
static void vigs_gl_surface_destroy(struct vigs_surface *sfc)
vigs_winsys_gl_surface_orphan(ws_sfc);
- if (gl_backend->make_current(gl_backend, true)) {
- if (gl_sfc->fb) {
- gl_backend->DeleteFramebuffers(1, &gl_sfc->fb);
- }
- if (gl_sfc->tmp_tex) {
- gl_backend->DeleteTextures(1, &gl_sfc->tmp_tex);
- }
-
- gl_backend->make_current(gl_backend, false);
+ if (gl_sfc->fb) {
+ gl_backend->DeleteFramebuffers(1, &gl_sfc->fb);
+ }
+ if (gl_sfc->tmp_tex) {
+ gl_backend->DeleteTextures(1, &gl_sfc->tmp_tex);
}
vigs_surface_cleanup(&gl_sfc->base);
return NULL;
}
+static void vigs_gl_backend_batch_end(struct vigs_backend *backend)
+{
+ struct vigs_gl_backend *gl_backend = (struct vigs_gl_backend*)backend;
+
+ gl_backend->Finish();
+ gl_backend->make_current(gl_backend, false);
+}
+
bool vigs_gl_backend_init(struct vigs_gl_backend *gl_backend)
{
const char *extensions;
* @}
*/
+ gl_backend->base.batch_start = &vigs_gl_backend_batch_start;
gl_backend->base.create_surface = &vigs_gl_backend_create_surface;
+ gl_backend->base.batch_end = &vigs_gl_backend_batch_end;
gl_backend->make_current(gl_backend, false);
return res->ws_sfc;
}
+static void vigs_server_end_batch(struct vigs_server *server)
+{
+ if (server->in_batch) {
+ server->backend->batch_end(server->backend);
+
+ server->in_batch = false;
+ }
+}
+
static void vigs_server_dispatch_batch_start(void *user_data)
{
+ struct vigs_server *server = user_data;
+
+ server->in_batch = false;
+
+ if (server->initialized) {
+ server->backend->batch_start(server->backend);
+
+ server->in_batch = true;
+ }
}
static bool vigs_server_dispatch_init(void *user_data)
return;
}
+ vigs_server_end_batch(server);
+
vigs_server_reset(server);
}
static void vigs_server_dispatch_batch_end(void *user_data)
{
+ struct vigs_server *server = user_data;
+
+ vigs_server_end_batch(server);
}
static struct vigs_comm_ops vigs_server_dispatch_ops =
GHashTableIter iter;
gpointer key, value;
+ server->backend->batch_start(server->backend);
+
g_hash_table_iter_init(&iter, server->surfaces);
while (g_hash_table_iter_next(&iter, &key, &value)) {
struct vigs_surface *sfc = value;
g_hash_table_iter_remove(&iter);
}
+ server->backend->batch_end(server->backend);
+
server->root_sfc = NULL;
server->root_sfc_data = NULL;
}
if (root_sfc->is_dirty) {
+ server->backend->batch_start(server->backend);
root_sfc->read_pixels(root_sfc,
0,
0,
root_sfc->ws_sfc->width,
root_sfc->ws_sfc->height,
sfc_data);
+ server->backend->batch_end(server->backend);
root_sfc->is_dirty = false;
}