| 188 | } |
| 189 | |
| 190 | bool TextureManager::UpdateDynamicTextures(ref_ptr<dp::GraphicsContext> context) |
| 191 | { |
| 192 | if (m_nothingToUpload.test_and_set()) |
| 193 | { |
| 194 | auto const apiVersion = context->GetApiVersion(); |
| 195 | if (apiVersion == dp::ApiVersion::OpenGLES3) |
| 196 | { |
| 197 | // For some reasons OpenGL can not update textures immediately. |
| 198 | // Here we use some timeout to prevent rendering frozening. |
| 199 | double constexpr kUploadTimeoutInSeconds = 2.0; |
| 200 | return m_uploadTimer.ElapsedSeconds() < kUploadTimeoutInSeconds; |
| 201 | } |
| 202 | |
| 203 | if (apiVersion == dp::ApiVersion::Metal || apiVersion == dp::ApiVersion::Vulkan) |
| 204 | return false; |
| 205 | |
| 206 | CHECK(false, ("Unsupported API version.")); |
| 207 | } |
| 208 | |
| 209 | CHECK(m_isInitialized, ()); |
| 210 | |
| 211 | m_uploadTimer.Reset(); |
| 212 | |
| 213 | CHECK(m_colorTexture != nullptr, ()); |
| 214 | m_colorTexture->UpdateState(context); |
| 215 | |
| 216 | CHECK(m_stipplePenTexture != nullptr, ()); |
| 217 | m_stipplePenTexture->UpdateState(context); |
| 218 | |
| 219 | UpdateGlyphTextures(context); |
| 220 | |
| 221 | CHECK(m_textureAllocator != nullptr, ()); |
| 222 | m_textureAllocator->Flush(); |
| 223 | |
| 224 | return true; |
| 225 | } |
| 226 | |
| 227 | void TextureManager::UpdateGlyphTextures(ref_ptr<dp::GraphicsContext> context) |
| 228 | { |
no test coverage detected