| 1 | #include <mbgl/gl/debugging.hpp> |
| 2 | #include <mbgl/gl/context.hpp> |
| 3 | #include <mbgl/gl/debugging_extension.hpp> |
| 4 | |
| 5 | namespace mbgl { |
| 6 | namespace gl { |
| 7 | |
| 8 | #ifndef NDEBUG |
| 9 | |
| 10 | DebugGroup::DebugGroup(const Context& context_, const std::string& name) : context(context_) { |
| 11 | if (auto debugging = context.getDebuggingExtension()) { |
| 12 | if (debugging->pushDebugGroup) { |
| 13 | MBGL_CHECK_ERROR(debugging->pushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, GLsizei(name.size()), name.c_str())); |
| 14 | } else if (debugging->pushGroupMarkerEXT) { |
| 15 | MBGL_CHECK_ERROR(debugging->pushGroupMarkerEXT(GLsizei(name.size() + 1), name.c_str())); |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | DebugGroup::~DebugGroup() { |
| 21 | if (auto debugging = context.getDebuggingExtension()) { |
| 22 | if (debugging->popDebugGroup) { |
| 23 | MBGL_CHECK_ERROR(debugging->popDebugGroup()); |
| 24 | } else if (debugging->popGroupMarkerEXT) { |
| 25 | MBGL_CHECK_ERROR(debugging->popGroupMarkerEXT()); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | #endif |
| 31 | |
| 32 | } // namespace gl |
| 33 | } // namespace mbgl |
| 34 | |