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