changeset 5160:657543cc92f9

Making the API simpler, removed the writepixels interface
author Sam Lantinga <slouken@libsdl.org>
date Thu, 03 Feb 2011 00:22:18 -0800
parents 307ccc9c135e
children b3ccd1947786
files 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
diffstat 6 files changed, 0 insertions(+), 146 deletions(-) [+]
line wrap: on
line diff
--- a/include/SDL_render.h	Thu Feb 03 00:19:40 2011 -0800
+++ b/include/SDL_render.h	Thu Feb 03 00:22:18 2011 -0800
@@ -527,26 +527,6 @@
                                                  void *pixels, int pitch);
 
 /**
- *  \brief Write pixels to the current rendering target.
- *  
- *  \param rect   A pointer to the rectangle to write, or NULL for the entire 
- *                render target.
- *  \param format The format of the pixel data, or 0 to use the format
- *                of the rendering target
- *  \param pixels A pointer to the pixel data to write.
- *  \param pitch  The pitch of the pixels parameter.
- *  
- *  \return 0 on success, or -1 if pixel writing is not supported.
- *  
- *  \warning This is a very slow operation, and should not be used frequently.
- */
-extern DECLSPEC int SDLCALL SDL_RenderWritePixels(SDL_Renderer * renderer,
-                                                  const SDL_Rect * rect,
-                                                  Uint32 format,
-                                                  const void *pixels,
-                                                  int pitch);
-
-/**
  *  \brief Update the screen with rendering performed.
  */
 extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
--- a/src/render/SDL_render.c	Thu Feb 03 00:19:40 2011 -0800
+++ b/src/render/SDL_render.c	Thu Feb 03 00:22:18 2011 -0800
@@ -1212,45 +1212,6 @@
                                       format, pixels, pitch);
 }
 
-int
-SDL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                      Uint32 format, const void * pixels, int pitch)
-{
-    SDL_Window *window;
-    SDL_Rect real_rect;
-
-    CHECK_RENDERER_MAGIC(renderer, -1);
-
-    if (!renderer->RenderWritePixels) {
-        SDL_Unsupported();
-        return -1;
-    }
-    window = renderer->window;
-
-    if (!format) {
-        format = SDL_GetWindowPixelFormat(window);
-    }
-
-    real_rect.x = 0;
-    real_rect.y = 0;
-    SDL_GetWindowSize(window, &real_rect.w, &real_rect.h);
-    if (rect) {
-        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
-            return 0;
-        }
-        if (real_rect.y > rect->y) {
-            pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y);
-        }
-        if (real_rect.x > rect->x) {
-            int bpp = SDL_BYTESPERPIXEL(SDL_GetWindowPixelFormat(window));
-            pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x);
-        }
-    }
-
-    return renderer->RenderWritePixels(renderer, &real_rect,
-                                       format, pixels, pitch);
-}
-
 void
 SDL_RenderPresent(SDL_Renderer * renderer)
 {
--- a/src/render/SDL_sysrender.h	Thu Feb 03 00:19:40 2011 -0800
+++ b/src/render/SDL_sysrender.h	Thu Feb 03 00:22:18 2011 -0800
@@ -89,8 +89,6 @@
                        const SDL_Rect * srcrect, const SDL_Rect * dstrect);
     int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
                              Uint32 format, void * pixels, int pitch);
-    int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
-                              Uint32 format, const void * pixels, int pitch);
     void (*RenderPresent) (SDL_Renderer * renderer);
     void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
 
--- a/src/render/direct3d/SDL_d3drender.c	Thu Feb 03 00:19:40 2011 -0800
+++ b/src/render/direct3d/SDL_d3drender.c	Thu Feb 03 00:22:18 2011 -0800
@@ -115,8 +115,6 @@
                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
 static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
                                 Uint32 format, void * pixels, int pitch);
-static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                 Uint32 format, const void * pixels, int pitch);
 static void D3D_RenderPresent(SDL_Renderer * renderer);
 static void D3D_DestroyTexture(SDL_Renderer * renderer,
                                SDL_Texture * texture);
@@ -325,7 +323,6 @@
     renderer->RenderFillRects = D3D_RenderFillRects;
     renderer->RenderCopy = D3D_RenderCopy;
     renderer->RenderReadPixels = D3D_RenderReadPixels;
-    renderer->RenderWritePixels = D3D_RenderWritePixels;
     renderer->RenderPresent = D3D_RenderPresent;
     renderer->DestroyTexture = D3D_DestroyTexture;
     renderer->DestroyRenderer = D3D_DestroyRenderer;
@@ -1021,15 +1018,6 @@
     return 0;
 }
 
-static int
-D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                      Uint32 format, const void * pixels, int pitch)
-{
-    /* Work in progress */
-    SDL_Unsupported();
-    return -1;
-}
-
 static void
 D3D_RenderPresent(SDL_Renderer * renderer)
 {
--- a/src/render/opengl/SDL_renderer_gl.c	Thu Feb 03 00:19:40 2011 -0800
+++ b/src/render/opengl/SDL_renderer_gl.c	Thu Feb 03 00:22:18 2011 -0800
@@ -63,8 +63,6 @@
                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
 static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
                                Uint32 pixel_format, void * pixels, int pitch);
-static int GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 pixel_format, const void * pixels, int pitch);
 static void GL_RenderPresent(SDL_Renderer * renderer);
 static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
 static void GL_DestroyRenderer(SDL_Renderer * renderer);
@@ -207,7 +205,6 @@
     renderer->RenderFillRects = GL_RenderFillRects;
     renderer->RenderCopy = GL_RenderCopy;
     renderer->RenderReadPixels = GL_RenderReadPixels;
-    renderer->RenderWritePixels = GL_RenderWritePixels;
     renderer->RenderPresent = GL_RenderPresent;
     renderer->DestroyTexture = GL_DestroyTexture;
     renderer->DestroyRenderer = GL_DestroyRenderer;
@@ -776,50 +773,6 @@
     return 0;
 }
 
-static int
-GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 pixel_format, const void * pixels, int pitch)
-{
-    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
-    SDL_Window *window = renderer->window;
-    GLint internalFormat;
-    GLenum format, type;
-    Uint8 *src, *dst, *tmp;
-    int w, h, length, rows;
-
-    GL_ActivateRenderer(renderer);
-
-    if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) {
-        /* FIXME: Do a temp copy to a format that is supported */
-        SDL_SetError("Unsupported pixel format");
-        return -1;
-    }
-
-    SDL_GetWindowSize(window, &w, &h);
-
-    data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    data->glPixelStorei(GL_UNPACK_ROW_LENGTH,
-                        (pitch / SDL_BYTESPERPIXEL(pixel_format)));
-
-    /* Flip the rows to be bottom-up */
-    length = rect->h * rect->w * pitch;
-    tmp = SDL_stack_alloc(Uint8, length);
-    src = (Uint8*)pixels + (rect->h-1)*pitch;
-    dst = (Uint8*)tmp;
-    rows = rect->h;
-    while (rows--) {
-        SDL_memcpy(dst, src, pitch);
-        dst += pitch;
-        src -= pitch;
-    }
-
-    data->glRasterPos2i(rect->x, (h-rect->y));
-    data->glDrawPixels(rect->w, rect->h, format, type, tmp);
-    SDL_stack_free(tmp);
-
-    return 0;
-}
-
 static void
 GL_RenderPresent(SDL_Renderer * renderer)
 {
--- a/src/render/software/SDL_renderer_sw.c	Thu Feb 03 00:19:40 2011 -0800
+++ b/src/render/software/SDL_renderer_sw.c	Thu Feb 03 00:22:18 2011 -0800
@@ -53,8 +53,6 @@
                          const SDL_Rect * srcrect, const SDL_Rect * dstrect);
 static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
                                Uint32 format, void * pixels, int pitch);
-static int SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                                Uint32 format, const void * pixels, int pitch);
 static void SW_RenderPresent(SDL_Renderer * renderer);
 static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
 static void SW_DestroyRenderer(SDL_Renderer * renderer);
@@ -166,7 +164,6 @@
     renderer->RenderFillRects = SW_RenderFillRects;
     renderer->RenderCopy = SW_RenderCopy;
     renderer->RenderReadPixels = SW_RenderReadPixels;
-    renderer->RenderWritePixels = SW_RenderWritePixels;
     renderer->RenderPresent = SW_RenderPresent;
     renderer->DestroyRenderer = SW_DestroyRenderer;
     renderer->info = SW_RenderDriver.info;
@@ -592,29 +589,6 @@
     return 0;
 }
 
-static int
-SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
-                     Uint32 format, const void * pixels, int pitch)
-{
-    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
-
-    if (!SW_ActivateRenderer(renderer)) {
-        return -1;
-    }
-
-    if (data->renderer->LockTexture(data->renderer, data->texture, rect,
-                                    &data->surface.pixels,
-                                    &data->surface.pitch) < 0) {
-        return -1;
-    }
-
-    SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch,
-                      data->format, data->surface.pixels, data->surface.pitch);
-
-    data->renderer->UnlockTexture(data->renderer, data->texture);
-    return 0;
-}
-
 static void
 SW_RenderPresent(SDL_Renderer * renderer)
 {