Flutter Engine
 
Loading...
Searching...
No Matches
diff_context_test.h
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#ifndef FLUTTER_FLOW_TESTING_DIFF_CONTEXT_TEST_H_
6#define FLUTTER_FLOW_TESTING_DIFF_CONTEXT_TEST_H_
7
8#include <utility>
9
15
16namespace flutter {
17namespace testing {
18
20 public:
21 explicit MockLayerTree(DlISize size = DlISize(1000, 1000))
22 : root_(std::make_shared<ContainerLayer>()), size_(size) {}
23
24 ContainerLayer* root() { return root_.get(); }
25 const ContainerLayer* root() const { return root_.get(); }
26
27 PaintRegionMap& paint_region_map() { return paint_region_map_; }
28 const PaintRegionMap& paint_region_map() const { return paint_region_map_; }
29
30 const DlISize& size() const { return size_; }
31
32 private:
33 std::shared_ptr<ContainerLayer> root_;
34 PaintRegionMap paint_region_map_;
35 DlISize size_;
36};
37
38class DiffContextTest : public LayerTest {
39 public:
41
43 const MockLayerTree& old_layer_tree,
44 const DlIRect& additional_damage = DlIRect(),
45 int horizontal_clip_alignment = 0,
46 int vertical_alignment = 0,
47 bool use_raster_cache = true,
48 bool impeller_enabled = false);
49
50 // Create display list consisting of filled rect with given color; Being able
51 // to specify different color is useful to test deep comparison of pictures
52 sk_sp<DisplayList> CreateDisplayList(const DlRect& bounds,
53 DlColor color = DlColor::kBlack());
54
55 std::shared_ptr<DisplayListLayer> CreateDisplayListLayer(
56 const sk_sp<DisplayList>& display_list,
57 const DlPoint& offset = DlPoint(0, 0));
58
59 std::shared_ptr<ContainerLayer> CreateContainerLayer(
60 std::initializer_list<std::shared_ptr<Layer>> layers);
61
62 std::shared_ptr<ContainerLayer> CreateContainerLayer(
63 std::shared_ptr<Layer> l) {
64 return CreateContainerLayer({std::move(l)});
65 }
66
67 std::shared_ptr<OpacityLayer> CreateOpacityLater(
68 std::initializer_list<std::shared_ptr<Layer>> layers,
69 uint8_t alpha,
70 const DlPoint& offset = DlPoint(0, 0));
71};
72
73} // namespace testing
74} // namespace flutter
75
76#endif // FLUTTER_FLOW_TESTING_DIFF_CONTEXT_TEST_H_
std::shared_ptr< OpacityLayer > CreateOpacityLater(std::initializer_list< std::shared_ptr< Layer > > layers, uint8_t alpha, const DlPoint &offset=DlPoint(0, 0))
std::shared_ptr< ContainerLayer > CreateContainerLayer(std::shared_ptr< Layer > l)
sk_sp< DisplayList > CreateDisplayList(const DlRect &bounds, DlColor color=DlColor::kBlack())
std::shared_ptr< ContainerLayer > CreateContainerLayer(std::initializer_list< std::shared_ptr< Layer > > layers)
std::shared_ptr< DisplayListLayer > CreateDisplayListLayer(const sk_sp< DisplayList > &display_list, const DlPoint &offset=DlPoint(0, 0))
Damage DiffLayerTree(MockLayerTree &layer_tree, const MockLayerTree &old_layer_tree, const DlIRect &additional_damage=DlIRect(), int horizontal_clip_alignment=0, int vertical_alignment=0, bool use_raster_cache=true, bool impeller_enabled=false)
sk_sp< DisplayList > display_list()
Definition layer_test.h:139
const PaintRegionMap & paint_region_map() const
const ContainerLayer * root() const
MockLayerTree(DlISize size=DlISize(1000, 1000))
const FlutterLayer ** layers
std::map< uint64_t, PaintRegion > PaintRegionMap
impeller::ISize32 DlISize
impeller::IRect32 DlIRect
impeller::Point DlPoint
Definition ref_ptr.h:261
static constexpr DlColor kBlack()
Definition dl_color.h:69