Make VectorIconRep an aggregate.
There's no need to provide constructors, so don't. Because span's constructor from (pointer, size) is explicit, this breaks callers who expect it to be implicitly invocable. Luckily, the shorter, clearer construction from an array works implicitly. Bug: 343248822, 364987728 Change-Id: Ia7ac0b6e3ec5e12405545bb7d702ea560250d1dc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6133458 Auto-Submit: Peter Kasting <pkasting@chromium.org> Commit-Queue: Peter Kasting <pkasting@chromium.org> Owners-Override: David Yeung <dayeung@chromium.org> Reviewed-by: Evan Stade <estade@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1401554}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
7c2e054f13
commit
48c3c19963
components/vector_icons
testing/libfuzzer/fuzzers
ui
@ -182,7 +182,7 @@ def AggregateVectorIcons(working_directory, file_list, output_cc, output_h):
|
||||
output_cc.write("VECTOR_ICON_REP_TEMPLATE({}, {})\n".format(
|
||||
icon_path_name, vector_commands))
|
||||
icon_representation_strings.append(
|
||||
"{{{0}, std::size({0})}}".format(icon_path_name))
|
||||
"{{{0}}}".format(icon_path_name))
|
||||
|
||||
# Another temporary variable kFooBarRepList is used to create all the
|
||||
# VectorIconReps inline, with a pointer to it in the final VectorIcon.
|
||||
|
@ -112,7 +112,7 @@ class PaintVectorIconFuzzTest {
|
||||
// An icon can contain multiple representations. We do not fuzz the code
|
||||
// that chooses which representation to draw based on canvas size and scale,
|
||||
// and instead use a single representation.
|
||||
gfx::VectorIconRep rep(path.data(), path.size());
|
||||
gfx::VectorIconRep rep{path};
|
||||
gfx::VectorIcon icon(&rep, /*reps_size=*/1u, "icon");
|
||||
|
||||
constexpr float kImageScale = 1.f;
|
||||
|
@ -21,7 +21,7 @@ namespace {
|
||||
const gfx::VectorIcon& GetCircleVectorIcon() {
|
||||
static constexpr gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18,
|
||||
5};
|
||||
static const gfx::VectorIconRep rep[] = {{path, 4}};
|
||||
static const gfx::VectorIconRep rep[] = {{path}};
|
||||
static constexpr gfx::VectorIcon circle_icon = {rep, 1, "circle"};
|
||||
|
||||
return circle_icon;
|
||||
@ -31,7 +31,7 @@ const gfx::VectorIcon& GetRectVectorIcon() {
|
||||
static constexpr gfx::PathElement path[] = {
|
||||
gfx::CommandType::LINE_TO, 0, 10, gfx::CommandType::LINE_TO, 10, 10,
|
||||
gfx::CommandType::LINE_TO, 10, 0, gfx::CommandType::CLOSE};
|
||||
static const gfx::VectorIconRep rep[] = {{path, 10}};
|
||||
static const gfx::VectorIconRep rep[] = {{path}};
|
||||
static constexpr gfx::VectorIcon rect_icon = {rep, 1, "rect"};
|
||||
|
||||
return rect_icon;
|
||||
|
@ -15,7 +15,7 @@ namespace {
|
||||
const gfx::VectorIcon* GetVectorIcon() {
|
||||
static constexpr gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18,
|
||||
5};
|
||||
static const gfx::VectorIconRep rep[] = {{path, 4}};
|
||||
static const gfx::VectorIconRep rep[] = {{path}};
|
||||
static constexpr gfx::VectorIcon circle_icon = {rep, 1, "circle"};
|
||||
|
||||
return &circle_icon;
|
||||
|
@ -52,7 +52,7 @@ TEST(VectorIconTest, RelativeMoveToAfterClose) {
|
||||
MOVE_TO, 4, 5, LINE_TO, 10, 11, CLOSE,
|
||||
// This move should use (4, 5) as the start point rather than (10, 11).
|
||||
R_MOVE_TO, 20, 21, R_LINE_TO, 50, 51};
|
||||
const VectorIconRep rep_list[] = {{elements, std::size(elements)}};
|
||||
const VectorIconRep rep_list[] = {{elements}};
|
||||
const VectorIcon icon(rep_list, 1u, nullptr);
|
||||
|
||||
PaintVectorIcon(&canvas, icon, 100, SK_ColorMAGENTA);
|
||||
@ -89,7 +89,7 @@ TEST(VectorIconTest, FillRuleNonZero) {
|
||||
NEW_PATH, FILL_RULE_NONZERO, MOVE_TO, 110, 0, R_H_LINE_TO, 90,
|
||||
R_V_LINE_TO, 90, R_H_LINE_TO, -90, CLOSE, MOVE_TO, 130, 20, R_H_LINE_TO,
|
||||
50, R_V_LINE_TO, 50, R_H_LINE_TO, -50, CLOSE};
|
||||
const VectorIconRep rep_list[] = {{elements, std::size(elements)}};
|
||||
const VectorIconRep rep_list[] = {{elements}};
|
||||
const VectorIcon icon(rep_list, 1u, nullptr);
|
||||
|
||||
PaintVectorIcon(&canvas, icon, 100, SK_ColorBLACK);
|
||||
@ -126,7 +126,7 @@ TEST(VectorIconTest, FlipsInRtl) {
|
||||
R_H_LINE_TO,
|
||||
-20,
|
||||
CLOSE};
|
||||
const VectorIconRep rep_list[] = {{elements, std::size(elements)}};
|
||||
const VectorIconRep rep_list[] = {{elements}};
|
||||
const VectorIcon icon(rep_list, 1u, nullptr);
|
||||
PaintVectorIcon(&canvas, icon, canvas_size, color);
|
||||
|
||||
@ -254,11 +254,8 @@ TEST(VectorIconTest, CorrectSizePainted) {
|
||||
0,
|
||||
CLOSE};
|
||||
// VectorIconReps are always sorted in descending order of size.
|
||||
const VectorIconRep rep_list[] = {{elements48, std::size(elements48)},
|
||||
{elements32, std::size(elements32)},
|
||||
{elements24, std::size(elements24)},
|
||||
{elements20, std::size(elements20)},
|
||||
{elements16, std::size(elements16)}};
|
||||
const VectorIconRep rep_list[] = {
|
||||
{elements48}, {elements32}, {elements24}, {elements20}, {elements16}};
|
||||
const VectorIcon icon(rep_list, 5u, nullptr);
|
||||
|
||||
// Test exact sizes paint the correctly sized icon, including the largest and
|
||||
|
@ -93,13 +93,6 @@ struct PathElement {
|
||||
// Describes the drawing commands for a single vector icon at a particular pixel
|
||||
// size or range of sizes.
|
||||
struct VectorIconRep {
|
||||
VectorIconRep() = default;
|
||||
constexpr VectorIconRep(const PathElement* path_data, size_t path_size)
|
||||
: path(path_data, path_size) {}
|
||||
|
||||
VectorIconRep(const VectorIconRep&) = delete;
|
||||
VectorIconRep& operator=(const VectorIconRep&) = delete;
|
||||
|
||||
base::raw_span<const PathElement> path;
|
||||
};
|
||||
|
||||
|
@ -273,7 +273,7 @@ TEST(SimpleMenuModelTest, HasIconsViaVectorIcon) {
|
||||
EXPECT_TRUE(simple_menu_model.GetIconAt(0).IsEmpty());
|
||||
|
||||
gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18, 5};
|
||||
gfx::VectorIconRep rep[] = {{path, 4}};
|
||||
gfx::VectorIconRep rep[] = {{path}};
|
||||
gfx::VectorIcon circle_icon = {rep, 1, "circle"};
|
||||
|
||||
simple_menu_model.AddItemWithIcon(
|
||||
|
Reference in New Issue
Block a user