9#include "flutter/display_list/dl_sampling_options.h"
10#include "flutter/display_list/effects/dl_color_source.h"
11#include "flutter/display_list/effects/dl_runtime_effect.h"
12#include "flutter/display_list/image/dl_image.h"
13#include "flutter/display_list/testing/dl_test_equality.h"
38 SkString(
"vec4 main(vec2 p) { return vec4(0); }"))
43 SkString(
"vec4 main(vec2 p) { return vec4(1); }"))
89TEST(DisplayListColorSource, ColorConstructor) {
93TEST(DisplayListColorSource, ColorShared) {
99TEST(DisplayListColorSource, ColorAsColor) {
101 ASSERT_NE(
source.asColor(),
nullptr);
105 ASSERT_EQ(
source.asLinearGradient(),
nullptr);
106 ASSERT_EQ(
source.asRadialGradient(),
nullptr);
107 ASSERT_EQ(
source.asConicalGradient(),
nullptr);
108 ASSERT_EQ(
source.asSweepGradient(),
nullptr);
109 ASSERT_EQ(
source.asRuntimeEffect(),
nullptr);
112TEST(DisplayListColorSource, ColorContents) {
115 ASSERT_EQ(
source.is_opaque(),
true);
116 for (
int i = 0;
i < 255;
i++) {
119 ASSERT_EQ(alpha_source.color(), alpha_color);
120 ASSERT_EQ(alpha_source.is_opaque(),
false);
124TEST(DisplayListColorSource, ColorEquals) {
130TEST(DisplayListColorSource, ColorNotEquals) {
136TEST(DisplayListColorSource, ImageConstructor) {
141TEST(DisplayListColorSource, ImageShared) {
148TEST(DisplayListColorSource, ImageAsImage) {
154 ASSERT_EQ(
source.asColor(),
nullptr);
155 ASSERT_EQ(
source.asLinearGradient(),
nullptr);
156 ASSERT_EQ(
source.asRadialGradient(),
nullptr);
157 ASSERT_EQ(
source.asConicalGradient(),
nullptr);
158 ASSERT_EQ(
source.asSweepGradient(),
nullptr);
161TEST(DisplayListColorSource, ImageContents) {
170 ASSERT_EQ(
source.is_opaque(),
true);
173TEST(DisplayListColorSource, AlphaImageContents) {
182 ASSERT_EQ(
source.is_opaque(),
false);
185TEST(DisplayListColorSource, ImageEquals) {
195TEST(DisplayListColorSource, ImageNotEquals) {
231TEST(DisplayListColorSource, LinearGradientConstructor) {
237TEST(DisplayListColorSource, LinearGradientShared) {
245TEST(DisplayListColorSource, LinearGradientAsLinear) {
249 ASSERT_NE(
source->asLinearGradient(),
nullptr);
252 ASSERT_EQ(
source->asColor(),
nullptr);
254 ASSERT_EQ(
source->asRadialGradient(),
nullptr);
255 ASSERT_EQ(
source->asConicalGradient(),
nullptr);
256 ASSERT_EQ(
source->asSweepGradient(),
nullptr);
257 ASSERT_EQ(
source->asRuntimeEffect(),
nullptr);
260TEST(DisplayListColorSource, LinearGradientContents) {
273 ASSERT_EQ(
source->is_opaque(),
true);
276TEST(DisplayListColorSource, AlphaLinearGradientContents) {
289 ASSERT_EQ(
source->is_opaque(),
false);
292TEST(DisplayListColorSource, LinearGradientEquals) {
302TEST(DisplayListColorSource, LinearGradientNotEquals) {
350TEST(DisplayListColorSource, RadialGradientConstructor) {
356TEST(DisplayListColorSource, RadialGradientShared) {
364TEST(DisplayListColorSource, RadialGradientAsRadial) {
368 ASSERT_NE(
source->asRadialGradient(),
nullptr);
371 ASSERT_EQ(
source->asColor(),
nullptr);
373 ASSERT_EQ(
source->asLinearGradient(),
nullptr);
374 ASSERT_EQ(
source->asConicalGradient(),
nullptr);
375 ASSERT_EQ(
source->asSweepGradient(),
nullptr);
376 ASSERT_EQ(
source->asRuntimeEffect(),
nullptr);
379TEST(DisplayListColorSource, RadialGradientContents) {
384 ASSERT_EQ(
source->asRadialGradient()->radius(), 10.0);
392 ASSERT_EQ(
source->is_opaque(),
true);
395TEST(DisplayListColorSource, AlphaRadialGradientContents) {
400 ASSERT_EQ(
source->asRadialGradient()->radius(), 10.0);
408 ASSERT_EQ(
source->is_opaque(),
false);
411TEST(DisplayListColorSource, RadialGradientEquals) {
421TEST(DisplayListColorSource, RadialGradientNotEquals) {
469TEST(DisplayListColorSource, ConicalGradientConstructor) {
475TEST(DisplayListColorSource, ConicalGradientShared) {
483TEST(DisplayListColorSource, ConicalGradientAsConical) {
487 ASSERT_NE(
source->asConicalGradient(),
nullptr);
490 ASSERT_EQ(
source->asColor(),
nullptr);
492 ASSERT_EQ(
source->asLinearGradient(),
nullptr);
493 ASSERT_EQ(
source->asRadialGradient(),
nullptr);
494 ASSERT_EQ(
source->asSweepGradient(),
nullptr);
495 ASSERT_EQ(
source->asRuntimeEffect(),
nullptr);
498TEST(DisplayListColorSource, ConicalGradientContents) {
503 ASSERT_EQ(
source->asConicalGradient()->start_radius(), 10.0);
505 ASSERT_EQ(
source->asConicalGradient()->end_radius(), 20.0);
513 ASSERT_EQ(
source->is_opaque(),
true);
516TEST(DisplayListColorSource, AlphaConicalGradientContents) {
521 ASSERT_EQ(
source->asConicalGradient()->start_radius(), 10.0);
523 ASSERT_EQ(
source->asConicalGradient()->end_radius(), 20.0);
531 ASSERT_EQ(
source->is_opaque(),
false);
534TEST(DisplayListColorSource, ConicalGradientEquals) {
544TEST(DisplayListColorSource, ConicalGradientNotEquals) {
604TEST(DisplayListColorSource, SweepGradientConstructor) {
610TEST(DisplayListColorSource, SweepGradientShared) {
618TEST(DisplayListColorSource, SweepGradientAsSweep) {
622 ASSERT_NE(
source->asSweepGradient(),
nullptr);
625 ASSERT_EQ(
source->asColor(),
nullptr);
627 ASSERT_EQ(
source->asLinearGradient(),
nullptr);
628 ASSERT_EQ(
source->asRadialGradient(),
nullptr);
629 ASSERT_EQ(
source->asConicalGradient(),
nullptr);
630 ASSERT_EQ(
source->asRuntimeEffect(),
nullptr);
633TEST(DisplayListColorSource, SweepGradientContents) {
638 ASSERT_EQ(
source->asSweepGradient()->start(), 10.0);
639 ASSERT_EQ(
source->asSweepGradient()->end(), 20.0);
647 ASSERT_EQ(
source->is_opaque(),
true);
650TEST(DisplayListColorSource, AlphaSweepGradientContents) {
655 ASSERT_EQ(
source->asSweepGradient()->start(), 10.0);
656 ASSERT_EQ(
source->asSweepGradient()->end(), 20.0);
664 ASSERT_EQ(
source->is_opaque(),
false);
667TEST(DisplayListColorSource, SweepGradientEquals) {
677TEST(DisplayListColorSource, SweepGradientNotEquals) {
731TEST(DisplayListColorSource, RuntimeEffect) {
732 std::shared_ptr<DlRuntimeEffectColorSource> source1 =
735 std::shared_ptr<DlRuntimeEffectColorSource> source2 =
738 std::shared_ptr<DlRuntimeEffectColorSource> source3 =
740 nullptr, {}, std::make_shared<std::vector<uint8_t>>());
743 ASSERT_EQ(source1->asRuntimeEffect(), source1.get());
744 ASSERT_NE(source2->asRuntimeEffect(), source1.get());
746 ASSERT_EQ(source1->asImage(),
nullptr);
747 ASSERT_EQ(source1->asColor(),
nullptr);
748 ASSERT_EQ(source1->asLinearGradient(),
nullptr);
749 ASSERT_EQ(source1->asRadialGradient(),
nullptr);
750 ASSERT_EQ(source1->asConicalGradient(),
nullptr);
751 ASSERT_EQ(source1->asSweepGradient(),
nullptr);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kOpaque_SkAlphaType
pixel is opaque
constexpr SkColor SK_ColorTRANSPARENT
static constexpr SkColor SkColorSetA(SkColor c, U8CPU a)
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
#define SkColorGetA(color)
sk_sp< SkImage > asImage() const
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static Result MakeForShader(SkString sksl, const Options &)
static std::shared_ptr< DlConicalGradientColorSource > MakeConical(SkPoint start_center, SkScalar start_radius, SkPoint end_center, SkScalar end_radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
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< DlSweepGradientColorSource > MakeSweep(SkPoint center, SkScalar start, SkScalar end, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
static std::shared_ptr< DlRadialGradientColorSource > MakeRadial(SkPoint center, SkScalar radius, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const SkMatrix *matrix=nullptr)
static sk_sp< DlImage > Make(const SkImage *image)
static sk_sp< DlRuntimeEffect > MakeSkia(const sk_sp< SkRuntimeEffect > &runtime_effect)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static const sk_sp< DlImage > kTestAlphaImage1
static constexpr float kTestStops2[kTestStopCount]
static const sk_sp< DlRuntimeEffect > kTestRuntimeEffect1
static const SkMatrix kTestMatrix2
static constexpr int kTestStopCount
static constexpr SkPoint kTestPoints[2]
static constexpr float kTestStops[kTestStopCount]
static const sk_sp< DlRuntimeEffect > kTestRuntimeEffect2
static const SkMatrix kTestMatrix1
static const sk_sp< DlImage > kTestImage1
static const DlColor kTestAlphaColors[kTestStopCount]
static constexpr SkPoint kTestPoints2[2]
static sk_sp< DlImage > MakeTestImage(int w, int h, SkColor color)
static constexpr DlColor kTestColors[kTestStopCount]
static void TestNotEquals(T &source1, T &source2, const std::string &label)
static void TestEquals(T &source1, T &source2)
TEST(DisplayListComplexity, EmptyDisplayList)
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 to the cache directory This is different from the persistent_cache_path in embedder h
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
static constexpr SkPoint Make(float x, float y)
static constexpr DlColor kBlue()
constexpr DlColor withAlpha(uint8_t alpha) const
static constexpr DlColor kRed()
static constexpr DlColor kGreen()