diff --git a/impeller/image/backends/skia/compressed_image_skia.h b/impeller/image/backends/skia/compressed_image_skia.h index 0245aa4dd693f..4b940fdbf855d 100644 --- a/impeller/image/backends/skia/compressed_image_skia.h +++ b/impeller/image/backends/skia/compressed_image_skia.h @@ -14,7 +14,7 @@ class CompressedImageSkia final : public CompressedImage { static std::shared_ptr Create( std::shared_ptr allocation); - CompressedImageSkia(std::shared_ptr allocation); + explicit CompressedImageSkia(std::shared_ptr allocation); ~CompressedImageSkia() override; diff --git a/impeller/playground/compute_playground_test.h b/impeller/playground/compute_playground_test.h index 4220032e3efa0..3af883b66e261 100644 --- a/impeller/playground/compute_playground_test.h +++ b/impeller/playground/compute_playground_test.h @@ -39,7 +39,7 @@ class ComputePlaygroundTest template std::shared_ptr CreateHostVisibleDeviceBuffer( - std::shared_ptr context, + const std::shared_ptr& context, const std::string& label) { DeviceBufferDescriptor desc; desc.storage_mode = StorageMode::kHostVisible; diff --git a/impeller/renderer/backend/metal/context_mtl.h b/impeller/renderer/backend/metal/context_mtl.h index 02997d6670b00..91b30a9c8aa5d 100644 --- a/impeller/renderer/backend/metal/context_mtl.h +++ b/impeller/renderer/backend/metal/context_mtl.h @@ -99,12 +99,12 @@ class ContextMTL final : public Context, #endif // IMPELLER_DEBUG // |Context| - void StoreTaskForGPU(std::function task) override; + void StoreTaskForGPU(const std::function& task) override; private: class SyncSwitchObserver : public fml::SyncSwitch::Observer { public: - SyncSwitchObserver(ContextMTL& parent); + explicit SyncSwitchObserver(ContextMTL& parent); virtual ~SyncSwitchObserver() = default; void OnSyncSwitchUpdate(bool new_value) override; diff --git a/impeller/renderer/backend/metal/context_mtl.mm b/impeller/renderer/backend/metal/context_mtl.mm index 9373d3e3a7b35..374da680afd4e 100644 --- a/impeller/renderer/backend/metal/context_mtl.mm +++ b/impeller/renderer/backend/metal/context_mtl.mm @@ -390,8 +390,8 @@ new ContextMTL(device, command_queue, return buffer; } -void ContextMTL::StoreTaskForGPU(std::function task) { - tasks_awaiting_gpu_.emplace_back(std::move(task)); +void ContextMTL::StoreTaskForGPU(const std::function& task) { + tasks_awaiting_gpu_.emplace_back(task); while (tasks_awaiting_gpu_.size() > kMaxTasksAwaitingGPU) { tasks_awaiting_gpu_.front()(); tasks_awaiting_gpu_.pop_front(); diff --git a/impeller/renderer/backend/metal/sampler_library_mtl.h b/impeller/renderer/backend/metal/sampler_library_mtl.h index 6af6bf8c1d70a..84bf62e493c49 100644 --- a/impeller/renderer/backend/metal/sampler_library_mtl.h +++ b/impeller/renderer/backend/metal/sampler_library_mtl.h @@ -29,7 +29,7 @@ class SamplerLibraryMTL final id device_ = nullptr; SamplerMap samplers_; - SamplerLibraryMTL(id device); + explicit SamplerLibraryMTL(id device); // |SamplerLibrary| std::shared_ptr GetSampler( diff --git a/impeller/renderer/backend/vulkan/blit_pass_vk.h b/impeller/renderer/backend/vulkan/blit_pass_vk.h index 961d79a43c6bd..1175dcab96bd8 100644 --- a/impeller/renderer/backend/vulkan/blit_pass_vk.h +++ b/impeller/renderer/backend/vulkan/blit_pass_vk.h @@ -26,7 +26,7 @@ class BlitPassVK final : public BlitPass { std::vector> commands_; std::string label_; - BlitPassVK(std::weak_ptr command_buffer); + explicit BlitPassVK(std::weak_ptr command_buffer); // |BlitPass| bool IsValid() const override; diff --git a/impeller/renderer/backend/vulkan/shared_object_vk.h b/impeller/renderer/backend/vulkan/shared_object_vk.h index 6fa5adaf328ac..f91f018c94e2a 100644 --- a/impeller/renderer/backend/vulkan/shared_object_vk.h +++ b/impeller/renderer/backend/vulkan/shared_object_vk.h @@ -25,6 +25,7 @@ class SharedObjectVKT : public SharedObjectVK { explicit SharedObjectVKT(UniqueResource res) : resource_(std::move(res)) {} + // NOLINTNEXTLINE(google-explicit-constructor) operator Resource() const { return Get(); } const Resource& Get() const { return *resource_; } diff --git a/impeller/renderer/backend/vulkan/swapchain_impl_vk.cc b/impeller/renderer/backend/vulkan/swapchain_impl_vk.cc index ad2ef4cc349f9..ac31b6eea5be8 100644 --- a/impeller/renderer/backend/vulkan/swapchain_impl_vk.cc +++ b/impeller/renderer/backend/vulkan/swapchain_impl_vk.cc @@ -339,7 +339,7 @@ std::shared_ptr SwapchainImplVK::GetContext() const { SwapchainImplVK::AcquireResult SwapchainImplVK::AcquireNextDrawable() { auto context_strong = context_.lock(); if (!context_strong) { - return {}; + return SwapchainImplVK::AcquireResult{}; } const auto& context = ContextVK::Cast(*context_strong); @@ -353,7 +353,7 @@ SwapchainImplVK::AcquireResult SwapchainImplVK::AcquireNextDrawable() { /// if (!sync->WaitForFence(context.GetDevice())) { VALIDATION_LOG << "Could not wait for fence."; - return {}; + return SwapchainImplVK::AcquireResult{}; } //---------------------------------------------------------------------------- @@ -368,7 +368,7 @@ SwapchainImplVK::AcquireResult SwapchainImplVK::AcquireNextDrawable() { if (caps_result != vk::Result::eSuccess) { VALIDATION_LOG << "Could not get surface capabilities: " << vk::to_string(caps_result); - return {}; + return SwapchainImplVK::AcquireResult{}; } if (caps.currentTransform != transform_if_changed_discard_swapchain_) { transform_if_changed_discard_swapchain_ = caps.currentTransform; @@ -404,7 +404,7 @@ SwapchainImplVK::AcquireResult SwapchainImplVK::AcquireNextDrawable() { if (index >= images_.size()) { VALIDATION_LOG << "Swapchain returned an invalid image index."; - return {}; + return SwapchainImplVK::AcquireResult{}; } /// Record all subsequent cmd buffers as part of the current frame. diff --git a/impeller/renderer/backend/vulkan/swapchain_impl_vk.h b/impeller/renderer/backend/vulkan/swapchain_impl_vk.h index e6e841eb9e86e..f8ce74e120545 100644 --- a/impeller/renderer/backend/vulkan/swapchain_impl_vk.h +++ b/impeller/renderer/backend/vulkan/swapchain_impl_vk.h @@ -45,9 +45,10 @@ class SwapchainImplVK final std::unique_ptr surface; bool out_of_date = false; - AcquireResult(bool p_out_of_date = false) : out_of_date(p_out_of_date) {} + explicit AcquireResult(bool p_out_of_date = false) + : out_of_date(p_out_of_date) {} - AcquireResult(std::unique_ptr p_surface) + explicit AcquireResult(std::unique_ptr p_surface) : surface(std::move(p_surface)) {} }; diff --git a/impeller/renderer/context.h b/impeller/renderer/context.h index 3b91704deb3fb..b23055ef20e2e 100644 --- a/impeller/renderer/context.h +++ b/impeller/renderer/context.h @@ -195,7 +195,7 @@ class Context { /// Threadsafe. /// /// `task` will be executed on the platform thread. - virtual void StoreTaskForGPU(std::function task) { + virtual void StoreTaskForGPU(const std::function& task) { FML_CHECK(false && "not supported in this context"); } diff --git a/impeller/renderer/renderer.h b/impeller/renderer/renderer.h index 794fb0f07dc4a..552a49d724e22 100644 --- a/impeller/renderer/renderer.h +++ b/impeller/renderer/renderer.h @@ -24,8 +24,8 @@ class Renderer { using RenderCallback = std::function; - Renderer(std::shared_ptr context, - size_t max_frames_in_flight = kDefaultMaxFramesInFlight); + explicit Renderer(std::shared_ptr context, + size_t max_frames_in_flight = kDefaultMaxFramesInFlight); ~Renderer(); diff --git a/impeller/renderer/testing/mocks.h b/impeller/renderer/testing/mocks.h index 8d50ac115c27b..77d06a12cace0 100644 --- a/impeller/renderer/testing/mocks.h +++ b/impeller/renderer/testing/mocks.h @@ -16,7 +16,8 @@ namespace testing { class MockDeviceBuffer : public DeviceBuffer { public: - MockDeviceBuffer(const DeviceBufferDescriptor& desc) : DeviceBuffer(desc) {} + explicit MockDeviceBuffer(const DeviceBufferDescriptor& desc) + : DeviceBuffer(desc) {} MOCK_METHOD(bool, SetLabel, (const std::string& label), (override)); @@ -87,7 +88,7 @@ class MockBlitPass : public BlitPass { class MockCommandBuffer : public CommandBuffer { public: - MockCommandBuffer(std::weak_ptr context) + explicit MockCommandBuffer(std::weak_ptr context) : CommandBuffer(context) {} MOCK_METHOD(bool, IsValid, (), (const, override)); MOCK_METHOD(void, SetLabel, (const std::string& label), (const, override)); @@ -150,7 +151,7 @@ class MockImpellerContext : public Context { class MockTexture : public Texture { public: - MockTexture(const TextureDescriptor& desc) : Texture(desc) {} + explicit MockTexture(const TextureDescriptor& desc) : Texture(desc) {} MOCK_METHOD(void, SetLabel, (std::string_view label), (override)); MOCK_METHOD(bool, IsValid, (), (const, override)); MOCK_METHOD(ISize, GetSize, (), (const, override)); diff --git a/impeller/typographer/backends/skia/typeface_skia.h b/impeller/typographer/backends/skia/typeface_skia.h index b460c2e436c5c..20544b4e13f93 100644 --- a/impeller/typographer/backends/skia/typeface_skia.h +++ b/impeller/typographer/backends/skia/typeface_skia.h @@ -15,7 +15,7 @@ namespace impeller { class TypefaceSkia final : public Typeface, public BackendCast { public: - TypefaceSkia(sk_sp typeface); + explicit TypefaceSkia(sk_sp typeface); ~TypefaceSkia() override; diff --git a/impeller/typographer/backends/stb/typeface_stb.cc b/impeller/typographer/backends/stb/typeface_stb.cc index ef0250a82100a..573aec6c49d56 100644 --- a/impeller/typographer/backends/stb/typeface_stb.cc +++ b/impeller/typographer/backends/stb/typeface_stb.cc @@ -13,8 +13,7 @@ namespace impeller { // Instantiate a typeface based on a .ttf or other font file TypefaceSTB::TypefaceSTB(std::unique_ptr typeface_mapping) : typeface_mapping_(std::move(typeface_mapping)), - font_info_(std::make_unique()), - is_valid_(false) { + font_info_(std::make_unique()) { // We need an "offset" into the ttf file auto offset = stbtt_GetFontOffsetForIndex(typeface_mapping_->GetMapping(), 0); if (stbtt_InitFont(font_info_.get(), typeface_mapping_->GetMapping(), diff --git a/impeller/typographer/backends/stb/typeface_stb.h b/impeller/typographer/backends/stb/typeface_stb.h index 913a67c890726..29129c00886fc 100644 --- a/impeller/typographer/backends/stb/typeface_stb.h +++ b/impeller/typographer/backends/stb/typeface_stb.h @@ -38,7 +38,7 @@ class TypefaceSTB final : public Typeface, private: std::unique_ptr typeface_mapping_; std::unique_ptr font_info_; - bool is_valid_; + bool is_valid_ = false; TypefaceSTB(const TypefaceSTB&) = delete;