1 #pragma once
2 
3 /*
4 libgo2 - Support library for the ODROID-GO Advance
5 Copyright (C) 2020 OtherCrashOverride
6 
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11 
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21 
22 #include <stdint.h>
23 #include <stdbool.h>
24 
25 
26 typedef struct go2_display go2_display_t;
27 typedef struct go2_surface go2_surface_t;
28 typedef struct go2_frame_buffer go2_frame_buffer_t;
29 typedef struct go2_presenter go2_presenter_t;
30 
31 typedef enum go2_rotation
32 {
33     GO2_ROTATION_DEGREES_0 = 0,
34     GO2_ROTATION_DEGREES_90,
35     GO2_ROTATION_DEGREES_180,
36     GO2_ROTATION_DEGREES_270
37 } go2_rotation_t;
38 
39 typedef struct go2_context_attributes
40 {
41     int major;
42     int minor;
43     int red_bits;
44     int green_bits;
45     int blue_bits;
46     int alpha_bits;
47     int depth_bits;
48     int stencil_bits;
49 } go2_context_attributes_t;
50 
51 typedef struct go2_context go2_context_t;
52 
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 go2_display_t* go2_display_create();
59 void go2_display_destroy(go2_display_t* display);
60 int go2_display_width_get(go2_display_t* display);
61 int go2_display_height_get(go2_display_t* display);
62 void go2_display_present(go2_display_t* display, go2_frame_buffer_t* frame_buffer);
63 uint32_t go2_display_backlight_get(go2_display_t* display);
64 void go2_display_backlight_set(go2_display_t* display, uint32_t value);
65 
66 
67 int go2_drm_format_get_bpp(uint32_t format);
68 
69 
70 go2_surface_t* go2_surface_create(go2_display_t* display, int width, int height, uint32_t format);
71 void go2_surface_destroy(go2_surface_t* surface);
72 int go2_surface_width_get(go2_surface_t* surface);
73 int go2_surface_height_get(go2_surface_t* surface);
74 uint32_t go2_surface_format_get(go2_surface_t* surface);
75 int go2_surface_stride_get(go2_surface_t* surface);
76 go2_display_t* go2_surface_display_get(go2_surface_t* surface);
77 int go2_surface_prime_fd(go2_surface_t* surface);
78 void* go2_surface_map(go2_surface_t* surface);
79 void go2_surface_unmap(go2_surface_t* surface);
80 void go2_surface_blit(go2_surface_t* srcSurface, int srcX, int srcY, int srcWidth, int srcHeight,
81                       go2_surface_t* dstSurface, int dstX, int dstY, int dstWidth, int dstHeight,
82                       go2_rotation_t rotation, int scale_mode);
83 int go2_surface_save_as_png(go2_surface_t* surface, const char* filename);
84 
85 
86 go2_frame_buffer_t* go2_frame_buffer_create(go2_surface_t* surface);
87 void go2_frame_buffer_destroy(go2_frame_buffer_t* frame_buffer);
88 go2_surface_t* go2_frame_buffer_surface_get(go2_frame_buffer_t* frame_buffer);
89 
90 
91 go2_presenter_t* go2_presenter_create(go2_display_t* display, uint32_t format, uint32_t background_color, bool managed);
92 void go2_presenter_destroy(go2_presenter_t* presenter);
93 void go2_presenter_post(go2_presenter_t* presenter, go2_surface_t* surface, int srcX, int srcY, int srcWidth, int srcHeight, int dstX, int dstY, int dstWidth, int dstHeight, go2_rotation_t rotation, int scale_mode);
94 go2_display_t* go2_presenter_display_get(go2_presenter_t* presenter);
95 
96 
97 go2_context_t* go2_context_create(go2_display_t* display, int width, int height, const go2_context_attributes_t* attributes);
98 void go2_context_destroy(go2_context_t* context);
99 void* go2_context_egldisplay_get(go2_context_t* context);
100 void go2_context_make_current(go2_context_t* context);
101 void go2_context_swap_buffers(go2_context_t* context);
102 go2_surface_t* go2_context_surface_lock(go2_context_t* context);
103 void go2_context_surface_unlock(go2_context_t* context, go2_surface_t* surface);
104 
105 go2_frame_buffer_t* go2_frame_buffer_create(go2_surface_t* surface);
106 
107 #ifdef __cplusplus
108 }
109 #endif
110