Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
shell
platform
android
image_lru.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_PLATFORM_ANDROID_IMAGE_LRU_H_
6
#define FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_LRU_H_
7
8
#include <array>
9
#include <cstddef>
10
11
#include "
display_list/image/dl_image.h
"
12
13
namespace
flutter
{
14
15
// This value needs to be larger than the number of swapchain images
16
// that a typical image reader will produce to ensure that we effectively
17
// cache. If the value is too small, we will unnecessarily churn through
18
// images, while if it is too large we may retain images longer than
19
// necessary.
20
static
constexpr
size_t
kImageReaderSwapchainSize
= 6u;
21
22
using
HardwareBufferKey
= uint64_t;
23
24
class
ImageLRU
{
25
public
:
26
ImageLRU
() =
default
;
27
28
~ImageLRU
() =
default
;
29
30
/// @brief Retrieve the image associated with the given [key], or nullptr.
31
sk_sp<flutter::DlImage>
FindImage
(std::optional<HardwareBufferKey>
key
);
32
33
/// @brief Add a new image to the cache with a key, returning the key of the
34
/// LRU entry that was removed.
35
///
36
/// The value may be `0`, in which case nothing was removed.
37
HardwareBufferKey
AddImage
(
const
sk_sp<flutter::DlImage>
&
image
,
38
HardwareBufferKey
key
);
39
40
/// @brief Remove all entires from the image cache.
41
void
Clear
();
42
43
private
:
44
/// @brief Marks [key] as the most recently used.
45
void
UpdateKey(
const
sk_sp<flutter::DlImage>
&
image
,
HardwareBufferKey
key
);
46
47
struct
Data
{
48
HardwareBufferKey
key
= 0u;
49
sk_sp<flutter::DlImage>
value
;
50
};
51
52
std::array<Data, kImageReaderSwapchainSize> images_;
53
};
54
55
}
// namespace flutter
56
57
#endif
// FLUTTER_SHELL_PLATFORM_ANDROID_IMAGE_LRU_H_
flutter::ImageLRU
Definition
image_lru.h:24
flutter::ImageLRU::AddImage
HardwareBufferKey AddImage(const sk_sp< flutter::DlImage > &image, HardwareBufferKey key)
Add a new image to the cache with a key, returning the key of the LRU entry that was removed.
Definition
image_lru.cc:42
flutter::ImageLRU::~ImageLRU
~ImageLRU()=default
flutter::ImageLRU::FindImage
sk_sp< flutter::DlImage > FindImage(std::optional< HardwareBufferKey > key)
Retrieve the image associated with the given [key], or nullptr.
Definition
image_lru.cc:9
flutter::ImageLRU::ImageLRU
ImageLRU()=default
flutter::ImageLRU::Clear
void Clear()
Remove all entires from the image cache.
Definition
image_lru.cc:60
sk_sp
Definition
SkRefCnt.h:220
dl_image.h
image
sk_sp< SkImage > image
Definition
examples.cpp:29
value
uint8_t value
Definition
fl_standard_message_codec.cc:36
key
int key
Definition
keyboard_key_handler_unittests.cc:114
flutter
Definition
asset_manager.cc:10
flutter::kImageReaderSwapchainSize
static constexpr size_t kImageReaderSwapchainSize
Definition
image_lru.h:20
flutter::Data
struct PathData * Data(SkPath *path)
Definition
path_ops.cc:52
flutter::HardwareBufferKey
uint64_t HardwareBufferKey
Definition
image_lru.h:22
Generated on Fri Apr 26 2024 06:14:19 for Flutter Engine by
1.9.8