summaryrefslogtreecommitdiffstats
path: root/common/pixman_utils.h
blob: 45a58cae83801e8be46758791f1e190b1817a453 (plain)
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
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
   Copyright (C) 2009 Red Hat, Inc.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This library 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
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _H__PIXMAN_UTILS
#define _H__PIXMAN_UTILS

#include <spice/types.h>
#include <stdlib.h>
#define PIXMAN_DONT_DEFINE_STDINT
#include <pixman.h>

#include <common/draw.h>

/* This lists all possible 2 argument binary raster ops.
 * This enum has the same values as the X11 GXcopy type
 * and same as the GL constants (GL_AND etc) if you
 * or it with 0x1500. However it is not exactly the
 * same as the win32 ROP2 type (they use another order).
 */
typedef enum {
    SPICE_ROP_CLEAR,         /* 0x0    0 */
    SPICE_ROP_AND,           /* 0x1    src AND dst */
    SPICE_ROP_AND_REVERSE,   /* 0x2    src AND NOT dst */
    SPICE_ROP_COPY,          /* 0x3    src */
    SPICE_ROP_AND_INVERTED,  /* 0x4    (NOT src) AND dst */
    SPICE_ROP_NOOP,          /* 0x5    dst */
    SPICE_ROP_XOR,           /* 0x6    src XOR dst */
    SPICE_ROP_OR,            /* 0x7    src OR dst */
    SPICE_ROP_NOR,           /* 0x8    (NOT src) AND (NOT dst) */
    SPICE_ROP_EQUIV,         /* 0x9    (NOT src) XOR dst */
    SPICE_ROP_INVERT,        /* 0xa    NOT dst */
    SPICE_ROP_OR_REVERSE,    /* 0xb    src OR (NOT dst) */
    SPICE_ROP_COPY_INVERTED, /* 0xc    NOT src */
    SPICE_ROP_OR_INVERTED,   /* 0xd    (NOT src) OR dst */
    SPICE_ROP_NAND,          /* 0xe    (NOT src) OR (NOT dst) */
    SPICE_ROP_SET            /* 0xf    1 */
} SpiceROP;


int spice_pixman_image_get_bpp(pixman_image_t *image);

pixman_format_code_t spice_surface_format_to_pixman(uint32_t surface_format);
pixman_format_code_t spice_bitmap_format_to_pixman(int bitmap_format,
                                                   uint32_t palette_surface_format);
pixman_image_t *spice_bitmap_try_as_pixman(int src_format, int flags,
                                           int width, int height,
                                           uint8_t *data, int stride);
pixman_image_t *spice_bitmap_to_pixman(pixman_image_t *dest_image,
                                       int src_format, int flags,
                                       int width, int height,
                                       uint8_t *src, int src_stride,
                                       uint32_t palette_surface_format,
                                       SpicePalette *palette);
pixman_image_t *spice_bitmap_convert_to_pixman(pixman_format_code_t dest_format,
                                               pixman_image_t *dest_image,
                                               int src_format, int flags,
                                               int width, int height,
                                               uint8_t *src, int src_stride,
                                               uint32_t palette_surface_format,
                                               SpicePalette *palette);

void spice_pixman_region32_init_from_bitmap(pixman_region32_t *region,
                                            uint32_t *data,
                                            int width, int height,
                                            int stride);
pixman_bool_t spice_pixman_region32_init_rects(pixman_region32_t *region,
                                               const SpiceRect   *rects,
                                               int                count);
void spice_pixman_fill_rect(pixman_image_t *dest,
                            int x, int y,
                            int w, int h,
                            uint32_t value);
void spice_pixman_fill_rect_rop(pixman_image_t *dest,
                                int x, int y,
                                int w, int h,
                                uint32_t value,
                                SpiceROP rop);
void spice_pixman_tile_rect(pixman_image_t *dest,
                            int x, int y,
                            int w, int h,
                            pixman_image_t *tile,
                            int offset_x,
                            int offset_y);
void spice_pixman_tile_rect_rop(pixman_image_t *dest,
                                int x, int y,
                                int w, int h,
                                pixman_image_t *tile,
                                int offset_x,
                                int offset_y,
                                SpiceROP rop);
void spice_pixman_blit(pixman_image_t *dest,
                       pixman_image_t *src,
                       int src_x, int src_y,
                       int dest_x, int dest_y,
                       int w, int h);
void spice_pixman_blit_rop(pixman_image_t *dest,
                           pixman_image_t *src,
                           int src_x, int src_y,
                           int dest_x, int dest_y,
                           int w, int h,
                           SpiceROP rop);
void spice_pixman_blit_colorkey(pixman_image_t *dest,
                                pixman_image_t *src,
                                int src_x, int src_y,
                                int dest_x, int dest_y,
                                int width, int height,
                                uint32_t transparent_color);
void spice_pixman_copy_rect(pixman_image_t *image,
                            int src_x, int src_y,
                            int w, int h,
                            int dest_x, int dest_y);

#endif /* _H__PIXMAN_UTILS */