Flutter Engine
The Flutter Engine
paint_region.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_PAINT_REGION_H_
6#define FLUTTER_FLOW_PAINT_REGION_H_
7
8#include <utility>
9#include <vector>
10#include "flutter/fml/logging.h"
12
13namespace flutter {
14
15// Corresponds to area on the screen where the layer subtree has painted to.
16//
17// The area is used when adding damage of removed or dirty layer to overall
18// damage.
19//
20// Because there is a PaintRegion for each layer, it must be able to represent
21// the area with minimal overhead. This is accomplished by having one
22// vector<SkRect> shared between all paint regions, and each paint region
23// keeping begin and end index of rects relevant to particular subtree.
24//
25// All rects are in screen coordinates.
27 public:
28 PaintRegion() = default;
29 PaintRegion(std::shared_ptr<std::vector<SkRect>> rects,
30 size_t from,
31 size_t to,
32 bool has_readback,
33 bool has_texture)
34 : rects_(std::move(rects)),
35 from_(from),
36 to_(to),
37 has_readback_(has_readback),
38 has_texture_(has_texture) {}
39
40 std::vector<SkRect>::const_iterator begin() const {
42 return rects_->begin() + from_;
43 }
44
45 std::vector<SkRect>::const_iterator end() const {
47 return rects_->begin() + to_;
48 }
49
50 // Compute bounds for this region
51 SkRect ComputeBounds() const;
52
53 bool is_valid() const { return rects_ != nullptr; }
54
55 // Returns true if there is a layer in subtree represented by this region
56 // that performs readback
57 bool has_readback() const { return has_readback_; }
58
59 // Returns whether there is a TextureLayer in subtree represented by this
60 // region.
61 bool has_texture() const { return has_texture_; }
62
63 private:
64 std::shared_ptr<std::vector<SkRect>> rects_;
65 size_t from_ = 0;
66 size_t to_ = 0;
67 bool has_readback_ = false;
68 bool has_texture_ = false;
69};
70
71} // namespace flutter
72
73#endif // FLUTTER_FLOW_PAINT_REGION_H_
std::vector< SkRect >::const_iterator begin() const
Definition: paint_region.h:40
bool has_texture() const
Definition: paint_region.h:61
PaintRegion(std::shared_ptr< std::vector< SkRect > > rects, size_t from, size_t to, bool has_readback, bool has_texture)
Definition: paint_region.h:29
bool has_readback() const
Definition: paint_region.h:57
std::vector< SkRect >::const_iterator end() const
Definition: paint_region.h:45
SkRect ComputeBounds() const
Definition: paint_region.cc:9
bool is_valid() const
Definition: paint_region.h:53
#define FML_DCHECK(condition)
Definition: logging.h:103
Definition: ref_ptr.h:256