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_system.h" |
28 |
|
|
#include "gx_utility.h" |
29 |
|
|
#include "gx_canvas.h" |
30 |
|
|
|
31 |
|
|
/* Bring in externs for caller checking code. */ |
32 |
|
|
GX_CALLER_CHECKING_EXTERNS |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gxe_canvas_create PORTABLE C */ |
40 |
|
|
/* 6.3.0 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This function checks for errors in the canvas function call. */ |
48 |
|
|
/* */ |
49 |
|
|
/* INPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* canvas Canvas control block */ |
52 |
|
|
/* name Name of canvas */ |
53 |
|
|
/* display Display control block */ |
54 |
|
|
/* type Type of canvas */ |
55 |
|
|
/* width Width of canvas */ |
56 |
|
|
/* height Height of canvas */ |
57 |
|
|
/* memory_area Memory area of canvas with */ |
58 |
|
|
/* each pixel of GX_COLOR */ |
59 |
|
|
/* memory_size Size of canvas memory area */ |
60 |
|
|
/* canvas_control_block_size Size of the canvas control */ |
61 |
|
|
/* block */ |
62 |
|
|
/* */ |
63 |
|
|
/* OUTPUT */ |
64 |
|
|
/* */ |
65 |
|
|
/* status Completion status */ |
66 |
|
|
/* */ |
67 |
|
|
/* CALLS */ |
68 |
|
|
/* */ |
69 |
|
|
/* _gx_canvas_create Actual canvas create call */ |
70 |
|
|
/* */ |
71 |
|
|
/* CALLED BY */ |
72 |
|
|
/* */ |
73 |
|
|
/* Application Code */ |
74 |
|
|
/* */ |
75 |
|
|
/* RELEASE HISTORY */ |
76 |
|
|
/* */ |
77 |
|
|
/* DATE NAME DESCRIPTION */ |
78 |
|
|
/* */ |
79 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
80 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
81 |
|
|
/* resulting in version 6.1 */ |
82 |
|
|
/* 10-31-2023 Ting Zhu Modified comment(s), verify */ |
83 |
|
|
/* the memory size only when */ |
84 |
|
|
/* memory_area is provided, */ |
85 |
|
|
/* resulting in version 6.3.0 */ |
86 |
|
|
/* */ |
87 |
|
|
/**************************************************************************/ |
88 |
|
1288 |
UINT _gxe_canvas_create(GX_CANVAS *canvas, GX_CONST GX_CHAR *name, GX_DISPLAY *display, UINT type, |
89 |
|
|
UINT width, UINT height, GX_COLOR *memory_area, ULONG memory_size, |
90 |
|
|
UINT canvas_control_block_size) |
91 |
|
|
{ |
92 |
|
|
UINT status; |
93 |
|
|
UINT pitch; |
94 |
|
|
|
95 |
|
|
/* Check for appropriate caller. */ |
96 |
✓✓✓✓ ✓✓ |
1288 |
GX_INIT_AND_THREADS_CALLER_CHECKING |
97 |
|
|
|
98 |
|
|
/* Check for invalid input pointers. */ |
99 |
✓✓✓✓
|
1286 |
if ((canvas == GX_NULL) || (display == GX_NULL)) |
100 |
|
|
{ |
101 |
|
3 |
return(GX_PTR_ERROR); |
102 |
|
|
} |
103 |
|
|
|
104 |
✓✓ |
1283 |
if (canvas_control_block_size != sizeof(GX_CANVAS)) |
105 |
|
|
{ |
106 |
|
1 |
return(GX_INVALID_CANVAS_SIZE); |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
/* Check for widget already created. */ |
110 |
✓✓ |
1282 |
if (canvas -> gx_canvas_display != GX_NULL) |
111 |
|
|
{ |
112 |
|
1 |
return(GX_ALREADY_CREATED); |
113 |
|
|
} |
114 |
|
|
|
115 |
✓✓ |
1281 |
if (memory_area) |
116 |
|
|
{ |
117 |
|
1277 |
pitch = (UINT)(display -> gx_display_driver_row_pitch_get((USHORT)width)); |
118 |
✓✓ |
1277 |
if (memory_size < pitch * height) |
119 |
|
|
{ |
120 |
|
1 |
return GX_INVALID_SIZE; |
121 |
|
|
} |
122 |
|
|
} |
123 |
|
|
|
124 |
✓✓ |
1280 |
if (type & (~((UINT)(GX_CANVAS_SIMPLE | GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE | |
125 |
|
|
GX_CANVAS_MODIFIED | GX_CANVAS_COMPOSITE)))) |
126 |
|
|
{ |
127 |
|
1 |
return(GX_INVALID_TYPE); |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
/* Call the actual canvas create function. */ |
131 |
|
1279 |
status = _gx_canvas_create(canvas, name, display, type, width, height, memory_area, memory_size); |
132 |
|
|
|
133 |
|
|
/* Return completion status. */ |
134 |
|
1279 |
return status; |
135 |
|
|
} |
136 |
|
|
|