| Flutter Impeller |

aiks_gradient_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 "flutter/impeller/aiks/aiks_unittests.h"
6
7 #include "impeller/aiks/canvas.h"
8 #include "impeller/entity/contents/conical_gradient_contents.h"
9 #include "impeller/entity/contents/linear_gradient_contents.h"
10 #include "impeller/entity/contents/radial_gradient_contents.h"
11 #include "impeller/entity/contents/sweep_gradient_contents.h"
12 #include "impeller/geometry/geometry_asserts.h"
13 #include "impeller/geometry/path_builder.h"
14 #include "impeller/playground/widgets.h"
15 #include "third_party/imgui/imgui.h"
16
17 ////////////////////////////////////////////////////////////////////////////////
18 // This is for tests of Canvas that are interested the results of rendering
19 // gradients.
20 ////////////////////////////////////////////////////////////////////////////////
21
22 namespace impeller {
23 namespace testing {
24
25 #define APPLY_COLOR_FILTER_GRADIENT_TEST(name) \
26 TEST_P(AiksTest, name##GradientApplyColorFilter) { \
27 auto contents = name##GradientContents(); \
28 contents.SetColors({Color::CornflowerBlue().WithAlpha(0.75)}); \
29 auto result = contents.ApplyColorFilter([](const Color& color) { \
30 return color.Blend(Color::LimeGreen().WithAlpha(0.75), \
31 BlendMode::kScreen); \
32 }); \
33 ASSERT_TRUE(result); \
34 \
35 std::vector<Color> expected = {Color(0.433247, 0.879523, 0.825324, 0.75)}; \
36 ASSERT_COLORS_NEAR(contents.GetColors(), expected); \
37 }
38
39 APPLY_COLOR_FILTER_GRADIENT_TEST(Linear);
40 APPLY_COLOR_FILTER_GRADIENT_TEST(Radial);
41 APPLY_COLOR_FILTER_GRADIENT_TEST(Conical);
42 APPLY_COLOR_FILTER_GRADIENT_TEST(Sweep);
43
44 } // namespace testing
45 } // namespace impeller
geometry_asserts.h
aiks_unittests.h
sweep_gradient_contents.h
path_builder.h
widgets.h
conical_gradient_contents.h
canvas.h
radial_gradient_contents.h
impeller::testing::APPLY_COLOR_FILTER_GRADIENT_TEST
APPLY_COLOR_FILTER_GRADIENT_TEST(Linear)
impeller
Definition: aiks_blend_unittests.cc:18
linear_gradient_contents.h