Changeset 769 for trunk/src/plugins/gfxdrivers/directfb
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
r651 r769 69 69 70 70 enum CompositionModeStatus { 71 PorterDuff_None = 0x00, 72 PorterDuff_SupportedBlits = 0x01, 73 PorterDuff_SupportedPrimitives = 0x02, 74 PorterDuff_SupportedOpaquePrimitives = 0x04, 75 PorterDuff_Dirty = 0x10 71 PorterDuff_None = 0x0, 72 PorterDuff_Supported = 0x1, 73 PorterDuff_PremultiplyColors = 0x2, 74 PorterDuff_AlwaysBlend = 0x4 76 75 }; 77 76 … … 98 97 static inline void unlock(QDirectFBPaintDevice *device); 99 98 100 inline bool testCompositionMode(const QPen *pen, const QBrush *brush, const QColor *color = 0) const;101 99 inline bool isSimpleBrush(const QBrush &brush) const; 102 100 … … 131 129 QDirectFBPaintDevice *dfbDevice; 132 130 uint compositionModeStatus; 131 bool isPremultiplied; 133 132 134 133 bool inClip; … … 169 168 #endif 170 169 171 #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS 170 #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS || defined QT_DEBUG 172 171 #define VOID_ARG() static_cast<bool>(false) 173 172 enum PaintOperation { … … 179 178 ALL = 0xffff 180 179 }; 181 #endif 182 180 181 #ifdef QT_DEBUG 182 static void initRasterFallbacksMasks(int *warningMask, int *disableMask) 183 { 184 struct { 185 const char *name; 186 PaintOperation operation; 187 } const operations[] = { 188 { "DRAW_RECTS", DRAW_RECTS }, 189 { "DRAW_LINES", DRAW_LINES }, 190 { "DRAW_IMAGE", DRAW_IMAGE }, 191 { "DRAW_PIXMAP", DRAW_PIXMAP }, 192 { "DRAW_TILED_PIXMAP", DRAW_TILED_PIXMAP }, 193 { "STROKE_PATH", STROKE_PATH }, 194 { "DRAW_PATH", DRAW_PATH }, 195 { "DRAW_POINTS", DRAW_POINTS }, 196 { "DRAW_ELLIPSE", DRAW_ELLIPSE }, 197 { "DRAW_POLYGON", DRAW_POLYGON }, 198 { "DRAW_TEXT", DRAW_TEXT }, 199 { "FILL_PATH", FILL_PATH }, 200 { "FILL_RECT", FILL_RECT }, 201 { "DRAW_COLORSPANS", DRAW_COLORSPANS }, 202 { "DRAW_ROUNDED_RECT", DRAW_ROUNDED_RECT }, 203 { "ALL", ALL }, 204 { 0, ALL } 205 }; 206 207 QStringList warning = QString::fromLatin1(qgetenv("QT_DIRECTFB_WARN_ON_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'), 208 QString::SkipEmptyParts); 209 QStringList disable = QString::fromLatin1(qgetenv("QT_DIRECTFB_DISABLE_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'), 210 QString::SkipEmptyParts); 211 *warningMask = 0; 212 *disableMask = 0; 213 if (!warning.isEmpty() || !disable.isEmpty()) { 214 for (int i=0; operations[i].name; ++i) { 215 const QString name = QString::fromLatin1(operations[i].name); 216 int idx = warning.indexOf(name); 217 if (idx != -1) { 218 *warningMask |= operations[i].operation; 219 warning.erase(warning.begin() + idx); 220 } 221 idx = disable.indexOf(name); 222 if (idx != -1) { 223 *disableMask |= operations[i].operation; 224 disable.erase(disable.begin() + idx); 225 } 226 } 227 } 228 if (!warning.isEmpty()) { 229 qWarning("QDirectFBPaintEngine QT_DIRECTFB_WARN_ON_RASTERFALLBACKS Unknown operation(s): %s", 230 qPrintable(warning.join(QLatin1String("|")))); 231 } 232 if (!disable.isEmpty()) { 233 qWarning("QDirectFBPaintEngine QT_DIRECTFB_DISABLE_RASTERFALLBACKS Unknown operation(s): %s", 234 qPrintable(disable.join(QLatin1String("|")))); 235 } 236 237 } 238 #endif 239 240 static inline int rasterFallbacksMask(bool warn) 241 { 183 242 #ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS 243 if (warn) 244 return QT_DIRECTFB_WARN_ON_RASTERFALLBACKS; 245 #endif 246 #ifdef QT_DIRECTFB_DISABLE_RASTERFALLBACKS 247 if (!warn) 248 return QT_DIRECTFB_DISABLE_RASTERFALLBACKS; 249 #endif 250 #ifndef QT_DEBUG 251 return 0; 252 #else 253 static int warnMask = -1; 254 static int disableMask = -1; 255 if (warnMask == -1) 256 initRasterFallbacksMasks(&warnMask, &disableMask); 257 return warn ? warnMask : disableMask; 258 #endif 259 } 260 #endif 261 262 #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DEBUG 184 263 template <typename device, typename T1, typename T2, typename T3> 185 264 static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, … … 191 270 #endif 192 271 193 #if defined QT_D IRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS272 #if defined QT_DEBUG || (defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS) 194 273 #define RASTERFALLBACK(op, one, two, three) \ 195 if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ 196 rasterFallbackWarn("Disabled raster engine operation", \ 197 __FUNCTION__, state()->painter->device(), \ 198 d_func()->transformationType, \ 199 d_func()->simplePen, \ 200 d_func()->clipType, \ 201 d_func()->compositionModeStatus, \ 202 #one, one, #two, two, #three, three); \ 203 if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ 204 return; 274 { \ 275 const bool disable = op & rasterFallbacksMask(false); \ 276 if (op & rasterFallbacksMask(true)) \ 277 rasterFallbackWarn(disable \ 278 ? "Disabled raster engine operation" \ 279 : "Falling back to raster engine for", \ 280 __FUNCTION__, \ 281 state()->painter->device(), \ 282 d_func()->transformationType, \ 283 d_func()->simplePen, \ 284 d_func()->clipType, \ 285 d_func()->compositionModeStatus, \ 286 #one, one, #two, two, #three, three); \ 287 if (disable) \ 288 return; \ 289 } 205 290 #elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS 206 #define RASTERFALLBACK(op, one, two, three) \207 if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS))\291 #define RASTERFALLBACK(op, one, two, three) \ 292 if (op & rasterFallbacksMask(false)) \ 208 293 return; 209 294 #elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS 210 295 #define RASTERFALLBACK(op, one, two, three) \ 211 if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS))\296 if (op & rasterFallbacksMask(true)) \ 212 297 rasterFallbackWarn("Falling back to raster engine for", \ 213 298 __FUNCTION__, state()->painter->device(), \ … … 288 373 device->devType()); 289 374 } 375 d->isPremultiplied = QDirectFBScreen::isPremultiplied(d->dfbDevice->format()); 290 376 291 377 d->prepare(d->dfbDevice); … … 414 500 || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip 415 501 || !d->isSimpleBrush(brush) 416 || ! d->testCompositionMode(&pen, &brush)) {502 || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { 417 503 RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); 418 504 d->lock(); … … 444 530 || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip 445 531 || !d->isSimpleBrush(brush) 446 || ! d->testCompositionMode(&pen, &brush)) {532 || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { 447 533 RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); 448 534 d->lock(); … … 469 555 if (!d->simplePen 470 556 || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip 471 || ! d->testCompositionMode(&pen, 0)) {557 || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { 472 558 RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); 473 559 d->lock(); … … 489 575 if (!d->simplePen 490 576 || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip 491 || ! d->testCompositionMode(&pen, 0)) {577 || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { 492 578 RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); 493 579 d->lock(); … … 527 613 528 614 #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE 529 if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported Blits)615 if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) 530 616 || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) 531 617 || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) … … 576 662 Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); 577 663 QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); 578 if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported Blits)664 if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) 579 665 || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) 580 666 || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) … … 607 693 d->lock(); 608 694 QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); 609 } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported Blits)695 } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) 610 696 || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) 611 697 || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) … … 720 806 switch (brush.style()) { 721 807 case Qt::SolidPattern: { 722 if (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported723 || !d->testCompositionMode(0, &brush)) {724 break;725 }726 808 const QColor color = brush.color(); 727 809 if (!color.isValid()) 728 810 return; 811 812 if (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported 813 || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { 814 break; 815 } 729 816 d->setDFBColor(color); 730 817 const QRect r = state()->matrix.mapRect(rect).toRect(); … … 733 820 734 821 case Qt::TexturePattern: { 735 if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported Blits)822 if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) 736 823 || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) 737 824 || (!d->supportsStretchBlit() && state()->matrix.isScaling())) { … … 761 848 if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) 762 849 || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) 763 || ! d->testCompositionMode(0, 0, &color)) {850 || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { 764 851 RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); 765 852 d->lock(); … … 805 892 transformationType(0), opacity(255), 806 893 clipType(ClipUnset), dfbDevice(0), 807 compositionModeStatus(0), i nClip(false), q(p)894 compositionModeStatus(0), isPremultiplied(false), inClip(false), q(p) 808 895 { 809 896 fb = QDirectFBScreen::instance()->dfb(); … … 820 907 return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); 821 908 } 822 823 bool QDirectFBPaintEnginePrivate::testCompositionMode(const QPen *pen, const QBrush *brush, const QColor *color) const824 {825 Q_ASSERT(!pen || pen->style() == Qt::NoPen || pen->style() == Qt::SolidLine);826 Q_ASSERT(!brush || brush->style() == Qt::NoBrush || brush->style() == Qt::SolidPattern);827 switch (compositionModeStatus & (QDirectFBPaintEnginePrivate::PorterDuff_SupportedOpaquePrimitives828 |QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)) {829 case QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives:830 return true;831 case QDirectFBPaintEnginePrivate::PorterDuff_SupportedOpaquePrimitives:832 if (pen && pen->style() == Qt::SolidLine && pen->color().alpha() != 255)833 return false;834 if (brush) {835 if (brush->style() == Qt::SolidPattern && brush->color().alpha() != 255) {836 return false;837 }838 } else if (color && color->alpha() != 255) {839 return false;840 }841 return true;842 case QDirectFBPaintEnginePrivate::PorterDuff_None:843 return false;844 default:845 // ### PorterDuff_SupportedOpaquePrimitives|PorterDuff_SupportedPrimitives can't be combined846 break;847 }848 Q_ASSERT(0);849 return false;850 }851 852 909 853 910 void QDirectFBPaintEnginePrivate::lock() … … 913 970 static const bool forceRasterFallBack = qgetenv("QT_DIRECTFB_FORCE_RASTER").toInt() > 0; 914 971 if (forceRasterFallBack) { 915 compositionModeStatus = 0;972 compositionModeStatus = PorterDuff_None; 916 973 return; 917 974 } 918 975 919 compositionModeStatus = PorterDuff_Supported Blits;976 compositionModeStatus = PorterDuff_Supported|PorterDuff_PremultiplyColors|PorterDuff_AlwaysBlend; 920 977 switch (mode) { 921 978 case QPainter::CompositionMode_Clear: … … 924 981 case QPainter::CompositionMode_Source: 925 982 surface->SetPorterDuff(surface, DSPD_SRC); 926 compositionModeStatus |= PorterDuff_SupportedOpaquePrimitives; 983 compositionModeStatus &= ~PorterDuff_AlwaysBlend; 984 if (!isPremultiplied) 985 compositionModeStatus &= ~PorterDuff_PremultiplyColors; 927 986 break; 928 987 case QPainter::CompositionMode_SourceOver: 929 compositionModeStatus |= PorterDuff_SupportedPrimitives;988 compositionModeStatus &= ~PorterDuff_AlwaysBlend; 930 989 surface->SetPorterDuff(surface, DSPD_SRC_OVER); 931 990 break; … … 935 994 case QPainter::CompositionMode_SourceIn: 936 995 surface->SetPorterDuff(surface, DSPD_SRC_IN); 996 if (!isPremultiplied) 997 compositionModeStatus &= ~PorterDuff_PremultiplyColors; 937 998 break; 938 999 case QPainter::CompositionMode_DestinationIn: … … 945 1006 surface->SetPorterDuff(surface, DSPD_DST_OUT); 946 1007 break; 1008 #if (Q_DIRECTFB_VERSION >= 0x010209) 1009 case QPainter::CompositionMode_Destination: 1010 surface->SetPorterDuff(surface, DSPD_DST); 1011 break; 1012 #endif 947 1013 #if (Q_DIRECTFB_VERSION >= 0x010000) 948 1014 case QPainter::CompositionMode_SourceAtop: … … 960 1026 #endif 961 1027 default: 962 compositionModeStatus = 0;1028 compositionModeStatus = PorterDuff_None; 963 1029 break; 964 1030 } … … 982 1048 surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); 983 1049 surface->SetBlittingFlags(surface, blittingFlags); 984 if (compositionModeStatus & PorterDuff_Dirty) {985 setCompositionMode(q->state()->composition_mode);986 }987 1050 } 988 1051 … … 997 1060 { 998 1061 Q_ASSERT(surface); 1062 Q_ASSERT(compositionModeStatus & PorterDuff_Supported); 999 1063 const quint8 alpha = (opacity == 255 ? 1000 1064 color.alpha() : ALPHA_MUL(color.alpha(), opacity)); 1001 surface->SetColor(surface, color.red(), color.green(), color.blue(), alpha); 1002 surface->SetPorterDuff(surface, DSPD_NONE); 1003 surface->SetDrawingFlags(surface, alpha == 255 ? DSDRAW_NOFX : DSDRAW_BLEND); 1004 compositionModeStatus |= PorterDuff_Dirty; 1065 QColor col; 1066 if (compositionModeStatus & PorterDuff_PremultiplyColors) { 1067 col = QColor(ALPHA_MUL(color.red(), alpha), 1068 ALPHA_MUL(color.green(), alpha), 1069 ALPHA_MUL(color.blue(), alpha), 1070 alpha); 1071 } else { 1072 col = QColor(color.red(), color.green(), color.blue(), alpha); 1073 } 1074 surface->SetColor(surface, col.red(), col.green(), col.blue(), col.alpha()); 1075 surface->SetDrawingFlags(surface, alpha == 255 && !(compositionModeStatus & PorterDuff_AlwaysBlend) ? DSDRAW_NOFX : DSDRAW_BLEND); 1005 1076 } 1006 1077 … … 1284 1355 } 1285 1356 1286 #if def QT_DIRECTFB_WARN_ON_RASTERFALLBACKS1357 #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DEBUG 1287 1358 template <typename T> inline const T *ptr(const T &t) { return &t; } 1288 1359 template <> inline const bool* ptr<bool>(const bool &) { return 0; } -
trunk/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
r651 r769 175 175 Qt::ImageConversionFlags flags) 176 176 { 177 if (!QFile::exists(filename)) 178 return false; 177 179 if (flags == Qt::AutoColor) { 178 180 if (filename.startsWith(QLatin1Char(':'))) { // resource … … 289 291 Qt::ImageConversionFlags flags) 290 292 { 291 if (img.depth() == 1 || img.format() == QImage::Format_RGB32) { 292 fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags); 293 return; 294 } 295 296 if (img.hasAlphaChannel() 293 if (img.depth() == 1) { 294 alpha = true; 297 295 #ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION 298 && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) 299 #endif 300 ) { 296 } else if (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) { 301 297 alpha = true; 302 imageFormat = screen->alphaPixmapFormat(); 303 } else { 304 alpha = false; 305 imageFormat = screen->pixelFormat(); 306 } 298 #else 299 } else if (img.hasAlphaChannel()) { 300 alpha = true; 301 #endif 302 } 303 imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat(); 307 304 QImage image; 308 if ( flags!= Qt::AutoColor) {305 if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) { 309 306 image = img.convertToFormat(imageFormat, flags); 310 307 flags = Qt::AutoColor; 311 } else if (img.format() == QImage::Format_RGB32 ) {308 } else if (img.format() == QImage::Format_RGB32 || img.depth() == 1) { 312 309 image = img.convertToFormat(imageFormat, flags); 313 310 } else { … … 426 423 Q_ASSERT(dfbSurface); 427 424 428 alpha = (color.alpha() < 255);425 alpha |= (color.alpha() < 255); 429 426 430 427 if (alpha && isOpaqueFormat(imageFormat)) { … … 594 591 } 595 592 593 #ifndef QT_DIRECTFB_PLUGIN 594 Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_pixmap(const QPixmap &pixmap) 595 { 596 const QPixmapData *data = pixmap.pixmapData(); 597 if (!data || data->classId() != QPixmapData::DirectFBClass) 598 return 0; 599 const QDirectFBPixmapData *dfbData = static_cast<const QDirectFBPixmapData*>(data); 600 return dfbData->directFBSurface(); 601 } 602 #endif 603 596 604 QT_END_NAMESPACE 597 605 -
trunk/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
r651 r769 922 922 } 923 923 } else { 924 flipFlags = DSFLIP_BLIT ;924 flipFlags = DSFLIP_BLIT|DSFLIP_ONSYNC; 925 925 } 926 926 } … … 1127 1127 if (displayArgs.contains(QLatin1String("boundingrectflip"), Qt::CaseInsensitive)) { 1128 1128 d_ptr->directFBFlags |= BoundingRectFlip; 1129 } else if (displayArgs.contains(QLatin1String("nopartialflip"), Qt::CaseInsensitive)) { 1130 d_ptr->directFBFlags |= NoPartialFlip; 1129 1131 } 1130 1132 … … 1139 1141 #endif 1140 1142 d_ptr->dfb->SetCooperativeLevel(d_ptr->dfb, DFSCL_FULLSCREEN); 1143 1144 const bool forcePremultiplied = displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive); 1141 1145 1142 1146 DFBSurfaceDescription description; … … 1168 1172 } 1169 1173 1170 if ( displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive)) {1174 if (forcePremultiplied) { 1171 1175 description.caps |= DSCAPS_PREMULTIPLIED; 1172 1176 } … … 1218 1222 break; 1219 1223 case QImage::Format_ARGB32: 1224 if (forcePremultiplied) 1225 d_ptr->alphaPixmapFormat = pixelFormat = QImage::Format_ARGB32_Premultiplied; 1220 1226 case QImage::Format_ARGB32_Premultiplied: 1221 1227 case QImage::Format_ARGB4444_Premultiplied: … … 1675 1681 uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl) 1676 1682 { 1677 void *mem ;1683 void *mem = 0; 1678 1684 const DFBResult result = surface->Lock(surface, flags, &mem, bpl); 1679 1685 if (result != DFB_OK) { … … 1684 1690 } 1685 1691 1692 static inline bool isFullUpdate(IDirectFBSurface *surface, const QRegion ®ion, const QPoint &offset) 1693 { 1694 if (offset == QPoint(0, 0) && region.rectCount() == 1) { 1695 QSize size; 1696 surface->GetSize(surface, &size.rwidth(), &size.rheight()); 1697 if (region.boundingRect().size() == size) 1698 return true; 1699 } 1700 return false; 1701 } 1686 1702 1687 1703 void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags, 1688 1704 const QRegion ®ion, const QPoint &offset) 1689 1705 { 1690 if (!(flipFlags & DSFLIP_BLIT)) { 1706 if (d_ptr->directFBFlags & NoPartialFlip 1707 || (!(flipFlags & DSFLIP_BLIT) && QT_PREPEND_NAMESPACE(isFullUpdate(surface, region, offset)))) { 1691 1708 surface->Flip(surface, 0, flipFlags); 1692 1709 } else { -
trunk/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
r651 r769 145 145 VideoOnly = 0x01, 146 146 SystemOnly = 0x02, 147 BoundingRectFlip = 0x04 147 BoundingRectFlip = 0x04, 148 NoPartialFlip = 0x08 148 149 }; 149 150 -
trunk/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
r651 r769 62 62 , flipFlags(flip) 63 63 , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) 64 , flushPending(false) 64 65 { 65 66 #ifdef QT_NO_DIRECTFB_WM … … 81 82 , flipFlags(flip) 82 83 , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip) 84 , flushPending(false) 83 85 { 84 86 SurfaceFlags flags = 0; … … 93 95 flags = Buffered; 94 96 } 95 #else96 noSystemBackground = widget && widget->testAttribute(Qt::WA_NoSystemBackground);97 if (noSystemBackground)98 flags &= ~Opaque;99 97 #endif 100 98 setSurfaceFlags(flags); … … 135 133 qFatal("QDirectFBWindowSurface: Unable to get primary display layer!"); 136 134 135 updateIsOpaque(); 136 137 137 DFBWindowDescription description; 138 138 memset(&description, 0, sizeof(DFBWindowDescription)); 139 139 140 description.flags = DWDESC_CAPS|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT; 140 141 description.caps = DWCAPS_NODECORATION; 141 description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY; 142 #if (Q_DIRECTFB_VERSION >= 0x010200) 143 description.flags |= DWDESC_OPTIONS; 144 #endif 145 146 if (noSystemBackground) { 142 description.surface_caps = DSCAPS_NONE; 143 imageFormat = screen->pixelFormat(); 144 145 if (!(surfaceFlags() & Opaque)) { 146 imageFormat = screen->alphaPixmapFormat(); 147 147 description.caps |= DWCAPS_ALPHACHANNEL; 148 148 #if (Q_DIRECTFB_VERSION >= 0x010200) 149 description.flags |= DWDESC_OPTIONS; 149 150 description.options |= DWOP_ALPHACHANNEL; 150 151 #endif 151 152 } 152 153 description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(imageFormat); 153 154 description.posx = rect.x(); 154 155 description.posy = rect.y(); 155 156 description.width = rect.width(); 156 157 description.height = rect.height(); 157 description.surface_caps = DSCAPS_NONE; 158 159 if (QDirectFBScreen::isPremultiplied(imageFormat)) 160 description.surface_caps = DSCAPS_PREMULTIPLIED; 161 158 162 if (screen->directFBFlags() & QDirectFBScreen::VideoOnly) 159 163 description.surface_caps |= DSCAPS_VIDEOONLY; 160 const QImage::Format format = (noSystemBackground ? screen->alphaPixmapFormat() : screen->pixelFormat());161 description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);162 if (QDirectFBScreen::isPremultiplied(format))163 description.surface_caps = DSCAPS_PREMULTIPLIED;164 164 165 165 DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow); … … 183 183 Q_ASSERT(!dfbSurface); 184 184 dfbWindow->GetSurface(dfbWindow, &dfbSurface); 185 updateFormat();186 185 } 187 186 … … 268 267 } else { // mode == Offscreen 269 268 if (!dfbSurface) { 270 dfbSurface = screen->createDFBSurface(rect.size(), screen->pixelFormat(), QDirectFBScreen::DontTrackSurface); 269 dfbSurface = screen->createDFBSurface(rect.size(), surfaceFlags() & Opaque ? screen->pixelFormat() : screen->alphaPixmapFormat(), 270 QDirectFBScreen::DontTrackSurface); 271 271 } 272 272 } … … 275 275 #endif 276 276 } 277 if (oldSurface != dfbSurface) 278 updateFormat(); 277 if (oldSurface != dfbSurface) { 278 imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid; 279 } 279 280 280 281 if (oldRect.size() != rect.size()) { … … 297 298 sibling = *reinterpret_cast<QDirectFBWindowSurface *const*>(state.constData()); 298 299 Q_ASSERT(sibling); 299 sibling->setSurfaceFlags(surfaceFlags()); 300 } 301 } 302 303 static inline void scrollSurface(IDirectFBSurface *surface, const QRect &r, int dx, int dy) 304 { 300 setSurfaceFlags(sibling->surfaceFlags()); 301 } 302 } 303 304 bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) 305 { 306 if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.rectCount() != 1) 307 return false; 308 if (flushPending) { 309 dfbSurface->Flip(dfbSurface, 0, DSFLIP_BLIT); 310 } else { 311 flushPending = true; 312 } 313 dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); 314 const QRect r = region.boundingRect(); 305 315 const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() }; 306 surface->Blit(surface, surface, &rect, r.x() + dx, r.y() + dy); 307 const DFBRegion region = { rect.x + dx, rect.y + dy, r.right() + dx, r.bottom() + dy }; 308 surface->Flip(surface, ®ion, DSFLIP_BLIT); 309 } 310 311 bool QDirectFBWindowSurface::scroll(const QRegion ®ion, int dx, int dy) 312 { 313 if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.isEmpty()) 314 return false; 315 dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX); 316 if (region.rectCount() == 1) { 317 scrollSurface(dfbSurface, region.boundingRect(), dx, dy); 318 } else { 319 const QVector<QRect> rects = region.rects(); 320 const int n = rects.size(); 321 for (int i=0; i<n; ++i) { 322 scrollSurface(dfbSurface, rects.at(i), dx, dy); 323 } 324 } 316 dfbSurface->Blit(dfbSurface, dfbSurface, &rect, r.x() + dx, r.y() + dy); 325 317 return true; 326 318 } … … 360 352 const QRect windowGeometry = geometry(); 361 353 #ifdef QT_DIRECTFB_WM 362 const bool wasNoSystemBackground = noSystemBackground;363 noSystemBackground = win->testAttribute(Qt::WA_NoSystemBackground);364 354 quint8 currentOpacity; 365 355 Q_ASSERT(dfbWindow); … … 369 359 } 370 360 371 setOpaque(noSystemBackground || windowOpacity != 0xff);372 if (wasNoSystemBackground != noSystemBackground) {373 releaseSurface();374 dfbWindow->Release(dfbWindow);375 dfbWindow = 0;376 createWindow(windowGeometry);377 win->update();378 return;379 }380 361 screen->flipSurface(dfbSurface, flipFlags, region, offset); 381 362 #else 382 setOpaque(windowOpacity != 0xff);363 setOpaque(windowOpacity == 0xff); 383 364 if (mode == Offscreen) { 384 365 screen->exposeRegion(region.translated(offset + geometry().topLeft()), 0); … … 397 378 } 398 379 #endif 380 flushPending = false; 399 381 } 400 382 … … 404 386 engine = new QDirectFBPaintEngine(this); 405 387 } 388 flushPending = true; 406 389 } 407 390 … … 443 426 } 444 427 445 void QDirectFBWindowSurface::updateFormat()446 {447 imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid;448 }449 450 428 void QDirectFBWindowSurface::releaseSurface() 451 429 { … … 466 444 } 467 445 446 void QDirectFBWindowSurface::updateIsOpaque() 447 { 448 const QWidget *win = window(); 449 Q_ASSERT(win); 450 if (win->testAttribute(Qt::WA_OpaquePaintEvent) || win->testAttribute(Qt::WA_PaintOnScreen)) { 451 setOpaque(true); 452 return; 453 } 454 455 if (qFuzzyCompare(static_cast<float>(win->windowOpacity()), 1.0f)) { 456 const QPalette &pal = win->palette(); 457 458 if (win->autoFillBackground()) { 459 const QBrush &autoFillBrush = pal.brush(win->backgroundRole()); 460 if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) { 461 setOpaque(true); 462 return; 463 } 464 } 465 466 if (win->isWindow() && !win->testAttribute(Qt::WA_NoSystemBackground)) { 467 const QBrush &windowBrush = win->palette().brush(QPalette::Window); 468 if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) { 469 setOpaque(true); 470 return; 471 } 472 } 473 } 474 setOpaque(false); 475 } 468 476 469 477 QT_END_NAMESPACE 470 478 471 479 #endif // QT_NO_QWS_DIRECTFB 472 473 -
trunk/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
r651 r769 98 98 #endif 99 99 private: 100 void updateIsOpaque(); 100 101 void setOpaque(bool opaque); 101 void updateFormat();102 102 void releaseSurface(); 103 103 QDirectFBWindowSurface *sibling; … … 114 114 115 115 DFBSurfaceFlipFlags flipFlags; 116 bool noSystemBackground;117 116 bool boundingRectFlip; 117 bool flushPending; 118 118 #ifdef QT_DIRECTFB_TIMING 119 119 int frames;
Note:
See TracChangeset
for help on using the changeset viewer.