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
path: root/drape
diff options
context:
space:
mode:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2018-08-16 18:48:20 +0300
committerRoman Kuznetsov <r.kuznetsow@gmail.com>2018-08-17 13:11:53 +0300
commit04c0ffbab4df4bee1e229474787b98feb4d6ae06 (patch)
tree702742ea61542b85e400e7aa34540d7894dd93de /drape
parent5ab189afac15e9e97aef702e69e0d883bc8532b9 (diff)
Review fixes.
Diffstat (limited to 'drape')
-rw-r--r--drape/debug_renderer.hpp3
-rw-r--r--drape/dynamic_texture.hpp13
-rw-r--r--drape/graphics_context.hpp8
-rw-r--r--drape/hw_texture.cpp9
-rw-r--r--drape/hw_texture.hpp2
-rw-r--r--drape/mesh_object.cpp13
-rw-r--r--drape/mesh_object.hpp16
-rw-r--r--drape/oglcontext.cpp38
-rw-r--r--drape/overlay_tree.cpp2
-rw-r--r--drape/overlay_tree.hpp6
-rw-r--r--drape/render_bucket.cpp4
-rw-r--r--drape/render_bucket.hpp6
-rw-r--r--drape/render_state.cpp18
-rw-r--r--drape/render_state.hpp2
-rw-r--r--drape/static_texture.cpp14
-rw-r--r--drape/static_texture.hpp3
-rw-r--r--drape/texture.cpp10
-rw-r--r--drape/texture.hpp5
18 files changed, 101 insertions, 71 deletions
diff --git a/drape/debug_renderer.hpp b/drape/debug_renderer.hpp
index 39e82d3317..48dffed937 100644
--- a/drape/debug_renderer.hpp
+++ b/drape/debug_renderer.hpp
@@ -7,9 +7,10 @@ namespace dp
{
class GraphicsContext;
-class IDebugRenderer
+class DebugRenderer
{
public:
+ virtual ~DebugRenderer() = default;
virtual bool IsEnabled() const = 0;
virtual void DrawRect(ref_ptr<GraphicsContext> context, ScreenBase const & screen,
m2::RectF const & rect, Color const & color) = 0;
diff --git a/drape/dynamic_texture.hpp b/drape/dynamic_texture.hpp
index a795c50d90..877c40c168 100644
--- a/drape/dynamic_texture.hpp
+++ b/drape/dynamic_texture.hpp
@@ -10,6 +10,7 @@ namespace dp
template<typename TIndexer, typename TResourceKey, Texture::ResourceType TResourceType>
class DynamicTexture : public Texture
{
+ using Base = Texture;
public:
~DynamicTexture() override
{
@@ -25,6 +26,18 @@ public:
return m_indexer->MapResource(static_cast<TResourceKey const &>(key), newResource);
}
+ void Create(Params const & params) override
+ {
+ ASSERT(Base::IsPowerOfTwo(params.m_width, params.m_height), (params.m_width, params.m_height));
+ Base::Create(params);
+ }
+
+ void Create(Params const & params, ref_ptr<void> data) override
+ {
+ ASSERT(Base::IsPowerOfTwo(params.m_width, params.m_height), (params.m_width, params.m_height));
+ Base::Create(params, data);
+ }
+
void UpdateState() override
{
// Create texture before first uploading.
diff --git a/drape/graphics_context.hpp b/drape/graphics_context.hpp
index c78184cd8a..be750a2c4a 100644
--- a/drape/graphics_context.hpp
+++ b/drape/graphics_context.hpp
@@ -35,10 +35,10 @@ enum class StencilAction : uint8_t
Keep,
Zero,
Replace,
- Incr,
- IncrWrap,
- Decr,
- DecrWrap,
+ Increment,
+ IncrementWrap,
+ Decrement,
+ DecrementWrap,
Invert
};
diff --git a/drape/hw_texture.cpp b/drape/hw_texture.cpp
index 2fa4e7bc99..7e168258e4 100644
--- a/drape/hw_texture.cpp
+++ b/drape/hw_texture.cpp
@@ -9,10 +9,6 @@
#include "base/logging.hpp"
#include "base/math.hpp"
-#ifdef DEBUG
-#include "3party/glm/glm/gtx/bit.hpp"
-#endif
-
#if defined(OMIM_OS_IPHONE)
#include "drape/hw_texture_ios.hpp"
#endif
@@ -178,10 +174,7 @@ OpenGLHWTexture::~OpenGLHWTexture()
void OpenGLHWTexture::Create(Params const & params, ref_ptr<void> data)
{
- TBase::Create(params, data);
-
- //ASSERT(glm::isPowerOfTwo(static_cast<int>(m_width)), (m_width));
- //ASSERT(glm::isPowerOfTwo(static_cast<int>(m_height)), (m_height));
+ Base::Create(params, data);
m_textureID = GLFunctions::glGenTexture();
Bind();
diff --git a/drape/hw_texture.hpp b/drape/hw_texture.hpp
index 7fb1ffa1d2..0226e3b7d5 100644
--- a/drape/hw_texture.hpp
+++ b/drape/hw_texture.hpp
@@ -68,7 +68,7 @@ public:
class OpenGLHWTexture : public HWTexture
{
- using TBase = HWTexture;
+ using Base = HWTexture;
public:
~OpenGLHWTexture() override;
diff --git a/drape/mesh_object.cpp b/drape/mesh_object.cpp
index 3013c0a26c..236b5cae6f 100644
--- a/drape/mesh_object.cpp
+++ b/drape/mesh_object.cpp
@@ -14,9 +14,9 @@ glConst GetGLDrawPrimitive(dp::MeshObject::DrawPrimitive drawPrimitive)
{
switch (drawPrimitive)
{
- case dp::MeshObject::DrawPrimitive::Triangles: return gl_const::GLTriangles;
- case dp::MeshObject::DrawPrimitive::TriangleStrip: return gl_const::GLTriangleStrip;
- case dp::MeshObject::DrawPrimitive::LineStrip: return gl_const::GLLineStrip;
+ case dp::MeshObject::DrawPrimitive::Triangles: return gl_const::GLTriangles;
+ case dp::MeshObject::DrawPrimitive::TriangleStrip: return gl_const::GLTriangleStrip;
+ case dp::MeshObject::DrawPrimitive::LineStrip: return gl_const::GLLineStrip;
}
}
} // namespace
@@ -181,11 +181,11 @@ void MeshObject::Unbind(ref_ptr<dp::GpuProgram> program)
}
// static
-void MeshObject::GenerateNormalsForTriangles(std::vector<float> const & vertices, size_t componentsCount,
- std::vector<float> & normals)
+std::vector<float> MeshObject::GenerateNormalsForTriangles(std::vector<float> const & vertices,
+ size_t componentsCount)
{
auto const trianglesCount = vertices.size() / (3 * componentsCount);
- normals.clear();
+ std::vector<float> normals;
normals.reserve(trianglesCount * 9);
for (size_t triangle = 0; triangle < trianglesCount; ++triangle)
{
@@ -207,6 +207,7 @@ void MeshObject::GenerateNormalsForTriangles(std::vector<float> const & vertices
normals.push_back(normal.z);
}
}
+ return normals;
}
} // namespace dp
diff --git a/drape/mesh_object.hpp b/drape/mesh_object.hpp
index 211dbfe6a3..5d3c14bf5d 100644
--- a/drape/mesh_object.hpp
+++ b/drape/mesh_object.hpp
@@ -1,26 +1,21 @@
#pragma once
-#include "drape/graphics_context.hpp"
#include "drape/render_state.hpp"
#include "drape/pointers.hpp"
#include <functional>
+#include <string>
#include <vector>
namespace dp
{
class GpuProgram;
-
-class RenderParamsHolder
-{
-public:
- virtual void ApplyProgramParams() = 0;
-};
+class GraphicsContext;
class MeshObject
{
public:
- enum class DrawPrimitive: uint32_t
+ enum class DrawPrimitive: uint8_t
{
Triangles,
TriangleStrip,
@@ -41,7 +36,7 @@ public:
{
Bind(program);
- ApplyState(state, context, program);
+ ApplyState(context, program, state);
paramsSetter->Apply(program, params);
DrawPrimitives();
@@ -55,8 +50,7 @@ public:
void Build(ref_ptr<dp::GpuProgram> program);
void Reset();
- static void GenerateNormalsForTriangles(std::vector<float> const & vertices, size_t componentsCount,
- std::vector<float> & normals);
+ static std::vector<float> GenerateNormalsForTriangles(std::vector<float> const & vertices, size_t componentsCount);
private:
struct AttributeMapping
diff --git a/drape/oglcontext.cpp b/drape/oglcontext.cpp
index 7543b0fbeb..62794bb176 100644
--- a/drape/oglcontext.cpp
+++ b/drape/oglcontext.cpp
@@ -9,14 +9,14 @@ glConst DecodeTestFunction(TestFunction depthFunction)
{
switch (depthFunction)
{
- case TestFunction::Never: return gl_const::GLNever;
- case TestFunction::Less: return gl_const::GLLess;
- case TestFunction::Equal: return gl_const::GLEqual;
- case TestFunction::LessOrEqual: return gl_const::GLLessOrEqual;
- case TestFunction::Greater: return gl_const::GLGreat;
- case TestFunction::NotEqual: return gl_const::GLNotEqual;
- case TestFunction::GreaterOrEqual: return gl_const::GLGreatOrEqual;
- case TestFunction::Always: return gl_const::GLAlways;
+ case TestFunction::Never: return gl_const::GLNever;
+ case TestFunction::Less: return gl_const::GLLess;
+ case TestFunction::Equal: return gl_const::GLEqual;
+ case TestFunction::LessOrEqual: return gl_const::GLLessOrEqual;
+ case TestFunction::Greater: return gl_const::GLGreat;
+ case TestFunction::NotEqual: return gl_const::GLNotEqual;
+ case TestFunction::GreaterOrEqual: return gl_const::GLGreatOrEqual;
+ case TestFunction::Always: return gl_const::GLAlways;
}
ASSERT(false, ());
}
@@ -25,9 +25,9 @@ glConst DecodeStencilFace(StencilFace stencilFace)
{
switch (stencilFace)
{
- case StencilFace::Front: return gl_const::GLFront;
- case StencilFace::Back: return gl_const::GLBack;
- case StencilFace::FrontAndBack: return gl_const::GLFrontAndBack;
+ case StencilFace::Front: return gl_const::GLFront;
+ case StencilFace::Back: return gl_const::GLBack;
+ case StencilFace::FrontAndBack: return gl_const::GLFrontAndBack;
}
ASSERT(false, ());
}
@@ -36,14 +36,14 @@ glConst DecodeStencilAction(StencilAction stencilAction)
{
switch (stencilAction)
{
- case StencilAction::Keep: return gl_const::GLKeep;
- case StencilAction::Zero: return gl_const::GLZero;
- case StencilAction::Replace: return gl_const::GLReplace;
- case StencilAction::Incr: return gl_const::GLIncr;
- case StencilAction::IncrWrap: return gl_const::GLIncrWrap;
- case StencilAction::Decr: return gl_const::GLDecr;
- case StencilAction::DecrWrap: return gl_const::GLDecrWrap;
- case StencilAction::Invert: return gl_const::GLInvert;
+ case StencilAction::Keep: return gl_const::GLKeep;
+ case StencilAction::Zero: return gl_const::GLZero;
+ case StencilAction::Replace: return gl_const::GLReplace;
+ case StencilAction::Increment: return gl_const::GLIncr;
+ case StencilAction::IncrementWrap: return gl_const::GLIncrWrap;
+ case StencilAction::Decrement: return gl_const::GLDecr;
+ case StencilAction::DecrementWrap: return gl_const::GLDecrWrap;
+ case StencilAction::Invert: return gl_const::GLInvert;
}
ASSERT(false, ());
}
diff --git a/drape/overlay_tree.cpp b/drape/overlay_tree.cpp
index 7f44e37223..991d549309 100644
--- a/drape/overlay_tree.cpp
+++ b/drape/overlay_tree.cpp
@@ -453,7 +453,7 @@ OverlayTree::TDisplacementInfo const & OverlayTree::GetDisplacementInfo() const
return m_displacementInfo;
}
-void OverlayTree::SetDebugRectRenderer(ref_ptr<IDebugRenderer> debugRectRenderer)
+void OverlayTree::SetDebugRectRenderer(ref_ptr<DebugRenderer> debugRectRenderer)
{
m_debugRectRenderer = debugRectRenderer;
}
diff --git a/drape/overlay_tree.hpp b/drape/overlay_tree.hpp
index d52b48a2d0..0ed6162849 100644
--- a/drape/overlay_tree.hpp
+++ b/drape/overlay_tree.hpp
@@ -49,7 +49,7 @@ struct OverlayHasher
};
} // namespace detail
-class IDebugRenderer;
+class DebugRenderer;
using TOverlayContainer = buffer_vector<ref_ptr<OverlayHandle>, 8>;
@@ -95,7 +95,7 @@ public:
using TDisplacementInfo = std::vector<DisplacementData>;
TDisplacementInfo const & GetDisplacementInfo() const;
- void SetDebugRectRenderer(ref_ptr<IDebugRenderer> debugRectRenderer);
+ void SetDebugRectRenderer(ref_ptr<DebugRenderer> debugRectRenderer);
private:
ScreenBase const & GetModelView() const { return m_traits.GetModelView(); }
@@ -119,7 +119,7 @@ private:
FeatureID m_selectedFeatureID;
TDisplacementInfo m_displacementInfo;
- ref_ptr<IDebugRenderer> m_debugRectRenderer;
+ ref_ptr<DebugRenderer> m_debugRectRenderer;
HandlesCache m_displacers;
uint32_t m_frameUpdatePeriod;
diff --git a/drape/render_bucket.cpp b/drape/render_bucket.cpp
index 8682278b48..c4f5567846 100644
--- a/drape/render_bucket.cpp
+++ b/drape/render_bucket.cpp
@@ -133,8 +133,8 @@ void RenderBucket::SetFeatureMinZoom(int minZoom)
m_featuresMinZoom = minZoom;
}
-void RenderBucket::RenderDebug(ScreenBase const & screen, ref_ptr<GraphicsContext> context,
- ref_ptr<IDebugRenderer> debugRectRenderer) const
+void RenderBucket::RenderDebug(ref_ptr<GraphicsContext> context, ScreenBase const & screen,
+ ref_ptr<DebugRenderer> debugRectRenderer) const
{
if (!debugRectRenderer || !debugRectRenderer->IsEnabled() || m_overlay.empty())
return;
diff --git a/drape/render_bucket.hpp b/drape/render_bucket.hpp
index faab8425e3..0ef6ce50e6 100644
--- a/drape/render_bucket.hpp
+++ b/drape/render_bucket.hpp
@@ -17,7 +17,7 @@ namespace dp
{
class GraphicsContext;
-class IDebugRenderer;
+class DebugRenderer;
class OverlayHandle;
class OverlayTree;
class VertexArrayBuffer;
@@ -45,8 +45,8 @@ public:
void Render(bool drawAsLine);
// Only for testing! Don't use this function in production code!
- void RenderDebug(ScreenBase const & screen, ref_ptr<GraphicsContext> context,
- ref_ptr<IDebugRenderer> debugRectRenderer) const;
+ void RenderDebug(ref_ptr<GraphicsContext> context, ScreenBase const & screen,
+ ref_ptr<DebugRenderer> debugRectRenderer) const;
// Only for testing! Don't use this function in production code!
template <typename ToDo>
diff --git a/drape/render_state.cpp b/drape/render_state.cpp
index 93ea2a52f1..a6efc153b7 100644
--- a/drape/render_state.cpp
+++ b/drape/render_state.cpp
@@ -14,14 +14,14 @@ glConst DecodeTestFunction(TestFunction depthFunction)
{
switch (depthFunction)
{
- case TestFunction::Never: return gl_const::GLNever;
- case TestFunction::Less: return gl_const::GLLess;
- case TestFunction::Equal: return gl_const::GLEqual;
- case TestFunction::LessOrEqual: return gl_const::GLLessOrEqual;
- case TestFunction::Greater: return gl_const::GLGreat;
- case TestFunction::NotEqual: return gl_const::GLNotEqual;
- case TestFunction::GreaterOrEqual: return gl_const::GLGreatOrEqual;
- case TestFunction::Always: return gl_const::GLAlways;
+ case TestFunction::Never: return gl_const::GLNever;
+ case TestFunction::Less: return gl_const::GLLess;
+ case TestFunction::Equal: return gl_const::GLEqual;
+ case TestFunction::LessOrEqual: return gl_const::GLLessOrEqual;
+ case TestFunction::Greater: return gl_const::GLGreat;
+ case TestFunction::NotEqual: return gl_const::GLNotEqual;
+ case TestFunction::GreaterOrEqual: return gl_const::GLGreatOrEqual;
+ case TestFunction::Always: return gl_const::GLAlways;
}
CHECK_SWITCH();
}
@@ -215,7 +215,7 @@ void ApplyBlending(RenderState const & state)
state.GetBlending().Apply();
}
-void ApplyState(RenderState const & state, ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program)
+void ApplyState(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program, RenderState const & state)
{
TextureState::ApplyTextures(state, program);
ApplyBlending(state);
diff --git a/drape/render_state.hpp b/drape/render_state.hpp
index 27bb0a74d9..485ea1fb81 100644
--- a/drape/render_state.hpp
+++ b/drape/render_state.hpp
@@ -123,6 +123,6 @@ private:
static uint8_t m_usedSlots;
};
-void ApplyState(RenderState const & state, ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program);
+void ApplyState(ref_ptr<GraphicsContext> context, ref_ptr<GpuProgram> program, RenderState const & state);
void ApplyBlending(RenderState const & state);
} // namespace dp
diff --git a/drape/static_texture.cpp b/drape/static_texture.cpp
index 3121088433..e51609ee12 100644
--- a/drape/static_texture.cpp
+++ b/drape/static_texture.cpp
@@ -142,6 +142,20 @@ ref_ptr<Texture::ResourceInfo> StaticTexture::FindResource(Texture::Key const &
return make_ref(m_info);
}
+void StaticTexture::Create(Params const & params)
+{
+ ASSERT(Base::IsPowerOfTwo(params.m_width, params.m_height), (params.m_width, params.m_height));
+
+ Base::Create(params);
+}
+
+void StaticTexture::Create(Params const & params, ref_ptr<void> data)
+{
+ ASSERT(Base::IsPowerOfTwo(params.m_width, params.m_height), (params.m_width, params.m_height));
+
+ Base::Create(params, data);
+}
+
void StaticTexture::Fail()
{
int32_t alphaTexture = 0;
diff --git a/drape/static_texture.hpp b/drape/static_texture.hpp
index d7a6950445..8175a4d2fc 100644
--- a/drape/static_texture.hpp
+++ b/drape/static_texture.hpp
@@ -8,6 +8,7 @@ namespace dp
{
class StaticTexture : public Texture
{
+ using Base = Texture;
public:
class StaticKey : public Key
{
@@ -21,6 +22,8 @@ public:
dp::TextureFormat format, ref_ptr<HWTextureAllocator> allocator);
ref_ptr<ResourceInfo> FindResource(Key const & key, bool & newResource) override;
+ void Create(Params const & params) override;
+ void Create(Params const & params, ref_ptr<void> data) override;
void Invalidate(ref_ptr<HWTextureAllocator> allocator);
diff --git a/drape/texture.cpp b/drape/texture.cpp
index b09e35b180..3eb0156175 100644
--- a/drape/texture.cpp
+++ b/drape/texture.cpp
@@ -2,10 +2,13 @@
#include "drape/glextensions_list.hpp"
#include "drape/glfunctions.hpp"
+#include "drape/glsl_func.hpp"
#include "drape/utils/gpu_mem_tracker.hpp"
#include "base/math.hpp"
+#include "3party/glm/glm/gtx/bit.hpp"
+
namespace dp
{
Texture::ResourceInfo::ResourceInfo(m2::RectF const & texRect) : m_texRect(texRect) {}
@@ -83,11 +86,18 @@ void Texture::SetFilter(TextureFilter filter)
m_hwTexture->SetFilter(filter);
}
+// static
uint32_t Texture::GetMaxTextureSize()
{
return static_cast<uint32_t>(GLFunctions::glGetInteger(gl_const::GLMaxTextureSize));
}
+// static
+bool Texture::IsPowerOfTwo(uint32_t width, uint32_t height)
+{
+ return glm::isPowerOfTwo(static_cast<int>(width)) && glm::isPowerOfTwo(static_cast<int>(height));
+}
+
void Texture::Destroy() { m_hwTexture.reset(); }
bool Texture::AllocateTexture(ref_ptr<HWTextureAllocator> allocator)
diff --git a/drape/texture.hpp b/drape/texture.hpp
index 679eb121c5..8dff145036 100644
--- a/drape/texture.hpp
+++ b/drape/texture.hpp
@@ -64,11 +64,12 @@ public:
// Texture must be bound before calling this method.
virtual void SetFilter(TextureFilter filter);
- void Create(Params const & params);
- void Create(Params const & params, ref_ptr<void> data);
+ virtual void Create(Params const & params);
+ virtual 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();
+ static bool IsPowerOfTwo(uint32_t width, uint32_t height);
protected:
void Destroy();