Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::TextureRegistry Class Reference

#include <texture.h>

Public Member Functions

 TextureRegistry ()
 
void RegisterTexture (const std::shared_ptr< Texture > &texture)
 
void RegisterContextListener (uintptr_t id, std::weak_ptr< ContextListener > image)
 
void UnregisterTexture (int64_t id)
 
void UnregisterContextListener (uintptr_t id)
 
std::shared_ptr< TextureGetTexture (int64_t id)
 
void OnGrContextCreated ()
 
void OnGrContextDestroyed ()
 

Detailed Description

Definition at line 70 of file texture.h.

Constructor & Destructor Documentation

◆ TextureRegistry()

TextureRegistry::TextureRegistry ( )
default

Member Function Documentation

◆ GetTexture()

std::shared_ptr< Texture > TextureRegistry::GetTexture ( int64_t  id)

Definition at line 93 of file texture.cc.

93 {
94 auto it = mapping_.find(id);
95 return it != mapping_.end() ? it->second : nullptr;
96}

◆ OnGrContextCreated()

void TextureRegistry::OnGrContextCreated ( )

Definition at line 52 of file texture.cc.

52 {
53 for (auto& it : mapping_) {
54 it.second->OnGrContextCreated();
55 }
56
57 // Calling OnGrContextCreated may result in a subsequent call to
58 // RegisterContextListener from the listener, which may modify the map.
59 std::vector<InsertionOrderMap::value_type> ordered_images(
60 ordered_images_.begin(), ordered_images_.end());
61
62 for (const auto& [id, pair] : ordered_images) {
63 auto index_id = pair.first;
64 auto weak_image = pair.second;
65 if (auto image = weak_image.lock()) {
66 image->OnGrContextCreated();
67 } else {
68 image_indices_.erase(index_id);
69 ordered_images_.erase(id);
70 }
71 }
72}
sk_sp< SkImage > image
Definition examples.cpp:29

◆ OnGrContextDestroyed()

void TextureRegistry::OnGrContextDestroyed ( )

Definition at line 74 of file texture.cc.

74 {
75 for (auto& it : mapping_) {
76 it.second->OnGrContextDestroyed();
77 }
78
79 auto it = ordered_images_.begin();
80 while (it != ordered_images_.end()) {
81 auto index_id = it->second.first;
82 auto weak_image = it->second.second;
83 if (auto image = weak_image.lock()) {
84 image->OnGrContextDestroyed();
85 it++;
86 } else {
87 image_indices_.erase(index_id);
88 it = ordered_images_.erase(it);
89 }
90 }
91}

◆ RegisterContextListener()

void TextureRegistry::RegisterContextListener ( uintptr_t  id,
std::weak_ptr< ContextListener image 
)

Definition at line 26 of file texture.cc.

28 {
29 size_t next_id = image_counter_++;
30 auto const result = image_indices_.insert({id, next_id});
31 if (!result.second) {
32 ordered_images_.erase(result.first->second);
33 result.first->second = next_id;
34 }
35 ordered_images_[next_id] = {next_id, std::move(image)};
36}
static uint32_t next_id()
GAsyncResult * result
const uintptr_t id

◆ RegisterTexture()

void TextureRegistry::RegisterTexture ( const std::shared_ptr< Texture > &  texture)

Definition at line 19 of file texture.cc.

19 {
20 if (!texture) {
21 return;
22 }
23 mapping_[texture->Id()] = texture;
24}
FlTexture * texture

◆ UnregisterContextListener()

void TextureRegistry::UnregisterContextListener ( uintptr_t  id)

Definition at line 47 of file texture.cc.

47 {
48 ordered_images_.erase(image_indices_[id]);
49 image_indices_.erase(id);
50}

◆ UnregisterTexture()

void TextureRegistry::UnregisterTexture ( int64_t  id)

Definition at line 38 of file texture.cc.

38 {
39 auto found = mapping_.find(id);
40 if (found == mapping_.end()) {
41 return;
42 }
43 found->second->OnTextureUnregistered();
44 mapping_.erase(found);
45}

The documentation for this class was generated from the following files: