Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drape/drape_tests/memory_comparer.hpp4
-rw-r--r--drape/dynamic_texture.hpp42
-rw-r--r--drape/font_texture.hpp4
-rw-r--r--drape/glextensions_list.cpp3
-rw-r--r--drape/glextensions_list.hpp1
-rw-r--r--drape/hw_texture.cpp11
-rw-r--r--drape/texture.cpp3
-rw-r--r--drape/texture.hpp24
8 files changed, 61 insertions, 31 deletions
diff --git a/drape/drape_tests/memory_comparer.hpp b/drape/drape_tests/memory_comparer.hpp
index eb6a3fbdeb..fcc97c19a6 100644
--- a/drape/drape_tests/memory_comparer.hpp
+++ b/drape/drape_tests/memory_comparer.hpp
@@ -16,7 +16,7 @@ struct MemoryComparer
MemoryComparer(void * memory, int size) : m_mem(memory), m_size(size) {}
void cmpSubBuffer(glConst /*type*/, uint32_t size, void const * data, uint32_t /*offset*/) const
{
- TEST_EQUAL(size, m_size, ());
+ TEST_EQUAL(size, static_cast<uint32_t>(m_size), ());
TEST_EQUAL(memcmp(m_mem, data, size), 0, ());
}
@@ -39,7 +39,7 @@ struct MemoryComparer
ASSERT(gl_const::GL8BitOnChannel == pixelFormat, ());
- TEST_EQUAL(m_size, width * height * channelCount, ());
+ TEST_EQUAL(static_cast<uint32_t>(m_size), width * height * channelCount, ());
uint8_t * member = (uint8_t *)m_mem;
uint8_t * input = (uint8_t *)data;
diff --git a/drape/dynamic_texture.hpp b/drape/dynamic_texture.hpp
index f0b23ab4cf..da17f3cca2 100644
--- a/drape/dynamic_texture.hpp
+++ b/drape/dynamic_texture.hpp
@@ -3,6 +3,7 @@
#include "drape/texture.hpp"
#include "drape/glconstants.hpp"
+#include <atomic>
#include <vector>
namespace dp
@@ -28,11 +29,12 @@ public:
void UpdateState() override
{
// Create texture before first uploading.
- if (m_hwTexture == nullptr)
+ if (!m_isInitialized)
{
std::vector<uint8_t> initData(m_params.m_width * m_params.m_height *
GetBytesPerPixel(m_params.m_format), 0);
Create(m_params, initData.data());
+ m_isInitialized = true;
}
ASSERT(m_indexer != nullptr, ());
@@ -42,21 +44,50 @@ public:
TextureFormat GetFormat() const override
{
- return m_hwTexture == nullptr ? m_params.m_format : Texture::GetFormat();
+ return m_params.m_format;
}
uint32_t GetWidth() const override
{
- return m_hwTexture == nullptr ? m_params.m_width : Texture::GetWidth();
+ return m_params.m_width;
}
uint32_t GetHeight() const override
{
- return m_hwTexture == nullptr ? m_params.m_height : Texture::GetHeight();
+ return m_params.m_height;
+ }
+
+ float GetS(uint32_t x) const override
+ {
+ return static_cast<float>(x) / m_params.m_width;
+ }
+
+ float GetT(uint32_t y) const override
+ {
+ return static_cast<float>(y) / m_params.m_height;
+ }
+
+ uint32_t GetID() const override
+ {
+ return m_isInitialized ? Texture::GetID() : 0;
+ }
+
+ void Bind() const override
+ {
+ if (m_isInitialized)
+ Texture::Bind();
+ }
+
+ void SetFilter(glConst filter) override
+ {
+ if (m_isInitialized)
+ Texture::SetFilter(filter);
}
protected:
- DynamicTexture() {}
+ DynamicTexture()
+ : m_isInitialized(false)
+ {}
struct TextureParams
{
@@ -85,5 +116,6 @@ protected:
ref_ptr<TIndexer> m_indexer;
Texture::Params m_params;
+ std::atomic<bool> m_isInitialized;
};
} // namespace dp
diff --git a/drape/font_texture.hpp b/drape/font_texture.hpp
index b4e4a0144e..5ad8dda7c7 100644
--- a/drape/font_texture.hpp
+++ b/drape/font_texture.hpp
@@ -147,7 +147,7 @@ private:
class FontTexture : public DynamicTexture<GlyphIndex, GlyphKey, Texture::Glyph>
{
- typedef DynamicTexture<GlyphIndex, GlyphKey, Texture::Glyph> TBase;
+ using TBase = DynamicTexture<GlyphIndex, GlyphKey, Texture::Glyph>;
public:
FontTexture(m2::PointU const & size, ref_ptr<GlyphManager> glyphMng, ref_ptr<HWTextureAllocator> allocator)
: m_index(size, glyphMng)
@@ -156,7 +156,7 @@ public:
TBase::Init(allocator, make_ref(&m_index), params);
}
- ~FontTexture() { TBase::Reset(); }
+ ~FontTexture() override { TBase::Reset(); }
bool HasEnoughSpace(uint32_t newKeysCount) const override
{
diff --git a/drape/glextensions_list.cpp b/drape/glextensions_list.cpp
index b950b22c27..30cafee26a 100644
--- a/drape/glextensions_list.cpp
+++ b/drape/glextensions_list.cpp
@@ -10,7 +10,6 @@ namespace dp
GLExtensionsList::GLExtensionsList(dp::ApiVersion apiVersion)
{
#if defined(OMIM_OS_MOBILE)
- CheckExtension(TextureNPOT, "GL_OES_texture_npot");
if (apiVersion == dp::ApiVersion::OpenGLES2)
{
#ifdef OMIM_OS_ANDROID
@@ -39,7 +38,6 @@ GLExtensionsList::GLExtensionsList(dp::ApiVersion apiVersion)
SetExtension(UintIndices, true);
}
#elif defined(OMIM_OS_WINDOWS)
- m_impl->CheckExtension(TextureNPOT, "GL_ARB_texture_non_power_of_two");
SetExtension(MapBuffer, true);
SetExtension(UintIndices, true);
if (apiVersion == dp::ApiVersion::OpenGLES2)
@@ -53,7 +51,6 @@ GLExtensionsList::GLExtensionsList(dp::ApiVersion apiVersion)
SetExtension(MapBufferRange, true);
}
#else
- CheckExtension(TextureNPOT, "GL_ARB_texture_non_power_of_two");
SetExtension(MapBuffer, true);
SetExtension(UintIndices, true);
if (apiVersion == dp::ApiVersion::OpenGLES2)
diff --git a/drape/glextensions_list.hpp b/drape/glextensions_list.hpp
index 507c10ec52..5f2f18370f 100644
--- a/drape/glextensions_list.hpp
+++ b/drape/glextensions_list.hpp
@@ -15,7 +15,6 @@ public:
enum ExtensionName
{
VertexArrayObject,
- TextureNPOT,
MapBuffer,
UintIndices,
MapBufferRange
diff --git a/drape/hw_texture.cpp b/drape/hw_texture.cpp
index c55c5cf518..da6cedad3a 100644
--- a/drape/hw_texture.cpp
+++ b/drape/hw_texture.cpp
@@ -8,6 +8,10 @@
#include "base/logging.hpp"
#include "base/math.hpp"
+#ifdef DEBUG
+#include "3party/glm/glm/gtx/bit.hpp"
+#endif
+
#if defined(OMIM_OS_IPHONE)
#include "hw_texture_ios.hpp"
#endif
@@ -147,11 +151,8 @@ void OpenGLHWTexture::Create(Params const & params, ref_ptr<void> data)
{
TBase::Create(params, data);
- if (!GLExtensionsList::Instance().IsSupported(GLExtensionsList::TextureNPOT))
- {
- m_width = my::NextPowOf2(m_width);
- m_height = my::NextPowOf2(m_height);
- }
+ ASSERT(glm::isPowerOfTwo(static_cast<int>(m_width)), (m_width));
+ ASSERT(glm::isPowerOfTwo(static_cast<int>(m_height)), (m_height));
m_textureID = GLFunctions::glGenTexture();
Bind();
diff --git a/drape/texture.cpp b/drape/texture.cpp
index 21cfef11fb..39bbd60c7d 100644
--- a/drape/texture.cpp
+++ b/drape/texture.cpp
@@ -67,8 +67,7 @@ float Texture::GetT(uint32_t y) const
uint32_t Texture::GetID() const
{
- if (m_hwTexture == nullptr)
- return 0;
+ ASSERT(m_hwTexture != nullptr, ());
return m_hwTexture->GetID();
}
diff --git a/drape/texture.hpp b/drape/texture.hpp
index 41d6f92478..d5081f644e 100644
--- a/drape/texture.hpp
+++ b/drape/texture.hpp
@@ -7,6 +7,8 @@
#include "geometry/rect2d.hpp"
+#include "base/macros.hpp"
+
#include "std/cstdint.hpp"
#include "std/function.hpp"
@@ -52,23 +54,21 @@ public:
virtual bool HasEnoughSpace(uint32_t /*newKeysCount*/) const { return true; }
using Params = HWTexture::Params;
- void Create(Params const & params);
- void Create(Params const & params, ref_ptr<void> data);
-
- void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data);
-
virtual TextureFormat GetFormat() const;
virtual uint32_t GetWidth() const;
virtual uint32_t GetHeight() const;
+ virtual float GetS(uint32_t x) const;
+ virtual float GetT(uint32_t y) const;
+ virtual uint32_t GetID() const;
- float GetS(uint32_t x) const;
- float GetT(uint32_t y) const;
- uint32_t GetID() const;
-
- void Bind() const;
+ virtual void Bind() const;
// Texture must be bound before calling this method.
- void SetFilter(glConst filter);
+ virtual void SetFilter(glConst filter);
+
+ void Create(Params const & params);
+ void Create(Params const & params, ref_ptr<void> data);
+ void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data);
static uint32_t GetMaxTextureSize();
@@ -77,5 +77,7 @@ protected:
bool AllocateTexture(ref_ptr<HWTextureAllocator> allocator);
drape_ptr<HWTexture> m_hwTexture;
+
+ DISALLOW_COPY_AND_MOVE(Texture);
};
} // namespace dp