5#include "flutter/flow/layers/texture_layer.h"
7#include "flutter/flow/testing/diff_context_test.h"
8#include "flutter/flow/testing/layer_test.h"
9#include "flutter/flow/testing/mock_layer.h"
10#include "flutter/flow/testing/mock_texture.h"
11#include "flutter/fml/macros.h"
12#include "flutter/testing/display_list_testing.h"
22 auto layer = std::make_shared<TextureLayer>(
25 layer->Preroll(preroll_context());
26 EXPECT_EQ(layer->paint_bounds(),
29 EXPECT_TRUE(layer->needs_painting(paint_context()));
31 layer->Paint(display_list_paint_context());
40 auto mock_texture = std::make_shared<MockTexture>(
texture_id);
42 std::make_shared<TextureLayer>(layer_offset, layer_size,
texture_id,
46 preroll_context()->texture_registry->RegisterTexture(mock_texture);
48 layer->Preroll(preroll_context());
50 EXPECT_FALSE(layer->needs_painting(paint_context()));
52 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
53 "needs_painting\\(context\\)");
60 auto mock_texture = std::make_shared<MockTexture>(
texture_id);
61 auto layer = std::make_shared<TextureLayer>(
65 preroll_context()->texture_registry->RegisterTexture(mock_texture);
67 EXPECT_DEATH_IF_SUPPORTED(layer->Paint(paint_context()),
68 "needs_painting\\(context\\)");
75 const SkRect layer_bounds =
79 auto mock_texture = std::make_shared<MockTexture>(
texture_id, texture_image);
80 auto layer = std::make_shared<TextureLayer>(
84 preroll_context()->texture_registry->RegisterTexture(mock_texture);
86 layer->Preroll(preroll_context());
87 EXPECT_EQ(layer->paint_bounds(), layer_bounds);
88 EXPECT_TRUE(layer->needs_painting(paint_context()));
90 layer->Paint(display_list_paint_context());
103 auto container = std::make_shared<ContainerLayer>();
105 auto layer = std::make_shared<TextureLayer>(
SkPoint::Make(0, 0),
108 container->Add(layer);
116 damage = DiffLayerTree(tree2, tree1);
123 const SkRect layer_bounds =
127 auto mock_texture = std::make_shared<MockTexture>(
texture_id, texture_image);
129 auto texture_layer = std::make_shared<TextureLayer>(
131 auto layer = std::make_shared<OpacityLayer>(alpha,
SkPoint::Make(0.0f, 0.0f));
132 layer->Add(texture_layer);
139 texture_layer->Preroll(context);
146 layer->Preroll(context);
153 layer->Paint(display_list_paint_context());
156 expected_builder.
Save();
virtual void Add(std::shared_ptr< Layer > layer)
sk_sp< DisplayList > Build()
void DrawImageRect(const sk_sp< DlImage > &image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, const DlPaint *paint=nullptr, SrcRectConstraint constraint=SrcRectConstraint::kFast) override
DlPaint & setAlpha(uint8_t alpha)
static constexpr int kCallerCanApplyOpacity
static sk_sp< DlImage > MakeTestTexture(int w, int h, int checker_size)
TEST_F(DisplayListTest, Defaults)
LayerTestBase<::testing::Test > LayerTest
bool DisplayListsEQ_Verbose(const DisplayList *a, const DisplayList *b)
static constexpr SkRect kEmptyRect
LayerTest TextureLayerTest
bool Equals(const T *a, const T *b)
flutter::DisplayList DisplayList
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static constexpr SkPoint Make(float x, float y)
constexpr SkRect makeOffset(float dx, float dy) const
static constexpr SkRect MakeSize(const SkSize &size)
static constexpr SkSize Make(SkScalar w, SkScalar h)
std::shared_ptr< TextureRegistry > texture_registry
int renderable_state_flags
#define EXPECT_TRUE(handle)