2022-07-27 20:06:50 +02:00
|
|
|
// SPDX-FileCopyrightText: 2015 Citra Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-12-28 16:15:37 +01:00
|
|
|
|
2022-10-09 03:56:13 +02:00
|
|
|
#include <thread>
|
|
|
|
|
2020-12-28 16:15:37 +01:00
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/frontend/emu_window.h"
|
|
|
|
#include "video_core/renderer_base.h"
|
|
|
|
|
|
|
|
namespace VideoCore {
|
|
|
|
|
|
|
|
RendererBase::RendererBase(Core::Frontend::EmuWindow& window_,
|
|
|
|
std::unique_ptr<Core::Frontend::GraphicsContext> context_)
|
|
|
|
: render_window{window_}, context{std::move(context_)} {
|
|
|
|
RefreshBaseSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
RendererBase::~RendererBase() = default;
|
|
|
|
|
|
|
|
void RendererBase::RefreshBaseSettings() {
|
|
|
|
UpdateCurrentFramebufferLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RendererBase::UpdateCurrentFramebufferLayout() {
|
|
|
|
const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout();
|
|
|
|
|
|
|
|
render_window.UpdateCurrentFramebufferLayout(layout.width, layout.height);
|
|
|
|
}
|
|
|
|
|
2022-04-12 21:13:58 +02:00
|
|
|
bool RendererBase::IsScreenshotPending() const {
|
|
|
|
return renderer_settings.screenshot_requested;
|
|
|
|
}
|
|
|
|
|
2021-07-28 04:31:09 +02:00
|
|
|
void RendererBase::RequestScreenshot(void* data, std::function<void(bool)> callback,
|
2020-12-28 16:15:37 +01:00
|
|
|
const Layout::FramebufferLayout& layout) {
|
|
|
|
if (renderer_settings.screenshot_requested) {
|
|
|
|
LOG_ERROR(Render, "A screenshot is already requested or in progress, ignoring the request");
|
|
|
|
return;
|
|
|
|
}
|
2022-10-09 03:56:13 +02:00
|
|
|
auto async_callback{[callback = std::move(callback)](bool invert_y) {
|
|
|
|
std::thread t{callback, invert_y};
|
|
|
|
t.detach();
|
|
|
|
}};
|
2020-12-28 16:15:37 +01:00
|
|
|
renderer_settings.screenshot_bits = data;
|
2022-10-09 03:56:13 +02:00
|
|
|
renderer_settings.screenshot_complete_callback = async_callback;
|
2020-12-28 16:15:37 +01:00
|
|
|
renderer_settings.screenshot_framebuffer_layout = layout;
|
|
|
|
renderer_settings.screenshot_requested = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace VideoCore
|