From 265bcfe13f36f2af6dddf72d0d14b0c7319f60f6 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Thu, 22 Jun 2017 17:14:10 +0300 Subject: [PATCH] Fixed crash in rendering on using corrupted textures --- drape/texture.cpp | 5 +++-- drape/texture.hpp | 2 +- drape_frontend/message_subclasses.hpp | 2 ++ drape_frontend/postprocess_renderer.cpp | 12 ++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drape/texture.cpp b/drape/texture.cpp index 4b679cd230..21cfef11fb 100644 --- a/drape/texture.cpp +++ b/drape/texture.cpp @@ -65,9 +65,10 @@ float Texture::GetT(uint32_t y) const return m_hwTexture->GetT(y); } -int32_t Texture::GetID() const +uint32_t Texture::GetID() const { - ASSERT(m_hwTexture != nullptr, ()); + if (m_hwTexture == nullptr) + return 0; return m_hwTexture->GetID(); } diff --git a/drape/texture.hpp b/drape/texture.hpp index dc3a3927db..41d6f92478 100644 --- a/drape/texture.hpp +++ b/drape/texture.hpp @@ -63,7 +63,7 @@ public: float GetS(uint32_t x) const; float GetT(uint32_t y) const; - int32_t GetID() const; + uint32_t GetID() const; void Bind() const; diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index f09a4b2c8d..02a3c0cd58 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -695,6 +695,7 @@ public: Type GetType() const override { return Message::FlushRouteArrows; } + bool IsGLContextDependent() const override { return true; } drape_ptr && AcceptRouteArrowsData() { return std::move(m_routeArrowsData); } private: @@ -1231,6 +1232,7 @@ public: {} Type GetType() const override { return Message::SetPostprocessStaticTextures; } + bool IsGLContextDependent() const override { return true; } drape_ptr && AcceptTextures() { return std::move(m_textures); } diff --git a/drape_frontend/postprocess_renderer.cpp b/drape_frontend/postprocess_renderer.cpp index 37d77fc5dc..4d66a1b972 100644 --- a/drape_frontend/postprocess_renderer.cpp +++ b/drape_frontend/postprocess_renderer.cpp @@ -264,8 +264,8 @@ void PostprocessRenderer::BeginFrame() ASSERT(m_staticTextures != nullptr, ()); if (m_staticTextures->m_smaaSearchTexture == nullptr || m_staticTextures->m_smaaAreaTexture == nullptr || - m_staticTextures->m_smaaAreaTexture->GetID() < 0 || - m_staticTextures->m_smaaSearchTexture->GetID() < 0) + m_staticTextures->m_smaaAreaTexture->GetID() == 0 || + m_staticTextures->m_smaaSearchTexture->GetID() == 0) { SetEffectEnabled(Effect::Antialiasing, false); } @@ -289,10 +289,10 @@ void PostprocessRenderer::EndFrame(ref_ptr gpuProgramMana wasPostEffect = true; ASSERT(m_staticTextures->m_smaaAreaTexture != nullptr, ()); - ASSERT_GREATER_OR_EQUAL(m_staticTextures->m_smaaAreaTexture->GetID(), 0, ()); + ASSERT_GREATER(m_staticTextures->m_smaaAreaTexture->GetID(), 0, ()); ASSERT(m_staticTextures->m_smaaSearchTexture != nullptr, ()); - ASSERT_GREATER_OR_EQUAL(m_staticTextures->m_smaaSearchTexture->GetID(), 0, ()); + ASSERT_GREATER(m_staticTextures->m_smaaSearchTexture->GetID(), 0, ()); GLFunctions::glClearColor(0.0f, 0.0f, 0.0f, 0.0f); GLFunctions::glEnable(gl_const::GLStencilTest); @@ -322,8 +322,8 @@ void PostprocessRenderer::EndFrame(ref_ptr gpuProgramMana ASSERT(dynamic_cast(m_bwRendererContext.get()) != nullptr, ()); auto context = static_cast(m_bwRendererContext.get()); context->SetParams(m_edgesFramebuffer->GetTextureId(), - static_cast(m_staticTextures->m_smaaAreaTexture->GetID()), - static_cast(m_staticTextures->m_smaaSearchTexture->GetID()), + m_staticTextures->m_smaaAreaTexture->GetID(), + m_staticTextures->m_smaaSearchTexture->GetID(), m_width, m_height); m_screenQuadRenderer->Render(gpuProgramManager, make_ref(m_bwRendererContext)); }