changeset 2241:4932f192c565

Date: Wed, 15 Aug 2007 01:08:38 +0200 From: Couriersud Subject: Some SDL1.3 patches Modified UpdateTexture to lock and unlock DirectFB-Surface.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 15 Aug 2007 03:19:21 +0000
parents eebaa05f8bd9
children 313112f9ac5c
files src/video/directfb/SDL_DirectFB_render.c
diffstat 1 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/directfb/SDL_DirectFB_render.c	Wed Aug 15 03:18:24 2007 +0000
+++ b/src/video/directfb/SDL_DirectFB_render.c	Wed Aug 15 03:19:21 2007 +0000
@@ -505,27 +505,31 @@
     DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
     DirectFB_RenderData *renderdata =
         (DirectFB_RenderData *) renderer->driverdata;
-
-    if (data->pixels) {
-        Uint8 *src, *dst;
-        int row;
-        size_t length;
+    DFBResult ret;
+    Uint8 *dpixels;
+    int   dpitch;
+    Uint8 *src, *dst;
+    int row;
+    size_t length;
 
-        src = (Uint8 *) pixels;
-        dst =
-            (Uint8 *) data->pixels + rect->y * data->pitch +
-            rect->x * SDL_BYTESPERPIXEL(texture->format);
-        length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-        for (row = 0; row < rect->h; ++row) {
-            SDL_memcpy(dst, src, length);
-            src += pitch;
-            dst += data->pitch;
-        }
-    } else {
-        SDL_SetError("FIXME: Update without lock!\n");
-        return -1;
+    SDL_DFB_CHECKERR(data->surface->Lock(data->surface,
+                                         DSLF_WRITE | DSLF_READ, &dpixels,
+                                         &dpitch));
+    src = (Uint8 *) pixels;
+    dst =
+        (Uint8 *) dpixels + rect->y * dpitch +
+        rect->x * SDL_BYTESPERPIXEL(texture->format);
+    length = rect->w * SDL_BYTESPERPIXEL(texture->format);
+    for (row = 0; row < rect->h; ++row) {
+        SDL_memcpy(dst, src, length);
+        src += pitch;
+        dst += dpitch;
     }
+    SDL_DFB_CHECKERR(data->surface->Unlock(data->surface) );
     return 0;
+error:
+	return 1;
+
 }
 
 static int