Gnash  0.8.11dev
DirectFBDevice.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 //
19 
20 #ifndef __DIRECTFB_DEVICE_H__
21 #define __DIRECTFB_DEVICE_H__ 1
22 
23 #ifdef HAVE_CONFIG_H
24 #include "gnashconfig.h"
25 #endif
26 
27 #include <memory>
28 
29 #ifdef HAVE_DIRECTFB_H
30 # include <directfb/directfb.h>
31 #else
32 # error "This file needs DirectFB"
33 #endif
34 
35 #include "GnashDevice.h"
36 
37 namespace gnash {
38 
39 namespace renderer {
40 
41 namespace directfb {
42 
44 {
45  public:
47  DirectFBDevice(int argc, char *argv[]);
48 
50 
51  dtype_t getType() { return DIRECTFB; };
52 
53  // Initialize DirectFB Device layer
54  bool initDevice(int argc, char *argv[]);
55 
56  // Initialize DirectFB Window layer
57  // bool initDirectFB(DirectFBNativeWindowType window);
59 
60  // Utility methods not in the base class
62  const char *getErrorString(int error);
63 
64  // Accessors for the settings needed by higher level code.
65  // Surface accessors
66  size_t getWidth() {
67  return getWidth(_surface);
68  }
69 
70  size_t getHeight() {
71  return getHeight(_surface);
72  }
73 
74  int getDepth() {
75  DFBSurfacePixelFormat format;
76  if (_surface) {
77  _surface->GetPixelFormat(_surface, &format);
78  return getDepth(format);
79  }
80  return 0;
81  }
82 
83  int getRedSize() {
84  return 0;
85  };
86  int getGreenSize() {
87  return 0;
88  };
89  int getBlueSize() {
90  return 0;
91  };
92 
94  if (_surface) {
95  DFBSurfaceCapabilities caps;
96  _surface->GetCapabilities(_surface, &caps);
97  if (caps & DSCAPS_DOUBLE) {
98  return false;
99  }
100  }
101  return true;
102  }
103 
104  int getID() {
105  return static_cast<int>(getSurfaceID());
106  }
107 
109  // return isBufferDestroyed(_directfbSurface);
110  return false;
111  }
112 
113  int getSurfaceID() {
114  if (_layer) {
115  DFBDisplayLayerID id;
116  _screen->GetID(_screen, &id);
117  return static_cast<int>(id);
118  }
119  return 0;
120  }
121 
122  virtual bool supportsRenderer(rtype_t /* rtype */) { return true; };
123 
124  // Overload some of the base class methods to deal with Device specific
125  // data types.
126  int getDepth(DFBSurfacePixelFormat format);
127 
128  size_t getWidth(IDirectFBSurface *surface) {
129  int x, y;
130  if (surface) {
131  surface->GetSize(surface, &x, &y);
132  return static_cast<size_t>(x);
133  }
134  return 0;
135  };
136  size_t getHeight(IDirectFBSurface *surface) {
137  int x, y;
138  if (surface) {
139  surface->GetSize(surface, &x, &y);
140  return static_cast<size_t>(y);
141  }
142  return 0;
143  }
145  if (_surface) {
146  DFBSurfaceCapabilities caps;
147  _surface->GetCapabilities(_surface, &caps);
148  if (caps & DSCAPS_DOUBLE) {
149  return true;
150  }
151  return false;
152  }
153  }
154  // Context accessors
155  int getContextID() {
156  if (_layer) {
157  DFBDisplayLayerID id;
158  _layer->GetID(_layer, &id);
159  return static_cast<int>(id);
160  }
161  return 0;
162  }
163 
165  if (_layer) {
166  DFBDisplayLayerConfig config;
167  _layer->GetConfiguration(_layer, &config);
168  if (config.buffermode & DLBM_FRONTONLY) {
169  return true;
170  }
171  return false;
172  }
173  return false;
174  }
176  if (_layer) {
177  DFBDisplayLayerConfig config;
178  _layer->GetConfiguration(_layer, &config);
179  if (config.buffermode & DLBM_FRONTONLY) {
180  return false;
181  }
182  return true;
183  }
184  return true;
185  }
186 
187  bool isNativeRender() {
188  return true;
189  }
190 
191  size_t getVerticalRes() {
192  return getVerticalRes(_screen);
193  }
194  size_t getVerticalRes(IDirectFBScreen *screen) {
195  int x, y;
196  if (screen) {
197  screen->GetSize(screen, &x, &y);
198  return static_cast<size_t>(x);
199  }
200  return 0;
201  }
202  size_t getHorzRes() {
203  return getHorzRes(_screen);
204  }
205  size_t getHorzRes(IDirectFBScreen *screen) {
206  int x, y;
207  if (screen) {
208  screen->GetSize(screen, &x, &y);
209  return static_cast<size_t>(y);
210  }
211  return 0;
212  }
213 
215  void printDirectFB() {
217  };
218  void printDirectFB(IDirectFB *fb);
219 
221  void printFBSurface() {
223  };
224  void printFBSurface(IDirectFBSurface *surface);
225 
227  void printFBFont() {
229  };
230  void printFBFont(IDirectFBFont *font);
231 
233  void printFBDisplay() {
235  };
236  void printFBDisplay(IDirectFBDisplayLayer *display);
237 
238  void printFBLayer() {
240  };
241  void printFBDisplayLayer(IDirectFBDisplayLayer *layer);
242 
244  void printFBScreen() {
246  };
247  void printFBScreen(IDirectFBScreen *screen);
248 
252  };
253  void printFBInputDevice(IDirectFBInputDevice *input);
254 
255 protected:
256  void printAccelerationMask(DFBAccelerationMask mask);
257  void printSurfaceBlittingFlags(DFBSurfaceBlittingFlags flags);
258  void printSurfaceDrawingFlags(DFBSurfaceDrawingFlags flags);
259  void printGrapbicsDriverIndo(DFBGraphicsDriverInfo *driver);
260  void printSurfaceDescriptionFlags(DFBSurfaceDescriptionFlags flags);
261  void printSurfaceCapabilities(DFBSurfaceCapabilities caps);
262  void printSurfacePixelFormat(DFBSurfacePixelFormat format);
263  void printDisplayLayerTypeFlags(DFBDisplayLayerTypeFlags flags);
264  void printDisplayLayerCapabilities(DFBDisplayLayerCapabilities caps);
265  void printfScreenCapabilities(DFBScreenCapabilities caos);
266  void printDisplayLayerConfig(DFBDisplayLayerConfig *config);
267  void printDisplayLayerBufferMode(DFBDisplayLayerBufferMode mode);
268 
269  void printColor(DFBColor color);
270  // void printFBSurfaceHintFlags(DFBSurfaceHintFlags flags);
271 
272  IDirectFB *_dfb;
273  IDirectFBSurface *_surface;
274  IDirectFBInputDevice *_keyboard;
275  IDirectFBEventBuffer *_keybuffer;
276  IDirectFBImageProvider *_provider;
277  IDirectFBFont *_font;
278  IDirectFBDisplayLayer *_layer;
279  IDirectFBScreen *_screen;
280 };
281 
282 } // namespace directfb
283 } // namespace renderer
284 } // namespace gnash
285 
286 #endif // end of __DIRECTFB_DEVICE_H__
287 
288 // local Variables:
289 // mode: C++
290 // indent-tabs-mode: nil
291 // End:
IDirectFBFont * _font
Definition: DirectFBDevice.h:277
void printDisplayLayerTypeFlags(DFBDisplayLayerTypeFlags flags)
Definition: DirectFBDevice.cpp:558
void printDisplayLayerConfig(DFBDisplayLayerConfig *config)
Definition: DirectFBDevice.cpp:201
void printFBInputDevice()
print the data in a DirectFBInputDevice
Definition: DirectFBDevice.h:250
Definition: GnashDevice.h:48
void printGrapbicsDriverIndo(DFBGraphicsDriverInfo *driver)
Definition: DirectFBDevice.cpp:855
size_t getVerticalRes()
Definition: DirectFBDevice.h:191
int getID()
Get the window ID handle.
Definition: DirectFBDevice.h:104
void printColor(DFBColor color)
Definition: DirectFBDevice.cpp:1195
size_t getHorzRes()
Definition: DirectFBDevice.h:202
bool isBufferDestroyed()
Are buffers destroyed ?
Definition: DirectFBDevice.h:108
Definition: DirectFBDevice.h:43
size_t getVerticalRes(IDirectFBScreen *screen)
Definition: DirectFBDevice.h:194
void printDisplayLayerCapabilities(DFBDisplayLayerCapabilities caps)
Definition: DirectFBDevice.cpp:404
long native_window_t
Definition: GnashDevice.h:43
void printFBFont()
print the data in a DirectFBFont
Definition: DirectFBDevice.h:227
void printSurfaceCapabilities(DFBSurfaceCapabilities caps)
Definition: DirectFBDevice.cpp:984
Definition: GnashDevice.h:39
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
dtype_t
The list of supported device types.
Definition: GnashDevice.h:48
IDirectFBScreen * _screen
Definition: DirectFBDevice.h:279
void printFBDisplay()
print the data in a DirectFBDisplay
Definition: DirectFBDevice.h:233
void printSurfaceDrawingFlags(DFBSurfaceDrawingFlags flags)
Definition: DirectFBDevice.cpp:823
virtual bool supportsRenderer(rtype_t)
Is the specified renderer supported by this hardware ?
Definition: DirectFBDevice.h:122
const VGfloat color[4]
Definition: testr_gtk.cpp:82
void printFBSurface()
print the data in a DirectFBSurface
Definition: DirectFBDevice.h:221
int getGreenSize()
Get the size of the Green pixel.
Definition: DirectFBDevice.h:86
IDirectFBEventBuffer * _keybuffer
Definition: DirectFBDevice.h:275
IDirectFB * _dfb
Definition: DirectFBDevice.h:272
bool initDevice(int argc, char *argv[])
Definition: DirectFBDevice.cpp:107
void printSurfaceBlittingFlags(DFBSurfaceBlittingFlags flags)
Definition: DirectFBDevice.cpp:759
void printFBLayer()
Definition: DirectFBDevice.h:238
struct lirc_config * config
Definition: lirc_ext.cpp:43
rtype_t
The list of supported renders that use devices.
Definition: GnashDevice.h:46
void printDirectFB()
print the data in a DirectFB
Definition: DirectFBDevice.h:215
DirectFBDevice()
Definition: DirectFBDevice.cpp:52
int getDepth()
Get the depth of the device.
Definition: DirectFBDevice.h:74
~DirectFBDevice()
Definition: DirectFBDevice.cpp:82
dtype_t getType()
Definition: DirectFBDevice.h:51
void printSurfaceDescriptionFlags(DFBSurfaceDescriptionFlags flags)
Definition: DirectFBDevice.cpp:942
std::int32_t x
Definition: BitmapData_as.cpp:434
int getRedSize()
Get the size of the Red pixel.
Definition: DirectFBDevice.h:83
bool isSurfaceBackBuffered()
Definition: DirectFBDevice.h:144
void printDisplayLayerBufferMode(DFBDisplayLayerBufferMode mode)
Definition: DirectFBDevice.cpp:218
int getBlueSize()
Get the size of the Blue pixel.
Definition: DirectFBDevice.h:89
size_t getWidth()
Get the width of the device.
Definition: DirectFBDevice.h:66
IDirectFBImageProvider * _provider
Definition: DirectFBDevice.h:276
IDirectFBSurface * _surface
Definition: DirectFBDevice.h:273
bool isContextSingleBuffered()
Definition: DirectFBDevice.h:164
void printAccelerationMask(DFBAccelerationMask mask)
Definition: DirectFBDevice.cpp:715
std::int32_t y
Definition: BitmapData_as.cpp:435
bool attachWindow(GnashDevice::native_window_t window)
Definition: DirectFBDevice.cpp:193
IDirectFBInputDevice * _keyboard
Definition: DirectFBDevice.h:274
size_t getHorzRes(IDirectFBScreen *screen)
Definition: DirectFBDevice.h:205
bool isNativeRender()
Is this renderering natively.
Definition: DirectFBDevice.h:187
size_t getHeight()
Get the Height of the device.
Definition: DirectFBDevice.h:70
size_t getHeight(IDirectFBSurface *surface)
Definition: DirectFBDevice.h:136
bool isSingleBuffered()
Is this device single buffered.
Definition: DirectFBDevice.h:93
void printFBScreen()
print the data in a DirectFBFont
Definition: DirectFBDevice.h:244
void printFBDisplayLayer(IDirectFBDisplayLayer *layer)
bool isContextBackBuffered()
Definition: DirectFBDevice.h:175
size_t getWidth(IDirectFBSurface *surface)
Definition: DirectFBDevice.h:128
void printSurfacePixelFormat(DFBSurfacePixelFormat format)
Definition: DirectFBDevice.cpp:1056
const char * getErrorString(int error)
Return a string with the error code as text, instead of a numeric value.
Definition: DirectFBDevice.cpp:586
void printfScreenCapabilities(DFBScreenCapabilities caos)
Definition: DirectFBDevice.cpp:529
IDirectFBDisplayLayer * _layer
Definition: DirectFBDevice.h:278
int getSurfaceID()
Definition: DirectFBDevice.h:113
int getContextID()
Definition: DirectFBDevice.h:155