src/render/software/SDL_render_sw.c
changeset 6246 c70ec935a4bb
parent 6138 4c64952a58fb
child 6247 b6212690f78d
     1.1 --- a/src/render/software/SDL_render_sw.c	Sat Jan 21 22:14:38 2012 -0500
     1.2 +++ b/src/render/software/SDL_render_sw.c	Sat Jan 21 22:22:30 2012 -0500
     1.3 @@ -51,6 +51,7 @@
     1.4  static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
     1.5                            const SDL_Rect * rect, void **pixels, int *pitch);
     1.6  static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     1.7 +static int SW_SetTargetTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     1.8  static int SW_UpdateViewport(SDL_Renderer * renderer);
     1.9  static int SW_RenderClear(SDL_Renderer * renderer);
    1.10  static int SW_RenderDrawPoints(SDL_Renderer * renderer,
    1.11 @@ -72,7 +73,7 @@
    1.12      SW_CreateRenderer,
    1.13      {
    1.14       "software",
    1.15 -     SDL_RENDERER_SOFTWARE,
    1.16 +     SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
    1.17       8,
    1.18       {
    1.19        SDL_PIXELFORMAT_RGB555,
    1.20 @@ -91,6 +92,7 @@
    1.21  typedef struct
    1.22  {
    1.23      SDL_Surface *surface;
    1.24 +    SDL_Surface *window;
    1.25  } SW_RenderData;
    1.26  
    1.27  
    1.28 @@ -100,7 +102,10 @@
    1.29      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    1.30  
    1.31      if (!data->surface) {
    1.32 -        data->surface = SDL_GetWindowSurface(renderer->window);
    1.33 +        data->surface = data->window;
    1.34 +    }
    1.35 +    if (!data->surface) {
    1.36 +        data->surface = data->window = SDL_GetWindowSurface(renderer->window);
    1.37  
    1.38          SW_UpdateViewport(renderer);
    1.39      }
    1.40 @@ -140,8 +145,8 @@
    1.41      renderer->UpdateTexture = SW_UpdateTexture;
    1.42      renderer->LockTexture = SW_LockTexture;
    1.43      renderer->UnlockTexture = SW_UnlockTexture;
    1.44 +    renderer->SetTargetTexture = SW_SetTargetTexture;
    1.45      renderer->UpdateViewport = SW_UpdateViewport;
    1.46 -    renderer->DestroyTexture = SW_DestroyTexture;
    1.47      renderer->RenderClear = SW_RenderClear;
    1.48      renderer->RenderDrawPoints = SW_RenderDrawPoints;
    1.49      renderer->RenderDrawLines = SW_RenderDrawLines;
    1.50 @@ -149,6 +154,7 @@
    1.51      renderer->RenderCopy = SW_RenderCopy;
    1.52      renderer->RenderReadPixels = SW_RenderReadPixels;
    1.53      renderer->RenderPresent = SW_RenderPresent;
    1.54 +    renderer->DestroyTexture = SW_DestroyTexture;
    1.55      renderer->DestroyRenderer = SW_DestroyRenderer;
    1.56      renderer->info = SW_RenderDriver.info;
    1.57      renderer->driverdata = data;
    1.58 @@ -277,6 +283,19 @@
    1.59  }
    1.60  
    1.61  static int
    1.62 +SW_SetTargetTexture(SDL_Renderer * renderer, SDL_Texture * texture)
    1.63 +{
    1.64 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    1.65 +
    1.66 +    if (texture ) {
    1.67 +        data->surface = (SDL_Surface *) texture->driverdata;
    1.68 +    } else {
    1.69 +        data->surface = data->window;
    1.70 +    }
    1.71 +    return 0;
    1.72 +}
    1.73 +
    1.74 +static int
    1.75  SW_UpdateViewport(SDL_Renderer * renderer)
    1.76  {
    1.77      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;