From 7c6ba93ae413309672bb839da2ae1522a170b14d Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 23 Apr 2009 16:24:54 -0700 Subject: Remove the simpleBrush concept Since we have to update the brush for each paint command anyway keeping the state of the brush and caching the value of simpleBrush makes no sense. Also, most times when filling with a brush QPaintEngineEx::fillRect(const QRect &, const QBrush &) is called in which we never got a brushChanged() anyway. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/directfb.pro | 4 +- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 82 ++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro index 89a289c..1ee9030 100644 --- a/src/plugins/gfxdrivers/directfb/directfb.pro +++ b/src/plugins/gfxdrivers/directfb/directfb.pro @@ -3,7 +3,7 @@ include(../../qpluginbase.pri) QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers -# These defines might be necessary if your DirectFB driver doesn't +# These defines might be necessary if your DirectFB driver doesn't # support all of the DirectFB API. # #DEFINES += QT_NO_DIRECTFB_WM @@ -14,6 +14,8 @@ QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers #DEFINES += QT_NO_DIRECTFB_KEYBOARD #DEFINES += QT_DIRECTFB_TIMING #DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION +#DEFINES += QT_DIRECTFB_WARN_ON_RASTERFALLBACKS +#DEFINES += QT_DIRECTFB_DISABLE_RASTERFALLBACKS target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers INSTALLS += target diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 92b30a7..ba5d71a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -54,6 +54,70 @@ #include #include +#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS +template inline const T *ptr(const T &t) { return &t; } +template <> inline const bool* ptr(const bool &) { return 0; } +template +static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, + bool matrixScale, bool matrixRotShear, bool simplePen, + bool dfbHandledClip, bool forceRasterPrimitives, + const char *nameOne, const T1 &one, + const char *nameTwo, const T2 &two, + const char *nameThree, const T3 &three) +{ + QString out; + QDebug dbg(&out); + dbg << msg << (QByteArray(func) + "()") << "painting on"; + if (dev->devType() == QInternal::Widget) { + dbg << static_cast(dev); + } else { + dbg << dev << "of type" << dev->devType(); + } + + dbg << "matrixScale" << matrixScale + << "matrixRotShear" << matrixRotShear + << "simplePen" << simplePen + << "dfbHandledClip" << dfbHandledClip + << "forceRasterPrimitives" << forceRasterPrimitives; + + const T1 *t1 = ptr(one); + const T2 *t2 = ptr(two); + const T3 *t3 = ptr(three); + + if (t1) { + dbg << nameOne << *t1; + if (t2) { + dbg << nameTwo << *t2; + if (t3) { + dbg << nameThree << *t3; + } + } + } + qWarning("%s", qPrintable(out)); +} +#endif + +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#define RASTERFALLBACK(one, two, three) rasterFallbackWarn("Disabled raster engine operation", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->simplePen, d_func()->dfbCanHandleClip(), \ + d_func()->forceRasterPrimitives, \ + #one, one, #two, two, #three, three); \ + return; +#elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#define RASTERFALLBACK(one, two, three) return; +#elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS +#define RASTERFALLBACK(one, two, three) rasterFallbackWarn("Falling back to raster engine for", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->matrixScale, d_func()->matrixRotShear, \ + d_func()->simplePen, d_func()->dfbCanHandleClip(), \ + d_func()->forceRasterPrimitives, \ + #one, one, #two, two, #three, three); +#else +#define RASTERFALLBACK(one, two, three) +#endif + static inline uint ALPHA_MUL(uint x, uint a) { uint t = x * a; @@ -826,6 +890,7 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) if (!d->dfbCanHandleClip() || d->matrixRotShear || !d->simplePen || d->forceRasterPrimitives || !d->isSimpleBrush(brush)) { + RASTERFALLBACK(rectCount, static_cast(false), static_cast(false)); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); return; @@ -873,6 +938,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { + RASTERFALLBACK(lineCount, static_cast(false), static_cast(false)); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); return; @@ -890,6 +956,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->simplePen || !d->dfbCanHandleClip() || d->forceRasterPrimitives) { + RASTERFALLBACK(lineCount, static_cast(false), static_cast(false)); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); return; @@ -915,6 +982,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN) #endif { + RASTERFALLBACK(r, image.size(), sr); d->lock(); QRasterPaintEngine::drawImage(r, image, sr, flags); return; @@ -938,9 +1006,11 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, d->updateClip(); if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { + // not using RASTERFALLBACK since this is the way we do bitmaps? d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear) { + RASTERFALLBACK(r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(); d->lock(); QRasterPaintEngine::drawImage(r, *img, sr); @@ -965,6 +1035,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, sp); } else if (!d->dfbCanHandleClip(r) || d->matrixRotShear || !sp.isNull()) { + RASTERFALLBACK(r, pixmap.size(), sp); const QImage *img = static_cast(pixmap.pixmapData())->buffer(); d->lock(); QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); @@ -987,6 +1058,7 @@ void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) void QDirectFBPaintEngine::drawPath(const QPainterPath &path) { + RASTERFALLBACK(path.boundingRect(), static_cast(false), static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPath(path); @@ -994,6 +1066,7 @@ void QDirectFBPaintEngine::drawPath(const QPainterPath &path) void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) { + RASTERFALLBACK(pointCount, static_cast(false), static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPoints(points, pointCount); @@ -1001,6 +1074,7 @@ void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) { + RASTERFALLBACK(pointCount, static_cast(false), static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPoints(points, pointCount); @@ -1008,6 +1082,7 @@ void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) { + RASTERFALLBACK(rect, static_cast(false), static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawEllipse(rect); @@ -1016,6 +1091,7 @@ void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) { + RASTERFALLBACK(pointCount, mode, static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPolygon(points, pointCount, mode); @@ -1024,6 +1100,7 @@ void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode) { + RASTERFALLBACK(pointCount, mode, static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawPolygon(points, pointCount, mode); @@ -1032,6 +1109,7 @@ void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, void QDirectFBPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) { + RASTERFALLBACK(p, textItem.text(), static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::drawTextItem(p, textItem); @@ -1039,6 +1117,7 @@ void QDirectFBPaintEngine::drawTextItem(const QPointF &p, void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush) { + RASTERFALLBACK(path, brush, static_cast(false)); Q_D(QDirectFBPaintEngine); d->lock(); QRasterPaintEngine::fill(path, brush); @@ -1072,6 +1151,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) break; } } + RASTERFALLBACK(rect, brush, static_cast(false)); d->lock(); QRasterPaintEngine::fillRect(rect, brush); } @@ -1081,6 +1161,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) Q_D(QDirectFBPaintEngine); d->updateClip(); if (!d->dfbCanHandleClip() || d->matrixRotShear || d->forceRasterPrimitives) { + RASTERFALLBACK(rect, color, static_cast(false)); d->lock(); QRasterPaintEngine::fillRect(rect, color); } else { @@ -1097,6 +1178,7 @@ void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count, { Q_D(QDirectFBPaintEngine); if (d->forceRasterPrimitives) { + RASTERFALLBACK(count, color, static_cast(false)); d->lock(); QRasterPaintEngine::drawColorSpans(spans, count, color); } else { -- cgit v0.12