Gnash  0.8.10
DeviceGlue.h
Go to the documentation of this file.
00001 //
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 //
00019 
00020 #ifndef __DEVICE_GLUE_H__
00021 #define __DEVICE_GLUE_H__ 1
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "gnashconfig.h"
00025 #endif
00026 
00027 #include <boost/shared_array.hpp>
00028 #include <boost/scoped_ptr.hpp>
00029 
00030 #include "GnashDevice.h"
00031 
00032 
00036 namespace gnash {
00037 
00038 class DeviceGlue {
00039 public:
00040     DeviceGlue() {};
00041     ~DeviceGlue() {};
00042     
00048     boost::shared_array<renderer::GnashDevice::dtype_t> probeDevices() {
00049         GNASH_REPORT_FUNCTION;
00050         
00051         size_t total = 0;
00052 #ifdef BUILD_EGL_DEVICE
00053         total++;
00054 #endif
00055 #ifdef BUILD_RAWFB_DEVICE
00056         total++;
00057 #endif
00058 #ifdef BUILD_DIRECTFB_DEVICE
00059         total++;
00060 #endif
00061 #ifdef BUILD_X11_DEVICE
00062         total++;
00063 #endif
00064         total++;                // add one more for the list terminator
00065         boost::shared_array<renderer::GnashDevice::dtype_t> devs
00066             (new renderer::GnashDevice::dtype_t[total]);
00067         // terminate the list so it can easily be walked through later.
00068         devs[--total] = renderer::GnashDevice::NODEV;
00069 #ifdef BUILD_X11_DEVICE
00070         devs[--total] = renderer::GnashDevice::X11;
00071 #endif
00072 #ifdef BUILD_EGL_DEVICE
00073         devs[--total] = renderer::GnashDevice::EGL;
00074 #endif
00075 #ifdef BUILD_RAWFB_DEVICE
00076         devs[--total] = renderer::GnashDevice::RAWFB;
00077 #endif
00078 #ifdef BUILD_DIRECTFB_DEVICE
00079         devs[--total] = renderer::GnashDevice::DIRECTFB;
00080 #endif
00081         return devs;
00082     }
00083 
00085     void resetDevice() { _device.reset(); };
00086     
00088     renderer::GnashDevice::dtype_t getDevice()
00089     {
00090         if (_device) {
00091             return _device->getType();
00092         }
00093         return renderer::GnashDevice::NODEV;
00094     }
00095     
00098     void setDevice(renderer::GnashDevice::dtype_t dtype);
00099 
00105     bool initDevice(int argc, char *argv[]) {
00106         return (_device) ? _device->initDevice(argc, argv) : false;
00107     };
00108 
00112     bool attachWindow(renderer::GnashDevice::native_window_t window) {
00113         return (_device) ? _device->attachWindow(window) : false;
00114     };
00115 
00119     bool bindClient(renderer::GnashDevice::rtype_t rtype) {
00120         return (_device) ? _device->bindClient(rtype) : false;
00121     };
00122 
00125     size_t getWidth()  { return (_device) ? _device->getWidth() : 0; };
00126 
00129     size_t getHeight() { return (_device) ? _device->getHeight() : 0; };
00130 
00132     size_t getDepth() { return (_device) ? _device->getDepth() : 0; };
00133 
00135     bool swapBuffers() {
00136         return (_device) ? _device->swapBuffers() : false;
00137     }
00138 
00139 protected:
00140     boost::scoped_ptr<renderer::GnashDevice> _device;
00141 };
00142     
00143 } // namespace gnash
00144 
00145 #endif  // end of __DEVICE_GLUE_H__
00146 
00147 // local Variables:
00148 // mode: C++
00149 // indent-tabs-mode: nil
00150 // End: