Flutter Engine
The Flutter Engine
filter_input_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
5#include <memory>
6#include "flutter/testing/testing.h"
7#include "gtest/gtest.h"
13
14namespace impeller {
15namespace testing {
16
17TEST(FilterInputTest, CanSetLocalTransformForTexture) {
18 std::shared_ptr<Texture> texture = nullptr;
19 auto input =
21 Entity e;
22 e.SetTransform(Matrix::MakeTranslation({0.0, 2.0, 0.0}));
23
24 ASSERT_MATRIX_NEAR(input->GetLocalTransform(e),
25 Matrix::MakeTranslation({1.0, 0.0, 0.0}));
26 ASSERT_MATRIX_NEAR(input->GetTransform(e),
27 Matrix::MakeTranslation({1.0, 2.0, 0.0}));
28}
29
30TEST(FilterInputTest, IsLeaf) {
31 std::shared_ptr<FilterContents> leaf =
33 ASSERT_TRUE(leaf->IsLeaf());
34
36 Matrix(), {});
37
38 ASSERT_TRUE(leaf->IsLeaf());
39 ASSERT_FALSE(base->IsLeaf());
40}
41
42TEST(FilterInputTest, SetCoverageInputs) {
43 std::shared_ptr<FilterContents> leaf =
45 ASSERT_TRUE(leaf->IsLeaf());
46
48 Matrix(), {});
49
50 {
51 auto result = base->GetCoverage({});
52 ASSERT_FALSE(result.has_value());
53 }
54
55 auto coverage_rect = Rect::MakeLTRB(100, 100, 200, 200);
56 base->SetLeafInputs(FilterInput::Make({coverage_rect}));
57
58 {
59 auto result = base->GetCoverage({});
60 ASSERT_TRUE(result.has_value());
61 // NOLINTNEXTLINE(bugprone-unchecked-optional-access)
62 ASSERT_RECT_NEAR(result.value(), coverage_rect);
63 }
64}
65
66} // namespace testing
67} // namespace impeller
static std::shared_ptr< ColorFilterContents > MakeBlend(BlendMode blend_mode, FilterInput::Vector inputs, std::optional< Color > foreground_color=std::nullopt)
the [inputs] are expected to be in the order of dst, src.
static std::shared_ptr< FilterContents > MakeMatrixFilter(FilterInput::Ref input, const Matrix &matrix, const SamplerDescriptor &desc)
static FilterInput::Ref Make(Variant input, bool msaa_enabled=true)
Definition: filter_input.cc:19
GAsyncResult * result
#define ASSERT_RECT_NEAR(a, b)
#define ASSERT_MATRIX_NEAR(a, b)
FlTexture * texture
TEST(AiksCanvasTest, EmptyCullRect)
SK_API sk_sp< PrecompileColorFilter > Matrix()
static constexpr Matrix MakeTranslation(const Vector3 &t)
Definition: matrix.h:95
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition: rect.h:129