Making the API simpler, removed the writepixels interface
authorSam Lantinga <slouken@libsdl.org>
Thu, 03 Feb 2011 00:22:18 -0800
changeset 5157657543cc92f9
parent 5156 307ccc9c135e
child 5158 b3ccd1947786
Making the API simpler, removed the writepixels interface
include/SDL_render.h
src/render/SDL_render.c
src/render/SDL_sysrender.h
src/render/direct3d/SDL_d3drender.c
src/render/opengl/SDL_renderer_gl.c
src/render/software/SDL_renderer_sw.c
     1.1 --- a/include/SDL_render.h	Thu Feb 03 00:19:40 2011 -0800
     1.2 +++ b/include/SDL_render.h	Thu Feb 03 00:22:18 2011 -0800
     1.3 @@ -527,26 +527,6 @@
     1.4                                                   void *pixels, int pitch);
     1.5  
     1.6  /**
     1.7 - *  \brief Write pixels to the current rendering target.
     1.8 - *  
     1.9 - *  \param rect   A pointer to the rectangle to write, or NULL for the entire 
    1.10 - *                render target.
    1.11 - *  \param format The format of the pixel data, or 0 to use the format
    1.12 - *                of the rendering target
    1.13 - *  \param pixels A pointer to the pixel data to write.
    1.14 - *  \param pitch  The pitch of the pixels parameter.
    1.15 - *  
    1.16 - *  \return 0 on success, or -1 if pixel writing is not supported.
    1.17 - *  
    1.18 - *  \warning This is a very slow operation, and should not be used frequently.
    1.19 - */
    1.20 -extern DECLSPEC int SDLCALL SDL_RenderWritePixels(SDL_Renderer * renderer,
    1.21 -                                                  const SDL_Rect * rect,
    1.22 -                                                  Uint32 format,
    1.23 -                                                  const void *pixels,
    1.24 -                                                  int pitch);
    1.25 -
    1.26 -/**
    1.27   *  \brief Update the screen with rendering performed.
    1.28   */
    1.29  extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
     2.1 --- a/src/render/SDL_render.c	Thu Feb 03 00:19:40 2011 -0800
     2.2 +++ b/src/render/SDL_render.c	Thu Feb 03 00:22:18 2011 -0800
     2.3 @@ -1212,45 +1212,6 @@
     2.4                                        format, pixels, pitch);
     2.5  }
     2.6  
     2.7 -int
     2.8 -SDL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     2.9 -                      Uint32 format, const void * pixels, int pitch)
    2.10 -{
    2.11 -    SDL_Window *window;
    2.12 -    SDL_Rect real_rect;
    2.13 -
    2.14 -    CHECK_RENDERER_MAGIC(renderer, -1);
    2.15 -
    2.16 -    if (!renderer->RenderWritePixels) {
    2.17 -        SDL_Unsupported();
    2.18 -        return -1;
    2.19 -    }
    2.20 -    window = renderer->window;
    2.21 -
    2.22 -    if (!format) {
    2.23 -        format = SDL_GetWindowPixelFormat(window);
    2.24 -    }
    2.25 -
    2.26 -    real_rect.x = 0;
    2.27 -    real_rect.y = 0;
    2.28 -    SDL_GetWindowSize(window, &real_rect.w, &real_rect.h);
    2.29 -    if (rect) {
    2.30 -        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
    2.31 -            return 0;
    2.32 -        }
    2.33 -        if (real_rect.y > rect->y) {
    2.34 -            pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y);
    2.35 -        }
    2.36 -        if (real_rect.x > rect->x) {
    2.37 -            int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
    2.38 -            pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x);
    2.39 -        }
    2.40 -    }
    2.41 -
    2.42 -    return renderer->RenderWritePixels(renderer, &real_rect,
    2.43 -                                       format, pixels, pitch);
    2.44 -}
    2.45 -
    2.46  void
    2.47  SDL_RenderPresent(SDL_Renderer * renderer)
    2.48  {
     3.1 --- a/src/render/SDL_sysrender.h	Thu Feb 03 00:19:40 2011 -0800
     3.2 +++ b/src/render/SDL_sysrender.h	Thu Feb 03 00:22:18 2011 -0800
     3.3 @@ -89,8 +89,6 @@
     3.4                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
     3.5      int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
     3.6                               Uint32 format, void * pixels, int pitch);
     3.7 -    int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
     3.8 -                              Uint32 format, const void * pixels, int pitch);
     3.9      void (*RenderPresent) (SDL_Renderer * renderer);
    3.10      void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    3.11  
     4.1 --- a/src/render/direct3d/SDL_d3drender.c	Thu Feb 03 00:19:40 2011 -0800
     4.2 +++ b/src/render/direct3d/SDL_d3drender.c	Thu Feb 03 00:22:18 2011 -0800
     4.3 @@ -115,8 +115,6 @@
     4.4                            const SDL_Rect * srcrect, const SDL_Rect * dstrect);
     4.5  static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     4.6                                  Uint32 format, void * pixels, int pitch);
     4.7 -static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     4.8 -                                 Uint32 format, const void * pixels, int pitch);
     4.9  static void D3D_RenderPresent(SDL_Renderer * renderer);
    4.10  static void D3D_DestroyTexture(SDL_Renderer * renderer,
    4.11                                 SDL_Texture * texture);
    4.12 @@ -325,7 +323,6 @@
    4.13      renderer->RenderFillRects = D3D_RenderFillRects;
    4.14      renderer->RenderCopy = D3D_RenderCopy;
    4.15      renderer->RenderReadPixels = D3D_RenderReadPixels;
    4.16 -    renderer->RenderWritePixels = D3D_RenderWritePixels;
    4.17      renderer->RenderPresent = D3D_RenderPresent;
    4.18      renderer->DestroyTexture = D3D_DestroyTexture;
    4.19      renderer->DestroyRenderer = D3D_DestroyRenderer;
    4.20 @@ -1021,15 +1018,6 @@
    4.21      return 0;
    4.22  }
    4.23  
    4.24 -static int
    4.25 -D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    4.26 -                      Uint32 format, const void * pixels, int pitch)
    4.27 -{
    4.28 -    /* Work in progress */
    4.29 -    SDL_Unsupported();
    4.30 -    return -1;
    4.31 -}
    4.32 -
    4.33  static void
    4.34  D3D_RenderPresent(SDL_Renderer * renderer)
    4.35  {
     5.1 --- a/src/render/opengl/SDL_renderer_gl.c	Thu Feb 03 00:19:40 2011 -0800
     5.2 +++ b/src/render/opengl/SDL_renderer_gl.c	Thu Feb 03 00:22:18 2011 -0800
     5.3 @@ -63,8 +63,6 @@
     5.4                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
     5.5  static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     5.6                                 Uint32 pixel_format, void * pixels, int pitch);
     5.7 -static int GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     5.8 -                                Uint32 pixel_format, const void * pixels, int pitch);
     5.9  static void GL_RenderPresent(SDL_Renderer * renderer);
    5.10  static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    5.11  static void GL_DestroyRenderer(SDL_Renderer * renderer);
    5.12 @@ -207,7 +205,6 @@
    5.13      renderer->RenderFillRects = GL_RenderFillRects;
    5.14      renderer->RenderCopy = GL_RenderCopy;
    5.15      renderer->RenderReadPixels = GL_RenderReadPixels;
    5.16 -    renderer->RenderWritePixels = GL_RenderWritePixels;
    5.17      renderer->RenderPresent = GL_RenderPresent;
    5.18      renderer->DestroyTexture = GL_DestroyTexture;
    5.19      renderer->DestroyRenderer = GL_DestroyRenderer;
    5.20 @@ -776,50 +773,6 @@
    5.21      return 0;
    5.22  }
    5.23  
    5.24 -static int
    5.25 -GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    5.26 -                     Uint32 pixel_format, const void * pixels, int pitch)
    5.27 -{
    5.28 -    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    5.29 -    SDL_Window *window = renderer->window;
    5.30 -    GLint internalFormat;
    5.31 -    GLenum format, type;
    5.32 -    Uint8 *src, *dst, *tmp;
    5.33 -    int w, h, length, rows;
    5.34 -
    5.35 -    GL_ActivateRenderer(renderer);
    5.36 -
    5.37 -    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
    5.38 -        /* FIXME: Do a temp copy to a format that is supported */
    5.39 -        SDL_SetError("Unsupported pixel format");
    5.40 -        return -1;
    5.41 -    }
    5.42 -
    5.43 -    SDL_GetWindowSize(window, &w, &h);
    5.44 -
    5.45 -    data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    5.46 -    data->glPixelStorei(GL_UNPACK_ROW_LENGTH,
    5.47 -                        (pitch / SDL_BYTESPERPIXEL(pixel_format)));
    5.48 -
    5.49 -    /* Flip the rows to be bottom-up */
    5.50 -    length = rect->h * rect->w * pitch;
    5.51 -    tmp = SDL_stack_alloc(Uint8, length);
    5.52 -    src = (Uint8*)pixels + (rect->h-1)*pitch;
    5.53 -    dst = (Uint8*)tmp;
    5.54 -    rows = rect->h;
    5.55 -    while (rows--) {
    5.56 -        SDL_memcpy(dst, src, pitch);
    5.57 -        dst += pitch;
    5.58 -        src -= pitch;
    5.59 -    }
    5.60 -
    5.61 -    data->glRasterPos2i(rect->x, (h-rect->y));
    5.62 -    data->glDrawPixels(rect->w, rect->h, format, type, tmp);
    5.63 -    SDL_stack_free(tmp);
    5.64 -
    5.65 -    return 0;
    5.66 -}
    5.67 -
    5.68  static void
    5.69  GL_RenderPresent(SDL_Renderer * renderer)
    5.70  {
     6.1 --- a/src/render/software/SDL_renderer_sw.c	Thu Feb 03 00:19:40 2011 -0800
     6.2 +++ b/src/render/software/SDL_renderer_sw.c	Thu Feb 03 00:22:18 2011 -0800
     6.3 @@ -53,8 +53,6 @@
     6.4                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
     6.5  static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     6.6                                 Uint32 format, void * pixels, int pitch);
     6.7 -static int SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
     6.8 -                                Uint32 format, const void * pixels, int pitch);
     6.9  static void SW_RenderPresent(SDL_Renderer * renderer);
    6.10  static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    6.11  static void SW_DestroyRenderer(SDL_Renderer * renderer);
    6.12 @@ -166,7 +164,6 @@
    6.13      renderer->RenderFillRects = SW_RenderFillRects;
    6.14      renderer->RenderCopy = SW_RenderCopy;
    6.15      renderer->RenderReadPixels = SW_RenderReadPixels;
    6.16 -    renderer->RenderWritePixels = SW_RenderWritePixels;
    6.17      renderer->RenderPresent = SW_RenderPresent;
    6.18      renderer->DestroyRenderer = SW_DestroyRenderer;
    6.19      renderer->info = SW_RenderDriver.info;
    6.20 @@ -592,29 +589,6 @@
    6.21      return 0;
    6.22  }
    6.23  
    6.24 -static int
    6.25 -SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    6.26 -                     Uint32 format, const void * pixels, int pitch)
    6.27 -{
    6.28 -    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    6.29 -
    6.30 -    if (!SW_ActivateRenderer(renderer)) {
    6.31 -        return -1;
    6.32 -    }
    6.33 -
    6.34 -    if (data->renderer->LockTexture(data->renderer, data->texture, rect,
    6.35 -                                    &data->surface.pixels,
    6.36 -                                    &data->surface.pitch) < 0) {
    6.37 -        return -1;
    6.38 -    }
    6.39 -
    6.40 -    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
    6.41 -                      data->format, data->surface.pixels, data->surface.pitch);
    6.42 -
    6.43 -    data->renderer->UnlockTexture(data->renderer, data->texture);
    6.44 -    return 0;
    6.45 -}
    6.46 -
    6.47  static void
    6.48  SW_RenderPresent(SDL_Renderer * renderer)
    6.49  {