~serge-hallyn/ubuntu/raring/spice/spice-fixed2

« back to all changes in this revision

Viewing changes to common/canvas_base.h

  • Committer: Package Import Robot
  • Author(s): Liang Guo
  • Date: 2011-07-23 12:21:04 UTC
  • Revision ID: package-import@ubuntu.com-20110723122104-gvv70gd6ui6213qd
Tags: upstream-0.8.2
ImportĀ upstreamĀ versionĀ 0.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 
2
/*
 
3
   Copyright (C) 2009 Red Hat, Inc.
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   This library 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 GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
 
 
19
#ifndef _H_CANVAS_BASE
 
20
#define _H_CANVAS_BASE
 
21
 
 
22
 
 
23
#include "pixman_utils.h"
 
24
#include "lz.h"
 
25
#include "region.h"
 
26
#include "draw.h"
 
27
 
 
28
#ifdef __cplusplus
 
29
extern "C" {
 
30
#endif
 
31
 
 
32
typedef void (*spice_destroy_fn_t)(void *data);
 
33
 
 
34
typedef struct _SpiceImageCache SpiceImageCache;
 
35
typedef struct _SpiceImageSurfaces SpiceImageSurfaces;
 
36
typedef struct _SpicePaletteCache SpicePaletteCache;
 
37
typedef struct _SpiceGlzDecoder SpiceGlzDecoder;
 
38
typedef struct _SpiceJpegDecoder SpiceJpegDecoder;
 
39
typedef struct _SpiceZlibDecoder SpiceZlibDecoder;
 
40
typedef struct _SpiceCanvas SpiceCanvas;
 
41
 
 
42
typedef struct {
 
43
    void (*put)(SpiceImageCache *cache,
 
44
                uint64_t id,
 
45
                pixman_image_t *surface);
 
46
    pixman_image_t *(*get)(SpiceImageCache *cache,
 
47
                           uint64_t id);
 
48
#ifdef SW_CANVAS_CACHE
 
49
    void (*put_lossy)(SpiceImageCache *cache,
 
50
                      uint64_t id,
 
51
                      pixman_image_t *surface);
 
52
    void (*replace_lossy)(SpiceImageCache *cache,
 
53
                          uint64_t id,
 
54
                          pixman_image_t *surface);
 
55
    pixman_image_t *(*get_lossless)(SpiceImageCache *cache,
 
56
                                    uint64_t id);
 
57
#endif
 
58
} SpiceImageCacheOps;
 
59
 
 
60
struct _SpiceImageCache {
 
61
  SpiceImageCacheOps *ops;
 
62
};
 
63
 
 
64
typedef struct {
 
65
 SpiceCanvas *(*get)(SpiceImageSurfaces *surfaces,
 
66
                     uint32_t surface_id);
 
67
} SpiceImageSurfacesOps;
 
68
 
 
69
struct _SpiceImageSurfaces {
 
70
 SpiceImageSurfacesOps *ops;
 
71
};
 
72
 
 
73
typedef struct {
 
74
    void (*put)(SpicePaletteCache *cache,
 
75
                SpicePalette *palette);
 
76
    SpicePalette *(*get)(SpicePaletteCache *cache,
 
77
                         uint64_t id);
 
78
    void (*release)(SpicePaletteCache *cache,
 
79
                    SpicePalette *palette);
 
80
} SpicePaletteCacheOps;
 
81
 
 
82
struct _SpicePaletteCache {
 
83
  SpicePaletteCacheOps *ops;
 
84
};
 
85
 
 
86
typedef struct {
 
87
    void (*decode)(SpiceGlzDecoder *decoder,
 
88
                   uint8_t *data,
 
89
                   SpicePalette *plt,
 
90
                   void *usr_data);
 
91
} SpiceGlzDecoderOps;
 
92
 
 
93
struct _SpiceGlzDecoder {
 
94
  SpiceGlzDecoderOps *ops;
 
95
};
 
96
 
 
97
 
 
98
typedef struct SpiceJpegDecoderOps {
 
99
    void (*begin_decode)(SpiceJpegDecoder *decoder,
 
100
                         uint8_t* data,
 
101
                         int data_size,
 
102
                         int* out_width,
 
103
                         int* out_height);
 
104
    void (*decode)(SpiceJpegDecoder *decoder,
 
105
                   uint8_t* dest,
 
106
                   int stride,
 
107
                   int format);
 
108
} SpiceJpegDecoderOps;
 
109
 
 
110
struct _SpiceJpegDecoder {
 
111
    SpiceJpegDecoderOps *ops;
 
112
};
 
113
 
 
114
typedef struct {
 
115
    void (*decode)(SpiceZlibDecoder *decoder,
 
116
                   uint8_t *data,
 
117
                   int data_size,
 
118
                   uint8_t *dest,
 
119
                   int dest_size);
 
120
} SpiceZlibDecoderOps;
 
121
 
 
122
struct _SpiceZlibDecoder {
 
123
  SpiceZlibDecoderOps *ops;
 
124
};
 
125
 
 
126
typedef struct {
 
127
    void (*draw_fill)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceFill *fill);
 
128
    void (*draw_copy)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceCopy *copy);
 
129
    void (*draw_opaque)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceOpaque *opaque);
 
130
    void (*copy_bits)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpicePoint *src_pos);
 
131
    void (*draw_text)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceText *text);
 
132
    void (*draw_stroke)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceStroke *stroke);
 
133
    void (*draw_rop3)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceRop3 *rop3);
 
134
    void (*draw_blend)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceBlend *blend);
 
135
    void (*draw_blackness)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceBlackness *blackness);
 
136
    void (*draw_whiteness)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceWhiteness *whiteness);
 
137
    void (*draw_invers)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceInvers *invers);
 
138
    void (*draw_transparent)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceTransparent* transparent);
 
139
    void (*draw_alpha_blend)(SpiceCanvas *canvas, SpiceRect *bbox, SpiceClip *clip, SpiceAlphaBlend* alpha_blend);
 
140
    void (*put_image)(SpiceCanvas *canvas,
 
141
#ifdef WIN32
 
142
                      HDC dc,
 
143
#endif
 
144
                      const SpiceRect *dest, const uint8_t *src_data,
 
145
                      uint32_t src_width, uint32_t src_height, int src_stride,
 
146
                      const QRegion *clip);
 
147
    void (*clear)(SpiceCanvas *canvas);
 
148
    void (*read_bits)(SpiceCanvas *canvas, uint8_t *dest, int dest_stride, const SpiceRect *area);
 
149
    void (*group_start)(SpiceCanvas *canvas, QRegion *region);
 
150
    void (*group_end)(SpiceCanvas *canvas);
 
151
    void (*destroy)(SpiceCanvas *canvas);
 
152
 
 
153
    /* Implementation vfuncs */
 
154
    void (*fill_solid_spans)(SpiceCanvas *canvas,
 
155
                             SpicePoint *points,
 
156
                             int *widths,
 
157
                             int n_spans,
 
158
                             uint32_t color);
 
159
    void (*fill_solid_rects)(SpiceCanvas *canvas,
 
160
                             pixman_box32_t *rects,
 
161
                             int n_rects,
 
162
                             uint32_t color);
 
163
    void (*fill_solid_rects_rop)(SpiceCanvas *canvas,
 
164
                                 pixman_box32_t *rects,
 
165
                                 int n_rects,
 
166
                                 uint32_t color,
 
167
                                 SpiceROP rop);
 
168
    void (*fill_tiled_rects)(SpiceCanvas *canvas,
 
169
                             pixman_box32_t *rects,
 
170
                             int n_rects,
 
171
                             pixman_image_t *tile,
 
172
                             int offset_x, int offset_y);
 
173
    void (*fill_tiled_rects_from_surface)(SpiceCanvas *canvas,
 
174
                                          pixman_box32_t *rects,
 
175
                                          int n_rects,
 
176
                                          SpiceCanvas *tile,
 
177
                                          int offset_x, int offset_y);
 
178
    void (*fill_tiled_rects_rop)(SpiceCanvas *canvas,
 
179
                                 pixman_box32_t *rects,
 
180
                                 int n_rects,
 
181
                                 pixman_image_t *tile,
 
182
                                 int offset_x, int offset_y,
 
183
                                 SpiceROP rop);
 
184
    void (*fill_tiled_rects_rop_from_surface)(SpiceCanvas *canvas,
 
185
                                              pixman_box32_t *rects,
 
186
                                              int n_rects,
 
187
                                              SpiceCanvas *tile,
 
188
                                              int offset_x, int offset_y,
 
189
                                              SpiceROP rop);
 
190
    void (*blit_image)(SpiceCanvas *canvas,
 
191
                       pixman_region32_t *region,
 
192
                       pixman_image_t *src_image,
 
193
                       int offset_x, int offset_y);
 
194
    void (*blit_image_from_surface)(SpiceCanvas *canvas,
 
195
                                    pixman_region32_t *region,
 
196
                                    SpiceCanvas *src_image,
 
197
                                    int offset_x, int offset_y);
 
198
    void (*blit_image_rop)(SpiceCanvas *canvas,
 
199
                           pixman_region32_t *region,
 
200
                           pixman_image_t *src_image,
 
201
                           int offset_x, int offset_y,
 
202
                           SpiceROP rop);
 
203
    void (*blit_image_rop_from_surface)(SpiceCanvas *canvas,
 
204
                                        pixman_region32_t *region,
 
205
                                        SpiceCanvas *src_image,
 
206
                                        int offset_x, int offset_y,
 
207
                                        SpiceROP rop);
 
208
    void (*scale_image)(SpiceCanvas *canvas,
 
209
                        pixman_region32_t *region,
 
210
                        pixman_image_t *src_image,
 
211
                        int src_x, int src_y,
 
212
                        int src_width, int src_height,
 
213
                        int dest_x, int dest_y,
 
214
                        int dest_width, int dest_height,
 
215
                        int scale_mode);
 
216
    void (*scale_image_from_surface)(SpiceCanvas *canvas,
 
217
                                     pixman_region32_t *region,
 
218
                                     SpiceCanvas *src_image,
 
219
                                     int src_x, int src_y,
 
220
                                     int src_width, int src_height,
 
221
                                     int dest_x, int dest_y,
 
222
                                     int dest_width, int dest_height,
 
223
                                     int scale_mode);
 
224
    void (*scale_image_rop)(SpiceCanvas *canvas,
 
225
                            pixman_region32_t *region,
 
226
                            pixman_image_t *src_image,
 
227
                            int src_x, int src_y,
 
228
                            int src_width, int src_height,
 
229
                            int dest_x, int dest_y,
 
230
                            int dest_width, int dest_height,
 
231
                            int scale_mode, SpiceROP rop);
 
232
    void (*scale_image_rop_from_surface)(SpiceCanvas *canvas,
 
233
                                         pixman_region32_t *region,
 
234
                                         SpiceCanvas *src_image,
 
235
                                         int src_x, int src_y,
 
236
                                         int src_width, int src_height,
 
237
                                         int dest_x, int dest_y,
 
238
                                         int dest_width, int dest_height,
 
239
                                         int scale_mode, SpiceROP rop);
 
240
    void (*blend_image)(SpiceCanvas *canvas,
 
241
                        pixman_region32_t *region,
 
242
                        int dest_has_alpha,
 
243
                        pixman_image_t *src_image,
 
244
                        int src_x, int src_y,
 
245
                        int dest_x, int dest_y,
 
246
                        int width, int height,
 
247
                        int overall_alpha);
 
248
    void (*blend_image_from_surface)(SpiceCanvas *canvas,
 
249
                                     pixman_region32_t *region,
 
250
                                     int dest_has_alpha,
 
251
                                     SpiceCanvas *src_image,
 
252
                                     int src_has_alpha,
 
253
                                     int src_x, int src_y,
 
254
                                     int dest_x, int dest_y,
 
255
                                     int width, int height,
 
256
                                     int overall_alpha);
 
257
    void (*blend_scale_image)(SpiceCanvas *canvas,
 
258
                              pixman_region32_t *region,
 
259
                              int dest_has_alpha,
 
260
                              pixman_image_t *src_image,
 
261
                              int src_x, int src_y,
 
262
                              int src_width, int src_height,
 
263
                              int dest_x, int dest_y,
 
264
                              int dest_width, int dest_height,
 
265
                              int scale_mode,
 
266
                              int overall_alpha);
 
267
    void (*blend_scale_image_from_surface)(SpiceCanvas *canvas,
 
268
                                           pixman_region32_t *region,
 
269
                                           int dest_has_alpha,
 
270
                                           SpiceCanvas *src_image,
 
271
                                           int src_has_alpha,
 
272
                                           int src_x, int src_y,
 
273
                                           int src_width, int src_height,
 
274
                                           int dest_x, int dest_y,
 
275
                                           int dest_width, int dest_height,
 
276
                                           int scale_mode,
 
277
                                           int overall_alpha);
 
278
    void (*colorkey_image)(SpiceCanvas *canvas,
 
279
                           pixman_region32_t *region,
 
280
                           pixman_image_t *src_image,
 
281
                           int offset_x, int offset_y,
 
282
                           uint32_t transparent_color);
 
283
    void (*colorkey_image_from_surface)(SpiceCanvas *canvas,
 
284
                                        pixman_region32_t *region,
 
285
                                        SpiceCanvas *src_image,
 
286
                                        int offset_x, int offset_y,
 
287
                                        uint32_t transparent_color);
 
288
    void (*colorkey_scale_image)(SpiceCanvas *canvas,
 
289
                                 pixman_region32_t *region,
 
290
                                 pixman_image_t *src_image,
 
291
                                 int src_x, int src_y,
 
292
                                 int src_width, int src_height,
 
293
                                 int dest_x, int dest_y,
 
294
                                 int dest_width, int dest_height,
 
295
                                 uint32_t transparent_color);
 
296
    void (*colorkey_scale_image_from_surface)(SpiceCanvas *canvas,
 
297
                                              pixman_region32_t *region,
 
298
                                              SpiceCanvas *src_image,
 
299
                                              int src_x, int src_y,
 
300
                                              int src_width, int src_height,
 
301
                                              int dest_x, int dest_y,
 
302
                                              int dest_width, int dest_height,
 
303
                                              uint32_t transparent_color);
 
304
    void (*copy_region)(SpiceCanvas *canvas,
 
305
                        pixman_region32_t *dest_region,
 
306
                        int dx, int dy);
 
307
    pixman_image_t *(*get_image)(SpiceCanvas *canvas);
 
308
} SpiceCanvasOps;
 
309
 
 
310
void spice_canvas_set_usr_data(SpiceCanvas *canvas, void *data, spice_destroy_fn_t destroy_fn);
 
311
void *spice_canvas_get_usr_data(SpiceCanvas *canvas);
 
312
 
 
313
struct _SpiceCanvas {
 
314
  SpiceCanvasOps *ops;
 
315
};
 
316
 
 
317
#ifdef __cplusplus
 
318
}
 
319
#endif
 
320
 
 
321
#endif