Skip to content

Commit 0325472

Browse files
committed
Now properly supporting all rects/rectlike as positions, minor changes and renames
1 parent b7a7d78 commit 0325472

File tree

3 files changed

+16
-28
lines changed

3 files changed

+16
-28
lines changed

src_c/alphablit.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,13 @@ pg_multi_blitcopy(SDL_Surface *src, SDL_Surface *dst,
594594
BlitSequence *destinations)
595595
{
596596
Py_ssize_t i;
597+
const int src_skip = src->pitch / 4;
598+
const int dst_skip = dst->pitch / 4;
599+
597600
for (i = 0; i < destinations->size; i++) {
598-
CachedBlitDest *item = &destinations->sequence[i];
601+
BlitDestination *item = &destinations->sequence[i];
599602

600603
const int src_pitch = item->w * sizeof(Uint32);
601-
const int src_skip = src->pitch / 4;
602-
const int dst_skip = dst->pitch / 4;
603604

604605
Uint32 *srcp32 = (Uint32 *)src->pixels + item->x + item->y * src_skip;
605606
Uint32 *dstp32 = item->pixels;

src_c/surface.c

+10-23
Original file line numberDiff line numberDiff line change
@@ -2205,8 +2205,8 @@ _surf_fblits_multiblit_item_check_and_blit(PyObject *src_surf,
22052205
/* manage destinations memory */
22062206
Py_ssize_t new_size = PySequence_Fast_GET_SIZE(pos_sequence);
22072207
if (new_size > destinations->alloc_size) {
2208-
destinations->sequence = (CachedBlitDest *)realloc(
2209-
destinations->sequence, new_size * sizeof(CachedBlitDest));
2208+
destinations->sequence = (BlitDestination *)realloc(
2209+
destinations->sequence, new_size * sizeof(BlitDestination));
22102210

22112211
if (!destinations->sequence)
22122212
return FBLITS_ERR_NO_MEMORY;
@@ -2222,9 +2222,6 @@ _surf_fblits_multiblit_item_check_and_blit(PyObject *src_surf,
22222222
return FBLITS_ERR_INVALID_SEQUENCE_LENGTH;
22232223
}
22242224

2225-
if (destinations->size == 0)
2226-
return 0;
2227-
22282225
if (self->subsurface) {
22292226
PyObject *owner;
22302227
struct pgSubSurface_Data *subdata;
@@ -2281,7 +2278,7 @@ _surf_fblits_multiblit_item_check_and_blit(PyObject *src_surf,
22812278
if (!SDL_IntersectRect(clip_rect, &src_dest, &clipped))
22822279
continue; /* Skip out of bounds destinations */
22832280

2284-
CachedBlitDest *d_item = &destinations->sequence[current_size++];
2281+
BlitDestination *d_item = &destinations->sequence[current_size++];
22852282

22862283
d_item->pixels =
22872284
(Uint32 *)dst->pixels + clipped.y * dst->pitch / 4 + clipped.x;
@@ -2323,6 +2320,7 @@ _surf_fblits_blit(pgSurfaceObject *self, PyObject *item, int blend_flags,
23232320
{
23242321
PyObject *src_surf, *pos_or_seq;
23252322
SDL_Surface *src, *dst = pgSurface_AsSurface(self);
2323+
SDL_Rect temp, *argrect = NULL;
23262324
if (!dst) {
23272325
*error = BLITS_ERR_DISPLAY_SURF_QUIT;
23282326
return;
@@ -2350,23 +2348,12 @@ _surf_fblits_blit(pgSurfaceObject *self, PyObject *item, int blend_flags,
23502348
return;
23512349
}
23522350

2353-
if (pgRect_Check(pos_or_seq)) {
2354-
SDL_Rect *r = &pgRect_AsRect(pos_or_seq);
2355-
x = r->x;
2356-
y = r->y;
2357-
*error = _surf_fblits_item_check_and_blit(src_surf, src, self, x, y,
2358-
blend_flags);
2359-
return;
2360-
}
2361-
else if (pgFRect_Check(pos_or_seq)) {
2362-
SDL_FRect *r = &pgFRect_AsRect(pos_or_seq);
2363-
x = (int)r->x;
2364-
y = (int)r->y;
2365-
*error = _surf_fblits_item_check_and_blit(src_surf, src, self, x, y,
2366-
blend_flags);
2367-
return;
2368-
}
2369-
else if (pg_TwoIntsFromObj(pos_or_seq, &x, &y)) {
2351+
if (pg_TwoIntsFromObj(pos_or_seq, &x, &y) ||
2352+
(argrect = pgRect_FromObject(pos_or_seq, &temp))) {
2353+
if (argrect) {
2354+
x = argrect->x;
2355+
y = argrect->y;
2356+
}
23702357
*error = _surf_fblits_item_check_and_blit(src_surf, src, self, x, y,
23712358
blend_flags);
23722359
return;

src_c/surface.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@
340340
typedef struct {
341341
Uint32 *pixels;
342342
int w, h, x, y;
343-
} CachedBlitDest;
343+
} BlitDestination;
344344

345345
typedef struct {
346-
CachedBlitDest *sequence;
346+
BlitDestination *sequence;
347347
Py_ssize_t alloc_size;
348348
Py_ssize_t size;
349349
} BlitSequence;

0 commit comments

Comments
 (0)