MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
renderer_backend.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/util/util.hpp>
4 
5 #include <memory>
6 #include <mutex>
7 
8 namespace mbgl {
9 namespace gfx {
10 
11 class Context;
12 class Renderable;
13 class BackendScope;
14 
15 // We can make some optimizations if we know that the drawing context is not shared with other code.
16 enum class ContextMode : bool {
17  Unique,
18  Shared,
19 };
20 
22 protected:
24 
25 public:
26  virtual ~RendererBackend();
27  RendererBackend(const RendererBackend&) = delete;
29 
31  Context& getContext();
32 
33  template <typename T>
34  T& getContext() {
35  return static_cast<T&>(getContext());
36  }
37 
38  bool contextIsShared() const {
40  }
41 
44 
45 protected:
46  virtual std::unique_ptr<Context> createContext() = 0;
47 
56  virtual void activate() = 0;
57  virtual void deactivate() = 0;
58 
59 protected:
60  std::unique_ptr<Context> context;
62  std::once_flag initialized;
63 
64  friend class BackendScope;
65 };
66 
68  return &a == &b;
69 }
70 
71 } // namespace gfx
72 } // namespace mbgl
RendererBackend(const RendererBackend &)=delete
virtual void deactivate()=0
Context & getContext()
Returns the device's context.
virtual void activate()=0
virtual std::unique_ptr< Context > createContext()=0
RendererBackend & operator=(const RendererBackend &)=delete
std::unique_ptr< Context > context
virtual Renderable & getDefaultRenderable()=0
Returns a reference to the default surface that should be rendered on.
MBGL_CONSTEXPR bool operator==(const RendererBackend &a, const RendererBackend &b)
Definition: actor.hpp:15
#define MBGL_CONSTEXPR
Definition: util.hpp:18