File: ggidirectfb.h

package info (click to toggle)
libggi 1%3A2.2.2-5
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,752 kB
  • ctags: 9,218
  • sloc: ansic: 65,689; sh: 9,211; makefile: 1,226; pascal: 183
file content (283 lines) | stat: -rw-r--r-- 8,062 bytes parent folder | download | duplicates (3)
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
/* $Id: ggidirectfb.h,v 1.9 2005/07/31 15:30:34 soyt Exp $
******************************************************************************

   LibGGI - DirectFB chipset driver support.

   Copyright (C) 2001 Brian S. Julin   [bri@calyx.com]

   Permission is hereby granted, free of charge, to any person obtaining a
   copy of this software and associated documentation files (the "Software"),
   to deal in the Software without restriction, including without limitation
   the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
   THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
   IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

******************************************************************************
*/

#ifndef _GGIFBDEV_DIRECTFB_H
#define _GGIFBDEV_DIRECTFB_H

#include <unistd.h>
#include <sys/mman.h>

#include "config.h"
#include <ggi/internal/ggi-dl.h>
#include <ggi/display/fbdev.h>

#define FUSION_FAKE

#define directfb_major_version fbdev_directfb_major_version_bogus
#define directfb_minor_version fbdev_directfb_minor_version_bogus
#define directfb_micro_version fbdev_directfb_micro_version_bogus
#define directfb_binary_age    fbdev_directfb_binary_age_bogus
#define directfb_interface_age fbdev_directfb_interface_age_bogus
#ifdef _FBDEV_DIRECTFB_BOGUS_GLOBALS
# define extern
# include <directfb.h>
# undef extern
#else
# include <directfb.h>
#endif
#undef directfb_major_version
#undef directfb_minor_version
#undef directfb_micro_version
#undef directfb_binary_age
#undef directfb_interface_age
#undef extern

#ifdef _FBDEV_DIRECTFB_GLOBALS
# define extern
# define dfb_config dfb_config = NULL
# include <directfb-internal/misc/conf.h>
# undef dfb_config
# undef extern
#else
# define dfb_config fbdev_directfb_dfb_config_bogus
# ifdef _FBDEV_DIRECTFB_BOGUS_GLOBALS
#  define extern
#  include <directfb-internal/misc/conf.h>
#  undef extern
# else
#  include <directfb-internal/misc/conf.h>
# endif
# undef dfb_config
#endif

#include <directfb-internal/core/coretypes.h>
#include <directfb-internal/core/gfxcard.h>
#include <directfb-internal/core/fusion/list.h>
#include <directfb-internal/core/fusion/fusion_types.h>


/* These structures are lurking in a .c file so we must provide. */

typedef struct {
  FusionLink            link;

  GraphicsDriverFuncs  *funcs;

  int                   abi_version;
} GraphicsDriver;

typedef struct {
  struct fb_fix_screeninfo fix;

  GraphicsDriverInfo    driver_info;
  GraphicsDeviceInfo    device_info;
  void                 *device_data;

  FusionSkirmish        lock;

  SurfaceManager       *surface_manager;

  /*
   * Points to the current state of the graphics card.
   */
  CardState            *state;
} GraphicsDeviceShared;

struct _GraphicsDevice {
  GraphicsDeviceShared *shared;

  GraphicsDriver       *driver;
  void                 *driver_data;
  void                 *device_data; /* copy of shared->device_data */

  GraphicsDeviceFuncs   funcs;

  /* framebuffer address and size */
  struct {
    unsigned int     length;
    void            *base;
  } framebuffer;
};

#ifdef _FBDEV_DIRECTFB_GLOBALS
# define extern
# define dfb_fbdev dfb_fbdev = NULL
# include <directfb-internal/core/fbdev/fbdev.h>
# undef dfb_fbdev
# undef extern
#else
# define dfb_fbdev fbdev_directfb_dfb_fbdev_bogus
# ifdef _FBDEV_DIRECTFB_BOGUS_GLOBALS
#  define extern
#  include <directfb-internal/core/fbdev/fbdev.h>
#  undef extern
# else
#  include <directfb-internal/core/fbdev/fbdev.h>
# endif
# undef dfb_fbdev
#endif

#include <directfb-internal/core/state.h>
#include <directfb-internal/core/surfaces.h>

#undef FUSION_FAKE

#ifndef MAP_FAILED
#define MAP_FAILED ((void*)-1)
#endif

/* Size of the font */
#define FWIDTH	8
#define FHEIGHT	8

struct fbdev_directfb_global {
  DFBConfig	**dfb_config_ptr;
  FBDev		**dfb_fbdev_ptr;
};

struct directfb_priv {
  struct fbdev_directfb_global	globals;

  DFBConfig			dfbconfig;

  FBDev				fbdev;
  FBDevShared			fbdevshared;
  VideoMode			videomode;

  GraphicsDevice		device;
  GraphicsDriver		driver;
  GraphicsDeviceShared		deviceshared;
  CardState			cardstate;
  CoreSurface			coresurface;
  SurfaceBuffer			corebuffer;

  ggi_pixel	oldfg;
  ggi_pixel	oldbg;
  CoreSurface	*oldsource;

};

/* Update GC components if needed */
static inline void
directfb_gcupdate(ggi_visual_t vis, /* Only used when unmappixel() needed. */
		  struct directfb_priv *priv,
		  ggi_mode *mode, ggi_gc *gc,
		  int virtx, int yadd, DFBAccelerationMask accel)

{
  CardState *cardstate;
  DFBConfig *dfb_config;
  int newfg, newbg, newclip, newsource;

  cardstate = &(priv->cardstate);
  dfb_config = &(priv->dfbconfig);

  newfg = (gc->fg_color != priv->oldfg)
    || (cardstate->drawingflags != DSDRAW_NOFX)
    || (cardstate->blittingflags != DSBLIT_NOFX);
  newbg = (gc->bg_color != priv->oldbg)
    || (dfb_config->layer_bg_mode != DLBM_COLOR);
  newclip =
    (gc->cliptl.x != cardstate->clip.x1) ||
    (gc->clipbr.x != cardstate->clip.x2) ||
    (gc->cliptl.y != cardstate->clip.y1) ||
    (gc->clipbr.y != cardstate->clip.y2);
  newsource = (cardstate->source != priv->oldsource);

  if (! (newfg || newbg || newclip || newsource)) return;

  if (newclip) {
    cardstate->modified |= SMF_CLIP;
    cardstate->clip.x1 = gc->cliptl.x;
    cardstate->clip.x2 = gc->clipbr.x;
    cardstate->clip.y1 = gc->cliptl.y;
    cardstate->clip.y2 = gc->clipbr.y;
  }

  if (newfg) {
    ggi_color newfgcolor;

    cardstate->modified |= SMF_COLOR;
    ggiUnmapPixel(vis, gc->fg_color, &newfgcolor);
    cardstate->color.a = 0; /* ?? */
    cardstate->color.r = (uint8_t)(newfgcolor.r >> 8);
    cardstate->color.g = (uint8_t)(newfgcolor.g >> 8);
    cardstate->color.b = (uint8_t)(newfgcolor.b >> 8);
    if (cardstate->drawingflags != DSDRAW_NOFX) {
      cardstate->drawingflags = DSDRAW_NOFX;
      cardstate->modified |= SMF_DRAWING_FLAGS;
    }
    if (cardstate->blittingflags != DSBLIT_NOFX) {
      cardstate->blittingflags = DSBLIT_NOFX;
      cardstate->modified |= SMF_BLITTING_FLAGS;
    }

  }

  if (newbg) {
    ggi_color newbgcolor;

    ggiUnmapPixel(vis, gc->bg_color, &newbgcolor);
    dfb_config->layer_bg_color.a = 0; /* ?? */
    dfb_config->layer_bg_color.r = (uint8_t)(newbgcolor.r >> 8);
    dfb_config->layer_bg_color.g = (uint8_t)(newbgcolor.g >> 8);
    dfb_config->layer_bg_color.b = (uint8_t)(newbgcolor.b >> 8);
    /* Force reread of the layer color.  Inefficient? */
    cardstate->modified |= SMF_DESTINATION;
    priv->oldbg = gc->bg_color;
    dfb_config->layer_bg_mode = DLBM_COLOR;
  }

  if (newsource) {
    cardstate->modified = SMF_SOURCE;
    priv->oldsource = cardstate->source;
  }

  priv->device.funcs.SetState(priv->device.driver_data,
			      priv->device.device_data,
			      &(priv->device.funcs),
			      &(priv->cardstate),
			      accel);
}

#define DIRECTFB_PRIV(vis) ((struct directfb_priv*)FBDEV_PRIV(vis)->accelpriv)

ggifunc_getcharsize	GGI_directfb_getcharsize;
ggifunc_putc		GGI_directfb_putc;
ggifunc_puts		GGI_directfb_puts;
ggifunc_putc		GGI_directfb_fastputc;
ggifunc_puts		GGI_directfb_fastputs;

ggifunc_drawhline	GGI_directfb_drawhline;
ggifunc_drawvline	GGI_directfb_drawvline;
ggifunc_drawline	GGI_directfb_drawline;
ggifunc_drawbox		GGI_directfb_drawbox;
ggifunc_copybox		GGI_directfb_copybox;
ggifunc_fillscreen	GGI_directfb_fillscreen;
ggifunc_crossblit	GGI_directfb_crossblit;

#endif /* _GGIFBDEV_DIRECTFB_H */