]> git.saurik.com Git - wxWidgets.git/blobdiff - src/dfb/wrapdfb.cpp
check that the version of __sync_sub_and_fetch that returns a value is supported...
[wxWidgets.git] / src / dfb / wrapdfb.cpp
index c23796696367b73be73d6991e29ef745cecd00aa..e05ad09541b4500b12a8271234b739d97c170a6b 100644 (file)
     #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 +36,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: " _T(#code) );         \
                 return false                                            \
 
         DFB_ASSERT(DFB_DEAD);
                 return false                                            \
 
         DFB_ASSERT(DFB_DEAD);
@@ -98,14 +103,23 @@ void wxIDirectFB::CleanUp()
 
 wxIDirectFBSurfacePtr wxIDirectFB::GetPrimarySurface()
 {
 
 wxIDirectFBSurfacePtr wxIDirectFB::GetPrimarySurface()
 {
-    wxIDirectFBDisplayLayerPtr layer(GetDisplayLayer());
-    return layer ? layer->GetSurface() : NULL;
+    DFBSurfaceDescription desc;
+    desc.flags = DSDESC_CAPS;
+    desc.caps = DSCAPS_PRIMARY;
+    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 +130,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 +140,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 +150,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;
@@ -180,3 +206,26 @@ bool wxIDirectFBSurface::FlipToFront(const DFBRegion *region)
     // drawings:
     return Flip(region, DSFLIP_BLIT);
 }
     // 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)
+           );
+}