Skip to content

Commit 56bcd0c

Browse files
authored
[google_maps_flutter_ios] Fix kCGImageAlphaPremultipliedLast implicit conversion from enumeration type (#9720)
[Docs for `CGBitmapContextCreate ` `bitmapInfo`](https://developer.apple.com/documentation/coregraphics/cgcontext/init(data:width:height:bitspercomponent:bytesperrow:space:bitmapinfo:)?language=objc) parameter say: > The constants for specifying the alpha channel information are declared with the [CGImageAlphaInfo](https://developer.apple.com/documentation/coregraphics/cgimagealphainfo?language=objc) type but can be passed to this parameter safely. You can also pass the other constants associated with the [CGBitmapInfo](https://developer.apple.com/documentation/coregraphics/cgbitmapinfo?language=objc) type. The docs still [show `kCGImageAlphaPremultipliedLast` being passed in directly](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_context/dq_context.html#//apple_ref/doc/uid/TP30001066-CH203-CJBHBFFE). Instead of casting to `CGBitmapInfo` (which would also work I believe), use [`kCGBitmapAlphaInfoMask`](https://developer.apple.com/documentation/coregraphics/cgbitmapinfo/kcgbitmapalphainfomask). Further explanation at inkling/Subliminal#23 (comment). Tested here: https://github.com/flutter/packages/blob/b2aef15c15a75ac6853dc1b79ee2ad2086934f58/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsTests.m#L81 Fixes flutter/flutter#170440 ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 0727ed3 commit 56bcd0c

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.15.5
2+
3+
* Fixes `kCGImageAlphaPremultipliedLast` implicit conversion from enumeration type warning.
4+
15
## 2.15.4
26

37
* Deprecates `zIndex` parameter in Marker in favor of `zIndexInt`.

packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsTests.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ - (void)testHandleResultTileDownsamplesWideGamutImages {
8484
size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef);
8585

8686
// non wide gamut images use 8 bit format
87-
XCTAssert(bitsPerComponent == 8);
87+
XCTAssertEqual(bitsPerComponent, 8);
88+
XCTAssertEqual(CGImageGetAlphaInfo(imageRef), kCGImageAlphaPremultipliedLast);
8889
}
8990

9091
- (void)testAnimateCameraWithUpdate {

packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ - (UIImage *)handleResultTile:(nullable UIImage *)tile {
9696
// If it is wide gamut, we want to downsample it
9797
if (isFloat & (bitsPerComponent == 16)) {
9898
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
99-
CGContextRef context = CGBitmapContextCreate(nil, tile.size.width, tile.size.height, 8, 0,
100-
colorSpace, kCGImageAlphaPremultipliedLast);
99+
CGContextRef context =
100+
CGBitmapContextCreate(nil, tile.size.width, tile.size.height, 8, 0, colorSpace,
101+
(kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedLast));
101102
CGContextDrawImage(context, CGRectMake(0, 0, tile.size.width, tile.size.height), tile.CGImage);
102103
CGImageRef image = CGBitmapContextCreateImage(context);
103104
tile = [UIImage imageWithCGImage:image];

packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter_ios
22
description: iOS implementation of the google_maps_flutter plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
5-
version: 2.15.4
5+
version: 2.15.5
66

77
environment:
88
sdk: ^3.6.0

0 commit comments

Comments
 (0)