From 6a546cadf18b2c73d32868d84a8e3edc4455d508 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 24 Aug 2009 08:34:08 -0700 Subject: Implement support for keeping image provider alive If you define QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE we make sure atleast one IDirectFBImageProvider is alive at all times. Apparently this is refcounted by DirectFB on atleast one implementation and there's considerable overhead involved when releasing the last/creating the first image provider. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/directfb.pro | 1 + .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 8 ++++++- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 25 ++++++++++++++++++++++ src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 9 ++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index f01d8b1..055e7cd 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -7,6 +7,7 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers # support all of the DirectFB API. # #DEFINES += QT_DIRECTFB_IMAGEPROVIDER +#DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE #DEFINES += QT_DIRECTFB_IMAGECACHE #DEFINES += QT_NO_DIRECTFB_WM #DEFINES += QT_NO_DIRECTFB_LAYER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index caa973f..70a6e02 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -237,12 +237,18 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti return false; } +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + IDirectFBImageProvider *provider = 0; +#else QDirectFBPointer provider; +#endif if ((result = dataBuffer->CreateImageProvider(dataBuffer, &provider)) != DFB_OK) { DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't create image provider", result); return false; } - +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + screen->setDirectFBImageProvider(provider); +#endif DFBSurfaceDescription surfaceDescription; if ((result = provider->GetSurfaceDescription(provider, &surfaceDescription)) != DFB_OK) { DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't get surface description", result); diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index ecd4aba..3911178 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -87,6 +87,9 @@ public: #ifndef QT_NO_DIRECTFB_KEYBOARD QDirectFBKeyboardHandler *keyboard; #endif +#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + IDirectFBImageProvider *imageProvider; +#endif QColor backgroundColor; QDirectFBScreen *q; }; @@ -109,6 +112,9 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr) #ifndef QT_NO_DIRECTFB_KEYBOARD , keyboard(0) #endif +#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + , imageProvider(0) +#endif , q(qptr) { #ifndef QT_NO_QWS_SIGNALHANDLER @@ -128,6 +134,10 @@ QDirectFBScreenPrivate::~QDirectFBScreenPrivate() #ifndef QT_NO_DIRECTFB_KEYBOARD delete keyboard; #endif +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + if (imageProvider) + imageProvider->Release(imageProvider); +#endif for (QSet::const_iterator it = allocatedSurfaces.begin(); it != allocatedSurfaces.end(); ++it) { (*it)->Release(*it); @@ -1097,6 +1107,10 @@ bool QDirectFBScreen::connect(const QString &displaySpec) void QDirectFBScreen::disconnect() { +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + if (d_ptr->imageProvider) + d_ptr->imageProvider->Release(d_ptr->imageProvider); +#endif #ifdef QT_NO_DIRECTFB_WM d_ptr->primarySurface->Release(d_ptr->primarySurface); d_ptr->primarySurface = 0; @@ -1375,4 +1389,15 @@ void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags } } +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE +void QDirectFBScreen::setDirectFBImageProvider(IDirectFBImageProvider *provider) +{ + Q_ASSERT(provider); + if (d_ptr->imageProvider) + d_ptr->imageProvider->Release(d_ptr->imageProvider); + d_ptr->imageProvider = provider; +} +#endif + + diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index c61cde7..19f032e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -62,6 +62,9 @@ QT_MODULE(Gui) #if !defined QT_DIRECTFB_IMAGEPROVIDER && !defined QT_NO_DIRECTFB_IMAGEPROVIDER #define QT_NO_DIRECTFB_IMAGEPROVIDER #endif +#if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE +#define QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE +#endif #if !defined QT_NO_DIRECTFB_PALETTE && !defined QT_DIRECTFB_PALETTE #define QT_DIRECTFB_PALETTE #endif @@ -80,6 +83,9 @@ QT_MODULE(Gui) #if defined QT_NO_DIRECTFB_LAYER && defined QT_DIRECTFB_WM #error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM #endif +#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && defined QT_NO_DIRECTFB_IMAGEPROVIDER +#error QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE requires QT_DIRECTFB_IMAGEPROVIDER to be defined +#endif #define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERION << 8) | DIRECTFB_MICRO_VERSION) @@ -194,6 +200,9 @@ public: #endif static uchar *lockSurface(IDirectFBSurface *surface, uint flags, int *bpl = 0); +#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE + void setDirectFBImageProvider(IDirectFBImageProvider *provider); +#endif private: QDirectFBScreenPrivate *d_ptr; }; -- cgit v0.12