-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Replace deprecated UIGraphicsBeginImageContextWithOptions with UIGraphicsImageRenderer #6285
Conversation
e24413e
to
8854f33
Compare
if ((originalWidth == maxWidth.doubleValue && originalHeight == maxHeight.doubleValue) || | ||
(!hasMaxWidth && !hasMaxHeight)) { | ||
// Nothing to scale. | ||
return image; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is new, and unrelated to the fix. If there is nothing to scale, return the original image instead of doing extra work.
…hicsImageRenderer
XCTAssertEqual(scaledImage.size.height, scaledHeight); | ||
|
||
// Check the corners. Format is "R G B A" | ||
XCTAssertEqualObjects(ColorStringAtPixel(scaledImage, 0, 0), @"1 0.776471 0 1"); // yellow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: How about making these color string representations (e.g. @"1 0.776471 0 1"
) consts with descriptive names so they can be reused and seem less like a magic value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that for the two tests that are the same. These exact values would changes based on how small the image is scaled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a small suggestion
…h UIGraphicsImageRenderer (flutter/packages#6285)
flutter/packages@38711ac...b21c542 2024-03-14 [email protected] Support overriding `ErrorWidget.builder` (flutter/packages#6302) 2024-03-13 [email protected] Manual roll Flutter from 61812ca to 394269f (6 revisions) (flutter/packages#6320) 2024-03-13 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.1.1 to 4.1.2 (flutter/packages#6309) 2024-03-13 [email protected] Replace deprecated UIGraphicsBeginImageContextWithOptions with UIGraphicsImageRenderer (flutter/packages#6285) 2024-03-13 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.24.6 to 3.24.7 (flutter/packages#6310) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…hicsImageRenderer (flutter#6285) `UIGraphicsBeginImageContextWithOptions` isn't technically deprecated, but `API_TO_BE_DEPRECATED`. However, according to reports it's crashing in iOS 17. Replace usage with `UIGraphicsImageRenderer`, available in iOS 10. I kept introducing horizontal flipping bugs when I was writing this, but it wasn't causing test failures. Changed the test images from a single color to a gradient with different colors in each corner, then updated the tests to confirm the orientation is still correct. Generated the test image with ImageMagick: ``` magick \( xc:red xc:blue +append \) \( xc:yellow xc:cyan +append \) -append -filter triangle -resize 12x7\! jpgImage.jpg ``` Also avoid doing extra work if there's nothing to scale, and return the original image. Fixes flutter/flutter#144602
UIGraphicsBeginImageContextWithOptions
isn't technically deprecated, butAPI_TO_BE_DEPRECATED
. However, according to reports it's crashing in iOS 17. Replace usage withUIGraphicsImageRenderer
, available in iOS 10.I kept introducing horizontal flipping bugs when I was writing this, but it wasn't causing test failures. Changed the test images from a single color to a gradient with different colors in each corner, then updated the tests to confirm the orientation is still correct.
Generated the test image with ImageMagick:
Also avoid doing extra work if there's nothing to scale, and return the original image.
Fixes flutter/flutter#144602