| 89 | } |
| 90 | |
| 91 | std::shared_ptr<TextureView> ImageReader::readTexture(uint64_t contentVersion, Context* context, |
| 92 | bool mipmapped) { |
| 93 | std::lock_guard<std::mutex> autoLock(locker); |
| 94 | if (contentVersion == textureVersion) { |
| 95 | return textureView; |
| 96 | } |
| 97 | if (contentVersion < bufferVersion) { |
| 98 | LOGE( |
| 99 | "ImageReader::readTexture(): Failed to read the texture view, the target ImageBuffer is " |
| 100 | "already expired!"); |
| 101 | return nullptr; |
| 102 | } |
| 103 | bool success = true; |
| 104 | if (textureView == nullptr) { |
| 105 | textureView = stream->onMakeTexture(context, mipmapped); |
| 106 | success = textureView != nullptr; |
| 107 | } else { |
| 108 | success = stream->onUpdateTexture(textureView); |
| 109 | } |
| 110 | if (success) { |
| 111 | textureView->removeUniqueKey(); |
| 112 | textureVersion = contentVersion; |
| 113 | } |
| 114 | return textureView; |
| 115 | } |
| 116 | } // namespace tgfx |
no test coverage detected