Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
uber_sdf_parameters_unittests.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "gtest/gtest.h"
8
9namespace impeller {
10namespace testing {
11
12TEST(UberSDFParametersTest, MakeFillRect) {
13 auto rect = Rect::MakeLTRB(100, 100, 200, 200);
14 auto params = UberSDFParameters::MakeRect(Color::Red(), rect, std::nullopt);
15
17 EXPECT_EQ(params.color, Color::Red());
18 EXPECT_EQ(params.center, Point(150, 150));
19 EXPECT_EQ(params.size, Point(50, 50));
20 EXPECT_FALSE(params.stroke.has_value());
21}
22
23TEST(UberSDFParametersTest, MakeStrokeRect) {
24 auto rect = Rect::MakeLTRB(100, 100, 200, 200);
25 StrokeParameters stroke = {.width = 4.0f};
26 auto params = UberSDFParameters::MakeRect(Color::Red(), rect, stroke);
27
29 EXPECT_EQ(params.color, Color::Red());
30 EXPECT_EQ(params.center, Point(150, 150));
31 EXPECT_EQ(params.size, Point(50, 50));
32 EXPECT_EQ(params.stroke, stroke);
33}
34
35TEST(UberSDFParametersTest, MakeStrokeRectLowMiterLimitBecomesBevel) {
36 auto rect = Rect::MakeLTRB(100, 100, 200, 200);
37 StrokeParameters stroke = {
38 .width = 4.0f, .join = Join::kMiter, .miter_limit = 1.0f};
39 auto params = UberSDFParameters::MakeRect(Color::Red(), rect, stroke);
40
42 EXPECT_EQ(params.color, Color::Red());
43 EXPECT_EQ(params.center, Point(150, 150));
44 EXPECT_EQ(params.size, Point(50, 50));
45 StrokeParameters expected_stroke = {.width = 4.0f, .join = Join::kBevel};
46 EXPECT_EQ(params.stroke, expected_stroke);
47}
48
49TEST(UberSDFParametersTest, MakeFillCircle) {
50 Point center = {50, 50};
51 auto params =
52 UberSDFParameters::MakeCircle(Color::Red(), center, 10.0f, std::nullopt);
53
55 EXPECT_EQ(params.color, Color::Red());
56 EXPECT_EQ(params.center, center);
57 EXPECT_EQ(params.size, Point(10.0f, 10.0f));
58 EXPECT_FALSE(params.stroke.has_value());
59}
60
61TEST(UberSDFParametersTest, MakeStrokeCircle) {
62 Point center = {50, 50};
63 StrokeParameters stroke = {.width = 4.0f};
64 auto params =
65 UberSDFParameters::MakeCircle(Color::Red(), center, 10.0f, stroke);
66
68 EXPECT_EQ(params.color, Color::Red());
69 EXPECT_EQ(params.center, center);
70 EXPECT_EQ(params.size, Point(10.0f, 10.0f));
71 EXPECT_EQ(params.stroke, stroke);
72}
73
74TEST(UberSDFParametersTest, MakeFillOval) {
75 Point center = {25, 25};
76 Size size = Size(50, 50);
78
79 auto params = UberSDFParameters::MakeOval(Color::Red(), bounds, std::nullopt);
80
82 EXPECT_EQ(params.color, Color::Red());
83 EXPECT_EQ(params.center, center);
84 EXPECT_EQ(params.size, Point(size) * 0.5f);
85 EXPECT_FALSE(params.stroke.has_value());
86}
87
88TEST(UberSDFParametersTest, MakeStrokeOval) {
89 Point center = {25, 25};
90 Size size = Size(50, 50);
92 StrokeParameters stroke = {.width = 4.0f};
93
94 auto params = UberSDFParameters::MakeOval(Color::Red(), bounds, stroke);
95
97 EXPECT_EQ(params.color, Color::Red());
98 EXPECT_EQ(params.center, center);
99 EXPECT_EQ(params.size, Point(size) * 0.5f);
100 EXPECT_EQ(params.stroke, stroke);
101}
102
103TEST(UberSDFParametersTest, MakeRoundedRect) {
104 Rect rect = Rect::MakeXYWH(10, 20, 100, 100);
105 RoundingRadii radii = {
106 .top_left = Size(1.0f, 1.0f),
107 .top_right = Size(2.0f, 2.0f),
108 .bottom_left = Size(3.0f, 3.0f),
109 .bottom_right = Size(4.0f, 4.0f),
110 };
112 /*color=*/Color::Red(), /*rect=*/rect, /*radii=*/radii,
113 /*stroke=*/std::nullopt);
114
116 EXPECT_EQ(params.color, Color::Red());
117 EXPECT_EQ(params.center, Point(60, 70));
118 EXPECT_EQ(params.size, Point(50, 50));
119 EXPECT_EQ(params.radii.top_left.width, 1.0f);
120 EXPECT_EQ(params.radii.top_right.width, 2.0f);
121 EXPECT_EQ(params.radii.bottom_left.width, 3.0f);
122 EXPECT_EQ(params.radii.bottom_right.width, 4.0f);
123 EXPECT_FALSE(params.stroke.has_value());
124}
125
126} // namespace testing
127} // namespace impeller
const EmbeddedViewParams * params
TEST(FrameTimingsRecorderTest, RecordVsync)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
static constexpr Color Red()
Definition color.h:277
A structure to store all of the parameters related to stroking a path or basic geometry object.
static constexpr TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
Definition rect.h:144
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
Definition rect.h:136
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition rect.h:129
static UberSDFParameters MakeCircle(Color color, const Point &center, Scalar radius, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a circle.
static UberSDFParameters MakeOval(Color color, const Rect &bounds, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for an Oval.
static UberSDFParameters MakeRoundedRect(Color color, const Rect &rect, const RoundingRadii &radii, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a rounded rectangle.
static UberSDFParameters MakeRect(Color color, const Rect &rect, std::optional< StrokeParameters > stroke)
Creates UberSDFParameters for a rectangle.