summaryrefslogtreecommitdiff
path: root/src/libply-splash-core/ply-pixel-buffer.h
blob: 595e9bd09c76c22c4f09d26d8147d2cf1b62a7ff (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/* ply-pixel-buffer.h - pixel buffer abstraction
 *
 * Copyright (C) 2007, 2009 Red Hat, Inc.
 *
 * 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 2, 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * Written By: Ray Strode <rstrode@redhat.com>
 */
#ifndef PLY_PIXEL_BUFFER_H
#define PLY_PIXEL_BUFFER_H

#include <stdbool.h>
#include <stdint.h>

#include "ply-rectangle.h"
#include "ply-region.h"
#include "ply-utils.h"

typedef struct _ply_pixel_buffer ply_pixel_buffer_t;

#define PLY_PIXEL_BUFFER_COLOR_TO_PIXEL_VALUE(r, g, b, a)                        \
        (((uint8_t) (CLAMP (a * 255.0, 0.0, 255.0)) << 24)                        \
         | ((uint8_t) (CLAMP (r * 255.0, 0.0, 255.0)) << 16)                     \
         | ((uint8_t) (CLAMP (g * 255.0, 0.0, 255.0)) << 8)                      \
         | ((uint8_t) (CLAMP (b * 255.0, 0.0, 255.0))))

#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_pixel_buffer_t *ply_pixel_buffer_new (unsigned long width,
                                          unsigned long height);
void ply_pixel_buffer_free (ply_pixel_buffer_t *buffer);
void ply_pixel_buffer_get_size (ply_pixel_buffer_t *buffer,
                                ply_rectangle_t    *size);
int  ply_pixel_buffer_get_device_scale (ply_pixel_buffer_t *buffer);
void ply_pixel_buffer_set_device_scale (ply_pixel_buffer_t *buffer,
                                        int                 scale);

unsigned long ply_pixel_buffer_get_width (ply_pixel_buffer_t *buffer);
unsigned long ply_pixel_buffer_get_height (ply_pixel_buffer_t *buffer);

bool ply_pixel_buffer_is_opaque (ply_pixel_buffer_t *buffer);
void ply_pixel_buffer_set_opaque (ply_pixel_buffer_t *buffer,
                                  bool                is_opaque);

ply_region_t *ply_pixel_buffer_get_updated_areas (ply_pixel_buffer_t *buffer);

void ply_pixel_buffer_fill_with_color (ply_pixel_buffer_t *buffer,
                                       ply_rectangle_t    *fill_area,
                                       double              red,
                                       double              green,
                                       double              blue,
                                       double              alpha);
void ply_pixel_buffer_fill_with_hex_color (ply_pixel_buffer_t *buffer,
                                           ply_rectangle_t    *fill_area,
                                           uint32_t            hex_color);

void ply_pixel_buffer_fill_with_hex_color_at_opacity (ply_pixel_buffer_t *buffer,
                                                      ply_rectangle_t    *fill_area,
                                                      uint32_t            hex_color,
                                                      double              opacity);

void ply_pixel_buffer_fill_with_gradient (ply_pixel_buffer_t *buffer,
                                          ply_rectangle_t    *fill_area,
                                          uint32_t            start,
                                          uint32_t            end);

void ply_pixel_buffer_fill_with_argb32_data (ply_pixel_buffer_t *buffer,
                                             ply_rectangle_t    *fill_area,
                                             uint32_t           *data);
void ply_pixel_buffer_fill_with_argb32_data_at_opacity (ply_pixel_buffer_t *buffer,
                                                        ply_rectangle_t    *fill_area,
                                                        uint32_t           *data,
                                                        double              opacity);

void ply_pixel_buffer_fill_with_argb32_data_with_clip (ply_pixel_buffer_t *buffer,
                                                       ply_rectangle_t    *fill_area,
                                                       ply_rectangle_t    *clip_area,
                                                       uint32_t           *data);
void ply_pixel_buffer_fill_with_argb32_data_at_opacity_with_clip (ply_pixel_buffer_t *buffer,
                                                                  ply_rectangle_t    *fill_area,
                                                                  ply_rectangle_t    *clip_area,
                                                                  uint32_t           *data,
                                                                  double              opacity);
void ply_pixel_buffer_fill_with_argb32_data_at_opacity_with_clip_and_scale (ply_pixel_buffer_t *buffer,
                                                                            ply_rectangle_t    *fill_area,
                                                                            ply_rectangle_t    *clip_area,
                                                                            uint32_t           *data,
                                                                            double              opacity,
                                                                            int                 scale);

void ply_pixel_buffer_fill_with_buffer_at_opacity_with_clip (ply_pixel_buffer_t *canvas,
                                                             ply_pixel_buffer_t *source,
                                                             int                 x_offset,
                                                             int                 y_offset,
                                                             ply_rectangle_t    *clip_area,
                                                             float               opacity);
void ply_pixel_buffer_fill_with_buffer_at_opacity (ply_pixel_buffer_t *canvas,
                                                   ply_pixel_buffer_t *source,
                                                   int                 x_offset,
                                                   int                 y_offset,
                                                   float               opacity);
void ply_pixel_buffer_fill_with_buffer_with_clip (ply_pixel_buffer_t *canvas,
                                                  ply_pixel_buffer_t *source,
                                                  int                 x_offset,
                                                  int                 y_offset,
                                                  ply_rectangle_t    *clip_area);
void ply_pixel_buffer_fill_with_buffer (ply_pixel_buffer_t *canvas,
                                        ply_pixel_buffer_t *source,
                                        int                 x_offset,
                                        int                 y_offset);


void ply_pixel_buffer_push_clip_area (ply_pixel_buffer_t *buffer,
                                      ply_rectangle_t    *clip_area);
void ply_pixel_buffer_pop_clip_area (ply_pixel_buffer_t *buffer);

uint32_t *ply_pixel_buffer_get_argb32_data (ply_pixel_buffer_t *buffer);

ply_pixel_buffer_t *ply_pixel_buffer_resize (ply_pixel_buffer_t *old_buffer,
                                             long                width,
                                             long                height);

ply_pixel_buffer_t *ply_pixel_buffer_rotate (ply_pixel_buffer_t *old_buffer,
                                             long                center_x,
                                             long                center_y,
                                             double              theta_offset);

ply_pixel_buffer_t *ply_pixel_buffer_tile (ply_pixel_buffer_t *old_buffer,
                                           long                width,
                                           long                height);

#endif

#endif /* PLY_PIXEL_BUFFER_H */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */