Update with current status
[gnash.git] / libdevice / DeviceGlue.h
blobca5ddda073960670fb3d43936c27b4d437b45f21
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
20 #ifndef __DEVICE_GLUE_H__
21 #define __DEVICE_GLUE_H__ 1
23 #ifdef HAVE_CONFIG_H
24 #include "gnashconfig.h"
25 #endif
27 #include <memory>
29 #include "GnashDevice.h"
32 /// @note This file is a simple base class for any GUI glue layer code
33 /// That needs to use libdevice devices. Currently this is used by both
34 /// the GTK and Framebuffer GUIs for OpenVG, OpenGLES1, and OpenGLES2.
35 namespace gnash {
37 class DeviceGlue {
38 public:
39 DeviceGlue() {};
40 ~DeviceGlue() {};
42 /// Probe the system to see what types of display devices exist. This
43 /// doesn't select a device, it merely returns a list of what is
44 /// available.
45 ///
46 /// @return a list of devices
47 std::unique_ptr<renderer::GnashDevice::dtype_t[]> probeDevices() {
48 GNASH_REPORT_FUNCTION;
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;
83 /// Reset the the current device, which disables output
84 void resetDevice() { _device.reset(); };
86 /// Get the current active device type.
87 renderer::GnashDevice::dtype_t getDevice()
89 if (_device) {
90 return _device->getType();
92 return renderer::GnashDevice::GNASH_NODEV;
95 /// Set the display device for later use. After this is called,
96 /// the display device is active
97 void setDevice(renderer::GnashDevice::dtype_t dtype);
99 /// Initialze the device
101 /// @param argc The count of arguments from the command line
102 /// @param argv The array of command line arguments
103 /// @return status
104 bool initDevice(int argc, char *argv[]) {
105 return (_device) ? _device->initDevice(argc, argv) : false;
108 /// Attach the area to draw in to the lower level device. This makes
109 /// the drawing area available to the dispaly device when binding the
110 /// display to the native windowing system or framebuffer.
111 bool attachWindow(renderer::GnashDevice::native_window_t window) {
112 return (_device) ? _device->attachWindow(window) : false;
115 /// Bind the client API to the device. As EGL can support different
116 /// renderers, namely OpenGL, OpenGLES1, OpenGLES2, and OpenVG. This
117 /// is how the underlying hardware knows which API to implement.
118 bool bindClient(renderer::GnashDevice::rtype_t rtype) {
119 return (_device) ? _device->bindClient(rtype) : false;
122 /// Get the Width of the drawing area, in pixels. For framebuffer
123 /// based devices, this is the size of the display screen.
124 size_t getWidth() { return (_device) ? _device->getWidth() : 0; };
126 /// Height of the drawing area, in pixels. For framebuffer
127 /// based devices, this is the size of the display screen.
128 size_t getHeight() { return (_device) ? _device->getHeight() : 0; };
130 /// Depth of the display
131 size_t getDepth() { return (_device) ? _device->getDepth() : 0; };
133 /// Make the current buffer the active one.
134 bool swapBuffers() {
135 return (_device) ? _device->swapBuffers() : false;
138 protected:
139 std::unique_ptr<renderer::GnashDevice> _device;
142 } // namespace gnash
144 #endif // end of __DEVICE_GLUE_H__
146 // local Variables:
147 // mode: C++
148 // indent-tabs-mode: nil
149 // End: