/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */ /**************************************************************************/ /**************************************************************************/ /**************************************************************************/ /** */ /** 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_16bpp_canvas_copy PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Kenneth Maxwell, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* Generic 16bpp 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_16bpp_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite) { GX_RECTANGLE dirty; GX_RECTANGLE overlap; USHORT *read; USHORT *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 - (GX_VALUE)1); dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - (GX_VALUE)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 = (USHORT *)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 = (USHORT *)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 * 2)); /* Use case of memcpy is verified. */ write += composite -> gx_canvas_x_resolution; read += canvas -> gx_canvas_x_resolution; } } }