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-01 15:34:06 +0300
committerRoman Kuznetsov <r.kuznetsow@gmail.com>2018-08-01 16:21:56 +0300
commit0b7f3017fe6eeb25d14e22bac45271de4c53be01 (patch)
tree42f797cf352b2ab450979ea0bafc563be6e73a7a /drape
parentbc461840fe7462cb6d55cd3f577824de07583e0c (diff)
Graphics context. Review fixes.
Diffstat (limited to 'drape')
-rw-r--r--drape/CMakeLists.txt6
-rw-r--r--drape/graphic_context_factory.hpp52
-rw-r--r--drape/graphics_context.hpp (renamed from drape/graphic_context.hpp)14
-rw-r--r--drape/graphics_context_factory.cpp (renamed from drape/graphic_context_factory.cpp)14
-rw-r--r--drape/graphics_context_factory.hpp52
-rw-r--r--drape/oglcontext.cpp12
-rw-r--r--drape/oglcontext.hpp10
7 files changed, 80 insertions, 80 deletions
diff --git a/drape/CMakeLists.txt b/drape/CMakeLists.txt
index 48fad00676..efa16b2c14 100644
--- a/drape/CMakeLists.txt
+++ b/drape/CMakeLists.txt
@@ -63,9 +63,9 @@ set(
${DRAPE_ROOT}/gpu_buffer.hpp
${DRAPE_ROOT}/gpu_program.cpp
${DRAPE_ROOT}/gpu_program.hpp
- ${DRAPE_ROOT}/graphic_context.hpp
- ${DRAPE_ROOT}/graphic_context_factory.cpp
- ${DRAPE_ROOT}/graphic_context_factory.hpp
+ ${DRAPE_ROOT}/graphics_context.hpp
+ ${DRAPE_ROOT}/graphics_context_factory.cpp
+ ${DRAPE_ROOT}/graphics_context_factory.hpp
${DRAPE_ROOT}/hw_texture.cpp
${DRAPE_ROOT}/hw_texture.hpp
${DRAPE_ROOT}/index_buffer.cpp
diff --git a/drape/graphic_context_factory.hpp b/drape/graphic_context_factory.hpp
deleted file mode 100644
index 3c20665003..0000000000
--- a/drape/graphic_context_factory.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#pragma once
-
-#include "drape/graphic_context.hpp"
-
-#include "base/condition.hpp"
-#include "base/assert.hpp"
-
-#include "std/function.hpp"
-
-namespace dp
-{
-class GraphicContextFactory
-{
-public:
- virtual ~GraphicContextFactory() {}
- virtual GraphicContext * GetDrawContext() = 0;
- virtual GraphicContext * GetResourcesUploadContext() = 0;
- virtual bool IsDrawContextCreated() const { return false; }
- virtual bool IsUploadContextCreated() const { return false; }
- virtual void WaitForInitialization(dp::GraphicContext * context) {}
- virtual void SetPresentAvailable(bool available) {}
-};
-
-class ThreadSafeFactory : public GraphicContextFactory
-{
-public:
- ThreadSafeFactory(GraphicContextFactory * factory, bool enableSharing = true);
- ~ThreadSafeFactory();
- GraphicContext * GetDrawContext() override;
- GraphicContext * GetResourcesUploadContext() override;
-
- template<typename T>
- T * CastFactory()
- {
- ASSERT(dynamic_cast<T *>(m_factory) != nullptr, ());
- return static_cast<T *>(m_factory);
- }
-
- void WaitForInitialization(dp::GraphicContext * context) override;
- void SetPresentAvailable(bool available) override;
-
-protected:
- typedef function<GraphicContext * ()> TCreateCtxFn;
- typedef function<bool()> TIsSeparateCreatedFn;
- GraphicContext * CreateContext(TCreateCtxFn const & createFn, TIsSeparateCreatedFn const checkFn);
-
-private:
- GraphicContextFactory * m_factory;
- threads::Condition m_contidion;
- bool m_enableSharing;
-};
-} // namespace dp
diff --git a/drape/graphic_context.hpp b/drape/graphics_context.hpp
index 7f538079cc..d6f31b8f8a 100644
--- a/drape/graphic_context.hpp
+++ b/drape/graphics_context.hpp
@@ -4,19 +4,17 @@
namespace dp
{
-using ContextConst = uint32_t;
-
-enum ClearBits: ContextConst
+enum ClearBits: uint32_t
{
ColorBit = 1,
DepthBit = 1 << 1,
StencilBit = 1 << 2
};
-class GraphicContext
+class GraphicsContext
{
public:
- virtual ~GraphicContext() {}
+ virtual ~GraphicsContext() = default;
virtual void Present() = 0;
virtual void MakeCurrent() = 0;
virtual void DoneCurrent() {}
@@ -27,9 +25,9 @@ public:
virtual void SetPresentAvailable(bool /*available*/) {}
virtual bool Validate() { return true; }
- virtual void SetApiVersion(ApiVersion apiVersion) = 0;
- virtual void Init() = 0;
+ virtual void Init(ApiVersion apiVersion) = 0;
virtual void SetClearColor(float r, float g, float b, float a) = 0;
- virtual void Clear(ContextConst clearBits) = 0;
+ virtual void Clear(uint32_t clearBits) = 0;
+ virtual void Flush() = 0;
};
} // namespace dp
diff --git a/drape/graphic_context_factory.cpp b/drape/graphics_context_factory.cpp
index c9e3674c59..d2d8b50d09 100644
--- a/drape/graphic_context_factory.cpp
+++ b/drape/graphics_context_factory.cpp
@@ -1,8 +1,8 @@
-#include "drape/graphic_context_factory.hpp"
+#include "drape/graphics_context_factory.hpp"
namespace dp
{
-ThreadSafeFactory::ThreadSafeFactory(GraphicContextFactory * factory, bool enableSharing)
+ThreadSafeFactory::ThreadSafeFactory(GraphicsContextFactory * factory, bool enableSharing)
: m_factory(factory)
, m_enableSharing(enableSharing)
{}
@@ -12,22 +12,22 @@ ThreadSafeFactory::~ThreadSafeFactory()
delete m_factory;
}
-GraphicContext * ThreadSafeFactory::GetDrawContext()
+GraphicsContext * ThreadSafeFactory::GetDrawContext()
{
return CreateContext([this](){ return m_factory->GetDrawContext(); },
[this](){ return m_factory->IsUploadContextCreated(); });
}
-GraphicContext * ThreadSafeFactory::GetResourcesUploadContext()
+GraphicsContext * ThreadSafeFactory::GetResourcesUploadContext()
{
return CreateContext([this](){ return m_factory->GetResourcesUploadContext(); },
[this](){ return m_factory->IsDrawContextCreated(); });
}
-GraphicContext * ThreadSafeFactory::CreateContext(TCreateCtxFn const & createFn, TIsSeparateCreatedFn const checkFn)
+GraphicsContext * ThreadSafeFactory::CreateContext(TCreateCtxFn const & createFn, TIsSeparateCreatedFn const checkFn)
{
threads::ConditionGuard g(m_contidion);
- GraphicContext * ctx = createFn();
+ GraphicsContext * ctx = createFn();
if (m_enableSharing)
{
if (!checkFn())
@@ -39,7 +39,7 @@ GraphicContext * ThreadSafeFactory::CreateContext(TCreateCtxFn const & createFn,
return ctx;
}
-void ThreadSafeFactory::WaitForInitialization(GraphicContext * context)
+void ThreadSafeFactory::WaitForInitialization(GraphicsContext * context)
{
m_factory->WaitForInitialization(context);
}
diff --git a/drape/graphics_context_factory.hpp b/drape/graphics_context_factory.hpp
new file mode 100644
index 0000000000..8a057a9f22
--- /dev/null
+++ b/drape/graphics_context_factory.hpp
@@ -0,0 +1,52 @@
+#pragma once
+
+#include "drape/graphics_context.hpp"
+
+#include "base/condition.hpp"
+#include "base/assert.hpp"
+
+#include "std/function.hpp"
+
+namespace dp
+{
+class GraphicsContextFactory
+{
+public:
+ virtual ~GraphicsContextFactory() {}
+ virtual GraphicsContext * GetDrawContext() = 0;
+ virtual GraphicsContext * GetResourcesUploadContext() = 0;
+ virtual bool IsDrawContextCreated() const { return false; }
+ virtual bool IsUploadContextCreated() const { return false; }
+ virtual void WaitForInitialization(dp::GraphicsContext * context) {}
+ virtual void SetPresentAvailable(bool available) {}
+};
+
+class ThreadSafeFactory : public GraphicsContextFactory
+{
+public:
+ ThreadSafeFactory(GraphicsContextFactory * factory, bool enableSharing = true);
+ ~ThreadSafeFactory();
+ GraphicsContext * GetDrawContext() override;
+ GraphicsContext * GetResourcesUploadContext() override;
+
+ template<typename T>
+ T * CastFactory()
+ {
+ ASSERT(dynamic_cast<T *>(m_factory) != nullptr, ());
+ return static_cast<T *>(m_factory);
+ }
+
+ void WaitForInitialization(dp::GraphicsContext * context) override;
+ void SetPresentAvailable(bool available) override;
+
+protected:
+ typedef function<GraphicsContext * ()> TCreateCtxFn;
+ typedef function<bool()> TIsSeparateCreatedFn;
+ GraphicsContext * CreateContext(TCreateCtxFn const & createFn, TIsSeparateCreatedFn const checkFn);
+
+private:
+ GraphicsContextFactory * m_factory;
+ threads::Condition m_contidion;
+ bool m_enableSharing;
+};
+} // namespace dp
diff --git a/drape/oglcontext.cpp b/drape/oglcontext.cpp
index eaffb7f0d6..e91f454bc6 100644
--- a/drape/oglcontext.cpp
+++ b/drape/oglcontext.cpp
@@ -3,13 +3,10 @@
namespace dp
{
-void OGLContext::SetApiVersion(ApiVersion apiVersion)
+void OGLContext::Init(ApiVersion apiVersion)
{
GLFunctions::Init(apiVersion);
-}
-void OGLContext::Init()
-{
GLFunctions::glPixelStore(gl_const::GLUnpackAlignment, 1);
GLFunctions::glClearDepthValue(1.0);
@@ -27,7 +24,7 @@ void OGLContext::SetClearColor(float r, float g, float b, float a)
GLFunctions::glClearColor(r, g, b, a);
}
-void OGLContext::Clear(ContextConst clearBits)
+void OGLContext::Clear(uint32_t clearBits)
{
glConst glBits = 0;
if (clearBits & ClearBits::ColorBit)
@@ -39,4 +36,9 @@ void OGLContext::Clear(ContextConst clearBits)
GLFunctions::glClear(glBits);
}
+
+void OGLContext::Flush()
+{
+ GLFunctions::glFlush();
+}
} // namespace dp
diff --git a/drape/oglcontext.hpp b/drape/oglcontext.hpp
index 709df24b61..e25610a808 100644
--- a/drape/oglcontext.hpp
+++ b/drape/oglcontext.hpp
@@ -1,15 +1,15 @@
#pragma once
-#include "drape/graphic_context.hpp"
+#include "drape/graphics_context.hpp"
namespace dp
{
-class OGLContext: public GraphicContext
+class OGLContext: public GraphicsContext
{
public:
- void SetApiVersion(ApiVersion apiVersion) override;
- void Init() override;
+ void Init(ApiVersion apiVersion) override;
void SetClearColor(float r, float g, float b, float a) override;
- void Clear(ContextConst clearBits) override;
+ void Clear(uint32_t clearBits) override;
+ void Flush() override;
};
} // namespace dp