mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-04-24 15:07:27 -05:00
Revert "Try reducing the amount of structures used (will revert if no performance improvements are observed)"
Performance does not improve, and it leads to very annoying/confusing data management...
This commit is contained in:
parent
9fb31f8495
commit
1f478b5a3b
|
|
@ -142,7 +142,8 @@ private:
|
|||
volatile bool scheduled_work_on_window;
|
||||
volatile bool is_thread_done;
|
||||
|
||||
sf::RectangleShape m_out_rect_top, m_out_rect_bot;
|
||||
sf::RectangleShape m_in_rect_top, m_in_rect_bot;
|
||||
out_rect_data m_out_rect_top, m_out_rect_bot;
|
||||
ScreenType m_stype;
|
||||
|
||||
std::queue<SFEvent> events_queue;
|
||||
|
|
@ -167,7 +168,7 @@ private:
|
|||
static void reset_operations(ScreenOperations &operations);
|
||||
void free_ownership_of_window(bool is_main_thread);
|
||||
|
||||
void resize_in_tex_rect(sf::RectangleShape &rect, int start_x, int start_y, int width, int height);
|
||||
void resize_in_rect(sf::RectangleShape &in_rect, int start_x, int start_y, int width, int height);
|
||||
int get_screen_corner_modifier_x(int rotation, int width);
|
||||
int get_screen_corner_modifier_y(int rotation, int height);
|
||||
void print_notification_on_off(std::string base_text, bool value);
|
||||
|
|
@ -199,8 +200,9 @@ private:
|
|||
bool window_needs_work();
|
||||
void window_factory(bool is_main_thread);
|
||||
void pre_texture_conversion_processing();
|
||||
void post_texture_conversion_processing(out_rect_data &rect_data, const sf::RectangleShape &in_rect, bool actually_draw, bool is_top, bool is_debug);
|
||||
void window_bg_processing();
|
||||
void display_data_to_window(bool actually_draw);
|
||||
void display_data_to_window(bool actually_draw, bool is_debug = false);
|
||||
void window_render_call();
|
||||
void set_position_screens(sf::Vector2f &curr_top_screen_size, sf::Vector2f &curr_bot_screen_size, int offset_x, int offset_y, int max_x, int max_y, bool do_work = true);
|
||||
int prepare_screen_ratio(sf::Vector2f &screen_size, int own_rotation, int width_limit, int height_limit, int other_rotation, const PARData *own_par);
|
||||
|
|
@ -215,7 +217,7 @@ private:
|
|||
void open();
|
||||
void update_screen_settings();
|
||||
void rotate();
|
||||
sf::Vector2f getShownScreenSize(bool is_top, int &crop_kind, bool swap = false);
|
||||
sf::Vector2f getShownScreenSize(bool is_top, int &crop_kind);
|
||||
void crop();
|
||||
void setWinSize(bool is_main_thread);
|
||||
void setup_main_menu(bool reset_data = true);
|
||||
|
|
@ -254,8 +256,8 @@ void reset_fullscreen_info(ScreenInfo &info);
|
|||
void reset_screen_info(ScreenInfo &info);
|
||||
bool load_screen_info(std::string key, std::string value, std::string base, ScreenInfo &info);
|
||||
std::string save_screen_info(std::string base, const ScreenInfo &info);
|
||||
void get_par_size(float &width, float &height, float multiplier_factor, const PARData *correction_factor, bool swapped = true);
|
||||
void get_par_size(int &width, int &height, float multiplier_factor, const PARData *correction_factor, bool swapped = true);
|
||||
void get_par_size(float &width, float &height, float multiplier_factor, const PARData *correction_factor);
|
||||
void get_par_size(int &width, int &height, float multiplier_factor, const PARData *correction_factor);
|
||||
void default_sleep();
|
||||
void update_output(FrontendData* frontend_data, double frame_time = 0.0, VideoOutputData *out_buf = NULL);
|
||||
void screen_display_thread(WindowScreen *screen);
|
||||
|
|
|
|||
|
|
@ -109,10 +109,10 @@ void RotationMenu::prepare(float menu_scaling_factor, int view_size_x, int view_
|
|||
int option_index = this->options_indexes[real_index];
|
||||
switch(pollable_options[option_index]->out_action) {
|
||||
case ROTATION_MENU_TOP_ROTATION_DEC:
|
||||
this->labels[index]->setText(this->setTextOptionInt(real_index, (info->top_rotation + 90) % 360));
|
||||
this->labels[index]->setText(this->setTextOptionInt(real_index, info->top_rotation));
|
||||
break;
|
||||
case ROTATION_MENU_BOTTOM_ROTATION_DEC:
|
||||
this->labels[index]->setText(this->setTextOptionInt(real_index, (info->bot_rotation + 90) % 360));
|
||||
this->labels[index]->setText(this->setTextOptionInt(real_index, info->bot_rotation));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ WindowScreen::WindowScreen(ScreenType stype, CaptureStatus* capture_status, Disp
|
|||
FPSArrayInit(&this->draw_fps);
|
||||
FPSArrayInit(&this->poll_fps);
|
||||
this->in_tex.create(IN_VIDEO_WIDTH, IN_VIDEO_HEIGHT);
|
||||
this->m_in_rect_top.setTexture(&this->in_tex);
|
||||
this->m_in_rect_bot.setTexture(&this->in_tex);
|
||||
this->display_data = display_data;
|
||||
this->audio_data = audio_data;
|
||||
this->last_window_creation_time = std::chrono::high_resolution_clock::now();
|
||||
|
|
@ -71,11 +73,13 @@ void WindowScreen::build() {
|
|||
|
||||
this->reload();
|
||||
|
||||
this->m_out_rect_top.setSize(top_screen_size);
|
||||
this->m_out_rect_top.setTexture(&this->in_tex);
|
||||
this->m_out_rect_top.out_tex.create(top_screen_size.x, top_screen_size.y);
|
||||
this->m_out_rect_top.out_rect.setSize(top_screen_size);
|
||||
this->m_out_rect_top.out_rect.setTexture(&this->m_out_rect_top.out_tex.getTexture());
|
||||
|
||||
this->m_out_rect_bot.setSize(bot_screen_size);
|
||||
this->m_out_rect_bot.setTexture(&this->in_tex);
|
||||
this->m_out_rect_bot.out_tex.create(bot_screen_size.x, bot_screen_size.y);
|
||||
this->m_out_rect_bot.out_rect.setSize(bot_screen_size);
|
||||
this->m_out_rect_bot.out_rect.setTexture(&this->m_out_rect_bot.out_tex.getTexture());
|
||||
|
||||
this->m_view.setRotation(0);
|
||||
}
|
||||
|
|
@ -230,8 +234,14 @@ void WindowScreen::free_ownership_of_window(bool is_main_thread) {
|
|||
}
|
||||
}
|
||||
|
||||
void WindowScreen::resize_in_tex_rect(sf::RectangleShape &rect, int start_x, int start_y, int width, int height) {
|
||||
rect.setTextureRect(sf::IntRect(start_y, start_x, height, width));
|
||||
void WindowScreen::resize_in_rect(sf::RectangleShape &in_rect, int start_x, int start_y, int width, int height) {
|
||||
in_rect.setTextureRect(sf::IntRect(start_y, start_x, height, width));
|
||||
|
||||
in_rect.setSize(sf::Vector2f(height, width));
|
||||
in_rect.setOrigin(height / 2, width / 2);
|
||||
|
||||
in_rect.setRotation(-90);
|
||||
in_rect.setPosition(width / 2, height / 2);
|
||||
}
|
||||
|
||||
int WindowScreen::get_screen_corner_modifier_x(int rotation, int width) {
|
||||
|
|
@ -267,7 +277,8 @@ void WindowScreen::print_notification_float(std::string base_text, float value,
|
|||
|
||||
void WindowScreen::prepare_screen_rendering() {
|
||||
if(loaded_operations.call_blur) {
|
||||
this->in_tex.setSmooth(this->loaded_info.is_blurred);
|
||||
this->m_out_rect_top.out_tex.setSmooth(this->loaded_info.is_blurred);
|
||||
this->m_out_rect_bot.out_tex.setSmooth(this->loaded_info.is_blurred);
|
||||
}
|
||||
if(loaded_operations.call_crop) {
|
||||
this->crop();
|
||||
|
|
@ -350,18 +361,46 @@ void WindowScreen::pre_texture_conversion_processing() {
|
|||
this->in_tex.update((uint8_t*)this->saved_buf, IN_VIDEO_WIDTH, IN_VIDEO_HEIGHT, 0, 0);
|
||||
}
|
||||
|
||||
void WindowScreen::post_texture_conversion_processing(out_rect_data &rect_data, const sf::RectangleShape &in_rect, bool actually_draw, bool is_top, bool is_debug) {
|
||||
if((is_top && this->m_stype == ScreenType::BOTTOM) || ((!is_top) && this->m_stype == ScreenType::TOP))
|
||||
return;
|
||||
if(this->loaded_menu == CONNECT_MENU_TYPE)
|
||||
return;
|
||||
|
||||
if(is_debug) {
|
||||
if(is_top)
|
||||
rect_data.out_tex.clear(sf::Color::Red);
|
||||
else
|
||||
rect_data.out_tex.clear(sf::Color::Blue);
|
||||
}
|
||||
else {
|
||||
rect_data.out_tex.clear();
|
||||
if(actually_draw) {
|
||||
rect_data.out_tex.draw(in_rect);
|
||||
//Place postprocessing effects here
|
||||
}
|
||||
}
|
||||
rect_data.out_tex.display();
|
||||
}
|
||||
|
||||
void WindowScreen::window_bg_processing() {
|
||||
//Place BG processing here
|
||||
}
|
||||
|
||||
void WindowScreen::display_data_to_window(bool actually_draw) {
|
||||
this->m_win.clear();
|
||||
void WindowScreen::display_data_to_window(bool actually_draw, bool is_debug) {
|
||||
this->post_texture_conversion_processing(this->m_out_rect_top, this->m_in_rect_top, actually_draw, true, is_debug);
|
||||
this->post_texture_conversion_processing(this->m_out_rect_bot, this->m_in_rect_bot, actually_draw, false, is_debug);
|
||||
|
||||
if(is_debug)
|
||||
this->m_win.clear(sf::Color::Green);
|
||||
else
|
||||
this->m_win.clear();
|
||||
this->window_bg_processing();
|
||||
if(this->loaded_menu != CONNECT_MENU_TYPE) {
|
||||
if(this->m_stype != ScreenType::BOTTOM)
|
||||
this->m_win.draw(this->m_out_rect_top);
|
||||
this->m_win.draw(this->m_out_rect_top.out_rect);
|
||||
if(this->m_stype != ScreenType::TOP)
|
||||
this->m_win.draw(this->m_out_rect_bot);
|
||||
this->m_win.draw(this->m_out_rect_bot.out_rect);
|
||||
}
|
||||
this->execute_menu_draws();
|
||||
this->notification->draw(this->m_win);
|
||||
|
|
@ -465,8 +504,8 @@ void WindowScreen::set_position_screens(sf::Vector2f &curr_top_screen_size, sf::
|
|||
}
|
||||
}
|
||||
if(do_work) {
|
||||
this->m_out_rect_top.setPosition(top_screen_x + offset_x + get_screen_corner_modifier_x(this->loaded_info.top_rotation, top_screen_width), top_screen_y + offset_y + get_screen_corner_modifier_y(this->loaded_info.top_rotation, top_screen_height));
|
||||
this->m_out_rect_bot.setPosition(bot_screen_x + offset_x + get_screen_corner_modifier_x(this->loaded_info.bot_rotation, bot_screen_width), bot_screen_y + offset_y + get_screen_corner_modifier_y(this->loaded_info.bot_rotation, bot_screen_height));
|
||||
this->m_out_rect_top.out_rect.setPosition(top_screen_x + offset_x + get_screen_corner_modifier_x(this->loaded_info.top_rotation, top_screen_width), top_screen_y + offset_y + get_screen_corner_modifier_y(this->loaded_info.top_rotation, top_screen_height));
|
||||
this->m_out_rect_bot.out_rect.setPosition(bot_screen_x + offset_x + get_screen_corner_modifier_x(this->loaded_info.bot_rotation, bot_screen_width), bot_screen_y + offset_y + get_screen_corner_modifier_y(this->loaded_info.bot_rotation, bot_screen_height));
|
||||
}
|
||||
|
||||
int top_end_x = top_screen_x + offset_x + top_screen_width;
|
||||
|
|
@ -560,8 +599,8 @@ void WindowScreen::prepare_size_ratios(bool top_increase, bool bot_increase) {
|
|||
if(!this->m_info.is_fullscreen)
|
||||
return;
|
||||
|
||||
sf::Vector2f top_screen_size = getShownScreenSize(true, this->m_info.crop_kind, true);
|
||||
sf::Vector2f bot_screen_size = getShownScreenSize(false, this->m_info.crop_kind, true);
|
||||
sf::Vector2f top_screen_size = getShownScreenSize(true, this->m_info.crop_kind);
|
||||
sf::Vector2f bot_screen_size = getShownScreenSize(false, this->m_info.crop_kind);
|
||||
|
||||
if(this->m_stype == ScreenType::TOP) {
|
||||
bot_increase = true;
|
||||
|
|
@ -632,8 +671,8 @@ int WindowScreen::get_fullscreen_offset_y(int top_width, int top_height, int bot
|
|||
}
|
||||
|
||||
void WindowScreen::resize_window_and_out_rects(bool do_work) {
|
||||
sf::Vector2f top_screen_size = getShownScreenSize(true, this->loaded_info.crop_kind, true);
|
||||
sf::Vector2f bot_screen_size = getShownScreenSize(false, this->loaded_info.crop_kind, true);
|
||||
sf::Vector2f top_screen_size = getShownScreenSize(true, this->loaded_info.crop_kind);
|
||||
sf::Vector2f bot_screen_size = getShownScreenSize(false, this->loaded_info.crop_kind);
|
||||
int top_width = top_screen_size.x;
|
||||
int top_height = top_screen_size.y;
|
||||
float top_scaling = this->loaded_info.scaling;
|
||||
|
|
@ -666,8 +705,10 @@ void WindowScreen::resize_window_and_out_rects(bool do_work) {
|
|||
sf::Vector2f new_top_screen_size = sf::Vector2f(top_width, top_height);
|
||||
sf::Vector2f new_bot_screen_size = sf::Vector2f(bot_width, bot_height);
|
||||
if(do_work) {
|
||||
this->m_out_rect_top.setSize(new_top_screen_size);
|
||||
this->m_out_rect_bot.setSize(new_bot_screen_size);
|
||||
this->m_out_rect_top.out_rect.setSize(new_top_screen_size);
|
||||
this->m_out_rect_top.out_rect.setTextureRect(sf::IntRect(0, 0, top_screen_size.x, top_screen_size.y));
|
||||
this->m_out_rect_bot.out_rect.setSize(new_bot_screen_size);
|
||||
this->m_out_rect_bot.out_rect.setTextureRect(sf::IntRect(0, 0, bot_screen_size.x, bot_screen_size.y));
|
||||
}
|
||||
this->set_position_screens(new_top_screen_size, new_bot_screen_size, offset_x, offset_y, max_x, max_y, do_work);
|
||||
if((!this->loaded_info.is_fullscreen) && this->loaded_info.rounded_corners_fix) {
|
||||
|
|
@ -735,12 +776,12 @@ void WindowScreen::update_screen_settings() {
|
|||
}
|
||||
|
||||
void WindowScreen::rotate() {
|
||||
this->m_out_rect_top.setRotation(this->loaded_info.top_rotation);
|
||||
this->m_out_rect_bot.setRotation(this->loaded_info.bot_rotation);
|
||||
this->m_out_rect_top.out_rect.setRotation(this->loaded_info.top_rotation);
|
||||
this->m_out_rect_bot.out_rect.setRotation(this->loaded_info.bot_rotation);
|
||||
this->loaded_operations.call_screen_settings_update = true;
|
||||
}
|
||||
|
||||
sf::Vector2f WindowScreen::getShownScreenSize(bool is_top, int &crop_kind, bool swap) {
|
||||
sf::Vector2f WindowScreen::getShownScreenSize(bool is_top, int &crop_kind) {
|
||||
if(crop_kind >= this->possible_crops.size())
|
||||
crop_kind = 0;
|
||||
int width = this->possible_crops[crop_kind]->top_width;
|
||||
|
|
@ -749,8 +790,6 @@ sf::Vector2f WindowScreen::getShownScreenSize(bool is_top, int &crop_kind, bool
|
|||
width = this->possible_crops[crop_kind]->bot_width;
|
||||
height = this->possible_crops[crop_kind]->bot_height;
|
||||
}
|
||||
if(swap)
|
||||
return sf::Vector2f(height, width);
|
||||
return sf::Vector2f(width, height);
|
||||
}
|
||||
|
||||
|
|
@ -761,8 +800,8 @@ void WindowScreen::crop() {
|
|||
sf::Vector2f top_screen_size = getShownScreenSize(true, this->loaded_info.crop_kind);
|
||||
sf::Vector2f bot_screen_size = getShownScreenSize(false, this->loaded_info.crop_kind);
|
||||
|
||||
this->resize_in_tex_rect(this->m_out_rect_top, this->possible_crops[this->loaded_info.crop_kind]->top_x, this->possible_crops[this->loaded_info.crop_kind]->top_y, top_screen_size.x, top_screen_size.y);
|
||||
this->resize_in_tex_rect(this->m_out_rect_bot, TOP_WIDTH_3DS + this->possible_crops[this->loaded_info.crop_kind]->bot_x, this->possible_crops[this->loaded_info.crop_kind]->bot_y, bot_screen_size.x, bot_screen_size.y);
|
||||
this->resize_in_rect(this->m_in_rect_top, this->possible_crops[this->loaded_info.crop_kind]->top_x, this->possible_crops[this->loaded_info.crop_kind]->top_y, top_screen_size.x, top_screen_size.y);
|
||||
this->resize_in_rect(this->m_in_rect_bot, TOP_WIDTH_3DS + this->possible_crops[this->loaded_info.crop_kind]->bot_x, this->possible_crops[this->loaded_info.crop_kind]->bot_y, bot_screen_size.x, bot_screen_size.y);
|
||||
this->loaded_operations.call_screen_settings_update = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,14 +248,12 @@ bool load_screen_info(std::string key, std::string value, std::string base, Scre
|
|||
}
|
||||
if(key == (base + "top_rot")) {
|
||||
info.top_rotation = std::stoi(value);
|
||||
info.top_rotation += 270;
|
||||
info.top_rotation %= 360;
|
||||
info.top_rotation += (info.top_rotation < 0) ? 360 : 0;
|
||||
return true;
|
||||
}
|
||||
if(key == (base + "bot_rot")) {
|
||||
info.bot_rotation = std::stoi(value);
|
||||
info.bot_rotation += 270;
|
||||
info.bot_rotation %= 360;
|
||||
info.bot_rotation += (info.bot_rotation < 0) ? 360 : 0;
|
||||
return true;
|
||||
|
|
@ -344,8 +342,8 @@ std::string save_screen_info(std::string base, const ScreenInfo &info) {
|
|||
out += base + "sub_att_off=" + std::to_string(info.subscreen_attached_offset) + "\n";
|
||||
out += base + "off_x=" + std::to_string(info.total_offset_x) + "\n";
|
||||
out += base + "off_y=" + std::to_string(info.total_offset_y) + "\n";
|
||||
out += base + "top_rot=" + std::to_string((info.top_rotation + 90) % 360) + "\n";
|
||||
out += base + "bot_rot=" + std::to_string((info.bot_rotation + 90) % 360) + "\n";
|
||||
out += base + "top_rot=" + std::to_string(info.top_rotation) + "\n";
|
||||
out += base + "bot_rot=" + std::to_string(info.bot_rotation) + "\n";
|
||||
out += base + "vsync=" + std::to_string(info.v_sync_enabled) + "\n";
|
||||
out += base + "async=" + std::to_string(info.async) + "\n";
|
||||
out += base + "top_scaling=" + std::to_string(info.top_scaling) + "\n";
|
||||
|
|
@ -375,38 +373,23 @@ void joystick_axis_poll(std::queue<SFEvent> &events_queue) {
|
|||
}
|
||||
}
|
||||
|
||||
void get_par_size(int &width, int &height, float multiplier_factor, const PARData *correction_factor, bool swapped) {
|
||||
void get_par_size(int &width, int &height, float multiplier_factor, const PARData *correction_factor) {
|
||||
width *= multiplier_factor;
|
||||
height *= multiplier_factor;
|
||||
if(!swapped) {
|
||||
if(correction_factor->is_width_main)
|
||||
width = (width * correction_factor->width_multiplier) / correction_factor->width_divisor;
|
||||
else
|
||||
height = (height * correction_factor->width_divisor) / correction_factor->width_multiplier;
|
||||
}
|
||||
else {
|
||||
if(correction_factor->is_width_main)
|
||||
height = (height * correction_factor->width_multiplier) / correction_factor->width_divisor;
|
||||
else
|
||||
width = (width * correction_factor->width_divisor) / correction_factor->width_multiplier;
|
||||
}
|
||||
if(correction_factor->is_width_main)
|
||||
width = (width * correction_factor->width_multiplier) / correction_factor->width_divisor;
|
||||
else
|
||||
height = (height * correction_factor->width_divisor) / correction_factor->width_multiplier;
|
||||
}
|
||||
|
||||
void get_par_size(float &width, float &height, float multiplier_factor, const PARData *correction_factor, bool swapped) {
|
||||
void get_par_size(float &width, float &height, float multiplier_factor, const PARData *correction_factor) {
|
||||
width *= multiplier_factor;
|
||||
height *= multiplier_factor;
|
||||
if(!swapped) {
|
||||
if(correction_factor->is_width_main)
|
||||
width = (width * correction_factor->width_multiplier) / correction_factor->width_divisor;
|
||||
else
|
||||
height = (height * correction_factor->width_divisor) / correction_factor->width_multiplier;
|
||||
}
|
||||
else {
|
||||
if(correction_factor->is_width_main)
|
||||
height = (height * correction_factor->width_multiplier) / correction_factor->width_divisor;
|
||||
else
|
||||
width = (width * correction_factor->width_divisor) / correction_factor->width_multiplier;
|
||||
if(correction_factor->is_width_main) {
|
||||
width = (width * correction_factor->width_multiplier) / correction_factor->width_divisor;
|
||||
}
|
||||
else
|
||||
height = (height * correction_factor->width_divisor) / correction_factor->width_multiplier;
|
||||
}
|
||||
|
||||
JoystickDirection get_joystick_direction(uint32_t joystickId, sf::Joystick::Axis axis, float position) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user