~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/gfx/src/xlibrgb/xlibrgb.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 
2
 *
 
3
 * The contents of this file are subject to the Mozilla Public License
 
4
 * Version 1.1 (the "MPL"); you may not use this file except in
 
5
 * compliance with the MPL.  You may obtain a copy of the MPL at
 
6
 * http://www.mozilla.org/MPL/
 
7
 *
 
8
 * Software distributed under the MPL is distributed on an "AS IS" basis,
 
9
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
 
10
 * for the specific language governing rights and limitations under the
 
11
 * MPL.
 
12
 *
 
13
 * Alternatively, the contents of this file may be used under the
 
14
 * terms of the GNU Library General Public License (the "LGPL"), in
 
15
 * which case the provisions of the LGPL are applicable instead of
 
16
 * those above.  If you wish to allow use of your version of this file
 
17
 * only under the terms of the LGPL and not to allow others to use
 
18
 * your version of this file under the MPL, indicate your decision by
 
19
 * deleting the provisions above and replace them with the notice and
 
20
 * other provisions required by the LGPL.  If you do not delete the
 
21
 * provisions above, a recipient may use your version of this file
 
22
 * under either the MPL or the LGPL.
 
23
 */
 
24
 
 
25
/*
 
26
 * This code is derived from GdkRgb.
 
27
 * For more information on GdkRgb, see http://www.levien.com/gdkrgb/
 
28
 * Raph Levien <raph@acm.org>
 
29
 */
 
30
 
 
31
/* Ported by Christopher Blizzard to Xlib.  With permission from the
 
32
 * original authors of this file, the contents of this file are also
 
33
 * redistributable under the terms of the Mozilla Public license.  For
 
34
 * information about the Mozilla Public License, please see the
 
35
 * license information at http://www.mozilla.org/MPL/
 
36
 */
 
37
 
 
38
/* This code is copyright the following authors:
 
39
 * Raph Levien          <raph@acm.org>
 
40
 * Manish Singh         <manish@gtk.org>
 
41
 * Tim Janik            <timj@gtk.org>
 
42
 * Peter Mattis         <petm@xcf.berkeley.edu>
 
43
 * Spencer Kimball      <spencer@xcf.berkeley.edu>
 
44
 * Josh MacDonald       <jmacd@xcf.berkeley.edu>
 
45
 * Christopher Blizzard <blizzard@redhat.com>
 
46
 * Owen Taylor          <otaylor@redhat.com>
 
47
 * Shawn T. Amundson    <amundson@gtk.org>
 
48
 * Roland Mainz         <roland.mainz@informatik.med.uni-giessen.de> 
 
49
 */
 
50
 
 
51
 
 
52
#ifndef __XLIB_RGB_H__
 
53
#define __XLIB_RGB_H__
 
54
 
 
55
/* Force ANSI C prototypes from X11 headers */
 
56
#undef FUNCPROTO
 
57
#define FUNCPROTO 15
 
58
 
 
59
#include <X11/Xlib.h>
 
60
#include <X11/Xutil.h>
 
61
#include <X11/Xos.h>
 
62
#include <X11/Intrinsic.h>
 
63
 
 
64
_XFUNCPROTOBEGIN
 
65
 
 
66
/* Porting Note:
 
67
 * If you are going to use this code somewhere other than mozilla
 
68
 * you will need to set these defines.  It's pretty easy for Intel
 
69
 * but I'm not sure about other platforms.
 
70
 */
 
71
#ifdef USE_MOZILLA_TYPES
 
72
/* prtypes contains definitions for uint32/int32 and uint16/int16 */
 
73
#include "prtypes.h"
 
74
#include "prcpucfg.h"
 
75
 
 
76
#define NS_TO_XXLIB_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
 
77
#else
 
78
typedef unsigned int uint32;
 
79
typedef int int32;
 
80
typedef unsigned short uint16;
 
81
typedef short int16;
 
82
#endif /* USE_MOZILLA_TYPES */
 
83
 
 
84
typedef struct _XlibRgbCmap XlibRgbCmap;
 
85
typedef struct _XlibRgbHandle XlibRgbHandle;
 
86
 
 
87
struct _XlibRgbCmap {
 
88
  unsigned int colors[256];
 
89
  unsigned char lut[256]; /* for 8-bit modes */
 
90
};
 
91
 
 
92
 
 
93
typedef enum
 
94
{
 
95
  XLIB_RGB_DITHER_NONE,
 
96
  XLIB_RGB_DITHER_NORMAL,
 
97
  XLIB_RGB_DITHER_MAX
 
98
} XlibRgbDither;
 
99
 
 
100
typedef struct
 
101
{
 
102
  const char *handle_name;
 
103
  int         pseudogray; /* emulate GrayScale via PseudoColor visuals */
 
104
  int         install_colormap;
 
105
  int         disallow_image_tiling;
 
106
  int         disallow_mit_shmem;
 
107
  int         verbose;
 
108
  XVisualInfo xtemplate;
 
109
  long        xtemplate_mask;
 
110
} XlibRgbArgs;
 
111
 
 
112
XlibRgbHandle *
 
113
xxlib_rgb_create_handle (Display *display, Screen *screen, 
 
114
                         XlibRgbArgs *args);
 
115
                                  
 
116
void
 
117
xxlib_rgb_destroy_handle (XlibRgbHandle *handle);
 
118
 
 
119
unsigned long
 
120
xxlib_rgb_xpixel_from_rgb (XlibRgbHandle *handle, uint32 rgb);
 
121
 
 
122
void
 
123
xxlib_rgb_gc_set_foreground (XlibRgbHandle *handle, GC gc, uint32 rgb);
 
124
 
 
125
void
 
126
xxlib_rgb_gc_set_background (XlibRgbHandle *handle, GC gc, uint32 rgb);
 
127
 
 
128
void
 
129
xxlib_draw_rgb_image (XlibRgbHandle *handle, Drawable drawable,
 
130
                      GC gc,
 
131
                      int x,
 
132
                      int y,
 
133
                      int width,
 
134
                      int height,
 
135
                      XlibRgbDither dith,
 
136
                      unsigned char *rgb_buf,
 
137
                      int rowstride);
 
138
 
 
139
void
 
140
xxlib_draw_rgb_image_dithalign (XlibRgbHandle *handle, Drawable drawable,
 
141
                                GC gc,
 
142
                                int x,
 
143
                                int y,
 
144
                                int width,
 
145
                                int height,
 
146
                                XlibRgbDither dith,
 
147
                                unsigned char *rgb_buf,
 
148
                                int rowstride,
 
149
                                int xdith,
 
150
                                int ydith);
 
151
 
 
152
void
 
153
xxlib_draw_rgb_32_image (XlibRgbHandle *handle, Drawable drawable,
 
154
                         GC gc,
 
155
                         int x,
 
156
                         int y,
 
157
                         int width,
 
158
                         int height,
 
159
                         XlibRgbDither dith,
 
160
                         unsigned char *buf,
 
161
                         int rowstride);
 
162
 
 
163
void
 
164
xxlib_draw_gray_image (XlibRgbHandle *handle, Drawable drawable,
 
165
                       GC gc,
 
166
                       int x,
 
167
                       int y,
 
168
                       int width,
 
169
                       int height,
 
170
                       XlibRgbDither dith,
 
171
                       unsigned char *buf,
 
172
                       int rowstride);
 
173
 
 
174
XlibRgbCmap *
 
175
xxlib_rgb_cmap_new (XlibRgbHandle *handle, uint32 *colors, int n_colors);
 
176
 
 
177
void
 
178
xxlib_rgb_cmap_free (XlibRgbHandle *handle, XlibRgbCmap *cmap);
 
179
 
 
180
void
 
181
xxlib_draw_indexed_image (XlibRgbHandle *handle, Drawable drawable,
 
182
                          GC gc,
 
183
                          int x,
 
184
                          int y,
 
185
                          int width,
 
186
                          int height,
 
187
                          XlibRgbDither dith,
 
188
                          unsigned char *buf,
 
189
                          int rowstride,
 
190
                          XlibRgbCmap *cmap);
 
191
 
 
192
void
 
193
xxlib_draw_xprint_scaled_rgb_image( XlibRgbHandle *handle,
 
194
                                    Drawable drawable,
 
195
                                    long paper_resolution,
 
196
                                    long image_resolution,
 
197
                                    GC gc,
 
198
                                    int x,
 
199
                                    int y,
 
200
                                    int width,
 
201
                                    int height,
 
202
                                    XlibRgbDither dith,
 
203
                                    unsigned char *rgb_buf,
 
204
                                    int rowstride);
 
205
 
 
206
/* Below are some functions which are primarily useful for debugging
 
207
   and experimentation. */
 
208
Bool
 
209
xxlib_rgb_ditherable (XlibRgbHandle *handle);
 
210
 
 
211
void
 
212
xxlib_rgb_set_verbose (XlibRgbHandle *handle, Bool verbose);
 
213
 
 
214
void
 
215
xxlib_rgb_set_min_colors (XlibRgbHandle *handle, int min_colors);
 
216
 
 
217
Colormap
 
218
xxlib_rgb_get_cmap (XlibRgbHandle *handle);
 
219
 
 
220
Visual *
 
221
xxlib_rgb_get_visual (XlibRgbHandle *handle);
 
222
 
 
223
XVisualInfo *
 
224
xxlib_rgb_get_visual_info (XlibRgbHandle *handle);
 
225
 
 
226
int
 
227
xxlib_rgb_get_depth (XlibRgbHandle *handle);
 
228
 
 
229
/* hint: if you don't how to obtain a handle - use |xxlib_find_handle()| :-) */
 
230
Display *
 
231
xxlib_rgb_get_display (XlibRgbHandle *handle);
 
232
 
 
233
Screen *
 
234
xxlib_rgb_get_screen (XlibRgbHandle *handle);
 
235
 
 
236
unsigned long
 
237
xxlib_get_prec_from_mask(unsigned long);
 
238
 
 
239
unsigned long
 
240
xxlib_get_shift_from_mask(unsigned long);
 
241
 
 
242
/* default name - for cases where there is only one XlibRgbHandle required */
 
243
#define XXLIBRGB_DEFAULT_HANDLE ("xxlib-default")
 
244
 
 
245
Bool 
 
246
xxlib_register_handle(const char *name, XlibRgbHandle *handle);
 
247
 
 
248
Bool 
 
249
xxlib_deregister_handle(const char *name);
 
250
 
 
251
XlibRgbHandle *
 
252
xxlib_find_handle(const char *name);
 
253
 
 
254
_XFUNCPROTOEND
 
255
 
 
256
#endif /* !__XLIB_RGB_H__ */
 
257