summaryrefslogtreecommitdiffstats
path: root/meta-agl-drm-lease/recipes-core/psplash/files/0007-Extract-draw-rect-image-from-psplash-fb.patch
blob: 2e897d4ccc79fbf5b7ebb2b2cf529e8f74a2b9e5 (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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
From d0f899114600ee25eb2d7d2c089deb549c371bd2 Mon Sep 17 00:00:00 2001
From: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
Date: Mon, 25 Apr 2022 10:59:46 +0300
Subject: [PATCH 07/17] Extract draw rect/image 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 | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
 psplash-draw.h | 20 +++++++++++++++
 psplash-fb.c   | 70 --------------------------------------------------
 psplash-fb.h   | 20 ---------------
 psplash.c      | 16 ++++++------
 5 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/psplash-draw.c b/psplash-draw.c
index 570cfce..6887e22 100644
--- a/psplash-draw.c
+++ b/psplash-draw.c
@@ -118,3 +118,73 @@ psplash_plot_pixel(PSplashCanvas *canvas,
       }
   }
 }
+
+void
+psplash_draw_rect(PSplashCanvas *canvas,
+		  int            x,
+		  int            y,
+		  int            width,
+		  int            height,
+		  uint8          red,
+		  uint8          green,
+		  uint8          blue)
+{
+  int dx, dy;
+
+  for (dy=0; dy < height; dy++)
+    for (dx=0; dx < width; dx++)
+	psplash_plot_pixel(canvas, x+dx, y+dy, red, green, blue);
+}
+
+void
+psplash_draw_image(PSplashCanvas *canvas,
+		   int            x,
+		   int            y,
+		   int            img_width,
+		   int            img_height,
+		   int            img_bytes_per_pixel,
+		   int            img_rowstride,
+		   uint8         *rle_data)
+{
+  uint8       *p = rle_data;
+  int          dx = 0, dy = 0,  total_len;
+  unsigned int len;
+
+  total_len = img_rowstride * img_height;
+
+  /* FIXME: Optimise, check for over runs ... */
+  while ((p - rle_data) < total_len)
+    {
+      len = *(p++);
+
+      if (len & 128)
+	{
+	  len -= 128;
+
+	  if (len == 0) break;
+
+	  do
+	    {
+	      if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width)
+	        psplash_plot_pixel(canvas, x+dx, y+dy, *(p), *(p+1), *(p+2));
+	      if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; }
+	    }
+	  while (--len);
+
+	  p += img_bytes_per_pixel;
+	}
+      else
+	{
+	  if (len == 0) break;
+
+	  do
+	    {
+	      if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width)
+	        psplash_plot_pixel(canvas, x+dx, y+dy, *(p), *(p+1), *(p+2));
+	      if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; }
+	      p += img_bytes_per_pixel;
+	    }
+	  while (--len && (p - rle_data) < total_len);
+	}
+    }
+}
diff --git a/psplash-draw.h b/psplash-draw.h
index ab2d4d2..f8361da 100644
--- a/psplash-draw.h
+++ b/psplash-draw.h
@@ -48,4 +48,24 @@ psplash_plot_pixel(PSplashCanvas *canvas,
 		   uint8          green,
 		   uint8          blue);
 
+void
+psplash_draw_rect(PSplashCanvas *canvas,
+		  int            x,
+		  int            y,
+		  int            width,
+		  int            height,
+		  uint8          red,
+		  uint8          green,
+		  uint8          blue);
+
+void
+psplash_draw_image(PSplashCanvas *canvas,
+		   int            x,
+		   int            y,
+		   int            img_width,
+		   int            img_height,
+		   int            img_bytes_per_pixel,
+		   int            img_rowstride,
+		   uint8         *rle_data);
+
 #endif
diff --git a/psplash-fb.c b/psplash-fb.c
index a7029c5..07839d5 100644
--- a/psplash-fb.c
+++ b/psplash-fb.c
@@ -339,76 +339,6 @@ psplash_fb_new (int angle, int fbdev_id)
   return NULL;
 }
 
-void
-psplash_fb_draw_rect (PSplashFB    *fb,
-		      int          x,
-		      int          y,
-		      int          width,
-		      int          height,
-		      uint8        red,
-		      uint8        green,
-		      uint8        blue)
-{
-  int dx, dy;
-
-  for (dy=0; dy < height; dy++)
-    for (dx=0; dx < width; dx++)
-	psplash_plot_pixel(&fb->canvas, x+dx, y+dy, red, green, blue);
-}
-
-void
-psplash_fb_draw_image (PSplashFB    *fb,
-		       int          x,
-		       int          y,
-		       int          img_width,
-		       int          img_height,
-		       int          img_bytes_per_pixel,
-		       int          img_rowstride,
-		       uint8       *rle_data)
-{
-  uint8       *p = rle_data;
-  int          dx = 0, dy = 0,  total_len;
-  unsigned int len;
-
-  total_len = img_rowstride * img_height;
-
-  /* FIXME: Optimise, check for over runs ... */
-  while ((p - rle_data) < total_len)
-    {
-      len = *(p++);
-
-      if (len & 128)
-	{
-	  len -= 128;
-
-	  if (len == 0) break;
-
-	  do
-	    {
-	      if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width)
-	        psplash_plot_pixel(&fb->canvas, x+dx, y+dy, *(p), *(p+1), *(p+2));
-	      if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; }
-	    }
-	  while (--len);
-
-	  p += img_bytes_per_pixel;
-	}
-      else
-	{
-	  if (len == 0) break;
-
-	  do
-	    {
-	      if ((img_bytes_per_pixel < 4 || *(p+3)) && dx < img_width)
-	        psplash_plot_pixel(&fb->canvas, x+dx, y+dy, *(p), *(p+1), *(p+2));
-	      if (++dx * img_bytes_per_pixel >= img_rowstride) { dx=0; dy++; }
-	      p += img_bytes_per_pixel;
-	    }
-	  while (--len && (p - rle_data) < total_len);
-	}
-    }
-}
-
 /* Font rendering code based on BOGL by Ben Pfaff */
 
 static int
diff --git a/psplash-fb.h b/psplash-fb.h
index eb02c62..1eecb47 100644
--- a/psplash-fb.h
+++ b/psplash-fb.h
@@ -40,26 +40,6 @@ psplash_fb_destroy (PSplashFB *fb);
 PSplashFB*
 psplash_fb_new (int angle, int fbdev_id);
 
-void
-psplash_fb_draw_rect (PSplashFB    *fb,
-		      int          x,
-		      int          y,
-		      int          width,
-		      int          height,
-		      uint8        red,
-		      uint8        green,
-		      uint8        blue);
-
-void
-psplash_fb_draw_image (PSplashFB    *fb,
-		       int          x,
-		       int          y,
-		       int          img_width,
-		       int          img_height,
-		       int          img_bytes_pre_pixel,
-		       int          img_rowstride,
-		       uint8       *rle_data);
-
 void
 psplash_fb_text_size (int                *width,
 		      int                *height,
diff --git a/psplash.c b/psplash.c
index f23f03d..2aeb583 100644
--- a/psplash.c
+++ b/psplash.c
@@ -47,7 +47,7 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
 
   /* Clear */
 
-  psplash_fb_draw_rect (fb,
+  psplash_draw_rect(&fb->canvas,
 			0,
 			SPLIT_LINE_POS(fb) - h,
 			fb->canvas.width,
@@ -77,19 +77,19 @@ psplash_draw_progress (PSplashFB *fb, int value)
   if (value > 0)
     {
       barwidth = (CLAMP(value,0,100) * width) / 100;
-      psplash_fb_draw_rect (fb, x + barwidth, y,
+      psplash_draw_rect(&fb->canvas, x + barwidth, y,
     			width - barwidth, height,
 			PSPLASH_BAR_BACKGROUND_COLOR);
-      psplash_fb_draw_rect (fb, x, y, barwidth,
+      psplash_draw_rect(&fb->canvas, x, y, barwidth,
 			    height, PSPLASH_BAR_COLOR);
     }
   else
     {
       barwidth = (CLAMP(-value,0,100) * width) / 100;
-      psplash_fb_draw_rect (fb, x, y,
+      psplash_draw_rect(&fb->canvas, x, y,
     			width - barwidth, height,
 			PSPLASH_BAR_BACKGROUND_COLOR);
-      psplash_fb_draw_rect (fb, x + width - barwidth,
+      psplash_draw_rect(&fb->canvas, x + width - barwidth,
 			    y, barwidth, height,
 			    PSPLASH_BAR_COLOR);
     }
@@ -301,11 +301,11 @@ main (int argc, char** argv)
 #endif
 
   /* Clear the background with #ecece1 */
-  psplash_fb_draw_rect (fb, 0, 0, fb->canvas.width, fb->canvas.height,
+  psplash_draw_rect(&fb->canvas, 0, 0, fb->canvas.width, fb->canvas.height,
                         PSPLASH_BACKGROUND_COLOR);
 
   /* Draw the Poky logo  */
-  psplash_fb_draw_image (fb,
+  psplash_draw_image(&fb->canvas,
 			 (fb->canvas.width  - POKY_IMG_WIDTH)/2,
 #if PSPLASH_IMG_FULLSCREEN
 			 (fb->canvas.height - POKY_IMG_HEIGHT)/2,
@@ -321,7 +321,7 @@ main (int argc, char** argv)
 
 #ifdef PSPLASH_SHOW_PROGRESS_BAR
   /* Draw progress bar border */
-  psplash_fb_draw_image (fb,
+  psplash_draw_image(&fb->canvas,
 			 (fb->canvas.width  - BAR_IMG_WIDTH)/2,
 			 SPLIT_LINE_POS(fb),
 			 BAR_IMG_WIDTH,
-- 
2.25.1