Graphical framebuffer
[Framebuffer Service]

HelenOS graphical framebuffer. More...

Files

file  fb.c
file  fb.h

Data Structures

struct  animation_t
struct  bb_cell_t
 Backbuffer character cell. More...
struct  pixmap_t
struct  viewport_t

Defines

#define BB_POS(vport, col, row)   ((row) * vport->cols + (col))
#define BLUE(x, bits)   (((x) >> (8 - (bits))) & ((1 << (bits)) - 1))
#define COL2X(col)   ((col) * FONT_WIDTH)
#define DEFAULT_BGCOLOR   0xf0f0f0
#define DEFAULT_FGCOLOR   0x000000
#define FB_POS(x, y)   ((y) * screen.scanline + (x) * screen.pixelbytes)
#define GLYPH_POS(glyph, y, cursor)   (((glyph) + (cursor) * FONT_GLYPHS) * screen.glyphbytes + (y) * screen.glyphscanline)
#define GLYPH_UNAVAIL   '?'
#define GREEN(x, bits)   (((x) >> (8 + 8 - (bits))) & ((1 << (bits)) - 1))
#define MAX_ANIM_LEN   8
#define MAX_ANIMATIONS   4
#define MAX_PIXMAPS   256
 Maximum number of saved pixmaps.
#define MAX_VIEWPORTS   128
 Viewport is a rectangular area on the screen.
#define RED(x, bits)   (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1))
#define ROW2Y(row)   ((row) * FONT_SCANLINES)
#define X2COL(x)   ((x) / FONT_WIDTH)
#define Y2ROW(y)   ((y) / FONT_SCANLINES)

Typedefs

typedef void(*) dg_t (unsigned int x, unsigned int y, bool cursor, uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color)
 Function to draw a glyph.
typedef void(*) mask_conv_t (void *, bool)
 Function to render a bit mask.
typedef void(*) putpixel_cb_t (void *, unsigned int, unsigned int, uint32_t)
typedef void(*) rgb_conv_t (void *, uint32_t)
 Function to render a pixel from a RGB value.

Functions

static int anim_handle (ipc_callid_t callid, ipc_call_t *call, int vp)
static void anims_tick (void)
 Tick animation one step forward.
static void backbuf_clear (bb_cell_t *backbuf, size_t len, uint32_t fg_color, uint32_t bg_color)
static void bgr_0888 (void *dst, uint32_t rgb)
static void bgr_323 (void *dst, uint32_t rgb)
static void bgr_888 (void *dst, uint32_t rgb)
static void bgr_8880 (void *dst, uint32_t rgb)
static void copy_vp_to_pixmap (viewport_t *vport, pixmap_t *pmap)
static void cursor_blink (viewport_t *vport)
 Invert cursor, if it is enabled.
static void cursor_hide (viewport_t *vport)
 Hide cursor if it is shown.
static void cursor_show (viewport_t *vport)
 Show cursor if cursor showing is enabled.
static void draw_char (viewport_t *vport, wchar_t c, unsigned int col, unsigned int row)
 Draw character at given position relative to viewport.
static void draw_filled_rect (unsigned int x0, unsigned int y0, unsigned int x1, unsigned int y1, uint32_t color)
 Draw a filled rectangle.
static void draw_glyph_aligned (unsigned int x, unsigned int y, bool cursor, uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color)
 Draw a glyph, takes advantage of alignment.
static void draw_glyph_fallback (unsigned int x, unsigned int y, bool cursor, uint8_t *glyphs, uint32_t glyph, uint32_t fg_color, uint32_t bg_color)
 Draw a glyph, fallback version.
static int draw_pixmap (int vp, int pm)
 Draw pixmap on screen.
static void draw_text_data (viewport_t *vport, keyfield_t *data, unsigned int x, unsigned int y, unsigned int w, unsigned int h)
 Draw text data to viewport.
static void draw_vp_glyph (viewport_t *vport, bool cursor, unsigned int col, unsigned int row)
 Draw glyph at specified position in viewport.
static void fb_client_connection (ipc_callid_t iid, ipc_call_t *icall)
 Function for handling connections to FB.
int fb_init (void)
 Initialization of framebuffer.
static int fb_set_color (viewport_t *vport, sysarg_t fg_color, sysarg_t bg_color, sysarg_t attr)
static int fb_set_style (viewport_t *vport, sysarg_t style)
static int find_free_pixmap (void)
 Return first free pixmap.
static void mask_0888 (void *dst, bool mask)
static void mask_323 (void *dst, bool mask)
static void mask_555 (void *dst, bool mask)
static void mask_565 (void *dst, bool mask)
static void mask_888 (void *dst, bool mask)
static void mask_8880 (void *dst, bool mask)
static void mouse_hide (void)
static void mouse_move (unsigned int x, unsigned int y)
static void mouse_show (void)
static int pixmap_handle (ipc_callid_t callid, ipc_call_t *call, int vp)
 Handler for messages concerning pixmap handling.
static void putpixel (void *data, unsigned int x, unsigned int y, uint32_t color)
static void putpixel_pixmap (void *data, unsigned int x, unsigned int y, uint32_t color)
static void render_glyphs (void)
 Render glyphs.
static void rgb_0888 (void *dst, uint32_t rgb)
static void rgb_555_be (void *dst, uint32_t rgb)
static void rgb_555_le (void *dst, uint32_t rgb)
static void rgb_565_be (void *dst, uint32_t rgb)
static void rgb_565_le (void *dst, uint32_t rgb)
static void rgb_888 (void *dst, uint32_t rgb)
static void rgb_8880 (void *dst, uint32_t rgb)
static int rgb_from_attr (attr_rgb_t *rgb, const attrs_t *a)
static int rgb_from_idx (attr_rgb_t *rgb, sysarg_t fg_color, sysarg_t bg_color, sysarg_t flags)
static int rgb_from_style (attr_rgb_t *rgb, int style)
static int save_vp_to_pixmap (viewport_t *vport)
 Save viewport to pixmap.
static bool screen_init (void *addr, unsigned int xres, unsigned int yres, unsigned int scan, unsigned int visual)
 Initialize framebuffer as a chardev output device.
static int shm2pixmap (unsigned char *shm, size_t size)
 Create a new pixmap and return appropriate ID.
static bool shm_handle (ipc_callid_t callid, ipc_call_t *call, int vp)
 Handle shared memory communication calls.
static void vport_clear (viewport_t *vport)
 Clear viewport.
static int vport_create (unsigned int x, unsigned int y, unsigned int width, unsigned int height)
 Create new viewport.
static void vport_redraw (viewport_t *vport)
 Redraw viewport.
static void vport_scroll (viewport_t *vport, int lines)
 Scroll viewport by the specified number of lines.

Variables

static animation_t animations [MAX_ANIMATIONS]
static bool anims_enabled
static bool client_connected = false
 Allow only 1 connection.
static uint32_t color_table [16]
static pixmap_t pixmaps [MAX_PIXMAPS]
static bool pointer_enabled
static int pointer_pixmap = -1
static bool pointer_shown
static int pointer_vport = -1
static unsigned int pointer_x
static unsigned int pointer_y
static viewport_t viewports [128]

Detailed Description

HelenOS graphical framebuffer.


Function Documentation

static void draw_char ( viewport_t vport,
wchar_t  c,
unsigned int  col,
unsigned int  row 
) [static]

Draw character at given position relative to viewport.

Parameters:
vport Viewport identification
c Character to draw
col Screen position relative to viewport
row Screen position relative to viewport

Definition at line 910 of file fb.c.

static void draw_filled_rect ( unsigned int  x0,
unsigned int  y0,
unsigned int  x1,
unsigned int  y1,
uint32_t  color 
) [static]

Draw a filled rectangle.

Note:
Need real implementation that does not access VRAM twice.

Definition at line 341 of file fb.c.

static void draw_glyph_aligned ( unsigned int  x,
unsigned int  y,
bool  cursor,
uint8_t *  glyphs,
uint32_t  glyph,
uint32_t  fg_color,
uint32_t  bg_color 
) [static]

Draw a glyph, takes advantage of alignment.

This version can only be used if the following conditions are met:

It makes use of the pre-rendered mask to process (possibly) several pixels at once (word size / pixelbytes pixels at a time are processed) making it very fast. Most notably this version is not applicable at 24 bits per pixel.

Parameters:
x x coordinate of top-left corner on screen.
y y coordinate of top-left corner on screen.
cursor Draw glyph with cursor
glyphs Pointer to font bitmap.
glyph Code of the glyph to draw.
fg_color Foreground color.
bg_color Backgroudn color.

Definition at line 734 of file fb.c.

void draw_glyph_fallback ( unsigned int  x,
unsigned int  y,
bool  cursor,
uint8_t *  glyphs,
uint32_t  glyph,
uint32_t  fg_color,
uint32_t  bg_color 
) [static]

Draw a glyph, fallback version.

This version does not make use of the pre-rendered mask, it uses the font bitmap directly. It works always, but it is slower.

Parameters:
x x coordinate of top-left corner on screen.
y y coordinate of top-left corner on screen.
cursor Draw glyph with cursor
glyphs Pointer to font bitmap.
glyph Code of the glyph to draw.
fg_color Foreground color.
bg_color Backgroudn color.

Definition at line 795 of file fb.c.

static int draw_pixmap ( int  vp,
int  pm 
) [static]

Draw pixmap on screen.

Parameters:
vp Viewport to draw on
pm Pixmap identifier

Definition at line 1228 of file fb.c.

static void draw_text_data ( viewport_t vport,
keyfield_t data,
unsigned int  x,
unsigned int  y,
unsigned int  w,
unsigned int  h 
) [static]

Draw text data to viewport.

Parameters:
vport Viewport id
data Text data.
x Leftmost column of the area.
y Topmost row of the area.
w Number of rows.
h Number of columns.

Definition at line 950 of file fb.c.

static void draw_vp_glyph ( viewport_t vport,
bool  cursor,
unsigned int  col,
unsigned int  row 
) [static]

Draw glyph at specified position in viewport.

Parameters:
vport Viewport identification
cursor Draw glyph with cursor
col Screen position relative to viewport
row Screen position relative to viewport

Definition at line 851 of file fb.c.

static void render_glyphs ( void   )  [static]

Render glyphs.

Convert glyphs from device independent font description to current visual representation.

Definition at line 508 of file fb.c.

static bool screen_init ( void *  addr,
unsigned int  xres,
unsigned int  yres,
unsigned int  scan,
unsigned int  visual 
) [static]

Initialize framebuffer as a chardev output device.

Parameters:
addr Address of the framebuffer
xres Screen width in pixels
yres Screen height in pixels
visual Bits per pixel (8, 16, 24, 32)
scan Bytes per one scanline

Definition at line 624 of file fb.c.

static bool shm_handle ( ipc_callid_t  callid,
ipc_call_t call,
int  vp 
) [static]

Handle shared memory communication calls.

Protocol for drawing pixmaps:

Protocol for text drawing

Parameters:
callid Callid of the current call
call Current call data
vp Active viewport
Returns:
false if the call was not handled byt this function, true otherwise
Note: this function is not thread-safe, you would have to redefine static variables with fibril_local.

Definition at line 1067 of file fb.c.

static void vport_clear ( viewport_t vport  )  [static]

Clear viewport.

Parameters:
vport Viewport to clear

Definition at line 424 of file fb.c.

static int vport_create ( unsigned int  x,
unsigned int  y,
unsigned int  width,
unsigned int  height 
) [static]

Create new viewport.

Parameters:
x Origin of the viewport (x).
y Origin of the viewport (y).
width Width of the viewport.
height Height of the viewport.
Returns:
New viewport number.

Definition at line 539 of file fb.c.

static void vport_redraw ( viewport_t vport  )  [static]

Redraw viewport.

Parameters:
vport Viewport to redraw

Definition at line 381 of file fb.c.

static void vport_scroll ( viewport_t vport,
int  lines 
) [static]

Scroll viewport by the specified number of lines.

Parameters:
vport Viewport to scroll
lines Number of lines to scroll

Definition at line 437 of file fb.c.


Variable Documentation

uint8_t* glyphs [inherited]

Pre-rendered mask for rendering glyphs.

Specific for the visual.

Definition at line 103 of file fb.c.


Generated on Thu Jun 2 07:45:56 2011 for HelenOS/USB by  doxygen 1.4.7