~ubuntu-branches/debian/sid/grub2/sid-200907171837

« back to all changes in this revision

Viewing changes to include/grub/video.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2006-06-10 19:57:01 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060610195701-2khcfacexb229tq4
Tags: 1.94-3
Fix FTBFS in amd64. Closes: 372548

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  GRUB  --  GRand Unified Bootloader
 
3
 *  Copyright (C) 2006  Free Software Foundation, Inc.
 
4
 *
 
5
 *  GRUB is free software; you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation; either version 2 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with GRUB; if not, write to the Free Software
 
17
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 */
 
19
 
 
20
#ifndef GRUB_VIDEO_HEADER
 
21
#define GRUB_VIDEO_HEADER       1
 
22
 
 
23
#include <grub/err.h>
 
24
#include <grub/types.h>
 
25
 
 
26
typedef grub_uint32_t grub_video_color_t;
 
27
 
 
28
struct grub_video_render_target;
 
29
 
 
30
/* Defines used to describe video mode or rendering target.  */
 
31
#define GRUB_VIDEO_MODE_TYPE_ALPHA              0x00000008
 
32
#define GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED    0x00000004
 
33
#define GRUB_VIDEO_MODE_TYPE_INDEX_COLOR        0x00000002
 
34
#define GRUB_VIDEO_MODE_TYPE_RGB                0x00000001
 
35
 
 
36
/* Defines used to mask flags.  */
 
37
#define GRUB_VIDEO_MODE_TYPE_COLOR_MASK         0x00000003
 
38
 
 
39
/* Defines used to specify requested bit depth.  */
 
40
#define GRUB_VIDEO_MODE_TYPE_DEPTH_MASK         0x0000ff00
 
41
#define GRUB_VIDEO_MODE_TYPE_DEPTH_POS          8
 
42
 
 
43
/* Defined predefined render targets.  */
 
44
#define GRUB_VIDEO_RENDER_TARGET_DISPLAY        ((struct grub_video_render_target *) 0)
 
45
#define GRUB_VIDEO_RENDER_TARGET_FRONT_BUFFER   ((struct grub_video_render_target *) 0)
 
46
#define GRUB_VIDEO_RENDER_TARGET_BACK_BUFFER    ((struct grub_video_render_target *) 1)
 
47
 
 
48
/* Defined blitting formats.  */
 
49
enum grub_video_blit_format
 
50
  {
 
51
    /* Follow exactly field & mask information.  */
 
52
    GRUB_VIDEO_BLIT_FORMAT_RGBA,
 
53
    /* Make optimization assumption.  */
 
54
    GRUB_VIDEO_BLIT_FORMAT_R8G8B8A8,
 
55
    /* Follow exactly field & mask information.  */
 
56
    GRUB_VIDEO_BLIT_FORMAT_RGB,
 
57
    /* Make optimization assumption.  */
 
58
    GRUB_VIDEO_BLIT_FORMAT_R8G8B8,
 
59
    /* When needed, decode color or just use value as is.  */
 
60
    GRUB_VIDEO_BLIT_FORMAT_INDEXCOLOR
 
61
  };
 
62
 
 
63
struct grub_video_mode_info
 
64
{
 
65
  /* Width of the screen.  */
 
66
  unsigned int width;
 
67
  
 
68
  /* Height of the screen.  */
 
69
  unsigned int height;
 
70
 
 
71
  /* Mode type bitmask.  Contains information like is it Index color or 
 
72
     RGB mode.  */
 
73
  unsigned int mode_type;
 
74
 
 
75
  /* Bits per pixel.  */
 
76
  unsigned int bpp;
 
77
  
 
78
  /* Bytes per pixel.  */
 
79
  unsigned int bytes_per_pixel;
 
80
  
 
81
  /* Pitch of one scanline.  How many bytes there are for scanline.  */
 
82
  unsigned int pitch;
 
83
 
 
84
  /* In index color mode, number of colors.  In RGB mode this is 256.  */
 
85
  unsigned int number_of_colors;
 
86
 
 
87
  /* Optimization hint how binary data is coded.  */
 
88
  enum grub_video_blit_format blit_format;
 
89
 
 
90
  /* How many bits are reserved for red color.  */
 
91
  unsigned int red_mask_size;
 
92
 
 
93
  /* What is location of red color bits.  In Index Color mode, this is 0.  */
 
94
  unsigned int red_field_pos;
 
95
 
 
96
  /* How many bits are reserved for green color.  */
 
97
  unsigned int green_mask_size;
 
98
 
 
99
  /* What is location of green color bits.  In Index Color mode, this is 0.  */
 
100
  unsigned int green_field_pos;
 
101
 
 
102
  /* How many bits are reserved for blue color.  */
 
103
  unsigned int blue_mask_size;
 
104
 
 
105
  /* What is location of blue color bits.  In Index Color mode, this is 0.  */
 
106
  unsigned int blue_field_pos;
 
107
 
 
108
  /* How many bits are reserved in color.  */
 
109
  unsigned int reserved_mask_size;
 
110
 
 
111
  /* What is location of reserved color bits.  In Index Color mode, 
 
112
     this is 0.  */
 
113
  unsigned int reserved_field_pos;
 
114
};
 
115
 
 
116
struct grub_video_render_target
 
117
{
 
118
  /* Copy of the screen's mode info structure, except that width, height and
 
119
     mode_type has been re-adjusted to requested render target settings.  */
 
120
  struct grub_video_mode_info mode_info;
 
121
 
 
122
  struct
 
123
  {
 
124
    unsigned int x;
 
125
    unsigned int y;
 
126
    unsigned int width;
 
127
    unsigned int height;        
 
128
  } viewport;
 
129
 
 
130
  /* Indicates wether the data has been allocated by us and must be freed 
 
131
     when render target is destroyed.  */
 
132
  int is_allocated;
 
133
  
 
134
  /* Pointer to data.  Can either be in video card memory or in local host's
 
135
     memory.  */
 
136
  void *data;
 
137
};
 
138
 
 
139
struct grub_video_palette_data
 
140
{
 
141
  grub_uint8_t r; /* Red color value (0-255).  */
 
142
  grub_uint8_t g; /* Green color value (0-255).  */
 
143
  grub_uint8_t b; /* Blue color value (0-255).  */
 
144
  grub_uint8_t a; /* Reserved bits value (0-255).  */
 
145
};
 
146
 
 
147
struct grub_font_glyph;
 
148
struct grub_video_bitmap;
 
149
 
 
150
struct grub_video_adapter
 
151
{
 
152
  /* The video adapter name.  */
 
153
  const char *name;
 
154
 
 
155
  /* Initialize the video adapter.  */
 
156
  grub_err_t (*init) (void);
 
157
 
 
158
  /* Clean up the video adapter.  */
 
159
  grub_err_t (*fini) (void);
 
160
 
 
161
  grub_err_t (*setup) (unsigned int width, 
 
162
                       unsigned int height,
 
163
                       unsigned int mode_type);
 
164
 
 
165
  grub_err_t (*get_info) (struct grub_video_mode_info *mode_info);
 
166
  
 
167
  grub_err_t (*set_palette) (unsigned int start,
 
168
                             unsigned int count,
 
169
                             struct grub_video_palette_data *palette_data);
 
170
 
 
171
  grub_err_t (*get_palette) (unsigned int start,
 
172
                             unsigned int count,
 
173
                             struct grub_video_palette_data *palette_data);
 
174
 
 
175
  grub_err_t (*set_viewport) (unsigned int x,
 
176
                              unsigned int y,
 
177
                              unsigned int width,
 
178
                              unsigned int height);
 
179
 
 
180
  grub_err_t (*get_viewport) (unsigned int *x,
 
181
                              unsigned int *y,
 
182
                              unsigned int *width,
 
183
                              unsigned int *height);
 
184
 
 
185
  grub_video_color_t (*map_color) (grub_uint32_t color_name);
 
186
  
 
187
  grub_video_color_t (*map_rgb) (grub_uint8_t red,
 
188
                                 grub_uint8_t green,
 
189
                                 grub_uint8_t blue);
 
190
 
 
191
  grub_video_color_t (*map_rgba) (grub_uint8_t red,
 
192
                                  grub_uint8_t green,
 
193
                                  grub_uint8_t blue,
 
194
                                  grub_uint8_t alpha);
 
195
 
 
196
  grub_err_t (*fill_rect) (grub_video_color_t color,
 
197
                           int x,
 
198
                           int y,
 
199
                           unsigned int width,
 
200
                           unsigned int height);
 
201
 
 
202
  grub_err_t (*blit_glyph) (struct grub_font_glyph *glyph,
 
203
                            grub_video_color_t color,
 
204
                            int x,
 
205
                            int y);
 
206
 
 
207
  grub_err_t (*blit_bitmap) (struct grub_video_bitmap *bitmap,
 
208
                             int x,
 
209
                             int y,
 
210
                             int offset_x,
 
211
                             int offset_y,
 
212
                             unsigned int width,
 
213
                             unsigned int height);
 
214
 
 
215
  grub_err_t (*blit_render_target) (struct grub_video_render_target *source,
 
216
                                    int x,
 
217
                                    int y,
 
218
                                    int offset_x,
 
219
                                    int offset_y,
 
220
                                    unsigned int width,
 
221
                                    unsigned int height);
 
222
 
 
223
  grub_err_t (*scroll) (grub_video_color_t color,
 
224
                        int dx,
 
225
                        int dy);
 
226
 
 
227
  grub_err_t (*swap_buffers) (void);
 
228
 
 
229
  grub_err_t (*create_render_target) (struct grub_video_render_target **result,
 
230
                                      unsigned int width,
 
231
                                      unsigned int height,
 
232
                                      unsigned int mode_type);
 
233
 
 
234
  grub_err_t (*delete_render_target) (struct grub_video_render_target *target);
 
235
 
 
236
  grub_err_t (*set_active_render_target) (struct grub_video_render_target *target);
 
237
 
 
238
  /* The next video adapter.  */
 
239
  struct grub_video_adapter *next;
 
240
};
 
241
typedef struct grub_video_adapter *grub_video_adapter_t;
 
242
 
 
243
void grub_video_register (grub_video_adapter_t adapter);
 
244
void grub_video_unregister (grub_video_adapter_t adapter);
 
245
void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter));
 
246
 
 
247
grub_err_t grub_video_setup (unsigned int width,
 
248
                             unsigned int height,
 
249
                             unsigned int mode_type);
 
250
 
 
251
grub_err_t grub_video_restore (void);
 
252
 
 
253
grub_err_t grub_video_get_info (struct grub_video_mode_info *mode_info);
 
254
 
 
255
enum grub_video_blit_format grub_video_get_blit_format (struct grub_video_mode_info *mode_info);
 
256
 
 
257
grub_err_t grub_video_set_palette (unsigned int start,
 
258
                                   unsigned int count,
 
259
                                   struct grub_video_palette_data *palette_data);
 
260
 
 
261
grub_err_t grub_video_get_palette (unsigned int start,
 
262
                                   unsigned int count,
 
263
                                   struct grub_video_palette_data *palette_data);
 
264
 
 
265
grub_err_t grub_video_set_viewport (unsigned int x,
 
266
                                    unsigned int y,
 
267
                                    unsigned int width,
 
268
                                    unsigned int height);
 
269
 
 
270
grub_err_t grub_video_get_viewport (unsigned int *x,
 
271
                                    unsigned int *y,
 
272
                                    unsigned int *width,
 
273
                                    unsigned int *height);
 
274
 
 
275
grub_video_color_t grub_video_map_color (grub_uint32_t color_name);
 
276
 
 
277
grub_video_color_t grub_video_map_rgb (grub_uint8_t red,
 
278
                                       grub_uint8_t green,
 
279
                                       grub_uint8_t blue);
 
280
 
 
281
grub_video_color_t grub_video_map_rgba (grub_uint8_t red,
 
282
                                        grub_uint8_t green,
 
283
                                        grub_uint8_t blue,
 
284
                                        grub_uint8_t alpha);
 
285
 
 
286
grub_err_t grub_video_fill_rect (grub_video_color_t color,
 
287
                                 int x,
 
288
                                 int y,
 
289
                                 unsigned int width,
 
290
                                 unsigned int height);
 
291
 
 
292
grub_err_t grub_video_blit_glyph (struct grub_font_glyph *glyph,
 
293
                                  grub_video_color_t color,
 
294
                                  int x,
 
295
                                  int y);
 
296
 
 
297
grub_err_t grub_video_blit_bitmap (struct grub_video_bitmap *bitmap,
 
298
                                   int x,
 
299
                                   int y,
 
300
                                   int offset_x,
 
301
                                   int offset_y,
 
302
                                   unsigned int width,
 
303
                                   unsigned int height);
 
304
 
 
305
grub_err_t grub_video_blit_render_target (struct grub_video_render_target *source,
 
306
                                          int x,
 
307
                                          int y,
 
308
                                          int offset_x,
 
309
                                          int offset_y,
 
310
                                          unsigned int width,
 
311
                                          unsigned int height);
 
312
 
 
313
grub_err_t grub_video_scroll (grub_video_color_t color,
 
314
                              int dx,
 
315
                              int dy);
 
316
 
 
317
grub_err_t grub_video_swap_buffers (void);
 
318
 
 
319
grub_err_t grub_video_create_render_target (struct grub_video_render_target **result,
 
320
                                            unsigned int width,
 
321
                                            unsigned int height,
 
322
                                            unsigned int mode_type);
 
323
 
 
324
grub_err_t grub_video_delete_render_target (struct grub_video_render_target *target);
 
325
 
 
326
grub_err_t grub_video_set_active_render_target (struct grub_video_render_target *target);
 
327
 
 
328
#endif /* ! GRUB_VIDEO_HEADER */