From ff589eba4adc2b0eb96b5697b648af43a972defe Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Thu, 22 Oct 2015 12:50:20 +0300 Subject: [PATCH] Fixed black outline around icons --- drape/drape_tests/compile_shaders_test.cpp | 3 +- drape/dynamic_texture.hpp | 6 +-- drape/font_texture.hpp | 3 +- drape/glstate.cpp | 13 +++++ drape/glstate.hpp | 4 ++ drape/hw_texture.cpp | 16 ++++++- drape/hw_texture.hpp | 10 ++-- drape/hw_texture_ios.mm | 4 +- drape/shaders/dashed_fragment_shader.fsh | 2 +- drape/shaders/dashed_vertex_shader.vsh | 4 +- drape/stipple_pen_resource.hpp | 2 +- drape/texture.cpp | 6 +++ drape/texture.hpp | 3 ++ drape/texture_of_colors.hpp | 3 +- .../drape_frontend_tests.pro | 1 - .../drape_frontend_tests/skin_tests.cpp | 48 ------------------- drape_frontend/poi_symbol_shape.cpp | 1 + 17 files changed, 59 insertions(+), 70 deletions(-) delete mode 100644 drape_frontend/drape_frontend_tests/skin_tests.cpp diff --git a/drape/drape_tests/compile_shaders_test.cpp b/drape/drape_tests/compile_shaders_test.cpp index 2962581d73..9ab527df19 100644 --- a/drape/drape_tests/compile_shaders_test.cpp +++ b/drape/drape_tests/compile_shaders_test.cpp @@ -109,6 +109,7 @@ void ForEachShader(vector const & shaders, { QTemporaryFile srcFile; TEST(srcFile.open(), ("Temporary File can't be created!")); + //srcFile.setAutoRemove(false); WriteShaderToFile(srcFile, src); RunShaderTest(glslCompiler, srcFile.fileName(), procPrepare, argsPrepare, successComparator, errorLog); @@ -188,7 +189,7 @@ void TestMaliShaders(QString const & driver, shaderType = "-f"; ForEachShader(gpu::FragmentEnum, compilerPath, procPrepare, argForming, succesComparator, ss); - TEST(errorLog.isEmpty(), (errorLog)); + TEST(errorLog.isEmpty(), (shaderType,release, hardware, driver, errorLog)); } UNIT_TEST(MALI_CompileShaders_Test) diff --git a/drape/dynamic_texture.hpp b/drape/dynamic_texture.hpp index e4c6242fe9..41c593b98c 100644 --- a/drape/dynamic_texture.hpp +++ b/drape/dynamic_texture.hpp @@ -38,8 +38,7 @@ protected: { m2::PointU m_size; dp::TextureFormat m_format; - glConst m_minFilter; - glConst m_magFilter; + glConst m_filter; }; void Init(ref_ptr allocator, ref_ptr indexer, TextureParams const & params) @@ -56,8 +55,7 @@ protected: 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; + p.m_filter = params.m_filter; Create(p, data); } diff --git a/drape/font_texture.hpp b/drape/font_texture.hpp index 652f29bd12..e9da79e1a6 100644 --- a/drape/font_texture.hpp +++ b/drape/font_texture.hpp @@ -139,8 +139,7 @@ public: TBase::TextureParams params; params.m_size = size; params.m_format = TextureFormat::ALPHA; - params.m_minFilter = gl_const::GLLinear; - params.m_magFilter = gl_const::GLLinear; + params.m_filter = gl_const::GLLinear; vector initData(params.m_size.x * params.m_size.y, 0); TBase::Init(allocator, make_ref(&m_index), params, make_ref(initData.data())); diff --git a/drape/glstate.cpp b/drape/glstate.cpp index 443f1ff278..d8e89834fe 100644 --- a/drape/glstate.cpp +++ b/drape/glstate.cpp @@ -48,6 +48,7 @@ GLState::GLState(uint32_t gpuProgramIndex, DepthLayer depthLayer) : m_gpuProgramIndex(gpuProgramIndex) , m_depthLayer(depthLayer) , m_depthFunction(gl_const::GLLessOrEqual) + , m_textureFilter(gl_const::GLLinear) , m_colorTexture(nullptr) , m_maskTexture(nullptr) { @@ -63,6 +64,16 @@ void GLState::SetDepthFunction(glConst functionName) m_depthFunction = functionName; } +glConst GLState::GetTextureFilter() const +{ + return m_textureFilter; +} + +void GLState::SetTextureFilter(glConst filter) +{ + m_textureFilter = filter; +} + bool GLState::operator<(GLState const & other) const { if (m_depthLayer != other.m_depthLayer) @@ -108,6 +119,7 @@ void ApplyTextures(GLState state, ref_ptr program) GLFunctions::glActiveTexture(gl_const::GLTexture0); tex->Bind(); GLFunctions::glUniformValuei(colorTexLoc, 0); + tex->SetFilter(state.GetTextureFilter()); } else { @@ -130,6 +142,7 @@ void ApplyTextures(GLState state, ref_ptr program) GLFunctions::glActiveTexture(gl_const::GLTexture0 + 1); tex->Bind(); GLFunctions::glUniformValuei(maskTexLoc, 1); + tex->SetFilter(state.GetTextureFilter()); } else { diff --git a/drape/glstate.hpp b/drape/glstate.hpp index d77360ce4e..e5a4e481e5 100644 --- a/drape/glstate.hpp +++ b/drape/glstate.hpp @@ -62,6 +62,9 @@ public: glConst GetDepthFunction() const; void SetDepthFunction(glConst functionName); + glConst GetTextureFilter() const; + void SetTextureFilter(glConst filter); + bool operator<(GLState const & other) const; bool operator==(GLState const & other) const; @@ -70,6 +73,7 @@ private: DepthLayer m_depthLayer; Blending m_blending; glConst m_depthFunction; + glConst m_textureFilter; ref_ptr m_colorTexture; ref_ptr m_maskTexture; diff --git a/drape/hw_texture.cpp b/drape/hw_texture.cpp index 8fb4cd8aec..37ee4980fc 100644 --- a/drape/hw_texture.cpp +++ b/drape/hw_texture.cpp @@ -19,6 +19,7 @@ HWTexture::HWTexture() , m_height(0) , m_format(UNSPECIFIED) , m_textureID(-1) + , m_filter(gl_const::GLLinear) { } @@ -32,6 +33,7 @@ void HWTexture::Create(Params const & params, ref_ptr /*data*/) m_width = params.m_width; m_height = params.m_height; m_format = params.m_format; + m_filter = params.m_filter; #if defined(TRACK_GPU_MEM) glConst layout; @@ -106,6 +108,16 @@ void HWTexture::Bind() const GLFunctions::glBindTexture(GetID()); } +void HWTexture::SetFilter(glConst filter) +{ + if (m_filter != filter) + { + m_filter = filter; + GLFunctions::glTexParameter(gl_const::GLMinFilter, m_filter); + GLFunctions::glTexParameter(gl_const::GLMagFilter, m_filter); + } +} + int32_t HWTexture::GetID() const { return m_textureID; @@ -135,8 +147,8 @@ void OpenGLHWTexture::Create(Params const & params, ref_ptr data) 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::GLMinFilter, params.m_filter); + GLFunctions::glTexParameter(gl_const::GLMagFilter, params.m_filter); GLFunctions::glTexParameter(gl_const::GLWrapS, params.m_wrapSMode); GLFunctions::glTexParameter(gl_const::GLWrapT, params.m_wrapTMode); diff --git a/drape/hw_texture.hpp b/drape/hw_texture.hpp index 56383523f4..a408ee384f 100644 --- a/drape/hw_texture.hpp +++ b/drape/hw_texture.hpp @@ -19,8 +19,7 @@ public: struct Params { Params() - : m_minFilter(gl_const::GLLinear) - , m_magFilter(gl_const::GLLinear) + : m_filter(gl_const::GLLinear) , m_wrapSMode(gl_const::GLClampToEdge) , m_wrapTMode(gl_const::GLClampToEdge) , m_format(UNSPECIFIED) @@ -29,8 +28,7 @@ public: uint32_t m_width; uint32_t m_height; - glConst m_minFilter; - glConst m_magFilter; + glConst m_filter; glConst m_wrapSMode; glConst m_wrapTMode; TextureFormat m_format; @@ -44,6 +42,9 @@ public: void Bind() const; + // Texture must be bound before calling this method. + void SetFilter(glConst filter); + TextureFormat GetFormat() const; uint32_t GetWidth() const; uint32_t GetHeight() const; @@ -58,6 +59,7 @@ protected: uint32_t m_height; TextureFormat m_format; int32_t m_textureID; + glConst m_filter; }; class HWTextureAllocator diff --git a/drape/hw_texture_ios.mm b/drape/hw_texture_ios.mm index 884c35e203..f3d1b57086 100644 --- a/drape/hw_texture_ios.mm +++ b/drape/hw_texture_ios.mm @@ -145,8 +145,8 @@ void HWTextureApple::Create(Params const & params, ref_ptr data) 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::GLMinFilter, params.m_filter); + GLFunctions::glTexParameter(gl_const::GLMagFilter, params.m_filter); GLFunctions::glTexParameter(gl_const::GLWrapS, params.m_wrapSMode); GLFunctions::glTexParameter(gl_const::GLWrapT, params.m_wrapTMode); diff --git a/drape/shaders/dashed_fragment_shader.fsh b/drape/shaders/dashed_fragment_shader.fsh index c233b84576..aaa41df3fb 100644 --- a/drape/shaders/dashed_fragment_shader.fsh +++ b/drape/shaders/dashed_fragment_shader.fsh @@ -1,6 +1,6 @@ varying vec2 v_colorTexCoord; varying vec2 v_halfLength; -varying highp vec2 v_maskTexCoord; +varying vec2 v_maskTexCoord; uniform sampler2D u_colorTex; uniform sampler2D u_maskTex; diff --git a/drape/shaders/dashed_vertex_shader.vsh b/drape/shaders/dashed_vertex_shader.vsh index 4c95d2335a..a0e09a551f 100644 --- a/drape/shaders/dashed_vertex_shader.vsh +++ b/drape/shaders/dashed_vertex_shader.vsh @@ -1,13 +1,13 @@ attribute vec3 a_position; attribute vec3 a_normal; attribute vec2 a_colorTexCoord; -attribute highp vec2 a_maskTexCoord; +attribute vec2 a_maskTexCoord; uniform mat4 modelView; uniform mat4 projection; varying vec2 v_colorTexCoord; -varying highp vec2 v_maskTexCoord; +varying vec2 v_maskTexCoord; varying vec2 v_halfLength; void main(void) diff --git a/drape/stipple_pen_resource.hpp b/drape/stipple_pen_resource.hpp index b1b74a9a03..f016f8f70e 100644 --- a/drape/stipple_pen_resource.hpp +++ b/drape/stipple_pen_resource.hpp @@ -127,7 +127,7 @@ public: StipplePenTexture(m2::PointU const & size, ref_ptr allocator) : m_index(size) { - TBase::TextureParams params{ size, TextureFormat::ALPHA, gl_const::GLNearest, gl_const::GLNearest }; + TBase::TextureParams params{ size, TextureFormat::ALPHA, gl_const::GLNearest }; TBase::Init(allocator, make_ref(&m_index), params); } diff --git a/drape/texture.cpp b/drape/texture.cpp index 57631cc49c..9731cfd25d 100644 --- a/drape/texture.cpp +++ b/drape/texture.cpp @@ -84,6 +84,12 @@ void Texture::Bind() const m_hwTexture->Bind(); } +void Texture::SetFilter(glConst filter) +{ + ASSERT(m_hwTexture != nullptr, ()); + m_hwTexture->SetFilter(filter); +} + uint32_t Texture::GetMaxTextureSize() { return GLFunctions::glGetInteger(gl_const::GLMaxTextureSize); diff --git a/drape/texture.hpp b/drape/texture.hpp index de60ec5add..c88cf4d737 100644 --- a/drape/texture.hpp +++ b/drape/texture.hpp @@ -67,6 +67,9 @@ public: void Bind() const; + // Texture must be bound before calling this method. + void SetFilter(glConst filter); + static uint32_t GetMaxTextureSize(); protected: diff --git a/drape/texture_of_colors.hpp b/drape/texture_of_colors.hpp index 7535090194..52ed9b462f 100644 --- a/drape/texture_of_colors.hpp +++ b/drape/texture_of_colors.hpp @@ -72,8 +72,7 @@ public: TBase::TextureParams params; params.m_size = size; params.m_format = TextureFormat::RGBA8; - params.m_minFilter = gl_const::GLNearest; - params.m_magFilter = gl_const::GLNearest; + params.m_filter = gl_const::GLNearest; TBase::Init(allocator, make_ref(&m_pallete), params); } diff --git a/drape_frontend/drape_frontend_tests/drape_frontend_tests.pro b/drape_frontend/drape_frontend_tests/drape_frontend_tests.pro index df829828a5..4b9b507616 100644 --- a/drape_frontend/drape_frontend_tests/drape_frontend_tests.pro +++ b/drape_frontend/drape_frontend_tests/drape_frontend_tests.pro @@ -22,7 +22,6 @@ SOURCES += \ memory_feature_index_tests.cpp \ navigator_test.cpp \ object_pool_tests.cpp \ - skin_tests.cpp \ tile_tree_tests.cpp \ tile_utils_tests.cpp \ user_event_stream_tests.cpp \ diff --git a/drape_frontend/drape_frontend_tests/skin_tests.cpp b/drape_frontend/drape_frontend_tests/skin_tests.cpp deleted file mode 100644 index ba206306ac..0000000000 --- a/drape_frontend/drape_frontend_tests/skin_tests.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "base/SRC_FIRST.hpp" -#include "testing/testing.hpp" - -#include "drape_frontend/gui/skin.hpp" - -UNIT_TEST(ParseDefaultSkinTest) -{ - gui::Skin skin(gui::ResolveGuiSkinFile("default"), 2.0); - float width = 600.0f; - float height = 800.0f; - skin.Resize(width, height); - - gui::Position compassPos = skin.ResolvePosition(gui::WIDGET_COMPASS); - TEST_EQUAL(compassPos.m_anchor, dp::Center, ()); - TEST_ALMOST_EQUAL_ULPS(compassPos.m_pixelPivot.x, 35.0f * 2.0f, ()); - TEST_ALMOST_EQUAL_ULPS(compassPos.m_pixelPivot.y, height - 90.0f * 2.0f, ()); - - gui::Position rulerPos = skin.ResolvePosition(gui::WIDGET_RULER); - TEST_EQUAL(rulerPos.m_anchor, dp::Right, ()); - TEST_ALMOST_EQUAL_ULPS(rulerPos.m_pixelPivot.x, width - 70.0f * 2.0f, ()); - TEST_ALMOST_EQUAL_ULPS(rulerPos.m_pixelPivot.y, height - 10.0f * 2.0f, ()); - - gui::Position copyRightPos = skin.ResolvePosition(gui::WIDGET_COPYRIGHT); - TEST_EQUAL(copyRightPos.m_anchor, dp::Center, ()); - TEST_ALMOST_EQUAL_ULPS(copyRightPos.m_pixelPivot.x, width / 2.0f, ()); - TEST_ALMOST_EQUAL_ULPS(copyRightPos.m_pixelPivot.y, 30.0f * 2.0f, ()); - - { - width = 800.0f; - height = 600.0f; - skin.Resize(width, height); - - gui::Position compassPos = skin.ResolvePosition(gui::WIDGET_COMPASS); - TEST_EQUAL(compassPos.m_anchor, dp::Center, ()); - TEST_ALMOST_EQUAL_ULPS(compassPos.m_pixelPivot.x, 35.0f * 2.0f, ()); - TEST_ALMOST_EQUAL_ULPS(compassPos.m_pixelPivot.y, height - 90.0f * 2.0f, ()); - - gui::Position rulerPos = skin.ResolvePosition(gui::WIDGET_RULER); - TEST_EQUAL(rulerPos.m_anchor, dp::Right, ()); - TEST_ALMOST_EQUAL_ULPS(rulerPos.m_pixelPivot.x, width - 70.0f * 2.0f, ()); - TEST_ALMOST_EQUAL_ULPS(rulerPos.m_pixelPivot.y, height - 10.0f * 2.0f, ()); - - gui::Position copyRightPos = skin.ResolvePosition(gui::WIDGET_COPYRIGHT); - TEST_EQUAL(copyRightPos.m_anchor, dp::Center, ()); - TEST_ALMOST_EQUAL_ULPS(copyRightPos.m_pixelPivot.x, width / 2.0f, ()); - TEST_ALMOST_EQUAL_ULPS(copyRightPos.m_pixelPivot.y, 30.0f * 2.0f, ()); - } -} diff --git a/drape_frontend/poi_symbol_shape.cpp b/drape_frontend/poi_symbol_shape.cpp index 8218db5275..eaa743f411 100644 --- a/drape_frontend/poi_symbol_shape.cpp +++ b/drape_frontend/poi_symbol_shape.cpp @@ -46,6 +46,7 @@ void PoiSymbolShape::Draw(ref_ptr batcher, ref_ptr