@@ -2162,14 +2162,13 @@ surf_blits(pgSurfaceObject *self, PyObject *args, PyObject *keywds)
2162
2162
#define FBLITS_ERR_INVALID_SEQUENCE 21
2163
2163
2164
2164
int
2165
- _surf_fblits_item_check_and_blit (PyObject * src_surf , SDL_Surface * src ,
2165
+ _surf_fblits_item_check_and_blit (pgSurfaceObject * src_surf , SDL_Surface * src ,
2166
2166
pgSurfaceObject * dest , int x , int y ,
2167
2167
int blend_flags )
2168
2168
{
2169
2169
SDL_Rect dest_rect = {x , y , src -> w , src -> h };
2170
2170
2171
- if (pgSurface_Blit (dest , (pgSurfaceObject * )src_surf , & dest_rect , NULL ,
2172
- blend_flags ))
2171
+ if (pgSurface_Blit (dest , src_surf , & dest_rect , NULL , blend_flags ))
2173
2172
return BLITS_ERR_BLIT_FAIL ;
2174
2173
2175
2174
return 0 ;
@@ -2257,6 +2256,7 @@ _surf_fblits_multiblit_item_check_and_blit(PyObject *src_surf,
2257
2256
Py_ssize_t current_size = 0 ;
2258
2257
SDL_Rect src_dest = {0 , 0 , src -> w , src -> h };
2259
2258
SDL_Rect temp , * argrect ;
2259
+ const SDL_Rect * clip_rect = & dst -> clip_rect ;
2260
2260
for (i = 0 ; i < destinations -> size ; i ++ ) {
2261
2261
PyObject * item = seq_items [i ];
2262
2262
@@ -2273,7 +2273,6 @@ _surf_fblits_multiblit_item_check_and_blit(PyObject *src_surf,
2273
2273
src_dest .x += suboffsetx ;
2274
2274
src_dest .y += suboffsety ;
2275
2275
2276
- SDL_Rect * clip_rect = & dst -> clip_rect ;
2277
2276
SDL_Rect clipped ;
2278
2277
if (!SDL_IntersectRect (clip_rect , & src_dest , & clipped ))
2279
2278
continue ; /* Skip out of bounds destinations */
@@ -2282,12 +2281,12 @@ _surf_fblits_multiblit_item_check_and_blit(PyObject *src_surf,
2282
2281
2283
2282
d_item -> pixels =
2284
2283
(Uint32 * )dst -> pixels + clipped .y * dst -> pitch / 4 + clipped .x ;
2285
-
2286
- d_item -> w = clipped .w ;
2287
- d_item -> h = clipped . h ;
2288
-
2289
- d_item -> x = src_dest .x < clip_rect -> x ? clip_rect -> x - src_dest .x : 0 ;
2290
- d_item -> y = src_dest . y < clip_rect -> y ? clip_rect -> y - src_dest . y : 0 ;
2284
+ d_item -> copy_w = clipped . w * 4 ;
2285
+ d_item -> rows = clipped .h ;
2286
+ d_item -> src_offset =
2287
+ ( src_dest . x < clip_rect -> x ? clip_rect -> x - src_dest . x : 0 ) +
2288
+ ( src_dest .y < clip_rect -> y ? clip_rect -> y - src_dest .y : 0 ) *
2289
+ src -> pitch / 4 ;
2291
2290
}
2292
2291
2293
2292
if (!(destinations -> size = current_size )) {
@@ -2348,14 +2347,17 @@ _surf_fblits_blit(pgSurfaceObject *self, PyObject *item, int blend_flags,
2348
2347
return ;
2349
2348
}
2350
2349
2350
+ if (!src -> w || !src -> h )
2351
+ return ;
2352
+
2351
2353
if (pg_TwoIntsFromObj (pos_or_seq , & x , & y ) ||
2352
2354
(argrect = pgRect_FromObject (pos_or_seq , & temp ))) {
2353
2355
if (argrect ) {
2354
2356
x = argrect -> x ;
2355
2357
y = argrect -> y ;
2356
2358
}
2357
- * error = _surf_fblits_item_check_and_blit (src_surf , src , self , x , y ,
2358
- blend_flags );
2359
+ * error = _surf_fblits_item_check_and_blit (
2360
+ ( pgSurfaceObject * ) src_surf , src , self , x , y , blend_flags );
2359
2361
return ;
2360
2362
}
2361
2363
@@ -2403,9 +2405,8 @@ surf_fblits(pgSurfaceObject *self, PyObject *const *args, Py_ssize_t nargs)
2403
2405
Py_ssize_t i ;
2404
2406
PyObject * * sequence_items = PySequence_Fast_ITEMS (blit_sequence );
2405
2407
for (i = 0 ; i < PySequence_Fast_GET_SIZE (blit_sequence ); i ++ ) {
2406
- item = sequence_items [i ];
2407
-
2408
- _surf_fblits_blit (self , item , blend_flags , & destinations , & error );
2408
+ _surf_fblits_blit (self , sequence_items [i ], blend_flags ,
2409
+ & destinations , & error );
2409
2410
2410
2411
if (error )
2411
2412
goto on_error ;
0 commit comments