8#include "flutter/third_party/skia/include/utils/SkShadowUtils.h"
9#include "gtest/gtest.h"
16void TestShadowBounds(
bool with_rotate,
bool with_perspective) {
17 const SkVector3 light_position = SkVector3::Make(0.0f, -1.0f, 1.0f);
22 for (
int dpr = 1; dpr <= 2; dpr++) {
23 for (
int elevation = 1; elevation <= 5; elevation++) {
24 SkVector3 z_params = SkVector3::Make(0.0f, 0.0f, elevation * dpr);
25 for (
int i = 1;
i <= 10;
i++) {
27 for (
int j = 1; j <= 10; j++) {
31 {10.0f, 15.0f, 7.0f});
35 if (with_perspective) {
41 ASSERT_TRUE(
sk_matrix.invert(&sk_inverse));
43 auto label = (std::stringstream()
44 <<
"Matrix: " << matrix <<
", elevation = " << elevation
51 ASSERT_TRUE(SkShadowUtils::GetLocalBounds(
52 sk_matrix, dl_path.GetSkPath(), z_params, light_position,
53 light_radius, kDirectionalLight_ShadowFlag, &sk_bounds))
55 EXPECT_FLOAT_EQ(dl_bounds.GetLeft(), sk_bounds.fLeft) << label;
56 EXPECT_FLOAT_EQ(dl_bounds.GetTop(), sk_bounds.fTop) << label;
57 EXPECT_FLOAT_EQ(dl_bounds.GetRight(), sk_bounds.fRight) << label;
58 EXPECT_FLOAT_EQ(dl_bounds.GetBottom(), sk_bounds.fBottom) << label;
67TEST(DlSkCanvas, ShadowBoundsCompatibilityTranslateScale) {
68 TestShadowBounds(
false,
false);
71TEST(DlSkCanvas, ShadowBoundsCompatibilityTranslateScaleRotate) {
72 TestShadowBounds(
true,
false);
75TEST(DlSkCanvas, ShadowBoundsCompatibilityTranslateScalePerspective) {
76 TestShadowBounds(
false,
true);
static constexpr DlScalar kShadowLightHeight
static constexpr DlScalar kShadowLightRadius
static DlRect ComputeShadowBounds(const DlPath &path, float elevation, DlScalar dpr, const DlMatrix &ctm)
Compute the local coverage for a |DrawShadow| operation using the given parameters (excluding the col...
static DlPath MakeRectLTRB(DlScalar left, DlScalar top, DlScalar right, DlScalar bottom)
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::Scalar DlScalar
SkPaint ToSk(const DlPaint &paint)
impeller::Matrix DlMatrix
impeller::Degrees DlDegrees
static constexpr Matrix MakeTranslateScale(const Vector3 &s, const Vector3 &t)
static Matrix MakeRotationZ(Radians r)