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

[Impeller] Add non-rrect polygon to shadow test #37296

Merged
merged 3 commits into from
Nov 4, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions impeller/display_list/display_list_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <cmath>
#include <vector>

#include "display_list/display_list_blend_mode.h"
#include "display_list/display_list_color.h"
#include "display_list/display_list_color_filter.h"
Expand All @@ -14,6 +17,7 @@
#include "flutter/testing/testing.h"
#include "impeller/display_list/display_list_image_impeller.h"
#include "impeller/display_list/display_list_playground.h"
#include "impeller/geometry/constants.h"
#include "impeller/geometry/point.h"
#include "impeller/playground/widgets.h"
#include "include/core/SkRRect.h"
Expand Down Expand Up @@ -653,11 +657,29 @@ TEST_P(DisplayListTest, CanDrawZeroLengthLine) {

TEST_P(DisplayListTest, CanDrawShadow) {
flutter::DisplayListBuilder builder;
std::array<SkPath, 3> paths = {

constexpr size_t star_spikes = 5;
constexpr SkScalar half_spike_rotation = kPi / 5;
constexpr SkScalar radius = 40;
constexpr SkScalar spike_size = 10;
constexpr SkScalar outer_radius = radius + spike_size;
constexpr SkScalar inner_radius = radius - spike_size;
std::array<SkPoint, star_spikes * 2> star;
for (size_t i = 0; i < star_spikes; i++) {
const SkScalar rotation = half_spike_rotation * i * 2;
star[i * 2] = SkPoint::Make(50 + std::sin(rotation) * outer_radius,
50 - std::cos(rotation) * outer_radius);
star[i * 2 + 1] = SkPoint::Make(
50 + std::sin(rotation + half_spike_rotation) * inner_radius,
50 - std::cos(rotation + half_spike_rotation) * inner_radius);
}

std::array<SkPath, 4> paths = {
SkPath{}.addRect(SkRect::MakeXYWH(0, 0, 200, 100)),
SkPath{}.addRRect(
SkRRect::MakeRectXY(SkRect::MakeXYWH(0, 0, 200, 100), 30, 30)),
SkPath{}.addCircle(100, 50, 50),
SkPath{}.addPoly(star.data(), star.size(), true),
};
builder.setColor(flutter::DlColor::kWhite());
builder.drawPaint();
Expand All @@ -676,7 +698,7 @@ TEST_P(DisplayListTest, CanDrawShadow) {
}

ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
} // namespace testing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Don't think this is the end of the namespace. Perhaps your editor is confused?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! I trigger clang format runs in the middle of writing code often. Fixed.


// Draw a hexagon using triangle fan
TEST_P(DisplayListTest, CanConvertTriangleFanToTriangles) {
Expand Down