Merge branch 'master' into r300-compiler
[mesa.git] / src / gallium / state_trackers / egl / egl_surface.c
index 3ef1945b93cb4def5bc608cc66fe1bb1d5bdf5f4..7911a8834e01576c888d34332d4c7d888043f86b 100644 (file)
@@ -96,10 +96,6 @@ drm_create_texture(_EGLDisplay *dpy,
        if (!texture)
                goto err_tex;
 
-       dev->api->buffer_from_texture(dev->api, texture, &buf, &pitch);
-       if (!buf)
-               goto err_buf;
-
        surface = screen->get_tex_surface(screen,
                                          texture,
                                          0,
@@ -112,11 +108,11 @@ drm_create_texture(_EGLDisplay *dpy,
 
        scrn->tex = texture;
        scrn->surface = surface;
-       scrn->buffer = buf;
        scrn->front.width = w;
        scrn->front.height = h;
        scrn->front.pitch = pitch;
-       dev->api->handle_from_buffer(dev->api, screen, scrn->buffer, &scrn->front.handle);
+       dev->api->local_handle_from_texture(dev->api, screen, texture,
+                                           &scrn->front.pitch, &scrn->front.handle);
        if (0)
                goto err_handle;
 
@@ -126,7 +122,6 @@ err_handle:
        pipe_surface_reference(&surface, NULL);
 err_surf:
        pipe_texture_reference(&texture, NULL);
-err_buf:
 err_tex:
        pipe_buffer_reference(&buf, NULL);
        return;
@@ -157,7 +152,6 @@ drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen)
 
        pipe_surface_reference(&screen->surface, NULL);
        pipe_texture_reference(&screen->tex, NULL);
-       pipe_buffer_reference(&screen->buffer, NULL);
 
        screen->shown = 0;
 }
@@ -255,8 +249,8 @@ drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy,
 
 
        drm_create_texture(dpy, scrn, mode->Width, mode->Height);
-       if (!scrn->buffer)
-               return EGL_FALSE;
+       if (!scrn->tex)
+               goto err_tex;
 
        ret = drmModeAddFB(dev->drmFD,
                           scrn->front.width, scrn->front.height,
@@ -330,8 +324,8 @@ err_fb:
 err_bo:
        pipe_surface_reference(&scrn->surface, NULL);
        pipe_texture_reference(&scrn->tex, NULL);
-       pipe_buffer_reference(&scrn->buffer, NULL);
 
+err_tex:
        return EGL_FALSE;
 }
 
@@ -358,24 +352,21 @@ drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
        if (!surf)
                return EGL_FALSE;
 
-       /* error checking */
-       if (!_eglSwapBuffers(drv, dpy, draw))
-               return EGL_FALSE;
-
        st_get_framebuffer_surface(surf->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
 
        if (back_surf) {
+               struct drm_context *ctx = lookup_drm_context(draw->Binding);
 
                st_notify_swapbuffers(surf->stfb);
 
-               if (surf->screen) {
-                       surf->user->pipe->surface_copy(surf->user->pipe,
+               if (ctx && surf->screen) {
+                       ctx->pipe->surface_copy(ctx->pipe,
                                surf->screen->surface,
                                0, 0,
                                back_surf,
                                0, 0,
                                surf->w, surf->h);
-                       surf->user->pipe->flush(surf->user->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
+                       ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
 
 #ifdef DRM_MODE_FEATURE_DIRTYFB
                        /* TODO query connector property to see if this is needed */