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 <boost/scoped_array.hpp>
28 #include <boost/scoped_ptr.hpp>
29 
30 #ifdef HAVE_DIRECTFB_H
31 # include <directfb/directfb.h>
32 #else
33 # error "This file needs DirectFB"
34 #endif
35 
36 #include "GnashDevice.h"
37 
38 namespace gnash {
39 
40 namespace renderer {
41 
42 namespace directfb {
43 
45 {
46  public:
48  DirectFBDevice(int argc, char *argv[]);
49 
51 
52  dtype_t getType() { return DIRECTFB; };
53 
54  // Initialize DirectFB Device layer
55  bool initDevice(int argc, char *argv[]);
56 
57  // Initialize DirectFB Window layer
58  // bool initDirectFB(DirectFBNativeWindowType window);
60 
61  // Utility methods not in the base class
63  const char *getErrorString(int error);
64 
65  // Accessors for the settings needed by higher level code.
66  // Surface accessors
67  size_t getWidth() {
68  return getWidth(_surface);
69  }
70 
71  size_t getHeight() {
72  return getHeight(_surface);
73  }
74 
75  int getDepth() {
76  DFBSurfacePixelFormat format;
77  if (_surface) {
78  _surface->GetPixelFormat(_surface, &format);
79  return getDepth(format);
80  }
81  return 0;
82  }
83 
84  int getRedSize() {
85  return 0;
86  };
87  int getGreenSize() {
88  return 0;
89  };
90  int getBlueSize() {
91  return 0;
92  };
93 
95  if (_surface) {
96  DFBSurfaceCapabilities caps;
97  _surface->GetCapabilities(_surface, &caps);
98  if (caps & DSCAPS_DOUBLE) {
99  return false;
100  }
101  }
102  return true;
103  }
104 
105  int getID() {
106  return static_cast<int>(getSurfaceID());
107  }
108 
110  // return isBufferDestroyed(_directfbSurface);
111  return false;
112  }
113 
114  int getSurfaceID() {
115  if (_layer) {
116  DFBDisplayLayerID id;
117  _screen->GetID(_screen, &id);
118  return static_cast<int>(id);
119  }
120  return 0;
121  }
122 
123  virtual bool supportsRenderer(rtype_t /* rtype */) { return true; };
124 
125  // Overload some of the base class methods to deal with Device specific
126  // data types.
127  int getDepth(DFBSurfacePixelFormat format);
128 
129  size_t getWidth(IDirectFBSurface *surface) {
130  int x, y;
131  if (surface) {
132  surface->GetSize(surface, &x, &y);
133  return static_cast<size_t>(x);
134  }
135  return 0;
136  };
137  size_t getHeight(IDirectFBSurface *surface) {
138  int x, y;
139  if (surface) {
140  surface->GetSize(surface, &x, &y);
141  return static_cast<size_t>(y);
142  }
143  return 0;
144  }
146  if (_surface) {
147  DFBSurfaceCapabilities caps;
148  _surface->GetCapabilities(_surface, &caps);
149  if (caps & DSCAPS_DOUBLE) {
150  return true;
151  }
152  return false;
153  }
154  }
155  // Context accessors
156  int getContextID() {
157  if (_layer) {
158  DFBDisplayLayerID id;
159  _layer->GetID(_layer, &id);
160  return static_cast<int>(id);
161  }
162  return 0;
163  }
164 
166  if (_layer) {
167  DFBDisplayLayerConfig config;
168  _layer->GetConfiguration(_layer, &config);
169  if (config.buffermode & DLBM_FRONTONLY) {
170  return true;
171  }
172  return false;
173  }
174  return false;
175  }
177  if (_layer) {
178  DFBDisplayLayerConfig config;
179  _layer->GetConfiguration(_layer, &config);
180  if (config.buffermode & DLBM_FRONTONLY) {
181  return false;
182  }
183  return true;
184  }
185  return true;
186  }
187 
188  bool isNativeRender() {
189  return true;
190  }
191 
192  size_t getVerticalRes() {
193  return getVerticalRes(_screen);
194  }
195  size_t getVerticalRes(IDirectFBScreen *screen) {
196  int x, y;
197  if (screen) {
198  screen->GetSize(screen, &x, &y);
199  return static_cast<size_t>(x);
200  }
201  return 0;
202  }
203  size_t getHorzRes() {
204  return getHorzRes(_screen);
205  }
206  size_t getHorzRes(IDirectFBScreen *screen) {
207  int x, y;
208  if (screen) {
209  screen->GetSize(screen, &x, &y);
210  return static_cast<size_t>(y);
211  }
212  return 0;
213  }
214 
216  void printDirectFB() {
218  };
219  void printDirectFB(IDirectFB *fb);
220 
222  void printFBSurface() {
224  };
225  void printFBSurface(IDirectFBSurface *surface);
226 
228  void printFBFont() {
230  };
231  void printFBFont(IDirectFBFont *font);
232 
234  void printFBDisplay() {
236  };
237  void printFBDisplay(IDirectFBDisplayLayer *display);
238 
239  void printFBLayer() {
241  };
242  void printFBDisplayLayer(IDirectFBDisplayLayer *layer);
243 
245  void printFBScreen() {
247  };
248  void printFBScreen(IDirectFBScreen *screen);
249 
253  };
254  void printFBInputDevice(IDirectFBInputDevice *input);
255 
256 protected:
257  void printAccelerationMask(DFBAccelerationMask mask);
258  void printSurfaceBlittingFlags(DFBSurfaceBlittingFlags flags);
259  void printSurfaceDrawingFlags(DFBSurfaceDrawingFlags flags);
260  void printGrapbicsDriverIndo(DFBGraphicsDriverInfo *driver);
261  void printSurfaceDescriptionFlags(DFBSurfaceDescriptionFlags flags);
262  void printSurfaceCapabilities(DFBSurfaceCapabilities caps);
263  void printSurfacePixelFormat(DFBSurfacePixelFormat format);
264  void printDisplayLayerTypeFlags(DFBDisplayLayerTypeFlags flags);
265  void printDisplayLayerCapabilities(DFBDisplayLayerCapabilities caps);
266  void printfScreenCapabilities(DFBScreenCapabilities caos);
267  void printDisplayLayerConfig(DFBDisplayLayerConfig *config);
268  void printDisplayLayerBufferMode(DFBDisplayLayerBufferMode mode);
269 
270  void printColor(DFBColor color);
271  // void printFBSurfaceHintFlags(DFBSurfaceHintFlags flags);
272 
273  IDirectFB *_dfb;
274  IDirectFBSurface *_surface;
275  IDirectFBInputDevice *_keyboard;
276  IDirectFBEventBuffer *_keybuffer;
277  IDirectFBImageProvider *_provider;
278  IDirectFBFont *_font;
279  IDirectFBDisplayLayer *_layer;
280  IDirectFBScreen *_screen;
281 };
282 
283 } // namespace directfb
284 } // namespace renderer
285 } // namespace gnash
286 
287 #endif // end of __DIRECTFB_DEVICE_H__
288 
289 // local Variables:
290 // mode: C++
291 // indent-tabs-mode: nil
292 // End: