@@ -2277,39 +2277,7 @@ _surf_fblits_cached_item_check_and_blit(pgSurfaceObject *self, PyObject *item,
2277
2277
return FBLITS_ERR_INVALID_SEQUENCE_LENGTH ;
2278
2278
}
2279
2279
2280
- /* load destinations */
2281
- PyObject * * list_items = PySequence_Fast_ITEMS (pos_list );
2282
- Py_ssize_t current_size = 0 ;
2283
- for (i = 0 ; i < destinations -> size ; i ++ ) {
2284
- int x , y ;
2285
- PyObject * tup = list_items [i ];
2286
-
2287
- if (!PyTuple_Check (tup ) || PyTuple_GET_SIZE (tup ) != 2 ) {
2288
- return FBLITS_ERR_TUPLE_REQUIRED ;
2289
- }
2290
-
2291
- if (!pg_IntFromObj (PyTuple_GET_ITEM (tup , 0 ), & x ) ||
2292
- !pg_IntFromObj (PyTuple_GET_ITEM (tup , 1 ), & y )) {
2293
- return FBLITS_ERR_INVALID_DESTINATION ;
2294
- }
2295
-
2296
- SDL_Rect * clip_rect = & dst -> clip_rect ;
2297
- SDL_Rect clipped ;
2298
- if (!SDL_IntersectRect (clip_rect , & (SDL_Rect ){x , y , src -> w , src -> h },
2299
- & clipped ))
2300
- continue ; /* Skip out of bounds destinations */
2301
-
2302
- CachedBlitDest * blit_struct = & destinations -> sequence [current_size ++ ];
2303
-
2304
- blit_struct -> pixels =
2305
- (Uint32 * )dst -> pixels + clipped .y * dst -> pitch / 4 + clipped .x ;
2306
- blit_struct -> w = clipped .w ;
2307
- blit_struct -> h = clipped .h ;
2308
- blit_struct -> x = x < clip_rect -> x ? clip_rect -> x - x : 0 ;
2309
- blit_struct -> y = y < clip_rect -> y ? clip_rect -> y - y : 0 ;
2310
- }
2311
-
2312
- if (!(destinations -> size = current_size ))
2280
+ if (destinations -> size == 0 )
2313
2281
return 0 ;
2314
2282
2315
2283
if (self -> subsurface ) {
@@ -2342,6 +2310,47 @@ _surf_fblits_cached_item_check_and_blit(pgSurfaceObject *self, PyObject *item,
2342
2310
subsurface = NULL ;
2343
2311
}
2344
2312
2313
+ /* load destinations */
2314
+ PyObject * * list_items = PySequence_Fast_ITEMS (pos_list );
2315
+ Py_ssize_t current_size = 0 ;
2316
+ SDL_Rect src_dest = {0 , 0 , src -> w , src -> h };
2317
+ SDL_Rect temp , * argrect ;
2318
+ for (i = 0 ; i < destinations -> size ; i ++ ) {
2319
+ PyObject * item = list_items [i ];
2320
+
2321
+ if (pg_TwoIntsFromObj (item , & src_dest .x , & src_dest .y )) {
2322
+ }
2323
+ else if ((argrect = pgRect_FromObject (item , & temp ))) {
2324
+ src_dest .x = argrect -> x ;
2325
+ src_dest .y = argrect -> y ;
2326
+ }
2327
+ else {
2328
+ return FBLITS_ERR_INVALID_DESTINATION ;
2329
+ }
2330
+
2331
+ SDL_Rect * clip_rect = & dst -> clip_rect ;
2332
+ SDL_Rect clipped ;
2333
+ if (!SDL_IntersectRect (clip_rect , & src_dest , & clipped ))
2334
+ continue ; /* Skip out of bounds destinations */
2335
+
2336
+ CachedBlitDest * d_item = & destinations -> sequence [current_size ++ ];
2337
+
2338
+ d_item -> pixels = (Uint32 * )dst -> pixels ;
2339
+ d_item -> pixels += clipped .y * dst -> pitch / 4 + clipped .x ;
2340
+ d_item -> w = clipped .w ;
2341
+ d_item -> h = clipped .h ;
2342
+ d_item -> x = src_dest .x < clip_rect -> x ? clip_rect -> x - src_dest .x : 0 ;
2343
+ d_item -> y = src_dest .y < clip_rect -> y ? clip_rect -> y - src_dest .y : 0 ;
2344
+ }
2345
+
2346
+ if (!(destinations -> size = current_size )) {
2347
+ if (subsurface )
2348
+ SDL_SetClipRect (subsurface , & orig_clip );
2349
+ else
2350
+ pgSurface_Unprep (self );
2351
+ return 0 ;
2352
+ }
2353
+
2345
2354
pgSurface_Prep ((pgSurfaceObject * )src_surf );
2346
2355
2347
2356
error = SoftCachedBlitPyGame (src , dst , blend_flags , destinations );
0 commit comments