summaryrefslogtreecommitdiffstats
path: root/meta-agl-drm-lease/recipes-core/psplash/files/0008-Extract-draw-font-from-psplash-fb.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-agl-drm-lease/recipes-core/psplash/files/0008-Extract-draw-font-from-psplash-fb.patch')
-rw-r--r--meta-agl-drm-lease/recipes-core/psplash/files/0008-Extract-draw-font-from-psplash-fb.patch350
1 files changed, 350 insertions, 0 deletions
diff --git a/meta-agl-drm-lease/recipes-core/psplash/files/0008-Extract-draw-font-from-psplash-fb.patch b/meta-agl-drm-lease/recipes-core/psplash/files/0008-Extract-draw-font-from-psplash-fb.patch
new file mode 100644
index 00000000..a62e939c
--- /dev/null
+++ b/meta-agl-drm-lease/recipes-core/psplash/files/0008-Extract-draw-font-from-psplash-fb.patch
@@ -0,0 +1,350 @@
+From 532e889486ed4c6b254893e89c63cc4395cc83da Mon Sep 17 00:00:00 2001
+From: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
+Date: Mon, 25 Apr 2022 10:59:47 +0300
+Subject: [PATCH 08/17] Extract draw font from psplash-fb
+
+drm-backend backport from:
+https://patchwork.yoctoproject.org/project/yocto/cover/20220425075954.10427-1-vasyl.vavrychuk@opensynergy.com/
+
+Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
+---
+ psplash-draw.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++-
+ psplash-draw.h | 25 ++++++++----
+ psplash-fb.c | 108 ------------------------------------------------
+ psplash-fb.h | 16 --------
+ psplash.c | 4 +-
+ 5 files changed, 125 insertions(+), 137 deletions(-)
+
+diff --git a/psplash-draw.c b/psplash-draw.c
+index 6887e22..aa9887a 100644
+--- a/psplash-draw.c
++++ b/psplash-draw.c
+@@ -11,8 +11,7 @@
+
+ #define OFFSET(canvas, x, y) (((y) * (canvas)->stride) + ((x) * ((canvas)->bpp >> 3)))
+
+-/* TODO: change to 'static inline' as psplash_fb_plot_pixel was before */
+-void
++static inline void
+ psplash_plot_pixel(PSplashCanvas *canvas,
+ int x,
+ int y,
+@@ -188,3 +187,109 @@ psplash_draw_image(PSplashCanvas *canvas,
+ }
+ }
+ }
++
++/* Font rendering code based on BOGL by Ben Pfaff */
++
++static int
++psplash_font_glyph (const PSplashFont *font, wchar_t wc, u_int32_t **bitmap)
++{
++ int mask = font->index_mask;
++ int i;
++
++ for (;;)
++ {
++ for (i = font->offset[wc & mask]; font->index[i]; i += 2)
++ {
++ if ((wchar_t)(font->index[i] & ~mask) == (wc & ~mask))
++ {
++ if (bitmap != NULL)
++ *bitmap = &font->content[font->index[i+1]];
++ return font->index[i] & mask;
++ }
++ }
++ }
++ return 0;
++}
++
++void
++psplash_text_size(int *width,
++ int *height,
++ const PSplashFont *font,
++ const char *text)
++{
++ char *c = (char*)text;
++ wchar_t wc;
++ int k, n, w, h, mw;
++
++ n = strlen (text);
++ mw = h = w = 0;
++
++ mbtowc (0, 0, 0);
++ for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k)
++ {
++ if (*c == '\n')
++ {
++ if (w > mw)
++ mw = w;
++ w = 0;
++ h += font->height;
++ continue;
++ }
++
++ w += psplash_font_glyph (font, wc, NULL);
++ }
++
++ *width = (w > mw) ? w : mw;
++ *height = (h == 0) ? font->height : h;
++}
++
++void
++psplash_draw_text(PSplashCanvas *canvas,
++ int x,
++ int y,
++ uint8 red,
++ uint8 green,
++ uint8 blue,
++ const PSplashFont *font,
++ const char *text)
++{
++ int h, w, k, n, cx, cy, dx, dy;
++ char *c = (char*)text;
++ wchar_t wc;
++
++ n = strlen (text);
++ h = font->height;
++ dx = dy = 0;
++
++ mbtowc (0, 0, 0);
++ for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k)
++ {
++ u_int32_t *glyph = NULL;
++
++ if (*c == '\n')
++ {
++ dy += h;
++ dx = 0;
++ continue;
++ }
++
++ w = psplash_font_glyph (font, wc, &glyph);
++
++ if (glyph == NULL)
++ continue;
++
++ for (cy = 0; cy < h; cy++)
++ {
++ u_int32_t g = *glyph++;
++
++ for (cx = 0; cx < w; cx++)
++ {
++ if (g & 0x80000000)
++ psplash_plot_pixel(canvas, x+dx+cx, y+dy+cy, red, green, blue);
++ g <<= 1;
++ }
++ }
++
++ dx += w;
++ }
++}
+diff --git a/psplash-draw.h b/psplash-draw.h
+index f8361da..44546b0 100644
+--- a/psplash-draw.h
++++ b/psplash-draw.h
+@@ -39,15 +39,6 @@ typedef struct PSplashCanvas
+ }
+ PSplashCanvas;
+
+-/* TODO: Remove after rest of drawing functions migrated to psplash-draw.c */
+-void
+-psplash_plot_pixel(PSplashCanvas *canvas,
+- int x,
+- int y,
+- uint8 red,
+- uint8 green,
+- uint8 blue);
+-
+ void
+ psplash_draw_rect(PSplashCanvas *canvas,
+ int x,
+@@ -68,4 +59,20 @@ psplash_draw_image(PSplashCanvas *canvas,
+ int img_rowstride,
+ uint8 *rle_data);
+
++void
++psplash_text_size(int *width,
++ int *height,
++ const PSplashFont *font,
++ const char *text);
++
++void
++psplash_draw_text(PSplashCanvas *canvas,
++ int x,
++ int y,
++ uint8 red,
++ uint8 green,
++ uint8 blue,
++ const PSplashFont *font,
++ const char *text);
++
+ #endif
+diff --git a/psplash-fb.c b/psplash-fb.c
+index 07839d5..dd50a5a 100644
+--- a/psplash-fb.c
++++ b/psplash-fb.c
+@@ -338,111 +338,3 @@ psplash_fb_new (int angle, int fbdev_id)
+
+ return NULL;
+ }
+-
+-/* Font rendering code based on BOGL by Ben Pfaff */
+-
+-static int
+-psplash_font_glyph (const PSplashFont *font, wchar_t wc, u_int32_t **bitmap)
+-{
+- int mask = font->index_mask;
+- int i;
+-
+- for (;;)
+- {
+- for (i = font->offset[wc & mask]; font->index[i]; i += 2)
+- {
+- if ((wchar_t)(font->index[i] & ~mask) == (wc & ~mask))
+- {
+- if (bitmap != NULL)
+- *bitmap = &font->content[font->index[i+1]];
+- return font->index[i] & mask;
+- }
+- }
+- }
+- return 0;
+-}
+-
+-void
+-psplash_fb_text_size (int *width,
+- int *height,
+- const PSplashFont *font,
+- const char *text)
+-{
+- char *c = (char*)text;
+- wchar_t wc;
+- int k, n, w, h, mw;
+-
+- n = strlen (text);
+- mw = h = w = 0;
+-
+- mbtowc (0, 0, 0);
+- for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k)
+- {
+- if (*c == '\n')
+- {
+- if (w > mw)
+- mw = w;
+- w = 0;
+- h += font->height;
+- continue;
+- }
+-
+- w += psplash_font_glyph (font, wc, NULL);
+- }
+-
+- *width = (w > mw) ? w : mw;
+- *height = (h == 0) ? font->height : h;
+-}
+-
+-void
+-psplash_fb_draw_text (PSplashFB *fb,
+- int x,
+- int y,
+- uint8 red,
+- uint8 green,
+- uint8 blue,
+- const PSplashFont *font,
+- const char *text)
+-{
+- int h, w, k, n, cx, cy, dx, dy;
+- char *c = (char*)text;
+- wchar_t wc;
+-
+- n = strlen (text);
+- h = font->height;
+- dx = dy = 0;
+-
+- mbtowc (0, 0, 0);
+- for (; (k = mbtowc (&wc, c, n)) > 0; c += k, n -= k)
+- {
+- u_int32_t *glyph = NULL;
+-
+- if (*c == '\n')
+- {
+- dy += h;
+- dx = 0;
+- continue;
+- }
+-
+- w = psplash_font_glyph (font, wc, &glyph);
+-
+- if (glyph == NULL)
+- continue;
+-
+- for (cy = 0; cy < h; cy++)
+- {
+- u_int32_t g = *glyph++;
+-
+- for (cx = 0; cx < w; cx++)
+- {
+- if (g & 0x80000000)
+- psplash_plot_pixel(&fb->canvas, x+dx+cx, y+dy+cy,
+- red, green, blue);
+- g <<= 1;
+- }
+- }
+-
+- dx += w;
+- }
+-}
+-
+diff --git a/psplash-fb.h b/psplash-fb.h
+index 1eecb47..1b16bd5 100644
+--- a/psplash-fb.h
++++ b/psplash-fb.h
+@@ -40,22 +40,6 @@ psplash_fb_destroy (PSplashFB *fb);
+ PSplashFB*
+ psplash_fb_new (int angle, int fbdev_id);
+
+-void
+-psplash_fb_text_size (int *width,
+- int *height,
+- const PSplashFont *font,
+- const char *text);
+-
+-void
+-psplash_fb_draw_text (PSplashFB *fb,
+- int x,
+- int y,
+- uint8 red,
+- uint8 green,
+- uint8 blue,
+- const PSplashFont *font,
+- const char *text);
+-
+ void
+ psplash_fb_flip(PSplashFB *fb, int sync);
+
+diff --git a/psplash.c b/psplash.c
+index 2aeb583..1a5e543 100644
+--- a/psplash.c
++++ b/psplash.c
+@@ -41,7 +41,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
+ {
+ int w, h;
+
+- psplash_fb_text_size (&w, &h, &FONT_DEF, msg);
++ psplash_text_size(&w, &h, &FONT_DEF, msg);
+
+ DBG("displaying '%s' %ix%i\n", msg, w, h);
+
+@@ -54,7 +54,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
+ h,
+ PSPLASH_BACKGROUND_COLOR);
+
+- psplash_fb_draw_text (fb,
++ psplash_draw_text(&fb->canvas,
+ (fb->canvas.width-w)/2,
+ SPLIT_LINE_POS(fb) - h,
+ PSPLASH_TEXT_COLOR,
+--
+2.25.1
+