summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-08-03 11:33:34 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-08-03 11:33:34 (GMT)
commit5e05bafa229b645bf30a90975bfc57e458e081e5 (patch)
tree54606401f955891574cbcc589ae2558cb2a5b748 /src/plugins
parent128717b171f01c82e5f0fb83f5923d4f7b9cfc10 (diff)
parent463df7e4a6dc7c11716e27ca5de9ebeb61940990 (diff)
downloadQt-5e05bafa229b645bf30a90975bfc57e458e081e5.zip
Qt-5e05bafa229b645bf30a90975bfc57e458e081e5.tar.gz
Qt-5e05bafa229b645bf30a90975bfc57e458e081e5.tar.bz2
Merge branch '4.5'
Conflicts: src/corelib/tools/qsharedpointer.cpp src/corelib/tools/qsharedpointer_impl.h src/gui/dialogs/qcolordialog.cpp src/gui/painting/qwindowsurface_raster.cpp src/network/access/qnetworkaccessmanager.cpp tests/auto/qsharedpointer/externaltests.cpp
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp29
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp13
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h21
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp288
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp13
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h3
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp21
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h3
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp20
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h7
10 files changed, 262 insertions, 156 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
index b5376b1..13c4053 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
@@ -77,13 +77,15 @@ private:
QSocketNotifier *keyboardNotifier;
DFBEvent event;
int bytesRead;
-
+ int lastUnicode, lastKeycode;
+ Qt::KeyboardModifiers lastModifiers;
private Q_SLOTS:
void readKeyboardData();
};
QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *h)
- : handler(h), eventBuffer(0)
+ : handler(h), eventBuffer(0), keyboardNotifier(0), bytesRead(0),
+ lastUnicode(0), lastKeycode(0), lastModifiers(0)
{
Q_ASSERT(qt_screen);
@@ -114,8 +116,6 @@ QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboa
::fcntl(fd, F_SETFL, flags | O_NONBLOCK);
memset(&event, 0, sizeof(event));
- bytesRead = 0;
-
keyboardNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
connect(keyboardNotifier, SIGNAL(activated(int)),
@@ -213,8 +213,27 @@ void QDirectFBKeyboardHandlerPrivate::readKeyboardData()
unicode = symbol;
if (unicode != -1 || keycode != 0) {
+ bool autoRepeat = false;
+ if (press) {
+ if (unicode == lastUnicode && keycode == lastKeycode && modifiers == lastModifiers) {
+ autoRepeat = true;
+ } else {
+ lastUnicode = unicode;
+ lastKeycode = keycode;
+ lastModifiers = modifiers;
+ }
+ } else {
+ lastUnicode = lastKeycode = -1;
+ lastModifiers = 0;
+ }
+ if (autoRepeat) {
+ handler->processKeyEvent(unicode, keycode,
+ modifiers, false, autoRepeat);
+
+ }
+
handler->processKeyEvent(unicode, keycode,
- modifiers, press, false);
+ modifiers, press, autoRepeat);
}
}
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
index 86e92f7..2075799 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
@@ -43,10 +43,17 @@
#include "qdirectfbscreen.h"
#include "qdirectfbpaintdevice.h"
+#include "qdirectfbpaintengine.h"
+
+QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr)
+ : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr),
+ lock(DFBSurfaceLockFlags(0)), mem(0), engine(0)
+{}
QDirectFBPaintDevice::~QDirectFBPaintDevice()
{
delete lockedImage;
+ delete engine;
}
@@ -164,4 +171,10 @@ int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
}
}
+QPaintEngine *QDirectFBPaintDevice::paintEngine() const
+{
+ return engine;
+}
+
#endif
+
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
index 248a15b..c4aeb70 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
@@ -51,7 +51,8 @@ QT_BEGIN_HEADER
QT_MODULE(Gui)
// Inherited by both window surface and pixmap
- class QDirectFBPaintDevice : public QCustomRasterPaintDevice
+class QDirectFBPaintEngine;
+class QDirectFBPaintDevice : public QCustomRasterPaintDevice
{
public:
~QDirectFBPaintDevice();
@@ -62,19 +63,16 @@ public:
void unlockDirectFB();
// Reimplemented from QCustomRasterPaintDevice:
- void* memory() const;
+ void *memory() const;
QImage::Format format() const;
int bytesPerLine() const;
QSize size() const;
int metric(QPaintDevice::PaintDeviceMetric metric) const;
DFBSurfaceLockFlags lockFlags() const { return lock; }
-protected:
- // Shouldn't create QDirectFBPaintDevice by itself but only sub-class it:
- QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance())
- : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr),
- lock(DFBSurfaceLockFlags(0)), mem(0)
- {}
+ QPaintEngine *paintEngine() const;
+protected:
+ QDirectFBPaintDevice(QDirectFBScreen *scr);
inline int dotsPerMeterX() const
{
return (screen->deviceWidth() * 1000) / screen->physicalWidth();
@@ -83,16 +81,17 @@ protected:
{
return (screen->deviceHeight() * 1000) / screen->physicalHeight();
}
-
+protected:
IDirectFBSurface *dfbSurface;
QImage *lockedImage;
QDirectFBScreen *screen;
int bpl;
DFBSurfaceLockFlags lock;
uchar *mem;
+ QDirectFBPaintEngine *engine;
private:
- Q_DISABLE_COPY(QDirectFBPaintDevice)
- };
+ Q_DISABLE_COPY(QDirectFBPaintDevice);
+};
QT_END_HEADER
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 2ed890b..58c8a58 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -60,10 +60,25 @@ class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate
{
public:
enum TransformationTypeFlags {
- NegativeScale = 0x100,
- RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject),
- BlitUnsupported = (NegativeScale|RectsUnsupported)
+ Matrix_NegativeScale = 0x100,
+ Matrix_RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject),
+ Matrix_BlitsUnsupported = (Matrix_NegativeScale|Matrix_RectsUnsupported)
};
+
+ enum CompositionModeStatus {
+ PorterDuff_None = 0x0,
+ PorterDuff_SupportedBlits = 0x1,
+ PorterDuff_SupportedPrimitives = 0x2
+ };
+
+ enum ClipType {
+ ClipUnset,
+ NoClip,
+ RectClip,
+ RegionClip,
+ ComplexClip
+ };
+
QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p);
~QDirectFBPaintEnginePrivate();
@@ -77,9 +92,6 @@ public:
inline void lock();
inline void unlock();
- inline bool dfbCanHandleClip(const QRect &rect) const;
- inline bool dfbCanHandleClip(const QRectF &rect) const;
- inline bool dfbCanHandleClip() const;
inline bool isSimpleBrush(const QBrush &brush) const;
void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos);
@@ -101,19 +113,16 @@ private:
bool antialiased;
bool simplePen;
- uint transformationType; // this is QTransform::type() + NegativeScale if qMin(transform.m11(), transform.m22()) < 0
+ uint transformationType; // this is QTransform::type() + Matrix_NegativeScale if qMin(transform.m11(), transform.m22()) < 0
SurfaceCache *surfaceCache;
-
IDirectFB *fb;
-
quint8 opacity;
bool dirtyClip;
- bool dfbHandledClip;
- bool ignoreSystemClip;
+ ClipType clipType;
QDirectFBPaintDevice *dfbDevice;
- bool unsupportedCompositionMode;
+ uint compositionModeStatus;
QDirectFBPaintEngine *q;
QRect currentClip;
@@ -162,8 +171,12 @@ enum PaintOperation {
#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS
template <typename device, typename T1, typename T2, typename T3>
-static void rasterFallbackWarn(const char *msg, const char *, const device *, uint, bool, bool, bool,
- const char *, const T1 &, const char *, const T2 &, const char *, const T3 &);
+static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
+ uint transformationType, bool simplePen,
+ uint clipType, uint compositionModeStatus,
+ const char *nameOne, const T1 &one,
+ const char *nameTwo, const T2 &two,
+ const char *nameThree, const T3 &three);
#endif
#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS
@@ -173,8 +186,8 @@ static void rasterFallbackWarn(const char *msg, const char *, const device *, ui
__FUNCTION__, state()->painter->device(), \
d_func()->transformationType, \
d_func()->simplePen, \
- d_func()->dfbCanHandleClip(), \
- d_func()->unsupportedCompositionMode, \
+ d_func()->clipType, \
+ d_func()->compositionModeStatus, \
#one, one, #two, two, #three, three); \
if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \
return;
@@ -189,14 +202,13 @@ static void rasterFallbackWarn(const char *msg, const char *, const device *, ui
__FUNCTION__, state()->painter->device(), \
d_func()->transformationType, \
d_func()->simplePen, \
- d_func()->dfbCanHandleClip(), \
- d_func()->unsupportedCompositionMode, \
+ d_func()->clipType, \
+ d_func()->compositionModeStatus, \
#one, one, #two, two, #three, three);
#else
#define RASTERFALLBACK(op, one, two, three)
#endif
-
template <class T>
static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface);
template <class T>
@@ -204,6 +216,36 @@ static inline void fillRects(const T *rects, int n, const QTransform &transform,
template <class T>
static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface);
+#define CLIPPED_PAINT(operation) { \
+ DFBRegion clipRegion; \
+ switch (d->clipType) { \
+ case QDirectFBPaintEnginePrivate::NoClip: \
+ case QDirectFBPaintEnginePrivate::RectClip: \
+ operation; \
+ break; \
+ case QDirectFBPaintEnginePrivate::RegionClip: { \
+ Q_ASSERT(d->clip()); \
+ const QVector<QRect> cr = d->clip()->clipRegion.rects(); \
+ const int size = cr.size(); \
+ for (int i=0; i<size; ++i) { \
+ d->currentClip = cr.at(i); \
+ clipRegion.x1 = d->currentClip.x(); \
+ clipRegion.y1 = d->currentClip.y(); \
+ clipRegion.x2 = d->currentClip.right(); \
+ clipRegion.y2 = d->currentClip.bottom(); \
+ d->surface->SetClip(d->surface, &clipRegion); \
+ operation; \
+ } \
+ d->dirtyClip = true; \
+ break; } \
+ case QDirectFBPaintEnginePrivate::ComplexClip: \
+ case QDirectFBPaintEnginePrivate::ClipUnset: \
+ qFatal("CLIPPED_PAINT internal error %d", d->clipType); \
+ break; \
+ } \
+ }
+
+
QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device)
: QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device)
{
@@ -234,7 +276,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device)
}
d->prepare(d->dfbDevice);
-
+ d->setCompositionMode(state()->composition_mode);
return QRasterPaintEngine::begin(device);
}
@@ -324,58 +366,60 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount)
{
Q_D(QDirectFBPaintEngine);
- d->updateClip();
+ const QPen &pen = state()->pen;
const QBrush &brush = state()->brush;
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported)
+ if (brush == Qt::NoBrush && pen == Qt::NoPen)
+ return;
+
+ d->updateClip();
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
|| !d->simplePen
- || !d->dfbCanHandleClip()
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
|| !d->isSimpleBrush(brush)) {
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
return;
}
-
d->unlock();
-
if (brush != Qt::NoBrush) {
d->setDFBColor(brush.color());
- ::fillRects<QRect>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::fillRects<QRect>(rects, rectCount, state()->matrix, d->surface));
}
- const QPen &pen = state()->pen;
if (pen != Qt::NoPen) {
d->setDFBColor(pen.color());
- ::drawRects<QRect>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawRects<QRect>(rects, rectCount, state()->matrix, d->surface));
}
}
void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount)
{
Q_D(QDirectFBPaintEngine);
- d->updateClip();
+ const QPen &pen = state()->pen;
const QBrush &brush = state()->brush;
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported)
+ if (brush == Qt::NoBrush && pen == Qt::NoPen)
+ return;
+
+ d->updateClip();
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
|| !d->simplePen
- || !d->dfbCanHandleClip()
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
|| !d->isSimpleBrush(brush)) {
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawRects(rects, rectCount);
return;
}
-
d->unlock();
-
if (brush != Qt::NoBrush) {
d->setDFBColor(brush.color());
- ::fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface));
}
- const QPen &pen = state()->pen;
if (pen != Qt::NoPen) {
d->setDFBColor(pen.color());
- ::drawRects<QRectF>(rects, rectCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawRects<QRectF>(rects, rectCount, state()->matrix, d->surface));
}
}
@@ -383,7 +427,10 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) {
+
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || !d->simplePen
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
@@ -394,7 +441,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
if (pen != Qt::NoPen) {
d->unlock();
d->setDFBColor(pen.color());
- ::drawLines<QLine>(lines, lineCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawLines<QLine>(lines, lineCount, state()->matrix, d->surface));
}
}
@@ -402,7 +449,10 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
{
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (d->unsupportedCompositionMode || !d->simplePen || !d->dfbCanHandleClip()) {
+
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || !d->simplePen
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
d->lock();
QRasterPaintEngine::drawLines(lines, lineCount);
@@ -413,7 +463,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
if (pen != Qt::NoPen) {
d->unlock();
d->setDFBColor(pen.color());
- ::drawLines<QLineF>(lines, lineCount, state()->matrix, d->surface);
+ CLIPPED_PAINT(::drawLines<QLineF>(lines, lineCount, state()->matrix, d->surface));
}
}
@@ -443,9 +493,9 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
d->updateClip();
#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported)
- || !d->dfbCanHandleClip(r)
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
#ifndef QT_DIRECTFB_IMAGECACHE
|| QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN
#elif defined QT_NO_DIRECTFB_PREALLOCATED
@@ -464,7 +514,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
bool release;
IDirectFBSurface *imgSurface = d->getSurface(image, &release);
d->prepareForBlit(QDirectFBScreen::hasAlpha(imgSurface));
- d->blit(r, imgSurface, sr);
+ CLIPPED_PAINT(d->blit(r, imgSurface, sr));
if (release) {
#if (Q_DIRECTFB_VERSION >= 0x010000)
d->surface->ReleaseSource(d->surface);
@@ -483,15 +533,15 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
const QRectF &sr)
{
Q_D(QDirectFBPaintEngine);
- d->updateClip();
+ d->updateClip();
if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
d->lock();
QRasterPaintEngine::drawPixmap(r, pixmap, sr);
- } else if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported)
- || !d->dfbCanHandleClip(r)) {
+ } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ);
d->lock();
@@ -504,7 +554,8 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
dfbData->unlockDirectFB();
IDirectFBSurface *s = dfbData->directFBSurface();
- d->blit(r, s, sr);
+
+ CLIPPED_PAINT(d->blit(r, s, sr));
}
}
@@ -523,9 +574,9 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r,
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
d->lock();
QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset);
- } else if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported)
- || !d->dfbCanHandleClip(r)) {
+ } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
const QImage *img = static_cast<QDirectFBPixmapData*>(pixmap.pixmapData())->buffer(DSLF_READ);
d->lock();
@@ -624,30 +675,34 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
if (brush.style() == Qt::NoBrush)
return;
d->updateClip();
- if (!d->unsupportedCompositionMode
- && !(d->transformationType & (QDirectFBPaintEnginePrivate::RectsUnsupported))
- && d->dfbCanHandleClip(rect)) {
+ if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) {
switch (brush.style()) {
case Qt::SolidPattern: {
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)) {
+ break;
+ }
const QColor color = brush.color();
if (!color.isValid())
return;
d->unlock();
d->setDFBColor(color);
const QRect r = state()->matrix.mapRect(rect).toRect();
- d->surface->FillRectangle(d->surface, r.x(), r.y(),
- r.width(), r.height());
+ CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()));
return; }
+
case Qt::TexturePattern: {
- if (d->transformationType & QDirectFBPaintEnginePrivate::NegativeScale)
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)) {
break;
+ }
const QPixmap texture = brush.texture();
if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass)
break;
d->unlock();
- d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin);
+ CLIPPED_PAINT(d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin));
return; }
default:
break;
@@ -664,9 +719,9 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color)
return;
Q_D(QDirectFBPaintEngine);
d->updateClip();
- if (d->unsupportedCompositionMode
- || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported)
- || !d->dfbCanHandleClip()) {
+ if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)
+ || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
+ || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) {
RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG());
d->lock();
QRasterPaintEngine::fillRect(rect, color);
@@ -711,11 +766,10 @@ void QDirectFBPaintEngine::initImageCache(int size)
QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p)
: surface(0), antialiased(false), simplePen(false),
transformationType(0), opacity(255), dirtyClip(true),
- dfbHandledClip(false), dfbDevice(0),
- unsupportedCompositionMode(false), q(p)
+ clipType(ClipUnset), dfbDevice(0),
+ compositionModeStatus(0), q(p)
{
fb = QDirectFBScreen::instance()->dfb();
- ignoreSystemClip = QDirectFBScreen::instance()->directFBFlags() & QDirectFBScreen::IgnoreSystemClip;
surfaceCache = new SurfaceCache;
}
@@ -724,23 +778,6 @@ QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate()
delete surfaceCache;
}
-bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRect &) const
-{
- // TODO: Check to see if DirectFB can handle the clip for the given rect
- return dfbHandledClip;
-}
-
-bool QDirectFBPaintEnginePrivate::dfbCanHandleClip(const QRectF &) const
-{
- // TODO: Check to see if DirectFB can handle the clip for the given rect
- return dfbHandledClip;
-}
-
-bool QDirectFBPaintEnginePrivate::dfbCanHandleClip() const
-{
- return dfbHandledClip;
-}
-
bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const
{
return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased);
@@ -768,7 +805,7 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform)
{
transformationType = transform.type();
if (qMin(transform.m11(), transform.m22()) < 0) {
- transformationType |= QDirectFBPaintEnginePrivate::NegativeScale;
+ transformationType |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale;
}
setPen(q->state()->pen);
}
@@ -790,7 +827,53 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &pen)
void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode)
{
- unsupportedCompositionMode = (mode != QPainter::CompositionMode_SourceOver);
+ if (!surface)
+ return;
+ compositionModeStatus = PorterDuff_SupportedBlits;
+ switch (mode) {
+ case QPainter::CompositionMode_Clear:
+ surface->SetPorterDuff(surface, DSPD_CLEAR);
+ break;
+ case QPainter::CompositionMode_Source:
+ surface->SetPorterDuff(surface, DSPD_SRC);
+ break;
+ case QPainter::CompositionMode_SourceOver:
+ compositionModeStatus |= PorterDuff_SupportedPrimitives;
+ surface->SetPorterDuff(surface, DSPD_SRC_OVER);
+ break;
+ case QPainter::CompositionMode_DestinationOver:
+ surface->SetPorterDuff(surface, DSPD_DST_OVER);
+ break;
+ case QPainter::CompositionMode_SourceIn:
+ surface->SetPorterDuff(surface, DSPD_SRC_IN);
+ break;
+ case QPainter::CompositionMode_DestinationIn:
+ surface->SetPorterDuff(surface, DSPD_DST_IN);
+ break;
+ case QPainter::CompositionMode_SourceOut:
+ surface->SetPorterDuff(surface, DSPD_SRC_OUT);
+ break;
+ case QPainter::CompositionMode_DestinationOut:
+ surface->SetPorterDuff(surface, DSPD_DST_OUT);
+ break;
+#if (Q_DIRECTFB_VERSION >= 0x010000)
+ case QPainter::CompositionMode_SourceAtop:
+ surface->SetPorterDuff(surface, DSPD_SRC_ATOP);
+ break;
+ case QPainter::CompositionMode_DestinationAtop:
+ surface->SetPorterDuff(surface, DSPD_DST_ATOP);
+ break;
+ case QPainter::CompositionMode_Plus:
+ surface->SetPorterDuff(surface, DSPD_ADD);
+ break;
+#endif
+ case QPainter::CompositionMode_Xor:
+ surface->SetPorterDuff(surface, DSPD_XOR);
+ break;
+ default:
+ compositionModeStatus = 0;
+ break;
+ }
}
void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
@@ -896,7 +979,7 @@ static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset)
void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off)
{
Q_ASSERT(!dirtyClip);
- Q_ASSERT(!(transformationType & BlitUnsupported));
+ Q_ASSERT(!(transformationType & Matrix_BlitsUnsupported));
const QTransform &transform = q->state()->matrix;
const QRect destinationRect = transform.mapRect(dest).toRect().normalized();
QRect newClip = destinationRect;
@@ -909,8 +992,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix
const DFBRegion clip = {
newClip.x(),
newClip.y(),
- newClip.x() + newClip.width() - 1,
- newClip.y() + newClip.height() - 1
+ newClip.right(),
+ newClip.bottom()
};
surface->SetClip(surface, &clip);
@@ -979,8 +1062,8 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix
const DFBRegion clip = {
currentClip.x(),
currentClip.y(),
- currentClip.x() + currentClip.width(),
- currentClip.y() + currentClip.height()
+ currentClip.right(),
+ currentClip.bottom()
};
surface->SetClip(surface, &clip);
}
@@ -995,22 +1078,22 @@ void QDirectFBPaintEnginePrivate::updateClip()
const QClipData *clipData = clip();
if (!clipData || !clipData->enabled) {
surface->SetClip(surface, NULL);
- dfbHandledClip = true;
+ clipType = NoClip;
} else if (clipData->hasRectClip) {
const DFBRegion r = {
clipData->clipRect.x(),
clipData->clipRect.y(),
- clipData->clipRect.x() + clipData->clipRect.width(),
- clipData->clipRect.y() + clipData->clipRect.height()
+ clipData->clipRect.right(),
+ clipData->clipRect.bottom()
};
surface->SetClip(surface, &r);
currentClip = clipData->clipRect.normalized();
// ### is this guaranteed to always be normalized?
- dfbHandledClip = true;
- } else if (clipData->hasRegionClip && ignoreSystemClip && clipData->clipRegion == systemClip) {
- dfbHandledClip = true;
+ clipType = RectClip;
+ } else if (clipData->hasRegionClip) {
+ clipType = RegionClip;
} else {
- dfbHandledClip = false;
+ clipType = ComplexClip;
}
dirtyClip = false;
@@ -1107,7 +1190,7 @@ template <> inline const bool* ptr<bool>(const bool &) { return 0; }
template <typename device, typename T1, typename T2, typename T3>
static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
uint transformationType, bool simplePen,
- bool dfbHandledClip, bool unsupportedCompositionMode,
+ uint clipType, uint compositionModeStatus,
const char *nameOne, const T1 &one,
const char *nameTwo, const T2 &two,
const char *nameThree, const T3 &three)
@@ -1123,8 +1206,8 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0'))
<< "simplePen" << simplePen
- << "dfbHandledClip" << dfbHandledClip
- << "unsupportedCompositionMode" << unsupportedCompositionMode;
+ << "clipType" << clipType
+ << "compositionModeStatus" << compositionModeStatus;
const T1 *t1 = ptr(one);
const T2 *t2 = ptr(two);
@@ -1141,7 +1224,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device *
}
qWarning("%s", qPrintable(out));
}
-#endif
-
+#endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS
#endif // QT_NO_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index 52e85ba..bedd9e5 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -49,9 +49,9 @@
static int global_ser_no = 0;
-QDirectFBPixmapData::QDirectFBPixmapData(PixelType pixelType)
- : QPixmapData(pixelType, DirectFBClass),
- engine(0), format(QImage::Format_Invalid), alpha(false)
+QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType)
+ : QPixmapData(pixelType, DirectFBClass), QDirectFBPaintDevice(screen),
+ format(QImage::Format_Invalid), alpha(false)
{
setSerialNumber(0);
}
@@ -61,7 +61,6 @@ QDirectFBPixmapData::~QDirectFBPixmapData()
unlockDirectFB();
if (dfbSurface && QDirectFBScreen::instance())
screen->releaseDFBSurface(dfbSurface);
- delete engine;
}
void QDirectFBPixmapData::resize(int width, int height)
@@ -304,7 +303,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
Q_ASSERT(image);
const QImage transformed = image->transformed(transform, mode);
that->unlockDirectFB();
- QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType);
+ QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
data->fromImage(transformed, Qt::AutoColor);
return QPixmap(data);
}
@@ -314,7 +313,7 @@ QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
if (size.isEmpty())
return QPixmap();
- QDirectFBPixmapData *data = new QDirectFBPixmapData(QPixmapData::PixmapType);
+ QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
data->alpha = alpha;
if (alpha) {
@@ -373,6 +372,8 @@ QImage QDirectFBPixmapData::toImage() const
return img->copy();
}
+/* This is QPixmapData::paintEngine(), not QPaintDevice::paintEngine() */
+
QPaintEngine *QDirectFBPixmapData::paintEngine() const
{
if (!engine) {
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
index 0204061..df3c679 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
@@ -56,7 +56,7 @@ class QDirectFBPaintEngine;
class QDirectFBPixmapData : public QPixmapData, public QDirectFBPaintDevice
{
public:
- QDirectFBPixmapData(PixelType pixelType);
+ QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType);
~QDirectFBPixmapData();
// Re-implemented from QPixmapData:
@@ -79,7 +79,6 @@ public:
inline bool hasAlphaChannel() const { return alpha; }
private:
void invalidate();
- QDirectFBPaintEngine *engine;
QImage::Format format;
bool alpha;
};
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 030e51f..4f8fa2f 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -57,7 +57,7 @@
class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem
{
public:
- QDirectFBScreenPrivate(QDirectFBScreen*);
+ QDirectFBScreenPrivate(QDirectFBScreen *qptr);
~QDirectFBScreenPrivate();
void setFlipFlags(const QStringList &args);
@@ -82,10 +82,11 @@ public:
QDirectFBScreen::DirectFBFlags directFBFlags;
QImage::Format alphaPixmapFormat;
QColor backgroundColor;
+ QDirectFBScreen *q;
};
-QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen)
- : QWSGraphicsSystem(screen), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE)
+QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr)
+ : QWSGraphicsSystem(qptr), dfb(0), dfbSurface(0), flipFlags(DSFLIP_NONE)
#ifndef QT_NO_DIRECTFB_LAYER
, dfbLayer(0)
#endif
@@ -98,6 +99,7 @@ QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *screen)
#endif
, directFBFlags(QDirectFBScreen::NoFlags)
, alphaPixmapFormat(QImage::Format_Invalid)
+ , q(qptr)
{
#ifndef QT_NO_QWS_SIGNALHANDLER
QWSSignalHandler::instance()->addObject(this);
@@ -742,7 +744,7 @@ QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ
if (type == QPixmapData::BitmapType)
return QWSGraphicsSystem::createPixmapData(type);
- return new QDirectFBPixmapData(type);
+ return new QDirectFBPixmapData(q, type);
}
#if (Q_DIRECTFB_VERSION >= 0x000923)
@@ -914,9 +916,6 @@ bool QDirectFBScreen::connect(const QString &displaySpec)
QDirectFBPaintEngine::initImageCache(imageCacheSize);
#endif
- if (displayArgs.contains(QLatin1String("ignoresystemclip"), Qt::CaseInsensitive))
- d_ptr->directFBFlags |= IgnoreSystemClip;
-
#ifndef QT_NO_DIRECTFB_WM
if (displayArgs.contains(QLatin1String("fullscreen")))
#endif
@@ -1328,15 +1327,15 @@ void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags
for (int i=0; i<rects.size(); ++i) {
const QRect &r = rects.at(i);
const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.x() + r.width() + offset.x(),
- r.y() + r.height() + offset.y() };
+ r.right() + offset.x(),
+ r.bottom() + offset.y() };
surface->Flip(surface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags);
}
} else {
const QRect r = region.boundingRect();
const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.x() + r.width() + offset.x(),
- r.y() + r.height() + offset.y() };
+ r.right() + offset.x(),
+ r.bottom() + offset.y() };
surface->Flip(surface, &dfbReg, flipFlags);
}
}
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
index 63c608e..8884a06 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
@@ -79,8 +79,7 @@ public:
NoFlags = 0x00,
VideoOnly = 0x01,
SystemOnly = 0x02,
- IgnoreSystemClip = 0x04,
- BoundingRectFlip = 0x08
+ BoundingRectFlip = 0x04
};
Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag);
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
index 8cddc76..34168bc 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
@@ -55,7 +55,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
- , engine(0)
+ , engineHeight(-1)
, flipFlags(flip)
, boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
{
@@ -76,7 +76,7 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect
#ifndef QT_NO_DIRECTFB_WM
, dfbWindow(0)
#endif
- , engine(0)
+ , engineHeight(-1)
, flipFlags(flip)
, boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
{
@@ -295,16 +295,6 @@ bool QDirectFBWindowSurface::move(const QPoint &moveBy)
return true;
}
-QPaintEngine *QDirectFBWindowSurface::paintEngine() const
-{
- if (!engine) {
- QDirectFBWindowSurface *that = const_cast<QDirectFBWindowSurface*>(this);
- that->engine = new QDirectFBPaintEngine(that);
- return that->engine;
- }
- return engine;
-}
-
// hw: XXX: copied from QWidgetPrivate::isOpaque()
inline bool isWidgetOpaque(const QWidget *w)
{
@@ -429,6 +419,12 @@ void QDirectFBWindowSurface::flush(QWidget *, const QRegion &region,
void QDirectFBWindowSurface::beginPaint(const QRegion &)
{
+ const int h = height();
+ if (h > engineHeight) {
+ engineHeight = h;
+ delete engine;
+ engine = new QDirectFBPaintEngine(this);
+ }
}
void QDirectFBWindowSurface::endPaint(const QRegion &)
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
index c46d93b..fefe9f3 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
@@ -61,8 +61,8 @@ QT_MODULE(Gui)
class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice
{
public:
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr);
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen* scr, QWidget *widget);
+ QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr);
+ QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr, QWidget *widget);
~QDirectFBWindowSurface();
bool isValid() const;
@@ -79,7 +79,6 @@ public:
QImage image() const { return QImage(); }
QPaintDevice *paintDevice() { return this; }
- QPaintEngine *paintEngine() const;
void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
@@ -92,7 +91,7 @@ private:
void createWindow();
IDirectFBWindow *dfbWindow;
#endif
- QDirectFBPaintEngine *engine;
+ int engineHeight;
enum Mode {
Primary,