2018-11-07 12:24:35 -08:00
|
|
|
// Copyright 2013 The Flutter Authors. All rights reserved.
|
2017-11-02 02:57:29 -07:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
#include "flutter/flow/texture.h"
|
|
|
|
|
|
2019-04-17 14:38:45 -07:00
|
|
|
namespace flutter {
|
2017-11-02 02:57:29 -07:00
|
|
|
|
2019-12-03 14:33:02 -08:00
|
|
|
Texture::Texture(int64_t id) : id_(id) {}
|
2017-11-02 02:57:29 -07:00
|
|
|
|
2019-12-03 14:33:02 -08:00
|
|
|
Texture::~Texture() = default;
|
|
|
|
|
|
|
|
|
|
TextureRegistry::TextureRegistry() = default;
|
2019-12-03 12:02:37 -08:00
|
|
|
|
2017-11-02 02:57:29 -07:00
|
|
|
void TextureRegistry::RegisterTexture(std::shared_ptr<Texture> texture) {
|
|
|
|
|
mapping_[texture->Id()] = texture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextureRegistry::UnregisterTexture(int64_t id) {
|
2019-10-08 12:45:57 -07:00
|
|
|
mapping_[id]->OnTextureUnregistered();
|
2017-11-02 02:57:29 -07:00
|
|
|
mapping_.erase(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextureRegistry::OnGrContextCreated() {
|
|
|
|
|
for (auto& it : mapping_) {
|
|
|
|
|
it.second->OnGrContextCreated();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TextureRegistry::OnGrContextDestroyed() {
|
|
|
|
|
for (auto& it : mapping_) {
|
|
|
|
|
it.second->OnGrContextDestroyed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<Texture> TextureRegistry::GetTexture(int64_t id) {
|
2017-11-09 10:04:41 -08:00
|
|
|
auto it = mapping_.find(id);
|
|
|
|
|
return it != mapping_.end() ? it->second : nullptr;
|
2017-11-02 02:57:29 -07:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 14:38:45 -07:00
|
|
|
} // namespace flutter
|