src/video/SDL_renderer_sw.c
changeset 5138 da10636e5eca
parent 4929 aa8888658021
child 5140 e743b9c3f6d6
equal deleted inserted replaced
5137:e594f07297a9 5138:da10636e5eca
    48 static int SW_SetTextureColorMod(SDL_Renderer * renderer,
    48 static int SW_SetTextureColorMod(SDL_Renderer * renderer,
    49                                  SDL_Texture * texture);
    49                                  SDL_Texture * texture);
    50 static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
    50 static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
    51                                  SDL_Texture * texture);
    51                                  SDL_Texture * texture);
    52 static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
    52 static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
    53                                   SDL_Texture * texture);
       
    54 static int SW_SetTextureScaleMode(SDL_Renderer * renderer,
       
    55                                   SDL_Texture * texture);
    53                                   SDL_Texture * texture);
    56 static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    54 static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    57                             const SDL_Rect * rect, const void *pixels,
    55                             const SDL_Rect * rect, const void *pixels,
    58                             int pitch);
    56                             int pitch);
    59 static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    57 static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    88       SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
    86       SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
    89      (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
    87      (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
    90       SDL_TEXTUREMODULATE_ALPHA),
    88       SDL_TEXTUREMODULATE_ALPHA),
    91      (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
    89      (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
    92       SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
    90       SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
    93      (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST),
       
    94      14,
    91      14,
    95      {
    92      {
    96       SDL_PIXELFORMAT_INDEX8,
    93       SDL_PIXELFORMAT_INDEX8,
    97       SDL_PIXELFORMAT_RGB555,
    94       SDL_PIXELFORMAT_RGB555,
    98       SDL_PIXELFORMAT_RGB565,
    95       SDL_PIXELFORMAT_RGB565,
   178     renderer->SetTexturePalette = SW_SetTexturePalette;
   175     renderer->SetTexturePalette = SW_SetTexturePalette;
   179     renderer->GetTexturePalette = SW_GetTexturePalette;
   176     renderer->GetTexturePalette = SW_GetTexturePalette;
   180     renderer->SetTextureColorMod = SW_SetTextureColorMod;
   177     renderer->SetTextureColorMod = SW_SetTextureColorMod;
   181     renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
   178     renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
   182     renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
   179     renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
   183     renderer->SetTextureScaleMode = SW_SetTextureScaleMode;
       
   184     renderer->UpdateTexture = SW_UpdateTexture;
   180     renderer->UpdateTexture = SW_UpdateTexture;
   185     renderer->LockTexture = SW_LockTexture;
   181     renderer->LockTexture = SW_LockTexture;
   186     renderer->UnlockTexture = SW_UnlockTexture;
   182     renderer->UnlockTexture = SW_UnlockTexture;
   187     renderer->DestroyTexture = SW_DestroyTexture;
   183     renderer->DestroyTexture = SW_DestroyTexture;
   188 
   184 
   189     renderer->info.mod_modes = SW_RenderDriver.info.mod_modes;
   185     renderer->info.mod_modes = SW_RenderDriver.info.mod_modes;
   190     renderer->info.blend_modes = SW_RenderDriver.info.blend_modes;
   186     renderer->info.blend_modes = SW_RenderDriver.info.blend_modes;
   191     renderer->info.scale_modes = SW_RenderDriver.info.scale_modes;
       
   192     renderer->info.num_texture_formats =
   187     renderer->info.num_texture_formats =
   193         SW_RenderDriver.info.num_texture_formats;
   188         SW_RenderDriver.info.num_texture_formats;
   194     SDL_memcpy(renderer->info.texture_formats,
   189     SDL_memcpy(renderer->info.texture_formats,
   195                SW_RenderDriver.info.texture_formats,
   190                SW_RenderDriver.info.texture_formats,
   196                sizeof(renderer->info.texture_formats));;
   191                sizeof(renderer->info.texture_formats));;
   394                                  Bmask, Amask);
   389                                  Bmask, Amask);
   395         SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
   390         SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
   396                                texture->b);
   391                                texture->b);
   397         SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
   392         SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
   398         SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
   393         SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
   399         SDL_SetSurfaceScaleMode(texture->driverdata, texture->scaleMode);
       
   400 
   394 
   401         if (texture->access == SDL_TEXTUREACCESS_STATIC) {
   395         if (texture->access == SDL_TEXTUREACCESS_STATIC) {
   402             SDL_SetSurfaceRLE(texture->driverdata, 1);
   396             SDL_SetSurfaceRLE(texture->driverdata, 1);
   403         }
   397         }
   404     }
   398     }
   475 static int
   469 static int
   476 SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   470 SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   477 {
   471 {
   478     SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   472     SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   479     return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
   473     return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
   480 }
       
   481 
       
   482 static int
       
   483 SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
       
   484 {
       
   485     SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
       
   486     return SDL_SetSurfaceScaleMode(surface, texture->scaleMode);
       
   487 }
   474 }
   488 
   475 
   489 static int
   476 static int
   490 SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   477 SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   491                  const SDL_Rect * rect, const void *pixels, int pitch)
   478                  const SDL_Rect * rect, const void *pixels, int pitch)