diff --git a/impeller/base/thread.h b/impeller/base/thread.h index 9d44b7681cc93..75ab5aae9720d 100644 --- a/impeller/base/thread.h +++ b/impeller/base/thread.h @@ -53,7 +53,9 @@ class IPLR_CAPABILITY("mutex") RWMutex { class IPLR_SCOPED_CAPABILITY Lock { public: - Lock(Mutex& mutex) IPLR_ACQUIRE(mutex) : mutex_(mutex) { mutex_.Lock(); } + explicit Lock(Mutex& mutex) IPLR_ACQUIRE(mutex) : mutex_(mutex) { + mutex_.Lock(); + } ~Lock() IPLR_RELEASE() { mutex_.Unlock(); } @@ -65,7 +67,8 @@ class IPLR_SCOPED_CAPABILITY Lock { class IPLR_SCOPED_CAPABILITY ReaderLock { public: - ReaderLock(RWMutex& mutex) IPLR_ACQUIRE_SHARED(mutex) : mutex_(mutex) { + explicit ReaderLock(RWMutex& mutex) IPLR_ACQUIRE_SHARED(mutex) + : mutex_(mutex) { mutex_.LockReader(); } @@ -79,7 +82,7 @@ class IPLR_SCOPED_CAPABILITY ReaderLock { class IPLR_SCOPED_CAPABILITY WriterLock { public: - WriterLock(RWMutex& mutex) IPLR_ACQUIRE(mutex) : mutex_(mutex) { + explicit WriterLock(RWMutex& mutex) IPLR_ACQUIRE(mutex) : mutex_(mutex) { mutex_.LockWriter(); } diff --git a/impeller/base/version.h b/impeller/base/version.h index 8be914f6ba505..423e56272cf27 100644 --- a/impeller/base/version.h +++ b/impeller/base/version.h @@ -18,7 +18,9 @@ struct Version { size_t minor_version; size_t patch_version; - constexpr Version(size_t p_major = 0, size_t p_minor = 0, size_t p_patch = 0) + constexpr explicit Version(size_t p_major = 0, + size_t p_minor = 0, + size_t p_patch = 0) : major_version(p_major), minor_version(p_minor), patch_version(p_patch) {} diff --git a/impeller/geometry/color.h b/impeller/geometry/color.h index 02c89627d94d4..14247f1c6e5fd 100644 --- a/impeller/geometry/color.h +++ b/impeller/geometry/color.h @@ -144,7 +144,7 @@ struct Color { explicit Color(const ColorHSB& hsbColor); - Color(const Vector4& value); + explicit Color(const Vector4& value); constexpr Color(Scalar r, Scalar g, Scalar b, Scalar a) : red(r), green(g), blue(b), alpha(a) {} diff --git a/impeller/geometry/matrix.h b/impeller/geometry/matrix.h index 119702f6130a8..8a1f791e05cc4 100644 --- a/impeller/geometry/matrix.h +++ b/impeller/geometry/matrix.h @@ -62,7 +62,7 @@ struct Matrix { Vector4(m12, m13, m14, m15)} {} // clang-format on - Matrix(const MatrixDecomposition& decomposition); + explicit Matrix(const MatrixDecomposition& decomposition); // clang-format off static constexpr Matrix MakeColumn( diff --git a/impeller/golden_tests/metal_screenshot.h b/impeller/golden_tests/metal_screenshot.h index 0d2df7fc44309..30253989801de 100644 --- a/impeller/golden_tests/metal_screenshot.h +++ b/impeller/golden_tests/metal_screenshot.h @@ -30,9 +30,9 @@ class MetalScreenshot { private: friend class MetalScreenshoter; - MetalScreenshot(CGImageRef cgImage); + explicit MetalScreenshot(CGImageRef cgImage); FML_DISALLOW_COPY_AND_ASSIGN(MetalScreenshot); - CGImageRef cgImage_; + CGImageRef cg_image_; CFDataRef pixel_data_; }; } // namespace testing diff --git a/impeller/golden_tests/metal_screenshot.mm b/impeller/golden_tests/metal_screenshot.mm index db274a1de81e2..9a26bf08d3e5e 100644 --- a/impeller/golden_tests/metal_screenshot.mm +++ b/impeller/golden_tests/metal_screenshot.mm @@ -7,14 +7,14 @@ namespace impeller { namespace testing { -MetalScreenshot::MetalScreenshot(CGImageRef cgImage) : cgImage_(cgImage) { +MetalScreenshot::MetalScreenshot(CGImageRef cgImage) : cg_image_(cgImage) { CGDataProviderRef data_provider = CGImageGetDataProvider(cgImage); pixel_data_ = CGDataProviderCopyData(data_provider); } MetalScreenshot::~MetalScreenshot() { CFRelease(pixel_data_); - CGImageRelease(cgImage_); + CGImageRelease(cg_image_); } const UInt8* MetalScreenshot::GetBytes() const { @@ -22,11 +22,11 @@ } size_t MetalScreenshot::GetHeight() const { - return CGImageGetHeight(cgImage_); + return CGImageGetHeight(cg_image_); } size_t MetalScreenshot::GetWidth() const { - return CGImageGetWidth(cgImage_); + return CGImageGetWidth(cg_image_); } bool MetalScreenshot::WriteToPNG(const std::string& path) const { @@ -36,7 +36,7 @@ CGImageDestinationRef destination = CGImageDestinationCreateWithURL( (__bridge CFURLRef)output_url, kUTTypePNG, 1, nullptr); if (destination != nullptr) { - CGImageDestinationAddImage(destination, cgImage_, + CGImageDestinationAddImage(destination, cg_image_, (__bridge CFDictionaryRef) @{}); if (CGImageDestinationFinalize(destination)) { diff --git a/impeller/renderer/pool.h b/impeller/renderer/pool.h index f215ff2a6d975..a90357594196a 100644 --- a/impeller/renderer/pool.h +++ b/impeller/renderer/pool.h @@ -14,7 +14,7 @@ namespace impeller { template class Pool { public: - Pool(uint32_t limit_bytes) : limit_bytes_(limit_bytes), size_(0) {} + explicit Pool(uint32_t limit_bytes) : limit_bytes_(limit_bytes) {} std::shared_ptr Grab() { std::scoped_lock lock(mutex_); @@ -46,7 +46,7 @@ class Pool { private: std::vector> pool_; const uint32_t limit_bytes_; - uint32_t size_; + uint32_t size_ = 0; // Note: This would perform better as a lockless ring buffer. mutable std::mutex mutex_; }; diff --git a/impeller/scene/importer/importer_unittests.cc b/impeller/scene/importer/importer_unittests.cc index d172b7418deb4..c4aa6b27ec872 100644 --- a/impeller/scene/importer/importer_unittests.cc +++ b/impeller/scene/importer/importer_unittests.cc @@ -102,10 +102,10 @@ TEST(ImporterTest, CanParseSkinnedGLTF) { ASSERT_COLOR_NEAR(color, Color(1, 1, 1, 1)); Vector4 joints = ToVector4(vertex.joints()); - ASSERT_COLOR_NEAR(joints, Vector4(0, 0, 0, 0)); + ASSERT_VECTOR4_NEAR(joints, Vector4(0, 0, 0, 0)); Vector4 weights = ToVector4(vertex.weights()); - ASSERT_COLOR_NEAR(weights, Vector4(1, 0, 0, 0)); + ASSERT_VECTOR4_NEAR(weights, Vector4(1, 0, 0, 0)); ASSERT_EQ(scene.animations.size(), 2u); ASSERT_EQ(scene.animations[0]->name, "Idle");