forked from neochapay/plymouth-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ply-frame-buffer.h
151 lines (127 loc) · 6.62 KB
/
ply-frame-buffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/* ply-frame-buffer.h - framebuffer abstraction
*
* Copyright (C) 2007 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written By: Ray Strode <rstrode@redhat.com>
*/
#ifndef PLY_FRAME_BUFFER_H
#define PLY_FRAME_BUFFER_H
#include <stdbool.h>
#include <stdint.h>
#include "ply-utils.h"
typedef struct _ply_frame_buffer ply_frame_buffer_t;
typedef struct _ply_frame_buffer_area ply_frame_buffer_area_t;
struct _ply_frame_buffer_area
{
long x;
long y;
unsigned long width;
unsigned long height;
};
struct _ply_frame_buffer
{
char *device_name;
int device_fd;
char *map_address;
size_t size;
uint32_t *shadow_buffer;
uint32_t red_bit_position;
uint32_t green_bit_position;
uint32_t blue_bit_position;
uint32_t alpha_bit_position;
uint32_t bits_for_red;
uint32_t bits_for_green;
uint32_t bits_for_blue;
uint32_t bits_for_alpha;
int32_t dither_red;
int32_t dither_green;
int32_t dither_blue;
unsigned int bytes_per_pixel;
unsigned int row_stride;
ply_frame_buffer_area_t area;
ply_frame_buffer_area_t area_to_flush;
void (*flush)(ply_frame_buffer_t *buffer);
int pause_count;
};
#define PLY_FRAME_BUFFER_COLOR_TO_PIXEL_VALUE(r,g,b,a) \
(((uint8_t) (CLAMP (a * 255.0, 0.0, 255.0)) << 24) \
| ((uint8_t) (CLAMP (r * 255.0, 0.0, 255.0)) << 16) \
| ((uint8_t) (CLAMP (g * 255.0, 0.0, 255.0)) << 8) \
| ((uint8_t) (CLAMP (b * 255.0, 0.0, 255.0))))
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_frame_buffer_t *ply_frame_buffer_new (const char *device_name);
void ply_frame_buffer_free (ply_frame_buffer_t *buffer);
bool ply_frame_buffer_open (ply_frame_buffer_t *buffer);
void ply_frame_buffer_pause_updates (ply_frame_buffer_t *buffer);
bool ply_frame_buffer_unpause_updates (ply_frame_buffer_t *buffer);
bool ply_frame_buffer_device_is_open (ply_frame_buffer_t *buffer);
char *ply_frame_buffer_get_device_name (ply_frame_buffer_t *buffer);
void ply_frame_buffer_set_device_name (ply_frame_buffer_t *buffer,
const char *device_name);
void ply_frame_buffer_close (ply_frame_buffer_t *buffer);
void ply_frame_buffer_get_size (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *size);
bool ply_frame_buffer_fill_with_color (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
double red,
double green,
double blue,
double alpha);
bool ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
uint32_t hex_color);
bool ply_frame_buffer_fill_with_hex_color_at_opacity (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
uint32_t hex_color,
double opacity);
bool ply_frame_buffer_fill_with_gradient (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
uint32_t start,
uint32_t end);
bool ply_frame_buffer_fill_with_argb32_data (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
unsigned long x,
unsigned long y,
uint32_t *data);
bool ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
unsigned long x,
unsigned long y,
uint32_t *data,
double opacity);
bool ply_frame_buffer_fill_with_argb32_data_with_clip (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
ply_frame_buffer_area_t *clip,
unsigned long x,
unsigned long y,
uint32_t *data);
bool ply_frame_buffer_fill_with_argb32_data_at_opacity_with_clip (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
ply_frame_buffer_area_t *clip,
unsigned long x,
unsigned long y,
uint32_t *data,
double opacity);
bool ply_frame_buffer_fill_with_argb32_data_sprite(ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area,
uint32_t *data,
int sprite_num);
const char *ply_frame_buffer_get_bytes (ply_frame_buffer_t *buffer);
#endif
#endif /* PLY_FRAME_BUFFER_H */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */