14#include "gtest/gtest.h"
24 const std::vector<std::unique_ptr<DlImage>>&
images) {
26 canvas->
Scale(content_scale.
x, content_scale.
y);
45 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
51 const std::vector<std::unique_ptr<DlImage>>&
images) {
53 canvas->
Scale(content_scale.
x, content_scale.
y);
72 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
83 auto draw = [&](
DlCanvas* canvas,
const std::vector<sk_sp<DlImage>>&
images,
86 canvas->
Scale(content_scale.
x, content_scale.
y);
95 canvas->
SaveLayer(save_layer_bounds,
nullptr, blur.get());
99 std::vector<sk_sp<DlImage>>
images;
100 images.emplace_back(CreateDlImageForFixture(
"boston.jpg"));
102 auto make_screenshot = [&](
float sigma) {
104 draw(&builder,
images, sigma);
106 std::unique_ptr<impeller::testing::Screenshot> screenshot =
107 MakeScreenshot(builder.
Build());
111 float start_sigma = 10.0f;
112 std::unique_ptr<impeller::testing::Screenshot> left =
113 make_screenshot(start_sigma);
115 GTEST_SKIP() <<
"making screenshots not supported.";
118 double average_rmse = 0.0;
119 const int32_t sample_count = 200;
120 for (
int i = 1;
i <= sample_count; ++
i) {
121 float sigma = start_sigma + (
i / 2.f);
122 std::unique_ptr<impeller::testing::Screenshot> right =
123 make_screenshot(sigma);
124 double rmse =
RMSE(left.get(), right.get());
125 average_rmse += rmse;
140 left = std::move(right);
143 average_rmse = average_rmse / sample_count;
150 EXPECT_TRUE(average_rmse < 1.0) <<
"average_rmse: " << average_rmse;
152 EXPECT_TRUE(average_rmse >= 0.0) <<
"average_rmse: " << average_rmse;
169 builder.
Scale(content_scale.
x, content_scale.
y);
175 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
183 auto draw = [&](
DlCanvas* canvas,
const std::vector<sk_sp<DlImage>>&
images) {
184 canvas->
Scale(content_scale.
x, content_scale.
y);
188 canvas->
Scale(0.25, 0.25);
207 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
void DrawRoundRect(const DlRoundRect &rrect, const DlPaint &paint) override
void DrawColor(DlColor color, DlBlendMode mode) override
void Scale(DlScalar sx, DlScalar sy) override
sk_sp< DisplayList > Build()
static std::shared_ptr< DlMaskFilter > Make(DlBlurStyle style, SkScalar sigma, bool respect_ctm=true)
Developer-facing API for rendering anything within the engine.
virtual void ClipRect(const DlRect &rect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false)=0
virtual void DrawCircle(const DlPoint ¢er, DlScalar radius, const DlPaint &paint)=0
virtual void SaveLayer(const std::optional< DlRect > &bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt)=0
virtual void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr)=0
virtual void DrawColor(DlColor color, DlBlendMode mode=DlBlendMode::kSrcOver)=0
virtual void Scale(DlScalar sx, DlScalar sy)=0
static std::shared_ptr< DlImageFilter > MakeBlur(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)
DlPaint & setColor(DlColor color)
DlPaint & setStrokeWidth(float width)
DlPaint & setMaskFilter(std::nullptr_t filter)
DlPaint & setDrawStyle(DlDrawStyle style)
Describes a typeface along with any modifications to its intrinsic properties.
std::array< MockImage, 3 > images
bool RenderTextInCanvasSkia(DlCanvas *canvas, const std::string &text, const std::string_view &font_fixture, DlPoint position, const TextRenderOptions &options)
double RMSE(const impeller::testing::Screenshot *left, const impeller::testing::Screenshot *right)
TEST_P(DlGoldenTest, TextBlurMaskFilterRespectCTM)
@ kStroke
strokes boundary of shapes
@ kNormal
fuzzy inside and outside
static constexpr DlColor kBlue()
static constexpr DlColor kYellow()
static constexpr DlColor kRed()
std::shared_ptr< DlMaskFilter > mask_filter
static RoundRect MakeRectRadius(const Rect &rect, Scalar radius)
RoundRect Shift(Scalar dx, Scalar dy) const
Returns a new round rectangle translated by the given offset.
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)