summaryrefslogtreecommitdiffstats
path: root/meta-agl-drm-lease/recipes-core/psplash/files/0009-psplash.c-Make-psplash_draw_-msg-progress-independen.patch
blob: 9cd2692c0e945047e2c7068ea6d9d8738296c2da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
From 1046e65f7cca2b592fbb7e8f0d1392fb742a67b1 Mon Sep 17 00:00:00 2001
From: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
Date: Mon, 25 Apr 2022 10:59:48 +0300
Subject: [PATCH 09/17] psplash.c: Make psplash_draw_{msg,progress} independent
 of 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.c | 64 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/psplash.c b/psplash.c
index 1a5e543..c234d46 100644
--- a/psplash.c
+++ b/psplash.c
@@ -21,11 +21,11 @@
 #endif
 #include FONT_HEADER
 
-#define SPLIT_LINE_POS(fb)                                  \
-	(  (fb)->canvas.height                              \
-	 - ((  PSPLASH_IMG_SPLIT_DENOMINATOR                \
-	     - PSPLASH_IMG_SPLIT_NUMERATOR)                 \
-	    * (fb)->canvas.height / PSPLASH_IMG_SPLIT_DENOMINATOR) \
+#define SPLIT_LINE_POS(canvas)                                  \
+	(  (canvas)->height                                     \
+	 - ((  PSPLASH_IMG_SPLIT_DENOMINATOR                    \
+	     - PSPLASH_IMG_SPLIT_NUMERATOR)                     \
+	    * (canvas)->height / PSPLASH_IMG_SPLIT_DENOMINATOR) \
 	)
 
 void
@@ -37,7 +37,7 @@ psplash_exit (int UNUSED(signum))
 }
 
 void
-psplash_draw_msg (PSplashFB *fb, const char *msg)
+psplash_draw_msg(PSplashCanvas *canvas, const char *msg)
 {
   int w, h;
 
@@ -47,16 +47,16 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
 
   /* Clear */
 
-  psplash_draw_rect(&fb->canvas,
+  psplash_draw_rect(canvas,
 			0,
-			SPLIT_LINE_POS(fb) - h,
-			fb->canvas.width,
+			SPLIT_LINE_POS(canvas) - h,
+			canvas->width,
 			h,
 			PSPLASH_BACKGROUND_COLOR);
 
-  psplash_draw_text(&fb->canvas,
-			(fb->canvas.width-w)/2,
-			SPLIT_LINE_POS(fb) - h,
+  psplash_draw_text(canvas,
+			(canvas->width-w)/2,
+			SPLIT_LINE_POS(canvas) - h,
 			PSPLASH_TEXT_COLOR,
 			&FONT_DEF,
 			msg);
@@ -64,32 +64,32 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
 
 #ifdef PSPLASH_SHOW_PROGRESS_BAR
 void
-psplash_draw_progress (PSplashFB *fb, int value)
+psplash_draw_progress(PSplashCanvas *canvas, int value)
 {
   int x, y, width, height, barwidth;
 
   /* 4 pix border */
-  x      = ((fb->canvas.width  - BAR_IMG_WIDTH)/2) + 4 ;
-  y      = SPLIT_LINE_POS(fb) + 4;
+  x      = ((canvas->width  - BAR_IMG_WIDTH)/2) + 4 ;
+  y      = SPLIT_LINE_POS(canvas) + 4;
   width  = BAR_IMG_WIDTH - 8;
   height = BAR_IMG_HEIGHT - 8;
 
   if (value > 0)
     {
       barwidth = (CLAMP(value,0,100) * width) / 100;
-      psplash_draw_rect(&fb->canvas, x + barwidth, y,
+      psplash_draw_rect(canvas, x + barwidth, y,
     			width - barwidth, height,
 			PSPLASH_BAR_BACKGROUND_COLOR);
-      psplash_draw_rect(&fb->canvas, x, y, barwidth,
+      psplash_draw_rect(canvas, x, y, barwidth,
 			    height, PSPLASH_BAR_COLOR);
     }
   else
     {
       barwidth = (CLAMP(-value,0,100) * width) / 100;
-      psplash_draw_rect(&fb->canvas, x, y,
+      psplash_draw_rect(canvas, x, y,
     			width - barwidth, height,
 			PSPLASH_BAR_BACKGROUND_COLOR);
-      psplash_draw_rect(&fb->canvas, x + width - barwidth,
+      psplash_draw_rect(canvas, x + width - barwidth,
 			    y, barwidth, height,
 			    PSPLASH_BAR_COLOR);
     }
@@ -116,7 +116,7 @@ parse_command (PSplashFB *fb, char *string)
       char *arg = strtok(NULL, "\0");
 
       if (arg)
-        psplash_draw_msg (fb, arg);
+        psplash_draw_msg(&fb->canvas, arg);
     }
  #ifdef PSPLASH_SHOW_PROGRESS_BAR
   else  if (!strcmp(command,"PROGRESS"))
@@ -124,7 +124,7 @@ parse_command (PSplashFB *fb, char *string)
       char *arg = strtok(NULL, "\0");
 
       if (arg)
-        psplash_draw_progress (fb, atoi(arg));
+        psplash_draw_progress(&fb->canvas, atoi(arg));
     }
 #endif
   else if (!strcmp(command,"QUIT"))
@@ -226,6 +226,7 @@ main (int argc, char** argv)
   char      *rundir;
   int        pipe_fd, i = 0, angle = 0, fbdev_id = 0, ret = 0;
   PSplashFB *fb;
+  PSplashCanvas *canvas;
   bool       disable_console_switch = FALSE;
 
   signal(SIGHUP, psplash_exit);
@@ -295,22 +296,23 @@ main (int argc, char** argv)
 	  ret = -1;
 	  goto fb_fail;
     }
+  canvas = &fb->canvas;
 
 #ifdef HAVE_SYSTEMD
   sd_notify(0, "READY=1");
 #endif
 
   /* Clear the background with #ecece1 */
-  psplash_draw_rect(&fb->canvas, 0, 0, fb->canvas.width, fb->canvas.height,
+  psplash_draw_rect(canvas, 0, 0, canvas->width, canvas->height,
                         PSPLASH_BACKGROUND_COLOR);
 
   /* Draw the Poky logo  */
-  psplash_draw_image(&fb->canvas,
-			 (fb->canvas.width  - POKY_IMG_WIDTH)/2,
+  psplash_draw_image(canvas,
+			 (canvas->width  - POKY_IMG_WIDTH)/2,
 #if PSPLASH_IMG_FULLSCREEN
-			 (fb->canvas.height - POKY_IMG_HEIGHT)/2,
+			 (canvas->height - POKY_IMG_HEIGHT)/2,
 #else
-			 (fb->canvas.height * PSPLASH_IMG_SPLIT_NUMERATOR
+			 (canvas->height * PSPLASH_IMG_SPLIT_NUMERATOR
 			  / PSPLASH_IMG_SPLIT_DENOMINATOR - POKY_IMG_HEIGHT)/2,
 #endif
 			 POKY_IMG_WIDTH,
@@ -321,20 +323,20 @@ main (int argc, char** argv)
 
 #ifdef PSPLASH_SHOW_PROGRESS_BAR
   /* Draw progress bar border */
-  psplash_draw_image(&fb->canvas,
-			 (fb->canvas.width  - BAR_IMG_WIDTH)/2,
-			 SPLIT_LINE_POS(fb),
+  psplash_draw_image(canvas,
+			 (canvas->width  - BAR_IMG_WIDTH)/2,
+			 SPLIT_LINE_POS(canvas),
 			 BAR_IMG_WIDTH,
 			 BAR_IMG_HEIGHT,
 			 BAR_IMG_BYTES_PER_PIXEL,
 			 BAR_IMG_ROWSTRIDE,
 			 BAR_IMG_RLE_PIXEL_DATA);
 
-  psplash_draw_progress (fb, 0);
+  psplash_draw_progress(canvas, 0);
 #endif
 
 #ifdef PSPLASH_STARTUP_MSG
-  psplash_draw_msg (fb, PSPLASH_STARTUP_MSG);
+  psplash_draw_msg(canvas, PSPLASH_STARTUP_MSG);
 #endif
 
   /* Scene set so let's flip the buffers. */
-- 
2.25.1