5#include "flutter/display_list/dl_blend_mode.h"
6#include "flutter/display_list/dl_paint.h"
7#include "flutter/display_list/dl_sampling_options.h"
8#include "flutter/display_list/dl_tile_mode.h"
9#include "flutter/display_list/dl_vertices.h"
10#include "flutter/display_list/effects/dl_color_source.h"
11#include "flutter/display_list/skia/dl_sk_conversions.h"
12#include "gtest/gtest.h"
20TEST(DisplayListImageFilter, LocalImageSkiaNull) {
27 ASSERT_EQ(
ToSk(dl_local_matrix_filter),
nullptr);
30TEST(DisplayListSkConversions, ToSkColor) {
41 auto const grey_hex_half_opaque = 0x7F999999;
45TEST(DisplayListSkConversions, ToSkTileMode) {
52TEST(DisplayListSkConversions, ToSkBlurStyle) {
59TEST(DisplayListSkConversions, ToSkDrawStyle) {
63 SkPaint::Style::kStrokeAndFill_Style);
66TEST(DisplayListSkConversions, ToSkStrokeCap) {
72TEST(DisplayListSkConversions, ToSkStrokeJoin) {
78TEST(DisplayListSkConversions, ToSkVertexMode) {
80 SkVertices::VertexMode::kTriangles_VertexMode);
82 SkVertices::VertexMode::kTriangleStrip_VertexMode);
84 SkVertices::VertexMode::kTriangleFan_VertexMode);
87TEST(DisplayListSkConversions, ToSkFilterMode) {
93TEST(DisplayListSkConversions, ToSkSrcRectConstraint) {
95 SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint);
97 SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint);
100TEST(DisplayListSkConversions, ToSkSamplingOptions) {
111#define FOR_EACH_BLEND_MODE_ENUM(FUNC) \
142 FUNC(kLastCoeffMode) \
143 FUNC(kLastSeparableMode) \
146TEST(DisplayListSkConversions, ToSkBlendMode){
147#define CHECK_TO_SKENUM(V) ASSERT_EQ(ToSk(DlBlendMode::V), SkBlendMode::V);
149#undef CHECK_TO_SKENUM
152TEST(DisplayListSkConversions, BlendColorFilterModifiesTransparency) {
154 std::stringstream desc_str;
155 desc_str <<
"blend[" <<
static_cast<int>(
mode) <<
", " <<
color.argb()
157 std::string
desc = desc_str.str();
162 auto sk_filter =
ToSk(filter);
163 ASSERT_NE(dl_filter,
nullptr) <<
desc;
164 ASSERT_NE(sk_filter,
nullptr) <<
desc;
171 auto sk_filter =
ToSk(filter);
172 EXPECT_EQ(dl_filter ==
nullptr, sk_filter ==
nullptr) <<
desc;
173 ASSERT_TRUE(sk_filter ==
nullptr ||
189#define TEST_MODE(V) test_mode(DlBlendMode::V);
194#undef FOR_EACH_BLEND_MODE_ENUM
196TEST(DisplayListSkConversions, ConvertWithZeroAndNegativeVerticesAndIndices) {
199 EXPECT_NE(vertices1,
nullptr);
200 EXPECT_NE(
ToSk(vertices1),
nullptr);
204 EXPECT_NE(vertices2,
nullptr);
205 EXPECT_NE(
ToSk(vertices2),
nullptr);
208TEST(DisplayListVertices, ConvertWithZeroAndNegativeVerticesAndIndices) {
212 std::shared_ptr<DlVertices> vertices1 = builder1.
build();
213 EXPECT_NE(vertices1,
nullptr);
214 EXPECT_NE(
ToSk(vertices1),
nullptr);
219 std::shared_ptr<DlVertices> vertices2 = builder2.
build();
220 EXPECT_NE(vertices2,
nullptr);
221 EXPECT_NE(
ToSk(vertices2),
nullptr);
224TEST(DisplayListColorSource, ConvertRuntimeEffect) {
227 SkString(
"vec4 main(vec2 p) { return vec4(0); }"))
231 SkString(
"vec4 main(vec2 p) { return vec4(1); }"))
233 std::shared_ptr<DlRuntimeEffectColorSource> source1 =
236 std::shared_ptr<DlRuntimeEffectColorSource> source2 =
239 std::shared_ptr<DlRuntimeEffectColorSource> source3 =
241 nullptr, {}, std::make_shared<std::vector<uint8_t>>());
243 ASSERT_NE(
ToSk(source1),
nullptr);
244 ASSERT_NE(
ToSk(source2),
nullptr);
245 ASSERT_EQ(
ToSk(source3),
nullptr);
248TEST(DisplayListColorSource, ConvertRuntimeEffectWithNullSampler) {
251 SkString(
"vec4 main(vec2 p) { return vec4(0); }"))
253 std::shared_ptr<DlRuntimeEffectColorSource> source1 =
256 std::make_shared<std::vector<uint8_t>>());
258 ASSERT_EQ(
ToSk(source1),
nullptr);
261TEST(DisplayListSkConversions, MatrixColorFilterModifiesTransparency) {
276 auto sk_filter =
ToSk(filter);
278 EXPECT_EQ(dl_filter ==
nullptr, sk_filter ==
nullptr);
281 srgb.get(), srgb.get()) !=
288 for (
int i = 0;
i < 20;
i++) {
300TEST(DisplayListSkConversions, ToSkDitheringEnabledForGradients) {
static void test_matrix(skiatest::Reporter *reporter)
@ kOuter_SkBlurStyle
nothing inside, fuzzy outside
@ kSolid_SkBlurStyle
solid inside, fuzzy outside
@ kInner_SkBlurStyle
fuzzy inside, nothing outside
@ kNormal_SkBlurStyle
fuzzy inside and outside
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
#define SK_ScalarInfinity
static sk_sp< SkColorSpace > MakeSRGB()
static SkMatrix RotateDeg(SkScalar deg)
static Result MakeForShader(SkString sksl, const Options &)
static std::shared_ptr< DlColorFilter > Make(DlColor color, DlBlendMode mode)
bool modifies_transparent_black() const override
static std::shared_ptr< DlRuntimeEffectColorSource > MakeRuntimeEffect(sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)
static std::shared_ptr< DlLinearGradientColorSource > MakeLinear(const SkPoint start_point, const SkPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
static std::shared_ptr< DlColorFilter > Make(const float matrix[20])
bool modifies_transparent_black() const override
DlPaint & setColorSource(std::shared_ptr< const DlColorSource > source)
static sk_sp< DlRuntimeEffect > MakeSkia(const sk_sp< SkRuntimeEffect > &runtime_effect)
A utility class to build up a |DlVertices| object one set of data at a time.
static constexpr Flags kNone
std::shared_ptr< DlVertices > build()
Finalizes and the constructed DlVertices object.
bool is_valid()
Returns true iff the underlying object was successfully allocated.
static std::shared_ptr< DlVertices > Make(DlVertexMode mode, int vertex_count, const SkPoint vertices[], const SkPoint texture_coordinates[], const DlColor colors[], int index_count=0, const uint16_t indices[]=nullptr)
Constructs a DlVector with compact inline storage for all of its required and optional lists of data.
#define CHECK_TO_SKENUM(V)
#define FOR_EACH_BLEND_MODE_ENUM(FUNC)
constexpr SkColor4f kTransparent
unsigned useCenter Optional< SkMatrix > matrix
static const sk_sp< DlRuntimeEffect > kTestRuntimeEffect1
static const sk_sp< DlRuntimeEffect > kTestRuntimeEffect2
TEST(DisplayListComplexity, EmptyDisplayList)
SkPaint ToSk(const DlPaint &paint)
@ kMiter
extends to miter limit
@ kBevel
connects outside edges
@ kButt
no stroke extension
SkPaint ToStrokedSk(const DlPaint &paint)
@ kTriangles
The vertices are taken 3 at a time to form a triangle.
SkPaint ToNonShaderSk(const DlPaint &paint)
@ kStrokeAndFill
both strokes and fills shapes
@ kStroke
strokes boundary of shapes
@ kFill
fills interior of shapes
@ kNormal
fuzzy inside and outside
@ kOuter
nothing inside, fuzzy outside
@ kInner
fuzzy inside, nothing outside
@ kSolid
solid inside, fuzzy outside
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
SkSamplingOptions(SkFilterMode::kLinear))
static SkString to_string(int n)
static constexpr SkPoint Make(float x, float y)
static constexpr DlColor kWhite()
static constexpr DlColor kBlue()
static constexpr DlColor kBlack()
static constexpr DlColor kTransparent()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
#define EXPECT_TRUE(handle)