gfx: Move util::SourceTexture to gfx::SourceTexture

'gfx' is the new preview for Graphics utilities that do not act as a wrapper around the Graphics Subsystem directly.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2018-03-08 11:28:23 +01:00
parent 53073660c0
commit 9f518764b6
5 changed files with 14 additions and 14 deletions

View File

@ -52,7 +52,7 @@ SET(obs-stream-effects_HEADERS
"${PROJECT_SOURCE_DIR}/source/strings.h"
"${PROJECT_SOURCE_DIR}/source/util-math.h"
"${PROJECT_SOURCE_DIR}/source/util-memory.h"
"${PROJECT_SOURCE_DIR}/source/util-source-texture.h"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.h"
)
SET(obs-stream-effects_SOURCES
"${PROJECT_SOURCE_DIR}/source/plugin.cpp"
@ -73,7 +73,7 @@ SET(obs-stream-effects_SOURCES
"${PROJECT_SOURCE_DIR}/source/gs-vertexbuffer.cpp"
"${PROJECT_SOURCE_DIR}/source/util-math.cpp"
"${PROJECT_SOURCE_DIR}/source/util-memory.cpp"
"${PROJECT_SOURCE_DIR}/source/util-source-texture.cpp"
"${PROJECT_SOURCE_DIR}/source/gfx-source-texture.cpp"
)
SET(obs-stream-effects_LOCALE
"${PROJECT_SOURCE_DIR}/data/locale/en-US.ini"

View File

@ -15,9 +15,9 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "util-source-texture.h"
#include "gfx-source-texture.h"
util::SourceTexture::~SourceTexture() {
gfx::SourceTexture::~SourceTexture() {
if (m_source) {
obs_source_release(m_source);
m_source = nullptr;
@ -25,31 +25,31 @@ util::SourceTexture::~SourceTexture() {
m_rt = nullptr;
}
util::SourceTexture::SourceTexture() {
gfx::SourceTexture::SourceTexture() {
m_rt = std::make_shared<GS::RenderTarget>(GS_RGBA, GS_ZS_NONE);
}
obs_source_t* util::SourceTexture::GetObject() {
obs_source_t* gfx::SourceTexture::GetObject() {
return m_source;
}
util::SourceTexture::SourceTexture(const char* name) : SourceTexture() {
gfx::SourceTexture::SourceTexture(const char* name) : SourceTexture() {
m_source = obs_get_source_by_name(name);
if (!m_source) {
throw std::invalid_argument("No such source.");
}
}
util::SourceTexture::SourceTexture(std::string name) : SourceTexture(name.c_str()) {}
gfx::SourceTexture::SourceTexture(std::string name) : SourceTexture(name.c_str()) {}
util::SourceTexture::SourceTexture(obs_source_t* src) : SourceTexture() {
gfx::SourceTexture::SourceTexture(obs_source_t* src) : SourceTexture() {
m_source = src;
if (!m_source) {
throw std::invalid_argument("No such source.");
}
}
std::shared_ptr<GS::Texture> util::SourceTexture::Render(size_t width, size_t height) {
std::shared_ptr<GS::Texture> gfx::SourceTexture::Render(size_t width, size_t height) {
if (!m_source) {
throw std::invalid_argument("Missing source to render.");
}

View File

@ -22,7 +22,7 @@
#include "gs-texture.h"
#include "gs-rendertarget.h"
namespace util {
namespace gfx {
class SourceTexture {
obs_source_t* m_source;
std::shared_ptr<GS::RenderTarget> m_rt;

View File

@ -233,7 +233,7 @@ void Source::Mirror::update(obs_data_t* data) {
const char* sourceName = obs_data_get_string(data, P_SOURCE);
if (sourceName != m_mirrorName) {
try {
m_mirrorSource = std::make_unique<util::SourceTexture>(sourceName);
m_mirrorSource = std::make_unique<gfx::SourceTexture>(sourceName);
m_mirrorName = sourceName;
} catch (...) {
}

View File

@ -21,7 +21,7 @@
#include "plugin.h"
#include "gs-rendertarget.h"
#include "gs-sampler.h"
#include "util-source-texture.h"
#include "gfx-source-texture.h"
#include <memory>
namespace Source {
@ -62,7 +62,7 @@ namespace Source {
std::shared_ptr<GS::Sampler> m_sampler;
gs_effect_t* m_scalingEffect = nullptr;
std::unique_ptr<util::SourceTexture> m_mirrorSource;
std::unique_ptr<gfx::SourceTexture> m_mirrorSource;
std::string m_mirrorName;
public: