Flutter Engine
 
Loading...
Searching...
No Matches
dl_canvas_unittests.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include "gtest/gtest.h"
8
9namespace flutter {
10namespace testing {
11
12TEST(DisplayListCanvas, GetShadowBoundsScaleTranslate) {
13 DlMatrix matrix =
14 DlMatrix::MakeTranslateScale({5.0f, 7.0f, 1.0f}, {10.0f, 15.0f, 7.0f});
15 DlPath path = DlPath::MakeRectLTRB(100, 100, 200, 200);
16
17 DlRect shadow_bounds =
18 DlCanvas::ComputeShadowBounds(path, 5.0f, 2.0f, matrix);
19
20 EXPECT_FLOAT_EQ(shadow_bounds.GetLeft(), 96.333336f);
21 EXPECT_FLOAT_EQ(shadow_bounds.GetTop(), 97.761909f);
22 EXPECT_FLOAT_EQ(shadow_bounds.GetRight(), 203.66667f);
23 EXPECT_FLOAT_EQ(shadow_bounds.GetBottom(), 205.09525f);
24}
25
26TEST(DisplayListCanvas, GetShadowBoundsScaleTranslateRotate) {
27 DlMatrix matrix =
28 DlMatrix::MakeTranslateScale({5.0f, 7.0f, 1.0f}, {10.0f, 15.0f, 7.0f});
29 matrix = matrix * DlMatrix::MakeRotationZ(DlDegrees(45));
30 DlPath path = DlPath::MakeRectLTRB(100, 100, 200, 200);
31
32 DlRect shadow_bounds =
33 DlCanvas::ComputeShadowBounds(path, 5.0f, 2.0f, matrix);
34
35 EXPECT_FLOAT_EQ(shadow_bounds.GetLeft(), 97.343491f);
36 EXPECT_FLOAT_EQ(shadow_bounds.GetTop(), 97.343491f);
37 EXPECT_FLOAT_EQ(shadow_bounds.GetRight(), 204.67682f);
38 EXPECT_FLOAT_EQ(shadow_bounds.GetBottom(), 204.67682f);
39}
40
41TEST(DisplayListCanvas, GetShadowBoundsScaleTranslatePerspective) {
42 DlMatrix matrix =
43 DlMatrix::MakeTranslateScale({5.0f, 7.0f, 1.0f}, {10.0f, 15.0f, 7.0f});
44 matrix.m[3] = 0.001f;
45 DlPath path = DlPath::MakeRectLTRB(100, 100, 200, 200);
46
47 DlRect shadow_bounds =
48 DlCanvas::ComputeShadowBounds(path, 5.0f, 2.0f, matrix);
49
50 EXPECT_FLOAT_EQ(shadow_bounds.GetLeft(), 96.535324f);
51 EXPECT_FLOAT_EQ(shadow_bounds.GetTop(), 90.253288f);
52 EXPECT_FLOAT_EQ(shadow_bounds.GetRight(), 204.15054f);
53 EXPECT_FLOAT_EQ(shadow_bounds.GetBottom(), 223.3252f);
54}
55
56} // namespace testing
57} // namespace flutter
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...
Definition dl_canvas.cc:125
static DlPath MakeRectLTRB(DlScalar left, DlScalar top, DlScalar right, DlScalar bottom)
Definition dl_path.cc:43
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::Degrees DlDegrees
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switch_defs.h:52
A 4x4 matrix using column-major storage.
Definition matrix.h:37
Scalar m[16]
Definition matrix.h:39
static constexpr Matrix MakeTranslateScale(const Vector3 &s, const Vector3 &t)
Definition matrix.h:113
static Matrix MakeRotationZ(Radians r)
Definition matrix.h:223
constexpr auto GetBottom() const
Definition rect.h:357
constexpr auto GetTop() const
Definition rect.h:353
constexpr auto GetLeft() const
Definition rect.h:351
constexpr auto GetRight() const
Definition rect.h:355