Make impeller/geometry/... compatible with .clang-tidy. (flutter/engine#48154)

This commit is contained in:
Matan Lurey
2023-11-17 12:05:40 -08:00
committed by GitHub
parent c175f20309
commit 178e3396e3
5 changed files with 18 additions and 9 deletions

View File

@@ -840,10 +840,14 @@ struct Color {
static Color Random() {
return {
// This method is not used for cryptographic purposes.
// NOLINTBEGIN(clang-analyzer-security.insecureAPI.rand)
static_cast<Scalar>((std::rand() % 255) / 255.0f), //
static_cast<Scalar>((std::rand() % 255) / 255.0f), //
static_cast<Scalar>((std::rand() % 255) / 255.0f), //
1.0f //
// NOLINTEND(clang-analyzer-security.insecureAPI.rand)
1.0f //
};
}

View File

@@ -228,20 +228,20 @@ bool Path::GetContourComponentAtIndex(size_t index,
Path::Polyline::Polyline(Path::Polyline::PointBufferPtr point_buffer,
Path::Polyline::ReclaimPointBufferCallback reclaim)
: points(std::move(point_buffer)), reclaim_points(std::move(reclaim)) {
: points(std::move(point_buffer)), reclaim_points_(std::move(reclaim)) {
FML_DCHECK(points);
}
Path::Polyline::Polyline(Path::Polyline&& other) {
points = std::move(other.points);
reclaim_points = std::move(other.reclaim_points);
reclaim_points_ = std::move(other.reclaim_points_);
contours = std::move(other.contours);
}
Path::Polyline::~Polyline() {
if (reclaim_points) {
if (reclaim_points_) {
points->clear();
reclaim_points(std::move(points));
reclaim_points_(std::move(points));
}
}

View File

@@ -125,7 +125,7 @@ class Path {
size_t contour_index) const;
private:
ReclaimPointBufferCallback reclaim_points;
ReclaimPointBufferCallback reclaim_points_;
};
Path();

View File

@@ -102,7 +102,7 @@ struct CubicPathComponent {
CubicPathComponent() {}
CubicPathComponent(const QuadraticPathComponent& q)
explicit CubicPathComponent(const QuadraticPathComponent& q)
: p1(q.p1),
cp1(q.p1 + (q.cp - q.p1) * (2.0 / 3.0)),
cp2(q.p2 + (q.cp - q.p2) * (2.0 / 3.0)),
@@ -148,7 +148,7 @@ struct ContourComponent {
ContourComponent() {}
ContourComponent(Point p, bool is_closed = false)
explicit ContourComponent(Point p, bool is_closed = false)
: destination(p), is_closed(is_closed) {}
bool operator==(const ContourComponent& other) const {

View File

@@ -9,6 +9,7 @@
#include <ostream>
#include <vector>
#include "fml/logging.h"
#include "impeller/geometry/matrix.h"
#include "impeller/geometry/point.h"
#include "impeller/geometry/scalar.h"
@@ -216,7 +217,11 @@ struct TRect {
/// rectangle.
constexpr TRect TransformBounds(const Matrix& transform) const {
auto points = GetTransformedPoints(transform);
return TRect::MakePointBounds(points.begin(), points.end()).value();
auto bounds = TRect::MakePointBounds(points.begin(), points.end());
if (bounds.has_value()) {
return bounds.value();
}
FML_UNREACHABLE();
}
/// @brief Constructs a Matrix that will map all points in the coordinate