blob: 0750e5f7ffa62b9dd95ea074b32c875dcaa08998 [file] [log] [blame]
// 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.
#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 {
PaintRegion() = default;
PaintRegion(std::shared_ptr<std::vector<SkRect>> rects,
size_t from,
size_t to,
bool has_readback)
: rects_(rects), from_(from), to_(to), has_readback_(has_readback) {}
std::vector<SkRect>::const_iterator begin() const {
return rects_->begin() + from_;
std::vector<SkRect>::const_iterator end() const {
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_; }
std::shared_ptr<std::vector<SkRect>> rects_;
size_t from_ = 0;
size_t to_ = 0;
bool has_readback_ = false;
} // namespace flutter