Browse Source

If scaling fails, fall back to the closest image available in SDL_GetSurfaceImage()

Sam Lantinga 1 năm trước cách đây
mục cha
commit
41f1c83caa
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      src/video/SDL_surface.c

+ 3 - 1
src/video/SDL_surface.c

@@ -555,7 +555,9 @@ SDL_Surface *SDL_GetSurfaceImage(SDL_Surface *surface, float display_scale)
         }
         scaled = next_scaled;
         if (!scaled) {
-            return NULL;
+            // Failure, fall back to the closest surface
+            ++closest->refcount;
+            return closest;
         }
     } while (scaled->w != desired_w || scaled->h != desired_h);