1
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3
Copyright (C) 2009 Red Hat, Inc.
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.
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.
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/>.
19
#ifndef _H_CANVAS_BASE
20
#define _H_CANVAS_BASE
23
#include "pixman_utils.h"
32
typedef void (*spice_destroy_fn_t)(void *data);
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;
43
void (*put)(SpiceImageCache *cache,
45
pixman_image_t *surface);
46
pixman_image_t *(*get)(SpiceImageCache *cache,
48
#ifdef SW_CANVAS_CACHE
49
void (*put_lossy)(SpiceImageCache *cache,
51
pixman_image_t *surface);
52
void (*replace_lossy)(SpiceImageCache *cache,
54
pixman_image_t *surface);
55
pixman_image_t *(*get_lossless)(SpiceImageCache *cache,
60
struct _SpiceImageCache {
61
SpiceImageCacheOps *ops;
65
SpiceCanvas *(*get)(SpiceImageSurfaces *surfaces,
67
} SpiceImageSurfacesOps;
69
struct _SpiceImageSurfaces {
70
SpiceImageSurfacesOps *ops;
74
void (*put)(SpicePaletteCache *cache,
75
SpicePalette *palette);
76
SpicePalette *(*get)(SpicePaletteCache *cache,
78
void (*release)(SpicePaletteCache *cache,
79
SpicePalette *palette);
80
} SpicePaletteCacheOps;
82
struct _SpicePaletteCache {
83
SpicePaletteCacheOps *ops;
87
void (*decode)(SpiceGlzDecoder *decoder,
93
struct _SpiceGlzDecoder {
94
SpiceGlzDecoderOps *ops;
98
typedef struct SpiceJpegDecoderOps {
99
void (*begin_decode)(SpiceJpegDecoder *decoder,
104
void (*decode)(SpiceJpegDecoder *decoder,
108
} SpiceJpegDecoderOps;
110
struct _SpiceJpegDecoder {
111
SpiceJpegDecoderOps *ops;
115
void (*decode)(SpiceZlibDecoder *decoder,
120
} SpiceZlibDecoderOps;
122
struct _SpiceZlibDecoder {
123
SpiceZlibDecoderOps *ops;
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,
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);
153
/* Implementation vfuncs */
154
void (*fill_solid_spans)(SpiceCanvas *canvas,
159
void (*fill_solid_rects)(SpiceCanvas *canvas,
160
pixman_box32_t *rects,
163
void (*fill_solid_rects_rop)(SpiceCanvas *canvas,
164
pixman_box32_t *rects,
168
void (*fill_tiled_rects)(SpiceCanvas *canvas,
169
pixman_box32_t *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,
177
int offset_x, int offset_y);
178
void (*fill_tiled_rects_rop)(SpiceCanvas *canvas,
179
pixman_box32_t *rects,
181
pixman_image_t *tile,
182
int offset_x, int offset_y,
184
void (*fill_tiled_rects_rop_from_surface)(SpiceCanvas *canvas,
185
pixman_box32_t *rects,
188
int offset_x, int offset_y,
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,
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,
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,
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,
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,
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,
248
void (*blend_image_from_surface)(SpiceCanvas *canvas,
249
pixman_region32_t *region,
251
SpiceCanvas *src_image,
253
int src_x, int src_y,
254
int dest_x, int dest_y,
255
int width, int height,
257
void (*blend_scale_image)(SpiceCanvas *canvas,
258
pixman_region32_t *region,
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,
267
void (*blend_scale_image_from_surface)(SpiceCanvas *canvas,
268
pixman_region32_t *region,
270
SpiceCanvas *src_image,
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,
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,
307
pixman_image_t *(*get_image)(SpiceCanvas *canvas);
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);
313
struct _SpiceCanvas {