removed c style casts and enabled the lint (flutter/engine#57162)

test exempt: should have no functional change

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++,
Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I added new tests to check the change I am making or feature I am
adding, or the PR is [test-exempt]. See [testing the engine] for
instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I signed the [CLA].
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/engine/blob/main/docs/testing/Testing-the-engine.md
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md
This commit is contained in:
gaaclarke 2024-12-12 15:33:37 -08:00 committed by GitHub
parent fda902f593
commit 3d8fc3c652
33 changed files with 177 additions and 149 deletions

View File

@ -17,7 +17,6 @@ Checks: >-
-google-default-arguments,
-google-objc-global-variable-declaration,
-google-objc-avoid-throwing-exception,
-google-readability-casting,
-clang-analyzer-nullability.NullPassedToNonnull,
-clang-analyzer-nullability.NullablePassedToNonnull,
-clang-analyzer-nullability.NullReturnedFromNonnull,

View File

@ -176,7 +176,7 @@ sk_sp<SkData> ParseBase64(const std::string& input) {
size_t output_len;
error = Base64::Decode(input.c_str(), input.length(), nullptr, &output_len);
if (error != Base64::Error::kNone) {
FML_LOG(ERROR) << "Base64 decode error: " << (int)error;
FML_LOG(ERROR) << "Base64 decode error: " << static_cast<int>(error);
FML_LOG(ERROR) << "Base64 can't decode: " << input;
return nullptr;
}
@ -185,7 +185,7 @@ sk_sp<SkData> ParseBase64(const std::string& input) {
void* output = data->writable_data();
error = Base64::Decode(input.c_str(), input.length(), output, &output_len);
if (error != Base64::Error::kNone) {
FML_LOG(ERROR) << "Base64 decode error: " << (int)error;
FML_LOG(ERROR) << "Base64 decode error: " << static_cast<int>(error);
FML_LOG(ERROR) << "Base64 can't decode: " << input;
return nullptr;
}

View File

@ -61,7 +61,7 @@ DlRegion::SpanChunkHandle DlRegion::SpanBuffer::storeChunk(const Span* begin,
size_t min_capacity = size_ + chunk_size + 1;
if (capacity_ < min_capacity) {
size_t new_capacity = std::max(min_capacity, capacity_ * 2);
new_capacity = std::max(new_capacity, size_t(512));
new_capacity = std::max(new_capacity, static_cast<size_t>(512));
reserve(new_capacity);
}
SpanChunkHandle res = size_;

View File

@ -123,7 +123,9 @@
"__std_stream": "cpp",
"*.ipp": "cpp",
"csetjmp": "cpp",
"cfenv": "cpp"
"cfenv": "cpp",
"execution": "cpp",
"print": "cpp"
},
"C_Cpp.default.includePath": [
"${default}",

View File

@ -42,7 +42,7 @@ void BackdropFilterLayer::Diff(DiffContext* context, const Layer* old_layer) {
void BackdropFilterLayer::Preroll(PrerollContext* context) {
Layer::AutoPrerollSaveLayerState save =
Layer::AutoPrerollSaveLayerState::Create(context, true, bool(filter_));
Layer::AutoPrerollSaveLayerState::Create(context, true, bool{filter_});
if (filter_ && context->view_embedder != nullptr) {
context->view_embedder->PushFilterToVisitedPlatformViews(
filter_, ToSkRect(context->state_stack.device_cull_rect()));

View File

@ -41,11 +41,11 @@ constexpr T ByteSwap(T n) {
if constexpr (sizeof(T) == 1) {
return n;
} else if constexpr (sizeof(T) == 2) {
return (T)FML_BYTESWAP_16((uint16_t)n);
return static_cast<T>(FML_BYTESWAP_16((uint16_t)n));
} else if constexpr (sizeof(T) == 4) {
return (T)FML_BYTESWAP_32((uint32_t)n);
return static_cast<T>(FML_BYTESWAP_32((uint32_t)n));
} else if constexpr (sizeof(T) == 8) {
return (T)FML_BYTESWAP_64((uint64_t)n);
return static_cast<T>(FML_BYTESWAP_64((uint64_t)n));
} else {
static_assert(!sizeof(T), "Unsupported size");
}

View File

@ -1014,7 +1014,8 @@ void Canvas::SaveLayer(const Paint& paint,
subpass_size = ISize(subpass_coverage.GetSize());
} else {
did_round_out = true;
subpass_size = ISize(IRect::RoundOut(subpass_coverage).GetSize());
subpass_size =
static_cast<ISize>(IRect::RoundOut(subpass_coverage).GetSize());
}
if (subpass_size.IsEmpty()) {
return SkipUntilMatchingRestore(total_content_depth);

View File

@ -64,7 +64,7 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
Point center = points_[0];
for (auto& vertex : circle_vertices) {
output[offset++] = Point(center + vertex);
output[offset++] = static_cast<Point>(center + vertex);
}
// For all subequent points, insert a degenerate triangle to break
// the strip. This could be optimized out if we switched to using
@ -73,9 +73,9 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
for (size_t i = 1; i < point_count_; i++) {
Point center = points_[i];
output[offset++] = last_point;
output[offset++] = Point(center + circle_vertices[0]);
output[offset++] = static_cast<Point>(center + circle_vertices[0]);
for (const Point& vertex : circle_vertices) {
output[offset++] = Point(center + vertex);
output[offset++] = static_cast<Point>(center + vertex);
}
last_point = circle_vertices.back() + center;
}

View File

@ -56,8 +56,8 @@ constexpr Scalar kRatioStep =
Scalar LerpPrecomputedVariable(size_t column, Scalar ratio) {
Scalar steps =
std::clamp<Scalar>((ratio - kMinRatio) / kRatioStep, 0, kNumRecords - 1);
size_t left =
std::clamp<size_t>((size_t)std::floor(steps), 0, kNumRecords - 2);
size_t left = std::clamp<size_t>(static_cast<size_t>(std::floor(steps)), 0,
kNumRecords - 2);
Scalar frac = steps - left;
return (1 - frac) * kPrecomputedVariables[left][column] +
@ -95,7 +95,8 @@ Scalar CalculateStep(Scalar minDimension, Scalar fullAngle) {
// Assumes at least 1 point is needed per pixel to achieve sufficient
// smoothness.
constexpr Scalar pointsPerPixel = 1.0;
size_t pointsByDimension = (size_t)std::ceil(minDimension * pointsPerPixel);
size_t pointsByDimension =
static_cast<size_t>(std::ceil(minDimension * pointsPerPixel));
Scalar angleByDimension = fullAngle / pointsByDimension;
return std::min(kMinAngleStep, angleByDimension);

View File

@ -86,14 +86,16 @@ class HandleGLES {
HandleGLES(HandleType p_type, UniqueID p_name)
: type_(p_type),
name_(p_name),
hash_(fml::HashCombine(std::underlying_type_t<decltype(p_type)>(p_type),
p_name)) {}
hash_(fml::HashCombine(
static_cast<std::underlying_type_t<decltype(p_type)>>(p_type),
p_name)) {}
HandleGLES(HandleType p_type, std::optional<UniqueID> p_name)
: type_(p_type),
name_(p_name),
hash_(fml::HashCombine(std::underlying_type_t<decltype(p_type)>(p_type),
p_name)) {}
hash_(fml::HashCombine(
static_cast<std::underlying_type_t<decltype(p_type)>>(p_type),
p_name)) {}
static HandleGLES Create(HandleType type) {
return HandleGLES{type, UniqueID{}};

View File

@ -57,12 +57,12 @@ ShaderLibraryGLES::ShaderLibraryGLES(
) -> bool {
const auto stage = ToShaderStage(type);
const auto key_name = GLESShaderNameToShaderKeyName(name, stage);
functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>(
functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>{
new ShaderFunctionGLES(library_id, //
stage, //
key_name, //
mapping //
));
)};
return true;
};

View File

@ -62,8 +62,8 @@ static std::string JoinVKDebugUtilsObjectNameInfoEXT(
size_t count) {
std::stringstream stream;
for (size_t i = 0u; i < count; i++) {
stream << vk::to_string(vk::ObjectType(names[i].objectType)) << " ["
<< names[i].objectHandle << "] [";
stream << vk::to_string(static_cast<vk::ObjectType>(names[i].objectType))
<< " [" << names[i].objectHandle << "] [";
if (names[i].pObjectName != nullptr) {
stream << names[i].pObjectName;
} else {

View File

@ -754,143 +754,154 @@ void vkDestroyFramebuffer(VkDevice device,
PFN_vkVoidFunction GetMockVulkanProcAddress(VkInstance instance,
const char* pName) {
if (strcmp("vkEnumerateInstanceExtensionProperties", pName) == 0) {
return (PFN_vkVoidFunction)vkEnumerateInstanceExtensionProperties;
return reinterpret_cast<PFN_vkVoidFunction>(
vkEnumerateInstanceExtensionProperties);
} else if (strcmp("vkEnumerateInstanceLayerProperties", pName) == 0) {
return (PFN_vkVoidFunction)vkEnumerateInstanceLayerProperties;
return reinterpret_cast<PFN_vkVoidFunction>(
vkEnumerateInstanceLayerProperties);
} else if (strcmp("vkEnumeratePhysicalDevices", pName) == 0) {
return (PFN_vkVoidFunction)vkEnumeratePhysicalDevices;
return reinterpret_cast<PFN_vkVoidFunction>(vkEnumeratePhysicalDevices);
} else if (strcmp("vkGetPhysicalDeviceFormatProperties", pName) == 0) {
return (PFN_vkVoidFunction)vkGetPhysicalDeviceFormatProperties;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetPhysicalDeviceFormatProperties);
} else if (strcmp("vkGetPhysicalDeviceProperties", pName) == 0) {
return (PFN_vkVoidFunction)vkGetPhysicalDeviceProperties;
return reinterpret_cast<PFN_vkVoidFunction>(vkGetPhysicalDeviceProperties);
} else if (strcmp("vkGetPhysicalDeviceQueueFamilyProperties", pName) == 0) {
return (PFN_vkVoidFunction)vkGetPhysicalDeviceQueueFamilyProperties;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetPhysicalDeviceQueueFamilyProperties);
} else if (strcmp("vkEnumerateDeviceExtensionProperties", pName) == 0) {
return (PFN_vkVoidFunction)vkEnumerateDeviceExtensionProperties;
return reinterpret_cast<PFN_vkVoidFunction>(
vkEnumerateDeviceExtensionProperties);
} else if (strcmp("vkCreateDevice", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateDevice;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateDevice);
} else if (strcmp("vkCreateInstance", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateInstance;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateInstance);
} else if (strcmp("vkGetPhysicalDeviceMemoryProperties", pName) == 0) {
return (PFN_vkVoidFunction)vkGetPhysicalDeviceMemoryProperties;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetPhysicalDeviceMemoryProperties);
} else if (strcmp("vkCreatePipelineCache", pName) == 0) {
return (PFN_vkVoidFunction)vkCreatePipelineCache;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreatePipelineCache);
} else if (strcmp("vkCreateCommandPool", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateCommandPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateCommandPool);
} else if (strcmp("vkResetCommandPool", pName) == 0) {
return (PFN_vkVoidFunction)vkResetCommandPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkResetCommandPool);
} else if (strcmp("vkAllocateCommandBuffers", pName) == 0) {
return (PFN_vkVoidFunction)vkAllocateCommandBuffers;
return reinterpret_cast<PFN_vkVoidFunction>(vkAllocateCommandBuffers);
} else if (strcmp("vkBeginCommandBuffer", pName) == 0) {
return (PFN_vkVoidFunction)vkBeginCommandBuffer;
return reinterpret_cast<PFN_vkVoidFunction>(vkBeginCommandBuffer);
} else if (strcmp("vkCreateImage", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateImage;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateImage);
} else if (strcmp("vkGetInstanceProcAddr", pName) == 0) {
return (PFN_vkVoidFunction)GetMockVulkanProcAddress;
return reinterpret_cast<PFN_vkVoidFunction>(GetMockVulkanProcAddress);
} else if (strcmp("vkGetDeviceProcAddr", pName) == 0) {
return (PFN_vkVoidFunction)GetMockVulkanProcAddress;
return reinterpret_cast<PFN_vkVoidFunction>(GetMockVulkanProcAddress);
} else if (strcmp("vkGetImageMemoryRequirements2KHR", pName) == 0 ||
strcmp("vkGetImageMemoryRequirements2", pName) == 0) {
return (PFN_vkVoidFunction)vkGetImageMemoryRequirements2KHR;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetImageMemoryRequirements2KHR);
} else if (strcmp("vkAllocateMemory", pName) == 0) {
return (PFN_vkVoidFunction)vkAllocateMemory;
return reinterpret_cast<PFN_vkVoidFunction>(vkAllocateMemory);
} else if (strcmp("vkBindImageMemory", pName) == 0) {
return (PFN_vkVoidFunction)vkBindImageMemory;
return reinterpret_cast<PFN_vkVoidFunction>(vkBindImageMemory);
} else if (strcmp("vkCreateImageView", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateImageView;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateImageView);
} else if (strcmp("vkCreateBuffer", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateBuffer;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateBuffer);
} else if (strcmp("vkGetBufferMemoryRequirements2KHR", pName) == 0 ||
strcmp("vkGetBufferMemoryRequirements2", pName) == 0) {
return (PFN_vkVoidFunction)vkGetBufferMemoryRequirements2KHR;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetBufferMemoryRequirements2KHR);
} else if (strcmp("vkBindBufferMemory", pName) == 0) {
return (PFN_vkVoidFunction)vkBindBufferMemory;
return reinterpret_cast<PFN_vkVoidFunction>(vkBindBufferMemory);
} else if (strcmp("vkCreateRenderPass", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateRenderPass;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateRenderPass);
} else if (strcmp("vkCreateDescriptorSetLayout", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateDescriptorSetLayout;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateDescriptorSetLayout);
} else if (strcmp("vkCreatePipelineLayout", pName) == 0) {
return (PFN_vkVoidFunction)vkCreatePipelineLayout;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreatePipelineLayout);
} else if (strcmp("vkCreateGraphicsPipelines", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateGraphicsPipelines;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateGraphicsPipelines);
} else if (strcmp("vkDestroyDevice", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyDevice;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyDevice);
} else if (strcmp("vkDestroyPipeline", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyPipeline;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyPipeline);
} else if (strcmp("vkCreateShaderModule", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateShaderModule;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateShaderModule);
} else if (strcmp("vkDestroyShaderModule", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyShaderModule;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyShaderModule);
} else if (strcmp("vkDestroyPipelineCache", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyPipelineCache;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyPipelineCache);
} else if (strcmp("vkCmdBindPipeline", pName) == 0) {
return (PFN_vkVoidFunction)vkCmdBindPipeline;
return reinterpret_cast<PFN_vkVoidFunction>(vkCmdBindPipeline);
} else if (strcmp("vkCmdSetStencilReference", pName) == 0) {
return (PFN_vkVoidFunction)vkCmdSetStencilReference;
return reinterpret_cast<PFN_vkVoidFunction>(vkCmdSetStencilReference);
} else if (strcmp("vkCmdSetScissor", pName) == 0) {
return (PFN_vkVoidFunction)vkCmdSetScissor;
return reinterpret_cast<PFN_vkVoidFunction>(vkCmdSetScissor);
} else if (strcmp("vkCmdSetViewport", pName) == 0) {
return (PFN_vkVoidFunction)vkCmdSetViewport;
return reinterpret_cast<PFN_vkVoidFunction>(vkCmdSetViewport);
} else if (strcmp("vkDestroyCommandPool", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyCommandPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyCommandPool);
} else if (strcmp("vkFreeCommandBuffers", pName) == 0) {
return (PFN_vkVoidFunction)vkFreeCommandBuffers;
return reinterpret_cast<PFN_vkVoidFunction>(vkFreeCommandBuffers);
} else if (strcmp("vkEndCommandBuffer", pName) == 0) {
return (PFN_vkVoidFunction)vkEndCommandBuffer;
return reinterpret_cast<PFN_vkVoidFunction>(vkEndCommandBuffer);
} else if (strcmp("vkCreateFence", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateFence;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateFence);
} else if (strcmp("vkDestroyFence", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyFence;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyFence);
} else if (strcmp("vkQueueSubmit", pName) == 0) {
return (PFN_vkVoidFunction)vkQueueSubmit;
return reinterpret_cast<PFN_vkVoidFunction>(vkQueueSubmit);
} else if (strcmp("vkWaitForFences", pName) == 0) {
return (PFN_vkVoidFunction)vkWaitForFences;
return reinterpret_cast<PFN_vkVoidFunction>(vkWaitForFences);
} else if (strcmp("vkGetFenceStatus", pName) == 0) {
return (PFN_vkVoidFunction)vkGetFenceStatus;
return reinterpret_cast<PFN_vkVoidFunction>(vkGetFenceStatus);
} else if (strcmp("vkResetFences", pName) == 0) {
return (PFN_vkVoidFunction)vkResetFences;
return reinterpret_cast<PFN_vkVoidFunction>(vkResetFences);
} else if (strcmp("vkCreateDebugUtilsMessengerEXT", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateDebugUtilsMessengerEXT;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateDebugUtilsMessengerEXT);
} else if (strcmp("vkSetDebugUtilsObjectNameEXT", pName) == 0) {
return (PFN_vkVoidFunction)vkSetDebugUtilsObjectNameEXT;
return reinterpret_cast<PFN_vkVoidFunction>(vkSetDebugUtilsObjectNameEXT);
} else if (strcmp("vkCreateQueryPool", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateQueryPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateQueryPool);
} else if (strcmp("vkDestroyQueryPool", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyQueryPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyQueryPool);
} else if (strcmp("vkGetQueryPoolResults", pName) == 0) {
return (PFN_vkVoidFunction)vkGetQueryPoolResults;
return reinterpret_cast<PFN_vkVoidFunction>(vkGetQueryPoolResults);
} else if (strcmp("vkCreateDescriptorPool", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateDescriptorPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateDescriptorPool);
} else if (strcmp("vkDestroyDescriptorPool", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyDescriptorPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyDescriptorPool);
} else if (strcmp("vkResetDescriptorPool", pName) == 0) {
return (PFN_vkVoidFunction)vkResetDescriptorPool;
return reinterpret_cast<PFN_vkVoidFunction>(vkResetDescriptorPool);
} else if (strcmp("vkAllocateDescriptorSets", pName) == 0) {
return (PFN_vkVoidFunction)vkAllocateDescriptorSets;
return reinterpret_cast<PFN_vkVoidFunction>(vkAllocateDescriptorSets);
} else if (strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkGetPhysicalDeviceSurfaceFormatsKHR;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetPhysicalDeviceSurfaceFormatsKHR);
} else if (strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetPhysicalDeviceSurfaceCapabilitiesKHR);
} else if (strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkGetPhysicalDeviceSurfaceSupportKHR;
return reinterpret_cast<PFN_vkVoidFunction>(
vkGetPhysicalDeviceSurfaceSupportKHR);
} else if (strcmp("vkCreateSwapchainKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateSwapchainKHR;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateSwapchainKHR);
} else if (strcmp("vkDestroySwapchainKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroySwapchainKHR;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroySwapchainKHR);
} else if (strcmp("vkGetSwapchainImagesKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkGetSwapchainImagesKHR;
return reinterpret_cast<PFN_vkVoidFunction>(vkGetSwapchainImagesKHR);
} else if (strcmp("vkCreateSemaphore", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateSemaphore;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateSemaphore);
} else if (strcmp("vkDestroySemaphore", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroySemaphore;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroySemaphore);
} else if (strcmp("vkDestroySurfaceKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroySurfaceKHR;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroySurfaceKHR);
} else if (strcmp("vkAcquireNextImageKHR", pName) == 0) {
return (PFN_vkVoidFunction)vkAcquireNextImageKHR;
return reinterpret_cast<PFN_vkVoidFunction>(vkAcquireNextImageKHR);
} else if (strcmp("vkCreateFramebuffer", pName) == 0) {
return (PFN_vkVoidFunction)vkCreateFramebuffer;
return reinterpret_cast<PFN_vkVoidFunction>(vkCreateFramebuffer);
} else if (strcmp("vkDestroyFramebuffer", pName) == 0) {
return (PFN_vkVoidFunction)vkDestroyFramebuffer;
return reinterpret_cast<PFN_vkVoidFunction>(vkDestroyFramebuffer);
}
return noop;
}

View File

@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "impeller/renderer/render_pass.h"
#include <utility>
#include "fml/status.h"
#include "impeller/base/validation.h"
#include "impeller/core/vertex_buffer.h"
@ -82,7 +84,9 @@ const std::shared_ptr<const Context>& RenderPass::GetContext() const {
}
void RenderPass::SetPipeline(PipelineRef pipeline) {
pending_.pipeline = pipeline;
// On debug this makes a difference, but not on release builds.
// NOLINTNEXTLINE(performance-move-const-arg)
pending_.pipeline = std::move(pipeline);
}
void RenderPass::SetPipeline(

View File

@ -272,12 +272,12 @@ bool Trampoline::BlitTextureOpenGLToVulkan(
gl.BufferData(GL_ARRAY_BUFFER, sizeof(kVertData), kVertData, GL_STATIC_DRAW);
gl.EnableVertexAttribArray(kAttributeIndexPosition);
gl.EnableVertexAttribArray(kAttributeIndexTexCoord);
gl.VertexAttribPointer(kAttributeIndexPosition, 2, GL_FLOAT, GL_FALSE,
sizeof(VertexData),
(void*)offsetof(VertexData, position));
gl.VertexAttribPointer(kAttributeIndexTexCoord, 2, GL_FLOAT, GL_FALSE,
sizeof(VertexData),
(void*)offsetof(VertexData, tex_coord));
gl.VertexAttribPointer(
kAttributeIndexPosition, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData),
reinterpret_cast<void*>(offsetof(VertexData, position)));
gl.VertexAttribPointer(
kAttributeIndexTexCoord, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData),
reinterpret_cast<void*>(offsetof(VertexData, tex_coord)));
gl.ActiveTexture(GL_TEXTURE0);
gl.BindTexture(src_texture.target, src_texture.texture);

View File

@ -416,7 +416,7 @@ static void DrawTextFrame(const hpp::TypographyContext& tc,
hpp::ParagraphBuilder p_builder(tc);
p_builder.PushStyle(p_style);
p_builder.AddText((const uint8_t*)text, sizeof(text));
p_builder.AddText(reinterpret_cast<const uint8_t*>(text), sizeof(text));
auto left_p = p_builder.Build(box_rect.width - 20.0);
ImpellerPoint pt = {20.0f + x_offset, 20.0f};

View File

@ -31,7 +31,7 @@ class SkylineRectanglePacker final : public RectanglePacker {
bool AddRect(int w, int h, IPoint16* loc) final;
Scalar PercentFull() const final {
return area_so_far_ / ((float)width() * height());
return area_so_far_ / (static_cast<float>(width()) * height());
}
private:
@ -60,8 +60,8 @@ class SkylineRectanglePacker final : public RectanglePacker {
};
bool SkylineRectanglePacker::AddRect(int p_width, int p_height, IPoint16* loc) {
if ((unsigned)p_width > (unsigned)width() ||
(unsigned)p_height > (unsigned)height()) {
if (static_cast<unsigned>(p_width) > static_cast<unsigned>(width()) ||
static_cast<unsigned>(p_height) > static_cast<unsigned>(height())) {
return false;
}

View File

@ -84,6 +84,8 @@ bool RenderPass::Begin(flutter::gpu::CommandBuffer& command_buffer) {
}
void RenderPass::SetPipeline(fml::RefPtr<RenderPipeline> pipeline) {
// On debug this makes a difference, but not on release builds.
// NOLINTNEXTLINE(performance-move-const-arg)
render_pipeline_ = std::move(pipeline);
}

View File

@ -716,7 +716,7 @@ class FakePlatformConfigurationClient : public PlatformConfigurationClient {
std::unique_ptr<PlatformMessage> message) override {}
FontCollection& GetFontCollection() override {
FML_UNREACHABLE();
return *(FontCollection*)(this);
return *reinterpret_cast<FontCollection*>(this);
}
std::shared_ptr<AssetManager> GetAssetManager() override { return nullptr; }
void UpdateIsolateDescription(const std::string isolate_name,

View File

@ -84,30 +84,30 @@ Base64::Error Base64::Decode(const void* srcv,
int two = 0;
int three = 0;
if (dst) {
int one = (uint8_t)(bytes[0] << 2);
int one = static_cast<uint8_t>(bytes[0] << 2);
two = bytes[1];
one |= two >> 4;
two = (uint8_t)((two << 4) & 0xFF);
two = static_cast<uint8_t>((two << 4) & 0xFF);
three = bytes[2];
two |= three >> 2;
three = (uint8_t)((three << 6) & 0xFF);
three = static_cast<uint8_t>((three << 6) & 0xFF);
three |= bytes[3];
FML_DCHECK(one < 256 && two < 256 && three < 256);
dst[i] = (unsigned char)one;
dst[i] = static_cast<unsigned char>(one);
}
i++;
if (padTwo) {
break;
}
if (dst) {
dst[i] = (unsigned char)two;
dst[i] = static_cast<unsigned char>(two);
}
i++;
if (padThree) {
break;
}
if (dst) {
dst[i] = (unsigned char)three;
dst[i] = static_cast<unsigned char>(three);
}
i++;
}
@ -141,7 +141,7 @@ size_t Base64::Encode(const void* srcv, size_t length, void* dstv) {
if (remainder > 0) {
int k1 = 0;
int k2 = EncodePad;
int a = (uint8_t)*src++;
int a = static_cast<uint8_t>(*src++);
if (remainder == 2) {
int b = *src++;
k1 = b >> 4;

View File

@ -106,7 +106,7 @@ TEST(Base64, DecodeBytes) {
ASSERT_EQ(err, Base64::Error::kNone);
FML_CHECK(len <= 256);
ASSERT_EQ(num, len) << input;
for (int i = 0; i < int(len); i++) {
for (int i = 0; i < static_cast<int>(len); i++) {
ASSERT_EQ(uint8_t(buffer[i]), output[i]) << input << i;
}
};

View File

@ -48,8 +48,9 @@ sk_sp<flutter::DlImage> ImageExternalTextureGLImpeller::CreateDlImage(
return nullptr;
}
// Associate the hardware buffer image with the texture.
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
(GLeglImageOES)egl_image.get().image);
glEGLImageTargetTexture2DOES(
GL_TEXTURE_EXTERNAL_OES,
static_cast<GLeglImageOES>(egl_image.get().image));
gl_entries_[id.value_or(0)] = GlEntry{
.egl_image = std::move(egl_image),
};

View File

@ -36,7 +36,7 @@ void ImageExternalTextureGLSkia::BindImageToTexture(
}
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
(GLeglImageOES)image.get().image);
static_cast<GLeglImageOES>(image.get().image));
}
sk_sp<flutter::DlImage> ImageExternalTextureGLSkia::CreateDlImage(

View File

@ -1358,11 +1358,11 @@ double PlatformViewAndroidJNIImpl::FlutterViewGetScaledFontSize(
return -3;
}
const jfloat scaledSize =
env->CallFloatMethod(java_object.obj(), g_get_scaled_font_size_method,
(jfloat)font_size, (jint)configuration_id);
const jfloat scaledSize = env->CallFloatMethod(
java_object.obj(), g_get_scaled_font_size_method,
static_cast<jfloat>(font_size), static_cast<jint>(configuration_id));
FML_CHECK(fml::jni::CheckException(env));
return (double)scaledSize;
return static_cast<double>(scaledSize);
}
void PlatformViewAndroidJNIImpl::FlutterViewUpdateSemantics(

View File

@ -67,9 +67,9 @@ class EventChannel {
BinaryMessageHandler binary_handler =
[shared_handler, codec, channel_name, messenger,
// Mutable state to track the handler's listening status.
is_listening = bool(false)](const uint8_t* message,
const size_t message_size,
const BinaryReply& reply) mutable {
is_listening = false](const uint8_t* message,
const size_t message_size,
const BinaryReply& reply) mutable {
constexpr char kOnListenMethod[] = "listen";
constexpr char kOnCancelMethod[] = "cancel";

View File

@ -50,7 +50,7 @@ uint32_t FlutterStandardCodecHelperReadSize(unsigned long* location,
CFDataRef data) {
uint8_t byte = FlutterStandardCodecHelperReadByte(location, data);
if (byte < 254) {
return (uint32_t)byte;
return static_cast<uint32_t>(byte);
} else if (byte == 254) {
UInt16 value;
FlutterStandardCodecHelperReadBytes(location, 2, &value, data);
@ -107,7 +107,7 @@ CFTypeRef FlutterStandardCodecHelperReadValueOfType(
CFTypeRef (*ReadValue)(CFTypeRef),
CFTypeRef (*ReadTypedDataOfType)(FlutterStandardField, CFTypeRef),
CFTypeRef user_data) {
FlutterStandardField field = (FlutterStandardField)type;
FlutterStandardField field = static_cast<FlutterStandardField>(type);
switch (field) {
case FlutterStandardFieldNil:
return nil;
@ -190,7 +190,7 @@ void FlutterStandardCodecHelperWriteSize(CFMutableDataRef data, uint32_t size) {
FlutterStandardCodecHelperWriteByte(data, size);
} else if (size <= 0xffff) {
FlutterStandardCodecHelperWriteByte(data, 254);
UInt16 value = (UInt16)size;
UInt16 value = static_cast<UInt16>(size);
FlutterStandardCodecHelperWriteBytes(data, &value, 2);
} else {
FlutterStandardCodecHelperWriteByte(data, 255);
@ -240,7 +240,7 @@ bool FlutterStandardCodecHelperWriteNumber(CFMutableDataRef data,
CFNumberRef number) {
bool success = false;
if (CFGetTypeID(number) == CFBooleanGetTypeID()) {
bool b = CFBooleanGetValue((CFBooleanRef)number);
bool b = CFBooleanGetValue(reinterpret_cast<CFBooleanRef>(number));
FlutterStandardCodecHelperWriteByte(
data, (b ? FlutterStandardFieldTrue : FlutterStandardFieldFalse));
success = true;

View File

@ -196,7 +196,7 @@
@autoreleasepool {
id<CAMetalDrawable> drawable = [layer nextDrawable];
XCTAssertNotNil(drawable);
texture = (id<MTLTexture>)drawable.texture;
texture = drawable.texture;
// Dropping the drawable must return texture to pool, so
// next drawable should return the same texture.
}

View File

@ -1016,7 +1016,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
}
if ([self validateOneVisualEffectView:subview
expectedFrame:CGRectMake(0, 0, 10, 10)
inputRadius:(CGFloat)expectInputRadius]) {
inputRadius:expectInputRadius]) {
[newVisualEffectViews addObject:subview];
}
}
@ -1072,7 +1072,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
}
if ([self validateOneVisualEffectView:subview
expectedFrame:CGRectMake(0, 0, 10, 10)
inputRadius:(CGFloat)expectInputRadius]) {
inputRadius:expectInputRadius]) {
[newVisualEffectViews addObject:subview];
}
}
@ -1127,7 +1127,7 @@ fml::RefPtr<fml::TaskRunner> GetDefaultTaskRunner() {
}
if ([self validateOneVisualEffectView:subview
expectedFrame:CGRectMake(0, 0, 10, 10)
inputRadius:(CGFloat)expectInputRadius]) {
inputRadius:expectInputRadius]) {
[newVisualEffectViews addObject:subview];
}
}

View File

@ -271,7 +271,8 @@ static void render_with_textures(FlRenderer* self,
GLint texcoord_index = glGetAttribLocation(priv->program, "in_texcoord");
glEnableVertexAttribArray(texcoord_index);
glVertexAttribPointer(texcoord_index, 2, GL_FLOAT, GL_FALSE,
sizeof(GLfloat) * 4, (void*)(sizeof(GLfloat) * 2));
sizeof(GLfloat) * 4,
reinterpret_cast<void*>(sizeof(GLfloat) * 2));
glDrawArrays(GL_TRIANGLES, 0, 6);
@ -323,9 +324,9 @@ static void fl_renderer_init(FlRenderer* self) {
fl_renderer_get_instance_private(self));
priv->views = g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr,
free_weak_ref);
priv->framebuffers_by_view_id =
g_hash_table_new_full(g_direct_hash, g_direct_equal, nullptr,
(GDestroyNotify)g_ptr_array_unref);
priv->framebuffers_by_view_id = g_hash_table_new_full(
g_direct_hash, g_direct_equal, nullptr,
reinterpret_cast<GDestroyNotify>(g_ptr_array_unref));
}
void fl_renderer_set_engine(FlRenderer* self, FlEngine* engine) {

View File

@ -450,7 +450,7 @@ G_MODULE_EXPORT void fl_value_unref(FlValue* self) {
case FL_VALUE_TYPE_CUSTOM: {
FlValueCustom* v = reinterpret_cast<FlValueCustom*>(self);
if (v->destroy_notify != nullptr) {
v->destroy_notify((gpointer)v->value);
v->destroy_notify(const_cast<gpointer>(v->value));
}
break;
}

View File

@ -320,19 +320,22 @@ static void fl_mock_binary_messenger_iface_init(
}
static void fl_mock_binary_messenger_init(FlMockBinaryMessenger* self) {
self->handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)handler_free);
self->handlers =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
reinterpret_cast<GDestroyNotify>(handler_free));
self->mock_channels = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free, (GDestroyNotify)mock_channel_free);
self->mock_message_channels =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)mock_message_channel_free);
self->mock_method_channels =
g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
(GDestroyNotify)mock_method_channel_free);
g_str_hash, g_str_equal, g_free,
reinterpret_cast<GDestroyNotify>(mock_channel_free));
self->mock_message_channels = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free,
reinterpret_cast<GDestroyNotify>(mock_message_channel_free));
self->mock_method_channels = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free,
reinterpret_cast<GDestroyNotify>(mock_method_channel_free));
self->mock_error_channels = g_hash_table_new_full(
g_str_hash, g_str_equal, g_free, (GDestroyNotify)mock_error_channel_free);
g_str_hash, g_str_equal, g_free,
reinterpret_cast<GDestroyNotify>(mock_error_channel_free));
}
FlMockBinaryMessenger* fl_mock_binary_messenger_new() {

View File

@ -12,13 +12,14 @@ namespace {
bool gtk_initialized = false;
GLogWriterFunc log_writer_cb = nullptr;
GLogLevelFlags fl_received_log_levels = (GLogLevelFlags)0x0;
GLogLevelFlags fl_received_log_levels = static_cast<GLogLevelFlags>(0x0);
GLogWriterOutput log_writer(GLogLevelFlags log_level,
const GLogField* fields,
gsize n_fields,
gpointer user_data) {
fl_received_log_levels = (GLogLevelFlags)(log_level | fl_received_log_levels);
fl_received_log_levels =
static_cast<GLogLevelFlags>(log_level | fl_received_log_levels);
if (log_writer_cb == nullptr) {
return g_log_writer_default(log_level, fields, n_fields, user_data);
}
@ -43,7 +44,7 @@ void fl_ensure_gtk_init(GLogWriterFunc writer) {
}
void fl_reset_received_gtk_log_levels() {
fl_received_log_levels = (GLogLevelFlags)0x0;
fl_received_log_levels = static_cast<GLogLevelFlags>(0x0);
}
GLogLevelFlags fl_get_received_gtk_log_levels() {

View File

@ -126,7 +126,7 @@ int main(int argc, char** argv) {
while (std::cin >> raw_codepoint) {
bool optional = false;
auto codepoint =
ParseCodepoint(std::string_view(raw_codepoint), optional);
ParseCodepoint(std::string_view{raw_codepoint}, optional);
if (!codepoint) {
std::cerr << "Invalid codepoint for " << raw_codepoint << "; exiting."
<< std::endl;