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 /**   Animation Management (Animation)                                    */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_utility.h"
30 #include "gx_window.h"
31 #include "gx_canvas.h"
32 #include "gx_animation.h"
33 
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _gxe_animation_canvas_define                        PORTABLE C      */
40 /*                                                           6.1          */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    Kenneth Maxwell, Microsoft Corporation                              */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This function checks error in animation canvas define function.     */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    animation                             Animation control block       */
52 /*    canvas                                Pointer to animation canvas   */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Completion status             */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _gx_animation_canvas_define           The actual animation canvas   */
61 /*                                            define function             */
62 /*                                                                        */
63 /*  CALLED BY                                                             */
64 /*                                                                        */
65 /*    Application Code                                                    */
66 /*                                                                        */
67 /*  RELEASE HISTORY                                                       */
68 /*                                                                        */
69 /*    DATE              NAME                      DESCRIPTION             */
70 /*                                                                        */
71 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
72 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
73 /*                                            resulting in version 6.1    */
74 /*                                                                        */
75 /**************************************************************************/
_gxe_animation_canvas_define(GX_ANIMATION * animation,GX_CANVAS * canvas)76 UINT  _gxe_animation_canvas_define(GX_ANIMATION *animation, GX_CANVAS *canvas)
77 {
78 UINT  status = GX_SUCCESS;
79 GX_DISPLAY *display;
80 ULONG required_size;
81 
82     if (animation == GX_NULL ||
83         canvas == GX_NULL)
84     {
85         return GX_PTR_ERROR;
86     }
87 
88     display = canvas -> gx_canvas_display;
89     if (display == GX_NULL)
90     {
91         return GX_PTR_ERROR;
92     }
93 
94     required_size = (ULONG)(display -> gx_display_driver_row_pitch_get((USHORT) canvas->gx_canvas_x_resolution));
95     required_size = required_size * (ULONG) canvas->gx_canvas_y_resolution;
96 
97     if (canvas ->gx_canvas_memory_size < required_size)
98     {
99         return GX_INVALID_MEMORY_SIZE;
100     }
101 
102     status = _gx_animation_canvas_define(animation, canvas);
103 
104     /* Return completion status code. */
105     return(status);
106 }
107 
108