1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** GUIX Component */ 17 /** */ 18 /** Display Management (Display) */ 19 /** */ 20 /**************************************************************************/ 21 22 #define GX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "gx_api.h" 28 #include "gx_display.h" 29 #include "gx_utility.h" 30 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_display_driver_32bpp_rotated_canvas_copy PORTABLE C */ 38 /* 6.1.4 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* Generic rotated 32bpp canvas copy function. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* canvas The canvas to copy from */ 50 /* composite The canvas to copy to */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* None */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* _gx_utility_rectangle_shift Move the rectangle */ 59 /* _gx_utility_rectangle_overlap_detect Detect two rectangles being */ 60 /* overlap to each other */ 61 /* memcpy Move canvas data */ 62 /* */ 63 /* CALLED BY */ 64 /* */ 65 /* GUIX Internal Code */ 66 /* */ 67 /* RELEASE HISTORY */ 68 /* */ 69 /* DATE NAME DESCRIPTION */ 70 /* */ 71 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */ 72 /* */ 73 /**************************************************************************/ _gx_display_driver_32bpp_rotated_canvas_copy(GX_CANVAS * canvas,GX_CANVAS * composite)74VOID _gx_display_driver_32bpp_rotated_canvas_copy(GX_CANVAS *canvas, GX_CANVAS *composite) 75 { 76 GX_RECTANGLE dirty; 77 GX_RECTANGLE overlap; 78 ULONG *read; 79 ULONG *write; 80 INT width; 81 INT row; 82 83 dirty.gx_rectangle_left = dirty.gx_rectangle_top = 0; 84 dirty.gx_rectangle_right = (GX_VALUE)(canvas -> gx_canvas_x_resolution - 1); 85 dirty.gx_rectangle_bottom = (GX_VALUE)(canvas -> gx_canvas_y_resolution - 1); 86 87 _gx_utility_rectangle_shift(&dirty, canvas -> gx_canvas_display_offset_x, canvas -> gx_canvas_display_offset_y); 88 89 if (_gx_utility_rectangle_overlap_detect(&dirty, &composite -> gx_canvas_dirty_area, &overlap)) 90 { 91 width = overlap.gx_rectangle_bottom - overlap.gx_rectangle_top + 1; 92 read = (ULONG *)canvas -> gx_canvas_memory; 93 write = (ULONG *)composite -> gx_canvas_memory; 94 95 if (canvas -> gx_canvas_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) 96 { 97 /* Index into starting row. */ 98 read += (dirty.gx_rectangle_right - overlap.gx_rectangle_right) * canvas -> gx_canvas_y_resolution; 99 100 /* Index into pixel. */ 101 read += overlap.gx_rectangle_top - dirty.gx_rectangle_top; 102 103 /* Calculate the write pointer. */ 104 write += (composite -> gx_canvas_x_resolution - overlap.gx_rectangle_right - 1) * composite -> gx_canvas_y_resolution; 105 write += overlap.gx_rectangle_top; 106 } 107 else 108 { 109 /* Index into starting row. */ 110 read += (overlap.gx_rectangle_left - dirty.gx_rectangle_left) * canvas -> gx_canvas_y_resolution; 111 112 /* Index into pixel. */ 113 read += dirty.gx_rectangle_bottom - overlap.gx_rectangle_bottom; 114 115 /* Calculate the write pointer. */ 116 write += overlap.gx_rectangle_left * composite -> gx_canvas_y_resolution; 117 write += (composite -> gx_canvas_y_resolution - overlap.gx_rectangle_bottom - 1); 118 } 119 120 for (row = overlap.gx_rectangle_left; row <= overlap.gx_rectangle_right; row++) 121 { 122 memcpy(write, read, (size_t)width * 4); /* Use case of memcpy is verified. */ 123 124 write += composite -> gx_canvas_y_resolution; 125 read += canvas -> gx_canvas_y_resolution; 126 } 127 } 128 } 129 130