1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** GUIX Component */ 16 /** */ 17 /** Canvas Management (Canvas) */ 18 /** */ 19 /**************************************************************************/ 20 21 #define GX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "gx_api.h" 27 #include "gx_canvas.h" 28 29 30 /**************************************************************************/ 31 /* */ 32 /* FUNCTION RELEASE */ 33 /* */ 34 /* _gx_canvas_memory_define PORTABLE C */ 35 /* 6.3.0 */ 36 /* AUTHOR */ 37 /* */ 38 /* Kenneth Maxwell, Microsoft Corporation */ 39 /* */ 40 /* DESCRIPTION */ 41 /* */ 42 /* This function assigns canvas memory pointer and size */ 43 /* */ 44 /* INPUT */ 45 /* */ 46 /* canvas Canvas control block */ 47 /* memory Canvas memory address */ 48 /* memsize Canvas memory size */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* status Completion status */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* _gx_canvas_dirty_mark Set the canvas dirty flag */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* Application software */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 67 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* 10-31-2023 Ting Zhu Modified comment(s), */ 70 /* added partial canvas buffer */ 71 /* support, */ 72 /* resulting in version 6.3.0 */ 73 /* */ 74 /**************************************************************************/ _gx_canvas_memory_define(GX_CANVAS * canvas,GX_COLOR * memory,ULONG memsize)75UINT _gx_canvas_memory_define(GX_CANVAS *canvas, GX_COLOR *memory, ULONG memsize) 76 { 77 #ifdef GX_ENABLE_CANVAS_PARTIAL_FRAME_BUFFER 78 GX_DISPLAY *display = canvas -> gx_canvas_display; 79 ULONG canvas_size; 80 81 if (!display) 82 { 83 return GX_INVALID_DISPLAY; 84 } 85 86 canvas_size = (ULONG)(display -> gx_display_driver_row_pitch_get((USHORT)canvas -> gx_canvas_x_resolution) * canvas -> gx_canvas_y_resolution); 87 88 if (memsize < canvas_size) 89 { 90 canvas -> gx_canvas_status |= GX_CANVAS_PARTIAL_FRAME_BUFFER; 91 } 92 #endif 93 94 /* change the memory pointer value */ 95 canvas -> gx_canvas_memory = memory; 96 97 /* change the memory size */ 98 canvas -> gx_canvas_memory_size = memsize; 99 100 /* mark the canvas dirty so that it get refreshed */ 101 _gx_canvas_dirty_mark(canvas, GX_NULL); 102 103 /* Return successful status. */ 104 return(GX_SUCCESS); 105 } 106 107