summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2020-07-15 15:37:00 +0800
committerJoel Kitching <kitching@google.com>2020-07-23 05:09:31 +0000
commitb086728094d70b3455ddc66c513571e319516efe (patch)
tree476d35fb0fad75ef082bf6ce44040cc5b4d0b374 /payloads/libpayload/include
parent918073d9bf7620694b94d24b369fb2e08acec624 (diff)
libpayload: cbgfx: Add draw_line()
Add a function draw_line() to draw either a horizontal or vertical line segment. Theoretically a horizontal line can also be drawn by calling draw_rounded_box() with dim_rel.x being the line length and dim_rel.y being the line width. However, due to the truncation in integer division when converting relative coordinates to absolute ones, this will potentially produce inconsistent line widths, depending on the value of pos_rel.y. It is guaranteed that draw_line() will produce consistent line widths, regardless of the position of the line. Also, when the thickness argument is zero, this function is able to draw a line with 1-pixel width, which is not achievable by draw_rounded_box(). BRANCH=puff BUG=b:146399181, b:161424726 TEST=emerge-puff libpayload Change-Id: I2d50414c4bfed343516197da9bb50791c89ba4c2 Signed-off-by: Yu-Ping Wu <yupingso@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/43508 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Joel Kitching <kitching@google.com>
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r--payloads/libpayload/include/cbgfx.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/payloads/libpayload/include/cbgfx.h b/payloads/libpayload/include/cbgfx.h
index 84e76f26d1..f2883b0c43 100644
--- a/payloads/libpayload/include/cbgfx.h
+++ b/payloads/libpayload/include/cbgfx.h
@@ -133,6 +133,22 @@ int draw_rounded_box(const struct scale *pos_rel, const struct scale *dim_rel,
const struct fraction *radius);
/**
+ * Draw a horizontal or vertical line segment on screen. If horizontal, pos1
+ * must be the left endpoint. If vertical, pos1 must be the top endpoint. When
+ * the specified thickness is zero (or truncated to zero), a line with 1-pixel
+ * width will be drawn.
+ *
+ * @param[in] pos1 Start position of the line relative to the canvas.
+ * @param[in] pos2 End position of the line relative to the canvas.
+ * @param[in] thickness Thickness of the line relative to the canvas.
+ * @param[in] rgb Color of the line.
+ *
+ * @return CBGFX_* error codes
+ */
+int draw_line(const struct scale *pos1, const struct scale *pos2,
+ const struct fraction *thickness, const struct rgb_color *rgb);
+
+/**
* Clear the canvas
*/
int clear_canvas(const struct rgb_color *rgb);