5#include "gtest/gtest.h"
7#include "flutter/display_list/effects/dl_color_filter.h"
8#include "flutter/display_list/effects/dl_image_filter.h"
9#include "flutter/flow/layers/layer.h"
10#include "flutter/flow/layers/layer_state_stack.h"
11#include "flutter/testing/display_list_testing.h"
21 "LayerStateStack state queried without a delegate");
23 "LayerStateStack state queried without a delegate");
25 "LayerStateStack state queried without a delegate");
27 "LayerStateStack state queried without a delegate");
29 "LayerStateStack state queried without a delegate");
32 auto mutator = state_stack.
save();
56 state_stack.
fill(dl_paint);
97 ASSERT_TRUE(
builder.GetTransform().isIdentity());
102 ASSERT_TRUE(
builder.GetTransform().isIdentity());
105 auto mutator = state_stack.
save();
113 ASSERT_TRUE(
builder.GetTransform().isIdentity());
118 ASSERT_TRUE(
builder.GetTransform().isIdentity());
124 ASSERT_TRUE(
builder.GetTransform().isIdentity());
130 ASSERT_TRUE(
builder.GetTransform().isIdentity());
140 auto mutator = state_stack.
save();
148 auto mutator2 = state_stack.
save();
210 std::shared_ptr<DlBlendColorFilter> outer_filter =
213 std::shared_ptr<DlBlendColorFilter> inner_filter =
220 auto mutator = state_stack.
save();
227 auto mutator2 = state_stack.
save();
290 std::shared_ptr<DlBlurImageFilter> outer_filter =
292 std::shared_ptr<DlBlurImageFilter> inner_filter =
296 ASSERT_EQ(inner_filter->map_local_bounds(
rect, outer_src_rect),
302 auto mutator = state_stack.
save();
309 auto mutator2 = state_stack.
save();
331 expected.
SaveLayer(&outer_src_rect, &outer_save_paint);
332 expected.
SaveLayer(&inner_src_rect, &inner_save_paint);
358 expected.
SaveLayer(&outer_src_rect, &save_paint);
379 ASSERT_EQ(
builder.GetSaveCount(), 1);
382 auto mutator1 = state_stack.
save();
383 ASSERT_EQ(
builder.GetSaveCount(), 1);
384 mutator1.applyOpacity(
rect, 0.5f);
385 ASSERT_EQ(
builder.GetSaveCount(), 1);
388 auto mutator2 = state_stack.
save();
389 ASSERT_EQ(
builder.GetSaveCount(), 1);
393 ASSERT_EQ(
builder.GetSaveCount(), 2);
397 ASSERT_EQ(
builder.GetSaveCount(), 1);
401 ASSERT_EQ(
builder.GetSaveCount(), 1);
406 auto mutator1 = state_stack.
save();
407 ASSERT_EQ(
builder.GetSaveCount(), 1);
409 ASSERT_EQ(
builder.GetSaveCount(), 1);
412 auto mutator2 = state_stack.
save();
413 ASSERT_EQ(
builder.GetSaveCount(), 1);
414 mutator2.applyOpacity(
rect, 0.5f);
417 ASSERT_EQ(
builder.GetSaveCount(), 1);
421 ASSERT_EQ(
builder.GetSaveCount(), 1);
425 ASSERT_EQ(
builder.GetSaveCount(), 1);
432 std::shared_ptr<DlBlurImageFilter> image_filter =
438 ASSERT_EQ(
builder.GetSaveCount(), 1);
441 auto mutator1 = state_stack.
save();
442 ASSERT_EQ(
builder.GetSaveCount(), 1);
443 mutator1.applyOpacity(
rect, 0.5f);
444 ASSERT_EQ(
builder.GetSaveCount(), 1);
447 auto mutator2 = state_stack.
save();
448 ASSERT_EQ(
builder.GetSaveCount(), 1);
449 mutator2.applyImageFilter(
rect, image_filter);
452 ASSERT_EQ(
builder.GetSaveCount(), 1);
456 ASSERT_EQ(
builder.GetSaveCount(), 1);
460 ASSERT_EQ(
builder.GetSaveCount(), 1);
465 auto mutator1 = state_stack.
save();
466 ASSERT_EQ(
builder.GetSaveCount(), 1);
467 mutator1.applyImageFilter(
rect, image_filter);
468 ASSERT_EQ(
builder.GetSaveCount(), 1);
471 auto mutator2 = state_stack.
save();
472 ASSERT_EQ(
builder.GetSaveCount(), 1);
473 mutator2.applyOpacity(
rect, 0.5f);
476 ASSERT_EQ(
builder.GetSaveCount(), 2);
480 ASSERT_EQ(
builder.GetSaveCount(), 1);
484 ASSERT_EQ(
builder.GetSaveCount(), 1);
494 std::shared_ptr<DlBlurImageFilter> image_filter =
500 ASSERT_EQ(
builder.GetSaveCount(), 1);
503 auto mutator1 = state_stack.
save();
504 ASSERT_EQ(
builder.GetSaveCount(), 1);
506 ASSERT_EQ(
builder.GetSaveCount(), 1);
509 auto mutator2 = state_stack.
save();
510 ASSERT_EQ(
builder.GetSaveCount(), 1);
511 mutator2.applyImageFilter(
rect, image_filter);
514 ASSERT_EQ(
builder.GetSaveCount(), 1);
518 ASSERT_EQ(
builder.GetSaveCount(), 1);
522 ASSERT_EQ(
builder.GetSaveCount(), 1);
527 auto mutator1 = state_stack.
save();
528 ASSERT_EQ(
builder.GetSaveCount(), 1);
529 mutator1.applyImageFilter(
rect, image_filter);
530 ASSERT_EQ(
builder.GetSaveCount(), 1);
533 auto mutator2 = state_stack.
save();
534 ASSERT_EQ(
builder.GetSaveCount(), 1);
538 ASSERT_EQ(
builder.GetSaveCount(), 2);
542 ASSERT_EQ(
builder.GetSaveCount(), 1);
546 ASSERT_EQ(
builder.GetSaveCount(), 1);
static sk_sp< SkImage > color_filter(const SkImage *image, SkColorFilter *colorFilter)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static const SkMatrix & I()
void DrawRect(const SkRect &rect, const DlPaint &paint) override
void SaveLayer(const SkRect *bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr) override
sk_sp< DisplayList > Build()
Developer-facing API for rendering anything within the engine.
virtual SkMatrix GetTransform() const =0
DlPaint & setColorFilter(const std::shared_ptr< const DlColorFilter > &filter)
DlPaint & setImageFilter(const std::shared_ptr< const DlImageFilter > &filter)
DlPaint & setOpacity(SkScalar opacity)
void applyColorFilter(const SkRect &bounds, const std::shared_ptr< const DlColorFilter > &filter)
void translate(SkScalar tx, SkScalar ty)
void applyImageFilter(const SkRect &bounds, const std::shared_ptr< const DlImageFilter > &filter)
void applyOpacity(const SkRect &bounds, SkScalar opacity)
std::shared_ptr< const DlImageFilter > outstanding_image_filter() const
SkRect outstanding_bounds() const
SkMatrix transform_3x3() const
void fill(MutatorsStack *mutators)
DlCanvas * canvas_delegate()
AutoRestore applyState(const SkRect &bounds, int can_apply_flags)
void set_preroll_delegate(const SkRect &cull_rect, const SkMatrix &matrix)
SkM44 transform_4x4() const
SkScalar outstanding_opacity() const
SkRect device_cull_rect() const
static constexpr int kCallerCanApplyColorFilter
SkRect local_cull_rect() const
void set_delegate(DlCanvas *canvas)
bool content_culled(const SkRect &content_bounds) const
std::shared_ptr< const DlColorFilter > outstanding_color_filter() const
static constexpr int kCallerCanApplyImageFilter
static constexpr int kCallerCanApplyOpacity
static void draw_paint(SkCanvas *canvas, const SkRect &r, sk_sp< SkImageFilter > imf)
sk_sp< SkBlender > blender SkRect rect
bool DisplayListsEQ_Verbose(const DisplayList *a, const DisplayList *b)
TEST(DisplayListComplexity, EmptyDisplayList)
static constexpr SkRect kGiantRect
@ kColorBurn
darken destination to reflect source
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
static constexpr DlColor kYellow()
static constexpr DlColor kRed()