/*************************************************************************** * 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" #include "gx_utility.h" /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _gx_display_driver_8bpp_canvas_copy PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Kenneth Maxwell, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* Generic 8bpp canvas copy function. */ /* */ /* INPUT */ /* */ /* canvas The canvas to copy from */ /* composite The canvas to copy to */ /* */ /* OUTPUT */ /* */ /* None */ /* */ /* CALLS */ /* */ /* _gx_utility_rectangle_shift Move the rectangle */ /* _gx_utility_rectangle_overlap_detect Detect two rectangles being */ /* overlap to each other */ /* memcpy Move canvas data */ /* */ /* 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_8bpp_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite) { GX_RECTANGLE dirty; GX_RECTANGLE overlap; GX_UBYTE *read; GX_UBYTE *write; INT width; INT row; dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0; dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1); dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1); _gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y); if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap)) { width = overlap.gx_rectangle_right - overlap.gx_rectangle_left + 1; read = (GX_UBYTE *)canvas -> gx_canvas_memory; /* index into starting row */ read += (overlap.gx_rectangle_top - dirty.gx_rectangle_top) * canvas -> gx_canvas_x_resolution; /* index into pixel */ read += overlap.gx_rectangle_left - dirty.gx_rectangle_left; /* calculate the write pointer */ write = (GX_UBYTE *)composite -> gx_canvas_memory; write += overlap.gx_rectangle_top * composite -> gx_canvas_x_resolution; write += overlap.gx_rectangle_left; for (row = overlap.gx_rectangle_top; row <= overlap.gx_rectangle_bottom; row++) { memcpy(write, read, (size_t)width); /* Use case of memcpy is verified. */ write += composite -> gx_canvas_x_resolution; read += canvas -> gx_canvas_x_resolution; } } }