This commit is contained in:
David Griswold 2025-12-09 14:54:59 -05:00 committed by GitHub
commit ef136755fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 26 deletions

View File

@ -365,6 +365,12 @@ FramebufferLayout CustomFrameLayout(u32 width, u32 height, bool is_swapped, bool
}
FramebufferLayout res{
width, height, true, true, {}, {}, !Settings::values.upright_screen, is_portrait_mode};
float opacity_value = Settings::values.custom_second_layer_opacity.GetValue() / 100.0f;
if (!is_portrait_mode && opacity_value < 1) {
is_swapped ? res.top_opacity = opacity_value : res.bottom_opacity = opacity_value;
}
const u16 top_x = is_portrait_mode ? Settings::values.custom_portrait_top_x.GetValue()
: Settings::values.custom_top_x.GetValue();
const u16 top_width = is_portrait_mode ? Settings::values.custom_portrait_top_width.GetValue()

View File

@ -35,16 +35,20 @@ struct FramebufferLayout {
bool is_rotated = true;
bool is_portrait = false;
bool additional_screen_enabled;
float top_opacity = 1.0f;
float bottom_opacity = 1.0f;
Common::Rectangle<u32> additional_screen;
CardboardSettings cardboard;
/**
/**
* Returns the ratio of pixel size of the top screen, compared to the native size of the 3DS
* screen.
*/
u32 GetScalingRatio() const;
static float GetAspectRatioValue(Settings::AspectRatio aspect_ratio);
};

View File

@ -689,12 +689,12 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
if (!Settings::values.swap_screen.GetValue()) {
DrawTopScreen(layout, top_screen);
glUniform1i(uniform_layer, 0);
ApplySecondLayerOpacity(layout.is_portrait);
ApplySecondLayerOpacity(layout.bottom_opacity);
DrawBottomScreen(layout, bottom_screen);
} else {
DrawBottomScreen(layout, bottom_screen);
glUniform1i(uniform_layer, 0);
ApplySecondLayerOpacity(layout.is_portrait);
ApplySecondLayerOpacity(layout.top_opacity);
DrawTopScreen(layout, top_screen);
}
@ -706,29 +706,24 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
DrawBottomScreen(layout, additional_screen);
}
}
ResetSecondLayerOpacity(layout.is_portrait);
ResetSecondLayerOpacity();
}
void RendererOpenGL::ApplySecondLayerOpacity(bool isPortrait) {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
void RendererOpenGL::ApplySecondLayerOpacity(float opacity) {
state.blend.src_rgb_func = GL_CONSTANT_ALPHA;
state.blend.src_a_func = GL_CONSTANT_ALPHA;
state.blend.dst_a_func = GL_ONE_MINUS_CONSTANT_ALPHA;
state.blend.dst_rgb_func = GL_ONE_MINUS_CONSTANT_ALPHA;
state.blend.color.alpha = Settings::values.custom_second_layer_opacity.GetValue() / 100.0f;
}
state.blend.color.alpha = opacity;
}
void RendererOpenGL::ResetSecondLayerOpacity(bool isPortrait) {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
void RendererOpenGL::ResetSecondLayerOpacity() {
state.blend.src_rgb_func = GL_ONE;
state.blend.dst_rgb_func = GL_ZERO;
state.blend.src_a_func = GL_ONE;
state.blend.dst_a_func = GL_ZERO;
state.blend.color.alpha = 0.0f;
}
}
void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout,

View File

@ -65,8 +65,8 @@ private:
const Pica::FramebufferConfig& framebuffer,
const Pica::ColorFill& color_fill);
void DrawScreens(const Layout::FramebufferLayout& layout, bool flipped);
void ApplySecondLayerOpacity(bool isPortrait = false);
void ResetSecondLayerOpacity(bool isPortrait = false);
void ApplySecondLayerOpacity(float opacity = 1.0f);
void ResetSecondLayerOpacity();
void DrawBottomScreen(const Layout::FramebufferLayout& layout,
const Common::Rectangle<u32>& bottom_screen);
void DrawTopScreen(const Layout::FramebufferLayout& layout,

View File

@ -885,25 +885,18 @@ void RendererVulkan::DrawScreens(Frame* frame, const Layout::FramebufferLayout&
// Apply the initial default opacity value; Needed to avoid flickering
ApplySecondLayerOpacity(1.0f);
bool use_custom_opacity =
Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
Settings::values.custom_second_layer_opacity.GetValue() < 100;
float second_alpha = use_custom_opacity
? Settings::values.custom_second_layer_opacity.GetValue() / 100.0f
: 1.0f;
if (!Settings::values.swap_screen.GetValue()) {
DrawTopScreen(layout, top_screen);
draw_info.layer = 0;
if (use_custom_opacity) {
ApplySecondLayerOpacity(second_alpha);
if (layout.bottom_opacity < 1) {
ApplySecondLayerOpacity(layout.bottom_opacity);
}
DrawBottomScreen(layout, bottom_screen);
} else {
DrawBottomScreen(layout, bottom_screen);
draw_info.layer = 0;
if (use_custom_opacity) {
ApplySecondLayerOpacity(second_alpha);
if (layout.top_opacity < 1) {
ApplySecondLayerOpacity(layout.top_opacity);
}
DrawTopScreen(layout, top_screen);
}