Gnash
0.8.10
|
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 __RAWFB_DEVICE_H__ 00021 #define __RAWFB_DEVICE_H__ 1 00022 00023 #ifdef HAVE_CONFIG_H 00024 #include "gnashconfig.h" 00025 #endif 00026 00027 #include <boost/scoped_array.hpp> 00028 #include <boost/scoped_ptr.hpp> 00029 #include <fcntl.h> 00030 #include <sys/ioctl.h> 00031 #include <sys/mman.h> 00032 #include <linux/fb.h> 00033 #include <linux/kd.h> 00034 #include <linux/vt.h> 00035 00036 #include "GnashDevice.h" 00037 00038 namespace gnash { 00039 00040 namespace renderer { 00041 00042 namespace rawfb { 00043 00044 #define CMAP_SIZE (256*2) 00045 00046 class RawFBDevice : public GnashDevice 00047 { 00048 public: 00049 00050 RawFBDevice(); 00051 RawFBDevice(int); 00052 RawFBDevice(int argc, char *argv[]); 00053 00054 // virtual classes should have virtual destructors 00055 virtual ~RawFBDevice(); 00056 00057 dtype_t getType() { return RAWFB; }; 00058 00059 // Initialize RAWFB Device layer 00060 bool initDevice(int argc, char *argv[]); 00061 00062 // Initialize RAWFB Window layer 00063 bool attachWindow(GnashDevice::native_window_t window); 00064 00065 // Utility methods not in the base class 00066 00067 // Return a string with the error code as text, instead of a numeric value 00068 const char *getErrorString(int error); 00069 00070 int getDepth() { return _varinfo.bits_per_pixel; }; 00071 00072 // Accessors for the settings needed by higher level code. 00073 // Surface accessors 00074 size_t getWidth() { return _varinfo.xres; }; 00075 size_t getHeight() { return _varinfo.yres; }; 00076 00077 bool supportsRenderer(GnashDevice::rtype_t /* rtype */) { return false; } 00078 00079 bool isBufferDestroyed() { return false; } 00080 // bool isBufferDestroyed(IRAWFBSurface surface) { 00081 // return false; 00082 // } 00083 int getID() { return 0; }; 00084 00085 // Get the size of the pixels 00086 int getRedSize() { return _varinfo.red.length; }; 00087 int getGreenSize() { return _varinfo.green.length; }; 00088 int getBlueSize() { return _varinfo.blue.length; }; 00089 00090 #ifdef RENDERER_AGG 00091 00092 00093 int getRedOffset() { return _varinfo.red.offset; }; 00094 int getGreenOffset() { return _varinfo.green.offset; }; 00095 int getBlueOffset() { return _varinfo.blue.offset; }; 00096 #endif 00097 00098 // Using RAWFB always means a native renderer 00099 bool isNativeRender() { return true; } 00100 00101 native_window_t getDrawableWindow() { return 0; }; 00102 00103 // 00104 // Testing Support 00105 // 00106 00107 // Create an RAWFB window to render in. This is only used by testing 00108 void createWindow(const char *name, int x, int y, int width, int height); 00109 00110 // Get the memory from the real framebuffer 00111 boost::uint8_t *getFBMemory() { return _fbmem; }; 00112 00113 // // Get the memory from an offscreen buffer to support Double Buffering 00114 boost::uint8_t *getOffscreenBuffer() { return _offscreen_buffer.get(); }; 00115 00116 size_t getStride() { return _fixinfo.line_length; }; 00117 size_t getFBMemSize() { return _fixinfo.smem_len; }; 00118 int getHandle() { return _fd; }; 00119 00126 void eventLoop(size_t passes); 00127 00130 bool setGrayscaleLUT8(); 00131 00132 bool isSingleBuffered() { 00133 #ifdef ENABLE_DOUBLE_BUFFERING 00134 return false; 00135 #else 00136 return true; 00137 #endif 00138 } 00139 00140 bool swapBuffers(); 00141 00142 protected: 00144 void clear(); 00145 00146 int _fd; 00147 std::string _filespec; 00148 struct fb_fix_screeninfo _fixinfo; 00149 struct fb_var_screeninfo _varinfo; 00150 boost::uint8_t *_fbmem; 00151 00152 boost::scoped_ptr<boost::uint8_t> _offscreen_buffer; 00153 struct fb_cmap _cmap; // the colormap 00154 }; 00155 00156 #ifdef ENABLE_FAKE_FRAMEBUFFER 00157 00158 00159 00160 int fakefb_ioctl(int fd, int request, void *data); 00161 #endif 00162 00163 typedef void (*init_func)(); 00164 typedef void (*reshape_func)(int, int); 00165 typedef void (*draw_func)(); 00166 typedef int (*key_func)(unsigned key); 00167 00168 } // namespace rawFB 00169 } // namespace renderer 00170 } // namespace gnash 00171 00172 #endif // end of __RAWFB_DEVICE_H__ 00173 00174 // local Variables: 00175 // mode: C++ 00176 // indent-tabs-mode: nil 00177 // End: