Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary pixeloffset member of subsurface data #3014

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@ struct pgEventObject {
*/
struct pgSubSurface_Data {
PyObject *owner;
int pixeloffset;
int offsetx, offsety;
};

Expand Down
9 changes: 3 additions & 6 deletions src_c/surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2557,8 +2557,6 @@ surf_subsurface(PyObject *self, PyObject *args)
SDL_Rect *rect, temp;
SDL_Surface *sub;
PyObject *subobj;
int pixeloffset;
char *startpixel;
struct pgSubSurface_Data *data;
Uint8 alpha;
Uint32 colorkey;
Expand All @@ -2575,9 +2573,9 @@ surf_subsurface(PyObject *self, PyObject *args)

pgSurface_Lock((pgSurfaceObject *)self);

pixeloffset =
rect->x * PG_FORMAT_BytesPerPixel(format) + rect->y * surf->pitch;
startpixel = ((char *)surf->pixels) + pixeloffset;
char *startpixel = ((char *)surf->pixels) +
rect->x * PG_FORMAT_BytesPerPixel(format) +
rect->y * surf->pitch;

sub = PG_CreateSurfaceFrom(startpixel, rect->w, rect->h, surf->pitch,
format->format);
Expand Down Expand Up @@ -2645,7 +2643,6 @@ surf_subsurface(PyObject *self, PyObject *args)
}
Py_INCREF(self);
data->owner = self;
data->pixeloffset = pixeloffset;
data->offsetx = rect->x;
data->offsety = rect->y;
((pgSurfaceObject *)subobj)->subsurface = data;
Expand Down
3 changes: 0 additions & 3 deletions src_c/surflock.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ pgSurface_Prep(pgSurfaceObject *surfobj)
{
struct pgSubSurface_Data *data = ((pgSurfaceObject *)surfobj)->subsurface;
if (data != NULL) {
SDL_Surface *surf = pgSurface_AsSurface(surfobj);
SDL_Surface *owner = pgSurface_AsSurface(data->owner);
pgSurface_LockBy((pgSurfaceObject *)data->owner, (PyObject *)surfobj);
surf->pixels = ((char *)owner->pixels) + data->pixeloffset;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code being removed here is so weird, I wonder if there was any intention behind this... IG we will never know

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I investigated a little further, it's been like this since surflock.c was created 24 years ago! pygame/pygame@45784b3

}
}

Expand Down
Loading