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{ FramebufferLayout res{
width, height, true, true, {}, {}, !Settings::values.upright_screen, is_portrait_mode}; 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() const u16 top_x = is_portrait_mode ? Settings::values.custom_portrait_top_x.GetValue()
: Settings::values.custom_top_x.GetValue(); : Settings::values.custom_top_x.GetValue();
const u16 top_width = is_portrait_mode ? Settings::values.custom_portrait_top_width.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_rotated = true;
bool is_portrait = false; bool is_portrait = false;
bool additional_screen_enabled; bool additional_screen_enabled;
float top_opacity = 1.0f;
float bottom_opacity = 1.0f;
Common::Rectangle<u32> additional_screen; Common::Rectangle<u32> additional_screen;
CardboardSettings cardboard; CardboardSettings cardboard;
/** /**
* Returns the ratio of pixel size of the top screen, compared to the native size of the 3DS * Returns the ratio of pixel size of the top screen, compared to the native size of the 3DS
* screen. * screen.
*/ */
u32 GetScalingRatio() const; u32 GetScalingRatio() const;
static float GetAspectRatioValue(Settings::AspectRatio aspect_ratio); 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()) { if (!Settings::values.swap_screen.GetValue()) {
DrawTopScreen(layout, top_screen); DrawTopScreen(layout, top_screen);
glUniform1i(uniform_layer, 0); glUniform1i(uniform_layer, 0);
ApplySecondLayerOpacity(layout.is_portrait); ApplySecondLayerOpacity(layout.bottom_opacity);
DrawBottomScreen(layout, bottom_screen); DrawBottomScreen(layout, bottom_screen);
} else { } else {
DrawBottomScreen(layout, bottom_screen); DrawBottomScreen(layout, bottom_screen);
glUniform1i(uniform_layer, 0); glUniform1i(uniform_layer, 0);
ApplySecondLayerOpacity(layout.is_portrait); ApplySecondLayerOpacity(layout.top_opacity);
DrawTopScreen(layout, top_screen); DrawTopScreen(layout, top_screen);
} }
@ -706,29 +706,24 @@ void RendererOpenGL::DrawScreens(const Layout::FramebufferLayout& layout, bool f
DrawBottomScreen(layout, additional_screen); DrawBottomScreen(layout, additional_screen);
} }
} }
ResetSecondLayerOpacity(layout.is_portrait); ResetSecondLayerOpacity();
} }
void RendererOpenGL::ApplySecondLayerOpacity(bool isPortrait) { void RendererOpenGL::ApplySecondLayerOpacity(float opacity) {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
state.blend.src_rgb_func = GL_CONSTANT_ALPHA; state.blend.src_rgb_func = GL_CONSTANT_ALPHA;
state.blend.src_a_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_a_func = GL_ONE_MINUS_CONSTANT_ALPHA;
state.blend.dst_rgb_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) { void RendererOpenGL::ResetSecondLayerOpacity() {
if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::CustomLayout &&
Settings::values.custom_second_layer_opacity.GetValue() < 100) {
state.blend.src_rgb_func = GL_ONE; state.blend.src_rgb_func = GL_ONE;
state.blend.dst_rgb_func = GL_ZERO; state.blend.dst_rgb_func = GL_ZERO;
state.blend.src_a_func = GL_ONE; state.blend.src_a_func = GL_ONE;
state.blend.dst_a_func = GL_ZERO; state.blend.dst_a_func = GL_ZERO;
state.blend.color.alpha = 0.0f; state.blend.color.alpha = 0.0f;
}
} }
void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout, void RendererOpenGL::DrawTopScreen(const Layout::FramebufferLayout& layout,

View File

@ -65,8 +65,8 @@ private:
const Pica::FramebufferConfig& framebuffer, const Pica::FramebufferConfig& framebuffer,
const Pica::ColorFill& color_fill); const Pica::ColorFill& color_fill);
void DrawScreens(const Layout::FramebufferLayout& layout, bool flipped); void DrawScreens(const Layout::FramebufferLayout& layout, bool flipped);
void ApplySecondLayerOpacity(bool isPortrait = false); void ApplySecondLayerOpacity(float opacity = 1.0f);
void ResetSecondLayerOpacity(bool isPortrait = false); void ResetSecondLayerOpacity();
void DrawBottomScreen(const Layout::FramebufferLayout& layout, void DrawBottomScreen(const Layout::FramebufferLayout& layout,
const Common::Rectangle<u32>& bottom_screen); const Common::Rectangle<u32>& bottom_screen);
void DrawTopScreen(const Layout::FramebufferLayout& layout, 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 // Apply the initial default opacity value; Needed to avoid flickering
ApplySecondLayerOpacity(1.0f); 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()) { if (!Settings::values.swap_screen.GetValue()) {
DrawTopScreen(layout, top_screen); DrawTopScreen(layout, top_screen);
draw_info.layer = 0; draw_info.layer = 0;
if (use_custom_opacity) { if (layout.bottom_opacity < 1) {
ApplySecondLayerOpacity(second_alpha); ApplySecondLayerOpacity(layout.bottom_opacity);
} }
DrawBottomScreen(layout, bottom_screen); DrawBottomScreen(layout, bottom_screen);
} else { } else {
DrawBottomScreen(layout, bottom_screen); DrawBottomScreen(layout, bottom_screen);
draw_info.layer = 0; draw_info.layer = 0;
if (use_custom_opacity) { if (layout.top_opacity < 1) {
ApplySecondLayerOpacity(second_alpha); ApplySecondLayerOpacity(layout.top_opacity);
} }
DrawTopScreen(layout, top_screen); DrawTopScreen(layout, top_screen);
} }