Skip to content

Commit

Permalink
Minor fixes for C++20 compatibility (#43674)
Browse files Browse the repository at this point in the history
Fixes the following errors when building with a C++20 toolchain.

I don't really know C++ that well so any pointers would be appreciated. 

For the change to the lambda, we can't follow the recommendation to capture `*this` explicitly because that wouldn't compile under C++17. This PR changes the semantics slightly to capture `surface_` by reference, which might be still okay?

For b/289776142

```
error: implicit capture of 'this' with a capture default of '=' is deprecated [-Werror,-Wdeprecated-this-capture]
   93 |       if (surface_) {
      |           ^
note: add an explicit capture of 'this' to capture '*this' by reference
   91 |     raster_thread_merger_->SetMergeUnmergeCallback([=]() {
      |                                                     ^
      |                                                      , this
```

```
error: bitwise operation between different enumeration types ('CGImageAlphaInfo' and '(unnamed enum at third_party/apple_sdks/xcode_14_2/iphonesimulator/System/Library/Frameworks/CoreGraphics.framework/Headers/CGImage.h:53:9)') is deprecated [-Werror,-Wdeprecated-anon-enum-enum-conversion]
  159 |       static_cast<CGBitmapInfo>(kCGImageAlphaPremultipliedLast |
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
  160 |                                 kCGBitmapByteOrder32Big),  // CGBitmapInfo bitmapInfo
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~
```
  • Loading branch information
jiahaog authored Jul 18, 2023
1 parent 97b6aee commit 4d8704f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void Rasterizer::Setup(std::unique_ptr<Surface> surface) {
delegate_.GetParentRasterThreadMerger(), platform_id, gpu_id);
}
if (raster_thread_merger_) {
raster_thread_merger_->SetMergeUnmergeCallback([=]() {
raster_thread_merger_->SetMergeUnmergeCallback([this]() {
// Clear the GL context after the thread configuration has changed.
if (surface_) {
surface_->ClearRenderContext();
Expand Down
13 changes: 7 additions & 6 deletions shell/platform/darwin/ios/framework/Source/FlutterView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,13 @@ - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context {
32, // size_t bitsPerPixel,
4 * screenshot.frame_size.width(), // size_t bytesPerRow
colorspace, // CGColorSpaceRef space
static_cast<CGBitmapInfo>(kCGImageAlphaPremultipliedLast |
kCGBitmapByteOrder32Big), // CGBitmapInfo bitmapInfo
image_data_provider, // CGDataProviderRef provider
nullptr, // const CGFloat* decode
false, // bool shouldInterpolate
kCGRenderingIntentDefault // CGColorRenderingIntent intent
static_cast<CGBitmapInfo>(
static_cast<uint32_t>(kCGImageAlphaPremultipliedLast) |
static_cast<uint32_t>(kCGBitmapByteOrder32Big)), // CGBitmapInfo bitmapInfo
image_data_provider, // CGDataProviderRef provider
nullptr, // const CGFloat* decode
false, // bool shouldInterpolate
kCGRenderingIntentDefault // CGColorRenderingIntent intent
));

const CGRect frame_rect =
Expand Down

0 comments on commit 4d8704f

Please sign in to comment.