Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
volatile_path_tracker.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
5#include "flutter/lib/ui/volatile_path_tracker.h"
6
7#include <utility>
8
9namespace flutter {
10
12 fml::RefPtr<fml::TaskRunner> ui_task_runner,
13 bool enabled)
14 : ui_task_runner_(std::move(ui_task_runner)), enabled_(enabled) {}
15
16void VolatilePathTracker::Track(const std::shared_ptr<TrackedPath>& path) {
17 FML_DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
19 FML_DCHECK(path->path.isVolatile());
20 if (!enabled_) {
21 path->path.setIsVolatile(false);
22 return;
23 }
24 paths_.push_back(path);
25}
26
28 FML_DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
29 if (!enabled_) {
30 return;
31 }
32
33 paths_.erase(std::remove_if(paths_.begin(), paths_.end(),
34 [](const std::weak_ptr<TrackedPath>& weak_path) {
35 auto path = weak_path.lock();
36 if (!path) {
37 return true;
38 }
39 path->frame_count++;
40 if (path->frame_count >= kFramesOfVolatility) {
41 path->path.setIsVolatile(false);
42 path->tracking_volatility = false;
43 return true;
44 }
45 return false;
46 }),
47 paths_.end());
48}
49
50} // namespace flutter
void Track(const std::shared_ptr< TrackedPath > &path)
static constexpr int kFramesOfVolatility
VolatilePathTracker(fml::RefPtr< fml::TaskRunner > ui_task_runner, bool enabled)
virtual bool RunsTasksOnCurrentThread()
#define FML_DCHECK(condition)
Definition logging.h:103
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition switches.h:57
Definition ref_ptr.h:256