//uspace/trunk/console/gcons.h |
---|
33,5 → 33,6 |
void gcons_change_console(int consnum); |
void gcons_notify_char(int consnum); |
void gcons_in_kernel(void); |
void gcons_notify_connect(int consnum); |
#endif |
//uspace/trunk/console/cons_has_data.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//uspace/trunk/console/console.c |
---|
226,10 → 226,10 |
if (newcons == active_console) |
return; |
if (newcons == -1) { |
if (active_console == -1) |
if (newcons == KERNEL_CONSOLE) { |
if (active_console == KERNEL_CONSOLE) |
return; |
active_console = -1; |
active_console = KERNEL_CONSOLE; |
curs_visibility(0); |
if (kernel_pixmap == -1) { |
306,7 → 306,7 |
// if ((c >= KBD_KEY_F1) && (c < KBD_KEY_F1 + CONSOLE_COUNT)) { |
if ((c >= '0') && (c < '0' + CONSOLE_COUNT)) { |
if (c == '0') |
change_console(-1); |
change_console(KERNEL_CONSOLE); |
else |
change_console(c - '1'); |
break; |
342,7 → 342,8 |
ipc_answer_fast(iid,ELIMIT,0,0); |
return; |
} |
gcons_notify_connect(consnum); |
connections[consnum].used = 1; |
connections[consnum].client_phone = IPC_GET_ARG3(call); |
screenbuffer_clear(&(connections[consnum].screenbuffer)); |
//uspace/trunk/console/cons_selected.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//uspace/trunk/console/console.h |
---|
29,6 → 29,8 |
#ifndef __CONSOLE_H__ |
#define __CONSOLE_H__ |
#define KERNEL_CONSOLE 9 |
#define CONSOLE_COUNT 12 |
#define CONSOLE_GETCHAR 1026 |
//uspace/trunk/console/gcons.c |
---|
32,17 → 32,19 |
#include <stdio.h> |
#include <sys/mman.h> |
#include <string.h> |
#include <align.h> |
#include "console.h" |
#include "gcons.h" |
#define CONSOLE_TOP 65 |
#define CONSOLE_MARGIN 10 |
#define CONSOLE_MARGIN 6 |
#define STATUS_START 120 |
#define STATUS_SPACE 5 |
#define STATUS_WIDTH 40 |
#define STATUS_HEIGHT 30 |
#define STATUS_START 110 |
#define STATUS_TOP 8 |
#define STATUS_SPACE 3 |
#define STATUS_WIDTH 48 |
#define STATUS_HEIGHT 48 |
#define MAIN_COLOR 0xffffff |
49,30 → 51,26 |
static int use_gcons = 0; |
static ipcarg_t xres,yres; |
enum butstate { |
CONS_DISCONNECTED = 0, |
CONS_SELECTED, |
CONS_IDLE, |
CONS_HAS_DATA, |
CONS_KERNEL, |
CONS_DISCONNECTED_SEL, |
CONS_LAST |
}; |
static int console_vp; |
static int cstatus_vp[CONSOLE_COUNT]; |
static int console_has_input[CONSOLE_COUNT]; |
static int cstat_row, cstat_col; /* Size of cstatus buttons */ |
static enum butstate console_state[CONSOLE_COUNT]; |
static int fbphone; |
enum butstate { |
CONS_ACTIVE = 0, |
CONS_IDLE, |
CONS_HAS_INPUT, |
CONS_DISCONNECTED |
}; |
/** List of pixmaps identifying these icons */ |
static int ic_pixmaps[CONS_LAST] = {-1,-1,-1,-1,-1,-1}; |
static struct { |
int fgcolor; |
int bgcolor; |
} stat_colors[] = { |
{0xd0d0d0, 0x808080}, |
{0xd0d0d0, 0x0}, |
{0xd0d0d0, 0xa04040}, |
{0xd0d0d0, 0x0} |
}; |
static int active_console = 0; |
static void vp_switch(int vp) |
106,32 → 104,50 |
nsend_call_3(fbphone, FB_PUTCHAR, c, row, col); |
} |
static void draw_stat(int consnum, enum butstate state) |
static void redraw_state(int consnum) |
{ |
char data[5]; |
int i; |
enum butstate state = console_state[consnum]; |
vp_switch(cstatus_vp[consnum]); |
set_style(stat_colors[state].fgcolor, stat_colors[state].bgcolor); |
clear(); |
if (state != CONS_DISCONNECTED) { |
snprintf(data, 5, "%d", consnum+1); |
for (i=0;data[i];i++) |
putch(data[i], 0, i); |
} |
if (ic_pixmaps[state] != -1) |
nsend_call_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[consnum], ic_pixmaps[state]); |
if (state != CONS_DISCONNECTED && state != CONS_KERNEL && state != CONS_DISCONNECTED_SEL) { |
snprintf(data, 5, "%d", consnum+1); |
for (i=0;data[i];i++) |
putch(data[i], 1, 2+i); |
} |
} |
/** Notification run on changing console (except kernel console) */ |
void gcons_change_console(int consnum) |
{ |
int i; |
if (!use_gcons) |
return; |
if (active_console != -1) |
draw_stat(active_console, CONS_IDLE); |
if (active_console == KERNEL_CONSOLE) { |
for (i=0; i < CONSOLE_COUNT; i++) |
redraw_state(i); |
} else { |
if (console_state[active_console] == CONS_DISCONNECTED_SEL) |
console_state[active_console] = CONS_DISCONNECTED; |
else |
console_state[active_console] = CONS_IDLE; |
redraw_state(active_console); |
} |
active_console = consnum; |
draw_stat(consnum, CONS_ACTIVE); |
console_has_input[consnum] = 0; |
if (console_state[consnum] == CONS_DISCONNECTED) { |
console_state[consnum] = CONS_DISCONNECTED_SEL; |
redraw_state(consnum); |
} else |
console_state[consnum] = CONS_SELECTED; |
redraw_state(consnum); |
vp_switch(console_vp); |
} |
141,25 → 157,45 |
if (!use_gcons) |
return; |
if (consnum == active_console || console_has_input[consnum]) |
if (consnum == active_console || console_state[consnum] == CONS_HAS_DATA) |
return; |
console_has_input[consnum] = 1; |
console_state[consnum] = CONS_HAS_DATA; |
if (active_console == -1) |
if (active_console == KERNEL_CONSOLE) |
return; |
draw_stat(consnum, CONS_HAS_INPUT); |
redraw_state(consnum); |
vp_switch(console_vp); |
} |
void gcons_notify_connect(int consnum) |
{ |
if (!use_gcons) |
return; |
if (active_console == consnum) |
console_state[consnum] = CONS_SELECTED; |
else |
console_state[consnum] = CONS_IDLE; |
if (active_console == KERNEL_CONSOLE) |
return; |
redraw_state(consnum); |
vp_switch(console_vp); |
} |
/** Change to kernel console */ |
void gcons_in_kernel(void) |
{ |
draw_stat(active_console, CONS_IDLE); |
active_console = -1; /* Set to kernel console */ |
if (console_state[active_console] = CONS_DISCONNECTED_SEL) |
console_state[active_console] = CONS_DISCONNECTED; |
else |
console_state[active_console] = CONS_IDLE; |
redraw_state(active_console); |
active_console = KERNEL_CONSOLE; /* Set to kernel console */ |
vp_switch(0); |
} |
189,7 → 225,7 |
if (rc) |
goto drop; |
/* Draw logo */ |
send_call_2(fbphone, FB_DRAW_PPM, x, y); |
nsend_call_2(fbphone, FB_DRAW_PPM, x, y); |
drop: |
/* Drop area */ |
nsend_call(fbphone, FB_DROP_SHM, 0); |
202,7 → 238,7 |
extern int _binary_helenos_ppm_size; |
extern char _binary_nameic_ppm_start[0]; |
extern int _binary_nameic_ppm_size; |
void gcons_redraw_console(void) |
static void gcons_redraw_console(void) |
{ |
int i; |
size_t hsize = (size_t)&_binary_helenos_ppm_size; |
213,15 → 249,58 |
vp_switch(0); |
set_style(MAIN_COLOR, MAIN_COLOR); |
clear(); |
draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-64, 0); |
draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 10); |
draw_pixmap(_binary_helenos_ppm_start, (size_t)&_binary_helenos_ppm_size, xres-66, 2); |
draw_pixmap(_binary_nameic_ppm_start, (size_t)&_binary_nameic_ppm_size, 5, 17); |
for (i=0;i < CONSOLE_COUNT; i++) |
draw_stat(i, i == active_console ? CONS_ACTIVE : CONS_DISCONNECTED); |
redraw_state(i); |
vp_switch(console_vp); |
} |
static int make_pixmap(char *data, int size) |
{ |
char *shm; |
int rc; |
int pxid = -1; |
/* Create area */ |
shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); |
if (shm == MAP_FAILED) |
return -1; |
memcpy(shm, data, size); |
/* Send area */ |
rc = sync_send_2(fbphone, FB_PREPARE_SHM, (ipcarg_t)shm, 0, NULL, NULL); |
if (rc) |
goto exit; |
rc = sync_send_3(fbphone, IPC_M_AS_AREA_SEND, (ipcarg_t)shm, 0, PROTO_READ, NULL, NULL, NULL); |
if (rc) |
goto drop; |
/* Obtain pixmap */ |
rc = sync_send(fbphone, FB_SHM2PIXMAP, 0, NULL); |
if (rc < 0) |
goto drop; |
pxid = rc; |
drop: |
/* Drop area */ |
nsend_call(fbphone, FB_DROP_SHM, 0); |
exit: |
/* Remove area */ |
munmap(shm, size); |
return pxid; |
} |
extern char _binary_cons_selected_ppm_start[0]; |
extern int _binary_cons_selected_ppm_size; |
extern char _binary_cons_idle_ppm_start[0]; |
extern int _binary_cons_idle_ppm_size; |
extern char _binary_cons_has_data_ppm_start[0]; |
extern int _binary_cons_has_data_ppm_size; |
extern char _binary_cons_kernel_ppm_start[0]; |
extern int _binary_cons_kernel_ppm_size; |
/** Initialize nice graphical console environment */ |
void gcons_init(int phone) |
{ |
238,8 → 317,10 |
return; |
/* create console viewport */ |
console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, xres-2*CONSOLE_MARGIN, |
yres-(CONSOLE_TOP+CONSOLE_MARGIN)); |
/* Align width & height to character size */ |
console_vp = vp_create(CONSOLE_MARGIN, CONSOLE_TOP, |
ALIGN_DOWN(xres-2*CONSOLE_MARGIN, 8), |
ALIGN_DOWN(yres-(CONSOLE_TOP+CONSOLE_MARGIN),16)); |
if (console_vp < 0) |
return; |
246,11 → 327,28 |
/* Create status buttons */ |
for (i=0; i < CONSOLE_COUNT; i++) { |
cstatus_vp[i] = vp_create(STATUS_START+CONSOLE_MARGIN+i*(STATUS_WIDTH+STATUS_SPACE), |
CONSOLE_MARGIN, STATUS_WIDTH, STATUS_HEIGHT); |
STATUS_TOP, STATUS_WIDTH, STATUS_HEIGHT); |
if (cstatus_vp[i] < 0) |
return; |
vp_switch(cstatus_vp[i]); |
set_style(0x202020, 0xffffff); |
} |
/* Initialize icons */ |
ic_pixmaps[CONS_SELECTED] = make_pixmap(_binary_cons_selected_ppm_start, |
(int)&_binary_cons_selected_ppm_size); |
ic_pixmaps[CONS_IDLE] = make_pixmap(_binary_cons_idle_ppm_start, |
(int)&_binary_cons_idle_ppm_size); |
ic_pixmaps[CONS_HAS_DATA] = make_pixmap(_binary_cons_has_data_ppm_start, |
(int)&_binary_cons_has_data_ppm_size); |
ic_pixmaps[CONS_DISCONNECTED] = make_pixmap(_binary_cons_idle_ppm_start, |
(int)&_binary_cons_idle_ppm_size); |
ic_pixmaps[CONS_KERNEL] = make_pixmap(_binary_cons_kernel_ppm_start, |
(int)&_binary_cons_kernel_ppm_size); |
ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED]; |
use_gcons = 1; |
console_state[0] = CONS_DISCONNECTED_SEL; |
console_state[KERNEL_CONSOLE] = CONS_KERNEL; |
gcons_redraw_console(); |
} |
//uspace/trunk/console/cons_idle.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//uspace/trunk/console/Makefile |
---|
47,7 → 47,8 |
../kbd/generic/key_buffer.c \ |
gcons.c |
IMAGES = helenos.ppm nameic.ppm |
IMAGES = helenos.ppm nameic.ppm cons_selected.ppm cons_idle.ppm \ |
cons_has_data.ppm cons_kernel.ppm |
ARCH_SOURCES = |
//uspace/trunk/console/cons_kernel.ppm |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
//uspace/trunk/fb/ppm.h |
---|
29,9 → 29,10 |
#ifndef _PPM_H_ |
#define _PPM_H_ |
int draw_ppm(unsigned char *data, size_t datasz, unsigned int sx, |
int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx, |
unsigned int sy, |
unsigned int maxwidth, unsigned int maxheight, |
void (*putpixel)(int,unsigned int, unsigned int, int),int vp); |
int ppm_get_data(unsigned char *data, size_t dtsz, int *width, int *height); |
#endif |
//uspace/trunk/fb/fb.c |
---|
54,8 → 54,8 |
/***************************************************************/ |
/* Pixel specific fuctions */ |
typedef void (*putpixel_fn_t)(unsigned int x, unsigned int y, int color); |
typedef int (*getpixel_fn_t)(unsigned int x, unsigned int y); |
typedef void (*conv2scr_fn_t)(void *, int); |
typedef int (*conv2rgb_fn_t)(void *); |
struct { |
__u8 *fbaddress ; |
65,8 → 65,8 |
unsigned int scanline ; |
unsigned int pixelbytes ; |
putpixel_fn_t putpixel; |
getpixel_fn_t getpixel; |
conv2scr_fn_t rgb2scr; |
conv2rgb_fn_t scr2rgb; |
} screen; |
typedef struct { |
90,7 → 90,7 |
typedef struct { |
unsigned int width; |
unsigned int height; |
void *data; |
__u8 *data; |
} pixmap_t; |
static pixmap_t pixmaps[MAX_PIXMAPS]; |
110,75 → 110,67 |
#define POINTPOS(x, y) ((y) * screen.scanline + (x) * screen.pixelbytes) |
/** Put pixel - 24-bit depth, 1 free byte */ |
static void putpixel_4byte(unsigned int x, unsigned int y, int color) |
/* Conversion routines between different color representations */ |
static void rgb_4byte(void *dst, int rgb) |
{ |
*((__u32 *)(screen.fbaddress + POINTPOS(x, y))) = color; |
*(int *)dst = rgb; |
} |
/** Return pixel color - 24-bit depth, 1 free byte */ |
static int getpixel_4byte(unsigned int x, unsigned int y) |
static int byte4_rgb(void *src) |
{ |
return *((__u32 *)(screen.fbaddress + POINTPOS(x, y))) & 0xffffff; |
return (*(int *)src) & 0xffffff; |
} |
/** Put pixel - 24-bit depth */ |
static void putpixel_3byte(unsigned int x, unsigned int y, int color) |
static void rgb_3byte(void *dst, int rgb) |
{ |
unsigned int startbyte = POINTPOS(x, y); |
__u8 *scr = dst; |
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
screen.fbaddress[startbyte] = RED(color, 8); |
screen.fbaddress[startbyte + 1] = GREEN(color, 8); |
screen.fbaddress[startbyte + 2] = BLUE(color, 8); |
scr[0] = RED(rgb, 8); |
scr[1] = GREEN(rgb, 8); |
scr[2] = BLUE(rgb, 8); |
#else |
screen.fbaddress[startbyte + 2] = RED(color, 8); |
screen.fbaddress[startbyte + 1] = GREEN(color, 8); |
screen.fbaddress[startbyte + 0] = BLUE(color, 8); |
scr[2] = RED(rgb, 8); |
scr[1] = GREEN(rgb, 8); |
scr[0] = BLUE(rgb, 8); |
#endif |
} |
/** Return pixel color - 24-bit depth */ |
static int getpixel_3byte(unsigned int x, unsigned int y) |
static int byte3_rgb(void *src) |
{ |
unsigned int startbyte = POINTPOS(x, y); |
__u8 *scr = src; |
#if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) |
return screen.fbaddress[startbyte] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 2]; |
return scr[0] << 16 | scr[1] << 8 | scr[2]; |
#else |
return screen.fbaddress[startbyte + 2] << 16 | screen.fbaddress[startbyte + 1] << 8 | screen.fbaddress[startbyte + 0]; |
#endif |
return scr[2] << 16 | scr[1] << 8 | scr[0]; |
#endif |
} |
/** Put pixel - 16-bit depth (5:6:5) */ |
static void putpixel_2byte(unsigned int x, unsigned int y, int color) |
/** 16-bit depth (5:6:5) */ |
static void rgb_2byte(void *dst, int rgb) |
{ |
/* 5-bit, 6-bits, 5-bits */ |
*((__u16 *)(screen.fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5); |
*((__u16 *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5); |
} |
/** Return pixel color - 16-bit depth (5:6:5) */ |
static int getpixel_2byte(unsigned int x, unsigned int y) |
/** 16-bit depth (5:6:5) */ |
static int byte2_rgb(void *src) |
{ |
int color = *((__u16 *)(screen.fbaddress + POINTPOS(x, y))); |
int color = *(__u16 *)(src); |
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
} |
/** Put pixel - 8-bit depth (3:2:3) */ |
static void putpixel_1byte(unsigned int x, unsigned int y, int color) |
static void rgb_1byte(void *dst, int rgb) |
{ |
screen.fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3); |
*(__u8 *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); |
} |
/** Return pixel color - 8-bit depth (3:2:3) */ |
static int getpixel_1byte(unsigned int x, unsigned int y) |
static int byte1_rgb(void *src) |
{ |
int color = screen.fbaddress[POINTPOS(x, y)]; |
int color = *(__u8 *)src; |
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
} |
191,12 → 183,17 |
*/ |
static void putpixel(int vp, unsigned int x, unsigned int y, int color) |
{ |
screen.putpixel(viewports[vp].x + x, viewports[vp].y + y, color); |
int dx = viewports[vp].x + x; |
int dy = viewports[vp].y + y; |
(*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],color); |
} |
/** Get pixel from viewport */ |
static int getpixel(int vp, unsigned int x, unsigned int y) |
{ |
return screen.getpixel(viewports[vp].x + x, viewports[vp].y + y); |
int dx = viewports[vp].x + x; |
int dy = viewports[vp].y + y; |
return (*screen.scr2rgb)(&screen.fbaddress[POINTPOS(dx,dy)]); |
} |
/** Fill line with color BGCOLOR */ |
358,23 → 355,23 |
{ |
switch (bpp) { |
case 8: |
screen.putpixel = putpixel_1byte; |
screen.getpixel = getpixel_1byte; |
screen.rgb2scr = rgb_1byte; |
screen.scr2rgb = byte1_rgb; |
screen.pixelbytes = 1; |
break; |
case 16: |
screen.putpixel = putpixel_2byte; |
screen.getpixel = getpixel_2byte; |
screen.rgb2scr = rgb_2byte; |
screen.scr2rgb = byte2_rgb; |
screen.pixelbytes = 2; |
break; |
case 24: |
screen.putpixel = putpixel_3byte; |
screen.getpixel = getpixel_3byte; |
screen.rgb2scr = rgb_3byte; |
screen.scr2rgb = byte3_rgb; |
screen.pixelbytes = 3; |
break; |
case 32: |
screen.putpixel = putpixel_4byte; |
screen.getpixel = getpixel_4byte; |
screen.rgb2scr = rgb_4byte; |
screen.scr2rgb = byte4_rgb; |
screen.pixelbytes = 4; |
break; |
} |
477,6 → 474,50 |
cursor_print(vp); |
} |
/** Return first free pixmap */ |
static int find_free_pixmap(void) |
{ |
int i; |
for (i=0;i < MAX_PIXMAPS;i++) |
if (!pixmaps[i].data) |
return i; |
return -1; |
} |
static void putpixel_pixmap(int pm, unsigned int x, unsigned int y, int color) |
{ |
pixmap_t *pmap = &pixmaps[pm]; |
int pos = (y * pmap->width + x) * screen.pixelbytes; |
(*screen.rgb2scr)(&pmap->data[pos],color); |
} |
/** Create a new pixmap and return appropriate ID */ |
static int shm2pixmap(char *shm, size_t size) |
{ |
int pm; |
pixmap_t *pmap; |
pm = find_free_pixmap(); |
if (pm == -1) |
return ELIMIT; |
pmap = &pixmaps[pm]; |
if (ppm_get_data(shm, size, &pmap->width, &pmap->height)) |
return EINVAL; |
pmap->data = malloc(pmap->width * pmap->height * screen.pixelbytes); |
if (!pmap->data) |
return ENOMEM; |
ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, |
putpixel_pixmap, pm); |
return pm; |
} |
/** Handle shared memory communication calls |
* |
* Protocol for drawing pixmaps: |
502,9 → 543,9 |
static keyfield_t *interbuffer = NULL; |
static size_t intersize = 0; |
static char *pixmap = NULL; |
static ipcarg_t pixmap_id = 0; |
static size_t pixmap_size; |
static char *shm = NULL; |
static ipcarg_t shm_id = 0; |
static size_t shm_size; |
int handled = 1; |
int retval = 0; |
514,14 → 555,14 |
switch (IPC_GET_METHOD(*call)) { |
case IPC_M_AS_AREA_SEND: |
/* We accept one area for data interchange */ |
if (IPC_GET_ARG1(*call) == pixmap_id) { |
if (IPC_GET_ARG1(*call) == shm_id) { |
void *dest = as_get_mappable_page(IPC_GET_ARG2(*call)); |
pixmap_size = IPC_GET_ARG2(*call); |
shm_size = IPC_GET_ARG2(*call); |
if (!ipc_answer_fast(callid, 0, (sysarg_t)dest, 0)) |
pixmap = dest; |
shm = dest; |
else |
pixmap_id = 0; |
if (pixmap[0] != 'P') |
shm_id = 0; |
if (shm[0] != 'P') |
while (1) |
; |
return 1; |
531,22 → 572,29 |
} |
return 1; |
case FB_PREPARE_SHM: |
if (pixmap_id) |
if (shm_id) |
retval = EBUSY; |
else |
pixmap_id = IPC_GET_ARG1(*call); |
shm_id = IPC_GET_ARG1(*call); |
break; |
case FB_DROP_SHM: |
if (pixmap) { |
as_area_destroy(pixmap); |
pixmap = NULL; |
if (shm) { |
as_area_destroy(shm); |
shm = NULL; |
} |
pixmap_id = 0; |
shm_id = 0; |
break; |
case FB_SHM2PIXMAP: |
if (!shm) { |
retval = EINVAL; |
break; |
} |
retval = shm2pixmap(shm, shm_size); |
break; |
case FB_DRAW_PPM: |
if (!pixmap) { |
if (!shm) { |
retval = EINVAL; |
break; |
} |
557,7 → 605,7 |
break; |
} |
draw_ppm(pixmap, pixmap_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), |
ppm_draw(shm, shm_size, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call), |
vport->width - x, vport->height - y, putpixel, vp); |
break; |
case FB_DRAW_TEXT_DATA: |
580,17 → 628,6 |
return handled; |
} |
/** Return first free pixmap */ |
static int find_free_pixmap(void) |
{ |
int i; |
for (i=0;i < MAX_PIXMAPS;i++) |
if (!pixmaps[i].data) |
return i; |
return -1; |
} |
/** Save viewport to pixmap */ |
static int save_vp_to_pixmap(int vp) |
{ |
//uspace/trunk/fb/ppm.c |
---|
56,6 → 56,21 |
} |
} |
int ppm_get_data(unsigned char *data, size_t dtsz, int *width, int *height) |
{ |
/* Read magic */ |
if (data[0] != 'P' || data[1] != '6') |
return EINVAL; |
data+=2; |
skip_whitespace(&data); |
read_num(&data, width); |
skip_whitespace(&data); |
read_num(&data,height); |
return 0; |
} |
/** Draw PPM pixmap |
* |
* @param data Pointer to PPM data |
66,7 → 81,7 |
* @param maxheight Maximum allowed height for picture |
* @param putpixel Putpixel function used to print bitmap |
*/ |
int draw_ppm(unsigned char *data, size_t datasz, unsigned int sx, |
int ppm_draw(unsigned char *data, size_t datasz, unsigned int sx, |
unsigned int sy, |
unsigned int maxwidth, unsigned int maxheight, |
void (*putpixel)(int,unsigned int, unsigned int, int),int vp) |
104,7 → 119,7 |
data += 3; |
continue; |
} |
color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[0]*coef; |
color = ((data[0]*coef) << 16) + ((data[1]*coef) << 8) + data[2]*coef; |
(*putpixel)(vp, sx+(i % width), sy+(i / width), color); |
data += 3; |