Gnash  0.8.10
DirectFBDevice.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 __DIRECTFB_DEVICE_H__
00021 #define __DIRECTFB_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 
00030 #ifdef HAVE_DIRECTFB_H
00031 # include <directfb/directfb.h>
00032 #else
00033 # error "This file needs DirectFB"
00034 #endif
00035 
00036 #include "GnashDevice.h"
00037 
00038 namespace gnash {
00039 
00040 namespace renderer {
00041 
00042 namespace directfb {
00043 
00044 class DirectFBDevice : public GnashDevice
00045 {
00046   public:
00047     DirectFBDevice();
00048     DirectFBDevice(int argc, char *argv[]);
00049 
00050     ~DirectFBDevice();
00051 
00052     dtype_t getType() { return DIRECTFB; };
00053 
00054     // Initialize DirectFB Device layer
00055     bool initDevice(int argc, char *argv[]);
00056 
00057     // Initialize DirectFB Window layer
00058     //    bool initDirectFB(DirectFBNativeWindowType window);
00059     bool attachWindow(GnashDevice::native_window_t window);
00060         
00061     // Utility methods not in the base class
00063     const char *getErrorString(int error);    
00064     
00065     // Accessors for the settings needed by higher level code.
00066     // Surface accessors
00067     size_t getWidth() {
00068         return getWidth(_surface);
00069     }
00070     
00071     size_t getHeight() {
00072         return getHeight(_surface);
00073     }
00074     
00075     int getDepth() {
00076         DFBSurfacePixelFormat format;
00077         if (_surface) {
00078             _surface->GetPixelFormat(_surface, &format);
00079             return getDepth(format);
00080         }
00081         return 0;
00082     }
00083 
00084     int getRedSize() {
00085         return 0;
00086     };
00087     int getGreenSize() {
00088         return 0;
00089     };
00090     int getBlueSize() {
00091         return 0;
00092     };
00093     
00094     bool isSingleBuffered() {
00095         if (_surface) {
00096             DFBSurfaceCapabilities caps;
00097             _surface->GetCapabilities(_surface, &caps);
00098             if (caps & DSCAPS_DOUBLE) {
00099                 return false;
00100             }
00101         }
00102         return true;
00103     }
00104 
00105     int getID() {
00106         return static_cast<int>(getSurfaceID());
00107     }
00108     
00109     bool isBufferDestroyed() {
00110         // return isBufferDestroyed(_directfbSurface);
00111         return false;
00112     }
00113 
00114     int getSurfaceID() {
00115         if (_layer) {
00116             DFBDisplayLayerID id;
00117             _screen->GetID(_screen, &id);
00118             return static_cast<int>(id);
00119         }
00120         return 0;
00121     }
00122 
00123     virtual bool supportsRenderer(rtype_t /* rtype */) { return true; };
00124 
00125     // Overload some of the base class methods to deal with Device specific
00126     // data types.
00127     int getDepth(DFBSurfacePixelFormat format);
00128 
00129     size_t getWidth(IDirectFBSurface *surface) {
00130         int x, y;
00131         if (surface) {
00132             surface->GetSize(surface, &x, &y);
00133             return static_cast<size_t>(x);
00134         }
00135         return 0;
00136     };
00137     size_t getHeight(IDirectFBSurface *surface) {
00138         int x, y;
00139         if (surface) {
00140             surface->GetSize(surface, &x, &y);
00141             return static_cast<size_t>(y);
00142         }
00143         return 0;
00144     }
00145     bool isSurfaceBackBuffered() {
00146         if (_surface) {
00147             DFBSurfaceCapabilities caps;
00148             _surface->GetCapabilities(_surface, &caps);
00149             if (caps & DSCAPS_DOUBLE) {
00150                 return true;
00151             }        
00152             return false;
00153         }
00154     }
00155     // Context accessors
00156     int getContextID() {
00157         if (_layer) {
00158             DFBDisplayLayerID id;
00159             _layer->GetID(_layer, &id);
00160             return static_cast<int>(id);
00161         }
00162         return 0;
00163     }
00164 
00165     bool isContextSingleBuffered() {
00166         if (_layer) {
00167             DFBDisplayLayerConfig config;
00168             _layer->GetConfiguration(_layer, &config);
00169             if (config.buffermode & DLBM_FRONTONLY) {
00170                 return true;
00171             }        
00172             return false;
00173         }
00174         return false;
00175     }
00176     bool isContextBackBuffered() {
00177         if (_layer) {
00178             DFBDisplayLayerConfig config;
00179             _layer->GetConfiguration(_layer, &config);
00180             if (config.buffermode & DLBM_FRONTONLY) {
00181                 return false;
00182             }        
00183             return true;
00184         }
00185         return true;
00186     }
00187 
00188     bool isNativeRender() {
00189         return true;
00190     }
00191     
00192     size_t getVerticalRes() {
00193         return getVerticalRes(_screen);
00194     }
00195     size_t getVerticalRes(IDirectFBScreen *screen) {
00196         int x, y;
00197         if (screen) {
00198             screen->GetSize(screen, &x, &y);
00199             return static_cast<size_t>(x);
00200         }
00201         return 0;
00202     }
00203     size_t getHorzRes() {
00204         return getHorzRes(_screen);
00205     }
00206     size_t getHorzRes(IDirectFBScreen *screen) {
00207         int x, y;
00208         if (screen) {
00209             screen->GetSize(screen, &x, &y);
00210             return static_cast<size_t>(y);
00211         }
00212         return 0;
00213     }
00214     
00216     void printDirectFB() {
00217         printDirectFB(_dfb);
00218     };
00219     void printDirectFB(IDirectFB *fb);
00220 
00222     void printFBSurface() {
00223         printFBSurface(_surface);
00224     };
00225     void printFBSurface(IDirectFBSurface *surface);
00226 
00228     void printFBFont() {
00229         printFBFont(_font);
00230     };
00231     void printFBFont(IDirectFBFont *font);
00232 
00234     void printFBDisplay() {
00235         printFBDisplay(_layer);
00236     };
00237     void printFBDisplay(IDirectFBDisplayLayer *display);
00238 
00239     void printFBLayer() {
00240         printFBDisplayLayer(_layer);
00241     };
00242     void printFBDisplayLayer(IDirectFBDisplayLayer *layer);
00243 
00245     void printFBScreen() {
00246         printFBScreen(_screen);
00247     };
00248     void printFBScreen(IDirectFBScreen *screen);
00249 
00251     void printFBInputDevice() {
00252         printFBInputDevice(_keyboard);
00253     };
00254     void printFBInputDevice(IDirectFBInputDevice *input);
00255 
00256 protected:
00257     void printAccelerationMask(DFBAccelerationMask mask);
00258     void printSurfaceBlittingFlags(DFBSurfaceBlittingFlags flags);
00259     void printSurfaceDrawingFlags(DFBSurfaceDrawingFlags flags);
00260     void printGrapbicsDriverIndo(DFBGraphicsDriverInfo *driver);
00261     void printSurfaceDescriptionFlags(DFBSurfaceDescriptionFlags flags);
00262     void printSurfaceCapabilities(DFBSurfaceCapabilities caps);
00263     void printSurfacePixelFormat(DFBSurfacePixelFormat format);
00264     void printDisplayLayerTypeFlags(DFBDisplayLayerTypeFlags flags);
00265     void printDisplayLayerCapabilities(DFBDisplayLayerCapabilities caps);
00266     void printfScreenCapabilities(DFBScreenCapabilities caos);
00267     void printDisplayLayerConfig(DFBDisplayLayerConfig *config);
00268     void printDisplayLayerBufferMode(DFBDisplayLayerBufferMode mode);
00269 
00270     void printColor(DFBColor color);
00271     //    void printFBSurfaceHintFlags(DFBSurfaceHintFlags flags);
00272     
00273     IDirectFB                *_dfb;
00274     IDirectFBSurface         *_surface;
00275     IDirectFBInputDevice     *_keyboard;
00276     IDirectFBEventBuffer     *_keybuffer;
00277     IDirectFBImageProvider   *_provider;
00278     IDirectFBFont            *_font;
00279     IDirectFBDisplayLayer    *_layer;
00280     IDirectFBScreen          *_screen;
00281 };
00282 
00283 } // namespace directfb
00284 } // namespace renderer
00285 } // namespace gnash
00286 
00287 #endif  // end of __DIRECTFB_DEVICE_H__
00288 
00289 // local Variables:
00290 // mode: C++
00291 // indent-tabs-mode: nil
00292 // End: