Skip to content

Commit a1d91e2

Browse files
committed
Move tests
1 parent 086ace4 commit a1d91e2

File tree

2 files changed

+166
-166
lines changed

2 files changed

+166
-166
lines changed

impeller/aiks/aiks_blur_unittests.cc

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,172 @@ TEST_P(AiksTest, MaskBlurWithZeroSigmaIsSkipped) {
281281
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
282282
}
283283

284+
struct MaskBlurTestConfig {
285+
FilterContents::BlurStyle style = FilterContents::BlurStyle::kNormal;
286+
Scalar sigma = 1.0f;
287+
Scalar alpha = 1.0f;
288+
std::shared_ptr<ImageFilter> image_filter;
289+
bool invert_colors = false;
290+
BlendMode blend_mode = BlendMode::kSourceOver;
291+
};
292+
293+
static Picture MaskBlurVariantTest(const AiksTest& test_context,
294+
const MaskBlurTestConfig& config) {
295+
Canvas canvas;
296+
canvas.Scale(test_context.GetContentScale());
297+
canvas.Scale(Vector2{0.8f, 0.8f});
298+
Paint paint;
299+
paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
300+
.style = FilterContents::BlurStyle::kNormal,
301+
.sigma = Sigma{1},
302+
};
303+
304+
canvas.DrawPaint({.color = Color::AntiqueWhite()});
305+
306+
paint.mask_blur_descriptor->style = config.style;
307+
paint.mask_blur_descriptor->sigma = Sigma{config.sigma};
308+
paint.image_filter = config.image_filter;
309+
paint.invert_colors = config.invert_colors;
310+
paint.blend_mode = config.blend_mode;
311+
312+
const Scalar x = 50;
313+
const Scalar radius = 20.0f;
314+
const Scalar y_spacing = 100.0f;
315+
316+
Scalar y = 50;
317+
paint.color = Color::Crimson().WithAlpha(config.alpha);
318+
canvas.DrawRect(Rect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
319+
radius, 60.0f - radius),
320+
paint);
321+
322+
y += y_spacing;
323+
paint.color = Color::Blue().WithAlpha(config.alpha);
324+
canvas.DrawCircle({x + 25, y + 25}, radius, paint);
325+
326+
y += y_spacing;
327+
paint.color = Color::Green().WithAlpha(config.alpha);
328+
canvas.DrawOval(Rect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
329+
radius, 60.0f - radius),
330+
paint);
331+
332+
y += y_spacing;
333+
paint.color = Color::Purple().WithAlpha(config.alpha);
334+
canvas.DrawRRect(Rect::MakeXYWH(x, y, 60.0f, 60.0f), //
335+
{radius, radius}, //
336+
paint);
337+
338+
y += y_spacing;
339+
paint.color = Color::Orange().WithAlpha(config.alpha);
340+
canvas.DrawRRect(Rect::MakeXYWH(x, y, 60.0f, 60.0f), //
341+
{radius, 5.0f}, paint);
342+
343+
y += y_spacing;
344+
paint.color = Color::Maroon().WithAlpha(config.alpha);
345+
canvas.DrawPath(PathBuilder{}
346+
.MoveTo({x + 0, y + 60})
347+
.LineTo({x + 30, y + 0})
348+
.LineTo({x + 60, y + 60})
349+
.Close()
350+
.TakePath(),
351+
paint);
352+
353+
y += y_spacing;
354+
paint.color = Color::Maroon().WithAlpha(config.alpha);
355+
canvas.DrawPath(PathBuilder{}
356+
.AddArc(Rect::MakeXYWH(x + 5, y, 50, 50),
357+
Radians{kPi / 2}, Radians{kPi})
358+
.AddArc(Rect::MakeXYWH(x + 25, y, 50, 50),
359+
Radians{kPi / 2}, Radians{kPi})
360+
.Close()
361+
.TakePath(),
362+
paint);
363+
364+
return canvas.EndRecordingAsPicture();
365+
}
366+
367+
static const std::map<std::string, MaskBlurTestConfig> kPaintVariations = {
368+
// 1. Normal style, translucent, zero sigma.
369+
{"NormalTranslucentZeroSigma",
370+
{.style = FilterContents::BlurStyle::kNormal,
371+
.sigma = 0.0f,
372+
.alpha = 0.5f}},
373+
// 2. Normal style, translucent.
374+
{"NormalTranslucent",
375+
{.style = FilterContents::BlurStyle::kNormal,
376+
.sigma = 8.0f,
377+
.alpha = 0.5f}},
378+
// 3. Solid style, translucent.
379+
{"SolidTranslucent",
380+
{.style = FilterContents::BlurStyle::kSolid,
381+
.sigma = 8.0f,
382+
.alpha = 0.5f}},
383+
// 4. Solid style, opaque.
384+
{"SolidOpaque",
385+
{.style = FilterContents::BlurStyle::kSolid, .sigma = 8.0f}},
386+
// 5. Solid style, translucent, color & image filtered.
387+
{"SolidTranslucentWithFilters",
388+
{.style = FilterContents::BlurStyle::kSolid,
389+
.sigma = 8.0f,
390+
.alpha = 0.5f,
391+
.image_filter = ImageFilter::MakeBlur(Sigma{3},
392+
Sigma{3},
393+
FilterContents::BlurStyle::kNormal,
394+
Entity::TileMode::kClamp),
395+
.invert_colors = true}},
396+
// 6. Solid style, translucent, exclusion blended.
397+
{"SolidTranslucentExclusionBlend",
398+
{.style = FilterContents::BlurStyle::kSolid,
399+
.sigma = 8.0f,
400+
.alpha = 0.5f,
401+
.blend_mode = BlendMode::kExclusion}},
402+
// 7. Inner style, translucent.
403+
{"InnerTranslucent",
404+
{.style = FilterContents::BlurStyle::kInner,
405+
.sigma = 8.0f,
406+
.alpha = 0.5f}},
407+
// 8. Inner style, translucent, blurred.
408+
{"InnerTranslucentWithBlurImageFilter",
409+
{.style = FilterContents::BlurStyle::kInner,
410+
.sigma = 8.0f,
411+
.alpha = 0.5f,
412+
.image_filter = ImageFilter::MakeBlur(Sigma{3},
413+
Sigma{3},
414+
FilterContents::BlurStyle::kNormal,
415+
Entity::TileMode::kClamp)}},
416+
// 9. Outer style, translucent.
417+
{"OuterTranslucent",
418+
{.style = FilterContents::BlurStyle::kOuter,
419+
.sigma = 8.0f,
420+
.alpha = 0.5f}},
421+
// 10. Outer style, opaque, image filtered.
422+
{"OuterOpaqueWithBlurImageFilter",
423+
{.style = FilterContents::BlurStyle::kOuter,
424+
.sigma = 8.0f,
425+
.image_filter = ImageFilter::MakeBlur(Sigma{3},
426+
Sigma{3},
427+
FilterContents::BlurStyle::kNormal,
428+
Entity::TileMode::kClamp)}},
429+
};
430+
431+
#define MASK_BLUR_VARIANT_TEST(config) \
432+
TEST_P(AiksTest, MaskBlurVariantTest##config) { \
433+
ASSERT_TRUE(OpenPlaygroundHere( \
434+
MaskBlurVariantTest(*this, kPaintVariations.at(#config)))); \
435+
}
436+
437+
MASK_BLUR_VARIANT_TEST(NormalTranslucentZeroSigma)
438+
MASK_BLUR_VARIANT_TEST(NormalTranslucent)
439+
MASK_BLUR_VARIANT_TEST(SolidTranslucent)
440+
MASK_BLUR_VARIANT_TEST(SolidOpaque)
441+
MASK_BLUR_VARIANT_TEST(SolidTranslucentWithFilters)
442+
MASK_BLUR_VARIANT_TEST(SolidTranslucentExclusionBlend)
443+
MASK_BLUR_VARIANT_TEST(InnerTranslucent)
444+
MASK_BLUR_VARIANT_TEST(InnerTranslucentWithBlurImageFilter)
445+
MASK_BLUR_VARIANT_TEST(OuterTranslucent)
446+
MASK_BLUR_VARIANT_TEST(OuterOpaqueWithBlurImageFilter)
447+
448+
#undef MASK_BLUR_VARIANT_TEST
449+
284450
TEST_P(AiksTest, GaussianBlurAtPeripheryVertical) {
285451
Canvas canvas;
286452

impeller/aiks/aiks_unittests.cc

Lines changed: 0 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,172 +1614,6 @@ TEST_P(AiksTest, SolidColorCirclesOvalsRRectsMaskBlurCorrectly) {
16141614
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
16151615
}
16161616

1617-
struct MaskBlurTestConfig {
1618-
FilterContents::BlurStyle style = FilterContents::BlurStyle::kNormal;
1619-
Scalar sigma = 1.0f;
1620-
Scalar alpha = 1.0f;
1621-
std::shared_ptr<ImageFilter> image_filter;
1622-
bool invert_colors = false;
1623-
BlendMode blend_mode = BlendMode::kSourceOver;
1624-
};
1625-
1626-
static Picture MaskBlurVariantTest(const AiksTest& test_context,
1627-
const MaskBlurTestConfig& config) {
1628-
Canvas canvas;
1629-
canvas.Scale(test_context.GetContentScale());
1630-
canvas.Scale(Vector2{0.8f, 0.8f});
1631-
Paint paint;
1632-
paint.mask_blur_descriptor = Paint::MaskBlurDescriptor{
1633-
.style = FilterContents::BlurStyle::kNormal,
1634-
.sigma = Sigma{1},
1635-
};
1636-
1637-
canvas.DrawPaint({.color = Color::AntiqueWhite()});
1638-
1639-
paint.mask_blur_descriptor->style = config.style;
1640-
paint.mask_blur_descriptor->sigma = Sigma{config.sigma};
1641-
paint.image_filter = config.image_filter;
1642-
paint.invert_colors = config.invert_colors;
1643-
paint.blend_mode = config.blend_mode;
1644-
1645-
const Scalar x = 50;
1646-
const Scalar radius = 20.0f;
1647-
const Scalar y_spacing = 100.0f;
1648-
1649-
Scalar y = 50;
1650-
paint.color = Color::Crimson().WithAlpha(config.alpha);
1651-
canvas.DrawRect(Rect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
1652-
radius, 60.0f - radius),
1653-
paint);
1654-
1655-
y += y_spacing;
1656-
paint.color = Color::Blue().WithAlpha(config.alpha);
1657-
canvas.DrawCircle({x + 25, y + 25}, radius, paint);
1658-
1659-
y += y_spacing;
1660-
paint.color = Color::Green().WithAlpha(config.alpha);
1661-
canvas.DrawOval(Rect::MakeXYWH(x + 25 - radius / 2, y + radius / 2, //
1662-
radius, 60.0f - radius),
1663-
paint);
1664-
1665-
y += y_spacing;
1666-
paint.color = Color::Purple().WithAlpha(config.alpha);
1667-
canvas.DrawRRect(Rect::MakeXYWH(x, y, 60.0f, 60.0f), //
1668-
{radius, radius}, //
1669-
paint);
1670-
1671-
y += y_spacing;
1672-
paint.color = Color::Orange().WithAlpha(config.alpha);
1673-
canvas.DrawRRect(Rect::MakeXYWH(x, y, 60.0f, 60.0f), //
1674-
{radius, 5.0f}, paint);
1675-
1676-
y += y_spacing;
1677-
paint.color = Color::Maroon().WithAlpha(config.alpha);
1678-
canvas.DrawPath(PathBuilder{}
1679-
.MoveTo({x + 0, y + 60})
1680-
.LineTo({x + 30, y + 0})
1681-
.LineTo({x + 60, y + 60})
1682-
.Close()
1683-
.TakePath(),
1684-
paint);
1685-
1686-
y += y_spacing;
1687-
paint.color = Color::Maroon().WithAlpha(config.alpha);
1688-
canvas.DrawPath(PathBuilder{}
1689-
.AddArc(Rect::MakeXYWH(x + 5, y, 50, 50),
1690-
Radians{kPi / 2}, Radians{kPi})
1691-
.AddArc(Rect::MakeXYWH(x + 25, y, 50, 50),
1692-
Radians{kPi / 2}, Radians{kPi})
1693-
.Close()
1694-
.TakePath(),
1695-
paint);
1696-
1697-
return canvas.EndRecordingAsPicture();
1698-
}
1699-
1700-
static const std::map<std::string, MaskBlurTestConfig> kPaintVariations = {
1701-
// 1. Normal style, translucent, zero sigma.
1702-
{"NormalTranslucentZeroSigma",
1703-
{.style = FilterContents::BlurStyle::kNormal,
1704-
.sigma = 0.0f,
1705-
.alpha = 0.5f}},
1706-
// 2. Normal style, translucent.
1707-
{"NormalTranslucent",
1708-
{.style = FilterContents::BlurStyle::kNormal,
1709-
.sigma = 8.0f,
1710-
.alpha = 0.5f}},
1711-
// 3. Solid style, translucent.
1712-
{"SolidTranslucent",
1713-
{.style = FilterContents::BlurStyle::kSolid,
1714-
.sigma = 8.0f,
1715-
.alpha = 0.5f}},
1716-
// 4. Solid style, opaque.
1717-
{"SolidOpaque",
1718-
{.style = FilterContents::BlurStyle::kSolid, .sigma = 8.0f}},
1719-
// 5. Solid style, translucent, color & image filtered.
1720-
{"SolidTranslucentWithFilters",
1721-
{.style = FilterContents::BlurStyle::kSolid,
1722-
.sigma = 8.0f,
1723-
.alpha = 0.5f,
1724-
.image_filter = ImageFilter::MakeBlur(Sigma{3},
1725-
Sigma{3},
1726-
FilterContents::BlurStyle::kNormal,
1727-
Entity::TileMode::kClamp),
1728-
.invert_colors = true}},
1729-
// 6. Solid style, translucent, exclusion blended.
1730-
{"SolidTranslucentExclusionBlend",
1731-
{.style = FilterContents::BlurStyle::kSolid,
1732-
.sigma = 8.0f,
1733-
.alpha = 0.5f,
1734-
.blend_mode = BlendMode::kExclusion}},
1735-
// 7. Inner style, translucent.
1736-
{"InnerTranslucent",
1737-
{.style = FilterContents::BlurStyle::kInner,
1738-
.sigma = 8.0f,
1739-
.alpha = 0.5f}},
1740-
// 8. Inner style, translucent, blurred.
1741-
{"InnerTranslucentWithBlurImageFilter",
1742-
{.style = FilterContents::BlurStyle::kInner,
1743-
.sigma = 8.0f,
1744-
.alpha = 0.5f,
1745-
.image_filter = ImageFilter::MakeBlur(Sigma{3},
1746-
Sigma{3},
1747-
FilterContents::BlurStyle::kNormal,
1748-
Entity::TileMode::kClamp)}},
1749-
// 9. Outer style, translucent.
1750-
{"OuterTranslucent",
1751-
{.style = FilterContents::BlurStyle::kOuter,
1752-
.sigma = 8.0f,
1753-
.alpha = 0.5f}},
1754-
// 10. Outer style, opaque, image filtered.
1755-
{"OuterOpaqueWithBlurImageFilter",
1756-
{.style = FilterContents::BlurStyle::kOuter,
1757-
.sigma = 8.0f,
1758-
.image_filter = ImageFilter::MakeBlur(Sigma{3},
1759-
Sigma{3},
1760-
FilterContents::BlurStyle::kNormal,
1761-
Entity::TileMode::kClamp)}},
1762-
};
1763-
1764-
#define MASK_BLUR_VARIANT_TEST(config) \
1765-
TEST_P(AiksTest, MaskBlurVariantTest##config) { \
1766-
ASSERT_TRUE(OpenPlaygroundHere( \
1767-
MaskBlurVariantTest(*this, kPaintVariations.at(#config)))); \
1768-
}
1769-
1770-
MASK_BLUR_VARIANT_TEST(NormalTranslucentZeroSigma)
1771-
MASK_BLUR_VARIANT_TEST(NormalTranslucent)
1772-
MASK_BLUR_VARIANT_TEST(SolidTranslucent)
1773-
MASK_BLUR_VARIANT_TEST(SolidOpaque)
1774-
MASK_BLUR_VARIANT_TEST(SolidTranslucentWithFilters)
1775-
MASK_BLUR_VARIANT_TEST(SolidTranslucentExclusionBlend)
1776-
MASK_BLUR_VARIANT_TEST(InnerTranslucent)
1777-
MASK_BLUR_VARIANT_TEST(InnerTranslucentWithBlurImageFilter)
1778-
MASK_BLUR_VARIANT_TEST(OuterTranslucent)
1779-
MASK_BLUR_VARIANT_TEST(OuterOpaqueWithBlurImageFilter)
1780-
1781-
#undef MASK_BLUR_VARIANT_TEST
1782-
17831617
TEST_P(AiksTest, FilledRoundRectPathsRenderCorrectly) {
17841618
Canvas canvas;
17851619
canvas.Scale(GetContentScale());

0 commit comments

Comments
 (0)