diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-03-29 19:09:29 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-04-05 11:49:17 +0200 |
commit | c02010ab6c8958f6897921c82cf47411de759269 (patch) | |
tree | 031d0b9f17d66c62232249b416fd327a2a519488 /src/mbgl/gfx | |
parent | 543b678982037595895a474f3a69348dc235e0fa (diff) | |
download | qtlocation-mapboxgl-c02010ab6c8958f6897921c82cf47411de759269.tar.gz |
[core] move debug groups to gfx::CommandEncoder
Diffstat (limited to 'src/mbgl/gfx')
-rw-r--r-- | src/mbgl/gfx/command_encoder.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/gfx/debug_group.hpp | 28 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/mbgl/gfx/command_encoder.hpp b/src/mbgl/gfx/command_encoder.hpp index 3f996bb701..f095c5b867 100644 --- a/src/mbgl/gfx/command_encoder.hpp +++ b/src/mbgl/gfx/command_encoder.hpp @@ -1,5 +1,7 @@ #pragma once +#include <mbgl/gfx/debug_group.hpp> + namespace mbgl { namespace gfx { @@ -7,10 +9,18 @@ class CommandEncoder { protected: explicit CommandEncoder() = default; + friend class DebugGroup<CommandEncoder>; + virtual void pushDebugGroup(const char* name) = 0; + virtual void popDebugGroup() = 0; + public: virtual ~CommandEncoder() = default; CommandEncoder(const CommandEncoder&) = delete; CommandEncoder& operator=(const CommandEncoder&) = delete; + + DebugGroup<CommandEncoder> createDebugGroup(const char* name) { + return { *this, name }; + } }; } // namespace gfx diff --git a/src/mbgl/gfx/debug_group.hpp b/src/mbgl/gfx/debug_group.hpp new file mode 100644 index 0000000000..b7a25ad467 --- /dev/null +++ b/src/mbgl/gfx/debug_group.hpp @@ -0,0 +1,28 @@ +#pragma once + +namespace mbgl { +namespace gfx { + +template <typename T> +class DebugGroup { +public: + DebugGroup(T& scope_, const char* name) : scope(&scope_) { + scope->pushDebugGroup(name); + } + + DebugGroup(DebugGroup&& rhs) : scope(rhs.scope) { + rhs.scope = nullptr; + } + + ~DebugGroup() { + if (scope) { + scope->popDebugGroup(); + } + } + +private: + T* scope; +}; + +} // namespace gfx +} // namespace mbgl |