azahar/src/video_core/renderer_base.cpp
David Griswold aca8b45664
android: Implement secondary display support (#617)
* Enable the SecondScreenPresentation class

* Update everything to enable second screen on android under GL and Vulkan. Still some issues!

* Some attempts to enable surface changes

* OpenGL is working on surface change, vulkan still no

* release surfaces (also fixed vulkan?)

* added and enabled layout setting

* resolve merge conflict

* rearrange switch cases to satisfy linux compiler

* openGL is working!

* several vk changes to try to fix crashes

* maybe vulkan is working?

* removing unnecessary code attempts

* Simplified secondscreen for better performance

* vk_platform.cpp: Fixed build failure caused by bad rebase

* vk_present_window.h: Removed stray newline

* Applied clang-format

* bug fix for odin 2

* Applied clang-format

* Updated license headers

* Moved SecondScreen class to org.citra.citra_emu.display

* Various formatting and readability improvements

* Added brackets where previously absent for readability

* Additional readability improvement

* RendererVulkan::NotifySurfaceChanged: Simplified condition checking

* change all references to "secondary screen" to "secondary display" to limit confusion with top screen / bottom screen

* rename main_window to main_present_window and second_window to secondary_present_window

* Reverted accidentally downgraded compatibility list submodule

* Removed unnecessary log message

* Applied clang-format

* Added a description to the Secondary Display Screen Layout setting

* Added `_ptr` suffix to `secondary_present_window`

This distinguishes it as a pointer, as `main_present_window` isn't a pointer, so there could be confusion on whether to use `.` or `->`

---------

Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
2025-08-08 21:41:52 +01:00

69 lines
2.4 KiB
C++

// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/settings.h"
#include "core/core.h"
#include "core/frontend/emu_window.h"
#include "core/tracer/recorder.h"
#include "video_core/debug_utils/debug_utils.h"
#include "video_core/renderer_base.h"
namespace VideoCore {
RendererBase::RendererBase(Core::System& system_, Frontend::EmuWindow& window,
Frontend::EmuWindow* secondary_window_)
: system{system_}, render_window{window}, secondary_window{secondary_window_} {}
RendererBase::~RendererBase() = default;
u32 RendererBase::GetResolutionScaleFactor() {
const auto graphics_api = Settings::values.graphics_api.GetValue();
if (graphics_api == Settings::GraphicsAPI::Software) {
// Software renderer always render at native resolution
return 1;
}
const u32 scale_factor = Settings::values.resolution_factor.GetValue();
return scale_factor != 0 ? scale_factor
: render_window.GetFramebufferLayout().GetScalingRatio();
}
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 != nullptr) {
update_layout(*secondary_window);
}
}
void RendererBase::EndFrame() {
current_frame++;
system.perf_stats->EndSystemFrame();
render_window.PollEvents();
system.frame_limiter.DoFrameLimiting(system.CoreTiming().GetGlobalTimeUs());
system.perf_stats->BeginSystemFrame();
}
bool RendererBase::IsScreenshotPending() const {
return settings.screenshot_requested;
}
void RendererBase::RequestScreenshot(void* data, std::function<void(bool)> callback,
const Layout::FramebufferLayout& layout) {
if (settings.screenshot_requested) {
LOG_ERROR(Render, "A screenshot is already requested or in progress, ignoring the request");
return;
}
settings.screenshot_bits = data;
settings.screenshot_complete_callback = callback;
settings.screenshot_framebuffer_layout = layout;
settings.screenshot_requested = true;
}
} // namespace VideoCore