Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 18a7409

Browse files
committed
Add non-rrect shadow to test
1 parent 2a94917 commit 18a7409

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

impeller/display_list/display_list_unittests.cc

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#include <cmath>
6+
#include <vector>
57
#include "display_list/display_list_blend_mode.h"
68
#include "display_list/display_list_color.h"
79
#include "display_list/display_list_color_filter.h"
@@ -14,6 +16,7 @@
1416
#include "flutter/testing/testing.h"
1517
#include "impeller/display_list/display_list_image_impeller.h"
1618
#include "impeller/display_list/display_list_playground.h"
19+
#include "impeller/geometry/constants.h"
1720
#include "impeller/geometry/point.h"
1821
#include "impeller/playground/widgets.h"
1922
#include "include/core/SkRRect.h"
@@ -653,11 +656,29 @@ TEST_P(DisplayListTest, CanDrawZeroLengthLine) {
653656

654657
TEST_P(DisplayListTest, CanDrawShadow) {
655658
flutter::DisplayListBuilder builder;
656-
std::array<SkPath, 3> paths = {
659+
660+
constexpr size_t star_spikes = 5;
661+
constexpr SkScalar half_spike_rotation = kPi / 5;
662+
constexpr SkScalar radius = 40;
663+
constexpr SkScalar spike_size = 10;
664+
constexpr SkScalar outer_radius = radius + spike_size;
665+
constexpr SkScalar inner_radius = radius - spike_size;
666+
std::array<SkPoint, star_spikes * 2> star;
667+
for (size_t i = 0; i < star_spikes; i++) {
668+
const SkScalar rotation = half_spike_rotation * i * 2;
669+
star[i * 2] = SkPoint::Make(50 + std::sin(rotation) * outer_radius,
670+
50 - std::cos(rotation) * outer_radius);
671+
star[i * 2 + 1] = SkPoint::Make(
672+
50 + std::sin(rotation + half_spike_rotation) * inner_radius,
673+
50 - std::cos(rotation + half_spike_rotation) * inner_radius);
674+
}
675+
676+
std::array<SkPath, 4> paths = {
657677
SkPath{}.addRect(SkRect::MakeXYWH(0, 0, 200, 100)),
658678
SkPath{}.addRRect(
659679
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 200, 100), 30, 30)),
660680
SkPath{}.addCircle(100, 50, 50),
681+
SkPath{}.addPoly(star.data(), star.size(), true),
661682
};
662683
builder.setColor(flutter::DlColor::kWhite());
663684
builder.drawPaint();
@@ -676,7 +697,7 @@ TEST_P(DisplayListTest, CanDrawShadow) {
676697
}
677698

678699
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
679-
}
700+
} // namespace testing
680701

681702
// Draw a hexagon using triangle fan
682703
TEST_P(DisplayListTest, CanConvertTriangleFanToTriangles) {

0 commit comments

Comments
 (0)