[directfb] Introduce the QDirectFBPointer from QWS/gfxdrivers
Introduce QDirectFBPointer and use it throughout the code to fix various resource leaks in the DirectFB backend. Fix the surface ownership of the IDirectFBSurface in the Blittable/BackingStore code. Change-Id: I0d4572eaab80b3558e644f26d76222461bf37bbb Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>bb10
parent
405894fc39
commit
500dc2a6f8
|
|
@ -50,19 +50,19 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDirectFbBackingStore::QDirectFbBackingStore(QWindow *window)
|
||||
: QPlatformBackingStore(window), m_pixmap(0), m_pmdata(0), m_dfbSurface(0)
|
||||
: QPlatformBackingStore(window), m_pixmap(0), m_pmdata(0)
|
||||
{
|
||||
|
||||
IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
|
||||
QDirectFBPointer<IDirectFBDisplayLayer> layer(QDirectFbConvenience::dfbDisplayLayer());
|
||||
|
||||
DFBWindowID id(window->winId());
|
||||
IDirectFBWindow *dfbWindow;
|
||||
QDirectFBPointer<IDirectFBWindow> dfbWindow;
|
||||
|
||||
layer->GetWindow(layer,id,&dfbWindow);
|
||||
layer->GetWindow(layer.data(), id, dfbWindow.outPtr());
|
||||
|
||||
dfbWindow->GetSurface(dfbWindow,&m_dfbSurface);
|
||||
dfbWindow->GetSurface(dfbWindow.data(), m_dfbSurface.outPtr());
|
||||
//WRONGSIZE
|
||||
QDirectFbBlitter *blitter = new QDirectFbBlitter(window->size(), m_dfbSurface);
|
||||
QDirectFbBlitter *blitter = new QDirectFbBlitter(window->size(), m_dfbSurface.data());
|
||||
m_pmdata = new QDirectFbBlitterPlatformPixmap;
|
||||
m_pmdata->setBlittable(blitter);
|
||||
m_pixmap.reset(new QPixmap(m_pmdata));
|
||||
|
|
@ -81,15 +81,13 @@ void QDirectFbBackingStore::flush(QWindow *, const QRegion ®ion, const QPoint
|
|||
for (int i = 0 ; i < rects.size(); i++) {
|
||||
const QRect rect = rects.at(i);
|
||||
DFBRegion dfbReg = { rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y()};
|
||||
m_dfbSurface->Flip(m_dfbSurface, &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC));
|
||||
m_dfbSurface->Flip(m_dfbSurface.data(), &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC));
|
||||
}
|
||||
}
|
||||
|
||||
void QDirectFbBackingStore::resize(const QSize &size, const QRegion& reg)
|
||||
{
|
||||
//Have to add 1 ref ass it will be removed by deleting the old blitter in setBlittable
|
||||
m_dfbSurface->AddRef(m_dfbSurface);
|
||||
QDirectFbBlitter *blitter = new QDirectFbBlitter(size,m_dfbSurface);
|
||||
QDirectFbBlitter *blitter = new QDirectFbBlitter(size, m_dfbSurface.data());
|
||||
m_pmdata->setBlittable(blitter);
|
||||
}
|
||||
|
||||
|
|
@ -107,14 +105,14 @@ bool QDirectFbBackingStore::scroll(const QRegion &area, int dx, int dy)
|
|||
|
||||
if (!m_dfbSurface || area.isEmpty())
|
||||
return false;
|
||||
m_dfbSurface->SetBlittingFlags(m_dfbSurface, DSBLIT_NOFX);
|
||||
m_dfbSurface->SetBlittingFlags(m_dfbSurface.data(), DSBLIT_NOFX);
|
||||
if (area.rectCount() == 1) {
|
||||
scrollSurface(m_dfbSurface, area.boundingRect(), dx, dy);
|
||||
scrollSurface(m_dfbSurface.data(), area.boundingRect(), dx, dy);
|
||||
} else {
|
||||
const QVector<QRect> rects = area.rects();
|
||||
const int n = rects.size();
|
||||
for (int i=0; i<n; ++i) {
|
||||
scrollSurface(m_dfbSurface, rects.at(i), dx, dy);
|
||||
scrollSurface(m_dfbSurface.data(), rects.at(i), dx, dy);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
#include <directfb.h>
|
||||
|
||||
#include "qdirectfbconvenience.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QDirectFbBackingStore : public QPlatformBackingStore
|
||||
|
|
@ -67,7 +69,7 @@ private:
|
|||
|
||||
QScopedPointer<QPixmap> m_pixmap;
|
||||
QBlittablePlatformPixmap *m_pmdata;
|
||||
IDirectFBSurface *m_dfbSurface;
|
||||
QDirectFBPointer<IDirectFBSurface> m_dfbSurface;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -53,8 +53,9 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, IDirectFBSurface *surface)
|
|||
|QBlittable::SourcePixmapCapability
|
||||
|QBlittable::SourceOverPixmapCapability
|
||||
|QBlittable::SourceOverScaledPixmapCapability))
|
||||
, m_surface(surface)
|
||||
{
|
||||
m_surface = surface;
|
||||
m_surface->AddRef(m_surface.data());
|
||||
}
|
||||
|
||||
QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, bool alpha)
|
||||
|
|
@ -79,25 +80,24 @@ QDirectFbBlitter::QDirectFbBlitter(const QSize &rect, bool alpha)
|
|||
|
||||
|
||||
IDirectFB *dfb = QDirectFbConvenience::dfbInterface();
|
||||
dfb->CreateSurface(dfb , &surfaceDesc, &m_surface);
|
||||
m_surface->Clear(m_surface, 0, 0, 0, 0);
|
||||
dfb->CreateSurface(dfb , &surfaceDesc, m_surface.outPtr());
|
||||
m_surface->Clear(m_surface.data(), 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
QDirectFbBlitter::~QDirectFbBlitter()
|
||||
{
|
||||
unlock();
|
||||
m_surface->Release(m_surface);
|
||||
}
|
||||
|
||||
void QDirectFbBlitter::fillRect(const QRectF &rect, const QColor &color)
|
||||
{
|
||||
m_surface->SetColor(m_surface, color.red(), color.green(), color.blue(), color.alpha());
|
||||
m_surface->SetColor(m_surface.data(), color.red(), color.green(), color.blue(), color.alpha());
|
||||
// When the blitter api supports non opaque blits, also remember to change
|
||||
// qpixmap_blitter.cpp::fill
|
||||
// DFBSurfaceDrawingFlags drawingFlags = color.alpha() ? DSDRAW_BLEND : DSDRAW_NOFX;
|
||||
// m_surface->SetDrawingFlags(m_surface, drawingFlags);
|
||||
m_surface->SetDrawingFlags(m_surface, DSDRAW_NOFX);
|
||||
m_surface->FillRectangle(m_surface, rect.x(), rect.y(),
|
||||
m_surface->SetDrawingFlags(m_surface.data(), DSDRAW_NOFX);
|
||||
m_surface->FillRectangle(m_surface.data(), rect.x(), rect.y(),
|
||||
rect.width(), rect.height());
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con
|
|||
QDirectFbBlitter *dfbBlitter = static_cast<QDirectFbBlitter *>(blitPm->blittable());
|
||||
dfbBlitter->unlock();
|
||||
|
||||
IDirectFBSurface *s = dfbBlitter->m_surface;
|
||||
IDirectFBSurface *s = dfbBlitter->m_surface.data();
|
||||
|
||||
DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX;
|
||||
DFBSurfacePorterDuffRule porterDuff = DSPD_SRC;
|
||||
|
|
@ -119,18 +119,18 @@ void QDirectFbBlitter::drawPixmap(const QRectF &rect, const QPixmap &pixmap, con
|
|||
porterDuff = DSPD_SRC_OVER;
|
||||
}
|
||||
|
||||
m_surface->SetBlittingFlags(m_surface, DFBSurfaceBlittingFlags(blittingFlags));
|
||||
m_surface->SetPorterDuff(m_surface,porterDuff);
|
||||
m_surface->SetDstBlendFunction(m_surface,DSBF_INVSRCALPHA);
|
||||
m_surface->SetBlittingFlags(m_surface.data(), DFBSurfaceBlittingFlags(blittingFlags));
|
||||
m_surface->SetPorterDuff(m_surface.data(), porterDuff);
|
||||
m_surface->SetDstBlendFunction(m_surface.data(), DSBF_INVSRCALPHA);
|
||||
|
||||
const DFBRectangle sRect = { srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height() };
|
||||
|
||||
DFBResult result;
|
||||
if (rect.width() == srcRect.width() && rect.height() == srcRect.height())
|
||||
result = m_surface->Blit(m_surface, s, &sRect, rect.x(), rect.y());
|
||||
result = m_surface->Blit(m_surface.data(), s, &sRect, rect.x(), rect.y());
|
||||
else {
|
||||
const DFBRectangle dRect = { rect.x(), rect.y(), rect.width(), rect.height() };
|
||||
result = m_surface->StretchBlit(m_surface, s, &sRect, &dRect);
|
||||
result = m_surface->StretchBlit(m_surface.data(), s, &sRect, &dRect);
|
||||
}
|
||||
if (result != DFB_OK)
|
||||
DirectFBError("QDirectFBBlitter::drawPixmap()", result);
|
||||
|
|
@ -143,15 +143,15 @@ QImage *QDirectFbBlitter::doLock()
|
|||
|
||||
void *mem;
|
||||
int bpl;
|
||||
const DFBResult result = m_surface->Lock(m_surface, DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast<void**>(&mem), &bpl);
|
||||
const DFBResult result = m_surface->Lock(m_surface.data(), DFBSurfaceLockFlags(DSLF_WRITE|DSLF_READ), static_cast<void**>(&mem), &bpl);
|
||||
if (result == DFB_OK) {
|
||||
DFBSurfacePixelFormat dfbFormat;
|
||||
DFBSurfaceCapabilities dfbCaps;
|
||||
m_surface->GetPixelFormat(m_surface,&dfbFormat);
|
||||
m_surface->GetCapabilities(m_surface,&dfbCaps);
|
||||
m_surface->GetPixelFormat(m_surface.data(), &dfbFormat);
|
||||
m_surface->GetCapabilities(m_surface.data(), &dfbCaps);
|
||||
QImage::Format format = QDirectFbConvenience::imageFormatFromSurfaceFormat(dfbFormat, dfbCaps);
|
||||
int w, h;
|
||||
m_surface->GetSize(m_surface,&w,&h);
|
||||
m_surface->GetSize(m_surface.data(), &w, &h);
|
||||
m_image = QImage(static_cast<uchar *>(mem),w,h,bpl,format);
|
||||
} else {
|
||||
DirectFBError("Failed to lock image", result);
|
||||
|
|
@ -162,5 +162,5 @@ QImage *QDirectFbBlitter::doLock()
|
|||
|
||||
void QDirectFbBlitter::doUnlock()
|
||||
{
|
||||
m_surface->Unlock(m_surface);
|
||||
m_surface->Unlock(m_surface.data());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ protected:
|
|||
virtual QImage *doLock();
|
||||
virtual void doUnlock();
|
||||
|
||||
IDirectFBSurface *m_surface;
|
||||
QDirectFBPointer<IDirectFBSurface> m_surface;
|
||||
QImage m_image;
|
||||
|
||||
friend class QDirectFbConvenience;
|
||||
|
|
|
|||
|
|
@ -106,13 +106,17 @@ int QDirectFbConvenience::colorDepthForSurface(const DFBSurfacePixelFormat forma
|
|||
return ((0x1f << 7) & format) >> 7;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is borrowing the reference of the QDirectFbBlitter. You may not store this
|
||||
* pointer as a class member but must only use it locally.
|
||||
*/
|
||||
IDirectFBSurface *QDirectFbConvenience::dfbSurfaceForPlatformPixmap(QPlatformPixmap *handle)
|
||||
{
|
||||
QBlittablePlatformPixmap *blittablePmData = static_cast<QBlittablePlatformPixmap *>(handle);
|
||||
if (blittablePmData) {
|
||||
QBlittable *blittable = blittablePmData->blittable();
|
||||
QDirectFbBlitter *dfbBlitter = static_cast<QDirectFbBlitter *>(blittable);
|
||||
return dfbBlitter->m_surface;
|
||||
return dfbBlitter->m_surface.data();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,4 +81,29 @@ private:
|
|||
friend class QDirectFbIntegration;
|
||||
};
|
||||
|
||||
template <typename T> struct QDirectFBInterfaceCleanupHandler
|
||||
{
|
||||
static void cleanup(T *t)
|
||||
{
|
||||
if (!t)
|
||||
return;
|
||||
t->Release(t);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class QDirectFBPointer : public QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >
|
||||
{
|
||||
public:
|
||||
QDirectFBPointer(T *t = 0)
|
||||
: QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >(t)
|
||||
{}
|
||||
|
||||
T** outPtr()
|
||||
{
|
||||
this->reset(0);
|
||||
return &this->d;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // QDIRECTFBCONVENIENCE_H
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
QDirectFBCursor::QDirectFBCursor(QPlatformScreen *screen)
|
||||
: QPlatformCursor(screen)
|
||||
{
|
||||
QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, &m_layer);
|
||||
QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY, m_layer.outPtr());
|
||||
m_image.reset(new QPlatformCursorImage(0, 0, 0, 0, 0, 0));
|
||||
}
|
||||
|
||||
|
|
@ -69,11 +69,11 @@ void QDirectFBCursor::changeCursor(QCursor *cursor, QWindow *)
|
|||
map = cursor->pixmap();
|
||||
}
|
||||
|
||||
IDirectFBSurface *surface = QDirectFbConvenience::dfbSurfaceForPlatformPixmap(map.handle());
|
||||
IDirectFBSurface* surface(QDirectFbConvenience::dfbSurfaceForPlatformPixmap(map.handle()));
|
||||
|
||||
if (m_layer->SetCooperativeLevel(m_layer, DLSCL_ADMINISTRATIVE) != DFB_OK) {
|
||||
if (m_layer->SetCooperativeLevel(m_layer.data(), DLSCL_ADMINISTRATIVE) != DFB_OK) {
|
||||
return;
|
||||
}
|
||||
m_layer->SetCursorShape( m_layer, surface, xSpot, ySpot);
|
||||
m_layer->SetCooperativeLevel(m_layer, DLSCL_SHARED);
|
||||
m_layer->SetCursorShape(m_layer.data(), surface, xSpot, ySpot);
|
||||
m_layer->SetCooperativeLevel(m_layer.data(), DLSCL_SHARED);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@
|
|||
|
||||
#include <QPlatformCursor>
|
||||
#include <directfb.h>
|
||||
|
||||
#include "qdirectfbconvenience.h"
|
||||
|
||||
class QDirectFbScreen;
|
||||
class QDirectFbBlitter;
|
||||
|
||||
|
|
@ -54,7 +57,7 @@ public:
|
|||
void changeCursor(QCursor *cursor, QWindow *window);
|
||||
|
||||
private:
|
||||
IDirectFBDisplayLayer *m_layer;
|
||||
QDirectFBPointer<IDirectFBDisplayLayer> m_layer;
|
||||
QScopedPointer<QPlatformCursorImage> m_image;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -54,17 +54,17 @@ QDirectFbInput::QDirectFbInput()
|
|||
: m_dfbInterface(QDirectFbConvenience::dfbInterface())
|
||||
, m_shouldStop(false)
|
||||
{
|
||||
DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface,&m_eventBuffer);
|
||||
DFBResult ok = m_dfbInterface->CreateEventBuffer(m_dfbInterface, m_eventBuffer.outPtr());
|
||||
if (ok != DFB_OK)
|
||||
DirectFBError("Failed to initialise eventbuffer", ok);
|
||||
|
||||
m_dfbInterface->GetDisplayLayer(m_dfbInterface,DLID_PRIMARY, &m_dfbDisplayLayer);
|
||||
m_dfbInterface->GetDisplayLayer(m_dfbInterface, DLID_PRIMARY, m_dfbDisplayLayer.outPtr());
|
||||
}
|
||||
|
||||
void QDirectFbInput::run()
|
||||
{
|
||||
while (!m_shouldStop) {
|
||||
if (m_eventBuffer->WaitForEvent(m_eventBuffer) == DFB_OK)
|
||||
if (m_eventBuffer->WaitForEvent(m_eventBuffer.data()) == DFB_OK)
|
||||
handleEvents();
|
||||
}
|
||||
}
|
||||
|
|
@ -72,33 +72,33 @@ void QDirectFbInput::run()
|
|||
void QDirectFbInput::stopInputEventLoop()
|
||||
{
|
||||
m_shouldStop = true;
|
||||
m_eventBuffer->WakeUp(m_eventBuffer);
|
||||
m_eventBuffer->WakeUp(m_eventBuffer.data());
|
||||
}
|
||||
|
||||
void QDirectFbInput::addWindow(DFBWindowID id, QWindow *qt_window)
|
||||
{
|
||||
m_tlwMap.insert(id,qt_window);
|
||||
IDirectFBWindow *window;
|
||||
m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,id,&window);
|
||||
QDirectFBPointer<IDirectFBWindow> window;
|
||||
m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer.data(), id, window.outPtr());
|
||||
|
||||
window->AttachEventBuffer(window,m_eventBuffer);
|
||||
window->AttachEventBuffer(window.data(), m_eventBuffer.data());
|
||||
}
|
||||
|
||||
void QDirectFbInput::removeWindow(WId wId)
|
||||
{
|
||||
IDirectFBWindow *window;
|
||||
m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,wId, &window);
|
||||
QDirectFBPointer<IDirectFBWindow> window;
|
||||
m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer.data(), wId, window.outPtr());
|
||||
|
||||
window->DetachEventBuffer(window,m_eventBuffer);
|
||||
window->DetachEventBuffer(window.data(), m_eventBuffer.data());
|
||||
m_tlwMap.remove(wId);
|
||||
}
|
||||
|
||||
void QDirectFbInput::handleEvents()
|
||||
{
|
||||
DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
|
||||
DFBResult hasEvent = m_eventBuffer->HasEvent(m_eventBuffer.data());
|
||||
while(hasEvent == DFB_OK){
|
||||
DFBEvent event;
|
||||
DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer,&event);
|
||||
DFBResult ok = m_eventBuffer->GetEvent(m_eventBuffer.data(), &event);
|
||||
if (ok != DFB_OK)
|
||||
DirectFBError("Failed to get event",ok);
|
||||
if (event.clazz == DFEC_WINDOW) {
|
||||
|
|
@ -124,7 +124,7 @@ void QDirectFbInput::handleEvents()
|
|||
|
||||
}
|
||||
|
||||
hasEvent = m_eventBuffer->HasEvent(m_eventBuffer);
|
||||
hasEvent = m_eventBuffer->HasEvent(m_eventBuffer.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -134,16 +134,16 @@ void QDirectFbInput::handleMouseEvents(const DFBEvent &event)
|
|||
QPoint globalPos = globalPoint(event);
|
||||
Qt::MouseButtons buttons = QDirectFbConvenience::mouseButtons(event.window.buttons);
|
||||
|
||||
IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
|
||||
IDirectFBWindow *window;
|
||||
layer->GetWindow(layer,event.window.window_id,&window);
|
||||
QDirectFBPointer<IDirectFBDisplayLayer> layer(QDirectFbConvenience::dfbDisplayLayer());
|
||||
QDirectFBPointer<IDirectFBWindow> window;
|
||||
layer->GetWindow(layer.data(), event.window.window_id, window.outPtr());
|
||||
|
||||
long timestamp = (event.window.timestamp.tv_sec*1000) + (event.window.timestamp.tv_usec/1000);
|
||||
|
||||
if (event.window.type == DWET_BUTTONDOWN) {
|
||||
window->GrabPointer(window);
|
||||
window->GrabPointer(window.data());
|
||||
} else if (event.window.type == DWET_BUTTONUP) {
|
||||
window->UngrabPointer(window);
|
||||
window->UngrabPointer(window.data());
|
||||
}
|
||||
QWindow *tlw = m_tlwMap.value(event.window.window_id);
|
||||
QWindowSystemInterface::handleMouseEvent(tlw, timestamp, p, globalPos, buttons);
|
||||
|
|
@ -192,10 +192,10 @@ void QDirectFbInput::handleEnterLeaveEvents(const DFBEvent &event)
|
|||
|
||||
inline QPoint QDirectFbInput::globalPoint(const DFBEvent &event) const
|
||||
{
|
||||
IDirectFBWindow *window;
|
||||
m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer,event.window.window_id,&window);
|
||||
QDirectFBPointer<IDirectFBWindow> window;
|
||||
m_dfbDisplayLayer->GetWindow(m_dfbDisplayLayer.data() , event.window.window_id, window.outPtr());
|
||||
int x,y;
|
||||
window->GetPosition(window,&x,&y);
|
||||
window->GetPosition(window.data(), &x, &y);
|
||||
return QPoint(event.window.cx +x, event.window.cy + y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
#include <QtGui/qwindowdefs.h>
|
||||
|
||||
#include <directfb.h>
|
||||
#include "qdirectfbconvenience.h"
|
||||
|
||||
class QDirectFbInput : public QThread
|
||||
{
|
||||
|
|
@ -74,8 +74,8 @@ private:
|
|||
|
||||
|
||||
IDirectFB *m_dfbInterface;
|
||||
IDirectFBDisplayLayer *m_dfbDisplayLayer;
|
||||
IDirectFBEventBuffer *m_eventBuffer; // XXX: TODO: FIXME: leaked!!! (but it is a singleton)
|
||||
QDirectFBPointer<IDirectFBDisplayLayer> m_dfbDisplayLayer;
|
||||
QDirectFBPointer<IDirectFBEventBuffer> m_eventBuffer;
|
||||
|
||||
bool m_shouldStop;
|
||||
QHash<DFBWindowID,QWindow *>m_tlwMap;
|
||||
|
|
|
|||
|
|
@ -61,12 +61,12 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
QDirectFbScreen::QDirectFbScreen(int display)
|
||||
: QPlatformScreen()
|
||||
, m_layer(QDirectFbConvenience::dfbDisplayLayer(display))
|
||||
{
|
||||
m_layer = QDirectFbConvenience::dfbDisplayLayer(display);
|
||||
m_layer->SetCooperativeLevel(m_layer,DLSCL_SHARED);
|
||||
m_layer->SetCooperativeLevel(m_layer.data(), DLSCL_SHARED);
|
||||
|
||||
DFBDisplayLayerConfig config;
|
||||
m_layer->GetConfiguration(m_layer, &config);
|
||||
m_layer->GetConfiguration(m_layer.data(), &config);
|
||||
|
||||
m_format = QDirectFbConvenience::imageFormatFromSurfaceFormat(config.pixelformat, config.surface_caps);
|
||||
m_geometry = QRect(0,0,config.width,config.height);
|
||||
|
|
@ -79,7 +79,8 @@ QDirectFbScreen::QDirectFbScreen(int display)
|
|||
}
|
||||
|
||||
QDirectFbIntegration::QDirectFbIntegration()
|
||||
: m_fontDb(new QGenericUnixFontDatabase())
|
||||
: m_dfb(QDirectFbConvenience::dfbInterface())
|
||||
, m_fontDb(new QGenericUnixFontDatabase())
|
||||
, m_eventDispatcher(createUnixEventDispatcher())
|
||||
{
|
||||
QGuiApplicationPrivate::instance()->setEventDispatcher(m_eventDispatcher);
|
||||
|
|
@ -101,10 +102,8 @@ QDirectFbIntegration::QDirectFbIntegration()
|
|||
delete[] argv[i];
|
||||
delete[] argv;
|
||||
|
||||
|
||||
|
||||
QDirectFbScreen *primaryScreen = new QDirectFbScreen(0);
|
||||
screenAdded(primaryScreen);
|
||||
m_primaryScreen.reset(new QDirectFbScreen(0));
|
||||
screenAdded(m_primaryScreen.data());
|
||||
|
||||
m_input.reset(new QDirectFbInput());
|
||||
m_input->start();
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ public:
|
|||
QImage::Format m_format;
|
||||
QSizeF m_physicalSize;
|
||||
|
||||
IDirectFBDisplayLayer *m_layer;
|
||||
QDirectFBPointer<IDirectFBDisplayLayer> m_layer;
|
||||
|
||||
private:
|
||||
QScopedPointer<QDirectFBCursor> m_cursor;
|
||||
|
|
@ -90,6 +90,8 @@ public:
|
|||
QPlatformFontDatabase *fontDatabase() const;
|
||||
|
||||
private:
|
||||
QDirectFBPointer<IDirectFB> m_dfb;
|
||||
QScopedPointer<QDirectFbScreen> m_primaryScreen;
|
||||
QScopedPointer<QDirectFbInput> m_input;
|
||||
QScopedPointer<QThread> m_inputRunner;
|
||||
QPlatformFontDatabase *m_fontDb;
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@
|
|||
QDirectFbWindow::QDirectFbWindow(QWindow *tlw, QDirectFbInput *inputhandler)
|
||||
: QPlatformWindow(tlw), m_inputHandler(inputhandler)
|
||||
{
|
||||
IDirectFBDisplayLayer *layer = QDirectFbConvenience::dfbDisplayLayer();
|
||||
QDirectFBPointer<IDirectFBDisplayLayer> layer(QDirectFbConvenience::dfbDisplayLayer());
|
||||
DFBDisplayLayerConfig layerConfig;
|
||||
layer->GetConfiguration(layer,&layerConfig);
|
||||
layer->GetConfiguration(layer.data(), &layerConfig);
|
||||
|
||||
DFBWindowDescription description;
|
||||
memset(&description,0,sizeof(DFBWindowDescription));
|
||||
|
|
@ -75,24 +75,24 @@ QDirectFbWindow::QDirectFbWindow(QWindow *tlw, QDirectFbInput *inputhandler)
|
|||
description.caps = DFBWindowCapabilities(DWCAPS_DOUBLEBUFFER|DWCAPS_ALPHACHANNEL);
|
||||
description.surface_caps = DSCAPS_PREMULTIPLIED;
|
||||
|
||||
DFBResult result = layer->CreateWindow(layer,&description,&m_dfbWindow);
|
||||
DFBResult result = layer->CreateWindow(layer.data(), &description, m_dfbWindow.outPtr());
|
||||
if (result != DFB_OK) {
|
||||
DirectFBError("QDirectFbGraphicsSystemScreen: failed to create window",result);
|
||||
}
|
||||
|
||||
m_dfbWindow->SetOpacity(m_dfbWindow,0xff);
|
||||
m_dfbWindow->SetOpacity(m_dfbWindow.data(), 0xff);
|
||||
|
||||
setVisible(window()->visible());
|
||||
|
||||
DFBWindowID id;
|
||||
m_dfbWindow->GetID(m_dfbWindow, &id);
|
||||
m_dfbWindow->GetID(m_dfbWindow.data(), &id);
|
||||
m_inputHandler->addWindow(id,tlw);
|
||||
}
|
||||
|
||||
QDirectFbWindow::~QDirectFbWindow()
|
||||
{
|
||||
m_inputHandler->removeWindow(winId());
|
||||
m_dfbWindow->Destroy(m_dfbWindow);
|
||||
m_dfbWindow->Destroy(m_dfbWindow.data());
|
||||
}
|
||||
|
||||
void QDirectFbWindow::setGeometry(const QRect &rect)
|
||||
|
|
@ -101,7 +101,7 @@ void QDirectFbWindow::setGeometry(const QRect &rect)
|
|||
|
||||
QPlatformWindow::setGeometry(rect);
|
||||
if (window()->visible()) {
|
||||
m_dfbWindow->SetBounds(m_dfbWindow, rect.x(),rect.y(),
|
||||
m_dfbWindow->SetBounds(m_dfbWindow.data(), rect.x(),rect.y(),
|
||||
rect.width(), rect.height());
|
||||
// ### TODO port, verify if this is needed
|
||||
#if 0
|
||||
|
|
@ -117,7 +117,7 @@ void QDirectFbWindow::setGeometry(const QRect &rect)
|
|||
void QDirectFbWindow::setOpacity(qreal level)
|
||||
{
|
||||
const quint8 windowOpacity = quint8(level * 0xff);
|
||||
m_dfbWindow->SetOpacity(m_dfbWindow,windowOpacity);
|
||||
m_dfbWindow->SetOpacity(m_dfbWindow.data(), windowOpacity);
|
||||
}
|
||||
|
||||
void QDirectFbWindow::setVisible(bool visible)
|
||||
|
|
@ -125,14 +125,14 @@ void QDirectFbWindow::setVisible(bool visible)
|
|||
if (visible) {
|
||||
int x = geometry().x();
|
||||
int y = geometry().y();
|
||||
m_dfbWindow->MoveTo(m_dfbWindow,x,y);
|
||||
m_dfbWindow->MoveTo(m_dfbWindow.data(), x, y);
|
||||
} else {
|
||||
IDirectFBDisplayLayer *displayLayer;
|
||||
QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(),DLID_PRIMARY,&displayLayer);
|
||||
QDirectFBPointer<IDirectFBDisplayLayer> displayLayer;
|
||||
QDirectFbConvenience::dfbInterface()->GetDisplayLayer(QDirectFbConvenience::dfbInterface(), DLID_PRIMARY, displayLayer.outPtr());
|
||||
|
||||
DFBDisplayLayerConfig config;
|
||||
displayLayer->GetConfiguration(displayLayer,&config);
|
||||
m_dfbWindow->MoveTo(m_dfbWindow,config.width+1,config.height + 1);
|
||||
displayLayer->GetConfiguration(displayLayer.data(), &config);
|
||||
m_dfbWindow->MoveTo(m_dfbWindow.data(), config. width + 1, config.height + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,31 +141,31 @@ Qt::WindowFlags QDirectFbWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||
switch (flags & Qt::WindowType_Mask) {
|
||||
case Qt::ToolTip: {
|
||||
DFBWindowOptions options;
|
||||
m_dfbWindow->GetOptions(m_dfbWindow,&options);
|
||||
m_dfbWindow->GetOptions(m_dfbWindow.data(), &options);
|
||||
options = DFBWindowOptions(options | DWOP_GHOST);
|
||||
m_dfbWindow->SetOptions(m_dfbWindow,options);
|
||||
m_dfbWindow->SetOptions(m_dfbWindow.data(), options);
|
||||
break; }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_dfbWindow->SetStackingClass(m_dfbWindow, flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE);
|
||||
m_dfbWindow->SetStackingClass(m_dfbWindow.data(), flags & Qt::WindowStaysOnTopHint ? DWSC_UPPER : DWSC_MIDDLE);
|
||||
return flags;
|
||||
}
|
||||
|
||||
void QDirectFbWindow::raise()
|
||||
{
|
||||
m_dfbWindow->RaiseToTop(m_dfbWindow);
|
||||
m_dfbWindow->RaiseToTop(m_dfbWindow.data());
|
||||
}
|
||||
|
||||
void QDirectFbWindow::lower()
|
||||
{
|
||||
m_dfbWindow->LowerToBottom(m_dfbWindow);
|
||||
m_dfbWindow->LowerToBottom(m_dfbWindow.data());
|
||||
}
|
||||
|
||||
WId QDirectFbWindow::winId() const
|
||||
{
|
||||
DFBWindowID id;
|
||||
m_dfbWindow->GetID(m_dfbWindow, &id);
|
||||
m_dfbWindow->GetID(m_dfbWindow.data(), &id);
|
||||
return WId(id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public:
|
|||
WId winId() const;
|
||||
|
||||
private:
|
||||
IDirectFBWindow *m_dfbWindow;
|
||||
QDirectFBPointer<IDirectFBWindow> m_dfbWindow;
|
||||
QDirectFbInput *m_inputHandler;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue