Skip to content

Commit

Permalink
Remove redundant check in pg_ResizeEventWatch
Browse files Browse the repository at this point in the history
Two locations were checking if `window == pygame_window`, which isn't necessary, because on line 707 the function returns early if `window != pygame_window`
  • Loading branch information
Starbuck5 committed Oct 2, 2023
1 parent dfdf8b8 commit 89d6249
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src_c/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,23 +696,20 @@ pg_ResizeEventWatch(void *userdata, SDL_Event *event)

if (state->unscaled_render && pg_renderer != NULL) {
if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
if (window == pygame_window) {
int w = event->window.data1;
int h = event->window.data2;
pgSurfaceObject *display_surface =
pg_GetDefaultWindowSurface();
SDL_Surface *surf =
PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);
int w = event->window.data1;
int h = event->window.data2;
pgSurfaceObject *display_surface = pg_GetDefaultWindowSurface();
SDL_Surface *surf =
PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);

SDL_FreeSurface(display_surface->surf);
display_surface->surf = surf;
SDL_FreeSurface(display_surface->surf);
display_surface->surf = surf;

SDL_DestroyTexture(pg_texture);
SDL_DestroyTexture(pg_texture);

pg_texture =
SDL_CreateTexture(pg_renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, w, h);
}
pg_texture =
SDL_CreateTexture(pg_renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, w, h);
}
return 0;
}
Expand Down Expand Up @@ -757,12 +754,10 @@ pg_ResizeEventWatch(void *userdata, SDL_Event *event)
}

if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
if (window == pygame_window) {
SDL_Surface *sdl_surface = SDL_GetWindowSurface(window);
pgSurfaceObject *old_surface = pg_GetDefaultWindowSurface();
if (sdl_surface != old_surface->surf) {
old_surface->surf = sdl_surface;
}
SDL_Surface *sdl_surface = SDL_GetWindowSurface(window);
pgSurfaceObject *old_surface = pg_GetDefaultWindowSurface();
if (sdl_surface != old_surface->surf) {
old_surface->surf = sdl_surface;
}
}
return 0;
Expand Down

0 comments on commit 89d6249

Please sign in to comment.