Flutter Engine
 
Loading...
Searching...
No Matches
layer.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
6
8
9namespace flutter {
10
11Layer::Layer() : unique_id_(NextUniqueID()), original_layer_id_(unique_id_) {}
12
13Layer::~Layer() = default;
14
15uint64_t Layer::NextUniqueID() {
16 static std::atomic<uint64_t> next_id(1);
17 uint64_t id;
18 do {
19 id = next_id.fetch_add(1);
20 } while (id == 0); // 0 is reserved for an invalid id.
21 return id;
22}
23
24Layer::AutoPrerollSaveLayerState::AutoPrerollSaveLayerState(
25 PrerollContext* preroll_context,
26 bool save_layer_is_active,
27 bool layer_itself_performs_readback)
28 : preroll_context_(preroll_context),
29 save_layer_is_active_(save_layer_is_active),
30 layer_itself_performs_readback_(layer_itself_performs_readback) {
31 if (save_layer_is_active_) {
32 prev_surface_needs_readback_ = preroll_context_->surface_needs_readback;
33 preroll_context_->surface_needs_readback = false;
34 }
35}
36
38 PrerollContext* preroll_context,
39 bool save_layer_is_active,
40 bool layer_itself_performs_readback) {
41 return Layer::AutoPrerollSaveLayerState(preroll_context, save_layer_is_active,
42 layer_itself_performs_readback);
43}
44
46 if (save_layer_is_active_) {
47 preroll_context_->surface_needs_readback =
48 (prev_surface_needs_readback_ || layer_itself_performs_readback_);
49 }
50}
51
52} // namespace flutter
static AutoPrerollSaveLayerState Create(PrerollContext *preroll_context, bool save_layer_is_active=true, bool layer_itself_performs_readback=false)
Definition layer.cc:37
virtual ~Layer()
const uintptr_t id