Skip to content

Commit 6a1560c

Browse files
authored
Merge pull request #3014 from Starbuck5/remove-unnecessary-subsurf-data
Remove unnecessary pixeloffset member of subsurface data
2 parents 4b5d83d + 8b48d66 commit 6a1560c

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

src_c/_pygame.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ struct pgEventObject {
478478
*/
479479
struct pgSubSurface_Data {
480480
PyObject *owner;
481-
int pixeloffset;
482481
int offsetx, offsety;
483482
};
484483

src_c/surface.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,8 +2557,6 @@ surf_subsurface(PyObject *self, PyObject *args)
25572557
SDL_Rect *rect, temp;
25582558
SDL_Surface *sub;
25592559
PyObject *subobj;
2560-
int pixeloffset;
2561-
char *startpixel;
25622560
struct pgSubSurface_Data *data;
25632561
Uint8 alpha;
25642562
Uint32 colorkey;
@@ -2575,9 +2573,9 @@ surf_subsurface(PyObject *self, PyObject *args)
25752573

25762574
pgSurface_Lock((pgSurfaceObject *)self);
25772575

2578-
pixeloffset =
2579-
rect->x * PG_FORMAT_BytesPerPixel(format) + rect->y * surf->pitch;
2580-
startpixel = ((char *)surf->pixels) + pixeloffset;
2576+
char *startpixel = ((char *)surf->pixels) +
2577+
rect->x * PG_FORMAT_BytesPerPixel(format) +
2578+
rect->y * surf->pitch;
25812579

25822580
sub = PG_CreateSurfaceFrom(startpixel, rect->w, rect->h, surf->pitch,
25832581
format->format);
@@ -2645,7 +2643,6 @@ surf_subsurface(PyObject *self, PyObject *args)
26452643
}
26462644
Py_INCREF(self);
26472645
data->owner = self;
2648-
data->pixeloffset = pixeloffset;
26492646
data->offsetx = rect->x;
26502647
data->offsety = rect->y;
26512648
((pgSurfaceObject *)subobj)->subsurface = data;

src_c/surflock.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ pgSurface_Prep(pgSurfaceObject *surfobj)
4444
{
4545
struct pgSubSurface_Data *data = ((pgSurfaceObject *)surfobj)->subsurface;
4646
if (data != NULL) {
47-
SDL_Surface *surf = pgSurface_AsSurface(surfobj);
48-
SDL_Surface *owner = pgSurface_AsSurface(data->owner);
4947
pgSurface_LockBy((pgSurfaceObject *)data->owner, (PyObject *)surfobj);
50-
surf->pixels = ((char *)owner->pixels) + data->pixeloffset;
5148
}
5249
}
5350

0 commit comments

Comments
 (0)