2 * This file is part of the libpayload project.
4 * Copyright (C) 2015 Google, Inc.
7 #include <libpayload.h>
8 #include <arch/types.h>
14 #define CBGFX_SUCCESS 0
16 #define CBGFX_ERROR_UNKNOWN 1
17 /* failed to initialize cbgfx library */
18 #define CBGFX_ERROR_INIT 2
19 /* drawing beyond screen boundary */
20 #define CBGFX_ERROR_SCREEN_BOUNDARY 3
21 /* drawing beyond canvas boundary */
22 #define CBGFX_ERROR_CANVAS_BOUNDARY 4
23 /* bitmap error: signature mismatch */
24 #define CBGFX_ERROR_BITMAP_SIGNATURE 0x10
25 /* bitmap error: unsupported format */
26 #define CBGFX_ERROR_BITMAP_FORMAT 0x11
27 /* bitmap error: invalid data */
28 #define CBGFX_ERROR_BITMAP_DATA 0x12
29 /* bitmap error: scaling out of range */
30 #define CBGFX_ERROR_SCALE_OUT_OF_RANGE 0x13
65 * Resolution of scale parameters used to describe height, width, coordinate,
66 * etc. relative to the canvas. For example, if it's 100, scales range from 0 to
69 #define CANVAS_SCALE 100
72 * The coordinate system is expected to have (0, 0) at top left corner with
73 * y values increasing towards bottom of screen.
77 * draw a box filled with a color on screen
79 * box: .offset points the coordinate of the top left corner and .size specifies
80 * width and height of the box. Both are relative to the canvas size thus scale
81 * from 0 to CANVAS_SCALE (0 to 100%).
82 * rgb: RGB color of the box.
84 * return: CBGFX_* error codes
86 int draw_box(const struct rect
*box
, const struct rgb_color
*rgb
);
91 int clear_canvas(struct rgb_color
*rgb
);
94 * Draw a bitmap image on screen.
96 * top_left_rel: coordinate of the top left corner of the image relative to the
97 * canvas (0 - CANVAS_SCALE). If scale_rel is zero, this is treated as absolute
99 * scale_rel: scale factor relative to the canvas width (0 - CANVAS_SCALE). If
100 * this is zero, scaling is turned off and the image is rendered with the
102 * bitmap: pointer to the bitmap data, starting from the file header.
103 * size: size of the bitmap data
105 * return: CBGFX_* error codes
107 int draw_bitmap(const struct vector
*top_left_rel
,
108 size_t scale_rel
, const void *bitmap
, size_t size
);