2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
+ #include < cmath>
6
+ #include < vector>
5
7
#include " display_list/display_list_blend_mode.h"
6
8
#include " display_list/display_list_color.h"
7
9
#include " display_list/display_list_color_filter.h"
14
16
#include " flutter/testing/testing.h"
15
17
#include " impeller/display_list/display_list_image_impeller.h"
16
18
#include " impeller/display_list/display_list_playground.h"
19
+ #include " impeller/geometry/constants.h"
17
20
#include " impeller/geometry/point.h"
18
21
#include " impeller/playground/widgets.h"
19
22
#include " include/core/SkRRect.h"
@@ -653,11 +656,29 @@ TEST_P(DisplayListTest, CanDrawZeroLengthLine) {
653
656
654
657
TEST_P (DisplayListTest, CanDrawShadow) {
655
658
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 = {
657
677
SkPath{}.addRect (SkRect::MakeXYWH (0 , 0 , 200 , 100 )),
658
678
SkPath{}.addRRect (
659
679
SkRRect::MakeRectXY (SkRect::MakeXYWH (0 , 0 , 200 , 100 ), 30 , 30 )),
660
680
SkPath{}.addCircle (100 , 50 , 50 ),
681
+ SkPath{}.addPoly (star.data (), star.size (), true ),
661
682
};
662
683
builder.setColor (flutter::DlColor::kWhite ());
663
684
builder.drawPaint ();
@@ -676,7 +697,7 @@ TEST_P(DisplayListTest, CanDrawShadow) {
676
697
}
677
698
678
699
ASSERT_TRUE (OpenPlaygroundHere (builder.Build ()));
679
- }
700
+ } // namespace testing
680
701
681
702
// Draw a hexagon using triangle fan
682
703
TEST_P (DisplayListTest, CanConvertTriangleFanToTriangles) {
0 commit comments