#define wxSTR_TO_DFB(s) wxConvUTF8.cWC2MB((s).wc_str(*wxConvUI))
#endif
-//-----------------------------------------------------------------------------
-// surface manipulation helpers
-//-----------------------------------------------------------------------------
-
-/// Mode of wxDfbCloneSurface() call
-enum wxDfbCloneSurfaceMode
-{
- /// Don't copy surface pixels, just clone surface size and attributes
- wxDfbCloneSurface_NoPixels = 0,
- /// Make exact copy, including the pixels
- wxDfbCloneSurface_CopyPixels
-};
-
-/**
- Creates surface that is compatible with given @a surface (i.e. has same
- capabilities, pixel format etc.) and has given @a size.
- */
-wxIDirectFBSurfacePtr wxDfbCreateCompatibleSurface(
- const wxIDirectFBSurfacePtr& surface,
- const wxSize& size);
-
-/**
- Creates a new surface by cloning existing one. Depending on @a mode,
- either makes exact copy (wxDfbCloneSurface_CopyPixels) or only creates a
- new surface with the same size and attributes (wxDfbCloneSurface_NoPixels).
- */
-wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s,
- wxDfbCloneSurfaceMode mode);
-
-/// Returns bit depth used by the surface
-int wxDfbGetSurfaceDepth(const wxIDirectFBSurfacePtr& s);
-
-/// Returns interface to the primary display layer:
-wxIDirectFBDisplayLayerPtr wxDfbGetDisplayLayer();
-
-/// Returns interface to the primary surface:
-wxIDirectFBSurfacePtr wxDfbGetPrimarySurface();
-
//-----------------------------------------------------------------------------
// misc helpers
//-----------------------------------------------------------------------------
bool Blit(const wxIDirectFBSurfacePtr& source,
const DFBRectangle *source_rect,
int x, int y)
- {
- return Check(
- m_ptr->Blit(m_ptr, source->GetRaw(), source_rect, x, y));
- }
+ { return Blit(source->GetRaw(), source_rect, x, y); }
+
+ bool Blit(IDirectFBSurface *source,
+ const DFBRectangle *source_rect,
+ int x, int y)
+ { return Check(m_ptr->Blit(m_ptr, source, source_rect, x, y)); }
+
+
+ /// Returns bit depth used by the surface or -1 on error
+ int GetDepth();
+
+ /**
+ Creates a new surface by cloning this one. New surface will have same
+ capabilities, pixel format and pixel data as the existing one.
+
+ @see CreateCompatible
+ */
+ wxIDirectFBSurfacePtr Clone();
+
+ /**
+ Creates a surface compatible with this one, i.e. surface with the same
+ capabilities and pixel format, but with different and size.
+
+ @param size Size of the surface to create. If wxDefaultSize, use the
+ size of this surface.
+ */
+ wxIDirectFBSurfacePtr CreateCompatible(const wxSize& size = wxDefaultSize);
};
return NULL;
}
- wxIDirectFBDisplayLayerPtr GetDisplayLayer(DFBDisplayLayerID id)
+ wxIDirectFBDisplayLayerPtr
+ GetDisplayLayer(DFBDisplayLayerID id = DLID_PRIMARY)
{
IDirectFBDisplayLayer *l;
if ( Check(m_ptr->GetDisplayLayer(m_ptr, id, &l)) )
return NULL;
}
+ /// Returns primary surface
+ wxIDirectFBSurfacePtr GetPrimarySurface();
+
private:
wxIDirectFB(IDirectFB *ptr) { Init(ptr); }
{
wxVideoMode m;
- wxIDirectFBSurfacePtr surface(wxDfbGetPrimarySurface());
+ wxIDirectFBSurfacePtr surface(wxIDirectFB::Get()->GetPrimarySurface());
if ( !surface )
return m; // invalid
surface->GetSize(&m.w, &m.h);
- m.bpp = wxDfbGetSurfaceDepth(surface);
+ m.bpp = surface->GetDepth();
return m;
}
wxBitmapRefData(const wxBitmapRefData& data)
{
- m_surface = wxDfbCloneSurface(data.m_surface,
- wxDfbCloneSurface_NoPixels);
+ if ( data.m_surface )
+ m_surface = data.m_surface->Clone();
+
m_mask = data.m_mask ? new wxMask(*data.m_mask) : NULL;
#if wxUSE_PALETTE
m_palette = data.m_palette ? new wxPalette(*data.m_palette) : NULL;
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
- return wxDfbGetSurfaceDepth(M_BITMAP->m_surface);
+ return M_BITMAP->m_surface->GetDepth();
}
wxMask *wxBitmap::GetMask() const
int wxDC::GetDepth() const
{
- return wxDfbGetSurfaceDepth(m_surface);
+ return m_surface->GetDepth();
}
// ---------------------------------------------------------------------------
// so let's create a dummy surface that has the same format as the real
// one would have and let the code paint on it:
wxSize size(rect ? rect->GetSize() : win->GetSize());
- surface = wxDfbCreateCompatibleSurface(win->GetDfbSurface(), size);
+ surface = win->GetDfbSurface()->CreateCompatible(size);
}
else if ( !rect )
{
wxScreenDC::wxScreenDC()
{
- Init(wxDfbGetPrimarySurface());
+ Init(wxIDirectFB::Get()->GetPrimarySurface());
}
#warning "FIXME: does wxScreenDC need Flip call in dtor?"
pos.y = 0;
// create DirectFB window:
- wxIDirectFBDisplayLayerPtr layer = wxDfbGetDisplayLayer();
+ wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
wxCHECK_MSG( layer, false, _T("no display layer") );
DFBWindowDescription desc;
wxDisplaySize(width, height);
}
-//-----------------------------------------------------------------------------
-// surface manipulation helpers
-//-----------------------------------------------------------------------------
-
-wxIDirectFBSurfacePtr wxDfbCreateCompatibleSurface(
- const wxIDirectFBSurfacePtr& s,
- const wxSize& size)
-{
- if ( !s )
- return NULL;
-
- DFBSurfaceDescription desc;
- desc.flags = (DFBSurfaceDescriptionFlags)(
- DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT);
- s->GetCapabilities(&desc.caps);
- s->GetPixelFormat(&desc.pixelformat);
- desc.width = size.x;
- desc.height = size.y;
-
- wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc));
- if ( !snew )
- return NULL;
-
- if ( desc.pixelformat == DSPF_LUT8 )
- {
- wxIDirectFBPalettePtr pal(s->GetPalette());
- if ( s )
- {
- if ( !snew->SetPalette(pal) )
- return NULL;
- }
- }
-
- return snew;
-}
-
-wxIDirectFBSurfacePtr wxDfbCloneSurface(const wxIDirectFBSurfacePtr& s,
- wxDfbCloneSurfaceMode mode)
-{
- if ( !s )
- return NULL;
-
- wxSize size;
- if ( !s->GetSize(&size.x, &size.y) )
- return NULL;
-
- wxIDirectFBSurfacePtr snew(wxDfbCreateCompatibleSurface(s, size));
- if ( !snew )
- return NULL;
-
- if ( mode == wxDfbCloneSurface_CopyPixels )
- {
- if ( !snew->SetBlittingFlags(DSBLIT_NOFX) )
- return NULL;
- if ( !snew->Blit(s, NULL, 0, 0) )
- return NULL;
- }
-
- return snew;
-}
-
-int wxDfbGetSurfaceDepth(const wxIDirectFBSurfacePtr& s)
-{
- wxCHECK_MSG( s, -1, _T("invalid surface") );
-
- DFBSurfacePixelFormat format = DSPF_UNKNOWN;
-
- if ( !s->GetPixelFormat(&format) )
- return -1;
-
- return DFB_BITS_PER_PIXEL(format);
-}
-
-wxIDirectFBDisplayLayerPtr wxDfbGetDisplayLayer()
-{
- return wxIDirectFB::Get()->GetDisplayLayer(DLID_PRIMARY);
-}
-
-wxIDirectFBSurfacePtr wxDfbGetPrimarySurface()
-{
- wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
- return layer ? layer->GetSurface() : NULL;
-}
-
//-----------------------------------------------------------------------------
// mouse
void wxGetMousePosition(int *x, int *y)
{
- wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
+ wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
if ( layer )
layer->GetCursorPosition(x, y);
}
if ( x >= w ) x = w-1;
if ( y >= h ) y = h-1;
- wxIDirectFBDisplayLayerPtr layer(wxDfbGetDisplayLayer());
+ wxIDirectFBDisplayLayerPtr layer(wxIDirectFB::Get()->GetDisplayLayer());
wxCHECK_RET( layer, _T("no display layer") );
layer->WarpCursor(x, y);
{
ms_ptr.Reset();
}
+
+wxIDirectFBSurfacePtr wxIDirectFB::GetPrimarySurface()
+{
+ wxIDirectFBDisplayLayerPtr layer(GetDisplayLayer());
+ return layer ? layer->GetSurface() : NULL;
+}
+
+//-----------------------------------------------------------------------------
+// wxIDirectFBSurface
+//-----------------------------------------------------------------------------
+
+int wxIDirectFBSurface::GetDepth()
+{
+ DFBSurfacePixelFormat format = DSPF_UNKNOWN;
+
+ if ( !GetPixelFormat(&format) )
+ return -1;
+
+ return DFB_BITS_PER_PIXEL(format);
+}
+
+wxIDirectFBSurfacePtr wxIDirectFBSurface::CreateCompatible(const wxSize& sz)
+{
+ wxSize size(sz);
+ if ( size == wxDefaultSize )
+ {
+ if ( !GetSize(&size.x, &size.y) )
+ return NULL;
+ }
+
+ wxCHECK_MSG( size.x > 0 && size.y > 0, NULL, _T("invalid size") );
+
+ DFBSurfaceDescription desc;
+ desc.flags = (DFBSurfaceDescriptionFlags)(
+ DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT);
+ GetCapabilities(&desc.caps);
+ GetPixelFormat(&desc.pixelformat);
+ desc.width = size.x;
+ desc.height = size.y;
+
+ wxIDirectFBSurfacePtr snew(wxIDirectFB::Get()->CreateSurface(&desc));
+ if ( !snew )
+ return NULL;
+
+ if ( desc.pixelformat == DSPF_LUT8 )
+ {
+ wxIDirectFBPalettePtr pal(GetPalette());
+ if ( pal )
+ {
+ if ( !snew->SetPalette(pal) )
+ return NULL;
+ }
+ }
+
+ return snew;
+}
+
+wxIDirectFBSurfacePtr wxIDirectFBSurface::Clone()
+{
+ wxIDirectFBSurfacePtr snew(CreateCompatible());
+ if ( !snew )
+ return NULL;
+
+ if ( !snew->SetBlittingFlags(DSBLIT_NOFX) )
+ return NULL;
+
+ if ( !snew->Blit(GetRaw(), NULL, 0, 0) )
+ return NULL;
+
+ return snew;
+}