src/video/SDL_renderer_sw.c
changeset 3435 9f62f47d989b
parent 3427 36cf454ba065
child 3536 0267b8b1595c
     1.1 --- a/src/video/SDL_renderer_sw.c	Sun Nov 15 09:21:46 2009 +0000
     1.2 +++ b/src/video/SDL_renderer_sw.c	Mon Nov 16 07:13:07 2009 +0000
     1.3 @@ -66,9 +66,9 @@
     1.4  static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
     1.5                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
     1.6  static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     1.7 -                               void * pixels, int pitch);
     1.8 +                               Uint32 format, void * pixels, int pitch);
     1.9  static int SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    1.10 -                                const void * pixels, int pitch);
    1.11 +                                Uint32 format, const void * pixels, int pitch);
    1.12  static void SW_RenderPresent(SDL_Renderer * renderer);
    1.13  static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    1.14  static void SW_DestroyRenderer(SDL_Renderer * renderer);
    1.15 @@ -736,12 +736,9 @@
    1.16  
    1.17  static int
    1.18  SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    1.19 -                    void * pixels, int pitch)
    1.20 +                    Uint32 format, void * pixels, int pitch)
    1.21  {
    1.22      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    1.23 -    const Uint8 *src;
    1.24 -    Uint8 *dst;
    1.25 -    int src_pitch, dst_pitch, w, h;
    1.26  
    1.27      if (data->renderer->LockTexture(data->renderer,
    1.28                                      data->texture[data->current_texture],
    1.29 @@ -750,17 +747,9 @@
    1.30          return -1;
    1.31      }
    1.32  
    1.33 -    src = data->surface.pixels;
    1.34 -    src_pitch = data->surface.pitch;
    1.35 -    dst = pixels;
    1.36 -    dst_pitch = pitch;
    1.37 -    h = rect->h;
    1.38 -    w = rect->w * data->surface.format->BytesPerPixel;
    1.39 -    while (h--) {
    1.40 -        SDL_memcpy(dst, src, w);
    1.41 -        src += src_pitch;
    1.42 -        dst += dst_pitch;
    1.43 -    }
    1.44 +    SDL_ConvertPixels(rect->w, rect->h,
    1.45 +                      data->format, data->surface.pixels, data->surface.pitch,
    1.46 +                      format, pixels, pitch);
    1.47  
    1.48      data->renderer->UnlockTexture(data->renderer,
    1.49                                    data->texture[data->current_texture]);
    1.50 @@ -769,12 +758,9 @@
    1.51  
    1.52  static int
    1.53  SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    1.54 -                     const void * pixels, int pitch)
    1.55 +                     Uint32 format, const void * pixels, int pitch)
    1.56  {
    1.57      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    1.58 -    const Uint8 *src;
    1.59 -    Uint8 *dst;
    1.60 -    int src_pitch, dst_pitch, w, h;
    1.61  
    1.62      if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
    1.63          SDL_AddDirtyRect(&data->dirty, rect);
    1.64 @@ -787,17 +773,8 @@
    1.65          return -1;
    1.66      }
    1.67  
    1.68 -    src = pixels;
    1.69 -    src_pitch = pitch;
    1.70 -    dst = data->surface.pixels;
    1.71 -    dst_pitch = data->surface.pitch;
    1.72 -    h = rect->h;
    1.73 -    w = rect->w * data->surface.format->BytesPerPixel;
    1.74 -    while (h--) {
    1.75 -        SDL_memcpy(dst, src, w);
    1.76 -        src += src_pitch;
    1.77 -        dst += dst_pitch;
    1.78 -    }
    1.79 +    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
    1.80 +                      data->format, data->surface.pixels, data->surface.pitch);
    1.81  
    1.82      data->renderer->UnlockTexture(data->renderer,
    1.83                                    data->texture[data->current_texture]);