YaGL: We now use DRI2
authorStanislav Vorobiov <s.vorobiov@samsung.com>
Wed, 15 May 2013 08:58:01 +0000 (12:58 +0400)
committerStanislav Vorobiov <s.vorobiov@samsung.com>
Wed, 15 May 2013 08:58:01 +0000 (12:58 +0400)
DRI2 in its basic form is implemented and working for both 2D
and 3D rendering

22 files changed:
Makefile.target
hw/vigs_gl_backend.c
hw/winsys_gl.h
hw/yagl_api.h
hw/yagl_apis/egl/yagl_egl_calls.c
hw/yagl_apis/egl/yagl_host_egl_calls.c
hw/yagl_apis/egl/yagl_host_egl_calls.h
hw/yagl_apis/gles1/yagl_host_gles1_calls.c
hw/yagl_apis/gles2/yagl_host_gles2_calls.c
hw/yagl_backends/egl_offscreen/yagl_egl_offscreen.c
hw/yagl_backends/egl_offscreen/yagl_egl_offscreen_surface.c
hw/yagl_backends/egl_onscreen/yagl_egl_onscreen.c
hw/yagl_backends/egl_onscreen/yagl_egl_onscreen_display.c
hw/yagl_backends/egl_onscreen/yagl_egl_onscreen_image.c
hw/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.c
hw/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.h
hw/yagl_device.c
hw/yagl_egl_backend.h
hw/yagl_eglb_display.h
hw/yagl_eglb_surface.h
hw/yagl_thread.c
hw/yagl_version.h

index cec763f..137cca9 100755 (executable)
@@ -279,12 +279,12 @@ obj-y += yagl_egl_offscreen_context.o
 obj-y += yagl_egl_offscreen_surface.o
 obj-y += yagl_egl_offscreen_image.o
 # EGL onscreen backend
-#obj-y += yagl_egl_onscreen.o
-#obj-y += yagl_egl_onscreen_ts.o
-#obj-y += yagl_egl_onscreen_display.o
-#obj-y += yagl_egl_onscreen_context.o
-#obj-y += yagl_egl_onscreen_surface.o
-#obj-y += yagl_egl_onscreen_image.o
+obj-y += yagl_egl_onscreen.o
+obj-y += yagl_egl_onscreen_ts.o
+obj-y += yagl_egl_onscreen_display.o
+obj-y += yagl_egl_onscreen_context.o
+obj-y += yagl_egl_onscreen_surface.o
+obj-y += yagl_egl_onscreen_image.o
 # EGL GLX driver
 ifdef CONFIG_LINUX
 obj-y += yagl_egl_glx.o
@@ -300,11 +300,11 @@ obj-y += yagl_gles1_ogl.o
 # GLESv2 OpenGL driver
 obj-y += yagl_gles2_ogl.o
 # GLES onscreen common driver
-#obj-y += yagl_gles_onscreen.o
+obj-y += yagl_gles_onscreen.o
 # GLESv1_CM onscreen driver
-#obj-y += yagl_gles1_onscreen.o
+obj-y += yagl_gles1_onscreen.o
 # GLESv2 onscreen driver
-#obj-y += yagl_gles2_onscreen.o
+obj-y += yagl_gles2_onscreen.o
 
 endif
 
index 1b0d858..8607509 100644 (file)
@@ -35,20 +35,12 @@ struct vigs_winsys_gl_surface
      */
 
     /*
-     * Texture that represent this surface's front buffer.
+     * Texture that represent this surface.
      * Used as color attachment in 'fb'.
      *
      * Allocated on first access.
      */
-    GLuint front_tex;
-
-    /*
-     * Texture that represents this surface's back buffer, only used by
-     * winsys_gl clients. Switched with 'front_tex' on 'swap_buffers'.
-     *
-     * Allocated on first access.
-     */
-    GLuint back_tex;
+    GLuint tex;
 };
 
 struct vigs_gl_surface
@@ -207,44 +199,24 @@ static void vigs_winsys_gl_surface_release(struct winsys_surface *sfc)
     vigs_ref_release(&vigs_sfc->ref);
 }
 
-static GLuint vigs_winsys_gl_surface_get_front_texture(struct winsys_gl_surface *sfc)
-{
-    struct vigs_winsys_gl_surface *vigs_sfc = (struct vigs_winsys_gl_surface*)sfc;
-    bool has_current = vigs_sfc->backend->has_current(vigs_sfc->backend);
-
-    if (!vigs_sfc->front_tex &&
-        (has_current ||
-        vigs_sfc->backend->make_current(vigs_sfc->backend, true))) {
-
-        vigs_winsys_gl_surface_create_texture(vigs_sfc,
-                                              &vigs_sfc->front_tex);
-
-        if (!has_current) {
-            vigs_sfc->backend->make_current(vigs_sfc->backend, false);
-        }
-    }
-
-    return vigs_sfc->front_tex;
-}
-
-static GLuint vigs_winsys_gl_surface_get_back_texture(struct winsys_gl_surface *sfc)
+static GLuint vigs_winsys_gl_surface_get_texture(struct winsys_gl_surface *sfc)
 {
     struct vigs_winsys_gl_surface *vigs_sfc = (struct vigs_winsys_gl_surface*)sfc;
     bool has_current = vigs_sfc->backend->has_current(vigs_sfc->backend);
 
-    if (!vigs_sfc->back_tex &&
+    if (!vigs_sfc->tex &&
         (has_current ||
         vigs_sfc->backend->make_current(vigs_sfc->backend, true))) {
 
         vigs_winsys_gl_surface_create_texture(vigs_sfc,
-                                              &vigs_sfc->back_tex);
+                                              &vigs_sfc->tex);
 
         if (!has_current) {
             vigs_sfc->backend->make_current(vigs_sfc->backend, false);
         }
     }
 
-    return vigs_sfc->back_tex;
+    return vigs_sfc->tex;
 }
 
 static void vigs_winsys_gl_surface_destroy(struct vigs_ref *ref)
@@ -255,11 +227,8 @@ static void vigs_winsys_gl_surface_destroy(struct vigs_ref *ref)
 
     if (has_current ||
         vigs_sfc->backend->make_current(vigs_sfc->backend, true)) {
-        if (vigs_sfc->front_tex) {
-            vigs_sfc->backend->DeleteTextures(1, &vigs_sfc->front_tex);
-        }
-        if (vigs_sfc->back_tex) {
-            vigs_sfc->backend->DeleteTextures(1, &vigs_sfc->back_tex);
+        if (vigs_sfc->tex) {
+            vigs_sfc->backend->DeleteTextures(1, &vigs_sfc->tex);
         }
 
         if (!has_current) {
@@ -290,8 +259,7 @@ static struct vigs_winsys_gl_surface
     ws_sfc->base.base.height = height;
     ws_sfc->base.base.acquire = &vigs_winsys_gl_surface_acquire;
     ws_sfc->base.base.release = &vigs_winsys_gl_surface_release;
-    ws_sfc->base.get_front_texture = &vigs_winsys_gl_surface_get_front_texture;
-    ws_sfc->base.get_back_texture = &vigs_winsys_gl_surface_get_back_texture;
+    ws_sfc->base.get_texture = &vigs_winsys_gl_surface_get_texture;
     ws_sfc->tex_internalformat = tex_internalformat;
     ws_sfc->tex_format = tex_format;
     ws_sfc->tex_type = tex_type;
@@ -339,12 +307,12 @@ static void vigs_gl_surface_read_pixels(struct vigs_surface *sfc,
         return;
     }
 
-    if (!ws_sfc->front_tex) {
+    if (!ws_sfc->tex) {
         VIGS_LOG_TRACE("skipping blank read");
         goto out;
     }
 
-    if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->front_tex)) {
+    if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
         goto out;
     }
 
@@ -397,7 +365,7 @@ static void vigs_gl_surface_read_pixels(struct vigs_surface *sfc,
     gl_backend->EnableClientState(GL_VERTEX_ARRAY);
     gl_backend->EnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-    gl_backend->BindTexture(GL_TEXTURE_2D, ws_sfc->front_tex);
+    gl_backend->BindTexture(GL_TEXTURE_2D, ws_sfc->tex);
 
     gl_backend->Color4f(1.0f, 1.0f, 1.0f, 1.0f);
 
@@ -438,7 +406,7 @@ static void vigs_gl_surface_draw_pixels(struct vigs_surface *sfc,
         return;
     }
 
-    if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->front_tex)) {
+    if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
         goto out;
     }
 
@@ -453,7 +421,7 @@ static void vigs_gl_surface_draw_pixels(struct vigs_surface *sfc,
     gl_backend->Disable(GL_TEXTURE_2D);
 
     gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-                                     GL_TEXTURE_2D, ws_sfc->front_tex, 0);
+                                     GL_TEXTURE_2D, ws_sfc->tex, 0);
 
     gl_backend->PixelZoom(1.0f, -1.0f);
     gl_backend->RasterPos2f(x, ws_sfc->base.base.height - y);
@@ -491,15 +459,15 @@ static void vigs_gl_surface_copy(struct vigs_surface *dst,
         return;
     }
 
-    if (!vigs_winsys_gl_surface_create_texture(ws_dst, &ws_dst->front_tex)) {
+    if (!vigs_winsys_gl_surface_create_texture(ws_dst, &ws_dst->tex)) {
         goto out;
     }
 
-    if (!ws_src->front_tex) {
+    if (!ws_src->tex) {
         VIGS_LOG_WARN("copying garbage ???");
     }
 
-    if (!vigs_winsys_gl_surface_create_texture(ws_src, &ws_src->front_tex)) {
+    if (!vigs_winsys_gl_surface_create_texture(ws_src, &ws_src->tex)) {
         goto out;
     }
 
@@ -562,7 +530,7 @@ static void vigs_gl_surface_copy(struct vigs_surface *dst,
          */
 
         gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-                                         GL_TEXTURE_2D, ws_dst->front_tex, 0);
+                                         GL_TEXTURE_2D, ws_dst->tex, 0);
 
     }
 
@@ -594,7 +562,7 @@ static void vigs_gl_surface_copy(struct vigs_surface *dst,
     gl_backend->EnableClientState(GL_VERTEX_ARRAY);
     gl_backend->EnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-    gl_backend->BindTexture(GL_TEXTURE_2D, ws_src->front_tex);
+    gl_backend->BindTexture(GL_TEXTURE_2D, ws_src->tex);
 
     gl_backend->Color4f(1.0f, 1.0f, 1.0f, 1.0f);
 
@@ -631,7 +599,7 @@ static void vigs_gl_surface_copy(struct vigs_surface *dst,
         tex_coords[7] = 0;
 
         gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-                                         GL_TEXTURE_2D, ws_dst->front_tex, 0);
+                                         GL_TEXTURE_2D, ws_dst->tex, 0);
 
         gl_backend->BindTexture(GL_TEXTURE_2D, gl_dst->tmp_tex);
 
@@ -670,7 +638,7 @@ static void vigs_gl_surface_solid_fill(struct vigs_surface *sfc,
         return;
     }
 
-    if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->front_tex)) {
+    if (!vigs_winsys_gl_surface_create_texture(ws_sfc, &ws_sfc->tex)) {
         goto out;
     }
 
@@ -687,7 +655,7 @@ static void vigs_gl_surface_solid_fill(struct vigs_surface *sfc,
     gl_backend->Disable(GL_TEXTURE_2D);
 
     gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
-                                     GL_TEXTURE_2D, ws_sfc->front_tex, 0);
+                                     GL_TEXTURE_2D, ws_sfc->tex, 0);
 
     vigs_vector_resize(&gl_backend->v1, 0);
 
index 9174611..8428b26 100644 (file)
@@ -7,8 +7,7 @@ struct winsys_gl_surface
 {
     struct winsys_surface base;
 
-    GLuint (*get_front_texture)(struct winsys_gl_surface */*sfc*/);
-    GLuint (*get_back_texture)(struct winsys_gl_surface */*sfc*/);
+    GLuint (*get_texture)(struct winsys_gl_surface */*sfc*/);
 };
 
 struct winsys_gl_info
index bf6f01d..0d1e448 100644 (file)
@@ -14,8 +14,6 @@ struct yagl_api_ps
 
     void (*thread_init)(struct yagl_api_ps */*api_ps*/);
 
-    void (*pre_batch)(struct yagl_api_ps */*api_ps*/);
-
     yagl_api_func (*get_func)(struct yagl_api_ps */*api_ps*/,
                               uint32_t /*func_id*/);
 
index 46e4fa6..d91a418 100644 (file)
@@ -487,10 +487,9 @@ static bool yagl_func_eglCopyBuffers(uint8_t **out_buff,
 {
     yagl_host_handle dpy = yagl_marshal_get_host_handle(out_buff);
     yagl_host_handle surface = yagl_marshal_get_host_handle(out_buff);
-    yagl_winsys_id target = yagl_marshal_get_yagl_winsys_id(out_buff);
-    YAGL_LOG_FUNC_ENTER_SPLIT3(eglCopyBuffers, yagl_host_handle, yagl_host_handle, yagl_winsys_id, dpy, surface, target);
+    YAGL_LOG_FUNC_ENTER_SPLIT2(eglCopyBuffers, yagl_host_handle, yagl_host_handle, dpy, surface);
     EGLBoolean retval;
-    bool res = yagl_host_eglCopyBuffers(&retval, dpy, surface, target);
+    bool res = yagl_host_eglCopyBuffers(&retval, dpy, surface);
     if (!res) {
         YAGL_LOG_FUNC_EXIT(NULL);
         return false;
@@ -690,10 +689,11 @@ static bool yagl_func_eglCreatePbufferSurfaceOnscreenYAGL(uint8_t **out_buff,
 {
     yagl_host_handle dpy = yagl_marshal_get_host_handle(out_buff);
     yagl_host_handle config = yagl_marshal_get_host_handle(out_buff);
+    yagl_winsys_id buffer = yagl_marshal_get_yagl_winsys_id(out_buff);
     target_ulong attrib_list = yagl_marshal_get_ptr(out_buff);
-    YAGL_LOG_FUNC_ENTER_SPLIT3(eglCreatePbufferSurfaceOnscreenYAGL, yagl_host_handle, yagl_host_handle, target_ulong, dpy, config, attrib_list);
+    YAGL_LOG_FUNC_ENTER_SPLIT4(eglCreatePbufferSurfaceOnscreenYAGL, yagl_host_handle, yagl_host_handle, yagl_winsys_id, target_ulong, dpy, config, buffer, attrib_list);
     yagl_host_handle retval;
-    bool res = yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(&retval, dpy, config, attrib_list);
+    bool res = yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(&retval, dpy, config, buffer, attrib_list);
     if (!res) {
         YAGL_LOG_FUNC_EXIT(NULL);
         return false;
@@ -725,7 +725,22 @@ static bool yagl_func_eglCreatePixmapSurfaceOnscreenYAGL(uint8_t **out_buff,
     return true;
 }
 
-const uint32_t yagl_egl_api_num_funcs = 34;
+/*
+ * eglInvalidateOnscreenSurfaceYAGL dispatcher. id = 35
+ */
+static bool yagl_func_eglInvalidateOnscreenSurfaceYAGL(uint8_t **out_buff,
+    uint8_t *in_buff)
+{
+    yagl_host_handle dpy = yagl_marshal_get_host_handle(out_buff);
+    yagl_host_handle surface = yagl_marshal_get_host_handle(out_buff);
+    yagl_winsys_id buffer = yagl_marshal_get_yagl_winsys_id(out_buff);
+    YAGL_LOG_FUNC_ENTER_SPLIT3(eglInvalidateOnscreenSurfaceYAGL, yagl_host_handle, yagl_host_handle, yagl_winsys_id, dpy, surface, buffer);
+    bool res = yagl_host_eglInvalidateOnscreenSurfaceYAGL(dpy, surface, buffer);
+    YAGL_LOG_FUNC_EXIT(NULL);
+    return res;
+}
+
+const uint32_t yagl_egl_api_num_funcs = 35;
 
 yagl_api_func yagl_egl_api_funcs[] = {
     &yagl_func_eglGetError,
@@ -761,5 +776,6 @@ yagl_api_func yagl_egl_api_funcs[] = {
     &yagl_func_eglUpdateOffscreenImageYAGL,
     &yagl_func_eglCreateWindowSurfaceOnscreenYAGL,
     &yagl_func_eglCreatePbufferSurfaceOnscreenYAGL,
-    &yagl_func_eglCreatePixmapSurfaceOnscreenYAGL
+    &yagl_func_eglCreatePixmapSurfaceOnscreenYAGL,
+    &yagl_func_eglInvalidateOnscreenSurfaceYAGL
 };
index 98a9b50..66d1ce6 100644 (file)
@@ -236,13 +236,6 @@ static bool yagl_egl_release_current_context(struct yagl_egl_display *dpy)
     return true;
 }
 
-static void yagl_host_egl_pre_batch(struct yagl_api_ps *api_ps)
-{
-    struct yagl_egl_api_ps *egl_api_ps = (struct yagl_egl_api_ps*)api_ps;
-
-    egl_api_ps->backend->pre_batch(egl_api_ps->backend);
-}
-
 static yagl_api_func yagl_host_egl_get_func(struct yagl_api_ps *api_ps,
                                             uint32_t func_id)
 {
@@ -342,7 +335,6 @@ struct yagl_api_ps *yagl_host_egl_process_init(struct yagl_api *api)
     yagl_api_ps_init(&egl_api_ps->base, api);
 
     egl_api_ps->base.thread_init = &yagl_host_egl_thread_init;
-    egl_api_ps->base.pre_batch = &yagl_host_egl_pre_batch;
     egl_api_ps->base.get_func = &yagl_host_egl_get_func;
     egl_api_ps->base.thread_fini = &yagl_host_egl_thread_fini;
     egl_api_ps->base.fini = &yagl_host_egl_process_fini;
@@ -1552,8 +1544,7 @@ out:
 
 bool yagl_host_eglCopyBuffers(EGLBoolean* retval,
     yagl_host_handle dpy_,
-    yagl_host_handle surface_,
-    yagl_winsys_id target)
+    yagl_host_handle surface_)
 {
     struct yagl_egl_display *dpy = NULL;
     struct yagl_egl_surface *surface = NULL;
@@ -1582,7 +1573,7 @@ bool yagl_host_eglCopyBuffers(EGLBoolean* retval,
         goto out;
     }
 
-    if (!surface->backend_sfc->copy_buffers(surface->backend_sfc, target)) {
+    if (!surface->backend_sfc->copy_buffers(surface->backend_sfc)) {
         YAGL_SET_ERR(EGL_BAD_NATIVE_PIXMAP);
         goto out;
     }
@@ -2261,14 +2252,13 @@ out:
 bool yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(yagl_host_handle* retval,
     yagl_host_handle dpy_,
     yagl_host_handle config_,
+    yagl_winsys_id buffer,
     target_ulong /* const EGLint* */ attrib_list_)
 {
     bool res = true;
     EGLint *attrib_list = NULL;
     struct yagl_eglb_surface *backend_sfc = NULL;
     struct yagl_egl_pbuffer_attribs attribs;
-    uint32_t width = 0;
-    uint32_t height = 0;
     struct yagl_egl_display *dpy = NULL;
     struct yagl_egl_config *config = NULL;
     struct yagl_egl_surface *surface = NULL;
@@ -2322,10 +2312,7 @@ bool yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(yagl_host_handle* retval,
                 }
                 break;
             case EGL_HEIGHT:
-                height = attrib_list[i + 1];
-                break;
             case EGL_WIDTH:
-                width = attrib_list[i + 1];
                 break;
             default:
                 YAGL_SET_ERR(EGL_BAD_ATTRIBUTE);
@@ -2353,8 +2340,7 @@ bool yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(yagl_host_handle* retval,
     backend_sfc = dpy->backend_dpy->create_onscreen_pbuffer_surface(dpy->backend_dpy,
                                                                     &config->native,
                                                                     &attribs,
-                                                                    width,
-                                                                    height);
+                                                                    buffer);
 
     if (!backend_sfc) {
         YAGL_SET_ERR(EGL_BAD_ALLOC);
@@ -2473,3 +2459,26 @@ out:
 
     return res;
 }
+
+bool yagl_host_eglInvalidateOnscreenSurfaceYAGL(yagl_host_handle dpy_,
+    yagl_host_handle surface_,
+    yagl_winsys_id buffer)
+{
+    struct yagl_egl_display *dpy = NULL;
+    struct yagl_egl_surface *surface = NULL;
+
+    if (!yagl_validate_display(dpy_, &dpy)) {
+        goto out;
+    }
+
+    if (!yagl_validate_surface(dpy, surface_, &surface)) {
+        goto out;
+    }
+
+    surface->backend_sfc->invalidate(surface->backend_sfc, buffer);
+
+out:
+    yagl_egl_surface_release(surface);
+
+    return true;
+}
index 86966cf..7f57793 100644 (file)
@@ -88,8 +88,7 @@ bool yagl_host_eglSwapBuffers(EGLBoolean* retval,
     yagl_host_handle surface_);
 bool yagl_host_eglCopyBuffers(EGLBoolean* retval,
     yagl_host_handle dpy_,
-    yagl_host_handle surface_,
-    yagl_winsys_id target);
+    yagl_host_handle surface_);
 bool yagl_host_eglCreateImageKHR(yagl_host_handle* retval,
     yagl_host_handle dpy_,
     yagl_host_handle ctx,
@@ -144,11 +143,15 @@ bool yagl_host_eglCreateWindowSurfaceOnscreenYAGL(yagl_host_handle* retval,
 bool yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(yagl_host_handle* retval,
     yagl_host_handle dpy_,
     yagl_host_handle config_,
+    yagl_winsys_id buffer,
     target_ulong /* const EGLint* */ attrib_list_);
 bool yagl_host_eglCreatePixmapSurfaceOnscreenYAGL(yagl_host_handle* retval,
     yagl_host_handle dpy_,
     yagl_host_handle config_,
     yagl_winsys_id pixmap,
     target_ulong /* const EGLint* */ attrib_list_);
+bool yagl_host_eglInvalidateOnscreenSurfaceYAGL(yagl_host_handle dpy_,
+    yagl_host_handle surface_,
+    yagl_winsys_id buffer);
 
 #endif
index 8aa545e..5a77acc 100644 (file)
@@ -100,10 +100,6 @@ static void yagl_host_gles1_thread_init(struct yagl_api_ps *api_ps)
     YAGL_LOG_FUNC_EXIT(NULL);
 }
 
-static void yagl_host_gles1_pre_batch(struct yagl_api_ps *api_ps)
-{
-}
-
 static void yagl_host_gles1_thread_fini(struct yagl_api_ps *api_ps)
 {
     YAGL_LOG_FUNC_ENTER(yagl_host_gles1_thread_fini, NULL);
@@ -181,7 +177,6 @@ struct yagl_api_ps *yagl_host_gles1_process_init(struct yagl_api *api)
     yagl_api_ps_init(&gles1_api_ps->base, api);
 
     gles1_api_ps->base.thread_init = &yagl_host_gles1_thread_init;
-    gles1_api_ps->base.pre_batch = &yagl_host_gles1_pre_batch;
     gles1_api_ps->base.get_func = &yagl_host_gles1_get_func;
     gles1_api_ps->base.thread_fini = &yagl_host_gles1_thread_fini;
     gles1_api_ps->base.fini = &yagl_host_gles1_process_fini;
index d623dde..38d2015 100644 (file)
@@ -109,10 +109,6 @@ static struct yagl_client_image
     return image ? &image->base : NULL;
 }
 
-static void yagl_host_gles2_pre_batch(struct yagl_api_ps *api_ps)
-{
-}
-
 static yagl_api_func yagl_host_gles2_get_func(struct yagl_api_ps *api_ps,
                                               uint32_t func_id)
 {
@@ -198,7 +194,6 @@ struct yagl_api_ps *yagl_host_gles2_process_init(struct yagl_api *api)
     yagl_api_ps_init(&gles2_api_ps->base, api);
 
     gles2_api_ps->base.thread_init = &yagl_host_gles2_thread_init;
-    gles2_api_ps->base.pre_batch = &yagl_host_gles2_pre_batch;
     gles2_api_ps->base.get_func = &yagl_host_gles2_get_func;
     gles2_api_ps->base.thread_fini = &yagl_host_gles2_thread_fini;
     gles2_api_ps->base.fini = &yagl_host_gles2_process_fini;
index 02a15f1..15116c2 100644 (file)
@@ -18,10 +18,6 @@ static void yagl_egl_offscreen_thread_init(struct yagl_egl_backend *backend)
     YAGL_LOG_FUNC_EXIT(NULL);
 }
 
-static void yagl_egl_offscreen_pre_batch(struct yagl_egl_backend *backend)
-{
-}
-
 static struct yagl_eglb_display *yagl_egl_offscreen_create_display(struct yagl_egl_backend *backend)
 {
     struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend;
@@ -224,7 +220,6 @@ struct yagl_egl_backend *yagl_egl_offscreen_create(struct yagl_egl_driver *drive
     }
 
     egl_offscreen->base.thread_init = &yagl_egl_offscreen_thread_init;
-    egl_offscreen->base.pre_batch = &yagl_egl_offscreen_pre_batch;
     egl_offscreen->base.create_display = &yagl_egl_offscreen_create_display;
     egl_offscreen->base.make_current = &yagl_egl_offscreen_make_current;
     egl_offscreen->base.release_current = &yagl_egl_offscreen_release_current;
index e2cb0d7..f67d321 100644 (file)
@@ -49,6 +49,11 @@ static void yagl_egl_offscreen_surface_reset(struct yagl_eglb_surface *sfc)
     osfc->bimage_ct = NULL;
 }
 
+static void yagl_egl_offscreen_surface_invalidate(struct yagl_eglb_surface *sfc,
+                                                  yagl_winsys_id id)
+{
+}
+
 static void yagl_egl_offscreen_surface_replace(struct yagl_eglb_surface *sfc,
                                                struct yagl_eglb_surface *with)
 {
@@ -119,8 +124,7 @@ static bool yagl_egl_offscreen_surface_swap_buffers(struct yagl_eglb_surface *sf
     return true;
 }
 
-static bool yagl_egl_offscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc,
-                                                    yagl_winsys_id target)
+static bool yagl_egl_offscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc)
 {
     struct yagl_egl_offscreen_surface *osfc =
         (struct yagl_egl_offscreen_surface*)sfc;
@@ -237,6 +241,7 @@ struct yagl_egl_offscreen_surface
     memcpy(&sfc->native_sfc_attribs, &pbuffer_attribs, sizeof(pbuffer_attribs));
 
     sfc->base.reset = &yagl_egl_offscreen_surface_reset;
+    sfc->base.invalidate = &yagl_egl_offscreen_surface_invalidate;
     sfc->base.replace = &yagl_egl_offscreen_surface_replace;
     sfc->base.query = &yagl_egl_offscreen_surface_query;
     sfc->base.swap_buffers = &yagl_egl_offscreen_surface_swap_buffers;
index 097171d..8e15d9d 100644 (file)
@@ -45,19 +45,6 @@ static void yagl_egl_onscreen_thread_init(struct yagl_egl_backend *backend)
     YAGL_LOG_FUNC_EXIT(NULL);
 }
 
-static void yagl_egl_onscreen_pre_batch(struct yagl_egl_backend *backend)
-{
-    struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend;
-
-    if (!egl_onscreen_ts->dpy) {
-        return;
-    }
-
-    if (egl_onscreen_ts->sfc_draw->needs_update) {
-        yagl_egl_onscreen_setup_framebuffer_zero(egl_onscreen);
-    }
-}
-
 static struct yagl_eglb_display *yagl_egl_onscreen_create_display(struct yagl_egl_backend *backend)
 {
     struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend;
@@ -296,7 +283,6 @@ struct yagl_egl_backend *yagl_egl_onscreen_create(struct winsys_interface *wsi,
     }
 
     egl_onscreen->base.thread_init = &yagl_egl_onscreen_thread_init;
-    egl_onscreen->base.pre_batch = &yagl_egl_onscreen_pre_batch;
     egl_onscreen->base.create_display = &yagl_egl_onscreen_create_display;
     egl_onscreen->base.make_current = &yagl_egl_onscreen_make_current;
     egl_onscreen->base.release_current = &yagl_egl_onscreen_release_current;
index 398dccf..978cc2a 100644 (file)
@@ -108,8 +108,7 @@ static struct yagl_eglb_surface
     *yagl_egl_onscreen_display_create_pbuffer_surface(struct yagl_eglb_display *dpy,
                                                       const struct yagl_egl_native_config *cfg,
                                                       const struct yagl_egl_pbuffer_attribs *attribs,
-                                                      uint32_t width,
-                                                      uint32_t height)
+                                                      yagl_winsys_id id)
 {
     struct yagl_egl_onscreen_display *egl_onscreen_dpy =
         (struct yagl_egl_onscreen_display*)dpy;
@@ -117,8 +116,7 @@ static struct yagl_eglb_surface
         yagl_egl_onscreen_surface_create_pbuffer(egl_onscreen_dpy,
                                                  cfg,
                                                  attribs,
-                                                 width,
-                                                 height);
+                                                 id);
 
     return sfc ? &sfc->base : NULL;
 }
index bf53cbc..e29a46f 100644 (file)
@@ -48,7 +48,6 @@ struct yagl_egl_onscreen_image
 {
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)dpy->base.backend;
-    struct winsys_resource *ws_res = NULL;
     struct winsys_gl_surface *ws_sfc = NULL;
     struct yagl_client_interface *client_iface = NULL;
     struct yagl_egl_onscreen_image_data *image_data = NULL;
@@ -65,17 +64,7 @@ struct yagl_egl_onscreen_image
         goto out;
     }
 
-    ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, buffer);
-
-    if (!ws_res) {
-        goto out;
-    }
-
-    if (ws_res->type != winsys_res_type_pixmap) {
-        goto out;
-    }
-
-    ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
+    ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, buffer);
 
     if (!ws_sfc) {
         goto out;
@@ -86,7 +75,7 @@ struct yagl_egl_onscreen_image
     yagl_ref_init(&image_data->ref, &yagl_egl_onscreen_image_data_destroy);
 
     glegl_image = client_iface->create_image(client_iface,
-                                             ws_sfc->get_front_texture(ws_sfc),
+                                             ws_sfc->get_texture(ws_sfc),
                                              &image_data->ref);
 
     if (!glegl_image) {
@@ -110,10 +99,6 @@ out:
         ws_sfc->base.release(&ws_sfc->base);
     }
 
-    if (ws_res) {
-        ws_res->release(ws_res);
-    }
-
     YAGL_LOG_FUNC_EXIT(NULL);
 
     return image;
index a25ffa9..ae20504 100644 (file)
@@ -16,6 +16,49 @@ static void yagl_egl_onscreen_surface_reset(struct yagl_eglb_surface *sfc)
 {
 }
 
+static void yagl_egl_onscreen_surface_invalidate(struct yagl_eglb_surface *sfc,
+                                                 yagl_winsys_id id)
+{
+    struct yagl_egl_onscreen_surface *osfc =
+        (struct yagl_egl_onscreen_surface*)sfc;
+    struct yagl_egl_onscreen *egl_onscreen =
+        (struct yagl_egl_onscreen*)sfc->dpy->backend;
+    struct winsys_gl_surface *ws_sfc = NULL;
+
+    YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_invalidate, NULL);
+
+    ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
+
+    if (!ws_sfc) {
+        YAGL_LOG_WARN("winsys surface 0x%X not found", id);
+        YAGL_LOG_FUNC_EXIT(NULL);
+        return;
+    }
+
+    if (ws_sfc == osfc->ws_sfc) {
+        ws_sfc->base.release(&ws_sfc->base);
+        YAGL_LOG_FUNC_EXIT(NULL);
+        return;
+    }
+
+    YAGL_LOG_DEBUG("winsys surface changed to 0x%X", id);
+
+    if (osfc->rb) {
+        egl_onscreen->gles_driver->DeleteRenderbuffers(1, &osfc->rb);
+        osfc->rb = 0;
+    }
+
+    osfc->ws_sfc->base.release(&osfc->ws_sfc->base);
+    osfc->ws_sfc = ws_sfc;
+
+    if (egl_onscreen_ts->sfc_draw == osfc) {
+        yagl_egl_onscreen_surface_setup(osfc);
+        yagl_egl_onscreen_surface_attach_to_framebuffer(osfc);
+    }
+
+    YAGL_LOG_FUNC_EXIT(NULL);
+}
+
 static bool yagl_egl_onscreen_surface_query(struct yagl_eglb_surface *sfc,
                                              EGLint attribute,
                                              EGLint *value)
@@ -39,92 +82,22 @@ static bool yagl_egl_onscreen_surface_query(struct yagl_eglb_surface *sfc,
 
 static bool yagl_egl_onscreen_surface_swap_buffers(struct yagl_eglb_surface *sfc)
 {
-    struct yagl_egl_onscreen_surface *osfc =
-        (struct yagl_egl_onscreen_surface*)sfc;
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)sfc->dpy->backend;
-    GLuint cur_fb = 0;
-
-    egl_onscreen->gles_driver->GetIntegerv(GL_FRAMEBUFFER_BINDING,
-                                           (GLint*)&cur_fb);
 
-    egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER,
-                                               egl_onscreen_ts->ctx->fb);
-
-    osfc->ws_sfc->swap_buffers(osfc->ws_sfc);
-
-    egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER, cur_fb);
+    egl_onscreen->gles_driver->Finish();
 
     return true;
 }
 
-static bool yagl_egl_onscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc,
-                                                   yagl_winsys_id target)
+static bool yagl_egl_onscreen_surface_copy_buffers(struct yagl_eglb_surface *sfc)
 {
-    struct yagl_egl_onscreen_surface *osfc =
-        (struct yagl_egl_onscreen_surface*)sfc;
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)sfc->dpy->backend;
-    struct winsys_resource *ws_res = NULL;
-    struct winsys_gl_surface *ws_sfc = NULL;
-    GLuint cur_fb = 0;
-    bool res = false;
-
-    ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, target);
-
-    if (!ws_res) {
-        goto out;
-    }
-
-    if (ws_res->type != winsys_res_type_pixmap) {
-        goto out;
-    }
-
-    ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
-
-    if (!ws_sfc) {
-        goto out;
-    }
-
-    egl_onscreen->gles_driver->GetIntegerv(GL_FRAMEBUFFER_BINDING,
-                                           (GLint*)&cur_fb);
-
-    egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER,
-                                               egl_onscreen_ts->ctx->fb);
-
-    ws_sfc->copy_buffers(yagl_egl_onscreen_surface_width(osfc),
-                         yagl_egl_onscreen_surface_height(osfc),
-                         ws_sfc,
-                         (ws_sfc == osfc->ws_sfc));
-
-    egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER, cur_fb);
-
-    res = true;
-
-out:
-    if (ws_sfc) {
-        ws_sfc->base.release(&ws_sfc->base);
-    }
-
-    if (ws_res) {
-        ws_res->release(ws_res);
-    }
-
-    return res;
-}
-
-static void yagl_egl_onscreen_surface_update(struct winsys_resource *res,
-                                             void *user_data)
-{
-    struct yagl_egl_onscreen_surface *sfc = user_data;
-
-    YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_update,
-                        "id = 0x%X",
-                        res->id);
 
-    sfc->needs_update = true;
+    egl_onscreen->gles_driver->Finish();
 
-    YAGL_LOG_FUNC_EXIT(NULL);
+    return true;
 }
 
 static void yagl_egl_onscreen_surface_destroy(struct yagl_eglb_surface *sfc)
@@ -136,11 +109,6 @@ static void yagl_egl_onscreen_surface_destroy(struct yagl_eglb_surface *sfc)
 
     YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_destroy, NULL);
 
-    if (osfc->cookie) {
-        osfc->ws_res->remove_callback(osfc->ws_res, osfc->cookie);
-        osfc->cookie = NULL;
-    }
-
     egl_onscreen->egl_driver->pbuffer_surface_destroy(
         egl_onscreen->egl_driver,
         ((struct yagl_egl_onscreen_display*)sfc->dpy)->native_dpy,
@@ -152,14 +120,8 @@ static void yagl_egl_onscreen_surface_destroy(struct yagl_eglb_surface *sfc)
         osfc->ws_sfc = NULL;
     }
 
-    if (osfc->ws_res) {
-        osfc->ws_res->release(osfc->ws_res);
-        osfc->ws_res = NULL;
-    }
-
-    if (osfc->pbuffer_tex || osfc->rb) {
+    if (osfc->rb) {
         yagl_ensure_ctx();
-        egl_onscreen->gles_driver->DeleteTextures(1, &osfc->pbuffer_tex);
         egl_onscreen->gles_driver->DeleteRenderbuffers(1, &osfc->rb);
         yagl_unensure_ctx();
     }
@@ -179,7 +141,6 @@ struct yagl_egl_onscreen_surface
 {
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)dpy->base.backend;
-    struct winsys_resource *ws_res = NULL;
     struct winsys_gl_surface *ws_sfc = NULL;
     struct yagl_egl_onscreen_surface *sfc = NULL;
     EGLSurface dummy_native_sfc = EGL_NO_SURFACE;
@@ -191,17 +152,7 @@ struct yagl_egl_onscreen_surface
                         cfg->config_id,
                         id);
 
-    ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, id);
-
-    if (!ws_res) {
-        goto fail;
-    }
-
-    if (ws_res->type != winsys_res_type_window) {
-        goto fail;
-    }
-
-    ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
+    ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
 
     if (!ws_sfc) {
         goto fail;
@@ -225,7 +176,6 @@ struct yagl_egl_onscreen_surface
     yagl_eglb_surface_init(&sfc->base, &dpy->base, EGL_WINDOW_BIT, attribs);
 
     sfc->dummy_native_sfc = dummy_native_sfc;
-    sfc->ws_res = ws_res;
     sfc->ws_sfc = ws_sfc;
 
     sfc->base.reset = &yagl_egl_onscreen_surface_reset;
@@ -234,10 +184,6 @@ struct yagl_egl_onscreen_surface
     sfc->base.copy_buffers = &yagl_egl_onscreen_surface_copy_buffers;
     sfc->base.destroy = &yagl_egl_onscreen_surface_destroy;
 
-    sfc->cookie = ws_res->add_callback(ws_res,
-                                       &yagl_egl_onscreen_surface_update,
-                                       sfc);
-
     YAGL_LOG_FUNC_EXIT(NULL);
 
     return sfc;
@@ -247,10 +193,6 @@ fail:
         ws_sfc->base.release(&ws_sfc->base);
     }
 
-    if (ws_res) {
-        ws_res->release(ws_res);
-    }
-
     YAGL_LOG_FUNC_EXIT(NULL);
 
     return NULL;
@@ -264,7 +206,6 @@ struct yagl_egl_onscreen_surface
 {
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)dpy->base.backend;
-    struct winsys_resource *ws_res = NULL;
     struct winsys_gl_surface *ws_sfc = NULL;
     struct yagl_egl_onscreen_surface *sfc = NULL;
     EGLSurface dummy_native_sfc = EGL_NO_SURFACE;
@@ -276,17 +217,7 @@ struct yagl_egl_onscreen_surface
                         cfg->config_id,
                         id);
 
-    ws_res = egl_onscreen->wsi->acquire_resource(egl_onscreen->wsi, id);
-
-    if (!ws_res) {
-        goto fail;
-    }
-
-    if (ws_res->type != winsys_res_type_pixmap) {
-        goto fail;
-    }
-
-    ws_sfc = (struct winsys_gl_surface*)ws_res->acquire_surface(ws_res);
+    ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
 
     if (!ws_sfc) {
         goto fail;
@@ -310,7 +241,6 @@ struct yagl_egl_onscreen_surface
     yagl_eglb_surface_init(&sfc->base, &dpy->base, EGL_PIXMAP_BIT, attribs);
 
     sfc->dummy_native_sfc = dummy_native_sfc;
-    sfc->ws_res = ws_res;
     sfc->ws_sfc = ws_sfc;
 
     sfc->base.reset = &yagl_egl_onscreen_surface_reset;
@@ -328,10 +258,6 @@ fail:
         ws_sfc->base.release(&ws_sfc->base);
     }
 
-    if (ws_res) {
-        ws_res->release(ws_res);
-    }
-
     YAGL_LOG_FUNC_EXIT(NULL);
 
     return NULL;
@@ -341,21 +267,26 @@ struct yagl_egl_onscreen_surface
     *yagl_egl_onscreen_surface_create_pbuffer(struct yagl_egl_onscreen_display *dpy,
                                              const struct yagl_egl_native_config *cfg,
                                              const struct yagl_egl_pbuffer_attribs *attribs,
-                                             uint32_t width,
-                                             uint32_t height)
+                                             yagl_winsys_id id)
 {
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)dpy->base.backend;
+    struct winsys_gl_surface *ws_sfc = NULL;
     struct yagl_egl_onscreen_surface *sfc = NULL;
     EGLSurface dummy_native_sfc = EGL_NO_SURFACE;
     struct yagl_egl_pbuffer_attribs pbuffer_attribs;
 
     YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_create_pbuffer,
-                        "dpy = %p, cfg = %d, width = %u, height = %u",
+                        "dpy = %p, cfg = %d, id = 0x%X",
                         dpy,
                         cfg->config_id,
-                        width,
-                        height);
+                        id);
+
+    ws_sfc = (struct winsys_gl_surface*)egl_onscreen->wsi->acquire_surface(egl_onscreen->wsi, id);
+
+    if (!ws_sfc) {
+        goto fail;
+    }
 
     yagl_egl_pbuffer_attribs_init(&pbuffer_attribs);
 
@@ -375,10 +306,10 @@ struct yagl_egl_onscreen_surface
     yagl_eglb_surface_init(&sfc->base, &dpy->base, EGL_PBUFFER_BIT, attribs);
 
     sfc->dummy_native_sfc = dummy_native_sfc;
-    sfc->pbuffer_width = width;
-    sfc->pbuffer_height = height;
+    sfc->ws_sfc = ws_sfc;
 
     sfc->base.reset = &yagl_egl_onscreen_surface_reset;
+    sfc->base.invalidate = &yagl_egl_onscreen_surface_invalidate;
     sfc->base.query = &yagl_egl_onscreen_surface_query;
     sfc->base.swap_buffers = &yagl_egl_onscreen_surface_swap_buffers;
     sfc->base.copy_buffers = &yagl_egl_onscreen_surface_copy_buffers;
@@ -389,6 +320,10 @@ struct yagl_egl_onscreen_surface
     return sfc;
 
 fail:
+    if (ws_sfc) {
+        ws_sfc->base.release(&ws_sfc->base);
+    }
+
     YAGL_LOG_FUNC_EXIT(NULL);
 
     return NULL;
@@ -399,98 +334,24 @@ void yagl_egl_onscreen_surface_setup(struct yagl_egl_onscreen_surface *sfc)
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)sfc->base.dpy->backend;
     GLuint cur_rb = 0;
-    GLuint cur_tex = 0;
-
-    YAGL_LOG_FUNC_SET(yagl_egl_onscreen_surface_setup);
-
-    if (sfc->needs_update) {
-        struct winsys_gl_surface *ws_sfc = NULL;
-
-        ws_sfc = (struct winsys_gl_surface*)sfc->ws_res->acquire_surface(sfc->ws_res);
-
-        if (ws_sfc) {
-            if (ws_sfc != sfc->ws_sfc) {
-                YAGL_LOG_DEBUG("winsys resource was changed for 0x%X", sfc->ws_res->id);
-
-                if (sfc->rb) {
-                    egl_onscreen->gles_driver->DeleteRenderbuffers(1, &sfc->rb);
-                    sfc->rb = 0;
-                }
-
-                sfc->ws_sfc->base.release(&sfc->ws_sfc->base);
-                ws_sfc->base.acquire(&ws_sfc->base);
-                sfc->ws_sfc = ws_sfc;
-            }
-
-            ws_sfc->base.release(&ws_sfc->base);
-        } else {
-            YAGL_LOG_WARN("winsys resource was destroyed for 0x%X", sfc->ws_res->id);
-        }
 
-        sfc->needs_update = false;
+    if (sfc->rb) {
+        return;
     }
 
-    switch (sfc->base.type) {
-    case EGL_PBUFFER_BIT:
-        if (!sfc->rb) {
-            egl_onscreen->gles_driver->GenRenderbuffers(1, &sfc->rb);
-
-            egl_onscreen->gles_driver->GetIntegerv(GL_RENDERBUFFER_BINDING,
-                                                   (GLint*)&cur_rb);
-
-            egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, sfc->rb);
-
-            egl_onscreen->gles_driver->RenderbufferStorage(GL_RENDERBUFFER,
-                                                           GL_DEPTH24_STENCIL8,
-                                                           sfc->pbuffer_width,
-                                                           sfc->pbuffer_height);
-
-            egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, cur_rb);
-        }
-        if (!sfc->pbuffer_tex) {
-            egl_onscreen->gles_driver->GenTextures(1, &sfc->pbuffer_tex);
-
-            egl_onscreen->gles_driver->GetIntegerv(GL_TEXTURE_BINDING_2D,
-                                                   (GLint*)&cur_tex);
-
-            egl_onscreen->gles_driver->BindTexture(GL_TEXTURE_2D, sfc->pbuffer_tex);
-
-            /*
-             * TODO: Use pbuffer attribs to setup texture format
-             * correctly.
-             */
-
-            egl_onscreen->gles_driver->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
-                                                  sfc->pbuffer_width,
-                                                  sfc->pbuffer_height, 0,
-                                                  GL_BGRA, GL_UNSIGNED_INT,
-                                                  NULL);
+    egl_onscreen->gles_driver->GenRenderbuffers(1, &sfc->rb);
 
-            egl_onscreen->gles_driver->BindTexture(GL_TEXTURE_2D, cur_tex);
-        }
-        break;
-    case EGL_PIXMAP_BIT:
-    case EGL_WINDOW_BIT:
-        if (!sfc->rb) {
-            egl_onscreen->gles_driver->GenRenderbuffers(1, &sfc->rb);
-
-            egl_onscreen->gles_driver->GetIntegerv(GL_RENDERBUFFER_BINDING,
-                                                   (GLint*)&cur_rb);
+    egl_onscreen->gles_driver->GetIntegerv(GL_RENDERBUFFER_BINDING,
+                                           (GLint*)&cur_rb);
 
-            egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, sfc->rb);
+    egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, sfc->rb);
 
-            egl_onscreen->gles_driver->RenderbufferStorage(GL_RENDERBUFFER,
-                                                           GL_DEPTH24_STENCIL8,
-                                                           sfc->ws_sfc->base.width,
-                                                           sfc->ws_sfc->base.height);
+    egl_onscreen->gles_driver->RenderbufferStorage(GL_RENDERBUFFER,
+                                                   GL_DEPTH24_STENCIL8,
+                                                   sfc->ws_sfc->base.width,
+                                                   sfc->ws_sfc->base.height);
 
-            egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, cur_rb);
-        }
-        break;
-    default:
-        assert(false);
-        break;
-    }
+    egl_onscreen->gles_driver->BindRenderbuffer(GL_RENDERBUFFER, cur_rb);
 }
 
 void yagl_egl_onscreen_surface_attach_to_framebuffer(struct yagl_egl_onscreen_surface *sfc)
@@ -498,32 +359,11 @@ void yagl_egl_onscreen_surface_attach_to_framebuffer(struct yagl_egl_onscreen_su
     struct yagl_egl_onscreen *egl_onscreen =
         (struct yagl_egl_onscreen*)sfc->base.dpy->backend;
 
-    switch (sfc->base.type) {
-    case EGL_PBUFFER_BIT:
-        egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
-                                                        GL_COLOR_ATTACHMENT0,
-                                                        GL_TEXTURE_2D,
-                                                        sfc->pbuffer_tex,
-                                                        0);
-        break;
-    case EGL_PIXMAP_BIT:
-        egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
-                                                        GL_COLOR_ATTACHMENT0,
-                                                        GL_TEXTURE_2D,
-                                                        sfc->ws_sfc->get_front_texture(sfc->ws_sfc),
-                                                        0);
-        break;
-    case EGL_WINDOW_BIT:
-        egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
-                                                        GL_COLOR_ATTACHMENT0,
-                                                        GL_TEXTURE_2D,
-                                                        sfc->ws_sfc->get_back_texture(sfc->ws_sfc),
-                                                        0);
-        break;
-    default:
-        assert(false);
-        break;
-    }
+    egl_onscreen->gles_driver->FramebufferTexture2D(GL_FRAMEBUFFER,
+                                                    GL_COLOR_ATTACHMENT0,
+                                                    GL_TEXTURE_2D,
+                                                    sfc->ws_sfc->get_texture(sfc->ws_sfc),
+                                                    0);
     egl_onscreen->gles_driver->FramebufferRenderbuffer(GL_FRAMEBUFFER,
                                                        GL_DEPTH_ATTACHMENT,
                                                        GL_RENDERBUFFER,
@@ -536,28 +376,10 @@ void yagl_egl_onscreen_surface_attach_to_framebuffer(struct yagl_egl_onscreen_su
 
 uint32_t yagl_egl_onscreen_surface_width(struct yagl_egl_onscreen_surface *sfc)
 {
-    switch (sfc->base.type) {
-    case EGL_PBUFFER_BIT:
-        return sfc->pbuffer_width;
-    case EGL_PIXMAP_BIT:
-    case EGL_WINDOW_BIT:
-        return sfc->ws_res->get_width(sfc->ws_res);
-    default:
-        assert(false);
-        return 0;
-    }
+    return sfc->ws_sfc->base.width;
 }
 
 uint32_t yagl_egl_onscreen_surface_height(struct yagl_egl_onscreen_surface *sfc)
 {
-    switch (sfc->base.type) {
-    case EGL_PBUFFER_BIT:
-        return sfc->pbuffer_height;
-    case EGL_PIXMAP_BIT:
-    case EGL_WINDOW_BIT:
-        return sfc->ws_res->get_height(sfc->ws_res);
-    default:
-        assert(false);
-        return 0;
-    }
+    return sfc->ws_sfc->base.height;
 }
index e1be1e1..fe1a424 100644 (file)
@@ -7,7 +7,6 @@
 struct yagl_egl_onscreen_display;
 struct yagl_egl_native_config;
 
-struct winsys_resource;
 struct winsys_gl_surface;
 
 struct yagl_egl_onscreen_surface
@@ -21,39 +20,15 @@ struct yagl_egl_onscreen_surface
     EGLSurface dummy_native_sfc;
 
     /*
-     * winsys resource in case if this is a window or pixmap surface.
-     */
-    struct winsys_resource *ws_res;
-
-    /*
-     * winsys surface in case if this is a window or pixmap surface.
+     * winsys surface.
      */
     struct winsys_gl_surface *ws_sfc;
 
     /*
-     * Callback cookie from ws_res::add_callback.
-     */
-    void *cookie;
-
-    /*
-     * pbuffer texture in case if this is a pbuffer surface. Allocated
-     * when this surface is made current for the first time.
-     */
-    GLuint pbuffer_tex;
-    uint32_t pbuffer_width;
-    uint32_t pbuffer_height;
-
-    /*
-     * Depth and stencil renderbuffer for 'ws_sfc'/'pbuffer_tex'. Allocated
+     * Depth and stencil renderbuffer for 'ws_sfc'. Allocated
      * when this surface is made current for the first time.
      */
     GLuint rb;
-
-    /*
-     * This surface has been changed on target and
-     * needs update on host.
-     */
-    bool needs_update;
 };
 
 struct yagl_egl_onscreen_surface
@@ -72,8 +47,7 @@ struct yagl_egl_onscreen_surface
     *yagl_egl_onscreen_surface_create_pbuffer(struct yagl_egl_onscreen_display *dpy,
                                              const struct yagl_egl_native_config *cfg,
                                              const struct yagl_egl_pbuffer_attribs *attribs,
-                                             uint32_t width,
-                                             uint32_t height);
+                                             yagl_winsys_id id);
 
 void yagl_egl_onscreen_surface_setup(struct yagl_egl_onscreen_surface *sfc);
 
index 7ab4cfc..8aeacf5 100644 (file)
@@ -256,15 +256,11 @@ static int yagl_device_init(PCIDevice *dev)
     }
 
     if (s->wsi) {
-        /*
-         * TODO: uncomment.
-         */
-        /*
         egl_backend = yagl_egl_onscreen_create(s->wsi,
                                                egl_driver,
                                                &gles2_driver->base);
         gles1_driver = yagl_gles1_onscreen_create(gles1_driver);
-        gles2_driver = yagl_gles2_onscreen_create(gles2_driver);*/
+        gles2_driver = yagl_gles2_onscreen_create(gles2_driver);
     } else {
         egl_backend = yagl_egl_offscreen_create(egl_driver);
     }
index 93db2d0..8c320fe 100644 (file)
@@ -18,8 +18,6 @@ struct yagl_egl_backend
 
     void (*thread_init)(struct yagl_egl_backend */*backend*/);
 
-    void (*pre_batch)(struct yagl_egl_backend */*backend*/);
-
     struct yagl_eglb_display *(*create_display)(struct yagl_egl_backend */*backend*/);
 
     bool (*make_current)(struct yagl_egl_backend */*backend*/,
index 7f9346d..e706b50 100644 (file)
@@ -54,8 +54,7 @@ struct yagl_eglb_display
     struct yagl_eglb_surface *(*create_onscreen_pbuffer_surface)(struct yagl_eglb_display */*dpy*/,
                                                                  const struct yagl_egl_native_config */*cfg*/,
                                                                  const struct yagl_egl_pbuffer_attribs */*attribs*/,
-                                                                 uint32_t /*width*/,
-                                                                 uint32_t /*height*/);
+                                                                 yagl_winsys_id /*id*/);
 
     struct yagl_eglb_image *(*create_image)(struct yagl_eglb_display */*dpy*/,
                                             yagl_winsys_id /*buffer*/);
index 3d94ba2..53b8867 100644 (file)
@@ -29,6 +29,13 @@ struct yagl_eglb_surface
     void (*reset)(struct yagl_eglb_surface */*sfc*/);
 
     /*
+     * Surface has been invalidated on target, update it
+     * from 'id'.
+     */
+    void (*invalidate)(struct yagl_eglb_surface */*sfc*/,
+                       yagl_winsys_id /*id*/);
+
+    /*
      * Replaces 'sfc' with 'with', destroying 'with' afterwards.
      * 'sfc' and 'with' must be of same type, but can have
      * different formats.
@@ -45,8 +52,7 @@ struct yagl_eglb_surface
 
     bool (*swap_buffers)(struct yagl_eglb_surface */*sfc*/);
 
-    bool (*copy_buffers)(struct yagl_eglb_surface */*sfc*/,
-                         yagl_winsys_id /*target*/);
+    bool (*copy_buffers)(struct yagl_eglb_surface */*sfc*/);
 
     void (*destroy)(struct yagl_eglb_surface */*sfc*/);
 };
index 7e50ef4..8e6a9ac 100644 (file)
@@ -76,12 +76,6 @@ static void *yagl_thread_func(void* arg)
 
         YAGL_LOG_TRACE("batch started");
 
-        for (i = 0; i < YAGL_NUM_APIS; ++i) {
-            if (ts->ps->api_states[i]) {
-                ts->ps->api_states[i]->pre_batch(ts->ps->api_states[i]);
-            }
-        }
-
         /*
          * current_buff is:
          *  (yagl_api_id) api_id
index ef3fb23..e50c829 100644 (file)
@@ -6,6 +6,6 @@
 /*
  * Whenever protocol changes be sure to bump this.
  */
-#define YAGL_VERSION 16
+#define YAGL_VERSION 17
 
 #endif