From 66abb8ada5d6f9b4496f039a0f79bdb6348c7e61 Mon Sep 17 00:00:00 2001 From: rachytski Date: Fri, 22 Jul 2011 00:00:50 +0300 Subject: [PATCH] [ANDROID] fixed text drawing and opengl state applying. --- map/framework.cpp | 4 ++-- yg/base_texture.cpp | 4 +++- yg/framebuffer.cpp | 19 +++---------------- yg/framebuffer.hpp | 2 -- yg/glyph_layout.cpp | 4 +++- yg/indexbuffer.cpp | 16 +++------------- yg/indexbuffer.hpp | 3 --- yg/renderbuffer.cpp | 21 +++------------------ yg/renderbuffer.hpp | 3 --- yg/vertexbuffer.cpp | 16 +++------------- yg/vertexbuffer.hpp | 2 -- 11 files changed, 20 insertions(+), 74 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 6c4ac90ae9..0a19374941 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -88,8 +88,8 @@ Framework::Framework(shared_ptr windowHandle, m_centeringMode(EDoNothing), m_tileSize(GetPlatform().TileSize()) { - SetRenderPolicy(make_shared_ptr(new RenderPolicyST(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4)))); - //SetRenderPolicy(make_shared_ptr(new TilingRenderPolicyMT(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4)))); +// SetRenderPolicy(make_shared_ptr(new RenderPolicyST(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4)))); + SetRenderPolicy(make_shared_ptr(new TilingRenderPolicyMT(windowHandle, bind(&this_type::DrawModel, this, _1, _2, _3, _4)))); m_informationDisplay.setBottomShift(bottomShift); #ifdef DRAW_TOUCH_POINTS m_informationDisplay.enableDebugPoints(true); diff --git a/yg/base_texture.cpp b/yg/base_texture.cpp index df1a29e872..5544a8662b 100644 --- a/yg/base_texture.cpp +++ b/yg/base_texture.cpp @@ -71,7 +71,9 @@ namespace yg void BaseTexture::makeCurrent() { - //if (current() != m_id) +#ifndef OMIM_OS_ANDROID + if (current() != m_id) +#endif OGLCHECK(glBindTexture(GL_TEXTURE_2D, m_id)); } diff --git a/yg/framebuffer.cpp b/yg/framebuffer.cpp index 3d29344f2a..ceede03339 100644 --- a/yg/framebuffer.cpp +++ b/yg/framebuffer.cpp @@ -25,21 +25,6 @@ namespace yg return id; } - void FrameBuffer::pushCurrent() - { - //frameBufferStack.push_back(current()); - } - - void FrameBuffer::popCurrent() - { -//#ifdef OMIM_GL_ES -// OGLCHECK(glBindFramebufferOES(GL_FRAMEBUFFER_OES, frameBufferStack.back())); -//#else -// OGLCHECK(glBindFramebuffer(GL_FRAMEBUFFER_EXT, frameBufferStack.back())); -//#endif -// frameBufferStack.pop_back(); - } - FrameBuffer::FrameBuffer(bool defaultFB /*= false*/) : m_width(0), m_height(0) { if (defaultFB) @@ -68,7 +53,9 @@ namespace yg void FrameBuffer::makeCurrent() { - //if (m_id != current()) +#ifndef OMIM_OS_ANDROID + if (m_id != current()) +#endif { #ifdef OMIM_GL_ES OGLCHECK(glBindFramebufferOES(GL_FRAMEBUFFER_OES, m_id)); diff --git a/yg/framebuffer.hpp b/yg/framebuffer.hpp index d44c3c96f7..49b56a481f 100644 --- a/yg/framebuffer.hpp +++ b/yg/framebuffer.hpp @@ -45,8 +45,6 @@ namespace yg unsigned height() const; static unsigned current(); - static void pushCurrent(); - static void popCurrent(); void checkStatus(); }; diff --git a/yg/glyph_layout.cpp b/yg/glyph_layout.cpp index 4c78324fd5..2db371137b 100644 --- a/yg/glyph_layout.cpp +++ b/yg/glyph_layout.cpp @@ -9,6 +9,7 @@ #include "../geometry/angles.hpp" #include "../geometry/aa_rect2d.hpp" +#include "../base/thread.hpp" namespace yg { @@ -81,7 +82,7 @@ namespace yg m_pivot(pt) { m2::RectD limitRect; - m2::PointD curPt; + m2::PointD curPt(0, 0); bool isFirst = true; @@ -90,6 +91,7 @@ namespace yg GlyphKey glyphKey(visText[i], fontDesc.m_size, fontDesc.m_isMasked, fontDesc.m_color); GlyphMetrics const m = glyphCache->getGlyphMetrics(glyphKey); + if (isFirst) { limitRect = m2::RectD(m.m_xOffset, diff --git a/yg/indexbuffer.cpp b/yg/indexbuffer.cpp index 5d4372722e..df0d29bcf9 100644 --- a/yg/indexbuffer.cpp +++ b/yg/indexbuffer.cpp @@ -20,18 +20,6 @@ namespace yg return id; } - void IndexBuffer::pushCurrent() - { -// indexBufferStack.push_back(current()); - } - - void IndexBuffer::popCurrent() - { -// if (indexBufferStack.back() != (unsigned int)-1) -// OGLCHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBufferStack.back())); -// indexBufferStack.pop_back(); - } - IndexBuffer::IndexBuffer(bool useVA) : m_size(0), m_gpuData(0), m_useVA(useVA) { @@ -114,7 +102,9 @@ namespace yg if (m_useVA) return; - //if (m_id != current()) +#ifndef OMIM_OS_ANDROID + if (m_id != current()) +#endif OGLCHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id)); } diff --git a/yg/indexbuffer.hpp b/yg/indexbuffer.hpp index a6c3dab7d2..f6672bf21d 100644 --- a/yg/indexbuffer.hpp +++ b/yg/indexbuffer.hpp @@ -28,10 +28,7 @@ namespace yg void * glPtr(); - static void pushCurrent(); - static void popCurrent(); static int current(); - }; } } diff --git a/yg/renderbuffer.cpp b/yg/renderbuffer.cpp index fc62ec6fdd..4c3bf22fdb 100644 --- a/yg/renderbuffer.cpp +++ b/yg/renderbuffer.cpp @@ -25,25 +25,9 @@ namespace yg return id; } - void RenderBuffer::pushCurrent() - { -// renderBufferStack.push_back(current()); - } - - void RenderBuffer::popCurrent() - { -//#ifdef OMIM_GL_ES -// OGLCHECK(glBindRenderbufferOES(GL_RENDERBUFFER_OES, renderBufferStack.back())); -//#else -// OGLCHECK(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderBufferStack.back())); -//#endif -// renderBufferStack.pop_back(); - } - RenderBuffer::RenderBuffer(size_t width, size_t height, bool isDepthBuffer) : m_isDepthBuffer(isDepthBuffer), m_width(width), m_height(height) { - pushCurrent(); #ifdef OMIM_GL_ES OGLCHECK(glGenRenderbuffersOES(1, &m_id)); makeCurrent(); @@ -68,7 +52,6 @@ namespace yg height)); #endif - popCurrent(); } RenderBuffer::~RenderBuffer() @@ -109,7 +92,9 @@ namespace yg void RenderBuffer::makeCurrent() { - //if (m_id != current()) +#ifndef OMIM_OS_ANDROID + if (m_id != current()) +#endif { #ifdef OMIM_GL_ES OGLCHECK(glBindRenderbufferOES(GL_RENDERBUFFER_OES, m_id)); diff --git a/yg/renderbuffer.hpp b/yg/renderbuffer.hpp index a2c6a411a5..6909ec78c5 100644 --- a/yg/renderbuffer.hpp +++ b/yg/renderbuffer.hpp @@ -33,9 +33,6 @@ namespace yg unsigned width() const; unsigned height() const; - - static void pushCurrent(); - static void popCurrent(); }; } } diff --git a/yg/vertexbuffer.cpp b/yg/vertexbuffer.cpp index 04c6d1c43f..cef2e42ac0 100644 --- a/yg/vertexbuffer.cpp +++ b/yg/vertexbuffer.cpp @@ -20,18 +20,6 @@ namespace yg return id; } - void VertexBuffer::pushCurrent() - { -// vertexBufferStack.push_back(current()); - } - - void VertexBuffer::popCurrent() - { -// if (vertexBufferStack.back() != (unsigned int)-1) -// OGLCHECK(glBindBuffer(GL_ARRAY_BUFFER, vertexBufferStack.back())); -// vertexBufferStack.pop_back(); - } - VertexBuffer::VertexBuffer(bool useVA) : m_size(0), m_gpuData(0), m_useVA(useVA) { @@ -123,7 +111,9 @@ namespace yg if (m_useVA) return; - //if (m_id != current()) +#ifndef OMIM_OS_ANDROID + if (m_id != current()) +#endif OGLCHECK(glBindBuffer(GL_ARRAY_BUFFER, m_id)); } diff --git a/yg/vertexbuffer.hpp b/yg/vertexbuffer.hpp index 819ec594c7..c85c992aba 100644 --- a/yg/vertexbuffer.hpp +++ b/yg/vertexbuffer.hpp @@ -30,8 +30,6 @@ namespace yg void * glPtr() const; static unsigned current(); - static void pushCurrent(); - static void popCurrent(); }; } }