From 64e17b1a443d2278e16782fe8b38080c4cffe024 Mon Sep 17 00:00:00 2001 From: Jia Hao Date: Tue, 18 Jul 2023 12:54:01 +0800 Subject: [PATCH] Minor fixes for C++20 compatibility (flutter/engine#43674) 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(kCGImageAlphaPremultipliedLast | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ 160 | kCGBitmapByteOrder32Big), // CGBitmapInfo bitmapInfo | ~~~~~~~~~~~~~~~~~~~~~~~ ``` --- engine/src/flutter/shell/common/rasterizer.cc | 2 +- .../darwin/ios/framework/Source/FlutterView.mm | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/engine/src/flutter/shell/common/rasterizer.cc b/engine/src/flutter/shell/common/rasterizer.cc index e3daa2d7ca..07de96e39f 100644 --- a/engine/src/flutter/shell/common/rasterizer.cc +++ b/engine/src/flutter/shell/common/rasterizer.cc @@ -88,7 +88,7 @@ void Rasterizer::Setup(std::unique_ptr 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(); diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 32534da9df..daef8b2ab3 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -156,12 +156,13 @@ static BOOL _forceSoftwareRendering; 32, // size_t bitsPerPixel, 4 * screenshot.frame_size.width(), // size_t bytesPerRow colorspace, // CGColorSpaceRef space - static_cast(kCGImageAlphaPremultipliedLast | - kCGBitmapByteOrder32Big), // CGBitmapInfo bitmapInfo - image_data_provider, // CGDataProviderRef provider - nullptr, // const CGFloat* decode - false, // bool shouldInterpolate - kCGRenderingIntentDefault // CGColorRenderingIntent intent + static_cast( + static_cast(kCGImageAlphaPremultipliedLast) | + static_cast(kCGBitmapByteOrder32Big)), // CGBitmapInfo bitmapInfo + image_data_provider, // CGDataProviderRef provider + nullptr, // const CGFloat* decode + false, // bool shouldInterpolate + kCGRenderingIntentDefault // CGColorRenderingIntent intent )); const CGRect frame_rect =