summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include/cbgfx.h
diff options
context:
space:
mode:
authorShelley Chen <shchen@google.com>2020-07-10 14:52:43 -0700
committerJulius Werner <jwerner@chromium.org>2020-07-15 20:23:07 +0000
commit31a37887392e81e8a24eca83f4b261019c05ebd5 (patch)
treeb9256963b5c73c8cd0e4719faaba55c7c7c97f83 /payloads/libpayload/include/cbgfx.h
parentdf5571dc9d94717a3eb32c56c950715b504c1b52 (diff)
cbgfx: Add blend functions to calculate transparency
Up until now we have no way of adding transparency into our firmware screens. Add set_blend() and clear_blend() functions to store alpha value and rgb values to calculate alpha blending in calculate_colors(). BUG=b:144969091,b:160839199 BRANCH=puff TEST=dut-control power_state:rec press ctrl-d Ensure background is dimmed when dialog pops up Change-Id: I95468f27836d34ab80392727d726a69c09dc168e Signed-off-by: Shelley Chen <shchen@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/43358 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'payloads/libpayload/include/cbgfx.h')
-rw-r--r--payloads/libpayload/include/cbgfx.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/payloads/libpayload/include/cbgfx.h b/payloads/libpayload/include/cbgfx.h
index 869f272722..84e76f26d1 100644
--- a/payloads/libpayload/include/cbgfx.h
+++ b/payloads/libpayload/include/cbgfx.h
@@ -210,3 +210,33 @@ int draw_bitmap_direct(const void *bitmap, size_t size,
* in the original size are returned.
*/
int get_bitmap_dimension(const void *bitmap, size_t sz, struct scale *dim_rel);
+
+/**
+ * Setup alpha and rgb values for alpha blending. When alpha is != 0,
+ * this enables a translucent layer of color (defined by rgb) to be
+ * blended at a given translucency (alpha) to all things drawn. Call
+ * clear_blend() to disable alpha blending.
+ *
+ * @param[in] rgb Color for transparency
+ * @param[in] alpha Opacity of color, from 0-255 where
+ * 0 = completely transparent (no blending)
+ * 255 = max alpha argument
+ *
+ * @return CBGFX_* error codes
+ */
+int set_blend(const struct rgb_color *rgb, uint8_t alpha);
+
+/**
+ * Clear alpha and rgb values, thus disabling any alpha blending.
+ *
+ * @return CBGFX_* error codes
+ */
+void clear_blend(void);
+
+/**
+ * For calculating Alpha value from % opacity
+ * For reference:
+ * 255 = max alpha argument
+ * 0 = min alpha argument, 0% opacity
+ */
+#define ALPHA(percentage) MIN(255, (256 * percentage / 100))