summaryrefslogtreecommitdiffstats
path: root/src/libply/ply-frame-buffer.h
blob: e57e1b108d2ea1ebe1151588821ced8f4d77b678 (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
/* ply-frame-buffer.h - framebuffer abstraction
 *
 * Copyright (C) 2007 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_FRAME_BUFFER_H
#define PLY_FRAME_BUFFER_H

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

#include "ply-utils.h"

typedef struct _ply_frame_buffer ply_frame_buffer_t;
typedef struct _ply_frame_buffer_area ply_frame_buffer_area_t;

struct _ply_frame_buffer_area
{
  unsigned long x;
  unsigned long y;
  unsigned long width;
  unsigned long height;
};

#define PLY_FRAME_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_frame_buffer_t *ply_frame_buffer_new (const char *device_name);
void ply_frame_buffer_free (ply_frame_buffer_t *buffer);
bool ply_frame_buffer_open (ply_frame_buffer_t *buffer);
void ply_frame_buffer_pause_updates (ply_frame_buffer_t *buffer);
bool ply_frame_buffer_unpause_updates (ply_frame_buffer_t *buffer);
bool ply_frame_buffer_device_is_open (ply_frame_buffer_t *buffer); 
char *ply_frame_buffer_get_device_name (ply_frame_buffer_t *buffer);
void ply_frame_buffer_set_device_name (ply_frame_buffer_t *buffer,
                                       const char     *device_name);
void ply_frame_buffer_close (ply_frame_buffer_t *buffer);
void ply_frame_buffer_get_size (ply_frame_buffer_t     *buffer,
                                ply_frame_buffer_area_t *size);
bool ply_frame_buffer_fill_with_color (ply_frame_buffer_t      *buffer,
                                       ply_frame_buffer_area_t  *area,
                                       double               red, 
                                       double               green,
                                       double               blue, 
                                       double               alpha);
bool ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t      *buffer,
                                           ply_frame_buffer_area_t *area,
                                           uint32_t                 hex_color);

bool ply_frame_buffer_fill_with_hex_color_at_opacity (ply_frame_buffer_t      *buffer,
                                                      ply_frame_buffer_area_t *area,
                                                      uint32_t                 hex_color,
                                                      double                   opacity);

bool ply_frame_buffer_fill_with_gradient (ply_frame_buffer_t      *buffer,
					  ply_frame_buffer_area_t *area,
					  uint32_t                 start,
					  uint32_t                 end);

bool ply_frame_buffer_fill_with_argb32_data (ply_frame_buffer_t      *buffer,
                                             ply_frame_buffer_area_t  *area,
                                             unsigned long        x,
                                             unsigned long        y,
                                             uint32_t            *data);
bool ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t      *buffer,
                                                        ply_frame_buffer_area_t *area,
                                                        unsigned long            x,
                                                        unsigned long            y,
                                                        uint32_t                *data,
                                                        double                   opacity);

#endif

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