forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
paint_region.h
72 lines (59 loc) · 2.08 KB
/
paint_region.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FLOW_PAINT_REGION_H_
#define FLUTTER_FLOW_PAINT_REGION_H_
#include <vector>
#include "flutter/fml/logging.h"
#include "third_party/skia/include/core/SkRect.h"
namespace flutter {
// Corresponds to area on the screen where the layer subtree has painted to.
//
// The area is used when adding damage of removed or dirty layer to overall
// damage.
//
// Because there is a PaintRegion for each layer, it must be able to represent
// the area with minimal overhead. This is accomplished by having one
// vector<SkRect> shared between all paint regions, and each paint region
// keeping begin and end index of rects relevant to particular subtree.
//
// All rects are in screen coordinates.
class PaintRegion {
public:
PaintRegion() = default;
PaintRegion(std::shared_ptr<std::vector<SkRect>> rects,
size_t from,
size_t to,
bool has_readback,
bool has_texture)
: rects_(rects),
from_(from),
to_(to),
has_readback_(has_readback),
has_texture_(has_texture) {}
std::vector<SkRect>::const_iterator begin() const {
FML_DCHECK(is_valid());
return rects_->begin() + from_;
}
std::vector<SkRect>::const_iterator end() const {
FML_DCHECK(is_valid());
return rects_->begin() + to_;
}
// Compute bounds for this region
SkRect ComputeBounds() const;
bool is_valid() const { return rects_ != nullptr; }
// Returns true if there is a layer in subtree represented by this region
// that performs readback
bool has_readback() const { return has_readback_; }
// Returns whether there is a TextureLayer in subtree represented by this
// region.
bool has_texture() const { return has_texture_; }
private:
std::shared_ptr<std::vector<SkRect>> rects_;
size_t from_ = 0;
size_t to_ = 0;
bool has_readback_ = false;
bool has_texture_ = false;
};
} // namespace flutter
#endif // FLUTTER_FLOW_PAINT_REGION_H_