Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
diff_context_test.cc
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#include "diff_context_test.h"
6
7#include <utility>
8#include "flutter/display_list/dl_builder.h"
9
10namespace flutter {
11namespace testing {
12
14
16 const MockLayerTree& old_layer_tree,
17 const SkIRect& additional_damage,
18 int horizontal_clip_alignment,
19 int vertical_clip_alignment,
20 bool use_raster_cache,
21 bool impeller_enabled) {
22 FML_CHECK(layer_tree.size() == old_layer_tree.size());
23
24 DiffContext dc(layer_tree.size(), layer_tree.paint_region_map(),
25 old_layer_tree.paint_region_map(), use_raster_cache,
26 impeller_enabled);
27 dc.PushCullRect(
28 SkRect::MakeIWH(layer_tree.size().width(), layer_tree.size().height()));
29 layer_tree.root()->Diff(&dc, old_layer_tree.root());
30 return dc.ComputeDamage(additional_damage, horizontal_clip_alignment,
31 vertical_clip_alignment);
32}
33
35 DlColor color) {
36 DisplayListBuilder builder;
37 builder.DrawRect(bounds, DlPaint().setColor(color));
38 return builder.Build();
39}
40
41std::shared_ptr<DisplayListLayer> DiffContextTest::CreateDisplayListLayer(
42 const sk_sp<DisplayList>& display_list,
43 const SkPoint& offset) {
44 return std::make_shared<DisplayListLayer>(offset, display_list, false, false);
45}
46
47std::shared_ptr<ContainerLayer> DiffContextTest::CreateContainerLayer(
48 std::initializer_list<std::shared_ptr<Layer>> layers) {
49 auto res = std::make_shared<ContainerLayer>();
50 for (const auto& l : layers) {
51 res->Add(l);
52 }
53 return res;
54}
55
56std::shared_ptr<OpacityLayer> DiffContextTest::CreateOpacityLater(
57 std::initializer_list<std::shared_ptr<Layer>> layers,
58 SkAlpha alpha,
59 const SkPoint& offset) {
60 auto res = std::make_shared<OpacityLayer>(alpha, offset);
61 for (const auto& l : layers) {
62 res->Add(l);
63 }
64 return res;
65}
66
67} // namespace testing
68} // namespace flutter
SkColor4f color
uint8_t SkAlpha
Definition SkColor.h:26
void Diff(DiffContext *context, const Layer *old_layer) override
bool PushCullRect(const SkRect &clip)
Damage ComputeDamage(const SkIRect &additional_damage, int horizontal_clip_alignment=0, int vertical_clip_alignment=0) const
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::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:175
#define FML_CHECK(condition)
Definition logging.h:85
Point offset
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37
static SkRect MakeIWH(int w, int h)
Definition SkRect.h:623