Gnash  0.8.11dev
DeviceGlue.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 __DEVICE_GLUE_H__
21 #define __DEVICE_GLUE_H__ 1
22 
23 #ifdef HAVE_CONFIG_H
24 #include "gnashconfig.h"
25 #endif
26 
27 #include <boost/shared_array.hpp>
28 #include <boost/scoped_ptr.hpp>
29 
30 #include "GnashDevice.h"
31 
32 
36 namespace gnash {
37 
38 class DeviceGlue {
39 public:
40  DeviceGlue() {};
42 
48  boost::shared_array<renderer::GnashDevice::dtype_t> probeDevices() {
50 
51  size_t total = 0;
52 #ifdef BUILD_EGL_DEVICE
53  total++;
54 #endif
55 #ifdef BUILD_RAWFB_DEVICE
56  total++;
57 #endif
58 #ifdef BUILD_DIRECTFB_DEVICE
59  total++;
60 #endif
61 #ifdef BUILD_X11_DEVICE
62  total++;
63 #endif
64  total++; // add one more for the list terminator
65  boost::shared_array<renderer::GnashDevice::dtype_t> devs
66  (new renderer::GnashDevice::dtype_t[total]);
67  // terminate the list so it can easily be walked through later.
68  devs[--total] = renderer::GnashDevice::NODEV;
69 #ifdef BUILD_X11_DEVICE
70  devs[--total] = renderer::GnashDevice::X11;
71 #endif
72 #ifdef BUILD_EGL_DEVICE
73  devs[--total] = renderer::GnashDevice::EGL;
74 #endif
75 #ifdef BUILD_RAWFB_DEVICE
76  devs[--total] = renderer::GnashDevice::RAWFB;
77 #endif
78 #ifdef BUILD_DIRECTFB_DEVICE
79  devs[--total] = renderer::GnashDevice::DIRECTFB;
80 #endif
81  return devs;
82  }
83 
85  void resetDevice() { _device.reset(); };
86 
89  {
90  if (_device) {
91  return _device->getType();
92  }
94  }
95 
99 
105  bool initDevice(int argc, char *argv[]) {
106  return (_device) ? _device->initDevice(argc, argv) : false;
107  };
108 
113  return (_device) ? _device->attachWindow(window) : false;
114  };
115 
120  return (_device) ? _device->bindClient(rtype) : false;
121  };
122 
125  size_t getWidth() { return (_device) ? _device->getWidth() : 0; };
126 
129  size_t getHeight() { return (_device) ? _device->getHeight() : 0; };
130 
132  size_t getDepth() { return (_device) ? _device->getDepth() : 0; };
133 
135  bool swapBuffers() {
136  return (_device) ? _device->swapBuffers() : false;
137  }
138 
139 protected:
140  boost::scoped_ptr<renderer::GnashDevice> _device;
141 };
142 
143 } // namespace gnash
144 
145 #endif // end of __DEVICE_GLUE_H__
146 
147 // local Variables:
148 // mode: C++
149 // indent-tabs-mode: nil
150 // End: