Flutter Engine
texture.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/flow/texture.h"
6 
7 namespace flutter {
8 
9 Texture::Texture(int64_t id) : id_(id) {}
10 
11 Texture::~Texture() = default;
12 
14 
15 void TextureRegistry::RegisterTexture(std::shared_ptr<Texture> texture) {
16  if (!texture) {
17  return;
18  }
19  mapping_[texture->Id()] = texture;
20 }
21 
23  auto found = mapping_.find(id);
24  if (found == mapping_.end()) {
25  return;
26  }
27  found->second->OnTextureUnregistered();
28  mapping_.erase(found);
29 }
30 
32  for (auto& it : mapping_) {
33  it.second->OnGrContextCreated();
34  }
35 }
36 
38  for (auto& it : mapping_) {
39  it.second->OnGrContextDestroyed();
40  }
41 }
42 
43 std::shared_ptr<Texture> TextureRegistry::GetTexture(int64_t id) {
44  auto it = mapping_.find(id);
45  return it != mapping_.end() ? it->second : nullptr;
46 }
47 
48 } // namespace flutter
void RegisterTexture(std::shared_ptr< Texture > texture)
Definition: texture.cc:15
virtual ~Texture()
void UnregisterTexture(int64_t id)
Definition: texture.cc:22
std::shared_ptr< Texture > GetTexture(int64_t id)
Definition: texture.cc:43
Texture(int64_t id)
Definition: texture.cc:9