forked from koreader/koreader-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblitbuffer.h
141 lines (125 loc) · 4.4 KB
/
blitbuffer.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
/*
KOReader: blitbuffer implementation for jit-disabled platforms
Copyright (C) 2011 Hans-Werner Hilse <[email protected]>
2017 Huang Xin <[email protected]>
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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _BLITBUFFER_H
#define _BLITBUFFER_H
#include <stdint.h>
typedef struct Color8 {
uint8_t a;
} Color8;
typedef struct Color8A {
uint8_t a;
uint8_t alpha;
} Color8A;
typedef struct ColorRGB16 {
uint16_t v;
} ColorRGB16;
typedef struct ColorRGB24 {
uint8_t r;
uint8_t g;
uint8_t b;
} ColorRGB24;
typedef struct ColorRGB32 {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t alpha;
} ColorRGB32;
typedef struct BlitBuffer {
int w;
int phys_w;
int h;
int phys_h;
int pitch;
uint8_t *data;
uint8_t config;
} BlitBuffer;
typedef struct BlitBuffer8 {
int w;
int phys_w;
int h;
int phys_h;
int pitch;
Color8 *data;
uint8_t config;
} BlitBuffer8;
typedef struct BlitBuffer8A {
int w;
int phys_w;
int h;
int phys_h;
int pitch;
Color8A *data;
uint8_t config;
} BlitBuffer8A;
typedef struct BlitBufferRGB16 {
int w;
int phys_w;
int h;
int phys_h;
int pitch;
ColorRGB16 *data;
uint8_t config;
} BlitBufferRGB16;
typedef struct BlitBufferRGB24 {
int w;
int phys_w;
int h;
int phys_h;
int pitch;
ColorRGB24 *data;
uint8_t config;
} BlitBufferRGB24;
typedef struct BlitBufferRGB32 {
int w;
int phys_w;
int h;
int phys_h;
int pitch;
ColorRGB32 *data;
uint8_t config;
} BlitBufferRGB32;
void BB_fill_rect(BlitBuffer *bb, int x, int y, int w, int h, uint8_t v);
void BB_blend_rect(BlitBuffer *bb, int x, int y, int w, int h, Color8A *color);
void BB_invert_rect(BlitBuffer *bb, int x, int y, int w, int h);
void BB_blit_to_BB8(BlitBuffer *src, BlitBuffer *dst,
int dest_x, int dest_y, int offs_x, int offs_y, int w, int h);
void BB_dither_blit_to_BB8(BlitBuffer *src, BlitBuffer *dst,
int dest_x, int dest_y, int offs_x, int offs_y, int w, int h);
void BB_blit_to_BB8A(BlitBuffer *src, BlitBuffer *dst,
int dest_x, int dest_y, int offs_x, int offs_y, int w, int h);
void BB_blit_to_BB16(BlitBuffer *src, BlitBuffer *dst,
int dest_x, int dest_y, int offs_x, int offs_y, int w, int h);
void BB_blit_to_BB24(BlitBuffer *src, BlitBuffer *dst,
int dest_x, int dest_y, int offs_x, int offs_y, int w, int h);
void BB_blit_to_BB32(BlitBuffer *src, BlitBuffer *dst,
int dest_x, int dest_y, int offs_x, int offs_y, int w, int h);
void BB_blit_to(BlitBuffer *source, BlitBuffer *dest, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h);
void BB_dither_blit_to(BlitBuffer *source, BlitBuffer *dest, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h);
void BB_add_blit_from(BlitBuffer *dest, BlitBuffer *source, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h, uint8_t alpha);
void BB_alpha_blit_from(BlitBuffer *dest, BlitBuffer *source, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h);
void BB_pmulalpha_blit_from(BlitBuffer *dest, BlitBuffer *source, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h);
void BB_dither_pmulalpha_blit_from(BlitBuffer *dest, BlitBuffer *source, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h);
void BB_invert_blit_from(BlitBuffer *dest, BlitBuffer *source, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h);
void BB_color_blit_from(BlitBuffer *dest, BlitBuffer *source, int dest_x, int dest_y,
int offs_x, int offs_y, int w, int h, Color8A *color);
#endif