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 <memory>
28 
29 #include "GnashDevice.h"
30 
31 
35 namespace gnash {
36 
37 class DeviceGlue {
38 public:
39  DeviceGlue() {};
41 
47  std::unique_ptr<renderer::GnashDevice::dtype_t[]> probeDevices() {
49 
50  size_t total = 0;
51 #ifdef BUILD_EGL_DEVICE
52  total++;
53 #endif
54 #ifdef BUILD_RAWFB_DEVICE
55  total++;
56 #endif
57 #ifdef BUILD_DIRECTFB_DEVICE
58  total++;
59 #endif
60 #ifdef BUILD_X11_DEVICE
61  total++;
62 #endif
63  total++; // add one more for the list terminator
64  std::unique_ptr<renderer::GnashDevice::dtype_t[]> devs
65  (new renderer::GnashDevice::dtype_t[total]);
66  // terminate the list so it can easily be walked through later.
67  devs[--total] = renderer::GnashDevice::GNASH_NODEV;
68 #ifdef BUILD_X11_DEVICE
69  devs[--total] = renderer::GnashDevice::X11;
70 #endif
71 #ifdef BUILD_EGL_DEVICE
72  devs[--total] = renderer::GnashDevice::EGL;
73 #endif
74 #ifdef BUILD_RAWFB_DEVICE
75  devs[--total] = renderer::GnashDevice::RAWFB;
76 #endif
77 #ifdef BUILD_DIRECTFB_DEVICE
78  devs[--total] = renderer::GnashDevice::DIRECTFB;
79 #endif
80  return devs;
81  }
82 
84  void resetDevice() { _device.reset(); };
85 
88  {
89  if (_device) {
90  return _device->getType();
91  }
93  }
94 
98 
104  bool initDevice(int argc, char *argv[]) {
105  return (_device) ? _device->initDevice(argc, argv) : false;
106  };
107 
112  return (_device) ? _device->attachWindow(window) : false;
113  };
114 
119  return (_device) ? _device->bindClient(rtype) : false;
120  };
121 
124  size_t getWidth() { return (_device) ? _device->getWidth() : 0; };
125 
128  size_t getHeight() { return (_device) ? _device->getHeight() : 0; };
129 
131  size_t getDepth() { return (_device) ? _device->getDepth() : 0; };
132 
134  bool swapBuffers() {
135  return (_device) ? _device->swapBuffers() : false;
136  }
137 
138 protected:
139  std::unique_ptr<renderer::GnashDevice> _device;
140 };
141 
142 } // namespace gnash
143 
144 #endif // end of __DEVICE_GLUE_H__
145 
146 // local Variables:
147 // mode: C++
148 // indent-tabs-mode: nil
149 // End:
bool swapBuffers()
Make the current buffer the active one.
Definition: DeviceGlue.h:134
Definition: GnashDevice.h:48
Definition: GnashDevice.h:48
DeviceGlue()
Definition: DeviceGlue.h:39
std::unique_ptr< renderer::GnashDevice::dtype_t[]> probeDevices()
Definition: DeviceGlue.h:47
size_t getWidth()
Definition: DeviceGlue.h:124
long native_window_t
Definition: GnashDevice.h:43
size_t getHeight()
Definition: DeviceGlue.h:128
Definition: GnashDevice.h:48
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
renderer::GnashDevice::dtype_t getDevice()
Get the current active device type.
Definition: DeviceGlue.h:87
Definition: GnashDevice.h:48
Definition: DeviceGlue.h:37
bool initDevice(int argc, char *argv[])
Definition: DeviceGlue.h:104
rtype_t
The list of supported renders that use devices.
Definition: GnashDevice.h:46
Definition: GnashDevice.h:48
size_t getDepth()
Depth of the display.
Definition: DeviceGlue.h:131
void resetDevice()
Reset the the current device, which disables output.
Definition: DeviceGlue.h:84
~DeviceGlue()
Definition: DeviceGlue.h:40
bool bindClient(renderer::GnashDevice::rtype_t rtype)
Definition: DeviceGlue.h:118
#define GNASH_REPORT_FUNCTION
Definition: log.h:452
bool attachWindow(renderer::GnashDevice::native_window_t window)
Definition: DeviceGlue.h:111
void setDevice(renderer::GnashDevice::dtype_t dtype)
Definition: DeviceGlue.cpp:41
std::unique_ptr< renderer::GnashDevice > _device
Definition: DeviceGlue.h:139