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:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2017-08-05 10:36:21 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2017-08-07 15:11:09 +0300
commit0cb5cd6f0d7a875e6b71ad02a4da76ec403de8e6 (patch)
treeebee6287d93a7b5c0b9dcd23338b22f5ba5dfeba
parent8b76dc2fc1185cc85f54ee549d1a769727e9d8ed (diff)
Refactored render layers and GLState
-rw-r--r--drape/batcher.cpp5
-rw-r--r--drape/batcher.hpp3
-rw-r--r--drape/drape_tests/batcher_tests.cpp333
-rw-r--r--drape/drape_tests/img.cpp2
-rw-r--r--drape/glstate.cpp42
-rw-r--r--drape/glstate.hpp41
-rw-r--r--drape_frontend/CMakeLists.txt2
-rw-r--r--drape_frontend/apply_feature_functors.cpp12
-rw-r--r--drape_frontend/apply_feature_functors.hpp4
-rw-r--r--drape_frontend/area_shape.cpp12
-rw-r--r--drape_frontend/arrow3d.cpp3
-rw-r--r--drape_frontend/arrow3d.hpp3
-rw-r--r--drape_frontend/circles_pack_shape.cpp2
-rw-r--r--drape_frontend/circles_pack_shape.hpp6
-rw-r--r--drape_frontend/colored_symbol_shape.cpp5
-rw-r--r--drape_frontend/drape_api_builder.hpp2
-rwxr-xr-xdrape_frontend/drape_frontend.pro2
-rwxr-xr-xdrape_frontend/frontend_renderer.cpp72
-rwxr-xr-xdrape_frontend/frontend_renderer.hpp22
-rw-r--r--drape_frontend/gui/choose_position_mark.cpp2
-rw-r--r--drape_frontend/gui/compass.cpp2
-rw-r--r--drape_frontend/gui/gui_text.cpp8
-rw-r--r--drape_frontend/gui/gui_text.hpp4
-rw-r--r--drape_frontend/gui/ruler.cpp2
-rw-r--r--drape_frontend/gui/shape.hpp6
-rw-r--r--drape_frontend/line_shape.cpp10
-rw-r--r--drape_frontend/line_shape.hpp2
-rw-r--r--drape_frontend/message_subclasses.hpp2
-rw-r--r--drape_frontend/my_position.cpp4
-rw-r--r--drape_frontend/my_position.hpp6
-rw-r--r--drape_frontend/overlay_batcher.hpp6
-rw-r--r--drape_frontend/path_symbol_shape.cpp4
-rw-r--r--drape_frontend/path_text_shape.cpp9
-rw-r--r--drape_frontend/poi_symbol_shape.cpp4
-rw-r--r--drape_frontend/postprocess_renderer.cpp2
-rwxr-xr-xdrape_frontend/render_group.cpp28
-rwxr-xr-xdrape_frontend/render_group.hpp4
-rw-r--r--drape_frontend/render_node.cpp7
-rw-r--r--drape_frontend/render_node.hpp19
-rw-r--r--drape_frontend/render_state.cpp47
-rw-r--r--drape_frontend/render_state.hpp45
-rw-r--r--drape_frontend/route_shape.cpp8
-rw-r--r--drape_frontend/route_shape.hpp6
-rw-r--r--drape_frontend/rule_drawer.cpp8
-rw-r--r--drape_frontend/screen_quad_renderer.cpp2
-rw-r--r--drape_frontend/selection_shape.cpp2
-rw-r--r--drape_frontend/shape_view_params.hpp5
-rw-r--r--drape_frontend/text_shape.cpp6
-rw-r--r--drape_frontend/traffic_generator.cpp4
-rw-r--r--drape_frontend/traffic_generator.hpp2
-rw-r--r--drape_frontend/user_mark_shapes.cpp5
-rw-r--r--drape_frontend/user_mark_shapes.hpp4
-rw-r--r--drape_frontend/user_marks_provider.hpp10
-rw-r--r--map/local_ads_mark.cpp4
-rw-r--r--map/local_ads_mark.hpp2
-rw-r--r--map/routing_mark.cpp4
-rw-r--r--map/routing_mark.hpp2
-rw-r--r--map/track.cpp4
-rw-r--r--map/track.hpp2
-rw-r--r--map/user_mark.cpp4
-rw-r--r--map/user_mark.hpp2
-rw-r--r--xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj8
62 files changed, 476 insertions, 414 deletions
diff --git a/drape/batcher.cpp b/drape/batcher.cpp
index aa7a67e670..f5e75ed1f8 100644
--- a/drape/batcher.cpp
+++ b/drape/batcher.cpp
@@ -104,13 +104,10 @@ private:
bool m_vaoChanged = false;
};
-////////////////////////////////////////////////////////////////
-
Batcher::Batcher(uint32_t indexBufferSize, uint32_t vertexBufferSize)
: m_indexBufferSize(indexBufferSize)
, m_vertexBufferSize(vertexBufferSize)
-{
-}
+{}
Batcher::~Batcher()
{
diff --git a/drape/batcher.hpp b/drape/batcher.hpp
index f3c3839aa0..a8da3eee98 100644
--- a/drape/batcher.hpp
+++ b/drape/batcher.hpp
@@ -110,5 +110,4 @@ public:
private:
Batcher & m_batcher;
};
-
-} // namespace dp
+} // namespace dp
diff --git a/drape/drape_tests/batcher_tests.cpp b/drape/drape_tests/batcher_tests.cpp
index 563b391e49..84486d7b5a 100644
--- a/drape/drape_tests/batcher_tests.cpp
+++ b/drape/drape_tests/batcher_tests.cpp
@@ -1,19 +1,18 @@
-#include "drape/drape_tests/memory_comparer.hpp"
#include "testing/testing.hpp"
#include "drape/batcher.hpp"
+#include "drape/drape_tests/glmock_functions.hpp"
+#include "drape/drape_tests/memory_comparer.hpp"
#include "drape/glconstants.hpp"
#include "drape/gpu_program_manager.hpp"
#include "drape/index_storage.hpp"
#include "drape/vertex_array_buffer.hpp"
-#include "drape/drape_tests/glmock_functions.hpp"
-
#include "base/stl_add.hpp"
-#include "std/bind.hpp"
-#include "std/cstring.hpp"
-#include "std/function.hpp"
+#include <cstring>
+#include <functional>
+#include <vector>
#include <gmock/gmock.h>
@@ -24,10 +23,10 @@ using testing::Invoke;
using testing::IgnoreResult;
using testing::AnyOf;
using namespace dp;
+using namespace std::placeholders;
namespace
{
-
struct VAOAcceptor
{
virtual void FlushFullBucket(GLState const & /*state*/, drape_ptr<RenderBucket> && bucket)
@@ -35,7 +34,14 @@ struct VAOAcceptor
m_vao.push_back(move(bucket));
}
- vector<drape_ptr<RenderBucket> > m_vao;
+ std::vector<drape_ptr<RenderBucket>> m_vao;
+};
+
+class TestRenderState : public dp::BaseRenderState
+{
+public:
+ bool Less(ref_ptr<dp::BaseRenderState> other) const override { return false; }
+ bool Equal(ref_ptr<dp::BaseRenderState> other) const override { return true; }
};
class BatcherExpectations
@@ -44,21 +50,21 @@ public:
BatcherExpectations()
: m_indexBufferID(1)
, m_dataBufferID(2)
- {
- }
+ {}
template <typename TBatcherCall>
void RunTest(float * vertexes, void * indexes,
uint32_t vertexCount, uint8_t vertexComponentCount,
uint32_t indexCount, TBatcherCall const & fn)
{
- int const vertexSize = vertexCount * vertexComponentCount;
+ uint32_t const vertexSize = vertexCount * vertexComponentCount;
MemoryComparer const dataCmp(vertexes, vertexSize * sizeof(float));
MemoryComparer const indexCmp(indexes, indexCount * dp::IndexStorage::SizeOfIndex());
ExpectBufferCreation(vertexSize, indexCount, indexCmp, dataCmp);
- GLState state(0, GLState::GeometryLayer);
+ auto renderState = make_unique_dp<TestRenderState>();
+ auto state = GLState(0, make_ref(renderState));
BindingInfo binding(1);
BindingDecl & decl = binding.GetBindingDecl(0);
@@ -73,7 +79,7 @@ public:
VAOAcceptor vaoAcceptor;
Batcher batcher(65000, 65000);
- batcher.StartSession(bind(&VAOAcceptor::FlushFullBucket, &vaoAcceptor, _1, _2));
+ batcher.StartSession(std::bind(&VAOAcceptor::FlushFullBucket, &vaoAcceptor, _1, _2));
fn(&batcher, state, make_ref(&provider));
batcher.EndSession();
@@ -91,13 +97,15 @@ public:
// data buffer creation
EXPECTGL(glGenBuffer()).WillOnce(Return(m_dataBufferID));
EXPECTGL(glBindBuffer(m_dataBufferID, gl_const::GLArrayBuffer));
- EXPECTGL(glBufferData(gl_const::GLArrayBuffer, vertexCount * sizeof(float), _, gl_const::GLDynamicDraw))
+ EXPECTGL(glBufferData(gl_const::GLArrayBuffer, vertexCount * sizeof(float), _,
+ gl_const::GLDynamicDraw))
.WillOnce(Invoke(&vertexCmp, &MemoryComparer::cmpSubBuffer));
// Index buffer creation
EXPECTGL(glGenBuffer()).WillOnce(Return(m_indexBufferID));
EXPECTGL(glBindBuffer(m_indexBufferID, gl_const::GLElementArrayBuffer));
- EXPECTGL(glBufferData(gl_const::GLElementArrayBuffer, indexCount * dp::IndexStorage::SizeOfIndex(), _, gl_const::GLDynamicDraw))
+ EXPECTGL(glBufferData(gl_const::GLElementArrayBuffer,
+ indexCount * dp::IndexStorage::SizeOfIndex(), _, gl_const::GLDynamicDraw))
.WillOnce(Invoke(&indexCmp, &MemoryComparer::cmpSubBuffer));
EXPECTGL(glBindBuffer(0, gl_const::GLElementArrayBuffer));
@@ -114,44 +122,44 @@ public:
}
private:
- uint32_t m_indexBufferID;
- uint32_t m_dataBufferID;
+ uint32_t m_indexBufferID = 0;
+ uint32_t m_dataBufferID = 0;
};
} // namespace
UNIT_TEST(BatchLists_Test)
{
- int const VERTEX_COUNT = 12;
- int const FLOAT_COUNT = 3 * 12; // 3 component on each vertex
- float data[FLOAT_COUNT];
- for (int i = 0; i < FLOAT_COUNT; ++i)
- data[i] = (float)i;
-
- vector<uint32_t> indexesRaw(VERTEX_COUNT);
- for (int i = 0; i < VERTEX_COUNT; ++i)
+ uint32_t const kVerticesCount = 12;
+ uint32_t const kFloatsCount = 3 * 12; // 3 component on each vertex.
+ float data[kFloatsCount];
+ for (uint32_t i = 0; i < kFloatsCount; ++i)
+ data[i] = static_cast<float>(i);
+
+ std::vector<uint32_t> indexesRaw(kVerticesCount);
+ for (uint32_t i = 0; i < kVerticesCount; ++i)
indexesRaw[i] = i;
- dp::IndexStorage indexes(move(indexesRaw));
+ dp::IndexStorage indexes(std::move(indexesRaw));
BatcherExpectations expectations;
auto fn = [](Batcher * batcher, GLState const & state, ref_ptr<AttributeProvider> p)
{
batcher->InsertTriangleList(state, p);
};
- expectations.RunTest(data, indexes.GetRaw(), VERTEX_COUNT, 3, VERTEX_COUNT, fn);
+ expectations.RunTest(data, indexes.GetRaw(), kVerticesCount, 3, kVerticesCount, fn);
}
UNIT_TEST(BatchListOfStript_4stride)
{
- int const VERTEX_COUNT = 12;
- int const INDEX_COUNT = 18;
+ uint32_t const kVerticesCount = 12;
+ uint32_t const kIndicesCount = 18;
- float data[3 * VERTEX_COUNT];
- for (int i = 0; i < VERTEX_COUNT * 3; ++i)
- data[i] = (float)i;
+ float data[3 * kVerticesCount];
+ for (uint32_t i = 0; i < kVerticesCount * 3; ++i)
+ data[i] = static_cast<float>(i);
- vector<uint32_t> indexesRaw = { 0, 1, 2, 1, 3, 2, 4, 5, 6, 5, 7, 6, 8, 9, 10, 9, 11, 10};
- dp::IndexStorage indexes(move(indexesRaw));
+ std::vector<uint32_t> indexesRaw = {0, 1, 2, 1, 3, 2, 4, 5, 6, 5, 7, 6, 8, 9, 10, 9, 11, 10};
+ dp::IndexStorage indexes(std::move(indexesRaw));
BatcherExpectations expectations;
auto fn = [](Batcher * batcher, GLState const & state, ref_ptr<AttributeProvider> p)
@@ -159,155 +167,158 @@ UNIT_TEST(BatchListOfStript_4stride)
batcher->InsertListOfStrip(state, p, dp::Batcher::VertexPerQuad);
};
- expectations.RunTest(data, indexes.GetRaw(), VERTEX_COUNT, 3, INDEX_COUNT, fn);
+ expectations.RunTest(data, indexes.GetRaw(), kVerticesCount, 3, kIndicesCount, fn);
}
UNIT_TEST(BatchListOfStript_5stride)
{
- int const VERTEX_COUNT = 15;
- int const INDEX_COUNT = 27;
-
- float data[3 * VERTEX_COUNT];
- for (int i = 0; i < VERTEX_COUNT * 3; ++i)
- data[i] = (float)i;
-
- vector<uint32_t> indexesRaw =
- { 0, 1, 2,
- 1, 3, 2,
- 2, 3, 4,
- 5, 6, 7,
- 6, 8, 7,
- 7, 8, 9,
- 10, 11, 12,
- 11, 13, 12,
- 12, 13, 14 };
- dp::IndexStorage indexes(move(indexesRaw));
+ uint32_t const kVerticesCount = 15;
+ uint32_t const kIndicesCount = 27;
+
+ float data[3 * kVerticesCount];
+ for (uint32_t i = 0; i < kVerticesCount * 3; ++i)
+ data[i] = static_cast<float>(i);
+
+ std::vector<uint32_t> indexesRaw =
+ { 0, 1, 2,
+ 1, 3, 2,
+ 2, 3, 4,
+ 5, 6, 7,
+ 6, 8, 7,
+ 7, 8, 9,
+ 10, 11, 12,
+ 11, 13, 12,
+ 12, 13, 14
+ };
+ dp::IndexStorage indexes(std::move(indexesRaw));
BatcherExpectations expectations;
auto fn = [](Batcher * batcher, GLState const & state, ref_ptr<AttributeProvider> p)
{
batcher->InsertListOfStrip(state, p, 5);
};
- expectations.RunTest(data, indexes.GetRaw(), VERTEX_COUNT, 3, INDEX_COUNT, fn);
+ expectations.RunTest(data, indexes.GetRaw(), kVerticesCount, 3, kIndicesCount, fn);
}
UNIT_TEST(BatchListOfStript_6stride)
{
- int const VERTEX_COUNT = 18;
- int const INDEX_COUNT = 36;
-
- float data[3 * VERTEX_COUNT];
- for (int i = 0; i < VERTEX_COUNT * 3; ++i)
- data[i] = (float)i;
-
- vector<uint32_t> indexesRaw =
- { 0, 1, 2,
- 1, 3, 2,
- 2, 3, 4,
- 3, 5, 4,
- 6, 7, 8,
- 7, 9, 8,
- 8, 9, 10,
- 9, 11, 10,
- 12, 13, 14,
- 13, 15, 14,
- 14, 15, 16,
- 15, 17, 16};
- dp::IndexStorage indexes(move(indexesRaw));
+ uint32_t const kVerticesCount = 18;
+ uint32_t const kIndicesCount = 36;
+
+ float data[3 * kVerticesCount];
+ for (uint32_t i = 0; i < kVerticesCount * 3; ++i)
+ data[i] = static_cast<float>(i);
+
+ std::vector<uint32_t> indexesRaw =
+ {
+ 0, 1, 2,
+ 1, 3, 2,
+ 2, 3, 4,
+ 3, 5, 4,
+ 6, 7, 8,
+ 7, 9, 8,
+ 8, 9, 10,
+ 9, 11, 10,
+ 12, 13, 14,
+ 13, 15, 14,
+ 14, 15, 16,
+ 15, 17, 16
+ };
+ dp::IndexStorage indexes(std::move(indexesRaw));
BatcherExpectations expectations;
auto fn = [](Batcher * batcher, GLState const & state, ref_ptr<AttributeProvider> p)
{
batcher->InsertListOfStrip(state, p, 6);
};
- expectations.RunTest(data, indexes.GetRaw(), VERTEX_COUNT, 3, INDEX_COUNT, fn);
+ expectations.RunTest(data, indexes.GetRaw(), kVerticesCount, 3, kIndicesCount, fn);
}
namespace
{
- class PartialBatcherTest
+class PartialBatcherTest
+{
+public:
+ struct BufferNode
{
- public:
- struct BufferNode
- {
- BufferNode(uint32_t indexByteCount, uint32_t vertexByteCount,
- void * indexData, void * vertexData)
- : m_indexByteCount(indexByteCount)
- , m_vertexByteCount(vertexByteCount)
- , m_indexData(indexData)
- , m_vertexData(vertexData)
- , m_indexBufferID(0)
- , m_vertexBufferID(0)
- {
- }
-
- uint32_t m_indexByteCount;
- uint32_t m_vertexByteCount;
- void * m_indexData;
- void * m_vertexData;
- uint32_t m_indexBufferID;
- uint32_t m_vertexBufferID;
- };
-
- PartialBatcherTest()
- : m_bufferIDCounter(1)
- {
- }
+ BufferNode(uint32_t indexByteCount, uint32_t vertexByteCount,
+ void * indexData, void * vertexData)
+ : m_indexByteCount(indexByteCount)
+ , m_vertexByteCount(vertexByteCount)
+ , m_indexData(indexData)
+ , m_vertexData(vertexData)
+ , m_indexBufferID(0)
+ , m_vertexBufferID(0)
+ {}
+
+ uint32_t m_indexByteCount;
+ uint32_t m_vertexByteCount;
+ void * m_indexData;
+ void * m_vertexData;
+ uint32_t m_indexBufferID;
+ uint32_t m_vertexBufferID;
+ };
- ~PartialBatcherTest()
- {
- for_each(m_comparators.begin(), m_comparators.end(), DeleteFunctor());
- }
+ PartialBatcherTest() = default;
- void AddBufferNode(BufferNode const & node)
- {
- m_nodes.push_back(node);
- BufferNode & currentNode = m_nodes.back();
- currentNode.m_indexBufferID = m_bufferIDCounter++;
- currentNode.m_vertexBufferID = m_bufferIDCounter++;
+ ~PartialBatcherTest()
+ {
+ std::for_each(m_comparators.begin(), m_comparators.end(), DeleteFunctor());
+ }
- // data buffer creation
- EXPECTGL(glGenBuffer()).WillOnce(Return(currentNode.m_vertexBufferID));
- EXPECTGL(glBindBuffer(currentNode.m_vertexBufferID, gl_const::GLArrayBuffer));
+ void AddBufferNode(BufferNode const & node)
+ {
+ m_nodes.push_back(node);
+ BufferNode & currentNode = m_nodes.back();
+ currentNode.m_indexBufferID = m_bufferIDCounter++;
+ currentNode.m_vertexBufferID = m_bufferIDCounter++;
- m_comparators.push_back(new MemoryComparer(currentNode.m_vertexData, currentNode.m_vertexByteCount));
- MemoryComparer * vertexComparer = m_comparators.back();
+ // data buffer creation
+ EXPECTGL(glGenBuffer()).WillOnce(Return(currentNode.m_vertexBufferID));
+ EXPECTGL(glBindBuffer(currentNode.m_vertexBufferID, gl_const::GLArrayBuffer));
- EXPECTGL(glBufferData(gl_const::GLArrayBuffer, currentNode.m_vertexByteCount, _, gl_const::GLDynamicDraw))
- .WillOnce(Invoke(vertexComparer, &MemoryComparer::cmpSubBuffer));
+ m_comparators.push_back(
+ new MemoryComparer(currentNode.m_vertexData, currentNode.m_vertexByteCount));
+ MemoryComparer * vertexComparer = m_comparators.back();
- // Index buffer creation
- EXPECTGL(glGenBuffer()).WillOnce(Return(currentNode.m_indexBufferID));
- EXPECTGL(glBindBuffer(currentNode.m_indexBufferID, gl_const::GLElementArrayBuffer));
+ EXPECTGL(glBufferData(gl_const::GLArrayBuffer, currentNode.m_vertexByteCount, _,
+ gl_const::GLDynamicDraw))
+ .WillOnce(Invoke(vertexComparer, &MemoryComparer::cmpSubBuffer));
- m_comparators.push_back(new MemoryComparer(currentNode.m_indexData, currentNode.m_indexByteCount));
- MemoryComparer * indexComparer = m_comparators.back();
+ // Index buffer creation
+ EXPECTGL(glGenBuffer()).WillOnce(Return(currentNode.m_indexBufferID));
+ EXPECTGL(glBindBuffer(currentNode.m_indexBufferID, gl_const::GLElementArrayBuffer));
- EXPECTGL(glBufferData(gl_const::GLElementArrayBuffer, currentNode.m_indexByteCount, _, gl_const::GLDynamicDraw))
- .WillOnce(Invoke(indexComparer, &MemoryComparer::cmpSubBuffer));
+ m_comparators.push_back(
+ new MemoryComparer(currentNode.m_indexData, currentNode.m_indexByteCount));
+ MemoryComparer * indexComparer = m_comparators.back();
- EXPECTGL(glBindBuffer(0, gl_const::GLElementArrayBuffer));
- EXPECTGL(glBindBuffer(0, gl_const::GLArrayBuffer));
- }
+ EXPECTGL(glBufferData(gl_const::GLElementArrayBuffer, currentNode.m_indexByteCount, _,
+ gl_const::GLDynamicDraw))
+ .WillOnce(Invoke(indexComparer, &MemoryComparer::cmpSubBuffer));
- void CloseExpection()
+ EXPECTGL(glBindBuffer(0, gl_const::GLElementArrayBuffer));
+ EXPECTGL(glBindBuffer(0, gl_const::GLArrayBuffer));
+ }
+
+ void CloseExpection()
+ {
+ for (auto const & node : m_nodes)
{
- for (size_t i = 0; i < m_nodes.size(); ++i)
- {
- EXPECTGL(glBindBuffer(0, gl_const::GLElementArrayBuffer));
- EXPECTGL(glDeleteBuffer(m_nodes[i].m_indexBufferID));
- EXPECTGL(glBindBuffer(0, gl_const::GLArrayBuffer));
- EXPECTGL(glDeleteBuffer(m_nodes[i].m_vertexBufferID));
- }
+ EXPECTGL(glBindBuffer(0, gl_const::GLElementArrayBuffer));
+ EXPECTGL(glDeleteBuffer(node.m_indexBufferID));
+ EXPECTGL(glBindBuffer(0, gl_const::GLArrayBuffer));
+ EXPECTGL(glDeleteBuffer(node.m_vertexBufferID));
}
+ }
- private:
- uint32_t m_bufferIDCounter;
+private:
+ uint32_t m_bufferIDCounter = 1;
- vector<BufferNode> m_nodes;
- vector<MemoryComparer *> m_comparators;
- };
-}
+ std::vector<BufferNode> m_nodes;
+ std::vector<MemoryComparer *> m_comparators;
+};
+} // namespace
UNIT_TEST(BatchListOfStript_partial)
{
@@ -323,18 +334,19 @@ UNIT_TEST(BatchListOfStript_partial)
float vertexData[VertexArraySize];
for (uint32_t i = 0; i < VertexArraySize; ++i)
- vertexData[i] = (float)i;
-
- vector<uint32_t> indexDataRaw =
- { 0, 1, 2,
- 1, 3, 2,
- 4, 5, 6,
- 5, 7, 6,
- 8, 9, 10,
- 9, 11, 10,
- 0, 1, 2, // start new buffer
- 1, 3, 2};
- dp::IndexStorage indexData(move(indexDataRaw));
+ vertexData[i] = static_cast<float>(i);
+
+ std::vector<uint32_t> indexDataRaw =
+ { 0, 1, 2,
+ 1, 3, 2,
+ 4, 5, 6,
+ 5, 7, 6,
+ 8, 9, 10,
+ 9, 11, 10,
+ 0, 1, 2, // start new buffer
+ 1, 3, 2
+ };
+ dp::IndexStorage indexData(std::move(indexDataRaw));
PartialBatcherTest::BufferNode node1(FirstBufferIndexPortion * dp::IndexStorage::SizeOfIndex(),
FirstBufferVertexPortion * ComponentCount * sizeof(float),
@@ -345,8 +357,8 @@ UNIT_TEST(BatchListOfStript_partial)
indexData.GetRaw(FirstBufferIndexPortion),
vertexData + FirstBufferVertexPortion * ComponentCount);
- typedef pair<uint32_t, uint32_t> IndexVertexCount;
- vector<IndexVertexCount> srcData;
+ using IndexVertexCount = std::pair<uint32_t, uint32_t>;
+ std::vector<IndexVertexCount> srcData;
srcData.push_back(make_pair(30, 12));
srcData.push_back(make_pair(30, 13));
srcData.push_back(make_pair(18, 30));
@@ -360,7 +372,8 @@ UNIT_TEST(BatchListOfStript_partial)
test.AddBufferNode(node2);
test.CloseExpection();
- GLState state(0, GLState::GeometryLayer);
+ auto renderState = make_unique_dp<TestRenderState>();
+ auto state = GLState(0, make_ref(renderState));
BindingInfo binding(1);
BindingDecl & decl = binding.GetBindingDecl(0);
@@ -375,7 +388,7 @@ UNIT_TEST(BatchListOfStript_partial)
VAOAcceptor vaoAcceptor;
Batcher batcher(srcData[i].first, srcData[i].second);
- batcher.StartSession(bind(&VAOAcceptor::FlushFullBucket, &vaoAcceptor, _1, _2));
+ batcher.StartSession(std::bind(&VAOAcceptor::FlushFullBucket, &vaoAcceptor, _1, _2));
batcher.InsertListOfStrip(state, make_ref(&provider), 4);
batcher.EndSession();
diff --git a/drape/drape_tests/img.cpp b/drape/drape_tests/img.cpp
index 34492d1129..00ba7e77dc 100644
--- a/drape/drape_tests/img.cpp
+++ b/drape/drape_tests/img.cpp
@@ -11,7 +11,7 @@ QImage CreateImage(uint32_t w, uint32_t h, uint8_t const * mem)
int byteCount = pitch * h;
unsigned char * buf = (unsigned char *)malloc(byteCount);
memset(buf, 0, byteCount);
- for (int i = 0; i < h; ++i)
+ for (uint32_t i = 0; i < h; ++i)
memcpy(buf + pitch * i, mem + w * i, w);
QImage img = QImage(buf, pitch, h, QImage::Format_Indexed8, &cleanUpQImageMemory, buf);
diff --git a/drape/glstate.cpp b/drape/glstate.cpp
index 702cbd8bd3..7abdf38662 100644
--- a/drape/glstate.cpp
+++ b/drape/glstate.cpp
@@ -2,17 +2,14 @@
#include "drape/glfunctions.hpp"
#include "base/buffer_vector.hpp"
-#include "std/bind.hpp"
namespace dp
{
-
BlendingParams::BlendingParams()
: m_blendFunction(gl_const::GLAddBlend)
, m_blendSrcFactor(gl_const::GLSrcAlfa)
, m_blendDstFactor(gl_const::GLOneMinusSrcAlfa)
-{
-}
+{}
void BlendingParams::Apply() const
{
@@ -42,17 +39,19 @@ bool Blending::operator == (Blending const & other) const
return m_isEnabled == other.m_isEnabled;
}
-GLState::GLState(int gpuProgramIndex, DepthLayer depthLayer)
- : m_gpuProgramIndex(gpuProgramIndex)
+GLState::GLState(int gpuProgramIndex, ref_ptr<BaseRenderState> renderState)
+ : m_renderState(renderState)
+ , m_gpuProgramIndex(gpuProgramIndex)
, m_gpuProgram3dIndex(gpuProgramIndex)
- , m_depthLayer(depthLayer)
, m_depthFunction(gl_const::GLLessOrEqual)
, m_textureFilter(gl_const::GLLinear)
, m_colorTexture(nullptr)
, m_maskTexture(nullptr)
, m_drawAsLine(false)
, m_lineWidth(1)
-{}
+{
+ ASSERT(m_renderState != nullptr, ());
+}
glConst GLState::GetDepthFunction() const
{
@@ -96,8 +95,8 @@ void GLState::SetLineWidth(int width)
bool GLState::operator<(GLState const & other) const
{
- if (m_depthLayer != other.m_depthLayer)
- return m_depthLayer < other.m_depthLayer;
+ if (!m_renderState->Equal(other.m_renderState))
+ return m_renderState->Less(other.m_renderState);
if (!(m_blending == other.m_blending))
return m_blending < other.m_blending;
if (m_gpuProgramIndex != other.m_gpuProgramIndex)
@@ -120,7 +119,7 @@ bool GLState::operator<(GLState const & other) const
bool GLState::operator==(GLState const & other) const
{
- return m_depthLayer == other.m_depthLayer &&
+ return m_renderState->Equal(other.m_renderState) &&
m_gpuProgramIndex == other.m_gpuProgramIndex &&
m_gpuProgram3dIndex == other.m_gpuProgram3dIndex &&
m_blending == other.m_blending &&
@@ -139,8 +138,7 @@ bool GLState::operator!=(GLState const & other) const
namespace
{
-
-struct UniformApplyer
+struct UniformApplier
{
ref_ptr<GpuProgram> m_program;
@@ -150,8 +148,7 @@ struct UniformApplyer
value.Apply(m_program);
}
};
-
-} // namespace
+} // namespace
uint8_t TextureState::m_usedSlots = 0;
@@ -189,18 +186,18 @@ uint8_t TextureState::GetLastUsedSlots()
void ApplyUniforms(UniformValuesStorage const & uniforms, ref_ptr<GpuProgram> program)
{
- static UniformApplyer applyer;
- applyer.m_program = program;
- uniforms.ForeachValue(applyer);
- applyer.m_program = nullptr;
+ static UniformApplier applier;
+ applier.m_program = program;
+ uniforms.ForeachValue(applier);
+ applier.m_program = nullptr;
}
-void ApplyBlending(GLState state)
+void ApplyBlending(GLState const & state)
{
state.GetBlending().Apply();
}
-void ApplyState(GLState state, ref_ptr<GpuProgram> program)
+void ApplyState(GLState const & state, ref_ptr<GpuProgram> program)
{
TextureState::ApplyTextures(state, program);
ApplyBlending(state);
@@ -208,5 +205,4 @@ void ApplyState(GLState state, ref_ptr<GpuProgram> program)
ASSERT_GREATER_OR_EQUAL(state.GetLineWidth(), 0, ());
GLFunctions::glLineWidth(static_cast<uint32_t>(state.GetLineWidth()));
}
-
-}
+} // namespace dp
diff --git a/drape/glstate.hpp b/drape/glstate.hpp
index a5773550b8..ed84c5490e 100644
--- a/drape/glstate.hpp
+++ b/drape/glstate.hpp
@@ -21,7 +21,7 @@ struct BlendingParams
struct Blending
{
- Blending(bool isEnabled = true);
+ explicit Blending(bool isEnabled = true);
void Apply() const;
@@ -31,25 +31,25 @@ struct Blending
bool m_isEnabled;
};
-class GLState
+class BaseRenderState
{
public:
- enum DepthLayer
- {
- /// Do not change order
- GeometryLayer,
- UserLineLayer,
- OverlayLayer,
- LocalAdsMarkLayer,
- UserMarkLayer,
- NavigationLayer,
- RoutingMarkLayer,
- Gui
- };
+ virtual ~BaseRenderState() = default;
+ virtual bool Less(ref_ptr<dp::BaseRenderState> other) const = 0;
+ virtual bool Equal(ref_ptr<dp::BaseRenderState> other) const = 0;
+};
- GLState(int gpuProgramIndex, DepthLayer depthLayer);
+class GLState
+{
+public:
+ GLState(int gpuProgramIndex, ref_ptr<BaseRenderState> renderState);
- DepthLayer const & GetDepthLayer() const { return m_depthLayer; }
+ template <typename RenderStateType>
+ ref_ptr<RenderStateType> GetRenderState() const
+ {
+ ASSERT(dynamic_cast<RenderStateType *>(m_renderState.get()) != nullptr, ());
+ return make_ref(static_cast<RenderStateType *>(m_renderState.get()));
+ }
void SetColorTexture(ref_ptr<Texture> tex) { m_colorTexture = tex; }
ref_ptr<Texture> GetColorTexture() const { return m_colorTexture; }
@@ -81,9 +81,9 @@ public:
bool operator!=(GLState const & other) const;
private:
+ ref_ptr<BaseRenderState> m_renderState;
int m_gpuProgramIndex;
int m_gpuProgram3dIndex;
- DepthLayer m_depthLayer;
Blending m_blending;
glConst m_depthFunction;
glConst m_textureFilter;
@@ -106,7 +106,6 @@ private:
};
void ApplyUniforms(UniformValuesStorage const & uniforms, ref_ptr<GpuProgram> program);
-void ApplyState(GLState state, ref_ptr<GpuProgram> program);
-void ApplyBlending(GLState state);
-
-} // namespace dp
+void ApplyState(GLState const & state, ref_ptr<GpuProgram> program);
+void ApplyBlending(GLState const & sstate);
+} // namespace dp
diff --git a/drape_frontend/CMakeLists.txt b/drape_frontend/CMakeLists.txt
index dd783d77ef..80be3ccb54 100644
--- a/drape_frontend/CMakeLists.txt
+++ b/drape_frontend/CMakeLists.txt
@@ -160,6 +160,8 @@ set(
render_group.hpp
render_node.cpp
render_node.hpp
+ render_state.cpp
+ render_state.hpp
requested_tiles.cpp
requested_tiles.hpp
route_builder.cpp
diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp
index 47ee77fa69..13b1c95244 100644
--- a/drape_frontend/apply_feature_functors.cpp
+++ b/drape_frontend/apply_feature_functors.cpp
@@ -483,7 +483,7 @@ void BaseApplyFeature::SetHotelData(HotelData && hotelData)
ApplyPointFeature::ApplyPointFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
FeatureID const & id, int minVisibleScale, uint8_t rank,
CaptionDescription const & captions, float posZ,
- int displacementMode, dp::GLState::DepthLayer depthLayer)
+ int displacementMode, RenderState::DepthLayer depthLayer)
: TBase(tileKey, insertShape, id, minVisibleScale, rank, captions)
, m_posZ(posZ)
, m_hasPoint(false)
@@ -564,7 +564,7 @@ void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng)
specialDisplacementMode = true;
specialModePriority = CalculateHotelOverlayPriority(m_hotelData);
}
- else if (m_depthLayer == dp::GLState::NavigationLayer && GetStyleReader().IsCarNavigationStyle())
+ else if (m_depthLayer == RenderState::NavigationLayer && GetStyleReader().IsCarNavigationStyle())
{
specialDisplacementMode = true;
specialModePriority = CalculateNavigationPoiPriority();
@@ -614,7 +614,7 @@ ApplyAreaFeature::ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const
bool skipAreaGeometry, float minPosZ, float posZ, int minVisibleScale,
uint8_t rank, CaptionDescription const & captions, bool hatchingArea)
: TBase(tileKey, insertShape, id, minVisibleScale, rank, captions, posZ,
- dp::displacement::kDefaultMode, dp::GLState::OverlayLayer)
+ dp::displacement::kDefaultMode, RenderState::OverlayLayer)
, m_minPosZ(minPosZ)
, m_isBuilding(isBuilding)
, m_skipAreaGeometry(skipAreaGeometry)
@@ -978,7 +978,7 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan
dp::FontDecl font = GetRoadShieldTextFont(baseFont, shield);
textParams.m_tileCenter = m_tileRect.Center();
textParams.m_depth = m_depth;
- textParams.m_depthLayer = dp::GLState::OverlayLayer;
+ textParams.m_depthLayer = RenderState::OverlayLayer;
textParams.m_minVisibleScale = kShieldMinVisibleZoomLevel;
textParams.m_rank = m_rank;
textParams.m_featureID = m_id;
@@ -1007,7 +1007,7 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan
symbolParams.m_featureID = m_id;
symbolParams.m_tileCenter = m_tileRect.Center();
symbolParams.m_depth = m_depth;
- symbolParams.m_depthLayer = dp::GLState::OverlayLayer;
+ symbolParams.m_depthLayer = RenderState::OverlayLayer;
symbolParams.m_minVisibleScale = kShieldMinVisibleZoomLevel;
symbolParams.m_rank = m_rank;
symbolParams.m_anchor = anchor;
@@ -1034,7 +1034,7 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr<dp::TextureMan
std::string symbolName = GetRoadShieldSymbolName(shield, fontScale);
poiParams.m_tileCenter = m_tileRect.Center();
poiParams.m_depth = m_depth;
- poiParams.m_depthLayer = dp::GLState::OverlayLayer;
+ poiParams.m_depthLayer = RenderState::OverlayLayer;
poiParams.m_minVisibleScale = kShieldMinVisibleZoomLevel;
poiParams.m_rank = m_rank;
poiParams.m_symbolName = symbolName;
diff --git a/drape_frontend/apply_feature_functors.hpp b/drape_frontend/apply_feature_functors.hpp
index 1cabe5a8ca..7878611e32 100644
--- a/drape_frontend/apply_feature_functors.hpp
+++ b/drape_frontend/apply_feature_functors.hpp
@@ -81,7 +81,7 @@ public:
ApplyPointFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape,
FeatureID const & id, int minVisibleScale, uint8_t rank,
CaptionDescription const & captions, float posZ,
- int displacementMode, dp::GLState::DepthLayer depthLayer);
+ int displacementMode, RenderState::DepthLayer depthLayer);
void operator()(m2::PointD const & point, bool hasArea);
void ProcessPointRule(Stylist::TRuleWrapper const & rule);
@@ -95,7 +95,7 @@ private:
bool m_hasArea;
bool m_createdByEditor;
bool m_obsoleteInEditor;
- dp::GLState::DepthLayer m_depthLayer;
+ RenderState::DepthLayer m_depthLayer;
double m_symbolDepth;
SymbolRuleProto const * m_symbolRule;
m2::PointF m_centerPoint;
diff --git a/drape_frontend/area_shape.cpp b/drape_frontend/area_shape.cpp
index 6151d251e6..578ed9f13d 100644
--- a/drape_frontend/area_shape.cpp
+++ b/drape_frontend/area_shape.cpp
@@ -1,9 +1,9 @@
#include "drape_frontend/area_shape.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/batcher.hpp"
-#include "drape/glstate.hpp"
#include "drape/texture_manager.hpp"
#include "drape/utils/vertex_decl.hpp"
@@ -58,7 +58,7 @@ void AreaShape::DrawArea(ref_ptr<dp::Batcher> batcher, m2::PointD const & colorU
m_params.m_depth), uv);
});
- dp::GLState state(gpu::AREA_PROGRAM, dp::GLState::GeometryLayer);
+ auto state = CreateGLState(gpu::AREA_PROGRAM, RenderState::GeometryLayer);
state.SetColorTexture(texture);
dp::AttributeProvider provider(1, static_cast<uint32_t>(vertexes.size()));
@@ -79,7 +79,7 @@ void AreaShape::DrawArea(ref_ptr<dp::Batcher> batcher, m2::PointD const & colorU
vertices.emplace_back(gpu::AreaVertex(glsl::vec3(pos, m_params.m_depth), ouv));
}
- dp::GLState outlineState(gpu::AREA_OUTLINE_PROGRAM, dp::GLState::GeometryLayer);
+ auto outlineState = CreateGLState(gpu::AREA_OUTLINE_PROGRAM, RenderState::GeometryLayer);
outlineState.SetColorTexture(texture);
outlineState.SetDrawAsLine(true);
@@ -112,7 +112,7 @@ void AreaShape::DrawHatchingArea(ref_ptr<dp::Batcher> batcher, m2::PointD const
vertexes[i].m_maskTexCoord.y = static_cast<float>(maxV * (m_vertexes[i].y - bbox.minY()) / bbox.SizeY());
}
- dp::GLState state(gpu::HATCHING_AREA_PROGRAM, dp::GLState::GeometryLayer);
+ auto state = CreateGLState(gpu::HATCHING_AREA_PROGRAM, RenderState::GeometryLayer);
state.SetColorTexture(texture);
state.SetMaskTexture(hatchingTexture);
state.SetTextureFilter(gl_const::GLLinear);
@@ -160,7 +160,7 @@ void AreaShape::DrawArea3D(ref_ptr<dp::Batcher> batcher, m2::PointD const & colo
vertexes.emplace_back(gpu::Area3dVertex(glsl::vec3(pt, -m_params.m_posZ), normal, uv));
}
- dp::GLState state(gpu::AREA_3D_PROGRAM, dp::GLState::GeometryLayer);
+ auto state = CreateGLState(gpu::AREA_3D_PROGRAM, RenderState::Geometry3dLayer);
state.SetColorTexture(texture);
state.SetBlending(dp::Blending(false /* isEnabled */));
@@ -173,7 +173,7 @@ void AreaShape::DrawArea3D(ref_ptr<dp::Batcher> batcher, m2::PointD const & colo
{
glsl::vec2 const ouv = glsl::ToVec2(outlineUv);
- dp::GLState outlineState(gpu::AREA_3D_OUTLINE_PROGRAM, dp::GLState::GeometryLayer);
+ auto outlineState = CreateGLState(gpu::AREA_3D_OUTLINE_PROGRAM, RenderState::Geometry3dLayer);
outlineState.SetColorTexture(texture);
outlineState.SetBlending(dp::Blending(false /* isEnabled */));
outlineState.SetDrawAsLine(true);
diff --git a/drape_frontend/arrow3d.cpp b/drape_frontend/arrow3d.cpp
index 721d136547..1741a8da6c 100644
--- a/drape_frontend/arrow3d.cpp
+++ b/drape_frontend/arrow3d.cpp
@@ -9,7 +9,6 @@
#include "drape/glfunctions.hpp"
#include "drape/glsl_func.hpp"
#include "drape/glsl_types.hpp"
-#include "drape/glstate.hpp"
#include "drape/gpu_program_manager.hpp"
#include "drape/texture_manager.hpp"
#include "drape/uniform_values_storage.hpp"
@@ -37,7 +36,7 @@ df::ColorConstant const kArrow3DColor = "Arrow3D";
df::ColorConstant const kArrow3DOutlineColor = "Arrow3DOutline";
Arrow3d::Arrow3d()
- : m_state(gpu::ARROW_3D_PROGRAM, dp::GLState::OverlayLayer)
+ : m_state(CreateGLState(gpu::ARROW_3D_PROGRAM, RenderState::OverlayLayer))
{
m_vertices = {
0.0f, 0.0f, -1.0f, 1.0f, -1.2f, -1.0f, 0.0f, 1.0f, 0.0f, 2.0f, 0.0f, 1.0f,
diff --git a/drape_frontend/arrow3d.hpp b/drape_frontend/arrow3d.hpp
index 40ef0ab128..6712b66368 100644
--- a/drape_frontend/arrow3d.hpp
+++ b/drape_frontend/arrow3d.hpp
@@ -1,6 +1,7 @@
#pragma once
-#include "drape/glstate.hpp"
+#include "drape_frontend/render_state.hpp"
+
#include "drape/pointers.hpp"
#include "geometry/rect2d.hpp"
diff --git a/drape_frontend/circles_pack_shape.cpp b/drape_frontend/circles_pack_shape.cpp
index 5f4366d030..1b73659e00 100644
--- a/drape_frontend/circles_pack_shape.cpp
+++ b/drape_frontend/circles_pack_shape.cpp
@@ -25,7 +25,7 @@ struct CirclesPackStaticVertex
dp::GLState GetCirclesPackState(ref_ptr<dp::TextureManager> texMng)
{
- dp::GLState state(gpu::CIRCLE_POINT_PROGRAM, dp::GLState::OverlayLayer);
+ auto state = CreateGLState(gpu::CIRCLE_POINT_PROGRAM, RenderState::OverlayLayer);
state.SetColorTexture(texMng->GetSymbolsTexture());
return state;
}
diff --git a/drape_frontend/circles_pack_shape.hpp b/drape_frontend/circles_pack_shape.hpp
index bc820292f0..dafdcaf877 100644
--- a/drape_frontend/circles_pack_shape.hpp
+++ b/drape_frontend/circles_pack_shape.hpp
@@ -2,8 +2,8 @@
#include "drape_frontend/map_shape.hpp"
#include "drape_frontend/shape_view_params.hpp"
+#include "drape_frontend/render_state.hpp"
-#include "drape/glstate.hpp"
#include "drape/overlay_handle.hpp"
#include "drape/pointers.hpp"
#include "drape/render_bucket.hpp"
@@ -24,7 +24,9 @@ struct CirclesPackRenderData
dp::GLState m_state;
drape_ptr<dp::RenderBucket> m_bucket;
- CirclesPackRenderData() : m_pointsCount(0), m_state(0, dp::GLState::OverlayLayer) {}
+ CirclesPackRenderData()
+ : m_pointsCount(0), m_state(CreateGLState(0, RenderState::OverlayLayer))
+ {}
};
struct CirclesPackDynamicVertex
diff --git a/drape_frontend/colored_symbol_shape.cpp b/drape_frontend/colored_symbol_shape.cpp
index 9e23d51d2e..82b2453099 100644
--- a/drape_frontend/colored_symbol_shape.cpp
+++ b/drape_frontend/colored_symbol_shape.cpp
@@ -1,4 +1,6 @@
#include "drape_frontend/colored_symbol_shape.hpp"
+
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape_frontend/visual_params.hpp"
@@ -6,7 +8,6 @@
#include "drape/batcher.hpp"
#include "drape/glsl_func.hpp"
#include "drape/glsl_types.hpp"
-#include "drape/glstate.hpp"
#include "drape/overlay_handle.hpp"
#include "drape/texture_manager.hpp"
#include "drape/utils/vertex_decl.hpp"
@@ -235,7 +236,7 @@ void ColoredSymbolShape::Draw(ref_ptr<dp::Batcher> batcher,
m_params.m_offset, GetOverlayPriority(), true /* isBound */,
debugName, true /* isBillboard */) : nullptr;
- dp::GLState state(gpu::COLORED_SYMBOL_PROGRAM, m_params.m_depthLayer);
+ auto state = CreateGLState(gpu::COLORED_SYMBOL_PROGRAM, m_params.m_depthLayer);
state.SetProgram3dIndex(gpu::COLORED_SYMBOL_BILLBOARD_PROGRAM);
state.SetColorTexture(colorRegion.GetTexture());
state.SetDepthFunction(gl_const::GLLess);
diff --git a/drape_frontend/drape_api_builder.hpp b/drape_frontend/drape_api_builder.hpp
index 18afa4f6b9..891862afab 100644
--- a/drape_frontend/drape_api_builder.hpp
+++ b/drape_frontend/drape_api_builder.hpp
@@ -1,8 +1,8 @@
#pragma once
#include "drape_frontend/drape_api.hpp"
+#include "drape_frontend/render_state.hpp"
-#include "drape/glstate.hpp"
#include "drape/render_bucket.hpp"
#include "drape/texture_manager.hpp"
diff --git a/drape_frontend/drape_frontend.pro b/drape_frontend/drape_frontend.pro
index f463bb3a8a..0c5607ec60 100755
--- a/drape_frontend/drape_frontend.pro
+++ b/drape_frontend/drape_frontend.pro
@@ -79,6 +79,7 @@ SOURCES += \
read_mwm_task.cpp \
render_group.cpp \
render_node.cpp \
+ render_state.cpp \
requested_tiles.cpp \
route_builder.cpp \
route_renderer.cpp \
@@ -191,6 +192,7 @@ HEADERS += \
read_mwm_task.hpp \
render_group.hpp \
render_node.hpp \
+ render_state.hpp \
requested_tiles.hpp \
route_builder.hpp \
route_renderer.hpp \
diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp
index 2b17e71d28..a7046391d4 100755
--- a/drape_frontend/frontend_renderer.cpp
+++ b/drape_frontend/frontend_renderer.cpp
@@ -943,9 +943,7 @@ void FrontendRenderer::AddToRenderGroup(dp::GLState const & state,
drape_ptr<dp::RenderBucket> && renderBucket,
TileKey const & newTile)
{
- RenderLayer::RenderLayerID id = RenderLayer::GetLayerID(state);
- RenderLayer & layer = m_layers[id];
-
+ RenderLayer & layer = m_layers[GetDepthLayer(state)];
for (auto const & g : layer.m_renderGroups)
{
if (!g->IsPendingOnDelete() && g->GetState() == state && g->GetTileKey().EqualStrict(newTile))
@@ -1124,7 +1122,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
GLFunctions::glClear(gl_const::GLColorBit | gl_const::GLDepthBit | gl_const::GLStencilBit);
Render2dLayer(modelView);
- RenderUserMarksLayer(modelView, RenderLayer::UserLineID);
+ RenderUserMarksLayer(modelView, RenderState::UserLineLayer);
if (m_buildingsFramebuffer->IsSupported())
{
@@ -1160,7 +1158,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
{
StencilWriterGuard guard(make_ref(m_postprocessRenderer));
RenderOverlayLayer(modelView);
- RenderUserMarksLayer(modelView, RenderLayer::LocalAdsMarkID);
+ RenderUserMarksLayer(modelView, RenderState::LocalAdsMarkLayer);
}
m_gpsTrackRenderer->RenderTrack(modelView, m_currentZoomLevel, make_ref(m_gpuProgramManager),
@@ -1175,8 +1173,8 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
{
StencilWriterGuard guard(make_ref(m_postprocessRenderer));
- RenderUserMarksLayer(modelView, RenderLayer::UserMarkID);
- RenderUserMarksLayer(modelView, RenderLayer::RoutingMarkID);
+ RenderUserMarksLayer(modelView, RenderState::UserMarkLayer);
+ RenderUserMarksLayer(modelView, RenderState::RoutingMarkLayer);
}
m_myPositionController->Render(modelView, m_currentZoomLevel, make_ref(m_gpuProgramManager),
@@ -1205,7 +1203,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
void FrontendRenderer::Render2dLayer(ScreenBase const & modelView)
{
- RenderLayer & layer2d = m_layers[RenderLayer::Geometry2dID];
+ RenderLayer & layer2d = m_layers[RenderState::GeometryLayer];
layer2d.Sort(make_ref(m_overlayTree));
for (drape_ptr<RenderGroup> const & group : layer2d.m_renderGroups)
@@ -1214,7 +1212,7 @@ void FrontendRenderer::Render2dLayer(ScreenBase const & modelView)
void FrontendRenderer::Render3dLayer(ScreenBase const & modelView, bool useFramebuffer)
{
- RenderLayer & layer = m_layers[RenderLayer::Geometry3dID];
+ RenderLayer & layer = m_layers[RenderState::Geometry3dLayer];
if (layer.m_renderGroups.empty())
return;
@@ -1248,7 +1246,7 @@ void FrontendRenderer::Render3dLayer(ScreenBase const & modelView, bool useFrame
void FrontendRenderer::RenderOverlayLayer(ScreenBase const & modelView)
{
- RenderLayer & overlay = m_layers[RenderLayer::OverlayID];
+ RenderLayer & overlay = m_layers[RenderState::OverlayLayer];
BuildOverlayTree(modelView);
for (drape_ptr<RenderGroup> & group : overlay.m_renderGroups)
RenderSingleGroup(modelView, make_ref(group));
@@ -1259,7 +1257,7 @@ void FrontendRenderer::RenderOverlayLayer(ScreenBase const & modelView)
void FrontendRenderer::RenderNavigationOverlayLayer(ScreenBase const & modelView)
{
- RenderLayer & navOverlayLayer = m_layers[RenderLayer::NavigationID];
+ RenderLayer & navOverlayLayer = m_layers[RenderState::NavigationLayer];
for (auto & group : navOverlayLayer.m_renderGroups)
{
if (group->HasOverlayHandles())
@@ -1281,7 +1279,7 @@ void FrontendRenderer::RenderTrafficAndRouteLayer(ScreenBase const & modelView)
make_ref(m_gpuProgramManager), m_generalUniforms);
}
-void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView, RenderLayer::RenderLayerID layerId)
+void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView, RenderState::DepthLayer layerId)
{
auto & renderGroups = m_layers[layerId].m_renderGroups;
if (renderGroups.empty())
@@ -1294,24 +1292,12 @@ void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView, Render
GLFunctions::glDisable(gl_const::GLDepthTest);
}
-void FrontendRenderer::RenderUserLinesLayer(ScreenBase const & modelView)
-{
- auto & renderGroups = m_layers[RenderLayer::UserLineID].m_renderGroups;
- if (renderGroups.empty())
- return;
-
- GLFunctions::glClear(gl_const::GLDepthBit);
- GLFunctions::glEnable(gl_const::GLDepthTest);
- for (drape_ptr<RenderGroup> & group : renderGroups)
- RenderSingleGroup(modelView, make_ref(group));
-}
-
void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView)
{
- static std::vector<RenderLayer::RenderLayerID> layers = {RenderLayer::OverlayID,
- RenderLayer::LocalAdsMarkID,
- RenderLayer::NavigationID,
- RenderLayer::RoutingMarkID};
+ static std::vector<RenderState::DepthLayer> layers = {RenderState::OverlayLayer,
+ RenderState::LocalAdsMarkLayer,
+ RenderState::NavigationLayer,
+ RenderState::RoutingMarkLayer};
BeginUpdateOverlayTree(modelView);
for (auto const & layerId : layers)
{
@@ -1363,8 +1349,10 @@ void FrontendRenderer::MergeBuckets()
ref_ptr<RenderGroup> group = make_ref(layer.m_renderGroups[i]);
if (!group->IsPendingOnDelete())
{
- dp::GLState state = group->GetState();
- ASSERT_EQUAL(state.GetDepthLayer(), dp::GLState::GeometryLayer, ());
+ dp::GLState const state = group->GetState();
+ auto const depthLayer = GetDepthLayer(state);
+ if (depthLayer != RenderState::GeometryLayer && depthLayer != RenderState::Geometry3dLayer)
+ ASSERT(false, ("Invalid depth layer for merging buckets"));
MergedGroupKey const k(state, group->GetTileKey());
forMerge[k].push_back(std::move(layer.m_renderGroups[i]));
}
@@ -1387,8 +1375,8 @@ void FrontendRenderer::MergeBuckets()
};
bool const isPerspective = m_userEventStream.GetCurrentScreen().isPerspective();
- mergeFn(m_layers[RenderLayer::Geometry2dID], isPerspective);
- mergeFn(m_layers[RenderLayer::Geometry3dID], isPerspective);
+ mergeFn(m_layers[RenderState::GeometryLayer], isPerspective);
+ mergeFn(m_layers[RenderState::Geometry3dLayer], isPerspective);
}
void FrontendRenderer::RenderSingleGroup(ScreenBase const & modelView, ref_ptr<BaseRenderGroup> group)
@@ -2057,26 +2045,6 @@ void FrontendRenderer::CheckAndRunFirstLaunchAnimation()
AddUserEvent(make_unique_dp<SetCenterEvent>(pos, kDesiredZoomLevel, true /* isAnim */));
}
-FrontendRenderer::RenderLayer::RenderLayerID FrontendRenderer::RenderLayer::GetLayerID(dp::GLState const & state)
-{
- switch (state.GetDepthLayer())
- {
- case dp::GLState::OverlayLayer: return OverlayID;
- case dp::GLState::UserMarkLayer: return UserMarkID;
- case dp::GLState::UserLineLayer: return UserLineID;
- case dp::GLState::RoutingMarkLayer: return RoutingMarkID;
- case dp::GLState::NavigationLayer: return NavigationID;
- case dp::GLState::LocalAdsMarkLayer: return LocalAdsMarkID;
- default: break;
- }
-
- if (state.GetProgram3dIndex() == gpu::AREA_3D_PROGRAM ||
- state.GetProgram3dIndex() == gpu::AREA_3D_OUTLINE_PROGRAM)
- return Geometry3dID;
-
- return Geometry2dID;
-}
-
void FrontendRenderer::RenderLayer::Sort(ref_ptr<dp::OverlayTree> overlayTree)
{
if (!m_isDirty)
diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp
index 20bc9f2319..fa4ecc8d52 100755
--- a/drape_frontend/frontend_renderer.hpp
+++ b/drape_frontend/frontend_renderer.hpp
@@ -12,6 +12,7 @@
#include "drape_frontend/navigator.hpp"
#include "drape_frontend/overlays_tracker.hpp"
#include "drape_frontend/render_group.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/requested_tiles.hpp"
#include "drape_frontend/route_renderer.hpp"
#include "drape_frontend/postprocess_renderer.hpp"
@@ -20,7 +21,6 @@
#include "drape_frontend/traffic_renderer.hpp"
#include "drape_frontend/user_event_stream.hpp"
-#include "drape/glstate.hpp"
#include "drape/gpu_program_manager.hpp"
#include "drape/overlay_tree.hpp"
#include "drape/pointers.hpp"
@@ -151,21 +151,6 @@ private:
struct RenderLayer
{
- enum RenderLayerID
- {
- Geometry2dID,
- UserLineID,
- OverlayID,
- LocalAdsMarkID,
- Geometry3dID,
- UserMarkID,
- NavigationID,
- RoutingMarkID,
- LayerCountID
- };
-
- static RenderLayerID GetLayerID(dp::GLState const & renderGroup);
-
std::vector<drape_ptr<RenderGroup>> m_renderGroups;
bool m_isDirty = false;
@@ -176,8 +161,7 @@ private:
void Render3dLayer(ScreenBase const & modelView, bool useFramebuffer);
void RenderOverlayLayer(ScreenBase const & modelView);
void RenderNavigationOverlayLayer(ScreenBase const & modelView);
- void RenderUserMarksLayer(ScreenBase const & modelView, RenderLayer::RenderLayerID layerId);
- void RenderUserLinesLayer(ScreenBase const & modelView);
+ void RenderUserMarksLayer(ScreenBase const & modelView, RenderState::DepthLayer layerId);
void RenderTrafficAndRouteLayer(ScreenBase const & modelView);
ScreenBase const & ProcessEvents(bool & modelViewChanged, bool & viewportChanged);
@@ -261,7 +245,7 @@ private:
drape_ptr<dp::GpuProgramManager> m_gpuProgramManager;
- std::array<RenderLayer, RenderLayer::LayerCountID> m_layers;
+ std::array<RenderLayer, RenderState::LayersCount> m_layers;
drape_ptr<gui::LayerRenderer> m_guiRenderer;
drape_ptr<MyPositionController> m_myPositionController;
diff --git a/drape_frontend/gui/choose_position_mark.cpp b/drape_frontend/gui/choose_position_mark.cpp
index ea638cf618..1a5cd2b2d3 100644
--- a/drape_frontend/gui/choose_position_mark.cpp
+++ b/drape_frontend/gui/choose_position_mark.cpp
@@ -59,7 +59,7 @@ drape_ptr<ShapeRenderer> ChoosePositionMark::Draw(ref_ptr<dp::TextureManager> te
ChoosePositionMarkVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))
};
- dp::GLState state(gpu::TEXTURING_GUI_PROGRAM, dp::GLState::Gui);
+ auto state = df::CreateGLState(gpu::TEXTURING_GUI_PROGRAM, df::RenderState::GuiLayer);
state.SetColorTexture(region.GetTexture());
dp::AttributeProvider provider(1 /*streamCount*/, 4 /*vertexCount*/);
diff --git a/drape_frontend/gui/compass.cpp b/drape_frontend/gui/compass.cpp
index ee38cadef7..3f0efdb133 100644
--- a/drape_frontend/gui/compass.cpp
+++ b/drape_frontend/gui/compass.cpp
@@ -104,7 +104,7 @@ drape_ptr<ShapeRenderer> Compass::Draw(m2::PointF & compassSize, ref_ptr<dp::Tex
CompassVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom()))
};
- dp::GLState state(gpu::TEXTURING_GUI_PROGRAM, dp::GLState::Gui);
+ auto state = df::CreateGLState(gpu::TEXTURING_GUI_PROGRAM, df::RenderState::GuiLayer);
state.SetColorTexture(region.GetTexture());
dp::AttributeProvider provider(1, 4);
diff --git a/drape_frontend/gui/gui_text.cpp b/drape_frontend/gui/gui_text.cpp
index 07bce179aa..e64a0fb79d 100644
--- a/drape_frontend/gui/gui_text.cpp
+++ b/drape_frontend/gui/gui_text.cpp
@@ -105,7 +105,9 @@ dp::BindingInfo const & StaticLabel::Vertex::GetBindingInfo()
return *info.get();
}
-StaticLabel::LabelResult::LabelResult() : m_state(gpu::TEXT_OUTLINED_GUI_PROGRAM, dp::GLState::Gui) {}
+StaticLabel::LabelResult::LabelResult()
+ : m_state(df::CreateGLState(gpu::TEXT_OUTLINED_GUI_PROGRAM, df::RenderState::GuiLayer))
+{}
char const * StaticLabel::DefaultDelim = "\n";
@@ -281,7 +283,9 @@ dp::BindingInfo const & MutableLabel::DynamicVertex::GetBindingInfo()
return *info.get();
}
-MutableLabel::PrecacheResult::PrecacheResult() : m_state(gpu::TEXT_OUTLINED_GUI_PROGRAM, dp::GLState::Gui) {}
+MutableLabel::PrecacheResult::PrecacheResult()
+ : m_state(df::CreateGLState(gpu::TEXT_OUTLINED_GUI_PROGRAM, df::RenderState::GuiLayer))
+{}
MutableLabel::MutableLabel(dp::Anchor anchor)
: m_anchor(anchor)
diff --git a/drape_frontend/gui/gui_text.hpp b/drape_frontend/gui/gui_text.hpp
index 9c32977f4c..1d1e20c330 100644
--- a/drape_frontend/gui/gui_text.hpp
+++ b/drape_frontend/gui/gui_text.hpp
@@ -1,11 +1,11 @@
#pragma once
-#include "shape.hpp"
+#include "drape_frontend/gui/shape.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape/binding_info.hpp"
#include "drape/drape_global.hpp"
#include "drape/glsl_types.hpp"
-#include "drape/glstate.hpp"
#include "drape/texture_manager.hpp"
#include "std/cstdint.hpp"
diff --git a/drape_frontend/gui/ruler.cpp b/drape_frontend/gui/ruler.cpp
index a475b094ef..0127d7bc9f 100644
--- a/drape_frontend/gui/ruler.cpp
+++ b/drape_frontend/gui/ruler.cpp
@@ -214,7 +214,7 @@ void Ruler::DrawRuler(m2::PointF & size, ShapeControl & control, ref_ptr<dp::Tex
data.push_back(RulerVertex(glsl::vec2(0.0, h), normals[1], texCoord));
data.push_back(RulerVertex(glsl::vec2(0.0, -h), normals[1], texCoord));
- dp::GLState state(gpu::RULER_PROGRAM, dp::GLState::Gui);
+ auto state = df::CreateGLState(gpu::RULER_PROGRAM, df::RenderState::GuiLayer);
state.SetColorTexture(reg.GetTexture());
dp::AttributeProvider provider(1, 4);
diff --git a/drape_frontend/gui/shape.hpp b/drape_frontend/gui/shape.hpp
index 9b0584db8a..e7ad5b38c3 100644
--- a/drape_frontend/gui/shape.hpp
+++ b/drape_frontend/gui/shape.hpp
@@ -1,10 +1,10 @@
#pragma once
-#include "skin.hpp"
+#include "drape_frontend/gui/skin.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape/batcher.hpp"
#include "drape/glsl_types.hpp"
-#include "drape/glstate.hpp"
#include "drape/gpu_program_manager.hpp"
#include "drape/overlay_handle.hpp"
#include "drape/texture_manager.hpp"
@@ -61,7 +61,7 @@ struct ShapeControl
struct ShapeInfo
{
- ShapeInfo() : m_state(0, dp::GLState::Gui) {}
+ ShapeInfo() : m_state(df::CreateGLState(0, df::RenderState::GuiLayer)) {}
ShapeInfo(dp::GLState const & state, drape_ptr<dp::VertexArrayBuffer> && buffer,
drape_ptr<Handle> && handle);
diff --git a/drape_frontend/line_shape.cpp b/drape_frontend/line_shape.cpp
index af25cf591a..657ff5b3b3 100644
--- a/drape_frontend/line_shape.cpp
+++ b/drape_frontend/line_shape.cpp
@@ -60,7 +60,7 @@ struct BaseBuilderParams
dp::TextureManager::ColorRegion m_color;
float m_pxHalfWidth;
float m_depth;
- dp::GLState::DepthLayer m_depthLayer;
+ RenderState::DepthLayer m_depthLayer;
dp::LineCap m_cap;
dp::LineJoin m_join;
};
@@ -179,7 +179,7 @@ public:
dp::GLState GetState() override
{
- dp::GLState state(gpu::LINE_PROGRAM, m_params.m_depthLayer);
+ auto state = CreateGLState(gpu::LINE_PROGRAM, m_params.m_depthLayer);
state.SetColorTexture(m_params.m_color.GetTexture());
return state;
}
@@ -208,7 +208,7 @@ public:
if (m_params.m_cap == dp::ButtCap)
return TBase::GetCapState();
- dp::GLState state(gpu::CAP_JOIN_PROGRAM, m_params.m_depthLayer);
+ auto state = CreateGLState(gpu::CAP_JOIN_PROGRAM, m_params.m_depthLayer);
state.SetColorTexture(m_params.m_color.GetTexture());
state.SetDepthFunction(gl_const::GLLess);
return state;
@@ -279,7 +279,7 @@ public:
dp::GLState GetState() override
{
- dp::GLState state(gpu::AREA_OUTLINE_PROGRAM, m_params.m_depthLayer);
+ auto state = CreateGLState(gpu::AREA_OUTLINE_PROGRAM, m_params.m_depthLayer);
state.SetColorTexture(m_params.m_color.GetTexture());
state.SetDrawAsLine(true);
state.SetLineWidth(m_lineWidth);
@@ -322,7 +322,7 @@ public:
dp::GLState GetState() override
{
- dp::GLState state(gpu::DASHED_LINE_PROGRAM, m_params.m_depthLayer);
+ auto state = CreateGLState(gpu::DASHED_LINE_PROGRAM, m_params.m_depthLayer);
state.SetColorTexture(m_params.m_color.GetTexture());
state.SetMaskTexture(m_texCoordGen.GetRegion().GetTexture());
return state;
diff --git a/drape_frontend/line_shape.hpp b/drape_frontend/line_shape.hpp
index a4e707dda6..f6ae996d21 100644
--- a/drape_frontend/line_shape.hpp
+++ b/drape_frontend/line_shape.hpp
@@ -1,10 +1,10 @@
#pragma once
#include "drape_frontend/map_shape.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shape_view_params.hpp"
#include "drape/binding_info.hpp"
-#include "drape/glstate.hpp"
#include "geometry/spline.hpp"
diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp
index d1d8bbcd3d..ecf80042b7 100644
--- a/drape_frontend/message_subclasses.hpp
+++ b/drape_frontend/message_subclasses.hpp
@@ -11,6 +11,7 @@
#include "drape_frontend/my_position.hpp"
#include "drape_frontend/overlay_batcher.hpp"
#include "drape_frontend/postprocess_renderer.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/route_builder.hpp"
#include "drape_frontend/selection_shape.hpp"
#include "drape_frontend/tile_utils.hpp"
@@ -18,7 +19,6 @@
#include "drape_frontend/user_mark_shapes.hpp"
#include "drape_frontend/user_marks_provider.hpp"
-#include "drape/glstate.hpp"
#include "drape/pointers.hpp"
#include "drape/render_bucket.hpp"
#include "drape/viewport.hpp"
diff --git a/drape_frontend/my_position.cpp b/drape_frontend/my_position.cpp
index eaf756ad5a..0f298322be 100644
--- a/drape_frontend/my_position.cpp
+++ b/drape_frontend/my_position.cpp
@@ -164,7 +164,7 @@ void MyPosition::CacheAccuracySector(ref_ptr<dp::TextureManager> mng)
buffer.emplace_back(nextNormal, colorCoord);
}
- dp::GLState state(gpu::ACCURACY_PROGRAM, dp::GLState::OverlayLayer);
+ auto state = CreateGLState(gpu::ACCURACY_PROGRAM, RenderState::OverlayLayer);
state.SetColorTexture(color.GetTexture());
{
@@ -215,7 +215,7 @@ void MyPosition::CachePointPosition(ref_ptr<dp::TextureManager> mng)
m_arrow3d.SetTexture(mng);
- dp::GLState state(gpu::MY_POSITION_PROGRAM, dp::GLState::OverlayLayer);
+ auto state = CreateGLState(gpu::MY_POSITION_PROGRAM, RenderState::OverlayLayer);
state.SetColorTexture(pointSymbol.GetTexture());
dp::TextureManager::SymbolRegion * symbols[kSymbolsCount] = { &pointSymbol };
diff --git a/drape_frontend/my_position.hpp b/drape_frontend/my_position.hpp
index 8310f01955..0a89cd410c 100644
--- a/drape_frontend/my_position.hpp
+++ b/drape_frontend/my_position.hpp
@@ -1,10 +1,10 @@
#pragma once
-#include "arrow3d.hpp"
-#include "render_node.hpp"
+#include "drape_frontend/arrow3d.hpp"
+#include "drape_frontend/render_node.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape/vertex_array_buffer.hpp"
-#include "drape/glstate.hpp"
#include "drape/gpu_program_manager.hpp"
#include "drape/texture_manager.hpp"
#include "drape/uniform_values_storage.hpp"
diff --git a/drape_frontend/overlay_batcher.hpp b/drape_frontend/overlay_batcher.hpp
index d1b5c9e549..45c1733ed8 100644
--- a/drape_frontend/overlay_batcher.hpp
+++ b/drape_frontend/overlay_batcher.hpp
@@ -1,11 +1,11 @@
#pragma once
+#include "drape_frontend/render_state.hpp"
+#include "drape_frontend/tile_key.hpp"
+
#include "drape/batcher.hpp"
-#include "drape/glstate.hpp"
#include "drape/pointers.hpp"
-#include "drape_frontend/tile_key.hpp"
-
#include "std/vector.hpp"
namespace dp
diff --git a/drape_frontend/path_symbol_shape.cpp b/drape_frontend/path_symbol_shape.cpp
index cb4231c740..307f9efc2d 100644
--- a/drape_frontend/path_symbol_shape.cpp
+++ b/drape_frontend/path_symbol_shape.cpp
@@ -1,4 +1,5 @@
#include "drape_frontend/path_symbol_shape.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape_frontend/visual_params.hpp"
@@ -8,7 +9,6 @@
#include "drape/overlay_handle.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/texture_manager.hpp"
-#include "drape/glstate.hpp"
#include "drape/batcher.hpp"
namespace df
@@ -54,7 +54,7 @@ void PathSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureMana
if (buffer.empty())
return;
- dp::GLState state(gpu::PATH_SYMBOL_LINE, dp::GLState::GeometryLayer);
+ auto state = CreateGLState(gpu::PATH_SYMBOL_LINE, RenderState::GeometryLayer);
state.SetColorTexture(region.GetTexture());
dp::AttributeProvider provider(1, static_cast<uint32_t>(buffer.size()));
diff --git a/drape_frontend/path_text_shape.cpp b/drape_frontend/path_text_shape.cpp
index 4c6c676c3a..fb1b79b6f8 100644
--- a/drape_frontend/path_text_shape.cpp
+++ b/drape_frontend/path_text_shape.cpp
@@ -1,10 +1,10 @@
#include "drape_frontend/path_text_shape.hpp"
#include "drape_frontend/path_text_handle.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/batcher.hpp"
-#include "drape/glstate.hpp"
#include "drape/overlay_handle.hpp"
#include "base/math.hpp"
@@ -81,9 +81,8 @@ void PathTextShape::DrawPathTextPlain(ref_ptr<dp::TextureManager> textures,
dp::TextureManager::ColorRegion color;
textures->GetColorRegion(m_params.m_textFont.m_color, color);
-
- dp::GLState state(layout->GetFixedHeight() > 0 ? gpu::TEXT_FIXED_PROGRAM : gpu::TEXT_PROGRAM,
- dp::GLState::OverlayLayer);
+ auto state = CreateGLState(layout->GetFixedHeight() > 0 ? gpu::TEXT_FIXED_PROGRAM : gpu::TEXT_PROGRAM,
+ RenderState::OverlayLayer);
state.SetProgram3dIndex(layout->GetFixedHeight() > 0 ? gpu::TEXT_FIXED_BILLBOARD_PROGRAM :
gpu::TEXT_BILLBOARD_PROGRAM);
state.SetColorTexture(color.GetTexture());
@@ -122,7 +121,7 @@ void PathTextShape::DrawPathTextOutlined(ref_ptr<dp::TextureManager> textures,
textures->GetColorRegion(m_params.m_textFont.m_color, color);
textures->GetColorRegion(m_params.m_textFont.m_outlineColor, outline);
- dp::GLState state(gpu::TEXT_OUTLINED_PROGRAM, dp::GLState::OverlayLayer);
+ auto state = CreateGLState(gpu::TEXT_OUTLINED_PROGRAM, RenderState::OverlayLayer);
state.SetProgram3dIndex(gpu::TEXT_OUTLINED_BILLBOARD_PROGRAM);
state.SetColorTexture(color.GetTexture());
state.SetMaskTexture(layout->GetMaskTexture());
diff --git a/drape_frontend/poi_symbol_shape.cpp b/drape_frontend/poi_symbol_shape.cpp
index 9fcf914501..792babdf29 100644
--- a/drape_frontend/poi_symbol_shape.cpp
+++ b/drape_frontend/poi_symbol_shape.cpp
@@ -66,7 +66,7 @@ void Batch<SV>(ref_ptr<dp::Batcher> batcher, drape_ptr<dp::OverlayHandle> && han
glsl::vec2(texRect.maxX(), texRect.minY()) },
};
- dp::GLState state(gpu::TEXTURING_PROGRAM, params.m_depthLayer);
+ auto state = df::CreateGLState(gpu::TEXTURING_PROGRAM, params.m_depthLayer);
state.SetProgram3dIndex(gpu::TEXTURING_BILLBOARD_PROGRAM);
state.SetColorTexture(symbolRegion.GetTexture());
state.SetTextureFilter(gl_const::GLNearest);
@@ -99,7 +99,7 @@ void Batch<MV>(ref_ptr<dp::Batcher> batcher, drape_ptr<dp::OverlayHandle> && han
glsl::vec2(texRect.maxX(), texRect.minY()), maskColorCoords },
};
- dp::GLState state(gpu::MASKED_TEXTURING_PROGRAM, params.m_depthLayer);
+ auto state = df::CreateGLState(gpu::MASKED_TEXTURING_PROGRAM, params.m_depthLayer);
state.SetProgram3dIndex(gpu::MASKED_TEXTURING_BILLBOARD_PROGRAM);
state.SetColorTexture(symbolRegion.GetTexture());
state.SetMaskTexture(colorRegion.GetTexture()); // Here mask is a color.
diff --git a/drape_frontend/postprocess_renderer.cpp b/drape_frontend/postprocess_renderer.cpp
index 4d66a1b972..2f10edf406 100644
--- a/drape_frontend/postprocess_renderer.cpp
+++ b/drape_frontend/postprocess_renderer.cpp
@@ -1,9 +1,9 @@
#include "drape_frontend/postprocess_renderer.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/screen_quad_renderer.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape/glfunctions.hpp"
-#include "drape/glstate.hpp"
#include "drape/gpu_program_manager.hpp"
#include "drape/texture_manager.hpp"
#include "drape/uniform_values_storage.hpp"
diff --git a/drape_frontend/render_group.cpp b/drape_frontend/render_group.cpp
index 8285aa696a..78ecbef798 100755
--- a/drape_frontend/render_group.cpp
+++ b/drape_frontend/render_group.cpp
@@ -154,16 +154,18 @@ void RenderGroup::AddBucket(drape_ptr<dp::RenderBucket> && bucket)
bool RenderGroup::IsOverlay() const
{
- return (m_state.GetDepthLayer() == dp::GLState::OverlayLayer) ||
- (m_state.GetDepthLayer() == dp::GLState::NavigationLayer && HasOverlayHandles());
+ auto const depthLayer = GetDepthLayer(m_state);
+ return (depthLayer == RenderState::OverlayLayer) ||
+ (depthLayer == RenderState::NavigationLayer && HasOverlayHandles());
}
bool RenderGroup::IsUserMark() const
{
- return m_state.GetDepthLayer() == dp::GLState::UserLineLayer ||
- m_state.GetDepthLayer() == dp::GLState::UserMarkLayer ||
- m_state.GetDepthLayer() == dp::GLState::RoutingMarkLayer ||
- m_state.GetDepthLayer() == dp::GLState::LocalAdsMarkLayer;
+ auto const depthLayer = GetDepthLayer(m_state);
+ return depthLayer == RenderState::UserLineLayer ||
+ depthLayer == RenderState::UserMarkLayer ||
+ depthLayer == RenderState::RoutingMarkLayer ||
+ depthLayer == RenderState::LocalAdsMarkLayer;
}
bool RenderGroup::UpdateCanBeDeletedStatus(bool canBeDeleted, int currentZoom, ref_ptr<dp::OverlayTree> tree)
@@ -197,10 +199,10 @@ bool RenderGroupComparator::operator()(drape_ptr<RenderGroup> const & l, drape_p
if (rCanBeDeleted == lCanBeDeleted)
{
- dp::GLState const & lState = l->GetState();
- dp::GLState const & rState = r->GetState();
- dp::GLState::DepthLayer lDepth = lState.GetDepthLayer();
- dp::GLState::DepthLayer rDepth = rState.GetDepthLayer();
+ auto const & lState = l->GetState();
+ auto const & rState = r->GetState();
+ auto const lDepth = GetDepthLayer(lState);
+ auto const rDepth = GetDepthLayer(rState);
if (lDepth != rDepth)
return lDepth < rDepth;
@@ -222,17 +224,13 @@ UserMarkRenderGroup::UserMarkRenderGroup(dp::GLState const & state, TileKey cons
}
}
-UserMarkRenderGroup::~UserMarkRenderGroup()
-{
-}
-
void UserMarkRenderGroup::UpdateAnimation()
{
BaseRenderGroup::UpdateAnimation();
float interplationT = 1.0f;
if (m_animation)
{
- float const t = static_cast<float>(m_animation->GetOpacity());
+ auto const t = static_cast<float>(m_animation->GetOpacity());
interplationT = m_mapping.GetValue(t);
}
m_uniforms.SetFloatValue("u_interpolationT", interplationT);
diff --git a/drape_frontend/render_group.hpp b/drape_frontend/render_group.hpp
index dcad688922..4b15798df6 100755
--- a/drape_frontend/render_group.hpp
+++ b/drape_frontend/render_group.hpp
@@ -2,9 +2,9 @@
#include "drape_frontend/animation/opacity_animation.hpp"
#include "drape_frontend/animation/value_mapping.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/tile_utils.hpp"
-#include "drape/glstate.hpp"
#include "drape/pointers.hpp"
#include "drape/render_bucket.hpp"
@@ -98,7 +98,7 @@ class UserMarkRenderGroup : public RenderGroup
public:
UserMarkRenderGroup(dp::GLState const & state, TileKey const & tileKey);
- ~UserMarkRenderGroup() override;
+ ~UserMarkRenderGroup() override {}
void UpdateAnimation() override;
diff --git a/drape_frontend/render_node.cpp b/drape_frontend/render_node.cpp
index 3792708e85..cebf0ff10a 100644
--- a/drape_frontend/render_node.cpp
+++ b/drape_frontend/render_node.cpp
@@ -5,13 +5,11 @@
namespace df
{
-
RenderNode::RenderNode(dp::GLState const & state, drape_ptr<dp::VertexArrayBuffer> && buffer)
: m_state(state)
, m_buffer(move(buffer))
, m_isBuilded(false)
-{
-}
+{}
void RenderNode::Render(ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStorage const & uniforms,
dp::IndicesRange const & range)
@@ -39,5 +37,4 @@ void RenderNode::Apply(ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStor
dp::ApplyState(m_state, prg);
dp::ApplyUniforms(uniforms, prg);
}
-
-}
+} // namespace df
diff --git a/drape_frontend/render_node.hpp b/drape_frontend/render_node.hpp
index 02e03a9ace..2405b29bef 100644
--- a/drape_frontend/render_node.hpp
+++ b/drape_frontend/render_node.hpp
@@ -1,33 +1,32 @@
#pragma once
-#include "drape/glstate.hpp"
+#include "drape_frontend/render_state.hpp"
+
#include "drape/pointers.hpp"
namespace dp
{
- class VertexArrayBuffer;
- class GpuProgramManager;
- struct IndicesRange;
-}
+class VertexArrayBuffer;
+class GpuProgramManager;
+struct IndicesRange;
+} // namespace dp
namespace df
{
-
class RenderNode
{
public:
RenderNode(dp::GLState const & state, drape_ptr<dp::VertexArrayBuffer> && buffer);
void Render(ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStorage const & uniforms);
- void Render(ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStorage const & uniforms, dp::IndicesRange const & range);
+ void Render(ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStorage const & uniforms,
+ dp::IndicesRange const & range);
private:
void Apply(ref_ptr<dp::GpuProgramManager> mng, dp::UniformValuesStorage const & uniforms);
-private:
dp::GLState m_state;
drape_ptr<dp::VertexArrayBuffer> m_buffer;
bool m_isBuilded;
};
-
-}
+} // namespace df
diff --git a/drape_frontend/render_state.cpp b/drape_frontend/render_state.cpp
new file mode 100644
index 0000000000..389038ba25
--- /dev/null
+++ b/drape_frontend/render_state.cpp
@@ -0,0 +1,47 @@
+#include "drape_frontend/render_state.hpp"
+
+#include <vector>
+
+namespace df
+{
+RenderState::RenderState(DepthLayer depthLayer)
+ : m_depthLayer(depthLayer)
+{}
+
+bool RenderState::Less(ref_ptr<dp::BaseRenderState> other) const
+{
+ ASSERT(dynamic_cast<RenderState const *>(other.get()) != nullptr, ());
+ auto const renderState = static_cast<RenderState const *>(other.get());
+ return m_depthLayer < renderState->m_depthLayer;
+}
+
+bool RenderState::Equal(ref_ptr<dp::BaseRenderState> other) const
+{
+ ASSERT(dynamic_cast<RenderState const *>(other.get()) != nullptr, ());
+ auto const renderState = static_cast<RenderState const *>(other.get());
+ return m_depthLayer == renderState->m_depthLayer;
+}
+
+// static
+ref_ptr<RenderState> RenderStateFactory::Get(RenderState::DepthLayer depthLayer)
+{
+ static std::vector<drape_ptr<RenderState>> m_states;
+ if (m_states.empty())
+ {
+ m_states.reserve(RenderState::LayersCount);
+ for (size_t i = 0; i < RenderState::LayersCount; ++i)
+ m_states.emplace_back(make_unique_dp<RenderState>(static_cast<RenderState::DepthLayer>(i)));
+ }
+ return make_ref(m_states[static_cast<size_t>(depthLayer)]);
+}
+
+RenderState::DepthLayer GetDepthLayer(dp::GLState const & state)
+{
+ return state.GetRenderState<RenderState>()->GetDepthLayer();
+}
+
+dp::GLState CreateGLState(int gpuProgramIndex, RenderState::DepthLayer depthLayer)
+{
+ return dp::GLState(gpuProgramIndex, RenderStateFactory::Get(depthLayer));
+}
+} // namespace df \ No newline at end of file
diff --git a/drape_frontend/render_state.hpp b/drape_frontend/render_state.hpp
new file mode 100644
index 0000000000..45370ab0fc
--- /dev/null
+++ b/drape_frontend/render_state.hpp
@@ -0,0 +1,45 @@
+#pragma once
+
+#include "drape/glstate.hpp"
+#include "drape/pointers.hpp"
+
+namespace df
+{
+class RenderState : public dp::BaseRenderState
+{
+public:
+ enum DepthLayer
+ {
+ // Do not change the order.
+ GeometryLayer = 0,
+ Geometry3dLayer,
+ UserLineLayer,
+ OverlayLayer,
+ LocalAdsMarkLayer,
+ UserMarkLayer,
+ NavigationLayer,
+ RoutingMarkLayer,
+ GuiLayer,
+ LayersCount
+ };
+
+ explicit RenderState(DepthLayer depthLayer);
+
+ bool Less(ref_ptr<dp::BaseRenderState> other) const override;
+ bool Equal(ref_ptr<dp::BaseRenderState> other) const override;
+
+ DepthLayer GetDepthLayer() const { return m_depthLayer; }
+
+private:
+ DepthLayer const m_depthLayer;
+};
+
+class RenderStateFactory
+{
+public:
+ static ref_ptr<RenderState> Get(RenderState::DepthLayer depthLayer);
+};
+
+extern RenderState::DepthLayer GetDepthLayer(dp::GLState const & state);
+extern dp::GLState CreateGLState(int gpuProgramIndex, RenderState::DepthLayer depthLayer);
+} // namespace df
diff --git a/drape_frontend/route_shape.cpp b/drape_frontend/route_shape.cpp
index 490eb32a06..ea812f4969 100644
--- a/drape_frontend/route_shape.cpp
+++ b/drape_frontend/route_shape.cpp
@@ -375,7 +375,7 @@ void RouteShape::CacheRouteArrows(ref_ptr<dp::TextureManager> mng, m2::PolylineD
TArrowGeometryBuffer joinsGeometry;
dp::TextureManager::SymbolRegion region;
GetArrowTextureRegion(mng, region);
- dp::GLState state = dp::GLState(gpu::ROUTE_ARROW_PROGRAM, dp::GLState::GeometryLayer);
+ auto state = CreateGLState(gpu::ROUTE_ARROW_PROGRAM, RenderState::GeometryLayer);
state.SetColorTexture(region.GetTexture());
// Generate arrow geometry.
@@ -415,9 +415,9 @@ void RouteShape::CacheRoute(ref_ptr<dp::TextureManager> textures, RouteData & ro
PrepareGeometry(routeData.m_subroute->m_polyline.GetPoints(), routeData.m_pivot, segmentsColors,
geometry, joinsGeometry, routeData.m_length);
- dp::GLState state = dp::GLState(routeData.m_subroute->m_pattern.m_isDashed ?
- gpu::ROUTE_DASH_PROGRAM : gpu::ROUTE_PROGRAM,
- dp::GLState::GeometryLayer);
+ auto state = CreateGLState(routeData.m_subroute->m_pattern.m_isDashed ?
+ gpu::ROUTE_DASH_PROGRAM : gpu::ROUTE_PROGRAM,
+ RenderState::GeometryLayer);
state.SetColorTexture(textures->GetSymbolsTexture());
BatchGeometry(state, make_ref(geometry.data()), static_cast<uint32_t>(geometry.size()),
diff --git a/drape_frontend/route_shape.hpp b/drape_frontend/route_shape.hpp
index 4647341c20..9f6da03385 100644
--- a/drape_frontend/route_shape.hpp
+++ b/drape_frontend/route_shape.hpp
@@ -2,9 +2,9 @@
#include "drape_frontend/color_constants.hpp"
#include "drape_frontend/map_shape.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shape_view_params.hpp"
-#include "drape/glstate.hpp"
#include "drape/render_bucket.hpp"
#include "drape/utils/vertex_decl.hpp"
#include "drape/pointers.hpp"
@@ -80,7 +80,9 @@ struct RouteRenderProperty
{
dp::GLState m_state;
std::vector<drape_ptr<dp::RenderBucket>> m_buckets;
- RouteRenderProperty() : m_state(0, dp::GLState::GeometryLayer) {}
+ RouteRenderProperty()
+ : m_state(CreateGLState(0, RenderState::GeometryLayer))
+ {}
};
struct BaseRouteData
diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp
index ff22dec0c1..aa68139f75 100644
--- a/drape_frontend/rule_drawer.cpp
+++ b/drape_frontend/rule_drawer.cpp
@@ -427,9 +427,9 @@ void RuleDrawer::ProcessPointStyle(FeatureType const & f, Stylist const & s, TIn
if (isSpeedCamera && !GetStyleReader().IsCarNavigationStyle())
return;
- dp::GLState::DepthLayer depthLayer = dp::GLState::OverlayLayer;
+ RenderState::DepthLayer depthLayer = RenderState::OverlayLayer;
if (isSpeedCamera)
- depthLayer = dp::GLState::NavigationLayer;
+ depthLayer = RenderState::NavigationLayer;
minVisibleScale = feature::GetMinDrawableScale(f);
ApplyPointFeature apply(m_context->GetTileKey(), insertShape, f.GetID(), minVisibleScale, f.GetRank(),
@@ -538,7 +538,7 @@ void RuleDrawer::DrawTileNet(TInsertShapeFn const & insertShape)
p.m_cap = dp::ButtCap;
p.m_color = dp::Color::Red();
p.m_depth = 20000;
- p.m_depthLayer = dp::GLState::GeometryLayer;
+ p.m_depthLayer = RenderState::GeometryLayer;
p.m_width = 5;
p.m_join = dp::RoundJoin;
@@ -548,7 +548,7 @@ void RuleDrawer::DrawTileNet(TInsertShapeFn const & insertShape)
tp.m_tileCenter = m_globalRect.Center();
tp.m_titleDecl.m_anchor = dp::Center;
tp.m_depth = 20000;
- tp.m_depthLayer = dp::GLState::OverlayLayer;
+ tp.m_depthLayer = RenderState::OverlayLayer;
tp.m_titleDecl.m_primaryText = strings::to_string(key.m_x) + " " +
strings::to_string(key.m_y) + " " +
strings::to_string(key.m_zoomLevel);
diff --git a/drape_frontend/screen_quad_renderer.cpp b/drape_frontend/screen_quad_renderer.cpp
index 7da2089685..70b790b762 100644
--- a/drape_frontend/screen_quad_renderer.cpp
+++ b/drape_frontend/screen_quad_renderer.cpp
@@ -1,11 +1,11 @@
#include "drape_frontend/screen_quad_renderer.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape/data_buffer.hpp"
#include "drape/glconstants.hpp"
#include "drape/glextensions_list.hpp"
#include "drape/glfunctions.hpp"
-#include "drape/glstate.hpp"
#include "drape/gpu_program_manager.hpp"
#include "drape/uniform_values_storage.hpp"
diff --git a/drape_frontend/selection_shape.cpp b/drape_frontend/selection_shape.cpp
index a21fe72476..035ca74707 100644
--- a/drape_frontend/selection_shape.cpp
+++ b/drape_frontend/selection_shape.cpp
@@ -85,7 +85,7 @@ SelectionShape::SelectionShape(ref_ptr<dp::TextureManager> mng)
buffer.emplace_back(nextNormal, colorCoord);
}
- dp::GLState state(gpu::ACCURACY_PROGRAM, dp::GLState::OverlayLayer);
+ auto state = CreateGLState(gpu::ACCURACY_PROGRAM, RenderState::OverlayLayer);
state.SetColorTexture(color.GetTexture());
{
diff --git a/drape_frontend/shape_view_params.hpp b/drape_frontend/shape_view_params.hpp
index 25e6ae09b5..8e8418e1d9 100644
--- a/drape_frontend/shape_view_params.hpp
+++ b/drape_frontend/shape_view_params.hpp
@@ -1,8 +1,9 @@
#pragma once
+#include "drape_frontend/render_state.hpp"
+
#include "drape/color.hpp"
#include "drape/drape_global.hpp"
-#include "drape/glstate.hpp"
#include "drape/stipple_pen_resource.hpp"
#include "indexer/feature_decl.hpp"
@@ -19,7 +20,7 @@ int constexpr kBuildingOutlineSize = 16;
struct CommonViewParams
{
- dp::GLState::DepthLayer m_depthLayer = dp::GLState::GeometryLayer;
+ RenderState::DepthLayer m_depthLayer = RenderState::GeometryLayer;
float m_depth = 0.0f;
int m_minVisibleScale = 0;
uint8_t m_rank = 0;
diff --git a/drape_frontend/text_shape.cpp b/drape_frontend/text_shape.cpp
index 709074b0aa..8854169359 100644
--- a/drape_frontend/text_shape.cpp
+++ b/drape_frontend/text_shape.cpp
@@ -1,4 +1,5 @@
#include "drape_frontend/text_shape.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape_frontend/text_handle.hpp"
#include "drape_frontend/text_layout.hpp"
@@ -6,7 +7,6 @@
#include "drape/utils/vertex_decl.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/batcher.hpp"
-#include "drape/glstate.hpp"
#include "drape/overlay_handle.hpp"
#include "drape/texture_manager.hpp"
@@ -270,7 +270,7 @@ void TextShape::DrawSubStringPlain(StraightTextLayout const & layout, dp::FontDe
baseOffset, color, staticBuffer, dynamicBuffer);
bool const isNonSdfText = layout.GetFixedHeight() > 0;
- dp::GLState state(isNonSdfText ? gpu::TEXT_FIXED_PROGRAM : gpu::TEXT_PROGRAM, m_params.m_depthLayer);
+ auto state = CreateGLState(isNonSdfText ? gpu::TEXT_FIXED_PROGRAM : gpu::TEXT_PROGRAM, m_params.m_depthLayer);
state.SetProgram3dIndex(isNonSdfText ? gpu::TEXT_FIXED_BILLBOARD_PROGRAM : gpu::TEXT_BILLBOARD_PROGRAM);
ASSERT(color.GetTexture() == outline.GetTexture(), ());
@@ -325,7 +325,7 @@ void TextShape::DrawSubStringOutlined(StraightTextLayout const & layout, dp::Fon
layout.Cache(glsl::vec4(pt, m_params.m_depth, -m_params.m_posZ),
baseOffset, color, outline, staticBuffer, dynamicBuffer);
- dp::GLState state(gpu::TEXT_OUTLINED_PROGRAM, m_params.m_depthLayer);
+ auto state = CreateGLState(gpu::TEXT_OUTLINED_PROGRAM, m_params.m_depthLayer);
state.SetProgram3dIndex(gpu::TEXT_OUTLINED_BILLBOARD_PROGRAM);
ASSERT(color.GetTexture() == outline.GetTexture(), ());
state.SetColorTexture(color.GetTexture());
diff --git a/drape_frontend/traffic_generator.cpp b/drape_frontend/traffic_generator.cpp
index 4c23f6b804..5fed6a1696 100644
--- a/drape_frontend/traffic_generator.cpp
+++ b/drape_frontend/traffic_generator.cpp
@@ -132,11 +132,11 @@ void TrafficGenerator::FlushSegmentsGeometry(TileKey const & tileKey, TrafficSeg
ASSERT(m_colorsCacheValid, ());
auto const texture = m_colorsCache[static_cast<size_t>(traffic::SpeedGroup::G0)].GetTexture();
- dp::GLState state(gpu::TRAFFIC_PROGRAM, dp::GLState::GeometryLayer);
+ auto state = CreateGLState(gpu::TRAFFIC_PROGRAM, RenderState::GeometryLayer);
state.SetColorTexture(texture);
state.SetMaskTexture(textures->GetTrafficArrowTexture());
- dp::GLState lineState(gpu::TRAFFIC_LINE_PROGRAM, dp::GLState::GeometryLayer);
+ auto lineState = CreateGLState(gpu::TRAFFIC_LINE_PROGRAM, RenderState::GeometryLayer);
lineState.SetColorTexture(texture);
lineState.SetDrawAsLine(true);
diff --git a/drape_frontend/traffic_generator.hpp b/drape_frontend/traffic_generator.hpp
index 1b42fd01f0..fd4ee9109c 100644
--- a/drape_frontend/traffic_generator.hpp
+++ b/drape_frontend/traffic_generator.hpp
@@ -2,11 +2,11 @@
#include "drape_frontend/batchers_pool.hpp"
#include "drape_frontend/color_constants.hpp"
+#include "drape_frontend/render_state.hpp"
#include "drape_frontend/tile_key.hpp"
#include "drape/color.hpp"
#include "drape/glsl_types.hpp"
-#include "drape/glstate.hpp"
#include "drape/render_bucket.hpp"
#include "drape/texture_manager.hpp"
diff --git a/drape_frontend/user_mark_shapes.cpp b/drape_frontend/user_mark_shapes.cpp
index 504c0e0c8c..af3581e0f6 100644
--- a/drape_frontend/user_mark_shapes.cpp
+++ b/drape_frontend/user_mark_shapes.cpp
@@ -95,7 +95,7 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
bool isAnimated = false;
dp::TextureManager::SymbolRegion region;
- dp::GLState::DepthLayer depthLayer = dp::GLState::UserMarkLayer;
+ RenderState::DepthLayer depthLayer = RenderState::UserMarkLayer;
for (auto const id : marksId)
{
auto const it = renderParams.find(id);
@@ -184,7 +184,8 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
if (!buffer.empty())
{
- dp::GLState state(isAnimated ? gpu::BOOKMARK_ANIM_PROGRAM : gpu::BOOKMARK_PROGRAM, depthLayer);
+ auto state = CreateGLState(isAnimated ? gpu::BOOKMARK_ANIM_PROGRAM
+ : gpu::BOOKMARK_PROGRAM, depthLayer);
state.SetProgram3dIndex(isAnimated ? gpu::BOOKMARK_ANIM_BILLBOARD_PROGRAM
: gpu::BOOKMARK_BILLBOARD_PROGRAM);
state.SetColorTexture(region.GetTexture());
diff --git a/drape_frontend/user_mark_shapes.hpp b/drape_frontend/user_mark_shapes.hpp
index 106df084f8..299272e624 100644
--- a/drape_frontend/user_mark_shapes.hpp
+++ b/drape_frontend/user_mark_shapes.hpp
@@ -25,7 +25,7 @@ struct UserMarkRenderParams
bool m_hasTitlePriority = false;
uint16_t m_priority = 0;
float m_depth = 0.0;
- dp::GLState::DepthLayer m_depthLayer = dp::GLState::UserMarkLayer;
+ RenderState::DepthLayer m_depthLayer = RenderState::UserMarkLayer;
bool m_hasCreationAnimation = false;
bool m_justCreated = false;
bool m_isVisible = true;
@@ -49,7 +49,7 @@ struct LineLayer
struct UserLineRenderParams
{
int m_minZoom = 1;
- dp::GLState::DepthLayer m_depthLayer = dp::GLState::UserLineLayer;
+ RenderState::DepthLayer m_depthLayer = RenderState::UserLineLayer;
std::vector<LineLayer> m_layers;
m2::SharedSpline m_spline;
};
diff --git a/drape_frontend/user_marks_provider.hpp b/drape_frontend/user_marks_provider.hpp
index b0fd837710..c74027921b 100644
--- a/drape_frontend/user_marks_provider.hpp
+++ b/drape_frontend/user_marks_provider.hpp
@@ -1,16 +1,14 @@
#pragma once
+#include "drape_frontend/render_state.hpp"
+
#include "drape/drape_global.hpp"
-#include "drape/glstate.hpp"
#include "drape/pointers.hpp"
#include "indexer/feature_decl.hpp"
#include "geometry/polyline2d.hpp"
-#include "base/mutex.hpp"
-
-#include <atomic>
#include <vector>
namespace df
@@ -53,7 +51,7 @@ public:
virtual std::string GetSymbolName() const = 0;
virtual dp::Anchor GetAnchor() const = 0;
virtual float GetDepth() const = 0;
- virtual dp::GLState::DepthLayer GetDepthLayer() const = 0;
+ virtual RenderState::DepthLayer GetDepthLayer() const = 0;
virtual bool IsVisible() const = 0;
virtual drape_ptr<dp::TitleDecl> GetTitleDecl() const = 0;
virtual uint16_t GetPriority() const = 0;
@@ -79,7 +77,7 @@ public:
virtual MarkID GetId() const { return m_id; }
virtual int GetMinZoom() const = 0;
- virtual dp::GLState::DepthLayer GetDepthLayer() const = 0;
+ virtual RenderState::DepthLayer GetDepthLayer() const = 0;
virtual size_t GetLayerCount() const = 0;
virtual dp::Color const & GetColor(size_t layerIndex) const = 0;
virtual float GetWidth(size_t layerIndex) const = 0;
diff --git a/map/local_ads_mark.cpp b/map/local_ads_mark.cpp
index 382319ab3a..0e4a142d10 100644
--- a/map/local_ads_mark.cpp
+++ b/map/local_ads_mark.cpp
@@ -30,9 +30,9 @@ LocalAdsMark::LocalAdsMark(m2::PointD const & ptOrg,
m_titleDecl.m_secondaryOffset = m2::PointF(0, kSecondaryOffsetY);
}
-dp::GLState::DepthLayer LocalAdsMark::GetDepthLayer() const
+df::RenderState::DepthLayer LocalAdsMark::GetDepthLayer() const
{
- return dp::GLState::LocalAdsMarkLayer;
+ return df::RenderState::LocalAdsMarkLayer;
}
drape_ptr<dp::TitleDecl> LocalAdsMark::GetTitleDecl() const
diff --git a/map/local_ads_mark.hpp b/map/local_ads_mark.hpp
index 64f62870d2..5927a3ca68 100644
--- a/map/local_ads_mark.hpp
+++ b/map/local_ads_mark.hpp
@@ -22,7 +22,7 @@ public:
LocalAdsMark(m2::PointD const & ptOrg, UserMarkContainer * container);
virtual ~LocalAdsMark() {}
- dp::GLState::DepthLayer GetDepthLayer() const override;
+ df::RenderState::DepthLayer GetDepthLayer() const override;
std::string GetSymbolName() const override { return m_data.m_symbolName; }
UserMark::Type GetMarkType() const override { return Type::LOCAL_ADS; }
diff --git a/map/routing_mark.cpp b/map/routing_mark.cpp
index e39abd907c..489e8447fc 100644
--- a/map/routing_mark.cpp
+++ b/map/routing_mark.cpp
@@ -38,9 +38,9 @@ dp::Anchor RouteMarkPoint::GetAnchor() const
return dp::Center;
}
-dp::GLState::DepthLayer RouteMarkPoint::GetDepthLayer() const
+df::RenderState::DepthLayer RouteMarkPoint::GetDepthLayer() const
{
- return dp::GLState::RoutingMarkLayer;
+ return df::RenderState::RoutingMarkLayer;
}
void RouteMarkPoint::SetRoutePointType(RouteMarkType type)
diff --git a/map/routing_mark.hpp b/map/routing_mark.hpp
index 59c85a01d0..5a82b09500 100644
--- a/map/routing_mark.hpp
+++ b/map/routing_mark.hpp
@@ -34,7 +34,7 @@ public:
void SetIsVisible(bool isVisible) { m_markData.m_isVisible = isVisible; }
dp::Anchor GetAnchor() const override;
- dp::GLState::DepthLayer GetDepthLayer() const override;
+ df::RenderState::DepthLayer GetDepthLayer() const override;
std::string GetSymbolName() const override;
UserMark::Type GetMarkType() const override { return Type::ROUTING; }
diff --git a/map/track.cpp b/map/track.cpp
index cb7d0408ce..1bde42fbc9 100644
--- a/map/track.cpp
+++ b/map/track.cpp
@@ -42,9 +42,9 @@ double Track::GetLengthMeters() const
return res;
}
-dp::GLState::DepthLayer Track::GetDepthLayer() const
+df::RenderState::DepthLayer Track::GetDepthLayer() const
{
- return dp::GLState::UserLineLayer;
+ return df::RenderState::UserLineLayer;
}
size_t Track::GetLayerCount() const
diff --git a/map/track.hpp b/map/track.hpp
index 9905fbcc55..372c8bf54e 100644
--- a/map/track.hpp
+++ b/map/track.hpp
@@ -43,7 +43,7 @@ public:
double GetLengthMeters() const;
int GetMinZoom() const override { return 1; }
- dp::GLState::DepthLayer GetDepthLayer() const override;
+ df::RenderState::DepthLayer GetDepthLayer() const override;
size_t GetLayerCount() const override;
dp::Color const & GetColor(size_t layerIndex) const override;
float GetWidth(size_t layerIndex) const override;
diff --git a/map/user_mark.cpp b/map/user_mark.cpp
index fb523ee075..01651b9e26 100644
--- a/map/user_mark.cpp
+++ b/map/user_mark.cpp
@@ -32,9 +32,9 @@ float UserMark::GetDepth() const
return GetContainer()->GetPointDepth();
}
-dp::GLState::DepthLayer UserMark::GetDepthLayer() const
+df::RenderState::DepthLayer UserMark::GetDepthLayer() const
{
- return dp::GLState::UserMarkLayer;
+ return df::RenderState::UserMarkLayer;
}
UserMarkContainer const * UserMark::GetContainer() const
diff --git a/map/user_mark.hpp b/map/user_mark.hpp
index 0918455659..2b9149f781 100644
--- a/map/user_mark.hpp
+++ b/map/user_mark.hpp
@@ -45,7 +45,7 @@ public:
m2::PointD GetPixelOffset() const override;
dp::Anchor GetAnchor() const override;
float GetDepth() const override;
- dp::GLState::DepthLayer GetDepthLayer() const override;
+ df::RenderState::DepthLayer GetDepthLayer() const override;
drape_ptr<dp::TitleDecl> GetTitleDecl() const override { return nullptr; }
uint16_t GetPriority() const override { return kDefaultUserMarkProirity; }
bool HasSymbolPriority() const override { return false; }
diff --git a/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj b/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj
index a2447b69c6..2ff4da8625 100644
--- a/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj
+++ b/xcode/drape_frontend/drape_frontend.xcodeproj/project.pbxproj
@@ -42,6 +42,8 @@
452FE5C41EB2004F00EE470C /* screen_quad_renderer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 452FE5C21EB2004F00EE470C /* screen_quad_renderer.hpp */; };
453EEA6D1E3A28F400505E09 /* colored_symbol_shape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 453EEA6B1E3A28F400505E09 /* colored_symbol_shape.cpp */; };
453EEA6E1E3A28F400505E09 /* colored_symbol_shape.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 453EEA6C1E3A28F400505E09 /* colored_symbol_shape.hpp */; };
+ 453FEDAC1F34C257005C1BB4 /* render_state.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 453FEDAA1F34C257005C1BB4 /* render_state.cpp */; };
+ 453FEDAD1F34C257005C1BB4 /* render_state.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 453FEDAB1F34C257005C1BB4 /* render_state.hpp */; };
454C19BB1CCE3EC0002A2C86 /* animation_constants.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 454C19B81CCE3EC0002A2C86 /* animation_constants.hpp */; };
454C19BC1CCE3EC0002A2C86 /* animation_system.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 454C19B91CCE3EC0002A2C86 /* animation_system.cpp */; };
454C19BD1CCE3EC0002A2C86 /* animation_system.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 454C19BA1CCE3EC0002A2C86 /* animation_system.hpp */; };
@@ -268,6 +270,8 @@
452FE5C21EB2004F00EE470C /* screen_quad_renderer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = screen_quad_renderer.hpp; sourceTree = "<group>"; };
453EEA6B1E3A28F400505E09 /* colored_symbol_shape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = colored_symbol_shape.cpp; sourceTree = "<group>"; };
453EEA6C1E3A28F400505E09 /* colored_symbol_shape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = colored_symbol_shape.hpp; sourceTree = "<group>"; };
+ 453FEDAA1F34C257005C1BB4 /* render_state.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_state.cpp; sourceTree = "<group>"; };
+ 453FEDAB1F34C257005C1BB4 /* render_state.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = render_state.hpp; sourceTree = "<group>"; };
454C19B81CCE3EC0002A2C86 /* animation_constants.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = animation_constants.hpp; sourceTree = "<group>"; };
454C19B91CCE3EC0002A2C86 /* animation_system.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = animation_system.cpp; sourceTree = "<group>"; };
454C19BA1CCE3EC0002A2C86 /* animation_system.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = animation_system.hpp; sourceTree = "<group>"; };
@@ -609,6 +613,8 @@
670947411BDF9B99005014C0 /* drape_frontend */ = {
isa = PBXGroup;
children = (
+ 453FEDAA1F34C257005C1BB4 /* render_state.cpp */,
+ 453FEDAB1F34C257005C1BB4 /* render_state.hpp */,
EB2B78011EEDD439002697B6 /* read_metaline_task.cpp */,
EB2B78021EEDD439002697B6 /* read_metaline_task.hpp */,
EB2B77FD1EEDD418002697B6 /* metaline_manager.cpp */,
@@ -967,6 +973,7 @@
670947D71BDF9BE1005014C0 /* user_event_stream.hpp in Headers */,
6709479E1BDF9BE1005014C0 /* message_acceptor.hpp in Headers */,
6709484A1BDF9C48005014C0 /* ruler_helper.hpp in Headers */,
+ 453FEDAD1F34C257005C1BB4 /* render_state.hpp in Headers */,
6743D36E1C3A9F090095054B /* arrow3d.hpp in Headers */,
670947B81BDF9BE1005014C0 /* route_builder.hpp in Headers */,
45B4B8CC1CF5C16B00A54761 /* screen_animations.hpp in Headers */,
@@ -1137,6 +1144,7 @@
670947B91BDF9BE1005014C0 /* route_renderer.cpp in Sources */,
670E393C1C46C59000E9C0A6 /* color_constants.cpp in Sources */,
677A2DE51C0DD55D00635A00 /* requested_tiles.cpp in Sources */,
+ 453FEDAC1F34C257005C1BB4 /* render_state.cpp in Sources */,
45B4B8CD1CF5C16B00A54761 /* screen_operations.cpp in Sources */,
670947B31BDF9BE1005014C0 /* render_group.cpp in Sources */,
675D21911BFB871D00717E4F /* text_engine.cpp in Sources */,