Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
resource_cache_limit_calculator.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_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_H_
6#define FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_H_
7
8#include <cstdint>
9#include <unordered_map>
10
11#include "flutter/fml/macros.h"
12#include "flutter/fml/memory/weak_ptr.h"
13
14namespace flutter {
16 public:
17 // The expected GPU resource cache limit in bytes. This will be called on the
18 // platform thread.
19 virtual size_t GetResourceCacheLimit() = 0;
20
21 protected:
22 virtual ~ResourceCacheLimitItem() = default;
23};
24
26 public:
27 explicit ResourceCacheLimitCalculator(size_t max_bytes_threshold)
28 : max_bytes_threshold_(max_bytes_threshold) {}
29
31
32 // This will be called on the platform thread.
35 items_.push_back(item);
36 }
37
38 // The maximum GPU resource cache limit in bytes calculated by
39 // 'ResourceCacheLimitItem's. This will be called on the platform thread.
41
42 private:
43 std::vector<fml::WeakPtr<ResourceCacheLimitItem>> items_;
44 size_t max_bytes_threshold_;
46};
47} // namespace flutter
48
49#endif // FLUTTER_SHELL_COMMON_RESOURCE_CACHE_LIMIT_CALCULATOR_H_
void AddResourceCacheLimitItem(const fml::WeakPtr< ResourceCacheLimitItem > &item)
virtual size_t GetResourceCacheLimit()=0
virtual ~ResourceCacheLimitItem()=default
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27