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:
authorExMix <rahuba.youri@mapswithme.com>2015-08-18 12:48:50 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2015-11-30 16:10:00 +0300
commitc1f9b0cf5868159ce49176bb7c9929c642e75aca (patch)
treed5530f3929160dd65ea386005a41c0789d20f3ec
parent2dff0c6bbe755f596a9930c415da6a1dbfe50b19 (diff)
[drape, ios] fast textures.
-rw-r--r--drape/drape_common.pri9
-rw-r--r--drape/drape_global.hpp22
-rw-r--r--drape/drape_tests/font_texture_tests.cpp7
-rw-r--r--drape/drape_tests/stipple_pen_tests.cpp8
-rw-r--r--drape/drape_tests/texture_of_colors_tests.cpp28
-rw-r--r--drape/dynamic_texture.hpp18
-rw-r--r--drape/font_texture.cpp2
-rw-r--r--drape/font_texture.hpp4
-rw-r--r--drape/hw_texture.cpp171
-rw-r--r--drape/hw_texture.hpp91
-rw-r--r--drape/hw_texture_ios.hpp62
-rw-r--r--drape/hw_texture_ios.mm199
-rw-r--r--drape/pointers.hpp7
-rw-r--r--drape/stipple_pen_resource.cpp3
-rw-r--r--drape/stipple_pen_resource.hpp4
-rw-r--r--drape/symbols_texture.cpp28
-rw-r--r--drape/symbols_texture.hpp6
-rw-r--r--drape/texture.cpp144
-rw-r--r--drape/texture.hpp27
-rw-r--r--drape/texture_manager.cpp15
-rw-r--r--drape/texture_manager.hpp3
-rw-r--r--drape/texture_of_colors.cpp4
-rw-r--r--drape/texture_of_colors.hpp4
-rw-r--r--iphone/Maps/Maps.xcodeproj/project.pbxproj1
24 files changed, 696 insertions, 171 deletions
diff --git a/drape/drape_common.pri b/drape/drape_common.pri
index 515c768775..b3cde3c00f 100644
--- a/drape/drape_common.pri
+++ b/drape/drape_common.pri
@@ -22,6 +22,7 @@ SOURCES += \
$$DRAPE_DIR/gpu_buffer.cpp \
$$DRAPE_DIR/gpu_program.cpp \
$$DRAPE_DIR/gpu_program_manager.cpp \
+ $$DRAPE_DIR/hw_texture.cpp \
$$DRAPE_DIR/index_buffer.cpp \
$$DRAPE_DIR/index_buffer_mutator.cpp \
$$DRAPE_DIR/index_storage.cpp \
@@ -45,8 +46,6 @@ SOURCES += \
$$DRAPE_DIR/utils/projection.cpp \
$$DRAPE_DIR/utils/vertex_decl.cpp \
$$DRAPE_DIR/vertex_array_buffer.cpp \
- $$ROOT_DIR/3party/stb_image/sdf_image.cpp \
- $$ROOT_DIR/3party/stb_image/stb_image.c \
HEADERS += \
$$DRAPE_DIR/attribute_buffer_mutator.hpp \
@@ -75,6 +74,7 @@ HEADERS += \
$$DRAPE_DIR/gpu_buffer.hpp \
$$DRAPE_DIR/gpu_program.hpp \
$$DRAPE_DIR/gpu_program_manager.hpp \
+ $$DRAPE_DIR/hw_texture.hpp \
$$DRAPE_DIR/index_buffer.hpp \
$$DRAPE_DIR/index_buffer_mutator.hpp \
$$DRAPE_DIR/index_storage.hpp \
@@ -100,3 +100,8 @@ HEADERS += \
$$DRAPE_DIR/utils/projection.hpp \
$$DRAPE_DIR/utils/vertex_decl.hpp \
$$DRAPE_DIR/vertex_array_buffer.hpp \
+
+iphone*{
+ HEADERS += $$DRAPE_DIR/hw_texture_ios.hpp
+ OBJECTIVE_SOURCES += $$DRAPE_DIR/hw_texture_ios.mm
+}
diff --git a/drape/drape_global.hpp b/drape/drape_global.hpp
index 193a7c8732..1031f891ce 100644
--- a/drape/drape_global.hpp
+++ b/drape/drape_global.hpp
@@ -2,17 +2,37 @@
#include "color.hpp"
+#include "base/assert.hpp"
+
namespace dp
{
enum TextureFormat
{
RGBA8,
- RGBA4,
ALPHA,
UNSPECIFIED
};
+uint8_t GetBytesPerPixel(TextureFormat format)
+{
+ uint8_t result = 0;
+ switch (format)
+ {
+ case RGBA8:
+ result = 4;
+ break;
+ case ALPHA:
+ result = 1;
+ break;
+ default:
+ ASSERT(false, ());
+ break;
+ }
+
+ return result;
+}
+
enum Anchor
{
Center = 0,
diff --git a/drape/drape_tests/font_texture_tests.cpp b/drape/drape_tests/font_texture_tests.cpp
index 81384b0616..102dcb9bb8 100644
--- a/drape/drape_tests/font_texture_tests.cpp
+++ b/drape/drape_tests/font_texture_tests.cpp
@@ -99,8 +99,13 @@ UNIT_TEST(UploadingGlyphs)
index.MapResource(GlyphKey(0x61));
while(index.HasAsyncRoutines());
+ Texture::Params p;
+ p.m_allocator = GetDefaultAllocator();
+ p.m_format = dp::ALPHA;
+ p.m_width = p.m_height = 64;
+
DummyTexture tex;
- tex.Create(64, 64, dp::ALPHA, nullptr);
+ tex.Create(p);
EXPECTGL(glTexSubImage2D(_, _, _, _, _, _, _)).WillOnce(Invoke(&r, &UploadedRender::glMemoryToQImage));
index.UploadResources(make_ref(&tex));
diff --git a/drape/drape_tests/stipple_pen_tests.cpp b/drape/drape_tests/stipple_pen_tests.cpp
index 5c53735787..c05c8ac466 100644
--- a/drape/drape_tests/stipple_pen_tests.cpp
+++ b/drape/drape_tests/stipple_pen_tests.cpp
@@ -455,8 +455,14 @@ UNIT_TEST(StippleMappingTest)
EXPECTGL(glTexSubImage2D(0, 0, 256, 6, AnyOf(gl_const::GLAlpha, gl_const::GLAlpha8), gl_const::GL8BitOnChannel, _))
.WillOnce(Invoke(&cmp, &MemoryComparer::cmpSubImage));
+ Texture::Params p;
+ p.m_allocator = GetDefaultAllocator();
+ p.m_format = dp::ALPHA;
+ p.m_width = width;
+ p.m_height = height;
+
DummyTexture texture;
- texture.Create(width, height, dp::ALPHA);
+ texture.Create(p);
index.UploadResources(make_ref(&texture));
StipplePenKey secInfo;
diff --git a/drape/drape_tests/texture_of_colors_tests.cpp b/drape/drape_tests/texture_of_colors_tests.cpp
index 804ea474a8..38b52fdea4 100644
--- a/drape/drape_tests/texture_of_colors_tests.cpp
+++ b/drape/drape_tests/texture_of_colors_tests.cpp
@@ -92,8 +92,14 @@ UNIT_TEST(ColorPalleteUploadingSingleRow)
int const height = 16;
InitOpenGLTextures(width, height);
+ Texture::Params p;
+ p.m_allocator = GetDefaultAllocator();
+ p.m_format = dp::RGBA8;
+ p.m_width = width;
+ p.m_height = height;
+
DummyTexture texture;
- texture.Create(width, height, dp::RGBA8);
+ texture.Create(p);
DummyColorPallete cp(m2::PointU(width, height));
cp.UploadResources(make_ref(&texture));
@@ -158,9 +164,15 @@ UNIT_TEST(ColorPalleteUploadingPartialyRow)
int const height = 16;
InitOpenGLTextures(width, height);
+ Texture::Params p;
+ p.m_allocator = GetDefaultAllocator();
+ p.m_format = dp::RGBA8;
+ p.m_width = width;
+ p.m_height = height;
+
DummyTexture texture;
- dp::ColorKey key(dp::Color(0, 0, 0, 0));
- texture.Create(width, height, dp::RGBA8);
+ texture.Create(p);
+
DummyColorPallete cp(m2::PointU(width, height));
{
@@ -233,9 +245,15 @@ UNIT_TEST(ColorPalleteUploadingMultipyRow)
int const height = 16;
InitOpenGLTextures(width, height);
+ Texture::Params p;
+ p.m_allocator = GetDefaultAllocator();
+ p.m_format = dp::RGBA8;
+ p.m_width = width;
+ p.m_height = height;
+
DummyTexture texture;
- dp::ColorKey key(dp::Color(0, 0, 0, 0));
- texture.Create(width, height, dp::RGBA8);
+ texture.Create(p);
+
DummyColorPallete cp(m2::PointU(width, height));
cp.SetIsDebug(true);
diff --git a/drape/dynamic_texture.hpp b/drape/dynamic_texture.hpp
index aac1bac1b2..e4c6242fe9 100644
--- a/drape/dynamic_texture.hpp
+++ b/drape/dynamic_texture.hpp
@@ -42,16 +42,24 @@ protected:
glConst m_magFilter;
};
- void Init(ref_ptr<TIndexer> indexer, TextureParams const & params)
+ void Init(ref_ptr<HWTextureAllocator> allocator, ref_ptr<TIndexer> indexer, TextureParams const & params)
{
- Init(indexer, params, nullptr);
+ Init(allocator, indexer, params, nullptr);
}
- void Init(ref_ptr<TIndexer> indexer, TextureParams const & params, ref_ptr<void> data)
+ void Init(ref_ptr<HWTextureAllocator> allocator, ref_ptr<TIndexer> indexer, TextureParams const & params,
+ ref_ptr<void> data)
{
m_indexer = indexer;
- Create(params.m_size.x, params.m_size.y, params.m_format, data);
- SetFilterParams(params.m_minFilter, params.m_magFilter);
+ Texture::Params p;
+ p.m_allocator = allocator;
+ p.m_width = params.m_size.x;
+ p.m_height = params.m_size.y;
+ p.m_format = params.m_format;
+ p.m_magFilter = params.m_magFilter;
+ p.m_minFilter = params.m_minFilter;
+
+ Create(p, data);
}
void Reset()
diff --git a/drape/font_texture.cpp b/drape/font_texture.cpp
index 6b481312fd..0dd228d1c3 100644
--- a/drape/font_texture.cpp
+++ b/drape/font_texture.cpp
@@ -271,7 +271,7 @@ void GlyphIndex::UploadResources(ref_ptr<Texture> texture)
glyph.m_image.Destroy();
}
- texture->UploadData(zeroPoint.x, zeroPoint.y, width, height, dp::ALPHA, make_ref(dstMemory));
+ texture->UploadData(zeroPoint.x, zeroPoint.y, width, height, make_ref(dstMemory));
SharedBufferManager::instance().freeSharedBuffer(byteCount, buffer);
}
}
diff --git a/drape/font_texture.hpp b/drape/font_texture.hpp
index 85b4e6b0e9..652f29bd12 100644
--- a/drape/font_texture.hpp
+++ b/drape/font_texture.hpp
@@ -133,7 +133,7 @@ class FontTexture : public DynamicTexture<GlyphIndex, GlyphKey, Texture::Glyph>
{
typedef DynamicTexture<GlyphIndex, GlyphKey, Texture::Glyph> TBase;
public:
- FontTexture(m2::PointU const & size, ref_ptr<GlyphManager> glyphMng)
+ FontTexture(m2::PointU const & size, ref_ptr<GlyphManager> glyphMng, ref_ptr<HWTextureAllocator> allocator)
: m_index(size, glyphMng)
{
TBase::TextureParams params;
@@ -143,7 +143,7 @@ public:
params.m_magFilter = gl_const::GLLinear;
vector<uint8_t> initData(params.m_size.x * params.m_size.y, 0);
- TBase::Init(make_ref(&m_index), params, make_ref(initData.data()));
+ TBase::Init(allocator, make_ref(&m_index), params, make_ref(initData.data()));
}
~FontTexture() { TBase::Reset(); }
diff --git a/drape/hw_texture.cpp b/drape/hw_texture.cpp
new file mode 100644
index 0000000000..11bbcc7172
--- /dev/null
+++ b/drape/hw_texture.cpp
@@ -0,0 +1,171 @@
+#include "hw_texture.hpp"
+
+#include "glfunctions.hpp"
+#include "glextensions_list.hpp"
+
+#include "base/math.hpp"
+
+#if defined(OMIM_OS_IPHONE)
+#include "hw_texture_ios.hpp"
+#endif
+
+#define ASSERT_ID ASSERT(GetID() != -1, ())
+
+namespace dp
+{
+
+HWTexture::HWTexture()
+ : m_width(0)
+ , m_height(0)
+ , m_format(UNSPECIFIED)
+ , m_textureID(-1)
+{
+}
+
+void HWTexture::Create(Params const & params)
+{
+ Create(params, nullptr);
+}
+
+void HWTexture::Create(Params const & params, ref_ptr<void> /*data*/)
+{
+ m_width = params.m_width;
+ m_height = params.m_height;
+ m_format = params.m_format;
+
+#if defined(TRACK_GPU_MEM)
+ glConst layout;
+ glConst pixelType;
+ UnpackFormat(format, layout, pixelType);
+
+ uint32_t channelBitSize = 8;
+ uint32_t channelCount = 4;
+ if (pixelType == gl_const::GL4BitOnChannel)
+ channelBitSize = 4;
+
+ if (layout == gl_const::GLAlpha)
+ channelCount = 1;
+
+ uint32_t bitCount = channelBitSize * channelCount * m_width * m_height;
+ uint32_t memSize = bitCount >> 3;
+ dp::GPUMemTracker::Inst().AddAllocated("Texture", m_textureID, memSize);
+ dp::GPUMemTracker::Inst().SetUsed("Texture", m_textureID, memSize);
+#endif
+}
+
+TextureFormat HWTexture::GetFormat() const
+{
+ return m_format;
+}
+
+uint32_t HWTexture::GetWidth() const
+{
+ ASSERT_ID;
+ return m_width;
+}
+
+uint32_t HWTexture::GetHeight() const
+{
+ ASSERT_ID;
+ return m_height;
+}
+
+float HWTexture::GetS(uint32_t x) const
+{
+ ASSERT_ID;
+ return x / (float)m_width;
+}
+
+float HWTexture::GetT(uint32_t y) const
+{
+ ASSERT_ID;
+ return y / (float)m_height;
+}
+
+void HWTexture::UnpackFormat(TextureFormat format, glConst & layout, glConst & pixelType)
+{
+ switch (format)
+ {
+ case RGBA8:
+ layout = gl_const::GLRGBA;
+ pixelType = gl_const::GL8BitOnChannel;
+ break;
+ case ALPHA:
+ layout = gl_const::GLAlpha;
+ pixelType = gl_const::GL8BitOnChannel;
+ break;
+ default:
+ ASSERT(false, ());
+ break;
+ }
+}
+
+void HWTexture::Bind() const
+{
+ ASSERT_ID;
+ GLFunctions::glBindTexture(GetID());
+}
+
+int32_t HWTexture::GetID() const
+{
+ return m_textureID;
+}
+
+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);
+ }
+
+ m_textureID = GLFunctions::glGenTexture();
+ Bind();
+
+ glConst layout;
+ glConst pixelType;
+ UnpackFormat(m_format, layout, pixelType);
+
+ GLFunctions::glTexImage2D(m_width, m_height, layout, pixelType, data.get());
+ GLFunctions::glTexParameter(gl_const::GLMinFilter, params.m_minFilter);
+ GLFunctions::glTexParameter(gl_const::GLMagFilter, params.m_magFilter);
+ GLFunctions::glTexParameter(gl_const::GLWrapS, params.m_wrapSMode);
+ GLFunctions::glTexParameter(gl_const::GLWrapT, params.m_wrapTMode);
+
+ GLFunctions::glFlush();
+ GLFunctions::glBindTexture(0);
+}
+
+void OpenGLHWTexture::UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data)
+{
+ ASSERT_ID;
+ glConst layout;
+ glConst pixelType;
+ UnpackFormat(m_format, layout, pixelType);
+
+ GLFunctions::glTexSubImage2D(x, y, width, height, layout, pixelType, data.get());
+}
+
+drape_ptr<HWTexture> OpenGLHWTextureAllocator::CreateTexture()
+{
+ return make_unique_dp<OpenGLHWTexture>();
+}
+
+drape_ptr<HWTextureAllocator> CreateAllocator()
+{
+#if defined(OMIM_OS_IPHONE)
+ return make_unique_dp<HWTextureAllocatorApple>();
+#else
+ return make_unique_dp<OpenGLHWTextureAllocator>();
+#endif
+}
+
+ref_ptr<HWTextureAllocator> GetDefaultAllocator()
+{
+ static OpenGLHWTextureAllocator s_allocator;
+ return make_ref<HWTextureAllocator>(&s_allocator);
+}
+
+}
diff --git a/drape/hw_texture.hpp b/drape/hw_texture.hpp
new file mode 100644
index 0000000000..98cb9cd846
--- /dev/null
+++ b/drape/hw_texture.hpp
@@ -0,0 +1,91 @@
+#pragma once
+
+#include "glconstants.hpp"
+#include "pointers.hpp"
+#include "drape_global.hpp"
+
+#include "std/cstdint.hpp"
+
+namespace dp
+{
+
+class HWTextureAllocator;
+class HWTexture
+{
+public:
+ HWTexture();
+ virtual ~HWTexture() {}
+
+ struct Params
+ {
+ Params()
+ : m_minFilter(gl_const::GLLinear)
+ , m_magFilter(gl_const::GLLinear)
+ , m_wrapSMode(gl_const::GLClampToEdge)
+ , m_wrapTMode(gl_const::GLClampToEdge)
+ , m_format(UNSPECIFIED)
+ {
+ }
+
+ uint32_t m_width;
+ uint32_t m_height;
+ glConst m_minFilter;
+ glConst m_magFilter;
+ glConst m_wrapSMode;
+ glConst m_wrapTMode;
+ TextureFormat m_format;
+
+ ref_ptr<HWTextureAllocator> m_allocator;
+ };
+
+ void Create(Params const & params);
+ virtual void Create(Params const & params, ref_ptr<void> data) = 0;
+ virtual void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data) = 0;
+
+ void Bind() const;
+
+ TextureFormat GetFormat() const;
+ uint32_t GetWidth() const;
+ uint32_t GetHeight() const;
+ float GetS(uint32_t x) const;
+ float GetT(uint32_t y) const;
+
+protected:
+ void UnpackFormat(TextureFormat format, glConst & layout, glConst & pixelType);
+ int32_t GetID() const;
+
+ uint32_t m_width;
+ uint32_t m_height;
+ TextureFormat m_format;
+ int32_t m_textureID;
+};
+
+class HWTextureAllocator
+{
+public:
+ virtual ~HWTextureAllocator() {}
+
+ virtual drape_ptr<HWTexture> CreateTexture() = 0;
+ virtual void Flush() = 0;
+};
+
+class OpenGLHWTexture : public HWTexture
+{
+ using TBase = HWTexture;
+
+public:
+ void Create(Params const & params, ref_ptr<void> data) override;
+ void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data) override;
+};
+
+class OpenGLHWTextureAllocator : public HWTextureAllocator
+{
+public:
+ drape_ptr<HWTexture> CreateTexture() override;
+ void Flush() override {}
+};
+
+ref_ptr<HWTextureAllocator> GetDefaultAllocator();
+drape_ptr<HWTextureAllocator> CreateAllocator();
+
+}
diff --git a/drape/hw_texture_ios.hpp b/drape/hw_texture_ios.hpp
new file mode 100644
index 0000000000..f93ca15f9f
--- /dev/null
+++ b/drape/hw_texture_ios.hpp
@@ -0,0 +1,62 @@
+#pragma once
+
+#import "hw_texture.hpp"
+
+#ifndef OMIM_OS_IPHONE
+ #error Only for ios
+#endif
+
+#import <CoreVideo/CVPixelBuffer.h>
+#import <CoreVideo/CVOpenGLESTexture.h>
+#import <CoreVideo/CVOpenGLESTextureCache.h>
+
+namespace dp
+{
+
+class HWTextureAllocatorApple : public HWTextureAllocator
+{
+public:
+ HWTextureAllocatorApple();
+ ~HWTextureAllocatorApple();
+
+ CVPixelBufferRef CVCreatePixelBuffer(uint32_t width, uint32_t height, int format);
+ void CVDestroyPixelBuffer(CVPixelBufferRef buffer);
+
+ CVOpenGLESTextureRef CVCreateTexture(CVPixelBufferRef buffer, uint32_t width, uint32_t height,
+ glConst layout, glConst pixelType);
+ void CVDestroyTexture(CVOpenGLESTextureRef texture);
+
+ void RiseFlushFlag();
+
+ drape_ptr<HWTexture> CreateTexture() override;
+ void Flush() override;
+
+private:
+ bool m_needFlush;
+ CVOpenGLESTextureCacheRef m_textureCache;
+};
+
+class HWTextureApple : public HWTexture
+{
+ using TBase = HWTexture;
+
+public:
+ HWTextureApple(ref_ptr<HWTextureAllocatorApple> allocator);
+ ~HWTextureApple();
+
+ 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);
+
+private:
+ void Lock();
+ void Unlock();
+
+private:
+ CVPixelBufferRef m_directBuffer;
+ CVOpenGLESTextureRef m_texture;
+ ref_ptr<HWTextureAllocatorApple> m_allocator;
+
+ void * m_directPointer;
+};
+
+}
diff --git a/drape/hw_texture_ios.mm b/drape/hw_texture_ios.mm
new file mode 100644
index 0000000000..9113b45b61
--- /dev/null
+++ b/drape/hw_texture_ios.mm
@@ -0,0 +1,199 @@
+#include "hw_texture_ios.hpp"
+
+#include "base/logging.hpp"
+
+#include "drape/glfunctions.hpp"
+
+#import <QuartzCore/CAEAGLLayer.h>
+
+#import <Foundation/NSDictionary.h>
+#import <Foundation/NSValue.h>
+
+#include <boost/gil/algorithm.hpp>
+#include <boost/gil/typedefs.hpp>
+
+using boost::gil::gray8c_pixel_t;
+using boost::gil::gray8_pixel_t;
+using boost::gil::gray8c_view_t;
+using boost::gil::gray8_view_t;
+using boost::gil::rgba8c_pixel_t;
+using boost::gil::rgba8_pixel_t;
+using boost::gil::rgba8c_view_t;
+using boost::gil::rgba8_view_t;
+using boost::gil::interleaved_view;
+using boost::gil::subimage_view;
+using boost::gil::copy_pixels;
+
+namespace dp
+{
+
+HWTextureAllocatorApple::HWTextureAllocatorApple()
+{
+ CVReturn cvRetval = CVOpenGLESTextureCacheCreate(kCFAllocatorDefault, nullptr,
+ [EAGLContext currentContext],
+ nullptr, &m_textureCache);
+
+ CHECK_EQUAL(cvRetval, kCVReturnSuccess, ());
+}
+
+HWTextureAllocatorApple::~HWTextureAllocatorApple()
+{
+ CFRelease(m_textureCache);
+}
+
+CVPixelBufferRef HWTextureAllocatorApple::CVCreatePixelBuffer(uint32_t width, uint32_t height, int format)
+{
+ NSDictionary * attrs = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSDictionary dictionary], kCVPixelBufferIOSurfacePropertiesKey,
+ [NSNumber numberWithInt:16], kCVPixelBufferBytesPerRowAlignmentKey,
+ [NSNumber numberWithBool:YES], kCVPixelBufferOpenGLESCompatibilityKey,
+ nil];
+
+ CFDictionaryRef attrsRef = (CFDictionaryRef)attrs;
+
+ CVPixelBufferRef result;
+ CVReturn cvRetval;
+ switch (format)
+ {
+ case dp::RGBA8:
+ cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_32BGRA, attrsRef, &result);
+ break;
+ case dp::ALPHA:
+ cvRetval = CVPixelBufferCreate(kCFAllocatorDefault, width, height, kCVPixelFormatType_OneComponent8, attrsRef, &result);
+ break;
+ default:
+ ASSERT(false, ());
+ break;
+ }
+
+ CHECK_EQUAL(cvRetval, kCVReturnSuccess, ());
+
+ return result;
+}
+
+void HWTextureAllocatorApple::CVDestroyPixelBuffer(CVPixelBufferRef buffer)
+{
+ CFRelease(buffer);
+}
+
+CVOpenGLESTextureRef HWTextureAllocatorApple::CVCreateTexture(CVPixelBufferRef buffer, uint32_t width, uint32_t height,
+ glConst layout, glConst pixelType)
+{
+ CVOpenGLESTextureRef texture;
+ CVReturn cvRetval = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, m_textureCache, buffer,
+ nullptr, gl_const::GLTexture2D, layout,
+ width, height, layout, pixelType, 0, &texture);
+
+ CHECK_EQUAL(cvRetval, kCVReturnSuccess, ());
+
+ return texture;
+}
+
+void HWTextureAllocatorApple::CVDestroyTexture(CVOpenGLESTextureRef texture)
+{
+ CFRelease(texture);
+}
+
+void HWTextureAllocatorApple::RiseFlushFlag()
+{
+ m_needFlush = true;
+}
+
+drape_ptr<HWTexture> HWTextureAllocatorApple::CreateTexture()
+{
+ return make_unique_dp<HWTextureApple>(make_ref<HWTextureAllocatorApple>(this));
+}
+
+void HWTextureAllocatorApple::Flush()
+{
+ if (m_needFlush)
+ {
+ CVOpenGLESTextureCacheFlush(m_textureCache, 0);
+ m_needFlush = false;
+ }
+}
+
+HWTextureApple::HWTextureApple(ref_ptr<HWTextureAllocatorApple> allocator)
+ : m_directBuffer(nullptr)
+ , m_texture(nullptr)
+ , m_allocator(nullptr)
+ , m_directPointer(nullptr)
+{
+}
+
+HWTextureApple::~HWTextureApple()
+{
+ if (m_allocator == nullptr)
+ {
+ m_allocator->CVDestroyTexture(m_texture);
+ m_allocator->CVDestroyPixelBuffer(m_directBuffer);
+ }
+}
+
+void HWTextureApple::Create(Params const & params, ref_ptr<void> data)
+{
+ TBase::Create(params, data);
+
+ m_allocator = params.m_allocator.downcast<HWTextureAllocatorApple>();
+ m_directBuffer = m_allocator->CVCreatePixelBuffer(params.m_width, params.m_height, params.m_format);
+
+ glConst layout, pixelType;
+ UnpackFormat(params.m_format, layout, pixelType);
+ m_texture = m_allocator->CVCreateTexture(m_directBuffer, params.m_width, params.m_height,
+ layout, pixelType);
+
+ m_textureID = CVOpenGLESTextureGetName(m_texture);
+ GLFunctions::glBindTexture(m_textureID);
+ GLFunctions::glTexParameter(gl_const::GLMinFilter, params.m_minFilter);
+ GLFunctions::glTexParameter(gl_const::GLMagFilter, params.m_magFilter);
+ GLFunctions::glTexParameter(gl_const::GLWrapS, params.m_wrapSMode);
+ GLFunctions::glTexParameter(gl_const::GLWrapT, params.m_wrapTMode);
+
+ if (data == nullptr)
+ return;
+
+ Lock();
+ memcpy(m_directPointer, data.get(), m_width * m_height * GetBytesPerPixel(m_format));
+ Unlock();
+}
+
+void HWTextureApple::UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data)
+{
+ uint8_t bytesPerPixel = GetBytesPerPixel(GetFormat());
+ Lock();
+ if (bytesPerPixel == 1)
+ {
+ gray8c_view_t srcView = interleaved_view(width, height, (gray8c_pixel_t *)data.get(), width);
+ gray8_view_t dstView = interleaved_view(m_width, m_height, (gray8_pixel_t *)m_directPointer, m_width);
+ gray8_view_t subDstView = subimage_view(dstView, x, y, width, height);
+ copy_pixels(srcView, subDstView);
+ }
+ else if (bytesPerPixel == 4)
+ {
+ rgba8c_view_t srcView = interleaved_view(width, height, (rgba8c_pixel_t *)data.get(), width * bytesPerPixel);
+ rgba8_view_t dstView = interleaved_view(m_width, m_height, (rgba8_pixel_t *)m_directPointer, m_width * bytesPerPixel);
+ rgba8_view_t subDstView = subimage_view(dstView, x, y, width, height);
+ copy_pixels(srcView, subDstView);
+ }
+ Unlock();
+}
+
+void HWTextureApple::Lock()
+{
+ ASSERT(m_directPointer == nullptr, ());
+
+ CHECK_EQUAL(CVPixelBufferLockBaseAddress(m_directBuffer, 0), kCVReturnSuccess, ());
+
+ ASSERT_EQUAL(CVPixelBufferGetBytesPerRow(m_directBuffer), m_width * GetBytesPerPixel(m_format), ());
+ m_directPointer = CVPixelBufferGetBaseAddress(m_directBuffer);
+}
+
+void HWTextureApple::Unlock()
+{
+ ASSERT(m_directPointer != nullptr, ());
+ m_directPointer = nullptr;
+ CHECK_EQUAL(CVPixelBufferUnlockBaseAddress(m_directBuffer, 0), kCVReturnSuccess, ());
+ m_allocator->RiseFlushFlag();
+}
+
+}
diff --git a/drape/pointers.hpp b/drape/pointers.hpp
index 720445fe47..66a4eeea09 100644
--- a/drape/pointers.hpp
+++ b/drape/pointers.hpp
@@ -118,6 +118,13 @@ public:
return ref_ptr<TResult>(static_cast<TResult *>(m_ptr), m_isOwnerUnique);
}
+ template<typename TResult>
+ ref_ptr<TResult> downcast() const
+ {
+ ASSERT(dynamic_cast<TResult *>(m_ptr) != nullptr, ());
+ return ref_ptr<TResult>(static_cast<TResult *>(m_ptr), m_isOwnerUnique);
+ }
+
operator bool() const { return m_ptr != nullptr; }
bool operator==(ref_ptr const & rhs) const { return m_ptr == rhs.m_ptr; }
diff --git a/drape/stipple_pen_resource.cpp b/drape/stipple_pen_resource.cpp
index dec9f11d70..02cf30e047 100644
--- a/drape/stipple_pen_resource.cpp
+++ b/drape/stipple_pen_resource.cpp
@@ -189,8 +189,7 @@ void StipplePenIndex::UploadResources(ref_ptr<Texture> texture)
pendingNodes[i].second.Rasterize(rawBuffer + i * bytesPerNode);
texture->UploadData(0, pendingNodes.front().first.minY(),
- MAX_STIPPLE_PEN_LENGTH, pendingNodes.size() * STIPPLE_HEIGHT,
- dp::ALPHA, make_ref(rawBuffer));
+ MAX_STIPPLE_PEN_LENGTH, pendingNodes.size() * STIPPLE_HEIGHT, make_ref(rawBuffer));
mng.freeSharedBuffer(reserveBufferSize, ptr);
}
diff --git a/drape/stipple_pen_resource.hpp b/drape/stipple_pen_resource.hpp
index 4e8744fca7..b1b74a9a03 100644
--- a/drape/stipple_pen_resource.hpp
+++ b/drape/stipple_pen_resource.hpp
@@ -124,11 +124,11 @@ class StipplePenTexture : public DynamicTexture<StipplePenIndex, StipplePenKey,
{
typedef DynamicTexture<StipplePenIndex, StipplePenKey, Texture::StipplePen> TBase;
public:
- StipplePenTexture(m2::PointU const & size)
+ StipplePenTexture(m2::PointU const & size, ref_ptr<HWTextureAllocator> allocator)
: m_index(size)
{
TBase::TextureParams params{ size, TextureFormat::ALPHA, gl_const::GLNearest, gl_const::GLNearest };
- TBase::Init(make_ref(&m_index), params);
+ TBase::Init(allocator, make_ref(&m_index), params);
}
~StipplePenTexture() { TBase::Reset(); }
diff --git a/drape/symbols_texture.cpp b/drape/symbols_texture.cpp
index bf62d97397..99a3215fbd 100644
--- a/drape/symbols_texture.cpp
+++ b/drape/symbols_texture.cpp
@@ -117,12 +117,12 @@ Texture::ResourceType SymbolsTexture::SymbolInfo::GetType() const
return Symbol;
}
-SymbolsTexture::SymbolsTexture(string const & skinPathName)
+SymbolsTexture::SymbolsTexture(string const & skinPathName, ref_ptr<HWTextureAllocator> allocator)
{
- Load(skinPathName);
+ Load(skinPathName, allocator);
}
-void SymbolsTexture::Load(string const & skinPathName)
+void SymbolsTexture::Load(string const & skinPathName, ref_ptr<HWTextureAllocator> allocator)
{
vector<unsigned char> rawData;
uint32_t width, height;
@@ -163,19 +163,27 @@ void SymbolsTexture::Load(string const & skinPathName)
unsigned char * data = stbi_png_load_from_memory(&rawData[0], rawData.size(), &w, &h, &bpp, 0);
if (width == w && height == h)
- Create(width, height, RGBA8, make_ref(data));
+ {
+ Texture::Params p;
+ p.m_allocator = allocator;
+ p.m_format = dp::RGBA8;
+ p.m_width = width;
+ p.m_height = height;
+
+ Create(p, make_ref(data));
+ }
else
Fail();
stbi_image_free(data);
}
-void SymbolsTexture::Invalidate(string const & skinPathName)
+void SymbolsTexture::Invalidate(string const & skinPathName, ref_ptr<HWTextureAllocator> allocator)
{
Destroy();
m_definition.clear();
- Load(skinPathName);
+ Load(skinPathName, allocator);
}
ref_ptr<Texture::ResourceInfo> SymbolsTexture::FindResource(Texture::Key const & key, bool & newResource)
@@ -195,7 +203,13 @@ void SymbolsTexture::Fail()
{
m_definition.clear();
int32_t alfaTexture = 0;
- Create(1, 1, RGBA8, make_ref(&alfaTexture));
+ Texture::Params p;
+ p.m_allocator = GetDefaultAllocator();
+ p.m_format = dp::RGBA8;
+ p.m_width = 1;
+ p.m_height = 1;
+
+ Create(p, make_ref(&alfaTexture));
}
} // namespace dp
diff --git a/drape/symbols_texture.hpp b/drape/symbols_texture.hpp
index 486ca06afd..6ed7f6dd3b 100644
--- a/drape/symbols_texture.hpp
+++ b/drape/symbols_texture.hpp
@@ -29,15 +29,15 @@ public:
virtual ResourceType GetType() const;
};
- explicit SymbolsTexture(string const & skinPathName);
+ explicit SymbolsTexture(string const & skinPathName, ref_ptr<HWTextureAllocator> allocator);
ref_ptr<ResourceInfo> FindResource(Key const & key, bool & newResource) override;
- void Invalidate(string const & skinPathName);
+ void Invalidate(string const & skinPathName, ref_ptr<HWTextureAllocator> allocator);
private:
void Fail();
- void Load(string const & skinPathName);
+ void Load(string const & skinPathName, ref_ptr<HWTextureAllocator> allocator);
typedef map<string, SymbolInfo> TSymDefinition;
mutable TSymDefinition m_definition;
diff --git a/drape/texture.cpp b/drape/texture.cpp
index da86948c12..57631cc49c 100644
--- a/drape/texture.cpp
+++ b/drape/texture.cpp
@@ -22,10 +22,6 @@ m2::RectF const & Texture::ResourceInfo::GetTexRect() const
//////////////////////////////////////////////////////////////////
Texture::Texture()
- : m_textureID(-1)
- , m_width(0)
- , m_height(0)
- , m_format(dp::UNSPECIFIED)
{
}
@@ -34,124 +30,58 @@ Texture::~Texture()
Destroy();
}
-void Texture::Create(uint32_t width, uint32_t height, TextureFormat format)
+void Texture::Create(Params const & params)
{
- Create(width, height, format, nullptr);
+ if (AllocateTexture(params.m_allocator))
+ m_hwTexture->Create(params);
}
-void Texture::Create(uint32_t width, uint32_t height, TextureFormat format, ref_ptr<void> data)
+void Texture::Create(Params const & params, ref_ptr<void> data)
{
- m_format = format;
- m_width = width;
- m_height = height;
- if (!GLExtensionsList::Instance().IsSupported(GLExtensionsList::TextureNPOT))
- {
- m_width = my::NextPowOf2(width);
- m_height = my::NextPowOf2(height);
- }
-
- m_textureID = GLFunctions::glGenTexture();
- GLFunctions::glBindTexture(m_textureID);
-
- glConst layout;
- glConst pixelType;
- UnpackFormat(format, layout, pixelType);
-
- GLFunctions::glTexImage2D(m_width, m_height, layout, pixelType, data.get());
- SetFilterParams(gl_const::GLLinear, gl_const::GLLinear);
- SetWrapMode(gl_const::GLClampToEdge, gl_const::GLClampToEdge);
-
- GLFunctions::glFlush();
- GLFunctions::glBindTexture(0);
-
-#if defined(TRACK_GPU_MEM)
- uint32_t channelBitSize = 8;
- uint32_t channelCount = 4;
- if (pixelType == gl_const::GL4BitOnChannel)
- channelBitSize = 4;
-
- if (layout == gl_const::GLAlpha)
- channelCount = 1;
-
- uint32_t bitCount = channelBitSize * channelCount * m_width * m_height;
- uint32_t memSize = bitCount >> 3;
- dp::GPUMemTracker::Inst().AddAllocated("Texture", m_textureID, memSize);
- dp::GPUMemTracker::Inst().SetUsed("Texture", m_textureID, memSize);
-#endif
-}
-
-void Texture::Destroy()
-{
- if (m_textureID != -1)
- {
- GLFunctions::glDeleteTexture(m_textureID);
-#if defined(TRACK_GPU_MEM)
- dp::GPUMemTracker::Inst().RemoveDeallocated("Texture", m_textureID);
-#endif
- m_textureID = -1;
- }
+ if (AllocateTexture(params.m_allocator))
+ m_hwTexture->Create(params, data);
}
-void Texture::SetFilterParams(glConst minFilter, glConst magFilter)
+void Texture::UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, ref_ptr<void> data)
{
- ASSERT_ID;
- GLFunctions::glTexParameter(gl_const::GLMinFilter, minFilter);
- GLFunctions::glTexParameter(gl_const::GLMagFilter, magFilter);
-}
-
-void Texture::SetWrapMode(glConst sMode, glConst tMode)
-{
- ASSERT_ID;
- GLFunctions::glTexParameter(gl_const::GLWrapS, sMode);
- GLFunctions::glTexParameter(gl_const::GLWrapT, tMode);
-}
-
-void Texture::UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height,
- TextureFormat format, ref_ptr<void> data)
-{
- ASSERT_ID;
- ASSERT(format == m_format, ());
- glConst layout;
- glConst pixelType;
-
- UnpackFormat(format, layout, pixelType);
-
- GLFunctions::glTexSubImage2D(x, y, width, height, layout, pixelType, data.get());
+ ASSERT(m_hwTexture != nullptr, ());
+ m_hwTexture->UploadData(x, y, width, height, data);
}
TextureFormat Texture::GetFormat() const
{
- return m_format;
+ ASSERT(m_hwTexture != nullptr, ());
+ return m_hwTexture->GetFormat();
}
uint32_t Texture::GetWidth() const
{
- ASSERT_ID;
- return m_width;
+ ASSERT(m_hwTexture != nullptr, ());
+ return m_hwTexture->GetWidth();
}
uint32_t Texture::GetHeight() const
{
- ASSERT_ID;
- return m_height;
+ ASSERT(m_hwTexture != nullptr, ());
+ return m_hwTexture->GetHeight();
}
float Texture::GetS(uint32_t x) const
{
- ASSERT_ID;
- return x / (float)m_width;
+ ASSERT(m_hwTexture != nullptr, ());
+ return m_hwTexture->GetS(x);
}
float Texture::GetT(uint32_t y) const
{
- ASSERT_ID;
- return y / (float)m_height;
+ ASSERT(m_hwTexture != nullptr, ());
+ return m_hwTexture->GetT(y);
}
void Texture::Bind() const
{
- ASSERT_ID;
- GLFunctions::glBindTexture(GetID());
+ ASSERT(m_hwTexture != nullptr, ());
+ m_hwTexture->Bind();
}
uint32_t Texture::GetMaxTextureSize()
@@ -159,32 +89,20 @@ uint32_t Texture::GetMaxTextureSize()
return GLFunctions::glGetInteger(gl_const::GLMaxTextureSize);
}
-void Texture::UnpackFormat(TextureFormat format, glConst & layout, glConst & pixelType)
+void Texture::Destroy()
{
- bool requiredFormat = false;//GLExtensionsList::Instance().IsSupported(GLExtensionsList::RequiredInternalFormat);
- switch (format)
- {
- case RGBA8:
- layout = requiredFormat ? gl_const::GLRGBA8 : gl_const::GLRGBA;
- pixelType = gl_const::GL8BitOnChannel;
- break;
- case RGBA4:
- layout = requiredFormat ? gl_const::GLRGBA4 : gl_const::GLRGBA;
- pixelType = gl_const::GL4BitOnChannel;
- break;
- case ALPHA:
- layout = requiredFormat ? gl_const::GLAlpha8 : gl_const::GLAlpha;
- pixelType = gl_const::GL8BitOnChannel;
- break;
- default:
- ASSERT(false, ());
- break;
- }
+ m_hwTexture.reset();
}
-int32_t Texture::GetID() const
+bool Texture::AllocateTexture(ref_ptr<HWTextureAllocator> allocator)
{
- return m_textureID;
+ if (allocator != nullptr)
+ {
+ m_hwTexture = allocator->CreateTexture();
+ return true;
+ }
+
+ return false;
}
} // namespace dp
diff --git a/drape/texture.hpp b/drape/texture.hpp
index 705bfcc96e..de60ec5add 100644
--- a/drape/texture.hpp
+++ b/drape/texture.hpp
@@ -3,6 +3,7 @@
#include "drape/pointers.hpp"
#include "drape/glconstants.hpp"
#include "drape/drape_global.hpp"
+#include "drape/hw_texture.hpp"
#include "geometry/rect2d.hpp"
@@ -47,19 +48,17 @@ public:
Texture();
virtual ~Texture();
- void Create(uint32_t width, uint32_t height, TextureFormat format);
- void Create(uint32_t width, uint32_t height, TextureFormat format, ref_ptr<void> data);
-
- void SetFilterParams(glConst minFilter, glConst magFilter);
- void SetWrapMode(glConst sMode, glConst tMode);
-
- void UploadData(uint32_t x, uint32_t y, uint32_t width, uint32_t height, TextureFormat format,
- ref_ptr<void> data);
-
virtual ref_ptr<ResourceInfo> FindResource(Key const & key, bool & newResource) = 0;
virtual void UpdateState() {}
virtual bool HasAsyncRoutines() const { return false; }
+ 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);
+
TextureFormat GetFormat() const;
uint32_t GetWidth() const;
uint32_t GetHeight() const;
@@ -72,16 +71,10 @@ public:
protected:
void Destroy();
+ bool AllocateTexture(ref_ptr<HWTextureAllocator> allocator);
private:
- void UnpackFormat(TextureFormat format, glConst & layout, glConst & pixelType);
- int32_t GetID() const;
-
-private:
- int32_t m_textureID;
- uint32_t m_width;
- uint32_t m_height;
- TextureFormat m_format;
+ drape_ptr<HWTexture> m_hwTexture;
};
} // namespace dp
diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp
index f2790e8c1e..ade58c103f 100644
--- a/drape/texture_manager.cpp
+++ b/drape/texture_manager.cpp
@@ -225,13 +225,15 @@ bool TextureManager::UpdateDynamicTextures()
UpdateGlyphTextures(m_glyphGroups);
UpdateGlyphTextures(m_hybridGlyphGroups);
+ m_textureAllocator->Flush();
+
return true;
}
ref_ptr<Texture> TextureManager::AllocateGlyphTexture()
{
m2::PointU size(m_maxTextureSize, m_maxTextureSize);
- m_glyphTextures.push_back(make_unique_dp<FontTexture>(size, make_ref(m_glyphManager)));
+ m_glyphTextures.push_back(make_unique_dp<FontTexture>(size, make_ref(m_glyphManager), make_ref(m_textureAllocator)));
return make_ref(m_glyphTextures.back());
}
@@ -358,11 +360,13 @@ size_t TextureManager::FindHybridGlyphsGroup(TMultilineText const & text)
void TextureManager::Init(Params const & params)
{
+ m_textureAllocator = CreateAllocator();
+
m_maxTextureSize = min(kMaxTextureSize, (uint32_t)GLFunctions::glGetInteger(gl_const::GLMaxTextureSize));
GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1);
- m_symbolTexture = make_unique_dp<SymbolsTexture>(params.m_resPostfix);
+ m_symbolTexture = make_unique_dp<SymbolsTexture>(params.m_resPostfix, make_ref(m_textureAllocator));
// initialize patterns
buffer_vector<buffer_vector<uint8_t, 8>, 64> patterns;
@@ -377,7 +381,8 @@ void TextureManager::Init(Params const & params)
uint32_t stippleTextureHeight = max(my::NextPowOf2(patterns.size() + kReservedPatterns), kMinStippleTextureHeight);
stippleTextureHeight = min(m_maxTextureSize, stippleTextureHeight);
- m_stipplePenTexture = make_unique_dp<StipplePenTexture>(m2::PointU(kStippleTextureWidth, stippleTextureHeight));
+ m_stipplePenTexture = make_unique_dp<StipplePenTexture>(m2::PointU(kStippleTextureWidth, stippleTextureHeight),
+ make_ref(m_textureAllocator));
LOG(LDEBUG, ("Patterns texture size = ", m_stipplePenTexture->GetWidth(), m_stipplePenTexture->GetHeight()));
ref_ptr<StipplePenTexture> stipplePenTextureTex = make_ref(m_stipplePenTexture);
@@ -393,7 +398,7 @@ void TextureManager::Init(Params const & params)
uint32_t colorTextureSize = max(my::NextPowOf2(floor(sqrt(colors.size() + kReservedColors))), kMinColorTextureSize);
colorTextureSize = min(m_maxTextureSize, colorTextureSize);
- m_colorTexture = make_unique_dp<ColorTexture>(m2::PointU(colorTextureSize, colorTextureSize));
+ m_colorTexture = make_unique_dp<ColorTexture>(m2::PointU(colorTextureSize, colorTextureSize), make_ref(m_textureAllocator));
LOG(LDEBUG, ("Colors texture size = ", m_colorTexture->GetWidth(), m_colorTexture->GetHeight()));
ref_ptr<ColorTexture> colorTex = make_ref(m_colorTexture);
@@ -431,7 +436,7 @@ void TextureManager::Invalidate(string const & resPostfix)
{
ASSERT(m_symbolTexture != nullptr, ());
ref_ptr<SymbolsTexture> symbolsTexture = make_ref(m_symbolTexture);
- symbolsTexture->Invalidate(resPostfix);
+ symbolsTexture->Invalidate(resPostfix, make_ref(m_textureAllocator));
}
void TextureManager::GetSymbolRegion(string const & symbolName, SymbolRegion & region)
diff --git a/drape/texture_manager.hpp b/drape/texture_manager.hpp
index db4b9a7074..fae9e77f52 100644
--- a/drape/texture_manager.hpp
+++ b/drape/texture_manager.hpp
@@ -14,6 +14,8 @@
namespace dp
{
+class HWTextureAllocator;
+
class TextureManager
{
public:
@@ -220,6 +222,7 @@ private:
list<drape_ptr<Texture>> m_glyphTextures;
drape_ptr<GlyphManager> m_glyphManager;
+ drape_ptr<HWTextureAllocator> m_textureAllocator;
buffer_vector<GlyphGroup, 64> m_glyphGroups;
buffer_vector<HybridGlyphGroup, 4> m_hybridGlyphGroups;
diff --git a/drape/texture_of_colors.cpp b/drape/texture_of_colors.cpp
index 1274394d10..e787e8c46f 100644
--- a/drape/texture_of_colors.cpp
+++ b/drape/texture_of_colors.cpp
@@ -141,8 +141,8 @@ void ColorPalette::UploadResources(ref_ptr<Texture> texture)
}
pointer = SharedBufferManager::GetRawPointer(buffer);
- texture->UploadData(uploadRect.minX(), uploadRect.minY(), uploadRect.SizeX(), uploadRect.SizeY(),
- dp::RGBA8, make_ref(pointer));
+ texture->UploadData(uploadRect.minX(), uploadRect.minY(),
+ uploadRect.SizeX(), uploadRect.SizeY(), make_ref(pointer));
}
}
diff --git a/drape/texture_of_colors.hpp b/drape/texture_of_colors.hpp
index 24d5974a60..7535090194 100644
--- a/drape/texture_of_colors.hpp
+++ b/drape/texture_of_colors.hpp
@@ -66,7 +66,7 @@ class ColorTexture : public DynamicTexture<ColorPalette, ColorKey, Texture::Colo
{
typedef DynamicTexture<ColorPalette, ColorKey, Texture::Color> TBase;
public:
- ColorTexture(m2::PointU const & size)
+ ColorTexture(m2::PointU const & size, ref_ptr<HWTextureAllocator> allocator)
: m_pallete(size)
{
TBase::TextureParams params;
@@ -75,7 +75,7 @@ public:
params.m_minFilter = gl_const::GLNearest;
params.m_magFilter = gl_const::GLNearest;
- TBase::Init(make_ref(&m_pallete), params);
+ TBase::Init(allocator, make_ref(&m_pallete), params);
}
void ReserveColor(dp::Color const & color);
diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj
index 1cebdcb343..325c816167 100644
--- a/iphone/Maps/Maps.xcodeproj/project.pbxproj
+++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj
@@ -609,6 +609,7 @@
A32B6D4D1A14980500E54A65 /* iosOGLContextFactory.mm in Sources */ = {isa = PBXBuildFile; fileRef = A32B6D4B1A14980500E54A65 /* iosOGLContextFactory.mm */; };
A367C93B1B17334800E2B6E7 /* resources-default in Resources */ = {isa = PBXBuildFile; fileRef = A367C93A1B17334800E2B6E7 /* resources-default */; };
A3CC2CD41A1C723900B832E1 /* LocationPredictor.mm in Sources */ = {isa = PBXBuildFile; fileRef = A3CC2CD21A1C723900B832E1 /* LocationPredictor.mm */; };
+ A3F402FB1B81F537008E5F65 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 454040681AD2D8D2007A9B12 /* CoreVideo.framework */; };
B00510FB1A11015900A61AA4 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 972CDCC51887F1B7006641CA /* CFNetwork.framework */; };
B00511021A1101E000A61AA4 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 97C98655186C734000AF7E9E /* AVFoundation.framework */; };
B00511041A1101F600A61AA4 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B00511031A1101F600A61AA4 /* CoreData.framework */; };