2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
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.
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.
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
24 #include "gnashconfig.h"
27 #include <boost/shared_array.hpp>
28 #include <boost/scoped_ptr.hpp>
30 #include "GnashDevice.h"
33 /// @note This file is a simple base class for any GUI glue layer code
34 /// That needs to use libdevice devices. Currently this is used by both
35 /// the GTK and Framebuffer GUIs for OpenVG, OpenGLES1, and OpenGLES2.
43 /// Probe the system to see what types of display devices exist. This
44 /// doesn't select a device, it merely returns a list of what is
47 /// @return a list of devices
48 boost::shared_array
<renderer::GnashDevice::dtype_t
> probeDevices() {
49 GNASH_REPORT_FUNCTION
;
52 #ifdef BUILD_EGL_DEVICE
55 #ifdef BUILD_RAWFB_DEVICE
58 #ifdef BUILD_DIRECTFB_DEVICE
61 #ifdef BUILD_X11_DEVICE
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
;
72 #ifdef BUILD_EGL_DEVICE
73 devs
[--total
] = renderer::GnashDevice::EGL
;
75 #ifdef BUILD_RAWFB_DEVICE
76 devs
[--total
] = renderer::GnashDevice::RAWFB
;
78 #ifdef BUILD_DIRECTFB_DEVICE
79 devs
[--total
] = renderer::GnashDevice::DIRECTFB
;
84 /// Reset the the current device, which disables output
85 void resetDevice() { _device
.reset(); };
87 /// Get the current active device type.
88 renderer::GnashDevice::dtype_t
getDevice()
91 return _device
->getType();
93 return renderer::GnashDevice::NODEV
;
96 /// Set the display device for later use. After this is called,
97 /// the display device is active
98 void setDevice(renderer::GnashDevice::dtype_t dtype
);
100 /// Initialze the device
102 /// @param argc The count of arguments from the command line
103 /// @param argv The array of command line arguments
105 bool initDevice(int argc
, char *argv
[]) {
106 return (_device
) ? _device
->initDevice(argc
, argv
) : false;
109 /// Attach the area to draw in to the lower level device. This makes
110 /// the drawing area available to the dispaly device when binding the
111 /// display to the native windowing system or framebuffer.
112 bool attachWindow(renderer::GnashDevice::native_window_t window
) {
113 return (_device
) ? _device
->attachWindow(window
) : false;
116 /// Bind the client API to the device. As EGL can support different
117 /// renderers, namely OpenGL, OpenGLES1, OpenGLES2, and OpenVG. This
118 /// is how the underlying hardware knows which API to implement.
119 bool bindClient(renderer::GnashDevice::rtype_t rtype
) {
120 return (_device
) ? _device
->bindClient(rtype
) : false;
123 /// Get the Width of the drawing area, in pixels. For framebuffer
124 /// based devices, this is the size of the display screen.
125 size_t getWidth() { return (_device
) ? _device
->getWidth() : 0; };
127 /// Height of the drawing area, in pixels. For framebuffer
128 /// based devices, this is the size of the display screen.
129 size_t getHeight() { return (_device
) ? _device
->getHeight() : 0; };
131 /// Depth of the display
132 size_t getDepth() { return (_device
) ? _device
->getDepth() : 0; };
134 /// Make the current buffer the active one.
136 return (_device
) ? _device
->swapBuffers() : false;
140 boost::scoped_ptr
<renderer::GnashDevice
> _device
;
145 #endif // end of __DEVICE_GLUE_H__
149 // indent-tabs-mode: nil