A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Dave Chapman
11 * Copyright (C) 2009 by Karl Kurbjun
12 *
13 * Rockbox driver for 16-bit colour LCDs with vertical strides
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ****************************************************************************/
24
25#include "config.h"
26
27#include "cpu.h"
28#include "lcd.h"
29#include "kernel.h"
30#include "thread.h"
31#include <stdlib.h>
32#include "string-extra.h" /* mem*() */
33#include "file.h"
34#include "debug.h"
35#include "system.h"
36#include "font.h"
37#include "rbunicode.h"
38#include "bidi.h"
39#include "scroll_engine.h"
40
41/*#define LOGF_ENABLE*/
42#include "logf.h"
43
44#define ROW_INC 1
45#define COL_INC lcd_current_viewport->buffer->stride
46
47extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[];
48extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[];
49
50#ifndef DISABLE_ALPHA_BITMAP
51static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
52 const unsigned char *src, int src_x,
53 int src_y, int x, int y,
54 int width, int height,
55 int stride_image, int stride_src);
56#endif /* !DISABLE_ALPHA_BITMAP */
57
58#include "lcd-color-common.c"
59#include "lcd-bitmap-common.c"
60#include "lcd-16bit-common.c"
61
62/*** drawing functions ***/
63
64/* Draw a horizontal line (optimised) */
65void lcd_hline(int x1, int x2, int y)
66{
67 struct viewport *vp = lcd_current_viewport;
68 fb_data *dst, *dst_end;
69 int stride_dst;
70
71 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[vp->drawmode];
72
73 if (!clip_viewport_hline(vp, &x1, &x2, &y))
74 return;
75
76 dst = FBADDR(x1, y);
77 stride_dst = vp->buffer->stride;
78 dst_end = dst + (x2 - x1) * stride_dst;
79
80 do
81 {
82 pfunc(dst);
83 dst += stride_dst;
84 }
85 while (dst <= dst_end);
86}
87
88/* Draw a vertical line (optimised) */
89void lcd_vline(int x, int y1, int y2)
90{
91 struct viewport *vp = lcd_current_viewport;
92 int height;
93 unsigned bits = 0;
94 enum fill_opt fillopt = OPT_NONE;
95 fb_data *dst, *dst_end;
96
97 if(!clip_viewport_vline(vp, &x, &y1, &y2))
98 return;
99
100 height = y2 - y1 + 1;
101
102 /* drawmode and optimisation */
103 if (vp->drawmode & DRMODE_INVERSEVID)
104 {
105 if (vp->drawmode & DRMODE_BG)
106 {
107 if (!lcd_backdrop)
108 {
109 fillopt = OPT_SET;
110 bits = vp->bg_pattern;
111 }
112 else
113 fillopt = OPT_COPY;
114 }
115 }
116 else
117 {
118 if (vp->drawmode & DRMODE_FG)
119 {
120 fillopt = OPT_SET;
121 bits = vp->fg_pattern;
122 }
123 }
124 if (fillopt == OPT_NONE && vp->drawmode != DRMODE_COMPLEMENT)
125 return;
126
127 dst = FBADDR(x, y1);
128
129 switch (fillopt)
130 {
131 case OPT_SET:
132 memset16(dst, bits, height);
133 break;
134
135 case OPT_COPY:
136 memcpy(dst, (void *)((long)dst + lcd_backdrop_offset),
137 height * sizeof(fb_data));
138 break;
139
140 case OPT_NONE: /* DRMODE_COMPLEMENT */
141 dst_end = dst + height;
142 do
143 *dst = ~(*dst);
144 while (++dst < dst_end);
145 break;
146 }
147}
148
149/* Draw a partial native bitmap */
150void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
151 int stride, int x, int y, int width,
152 int height)
153{
154 struct viewport *vp = lcd_current_viewport;
155 fb_data *dst;
156 int stride_dst;
157
158 if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y))
159 return;
160
161 src += stride * src_x + src_y; /* move starting point */
162 dst = FBADDR(x, y);
163 stride_dst = vp->buffer->stride;
164 fb_data *dst_end = dst + width * stride_dst;
165
166 do
167 {
168 memcpy(dst, src, height * sizeof(fb_data));
169 src += stride;
170 dst += stride_dst;
171 }
172 while (dst < dst_end);
173}
174
175/* Draw a partial native bitmap */
176void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
177 int src_y, int stride, int x,
178 int y, int width, int height)
179{
180 struct viewport *vp = lcd_current_viewport;
181 fb_data *dst, *dst_end;
182 int stride_dst;
183
184 if (!clip_viewport_rect(vp, &x, &y, &width, &height, &src_x, &src_y))
185 return;
186
187 src += stride * src_x + src_y; /* move starting point */
188 dst = FBADDR(x, y);
189 stride_dst = vp->buffer->stride;
190 dst_end = dst + width * stride_dst;
191
192 do
193 {
194 int i;
195 for(i = 0;i < height;i++)
196 {
197 if (src[i] == REPLACEWITHFG_COLOR)
198 dst[i] = vp->fg_pattern;
199 else if(src[i] != TRANSPARENT_COLOR)
200 dst[i] = src[i];
201 }
202 src += stride;
203 dst += stride_dst;
204 }
205 while (dst < dst_end);
206}