src/render/software/SDL_render_sw.c
changeset 5567 441c3036440c
parent 5535 96594ac5fd1a
child 6044 35448a5ea044
equal deleted inserted replaced
5566:0d221d6ffac8 5567:441c3036440c
   238     SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   238     SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   239     Uint8 *src, *dst;
   239     Uint8 *src, *dst;
   240     int row;
   240     int row;
   241     size_t length;
   241     size_t length;
   242 
   242 
       
   243     if(SDL_MUSTLOCK(surface))
       
   244         SDL_LockSurface(surface);
   243     src = (Uint8 *) pixels;
   245     src = (Uint8 *) pixels;
   244     dst = (Uint8 *) surface->pixels +
   246     dst = (Uint8 *) surface->pixels +
   245                         rect->y * surface->pitch +
   247                         rect->y * surface->pitch +
   246                         rect->x * surface->format->BytesPerPixel;
   248                         rect->x * surface->format->BytesPerPixel;
   247     length = rect->w * surface->format->BytesPerPixel;
   249     length = rect->w * surface->format->BytesPerPixel;
   248     for (row = 0; row < rect->h; ++row) {
   250     for (row = 0; row < rect->h; ++row) {
   249         SDL_memcpy(dst, src, length);
   251         SDL_memcpy(dst, src, length);
   250         src += pitch;
   252         src += pitch;
   251         dst += surface->pitch;
   253         dst += surface->pitch;
   252     }
   254     }
       
   255     if(SDL_MUSTLOCK(surface))
       
   256         SDL_UnlockSurface(surface);
   253     return 0;
   257     return 0;
   254 }
   258 }
   255 
   259 
   256 static int
   260 static int
   257 SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   261 SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,