(drivers_font) More untangling of video_info

This commit is contained in:
twinaphex 2020-03-07 05:48:21 +01:00
parent f3c6799b4e
commit e8ff0fddca
3 changed files with 33 additions and 21 deletions

View File

@ -32,6 +32,7 @@
#include "../common/win32_common.h" #include "../common/win32_common.h"
#include "../font_driver.h" #include "../font_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h" #include "../../verbosity.h"
@ -97,8 +98,14 @@ static void gdi_render_msg(
gdi_raster_t *font = (gdi_raster_t*)data; gdi_raster_t *font = (gdi_raster_t*)data;
unsigned width = video_info->width; unsigned width = video_info->width;
unsigned height = video_info->height; unsigned height = video_info->height;
SIZE textSize = {0}; SIZE textSize = {0};
struct string_list *msg_list = NULL; struct string_list *msg_list = NULL;
settings_t *settings = config_get_ptr();
float video_msg_pos_x = settings->floats.video_msg_pos_x;
float video_msg_pos_y = settings->floats.video_msg_pos_y;
float video_msg_color_r = settings->floats.video_msg_color_r;
float video_msg_color_g = settings->floats.video_msg_color_g;
float video_msg_color_b = settings->floats.video_msg_color_b;
if (!font || string_is_empty(msg) || !font->gdi) if (!font || string_is_empty(msg) || !font->gdi)
return; return;
@ -120,17 +127,17 @@ static void gdi_render_msg(
} }
else else
{ {
x = video_info->font_msg_pos_x; x = video_msg_pos_x;
y = video_info->font_msg_pos_y; y = video_msg_pos_y;
drop_x = -2; drop_x = -2;
drop_y = -2; drop_y = -2;
drop_mod = 0.3f; drop_mod = 0.3f;
drop_alpha = 1.0f; drop_alpha = 1.0f;
scale = 1.0f; scale = 1.0f;
align = TEXT_ALIGN_LEFT; align = TEXT_ALIGN_LEFT;
red = video_info->font_msg_color_r * 255.0f; red = video_msg_color_r * 255.0f;
green = video_info->font_msg_color_g * 255.0f; green = video_msg_color_g * 255.0f;
blue = video_info->font_msg_color_b * 255.0f; blue = video_msg_color_b * 255.0f;
} }
msg_strlen = strlen(msg); msg_strlen = strlen(msg);
@ -140,19 +147,19 @@ static void gdi_render_msg(
switch (align) switch (align)
{ {
case TEXT_ALIGN_LEFT: case TEXT_ALIGN_LEFT:
newX = x * width * scale; newX = x * width * scale;
newDropX = drop_x * width * scale; newDropX = drop_x * width * scale;
break; break;
case TEXT_ALIGN_RIGHT: case TEXT_ALIGN_RIGHT:
newX = (x * width * scale) - textSize.cx; newX = (x * width * scale) - textSize.cx;
newDropX = (drop_x * width * scale) - textSize.cx; newDropX = (drop_x * width * scale) - textSize.cx;
break; break;
case TEXT_ALIGN_CENTER: case TEXT_ALIGN_CENTER:
newX = (x * width * scale) - (textSize.cx / 2); newX = (x * width * scale) - (textSize.cx / 2);
newDropX = (drop_x * width * scale) - (textSize.cx / 2); newDropX = (drop_x * width * scale) - (textSize.cx / 2);
break; break;
default: default:
newX = 0; newX = 0;
newDropX = 0; newDropX = 0;
break; break;
} }

View File

@ -24,6 +24,7 @@
#endif #endif
#include "../font_driver.h" #include "../font_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h" #include "../../verbosity.h"
#include "../common/sixel_common.h" #include "../common/sixel_common.h"
@ -83,25 +84,25 @@ static void sixel_render_msg(video_frame_info_t *video_info,
unsigned newX, newY; unsigned newX, newY;
unsigned align; unsigned align;
sixel_raster_t *font = (sixel_raster_t*)data; sixel_raster_t *font = (sixel_raster_t*)data;
const struct font_params *params = (const struct font_params*)userdata; const struct font_params *params = (const struct font_params*)userdata;
settings_t *settings = config_get_ptr();
(void)newX; float video_msg_pos_x = settings->floats.video_msg_pos_x;
(void)newY; float video_msg_pos_y = settings->floats.video_msg_pos_y;
if (!font || string_is_empty(msg)) if (!font || string_is_empty(msg))
return; return;
if (params) if (params)
{ {
x = params->x; x = params->x;
y = params->y; y = params->y;
scale = params->scale; scale = params->scale;
align = params->text_align; align = params->text_align;
} }
else else
{ {
x = video_info->font_msg_pos_x; x = video_msg_pos_x;
y = video_info->font_msg_pos_y; y = video_msg_pos_y;
scale = 1.0f; scale = 1.0f;
align = TEXT_ALIGN_LEFT; align = TEXT_ALIGN_LEFT;
} }

View File

@ -23,6 +23,7 @@
#endif #endif
#include "../font_driver.h" #include "../font_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h" #include "../../verbosity.h"
#include "../common/vga_common.h" #include "../common/vga_common.h"
@ -84,6 +85,9 @@ static void vga_render_msg(video_frame_info_t *video_info,
unsigned newX, newY; unsigned newX, newY;
unsigned align; unsigned align;
vga_raster_t *font = (vga_raster_t*)data; vga_raster_t *font = (vga_raster_t*)data;
settings_t *settings = config_get_ptr();
float video_msg_pos_x = settings->floats.video_msg_pos_x;
float video_msg_pos_y = settings->floats.video_msg_pos_y;
if (!font || string_is_empty(msg)) if (!font || string_is_empty(msg))
return; return;
@ -97,8 +101,8 @@ static void vga_render_msg(video_frame_info_t *video_info,
} }
else else
{ {
x = video_info->font_msg_pos_x; x = video_msg_pos_x;
y = video_info->font_msg_pos_y; y = video_msg_pos_y;
scale = 1.0f; scale = 1.0f;
align = TEXT_ALIGN_LEFT; align = TEXT_ALIGN_LEFT;
} }