Subversion Repositories HelenOS

Rev

Rev 1871 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1871 Rev 1875
Line 68... Line 68...
68
 
68
 
69
typedef void (*conv2scr_fn_t)(void *, int);
69
typedef void (*conv2scr_fn_t)(void *, int);
70
typedef int (*conv2rgb_fn_t)(void *);
70
typedef int (*conv2rgb_fn_t)(void *);
71
 
71
 
72
struct {
72
struct {
73
    uint8_t *fbaddress ;
73
    uint8_t *fbaddress;
74
 
74
 
75
    unsigned int xres ;
75
    unsigned int xres;
76
    unsigned int yres ;
76
    unsigned int yres;
77
    unsigned int scanline ;
77
    unsigned int scanline;
78
    unsigned int pixelbytes ;
78
    unsigned int pixelbytes;
-
 
79
    unsigned int invert_colors;
79
 
80
 
80
    conv2scr_fn_t rgb2scr;
81
    conv2scr_fn_t rgb2scr;
81
    conv2rgb_fn_t scr2rgb;
82
    conv2rgb_fn_t scr2rgb;
82
} screen;
83
} screen;
83
 
84
 
Line 138... Line 139...
138
#define COL_WIDTH   8
139
#define COL_WIDTH   8
139
#define ROW_BYTES   (screen.scanline * FONT_SCANLINES)
140
#define ROW_BYTES   (screen.scanline * FONT_SCANLINES)
140
 
141
 
141
#define POINTPOS(x, y)  ((y) * screen.scanline + (x) * screen.pixelbytes)
142
#define POINTPOS(x, y)  ((y) * screen.scanline + (x) * screen.pixelbytes)
142
 
143
 
-
 
144
static inline int COLOR(int color)
-
 
145
{
-
 
146
    return screen.invert_colors ? ~color : color;
-
 
147
}
-
 
148
 
143
/* Conversion routines between different color representations */
149
/* Conversion routines between different color representations */
144
static void rgb_4byte(void *dst, int rgb)
150
static void rgb_4byte(void *dst, int rgb)
145
{
151
{
146
    *(int *)dst = rgb;
152
    *(int *)dst = rgb;
147
}
153
}
Line 161... Line 167...
161
#else
167
#else
162
    scr[2] = RED(rgb, 8);
168
    scr[2] = RED(rgb, 8);
163
    scr[1] = GREEN(rgb, 8);
169
    scr[1] = GREEN(rgb, 8);
164
    scr[0] = BLUE(rgb, 8);
170
    scr[0] = BLUE(rgb, 8);
165
#endif
171
#endif
166
 
-
 
167
 
-
 
168
}
172
}
169
 
173
 
170
static int byte3_rgb(void *src)
174
static int byte3_rgb(void *src)
171
{
175
{
172
    uint8_t *scr = src;
176
    uint8_t *scr = src;
Line 215... Line 219...
215
{
219
{
216
    int dx = vport->x + x;
220
    int dx = vport->x + x;
217
    int dy = vport->y + y;
221
    int dy = vport->y + y;
218
 
222
 
219
    if (! (vport->paused && vport->dbdata))
223
    if (! (vport->paused && vport->dbdata))
220
        (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],color);
224
        (*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)], COLOR(color));
221
 
225
 
222
    if (vport->dbdata) {
226
    if (vport->dbdata) {
223
        int dline = (y + vport->dboffset) % vport->height;
227
        int dline = (y + vport->dboffset) % vport->height;
224
        int doffset = screen.pixelbytes * (dline * vport->width + x);
228
        int doffset = screen.pixelbytes * (dline * vport->width + x);
225
        (*screen.rgb2scr)(&vport->dbdata[doffset],color);
229
        (*screen.rgb2scr)(&vport->dbdata[doffset], COLOR(color));
226
    }
230
    }
227
}
231
}
228
 
232
 
229
/** Get pixel from viewport */
233
/** Get pixel from viewport */
230
static int getpixel(viewport_t *vport, unsigned int x, unsigned int y)
234
static int getpixel(viewport_t *vport, unsigned int x, unsigned int y)
231
{
235
{
232
    int dx = vport->x + x;
236
    int dx = vport->x + x;
233
    int dy = vport->y + y;
237
    int dy = vport->y + y;
234
 
238
 
235
    return (*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]);
239
    return COLOR((*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]));
236
}
240
}
237
 
241
 
238
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y,
242
static inline void putpixel_mem(char *mem, unsigned int x, unsigned int y,
239
                int color)
243
                int color)
240
{
244
{
241
    (*screen.rgb2scr)(&mem[POINTPOS(x,y)],color);
245
    (*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
242
}
246
}
243
 
247
 
244
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
248
static void draw_rectangle(viewport_t *vport, unsigned int sx, unsigned int sy,
245
               unsigned int width, unsigned int height,
249
               unsigned int width, unsigned int height,
246
               int color)
250
               int color)
Line 452... Line 456...
452
 * @param xres Screen width in pixels
456
 * @param xres Screen width in pixels
453
 * @param yres Screen height in pixels
457
 * @param yres Screen height in pixels
454
 * @param bpp  Bits per pixel (8, 16, 24, 32)
458
 * @param bpp  Bits per pixel (8, 16, 24, 32)
455
 * @param scan Bytes per one scanline
459
 * @param scan Bytes per one scanline
456
 * @param align Alignment for 24bpp mode.
460
 * @param align Alignment for 24bpp mode.
-
 
461
 * @param invert_colors Inverted colors.
457
 *
462
 *
458
 */
463
 */
459
static void
464
static void
460
screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan, int align)
465
screen_init(void *addr, unsigned int xres, unsigned int yres, unsigned int bpp, unsigned int scan,
-
 
466
    int align, int invert_colors)
461
{
467
{
462
    switch (bpp) {
468
    switch (bpp) {
463
        case 8:
469
        case 8:
464
            screen.rgb2scr = rgb_1byte;
470
            screen.rgb2scr = rgb_1byte;
465
            screen.scr2rgb = byte1_rgb;
471
            screen.scr2rgb = byte1_rgb;
Line 488... Line 494...
488
       
494
       
489
    screen.fbaddress = (unsigned char *) addr;
495
    screen.fbaddress = (unsigned char *) addr;
490
    screen.xres = xres;
496
    screen.xres = xres;
491
    screen.yres = yres;
497
    screen.yres = yres;
492
    screen.scanline = scan;
498
    screen.scanline = scan;
-
 
499
    screen.invert_colors = invert_colors;
493
   
500
   
494
    /* Create first viewport */
501
    /* Create first viewport */
495
    viewport_create(0,0,xres,yres);
502
    viewport_create(0,0,xres,yres);
496
}
503
}
497
 
504
 
Line 591... Line 598...
591
static void putpixel_pixmap(int pm, unsigned int x, unsigned int y, int color)
598
static void putpixel_pixmap(int pm, unsigned int x, unsigned int y, int color)
592
{
599
{
593
    pixmap_t *pmap = &pixmaps[pm];
600
    pixmap_t *pmap = &pixmaps[pm];
594
    int pos = (y * pmap->width + x) * screen.pixelbytes;
601
    int pos = (y * pmap->width + x) * screen.pixelbytes;
595
 
602
 
596
    (*screen.rgb2scr)(&pmap->data[pos],color);
603
    (*screen.rgb2scr)(&pmap->data[pos],COLOR(color));
597
}
604
}
598
 
605
 
599
/** Create a new pixmap and return appropriate ID */
606
/** Create a new pixmap and return appropriate ID */
600
static int shm2pixmap(unsigned char *shm, size_t size)
607
static int shm2pixmap(unsigned char *shm, size_t size)
601
{
608
{
Line 1221... Line 1228...
1221
    unsigned int fb_width;
1228
    unsigned int fb_width;
1222
    unsigned int fb_height;
1229
    unsigned int fb_height;
1223
    unsigned int fb_bpp;
1230
    unsigned int fb_bpp;
1224
    unsigned int fb_bpp_align;
1231
    unsigned int fb_bpp_align;
1225
    unsigned int fb_scanline;
1232
    unsigned int fb_scanline;
-
 
1233
    unsigned int fb_invert_colors;
1226
    void *fb_addr;
1234
    void *fb_addr;
1227
    size_t asz;
1235
    size_t asz;
1228
 
1236
 
1229
    async_set_client_connection(fb_client_connection);
1237
    async_set_client_connection(fb_client_connection);
1230
 
1238
 
Line 1232... Line 1240...
1232
    fb_width=sysinfo_value("fb.width");
1240
    fb_width=sysinfo_value("fb.width");
1233
    fb_height=sysinfo_value("fb.height");
1241
    fb_height=sysinfo_value("fb.height");
1234
    fb_bpp=sysinfo_value("fb.bpp");
1242
    fb_bpp=sysinfo_value("fb.bpp");
1235
    fb_bpp_align=sysinfo_value("fb.bpp-align");
1243
    fb_bpp_align=sysinfo_value("fb.bpp-align");
1236
    fb_scanline=sysinfo_value("fb.scanline");
1244
    fb_scanline=sysinfo_value("fb.scanline");
-
 
1245
    fb_invert_colors=sysinfo_value("fb.invert-colors");
1237
 
1246
 
1238
    asz = fb_scanline*fb_height;
1247
    asz = fb_scanline*fb_height;
1239
    fb_addr = as_get_mappable_page(asz);
1248
    fb_addr = as_get_mappable_page(asz);
1240
   
1249
   
1241
    map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz,PAGE_SIZE) >>PAGE_WIDTH,
1250
    map_physmem(fb_ph_addr, fb_addr, ALIGN_UP(asz,PAGE_SIZE) >>PAGE_WIDTH,
1242
            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
1251
            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
1243
   
1252
   
1244
    screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, fb_bpp_align);
1253
    screen_init(fb_addr, fb_width, fb_height, fb_bpp, fb_scanline, fb_bpp_align, fb_invert_colors);
1245
 
1254
 
1246
    return 0;
1255
    return 0;
1247
}
1256
}
1248
 
1257
 
1249
 
1258