From 1951fb62eec27e9adad152de4c4cc16ab3d5661a Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 9 May 2020 23:37:52 +0200 Subject: [PATCH] obs/gs-helper: Optimize performance with inline --- source/obs/gs/gs-helper.cpp | 31 ------------------------------- source/obs/gs/gs-helper.hpp | 33 +++++++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 37 deletions(-) diff --git a/source/obs/gs/gs-helper.cpp b/source/obs/gs/gs-helper.cpp index 91dbd872..e37a818b 100644 --- a/source/obs/gs/gs-helper.cpp +++ b/source/obs/gs/gs-helper.cpp @@ -18,34 +18,3 @@ */ #include "gs-helper.hpp" - -gs::context::context() -{ - obs_enter_graphics(); -} - -gs::context::~context() -{ - obs_leave_graphics(); -} - -#ifdef ENABLE_PROFILING -gs::debug_marker::debug_marker(const float color[4], const char* format, ...) -{ - std::size_t size; - std::vector buffer(64); - - va_list vargs; - va_start(vargs, format); - size = static_cast(vsnprintf(buffer.data(), buffer.size(), format, vargs)); - va_end(vargs); - - _name = std::string(buffer.data(), buffer.data() + size); - gs_debug_marker_begin(color, _name.c_str()); -} - -gs::debug_marker::~debug_marker() -{ - gs_debug_marker_end(); -} -#endif diff --git a/source/obs/gs/gs-helper.hpp b/source/obs/gs/gs-helper.hpp index 2ba788aa..437920fc 100644 --- a/source/obs/gs/gs-helper.hpp +++ b/source/obs/gs/gs-helper.hpp @@ -1,6 +1,6 @@ /* * Modern effects for a modern Streamer - * Copyright (C) 2017 Michael Fabian Dirks + * Copyright (C) 2020 Michael Fabian Dirks * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,8 +25,14 @@ namespace gs { class context { public: - context(); - ~context(); + inline context() + { + obs_enter_graphics(); + } + ~context() + { + obs_leave_graphics(); + } }; #ifdef ENABLE_PROFILING @@ -59,9 +65,24 @@ namespace gs { std::string _name; public: - //debug_marker(const float color[4], std::string name); - debug_marker(const float_t color[4], const char* format, ...); - ~debug_marker(); + inline debug_marker(const float_t color[4], const char* format, ...) + { + std::size_t size; + std::vector buffer(64); + + va_list vargs; + va_start(vargs, format); + size = static_cast(vsnprintf(buffer.data(), buffer.size(), format, vargs)); + va_end(vargs); + + _name = std::string(buffer.data(), buffer.data() + size); + gs_debug_marker_begin(color, _name.c_str()); + } + + inline ~debug_marker() + { + gs_debug_marker_end(); + } }; #endif } // namespace gs