]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/wrapdfb.cpp
Avoid calling gtk_window_get_position() from "configure-event" handler, if possible.
[wxWidgets.git] / src / dfb / wrapdfb.cpp
index 873f040cdefac3b135e67b7ead116a94f5b38e0e..f62e9c367bdacfe8fb10d9865c4046f47f297ae4 100644 (file)
@@ -3,7 +3,6 @@
 // Purpose:     wx wrappers for DirectFB interfaces
 // Author:      Vaclav Slavik
 // Created:     2006-09-04
 // Purpose:     wx wrappers for DirectFB interfaces
 // Author:      Vaclav Slavik
 // Created:     2006-09-04
-// RCS-ID:      $Id$
 // Copyright:   (c) 2006 REA Elektronik GmbH
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) 2006 REA Elektronik GmbH
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
     #pragma hdrstop
 #endif
 
     #pragma hdrstop
 #endif
 
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/log.h"
+#endif
+
 #include "wx/dfb/wrapdfb.h"
 
 //-----------------------------------------------------------------------------
 #include "wx/dfb/wrapdfb.h"
 
 //-----------------------------------------------------------------------------
@@ -31,7 +35,7 @@ bool wxDfbCheckReturn(DFBResult code)
         // these are programming errors, assert:
         #define DFB_ASSERT(code)                                        \
             case code:                                                  \
         // these are programming errors, assert:
         #define DFB_ASSERT(code)                                        \
             case code:                                                  \
-                wxFAIL_MSG( _T("DirectFB error: ") _T(#code) );         \
+                wxFAIL_MSG( "DirectFB error: " wxT(#code) );         \
                 return false                                            \
 
         DFB_ASSERT(DFB_DEAD);
                 return false                                            \
 
         DFB_ASSERT(DFB_DEAD);
@@ -56,7 +60,7 @@ bool wxDfbCheckReturn(DFBResult code)
 
         default:
             // FIXME: should handle the errors individually
 
         default:
             // FIXME: should handle the errors individually
-            wxLogError(_("DirectFB error %d occured."), (int)code);
+            wxLogError(_("DirectFB error %d occurred."), (int)code);
             return false;
     }
 }
             return false;
     }
 }
@@ -98,14 +102,29 @@ void wxIDirectFB::CleanUp()
 
 wxIDirectFBSurfacePtr wxIDirectFB::GetPrimarySurface()
 {
 
 wxIDirectFBSurfacePtr wxIDirectFB::GetPrimarySurface()
 {
-    wxIDirectFBDisplayLayerPtr layer(GetDisplayLayer());
-    return layer ? layer->GetSurface() : NULL;
+    DFBSurfaceDescription desc;
+    desc.flags = DSDESC_CAPS;
+    // NB: see dcscreen.cpp for why we request double-buffered surface
+    //
+    //     This assumes the cooperative level is DFSCL_NORMAL (that's the
+    //     default and wx doesn't modify it anywhere); if we ever support
+    //     other cooperative levels, DSCAPS_DOUBLE should *not* be used with
+    //     them.
+    desc.caps = DFBSurfaceCapabilities(DSCAPS_PRIMARY | DSCAPS_DOUBLE);
+    return CreateSurface(&desc);
 }
 
 //-----------------------------------------------------------------------------
 // wxIDirectFBSurface
 //-----------------------------------------------------------------------------
 
 }
 
 //-----------------------------------------------------------------------------
 // wxIDirectFBSurface
 //-----------------------------------------------------------------------------
 
+DFBSurfacePixelFormat wxIDirectFBSurface::GetPixelFormat()
+{
+    DFBSurfacePixelFormat format = DSPF_UNKNOWN;
+    GetPixelFormat(&format);
+    return format;
+}
+
 int wxIDirectFBSurface::GetDepth()
 {
     DFBSurfacePixelFormat format = DSPF_UNKNOWN;
 int wxIDirectFBSurface::GetDepth()
 {
     DFBSurfacePixelFormat format = DSPF_UNKNOWN;
@@ -116,7 +135,8 @@ int wxIDirectFBSurface::GetDepth()
     return DFB_BITS_PER_PIXEL(format);
 }
 
     return DFB_BITS_PER_PIXEL(format);
 }
 
-wxIDirectFBSurfacePtr wxIDirectFBSurface::CreateCompatible(const wxSize& sz)
+wxIDirectFBSurfacePtr
+wxIDirectFBSurface::CreateCompatible(const wxSize& sz, int flags)
 {
     wxSize size(sz);
     if ( size == wxDefaultSize )
 {
     wxSize size(sz);
     if ( size == wxDefaultSize )
@@ -125,7 +145,7 @@ wxIDirectFBSurfacePtr wxIDirectFBSurface::CreateCompatible(const wxSize& sz)
             return NULL;
     }
 
             return NULL;
     }
 
-    wxCHECK_MSG( size.x > 0 && size.y > 0, NULL, _T("invalid size") );
+    wxCHECK_MSG( size.x > 0 && size.y > 0, NULL, "invalid size" );
 
     DFBSurfaceDescription desc;
     desc.flags = (DFBSurfaceDescriptionFlags)(
 
     DFBSurfaceDescription desc;
     desc.flags = (DFBSurfaceDescriptionFlags)(
@@ -135,6 +155,17 @@ wxIDirectFBSurfacePtr wxIDirectFBSurface::CreateCompatible(const wxSize& sz)
     desc.width = size.x;
     desc.height = size.y;
 
     desc.width = size.x;
     desc.height = size.y;
 
+    // filter out caps that don't make sense for a new compatible surface:
+    int caps = desc.caps;
+    caps &= ~DSCAPS_PRIMARY;
+    caps &= ~DSCAPS_SUBSURFACE;
+    if ( flags & CreateCompatible_NoBackBuffer )
+    {
+        caps &= ~DSCAPS_DOUBLE;
+        caps &= ~DSCAPS_TRIPLE;
+    }
+    desc.caps = (DFBSurfaceCapabilities)caps;
+
     wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc));
     if ( !snew )
         return NULL;
     wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc));
     if ( !snew )
         return NULL;
@@ -166,3 +197,40 @@ wxIDirectFBSurfacePtr wxIDirectFBSurface::Clone()
 
     return snew;
 }
 
     return snew;
 }
+
+bool wxIDirectFBSurface::Flip(const DFBRegion *region, int flags)
+{
+    return Check(m_ptr->Flip(m_ptr, region, (DFBSurfaceFlipFlags)flags));
+}
+
+bool wxIDirectFBSurface::FlipToFront(const DFBRegion *region)
+{
+    // Blit to the front buffer instead of exchanging front and back ones.
+    // Always doing this ensures that back and front buffer have same content
+    // and so painting to the back buffer will never lose any previous
+    // drawings:
+    return Flip(region, DSFLIP_BLIT);
+}
+
+//-----------------------------------------------------------------------------
+// wxIDirectFBDisplayLayer
+//-----------------------------------------------------------------------------
+
+wxVideoMode wxIDirectFBDisplayLayer::GetVideoMode()
+{
+    DFBDisplayLayerConfig cfg;
+    if ( !GetConfiguration(&cfg) )
+        return wxVideoMode(); // invalid
+
+    if ( !((cfg.flags & DLCONF_WIDTH) &&
+           (cfg.flags & DLCONF_HEIGHT) &&
+           (cfg.flags & DLCONF_PIXELFORMAT)) )
+        return wxVideoMode(); // invalid
+
+    return wxVideoMode
+           (
+             cfg.width,
+             cfg.height,
+             DFB_BITS_PER_PIXEL(cfg.pixelformat)
+           );
+}