/*************************************************************************** * Copyright (c) 2024 Microsoft Corporation * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ /** */ /** GUIX Component */ /** */ /** Display Management (Display) */ /** */ /**************************************************************************/ #define GX_SOURCE_CODE /* Include necessary system files. */ #include "gx_api.h" #include "gx_display.h" /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _gx_display_driver_32argb_pixelmap_raw_blend PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* Kenneth Maxwell, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* Internal helper function that handles blending of uncompressed */ /* pixlemap file without alpha channel. */ /* */ /* INPUT */ /* */ /* context Drawing context */ /* xpos x-coord of top-left draw point*/ /* ypos y-coord of top-left draw point*/ /* pixelmap Pointer to GX_PIXELMAP struct */ /* alpha blending value 0 to 255 */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _gx_display_driver_32xrgb_pixel_blend Display driver pixel blend */ /* function */ /* */ /* CALLED BY */ /* */ /* _gx_display_driver_32argb_pixelmap_blend */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ /* resulting in version 6.1 */ /* 06-02-2021 Kenneth Maxwell Modified comment(s), */ /* removed unused variable */ /* assignment, */ /* resulting in version 6.1.7 */ /* */ /**************************************************************************/ static VOID _gx_display_driver_32argb_pixelmap_raw_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha) { INT yval; INT xval; GX_COLOR color; GX_COLOR *get; GX_COLOR *getrow; GX_RECTANGLE *clip = context -> gx_draw_context_clip; getrow = (GX_COLOR *)((UINT)(pixelmap -> gx_pixelmap_data) + sizeof(GX_COLOR) * (UINT)(pixelmap -> gx_pixelmap_width) * (UINT)((INT)(clip -> gx_rectangle_top) - ypos)); getrow += (clip -> gx_rectangle_left - xpos); for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++) { get = getrow; for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++) { color = *get; get++; _gx_display_driver_32argb_pixel_blend(context, xval, yval, color, alpha); } getrow += pixelmap -> gx_pixelmap_width; } } /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _gx_display_driver_32argb_pixelmap_alpha_blend PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* Kenneth Maxwell, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* Internal helper function that handles blending of uncompressed */ /* pixlemap file with alpha channel. */ /* */ /* INPUT */ /* */ /* context Drawing context */ /* xpos x-coord of top-left draw point*/ /* ypos y-coord of top-left draw point*/ /* pixelmap Pointer to GX_PIXELMAP struct */ /* alpha blending value 0 to 255 */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _gx_display_driver_32xrgb_pixel_blend Display driver pixel blend */ /* function */ /* */ /* CALLED BY */ /* */ /* _gx_display_driver_32argb_pixelmap_blend */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ /* resulting in version 6.1 */ /* 06-02-2021 Kenneth Maxwell Modified comment(s), */ /* removed unused variable */ /* assignment, */ /* resulting in version 6.1.7 */ /* */ /**************************************************************************/ static VOID _gx_display_driver_32argb_pixelmap_alpha_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha) { int xval; int yval; int color; int width; ULONG *get; GX_RECTANGLE *clip = context -> gx_draw_context_clip; get = (ULONG *)((pixelmap -> gx_pixelmap_data) + sizeof(GX_COLOR) * (UINT)pixelmap -> gx_pixelmap_width * (UINT)((INT)clip -> gx_rectangle_top - ypos)); get += (clip -> gx_rectangle_left - xpos); width = clip -> gx_rectangle_right - clip -> gx_rectangle_left + 1; for (yval = clip -> gx_rectangle_top; yval <= clip -> gx_rectangle_bottom; yval++) { for (xval = clip -> gx_rectangle_left; xval <= clip -> gx_rectangle_right; xval++) { color = (int)(*get); _gx_display_driver_32argb_pixel_blend(context, xval, yval, (GX_COLOR)color, alpha); get++; } get += pixelmap -> gx_pixelmap_width - width; } } /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _gx_display_driver_32argb_pixelmap_blend PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Kenneth Maxwell, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* 32xrgb format screen driver pixelmap blending function that */ /* handles compressed or uncompress, with or without alpha channel. */ /* */ /* INPUT */ /* */ /* context Drawing context */ /* xpos x-coord of top-left draw point*/ /* ypos y-coord of top-left draw point*/ /* pixelmap Pointer to GX_PIXELMAP struct */ /* alpha blending value 0 to 255 */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _gx_display_driver_32argb_pixelmap_alpha_blend */ /* Real pixelmap blend function */ /* _gx_display_driver_32argb_pixelmap_raw_blend */ /* Real pixelmap blend function */ /* */ /* CALLED BY */ /* */ /* GUIX Internal Code */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ /* resulting in version 6.1 */ /* */ /**************************************************************************/ VOID _gx_display_driver_32argb_pixelmap_blend(GX_DRAW_CONTEXT *context, INT xpos, INT ypos, GX_PIXELMAP *pixelmap, GX_UBYTE alpha) { if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_TRANSPARENT) { /* Not supported yet. */ return; } if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED) { return; } if (pixelmap -> gx_pixelmap_format != GX_COLOR_FORMAT_32ARGB) { /* wrong color format for this driver */ return; } if (pixelmap -> gx_pixelmap_flags & GX_PIXELMAP_ALPHA) { /* alpha, no compression */ _gx_display_driver_32argb_pixelmap_alpha_blend(context, xpos, ypos, pixelmap, alpha); } else { /* no compression or alpha */ _gx_display_driver_32argb_pixelmap_raw_blend(context, xpos, ypos, pixelmap, alpha); } }