Flutter Engine
The Flutter Engine
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
10#include "flutter/flow/layers/container_layer.h"
11#include "flutter/flow/layers/display_list_layer.h"
12#include "flutter/flow/layers/opacity_layer.h"
13#include "flutter/flow/testing/layer_test.h"
14
15namespace flutter {
16namespace testing {
17
19 public:
20 explicit MockLayerTree(SkISize size = SkISize::Make(1000, 1000))
21 : root_(std::make_shared<ContainerLayer>()), size_(size) {}
22
23 ContainerLayer* root() { return root_.get(); }
24 const ContainerLayer* root() const { return root_.get(); }
25
26 PaintRegionMap& paint_region_map() { return paint_region_map_; }
27 const PaintRegionMap& paint_region_map() const { return paint_region_map_; }
28
29 const SkISize& size() const { return size_; }
30
31 private:
32 std::shared_ptr<ContainerLayer> root_;
33 PaintRegionMap paint_region_map_;
34 SkISize size_;
35};
36
37class DiffContextTest : public LayerTest {
38 public:
40
42 const MockLayerTree& old_layer_tree,
43 const SkIRect& additional_damage = SkIRect::MakeEmpty(),
44 int horizontal_clip_alignment = 0,
45 int vertical_alignment = 0,
46 bool use_raster_cache = true,
47 bool impeller_enabled = false);
48
49 // Create display list consisting of filled rect with given color; Being able
50 // to specify different color is useful to test deep comparison of pictures
53
54 std::shared_ptr<DisplayListLayer> CreateDisplayListLayer(
56 const SkPoint& offset = SkPoint::Make(0, 0));
57
58 std::shared_ptr<ContainerLayer> CreateContainerLayer(
59 std::initializer_list<std::shared_ptr<Layer>> layers);
60
61 std::shared_ptr<ContainerLayer> CreateContainerLayer(
62 std::shared_ptr<Layer> l) {
63 return CreateContainerLayer({std::move(l)});
64 }
65
66 std::shared_ptr<OpacityLayer> CreateOpacityLater(
67 std::initializer_list<std::shared_ptr<Layer>> layers,
68 SkAlpha alpha,
69 const SkPoint& offset = SkPoint::Make(0, 0));
70};
71
72} // namespace testing
73} // namespace flutter
74
75#endif // FLUTTER_FLOW_TESTING_DIFF_CONTEXT_TEST_H_
uint8_t SkAlpha
Definition: SkColor.h:26
std::shared_ptr< DisplayListLayer > CreateDisplayListLayer(const sk_sp< DisplayList > &display_list, const SkPoint &offset=SkPoint::Make(0, 0))
sk_sp< DisplayList > CreateDisplayList(const SkRect &bounds, DlColor color=DlColor::kBlack())
std::shared_ptr< ContainerLayer > CreateContainerLayer(std::shared_ptr< Layer > l)
std::shared_ptr< ContainerLayer > CreateContainerLayer(std::initializer_list< std::shared_ptr< Layer > > layers)
Damage DiffLayerTree(MockLayerTree &layer_tree, const MockLayerTree &old_layer_tree, const SkIRect &additional_damage=SkIRect::MakeEmpty(), int horizontal_clip_alignment=0, int vertical_alignment=0, bool use_raster_cache=true, bool impeller_enabled=false)
std::shared_ptr< OpacityLayer > CreateOpacityLater(std::initializer_list< std::shared_ptr< Layer > > layers, SkAlpha alpha, const SkPoint &offset=SkPoint::Make(0, 0))
sk_sp< DisplayList > display_list()
Definition: layer_test.h:158
const SkISize & size() const
const PaintRegionMap & paint_region_map() const
const ContainerLayer * root() const
MockLayerTree(SkISize size=SkISize::Make(1000, 1000))
DlColor color
Optional< SkRect > bounds
Definition: SkRecords.h:189
std::map< uint64_t, PaintRegion > PaintRegionMap
Definition: diff_context.h:41
Definition: ref_ptr.h:256
SeparatedVector2 offset
Definition: SkRect.h:32
static constexpr SkIRect MakeEmpty()
Definition: SkRect.h:45
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20
static constexpr SkPoint Make(float x, float y)
Definition: SkPoint_impl.h:173
static constexpr DlColor kBlack()
Definition: dl_color.h:22