Make a variety of low-impact Clang tidy fixes in Impeller. (flutter/engine#46116)
Work towards https://github.com/flutter/flutter/issues/134969. These are all self-contained, so I bundled them all together. All fixes are generated by `clang-tidy --fix`, and manual search/replace if that wasn't sufficient.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 @@ const UInt8* MetalScreenshot::GetBytes() const {
|
||||
}
|
||||
|
||||
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 @@ bool MetalScreenshot::WriteToPNG(const std::string& path) const {
|
||||
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)) {
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace impeller {
|
||||
template <typename T>
|
||||
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<T> Grab() {
|
||||
std::scoped_lock lock(mutex_);
|
||||
@@ -46,7 +46,7 @@ class Pool {
|
||||
private:
|
||||
std::vector<std::shared_ptr<T>> 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_;
|
||||
};
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user