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:
gnash::renderer::GnashDevice::native_window_t
long native_window_t
Definition: GnashDevice.h:43
gnash::DeviceGlue::getDepth
size_t getDepth()
Depth of the display.
Definition: DeviceGlue.h:131
gnash::DeviceGlue::swapBuffers
bool swapBuffers()
Make the current buffer the active one.
Definition: DeviceGlue.h:134
gnash::renderer::GnashDevice::GNASH_NODEV
@ GNASH_NODEV
Definition: GnashDevice.h:48
gnash::renderer::GnashDevice::dtype_t
dtype_t
The list of supported device types.
Definition: GnashDevice.h:48
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::DeviceGlue::bindClient
bool bindClient(renderer::GnashDevice::rtype_t rtype)
Definition: DeviceGlue.h:118
GNASH_REPORT_FUNCTION
#define GNASH_REPORT_FUNCTION
Definition: log.h:452
gnash::renderer::GnashDevice::DIRECTFB
@ DIRECTFB
Definition: GnashDevice.h:48
gnash::renderer::GnashDevice::EGL
@ EGL
Definition: GnashDevice.h:48
gnash::DeviceGlue::resetDevice
void resetDevice()
Reset the the current device, which disables output.
Definition: DeviceGlue.h:84
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::DeviceGlue::_device
std::unique_ptr< renderer::GnashDevice > _device
Definition: DeviceGlue.h:139
gnash::DeviceGlue::probeDevices
std::unique_ptr< renderer::GnashDevice::dtype_t[]> probeDevices()
Definition: DeviceGlue.h:47
gnash::renderer::x11::X11Device
Definition: X11Device.h:46
gnash::DeviceGlue::getHeight
size_t getHeight()
Definition: DeviceGlue.h:128
eglDevice.h
gnash::renderer::directfb::DirectFBDevice
Definition: DirectFBDevice.h:44
gnash::DeviceGlue::getDevice
renderer::GnashDevice::dtype_t getDevice()
Get the current active device type.
Definition: DeviceGlue.h:87
gnash::renderer::rawfb::RawFBDevice
Definition: RawFBDevice.h:46
X11Device.h
gnash::DeviceGlue::attachWindow
bool attachWindow(renderer::GnashDevice::native_window_t window)
Definition: DeviceGlue.h:111
gnashconfig.h
gnash::renderer::EGLDevice
Definition: eglDevice.h:57
gnash::DeviceGlue::initDevice
bool initDevice(int argc, char *argv[])
Definition: DeviceGlue.h:104
gnash::DeviceGlue::DeviceGlue
DeviceGlue()
Definition: DeviceGlue.h:39
gnash::renderer::GnashDevice::RAWFB
@ RAWFB
Definition: GnashDevice.h:48
DirectFBDevice.h
gnash::DeviceGlue::~DeviceGlue
~DeviceGlue()
Definition: DeviceGlue.h:40
GnashDevice.h
gnash::renderer::GnashDevice::X11
@ X11
Definition: GnashDevice.h:48
RawFBDevice.h
gnash::renderer::GnashDevice::rtype_t
rtype_t
The list of supported renders that use devices.
Definition: GnashDevice.h:46
gnash::DeviceGlue::getWidth
size_t getWidth()
Definition: DeviceGlue.h:124
DeviceGlue.h
gnash::DeviceGlue
Definition: DeviceGlue.h:37
gnash::DeviceGlue::setDevice
void setDevice(renderer::GnashDevice::dtype_t dtype)
Definition: DeviceGlue.cpp:41