citra/src/video_core/renderer_base.cpp

43 lines
1.5 KiB
C++

// Copyright 2015 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <memory>
#include "core/frontend/emu_window.h"
#include "video_core/renderer_base.h"
#include "video_core/renderer_opengl/gl_rasterizer.h"
#include "video_core/swrasterizer/swrasterizer.h"
#include "video_core/video_core.h"
RendererBase::RendererBase(Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window_)
: render_window{window}, secondary_window{secondary_window_} {}
RendererBase::~RendererBase() = default;
void RendererBase::UpdateCurrentFramebufferLayout(bool is_portrait_mode) {
const auto update_layout = [is_portrait_mode](Frontend::EmuWindow& window) {
const Layout::FramebufferLayout& layout = window.GetFramebufferLayout();
window.UpdateCurrentFramebufferLayout(layout.width, layout.height, is_portrait_mode);
};
update_layout(render_window);
if (secondary_window) {
update_layout(*secondary_window);
}
}
void RendererBase::RefreshRasterizerSetting() {
bool hw_renderer_enabled = VideoCore::g_hw_renderer_enabled;
if (rasterizer == nullptr || opengl_rasterizer_active != hw_renderer_enabled) {
opengl_rasterizer_active = hw_renderer_enabled;
if (hw_renderer_enabled) {
rasterizer = std::make_unique<OpenGL::RasterizerOpenGL>(render_window);
} else {
rasterizer = std::make_unique<VideoCore::SWRasterizer>();
}
}
}
void RendererBase::Sync() {
rasterizer->SyncEntireState();
}