From 4c1b3cac3089e9834ba858e7bcf16ad8981e029d Mon Sep 17 00:00:00 2001 From: ExMix Date: Wed, 13 Nov 2013 16:41:41 +0300 Subject: [PATCH] review fix --- drape/glextensions_list.cpp | 64 ++++++++++++++++++++++++++++++++++--- drape/glextensions_list.hpp | 9 ++++-- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/drape/glextensions_list.cpp b/drape/glextensions_list.cpp index b5836ebbe5..a52cb8120b 100644 --- a/drape/glextensions_list.cpp +++ b/drape/glextensions_list.cpp @@ -3,9 +3,66 @@ #include "../base/assert.hpp" +#include "../std/string.hpp" + +#ifdef DEBUG + #include "../std/map.hpp" + + class GLExtensionsList::Impl + { + public: + void CheckExtension(GLExtensionsList::ExtensionName const & enumName, const string & extName) + { + m_supportedMap[enumName] = GLFunctions::glHasExtension(extName); + } + + bool IsSupported(GLExtensionsList::ExtensionName const & enumName) const + { + map::const_iterator it = m_supportedMap.find(enumName); + if (it != m_supportedMap.end()) + return it->second; + + ASSERT(false, ("Not all used extensions is checked")); + return false; + } + + private: + map m_supportedMap; + }; +#else + #include "../std/set.hpp" + + class GLExtensionsList::Impl + { + public: + void CheckExtension(GLExtensionsList::ExtensionName const & enumName, const string & extName) + { + if (GLFunctions::glHasExtension(extName)) + m_supported.insert(enumName); + } + + bool IsSupported(GLExtensionsList::ExtensionName const & enumName) const + { + if (m_supported.find(enumName) != m_supported.end()) + return true; + + return false; + } + + private: + set m_supported; + }; +#endif + GLExtensionsList::GLExtensionsList() + : m_impl(new Impl()) { - m_supportMap[VertexArrayObject] = GLFunctions::glHasExtension("GL_OES_vertex_array_object"); + m_impl->CheckExtension(VertexArrayObject, "GL_OES_vertex_array_object"); +} + +GLExtensionsList::~GLExtensionsList() +{ + delete m_impl; } GLExtensionsList & GLExtensionsList::Instance() @@ -14,8 +71,7 @@ GLExtensionsList & GLExtensionsList::Instance() return extList; } -bool GLExtensionsList::IsSupported(const ExtensionName & extName) +bool GLExtensionsList::IsSupported(const ExtensionName & extName) const { - ASSERT(m_supportMap.find(extName) != m_supportMap.end(), ("Not all used extensions is checked")); - return m_supportMap[extName]; + return m_impl->IsSupported(extName); } diff --git a/drape/glextensions_list.hpp b/drape/glextensions_list.hpp index acb36f4043..78159d2349 100644 --- a/drape/glextensions_list.hpp +++ b/drape/glextensions_list.hpp @@ -1,7 +1,6 @@ #pragma once #include "../std/noncopyable.hpp" -#include "../std/map.hpp" class GLExtensionsList : private noncopyable { @@ -12,9 +11,13 @@ public: }; static GLExtensionsList & Instance(); - bool IsSupported(const ExtensionName & extName); + bool IsSupported(const ExtensionName & extName) const; private: GLExtensionsList(); - map m_supportMap; + ~GLExtensionsList(); + +private: + class Impl; + Impl * m_impl; };