diff --git a/.clang-tidy b/.clang-tidy index b74be267bc42f..c22fc3477215b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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, diff --git a/common/graphics/persistent_cache.cc b/common/graphics/persistent_cache.cc index d64cb51bb9368..19546acadae90 100644 --- a/common/graphics/persistent_cache.cc +++ b/common/graphics/persistent_cache.cc @@ -176,7 +176,7 @@ sk_sp 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(error); FML_LOG(ERROR) << "Base64 can't decode: " << input; return nullptr; } @@ -185,7 +185,7 @@ sk_sp 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(error); FML_LOG(ERROR) << "Base64 can't decode: " << input; return nullptr; } diff --git a/display_list/geometry/dl_region.cc b/display_list/geometry/dl_region.cc index f2306c4d8b78a..386e4e025b1c1 100644 --- a/display_list/geometry/dl_region.cc +++ b/display_list/geometry/dl_region.cc @@ -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(512)); reserve(new_capacity); } SpanChunkHandle res = size_; diff --git a/engine.code-workspace b/engine.code-workspace index 491b6a4451d22..c144ddc94c276 100644 --- a/engine.code-workspace +++ b/engine.code-workspace @@ -123,7 +123,9 @@ "__std_stream": "cpp", "*.ipp": "cpp", "csetjmp": "cpp", - "cfenv": "cpp" + "cfenv": "cpp", + "execution": "cpp", + "print": "cpp" }, "C_Cpp.default.includePath": [ "${default}", diff --git a/flow/layers/backdrop_filter_layer.cc b/flow/layers/backdrop_filter_layer.cc index 57c469a7638b0..37afc1f6e9f11 100644 --- a/flow/layers/backdrop_filter_layer.cc +++ b/flow/layers/backdrop_filter_layer.cc @@ -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())); diff --git a/fml/endianness.h b/fml/endianness.h index 18758b7b69492..d294a60c466d7 100644 --- a/fml/endianness.h +++ b/fml/endianness.h @@ -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(FML_BYTESWAP_16((uint16_t)n)); } else if constexpr (sizeof(T) == 4) { - return (T)FML_BYTESWAP_32((uint32_t)n); + return static_cast(FML_BYTESWAP_32((uint32_t)n)); } else if constexpr (sizeof(T) == 8) { - return (T)FML_BYTESWAP_64((uint64_t)n); + return static_cast(FML_BYTESWAP_64((uint64_t)n)); } else { static_assert(!sizeof(T), "Unsupported size"); } diff --git a/impeller/display_list/canvas.cc b/impeller/display_list/canvas.cc index 11cc4d7598a9f..6ad900b658ffd 100644 --- a/impeller/display_list/canvas.cc +++ b/impeller/display_list/canvas.cc @@ -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(IRect::RoundOut(subpass_coverage).GetSize()); } if (subpass_size.IsEmpty()) { return SkipUntilMatchingRestore(total_content_depth); diff --git a/impeller/entity/geometry/point_field_geometry.cc b/impeller/entity/geometry/point_field_geometry.cc index 2a8429a2d7ac5..35c1f416fe92a 100644 --- a/impeller/entity/geometry/point_field_geometry.cc +++ b/impeller/entity/geometry/point_field_geometry.cc @@ -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(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(center + circle_vertices[0]); for (const Point& vertex : circle_vertices) { - output[offset++] = Point(center + vertex); + output[offset++] = static_cast(center + vertex); } last_point = circle_vertices.back() + center; } diff --git a/impeller/entity/geometry/round_superellipse_geometry.cc b/impeller/entity/geometry/round_superellipse_geometry.cc index b595b169f1738..8b3006c3d64fc 100644 --- a/impeller/entity/geometry/round_superellipse_geometry.cc +++ b/impeller/entity/geometry/round_superellipse_geometry.cc @@ -56,8 +56,8 @@ constexpr Scalar kRatioStep = Scalar LerpPrecomputedVariable(size_t column, Scalar ratio) { Scalar steps = std::clamp((ratio - kMinRatio) / kRatioStep, 0, kNumRecords - 1); - size_t left = - std::clamp((size_t)std::floor(steps), 0, kNumRecords - 2); + size_t left = std::clamp(static_cast(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(std::ceil(minDimension * pointsPerPixel)); Scalar angleByDimension = fullAngle / pointsByDimension; return std::min(kMinAngleStep, angleByDimension); diff --git a/impeller/renderer/backend/gles/handle_gles.h b/impeller/renderer/backend/gles/handle_gles.h index 808918fe8e3a7..9d71b4c6e340e 100644 --- a/impeller/renderer/backend/gles/handle_gles.h +++ b/impeller/renderer/backend/gles/handle_gles.h @@ -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(p_type), - p_name)) {} + hash_(fml::HashCombine( + static_cast>(p_type), + p_name)) {} HandleGLES(HandleType p_type, std::optional p_name) : type_(p_type), name_(p_name), - hash_(fml::HashCombine(std::underlying_type_t(p_type), - p_name)) {} + hash_(fml::HashCombine( + static_cast>(p_type), + p_name)) {} static HandleGLES Create(HandleType type) { return HandleGLES{type, UniqueID{}}; diff --git a/impeller/renderer/backend/gles/shader_library_gles.cc b/impeller/renderer/backend/gles/shader_library_gles.cc index 018fc50c6b321..0d52f6c176bff 100644 --- a/impeller/renderer/backend/gles/shader_library_gles.cc +++ b/impeller/renderer/backend/gles/shader_library_gles.cc @@ -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( + functions[ShaderKey{key_name, stage}] = std::shared_ptr{ new ShaderFunctionGLES(library_id, // stage, // key_name, // mapping // - )); + )}; return true; }; diff --git a/impeller/renderer/backend/vulkan/debug_report_vk.cc b/impeller/renderer/backend/vulkan/debug_report_vk.cc index 3bfa2852c27c7..79f8eca401568 100644 --- a/impeller/renderer/backend/vulkan/debug_report_vk.cc +++ b/impeller/renderer/backend/vulkan/debug_report_vk.cc @@ -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(names[i].objectType)) + << " [" << names[i].objectHandle << "] ["; if (names[i].pObjectName != nullptr) { stream << names[i].pObjectName; } else { diff --git a/impeller/renderer/backend/vulkan/test/mock_vulkan.cc b/impeller/renderer/backend/vulkan/test/mock_vulkan.cc index 447b0665b5241..51273c2c0bb66 100644 --- a/impeller/renderer/backend/vulkan/test/mock_vulkan.cc +++ b/impeller/renderer/backend/vulkan/test/mock_vulkan.cc @@ -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( + vkEnumerateInstanceExtensionProperties); } else if (strcmp("vkEnumerateInstanceLayerProperties", pName) == 0) { - return (PFN_vkVoidFunction)vkEnumerateInstanceLayerProperties; + return reinterpret_cast( + vkEnumerateInstanceLayerProperties); } else if (strcmp("vkEnumeratePhysicalDevices", pName) == 0) { - return (PFN_vkVoidFunction)vkEnumeratePhysicalDevices; + return reinterpret_cast(vkEnumeratePhysicalDevices); } else if (strcmp("vkGetPhysicalDeviceFormatProperties", pName) == 0) { - return (PFN_vkVoidFunction)vkGetPhysicalDeviceFormatProperties; + return reinterpret_cast( + vkGetPhysicalDeviceFormatProperties); } else if (strcmp("vkGetPhysicalDeviceProperties", pName) == 0) { - return (PFN_vkVoidFunction)vkGetPhysicalDeviceProperties; + return reinterpret_cast(vkGetPhysicalDeviceProperties); } else if (strcmp("vkGetPhysicalDeviceQueueFamilyProperties", pName) == 0) { - return (PFN_vkVoidFunction)vkGetPhysicalDeviceQueueFamilyProperties; + return reinterpret_cast( + vkGetPhysicalDeviceQueueFamilyProperties); } else if (strcmp("vkEnumerateDeviceExtensionProperties", pName) == 0) { - return (PFN_vkVoidFunction)vkEnumerateDeviceExtensionProperties; + return reinterpret_cast( + vkEnumerateDeviceExtensionProperties); } else if (strcmp("vkCreateDevice", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateDevice; + return reinterpret_cast(vkCreateDevice); } else if (strcmp("vkCreateInstance", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateInstance; + return reinterpret_cast(vkCreateInstance); } else if (strcmp("vkGetPhysicalDeviceMemoryProperties", pName) == 0) { - return (PFN_vkVoidFunction)vkGetPhysicalDeviceMemoryProperties; + return reinterpret_cast( + vkGetPhysicalDeviceMemoryProperties); } else if (strcmp("vkCreatePipelineCache", pName) == 0) { - return (PFN_vkVoidFunction)vkCreatePipelineCache; + return reinterpret_cast(vkCreatePipelineCache); } else if (strcmp("vkCreateCommandPool", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateCommandPool; + return reinterpret_cast(vkCreateCommandPool); } else if (strcmp("vkResetCommandPool", pName) == 0) { - return (PFN_vkVoidFunction)vkResetCommandPool; + return reinterpret_cast(vkResetCommandPool); } else if (strcmp("vkAllocateCommandBuffers", pName) == 0) { - return (PFN_vkVoidFunction)vkAllocateCommandBuffers; + return reinterpret_cast(vkAllocateCommandBuffers); } else if (strcmp("vkBeginCommandBuffer", pName) == 0) { - return (PFN_vkVoidFunction)vkBeginCommandBuffer; + return reinterpret_cast(vkBeginCommandBuffer); } else if (strcmp("vkCreateImage", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateImage; + return reinterpret_cast(vkCreateImage); } else if (strcmp("vkGetInstanceProcAddr", pName) == 0) { - return (PFN_vkVoidFunction)GetMockVulkanProcAddress; + return reinterpret_cast(GetMockVulkanProcAddress); } else if (strcmp("vkGetDeviceProcAddr", pName) == 0) { - return (PFN_vkVoidFunction)GetMockVulkanProcAddress; + return reinterpret_cast(GetMockVulkanProcAddress); } else if (strcmp("vkGetImageMemoryRequirements2KHR", pName) == 0 || strcmp("vkGetImageMemoryRequirements2", pName) == 0) { - return (PFN_vkVoidFunction)vkGetImageMemoryRequirements2KHR; + return reinterpret_cast( + vkGetImageMemoryRequirements2KHR); } else if (strcmp("vkAllocateMemory", pName) == 0) { - return (PFN_vkVoidFunction)vkAllocateMemory; + return reinterpret_cast(vkAllocateMemory); } else if (strcmp("vkBindImageMemory", pName) == 0) { - return (PFN_vkVoidFunction)vkBindImageMemory; + return reinterpret_cast(vkBindImageMemory); } else if (strcmp("vkCreateImageView", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateImageView; + return reinterpret_cast(vkCreateImageView); } else if (strcmp("vkCreateBuffer", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateBuffer; + return reinterpret_cast(vkCreateBuffer); } else if (strcmp("vkGetBufferMemoryRequirements2KHR", pName) == 0 || strcmp("vkGetBufferMemoryRequirements2", pName) == 0) { - return (PFN_vkVoidFunction)vkGetBufferMemoryRequirements2KHR; + return reinterpret_cast( + vkGetBufferMemoryRequirements2KHR); } else if (strcmp("vkBindBufferMemory", pName) == 0) { - return (PFN_vkVoidFunction)vkBindBufferMemory; + return reinterpret_cast(vkBindBufferMemory); } else if (strcmp("vkCreateRenderPass", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateRenderPass; + return reinterpret_cast(vkCreateRenderPass); } else if (strcmp("vkCreateDescriptorSetLayout", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateDescriptorSetLayout; + return reinterpret_cast(vkCreateDescriptorSetLayout); } else if (strcmp("vkCreatePipelineLayout", pName) == 0) { - return (PFN_vkVoidFunction)vkCreatePipelineLayout; + return reinterpret_cast(vkCreatePipelineLayout); } else if (strcmp("vkCreateGraphicsPipelines", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateGraphicsPipelines; + return reinterpret_cast(vkCreateGraphicsPipelines); } else if (strcmp("vkDestroyDevice", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyDevice; + return reinterpret_cast(vkDestroyDevice); } else if (strcmp("vkDestroyPipeline", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyPipeline; + return reinterpret_cast(vkDestroyPipeline); } else if (strcmp("vkCreateShaderModule", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateShaderModule; + return reinterpret_cast(vkCreateShaderModule); } else if (strcmp("vkDestroyShaderModule", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyShaderModule; + return reinterpret_cast(vkDestroyShaderModule); } else if (strcmp("vkDestroyPipelineCache", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyPipelineCache; + return reinterpret_cast(vkDestroyPipelineCache); } else if (strcmp("vkCmdBindPipeline", pName) == 0) { - return (PFN_vkVoidFunction)vkCmdBindPipeline; + return reinterpret_cast(vkCmdBindPipeline); } else if (strcmp("vkCmdSetStencilReference", pName) == 0) { - return (PFN_vkVoidFunction)vkCmdSetStencilReference; + return reinterpret_cast(vkCmdSetStencilReference); } else if (strcmp("vkCmdSetScissor", pName) == 0) { - return (PFN_vkVoidFunction)vkCmdSetScissor; + return reinterpret_cast(vkCmdSetScissor); } else if (strcmp("vkCmdSetViewport", pName) == 0) { - return (PFN_vkVoidFunction)vkCmdSetViewport; + return reinterpret_cast(vkCmdSetViewport); } else if (strcmp("vkDestroyCommandPool", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyCommandPool; + return reinterpret_cast(vkDestroyCommandPool); } else if (strcmp("vkFreeCommandBuffers", pName) == 0) { - return (PFN_vkVoidFunction)vkFreeCommandBuffers; + return reinterpret_cast(vkFreeCommandBuffers); } else if (strcmp("vkEndCommandBuffer", pName) == 0) { - return (PFN_vkVoidFunction)vkEndCommandBuffer; + return reinterpret_cast(vkEndCommandBuffer); } else if (strcmp("vkCreateFence", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateFence; + return reinterpret_cast(vkCreateFence); } else if (strcmp("vkDestroyFence", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyFence; + return reinterpret_cast(vkDestroyFence); } else if (strcmp("vkQueueSubmit", pName) == 0) { - return (PFN_vkVoidFunction)vkQueueSubmit; + return reinterpret_cast(vkQueueSubmit); } else if (strcmp("vkWaitForFences", pName) == 0) { - return (PFN_vkVoidFunction)vkWaitForFences; + return reinterpret_cast(vkWaitForFences); } else if (strcmp("vkGetFenceStatus", pName) == 0) { - return (PFN_vkVoidFunction)vkGetFenceStatus; + return reinterpret_cast(vkGetFenceStatus); } else if (strcmp("vkResetFences", pName) == 0) { - return (PFN_vkVoidFunction)vkResetFences; + return reinterpret_cast(vkResetFences); } else if (strcmp("vkCreateDebugUtilsMessengerEXT", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateDebugUtilsMessengerEXT; + return reinterpret_cast(vkCreateDebugUtilsMessengerEXT); } else if (strcmp("vkSetDebugUtilsObjectNameEXT", pName) == 0) { - return (PFN_vkVoidFunction)vkSetDebugUtilsObjectNameEXT; + return reinterpret_cast(vkSetDebugUtilsObjectNameEXT); } else if (strcmp("vkCreateQueryPool", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateQueryPool; + return reinterpret_cast(vkCreateQueryPool); } else if (strcmp("vkDestroyQueryPool", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyQueryPool; + return reinterpret_cast(vkDestroyQueryPool); } else if (strcmp("vkGetQueryPoolResults", pName) == 0) { - return (PFN_vkVoidFunction)vkGetQueryPoolResults; + return reinterpret_cast(vkGetQueryPoolResults); } else if (strcmp("vkCreateDescriptorPool", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateDescriptorPool; + return reinterpret_cast(vkCreateDescriptorPool); } else if (strcmp("vkDestroyDescriptorPool", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyDescriptorPool; + return reinterpret_cast(vkDestroyDescriptorPool); } else if (strcmp("vkResetDescriptorPool", pName) == 0) { - return (PFN_vkVoidFunction)vkResetDescriptorPool; + return reinterpret_cast(vkResetDescriptorPool); } else if (strcmp("vkAllocateDescriptorSets", pName) == 0) { - return (PFN_vkVoidFunction)vkAllocateDescriptorSets; + return reinterpret_cast(vkAllocateDescriptorSets); } else if (strcmp("vkGetPhysicalDeviceSurfaceFormatsKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkGetPhysicalDeviceSurfaceFormatsKHR; + return reinterpret_cast( + vkGetPhysicalDeviceSurfaceFormatsKHR); } else if (strcmp("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkGetPhysicalDeviceSurfaceCapabilitiesKHR; + return reinterpret_cast( + vkGetPhysicalDeviceSurfaceCapabilitiesKHR); } else if (strcmp("vkGetPhysicalDeviceSurfaceSupportKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkGetPhysicalDeviceSurfaceSupportKHR; + return reinterpret_cast( + vkGetPhysicalDeviceSurfaceSupportKHR); } else if (strcmp("vkCreateSwapchainKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateSwapchainKHR; + return reinterpret_cast(vkCreateSwapchainKHR); } else if (strcmp("vkDestroySwapchainKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroySwapchainKHR; + return reinterpret_cast(vkDestroySwapchainKHR); } else if (strcmp("vkGetSwapchainImagesKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkGetSwapchainImagesKHR; + return reinterpret_cast(vkGetSwapchainImagesKHR); } else if (strcmp("vkCreateSemaphore", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateSemaphore; + return reinterpret_cast(vkCreateSemaphore); } else if (strcmp("vkDestroySemaphore", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroySemaphore; + return reinterpret_cast(vkDestroySemaphore); } else if (strcmp("vkDestroySurfaceKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroySurfaceKHR; + return reinterpret_cast(vkDestroySurfaceKHR); } else if (strcmp("vkAcquireNextImageKHR", pName) == 0) { - return (PFN_vkVoidFunction)vkAcquireNextImageKHR; + return reinterpret_cast(vkAcquireNextImageKHR); } else if (strcmp("vkCreateFramebuffer", pName) == 0) { - return (PFN_vkVoidFunction)vkCreateFramebuffer; + return reinterpret_cast(vkCreateFramebuffer); } else if (strcmp("vkDestroyFramebuffer", pName) == 0) { - return (PFN_vkVoidFunction)vkDestroyFramebuffer; + return reinterpret_cast(vkDestroyFramebuffer); } return noop; } diff --git a/impeller/renderer/render_pass.cc b/impeller/renderer/render_pass.cc index ecafb9013ba24..efef0ebdaa95a 100644 --- a/impeller/renderer/render_pass.cc +++ b/impeller/renderer/render_pass.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "impeller/renderer/render_pass.h" + +#include #include "fml/status.h" #include "impeller/base/validation.h" #include "impeller/core/vertex_buffer.h" @@ -82,7 +84,9 @@ const std::shared_ptr& 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( diff --git a/impeller/toolkit/glvk/trampoline.cc b/impeller/toolkit/glvk/trampoline.cc index 83ac20a14bbb8..eda8595a0c5e1 100644 --- a/impeller/toolkit/glvk/trampoline.cc +++ b/impeller/toolkit/glvk/trampoline.cc @@ -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(offsetof(VertexData, position))); + gl.VertexAttribPointer( + kAttributeIndexTexCoord, 2, GL_FLOAT, GL_FALSE, sizeof(VertexData), + reinterpret_cast(offsetof(VertexData, tex_coord))); gl.ActiveTexture(GL_TEXTURE0); gl.BindTexture(src_texture.target, src_texture.texture); diff --git a/impeller/toolkit/interop/impeller_unittests.cc b/impeller/toolkit/interop/impeller_unittests.cc index 19b64cab4fd39..b1d1c26c2b994 100644 --- a/impeller/toolkit/interop/impeller_unittests.cc +++ b/impeller/toolkit/interop/impeller_unittests.cc @@ -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(text), sizeof(text)); auto left_p = p_builder.Build(box_rect.width - 20.0); ImpellerPoint pt = {20.0f + x_offset, 20.0f}; diff --git a/impeller/typographer/rectangle_packer.cc b/impeller/typographer/rectangle_packer.cc index f9a7be86c5f59..c5e9e464e99e1 100644 --- a/impeller/typographer/rectangle_packer.cc +++ b/impeller/typographer/rectangle_packer.cc @@ -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(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(p_width) > static_cast(width()) || + static_cast(p_height) > static_cast(height())) { return false; } diff --git a/lib/gpu/render_pass.cc b/lib/gpu/render_pass.cc index 3416ef1d0b8a1..2db35c2143963 100644 --- a/lib/gpu/render_pass.cc +++ b/lib/gpu/render_pass.cc @@ -84,6 +84,8 @@ bool RenderPass::Begin(flutter::gpu::CommandBuffer& command_buffer) { } void RenderPass::SetPipeline(fml::RefPtr pipeline) { + // On debug this makes a difference, but not on release builds. + // NOLINTNEXTLINE(performance-move-const-arg) render_pipeline_ = std::move(pipeline); } diff --git a/runtime/dart_isolate_unittests.cc b/runtime/dart_isolate_unittests.cc index 9f7bb9a59d5da..76b45dfdf7106 100644 --- a/runtime/dart_isolate_unittests.cc +++ b/runtime/dart_isolate_unittests.cc @@ -716,7 +716,7 @@ class FakePlatformConfigurationClient : public PlatformConfigurationClient { std::unique_ptr message) override {} FontCollection& GetFontCollection() override { FML_UNREACHABLE(); - return *(FontCollection*)(this); + return *reinterpret_cast(this); } std::shared_ptr GetAssetManager() override { return nullptr; } void UpdateIsolateDescription(const std::string isolate_name, diff --git a/shell/common/base64.cc b/shell/common/base64.cc index 5924f1ecd6cf6..d98b5ecfda620 100644 --- a/shell/common/base64.cc +++ b/shell/common/base64.cc @@ -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(bytes[0] << 2); two = bytes[1]; one |= two >> 4; - two = (uint8_t)((two << 4) & 0xFF); + two = static_cast((two << 4) & 0xFF); three = bytes[2]; two |= three >> 2; - three = (uint8_t)((three << 6) & 0xFF); + three = static_cast((three << 6) & 0xFF); three |= bytes[3]; FML_DCHECK(one < 256 && two < 256 && three < 256); - dst[i] = (unsigned char)one; + dst[i] = static_cast(one); } i++; if (padTwo) { break; } if (dst) { - dst[i] = (unsigned char)two; + dst[i] = static_cast(two); } i++; if (padThree) { break; } if (dst) { - dst[i] = (unsigned char)three; + dst[i] = static_cast(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(*src++); if (remainder == 2) { int b = *src++; k1 = b >> 4; diff --git a/shell/common/base64_unittests.cc b/shell/common/base64_unittests.cc index c9b3a04d5e4a1..521a234bc1d2a 100644 --- a/shell/common/base64_unittests.cc +++ b/shell/common/base64_unittests.cc @@ -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(len); i++) { ASSERT_EQ(uint8_t(buffer[i]), output[i]) << input << i; } }; diff --git a/shell/platform/android/image_external_texture_gl_impeller.cc b/shell/platform/android/image_external_texture_gl_impeller.cc index 7b2e5ce706016..b756aa4f415a4 100644 --- a/shell/platform/android/image_external_texture_gl_impeller.cc +++ b/shell/platform/android/image_external_texture_gl_impeller.cc @@ -48,8 +48,9 @@ sk_sp 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(egl_image.get().image)); gl_entries_[id.value_or(0)] = GlEntry{ .egl_image = std::move(egl_image), }; diff --git a/shell/platform/android/image_external_texture_gl_skia.cc b/shell/platform/android/image_external_texture_gl_skia.cc index 3d9d6adb34ddb..cc2799f407de1 100644 --- a/shell/platform/android/image_external_texture_gl_skia.cc +++ b/shell/platform/android/image_external_texture_gl_skia.cc @@ -36,7 +36,7 @@ void ImageExternalTextureGLSkia::BindImageToTexture( } glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex); glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, - (GLeglImageOES)image.get().image); + static_cast(image.get().image)); } sk_sp ImageExternalTextureGLSkia::CreateDlImage( diff --git a/shell/platform/android/platform_view_android_jni_impl.cc b/shell/platform/android/platform_view_android_jni_impl.cc index 7ad6f075115e0..8977d21ffb0cd 100644 --- a/shell/platform/android/platform_view_android_jni_impl.cc +++ b/shell/platform/android/platform_view_android_jni_impl.cc @@ -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(font_size), static_cast(configuration_id)); FML_CHECK(fml::jni::CheckException(env)); - return (double)scaledSize; + return static_cast(scaledSize); } void PlatformViewAndroidJNIImpl::FlutterViewUpdateSemantics( diff --git a/shell/platform/common/client_wrapper/include/flutter/event_channel.h b/shell/platform/common/client_wrapper/include/flutter/event_channel.h index 1ff577a76d8c6..7d0d2598861fb 100644 --- a/shell/platform/common/client_wrapper/include/flutter/event_channel.h +++ b/shell/platform/common/client_wrapper/include/flutter/event_channel.h @@ -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"; diff --git a/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc b/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc index ef872f249bd22..1eb536d905724 100644 --- a/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc +++ b/shell/platform/darwin/common/framework/Source/FlutterStandardCodecHelper.cc @@ -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(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(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(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(number)); FlutterStandardCodecHelperWriteByte( data, (b ? FlutterStandardFieldTrue : FlutterStandardFieldFalse)); success = true; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm index efab8b6ea921e..042edcc12b528 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm @@ -196,7 +196,7 @@ - (void)testDroppedDrawableReturnsTextureToPool { @autoreleasepool { id drawable = [layer nextDrawable]; XCTAssertNotNil(drawable); - texture = (id)drawable.texture; + texture = drawable.texture; // Dropping the drawable must return texture to pool, so // next drawable should return the same texture. } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index d0b0dff4dab32..1ca19a3fbecb3 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -1016,7 +1016,7 @@ - (void)testEditBackdropFilters { } if ([self validateOneVisualEffectView:subview expectedFrame:CGRectMake(0, 0, 10, 10) - inputRadius:(CGFloat)expectInputRadius]) { + inputRadius:expectInputRadius]) { [newVisualEffectViews addObject:subview]; } } @@ -1072,7 +1072,7 @@ - (void)testEditBackdropFilters { } if ([self validateOneVisualEffectView:subview expectedFrame:CGRectMake(0, 0, 10, 10) - inputRadius:(CGFloat)expectInputRadius]) { + inputRadius:expectInputRadius]) { [newVisualEffectViews addObject:subview]; } } @@ -1127,7 +1127,7 @@ - (void)testEditBackdropFilters { } if ([self validateOneVisualEffectView:subview expectedFrame:CGRectMake(0, 0, 10, 10) - inputRadius:(CGFloat)expectInputRadius]) { + inputRadius:expectInputRadius]) { [newVisualEffectViews addObject:subview]; } } diff --git a/shell/platform/linux/fl_renderer.cc b/shell/platform/linux/fl_renderer.cc index 2465390a2951a..600dab0665bc2 100644 --- a/shell/platform/linux/fl_renderer.cc +++ b/shell/platform/linux/fl_renderer.cc @@ -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(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(g_ptr_array_unref)); } void fl_renderer_set_engine(FlRenderer* self, FlEngine* engine) { diff --git a/shell/platform/linux/fl_value.cc b/shell/platform/linux/fl_value.cc index d55f76d464c94..ca470a874808a 100644 --- a/shell/platform/linux/fl_value.cc +++ b/shell/platform/linux/fl_value.cc @@ -450,7 +450,7 @@ G_MODULE_EXPORT void fl_value_unref(FlValue* self) { case FL_VALUE_TYPE_CUSTOM: { FlValueCustom* v = reinterpret_cast(self); if (v->destroy_notify != nullptr) { - v->destroy_notify((gpointer)v->value); + v->destroy_notify(const_cast(v->value)); } break; } diff --git a/shell/platform/linux/testing/fl_mock_binary_messenger.cc b/shell/platform/linux/testing/fl_mock_binary_messenger.cc index a2d37b71580db..93e21fbdb6819 100644 --- a/shell/platform/linux/testing/fl_mock_binary_messenger.cc +++ b/shell/platform/linux/testing/fl_mock_binary_messenger.cc @@ -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(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(mock_channel_free)); + self->mock_message_channels = g_hash_table_new_full( + g_str_hash, g_str_equal, g_free, + reinterpret_cast(mock_message_channel_free)); + self->mock_method_channels = g_hash_table_new_full( + g_str_hash, g_str_equal, g_free, + reinterpret_cast(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(mock_error_channel_free)); } FlMockBinaryMessenger* fl_mock_binary_messenger_new() { diff --git a/shell/platform/linux/testing/fl_test_gtk_logs.cc b/shell/platform/linux/testing/fl_test_gtk_logs.cc index db25f306f92e3..d9f5fd2fb53a9 100644 --- a/shell/platform/linux/testing/fl_test_gtk_logs.cc +++ b/shell/platform/linux/testing/fl_test_gtk_logs.cc @@ -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(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(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(0x0); } GLogLevelFlags fl_get_received_gtk_log_levels() { diff --git a/tools/font_subset/main.cc b/tools/font_subset/main.cc index 346cb2f008eee..bc387cefe5dba 100644 --- a/tools/font_subset/main.cc +++ b/tools/font_subset/main.cc @@ -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;