Changeset bc52b5b in mainline for uspace/lib/gfx/src/color.c


Ignore:
Timestamp:
2021-08-15T10:02:32Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
99589a9
Parents:
de0c55a
Message:

Allow the use of EGA attributes/24-bit characters alongside RGB

In a big hack (since we cannot have different pixel formats yet) we
use a pixel format that allows both 24-bit RGB (without character)
or 24-bit character with 8-bit attributes. Thus in GFX we cannot
currently have characters with any RGB color, but we can set
foreground and background individually (and it even works in EGA mode).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/gfx/src/color.c

    rde0c55a rbc52b5b  
    11/*
    2  * Copyright (c) 2019 Jiri Svoboda
     2 * Copyright (c) 2021 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    6969}
    7070
     71/** Create new EGA color.
     72 *
     73 * @param attr EGA attributes
     74 * @param rcolor Place to store pointer to new color
     75 *
     76 * @return EOK on success or an error code, ENOMEM if out of resources,
     77 *         EIO if the graphic device connection was lost
     78 */
     79errno_t gfx_color_new_ega(uint8_t attr, gfx_color_t **rcolor)
     80{
     81        gfx_color_t *color;
     82
     83        color = calloc(1, sizeof(gfx_color_t));
     84        if (color == NULL)
     85                return ENOMEM;
     86
     87        color->attr = attr;
     88
     89        *rcolor = color;
     90        return EOK;
     91}
     92
    7193/** Delete color.
    7294 *
     
    93115}
    94116
     117/** Convert color to EGA attributes.
     118 *
     119 * @param color Color
     120 * @param attr Place to store EGA attributes
     121 */
     122void gfx_color_get_ega(gfx_color_t *color, uint8_t *attr)
     123{
     124        *attr = color->attr;
     125}
     126
    95127/** @}
    96128 */
Note: See TracChangeset for help on using the changeset viewer.