- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 56 56 #include <private/qimagepixmapcleanuphooks_p.h> 57 57 58 58 59 QT_BEGIN_NAMESPACE 59 60 … … 67 68 Matrix_BlitsUnsupported = (Matrix_NegativeScale|Matrix_RectsUnsupported) 68 69 }; 70 71 inline static uint getTransformationType(const QTransform &transform) 72 { 73 int ret = transform.type(); 74 if (qMin(transform.m11(), transform.m22()) < 0) { 75 ret |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale; 76 } 77 return ret; 78 } 69 79 70 80 enum CompositionModeStatus { … … 99 109 inline bool isSimpleBrush(const QBrush &brush) const; 100 110 101 void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos );111 void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos, const QTransform &pixmapTransform); 102 112 void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src); 103 113 … … 113 123 #endif 114 124 115 void prepareForBlit(bool alpha); 125 enum BlitFlag { 126 HasAlpha = 0x1, 127 Premultiplied = 0x2 128 }; 129 void prepareForBlit(uint blitFlags); 116 130 117 131 IDirectFBSurface *surface; … … 168 182 #endif 169 183 170 #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS || defined QT_DEBUG171 184 #define VOID_ARG() static_cast<bool>(false) 172 185 enum PaintOperation { … … 176 189 DRAW_POLYGON = 0x0200, DRAW_TEXT = 0x0400, FILL_PATH = 0x0800, 177 190 FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, DRAW_ROUNDED_RECT = 0x4000, 178 ALL = 0xffff191 DRAW_STATICTEXT = 0x8000, ALL = 0xffff 179 192 }; 180 193 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); 194 enum { RasterWarn = 1, RasterDisable = 2 }; 195 static inline uint rasterFallbacksMask(PaintOperation op) 196 { 197 uint ret = 0; 198 #ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS 199 if (op & QT_DIRECTFB_WARN_ON_RASTERFALLBACKS) 200 ret |= RasterWarn; 201 #endif 202 #ifdef QT_DIRECTFB_DISABLE_RASTERFALLBACKS 203 if (op & QT_DIRECTFB_DISABLE_RASTERFALLBACKS) 204 ret |= RasterDisable; 205 #endif 206 static int warningMask = -1; 207 static int disableMask = -1; 208 if (warningMask < 0) { 209 struct { 210 const char *name; 211 PaintOperation operation; 212 } const operations[] = { 213 { "DRAW_RECTS", DRAW_RECTS }, 214 { "DRAW_LINES", DRAW_LINES }, 215 { "DRAW_IMAGE", DRAW_IMAGE }, 216 { "DRAW_PIXMAP", DRAW_PIXMAP }, 217 { "DRAW_TILED_PIXMAP", DRAW_TILED_PIXMAP }, 218 { "STROKE_PATH", STROKE_PATH }, 219 { "DRAW_PATH", DRAW_PATH }, 220 { "DRAW_POINTS", DRAW_POINTS }, 221 { "DRAW_ELLIPSE", DRAW_ELLIPSE }, 222 { "DRAW_POLYGON", DRAW_POLYGON }, 223 { "DRAW_TEXT", DRAW_TEXT }, 224 { "FILL_PATH", FILL_PATH }, 225 { "FILL_RECT", FILL_RECT }, 226 { "DRAW_COLORSPANS", DRAW_COLORSPANS }, 227 { "DRAW_ROUNDED_RECT", DRAW_ROUNDED_RECT }, 228 { "ALL", ALL }, 229 { 0, ALL } 230 }; 231 232 QStringList warning = QString::fromLatin1(qgetenv("QT_DIRECTFB_WARN_ON_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'), 233 QString::SkipEmptyParts); 234 QStringList disable = QString::fromLatin1(qgetenv("QT_DIRECTFB_DISABLE_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'), 235 QString::SkipEmptyParts); 236 warningMask = 0; 237 disableMask = 0; 238 if (!warning.isEmpty() || !disable.isEmpty()) { 239 for (int i=0; operations[i].name; ++i) { 240 const QString name = QString::fromLatin1(operations[i].name); 241 int idx = warning.indexOf(name); 242 if (idx != -1) { 243 warningMask |= operations[i].operation; 244 warning.erase(warning.begin() + idx); 245 } 246 idx = disable.indexOf(name); 247 if (idx != -1) { 248 disableMask |= operations[i].operation; 249 disable.erase(disable.begin() + idx); 250 } 225 251 } 226 252 } 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 { 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 253 if (!warning.isEmpty()) { 254 qWarning("QDirectFBPaintEngine QT_DIRECTFB_WARN_ON_RASTERFALLBACKS Unknown operation(s): %s", 255 qPrintable(warning.join(QLatin1String("|")))); 256 } 257 if (!disable.isEmpty()) { 258 qWarning("QDirectFBPaintEngine QT_DIRECTFB_DISABLE_RASTERFALLBACKS Unknown operation(s): %s", 259 qPrintable(disable.join(QLatin1String("|")))); 260 } 261 } 262 if (op & warningMask) 263 ret |= RasterWarn; 264 if (op & disableMask) 265 ret |= RasterDisable; 266 return ret; 267 } 268 263 269 template <typename device, typename T1, typename T2, typename T3> 264 270 static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, … … 268 274 const char *nameTwo, const T2 &two, 269 275 const char *nameThree, const T3 &three); 270 #endif 271 272 #if defined QT_DEBUG || (defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS) 276 273 277 #define RASTERFALLBACK(op, one, two, three) \ 274 278 { \ 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",\279 static const uint rasterFallbacks = rasterFallbacksMask(op); \ 280 switch (rasterFallbacks) { \ 281 case 0: break; \ 282 case RasterWarn: \ 283 rasterFallbackWarn("Falling back to raster engine for", \ 280 284 __FUNCTION__, \ 281 285 state()->painter->device(), \ … … 285 289 d_func()->compositionModeStatus, \ 286 290 #one, one, #two, two, #three, three); \ 287 if (disable) \ 291 break; \ 292 case RasterDisable|RasterWarn: \ 293 rasterFallbackWarn("Disabled raster engine operation", \ 294 __FUNCTION__, \ 295 state()->painter->device(), \ 296 d_func()->transformationType, \ 297 d_func()->simplePen, \ 298 d_func()->clipType, \ 299 d_func()->compositionModeStatus, \ 300 #one, one, #two, two, #three, three); \ 301 case RasterDisable: \ 288 302 return; \ 289 } 290 #elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS 291 #define RASTERFALLBACK(op, one, two, three) \ 292 if (op & rasterFallbacksMask(false)) \ 293 return; 294 #elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS 295 #define RASTERFALLBACK(op, one, two, three) \ 296 if (op & rasterFallbacksMask(true)) \ 297 rasterFallbackWarn("Falling back to raster engine for", \ 298 __FUNCTION__, state()->painter->device(), \ 299 d_func()->transformationType, \ 300 d_func()->simplePen, \ 301 d_func()->clipType, \ 302 d_func()->compositionModeStatus, \ 303 #one, one, #two, two, #three, three); 304 #else 305 #define RASTERFALLBACK(op, one, two, three) 306 #endif 303 } \ 304 } 307 305 308 306 template <class T> … … 633 631 bool release; 634 632 IDirectFBSurface *imgSurface = d->getSurface(image, &release); 635 d->prepareForBlit(QDirectFBScreen::hasAlphaChannel(imgSurface)); 633 uint blitFlags = 0; 634 if (image.hasAlphaChannel()) 635 blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha; 636 if (QDirectFBScreen::isPremultiplied(image.format())) 637 blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied; 638 d->prepareForBlit(blitFlags); 636 639 CLIPPED_PAINT(d->blit(r, imgSurface, sr)); 637 640 if (release) { … … 672 675 } else { 673 676 QDirectFBPaintEnginePrivate::unlock(dfbData); 674 d->prepareForBlit(pixmap.hasAlphaChannel());675 677 IDirectFBSurface *s = dfbData->directFBSurface(); 678 uint blitFlags = 0; 679 if (pixmap.hasAlphaChannel()) 680 blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha; 681 if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat())) 682 blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied; 683 684 d->prepareForBlit(blitFlags); 676 685 CLIPPED_PAINT(d->blit(r, s, sr)); 677 686 } … … 708 717 QRasterPaintEngine::drawTiledPixmap(r, pix, offset); 709 718 } else { 710 CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset)); 719 QTransform transform(state()->matrix); 720 CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset, transform)); 711 721 } 712 722 } … … 796 806 d->lock(); 797 807 QRasterPaintEngine::drawRoundedRect(rect, xrad, yrad, mode); 808 } 809 810 void QDirectFBPaintEngine::drawStaticTextItem(QStaticTextItem *item) 811 { 812 RASTERFALLBACK(DRAW_STATICTEXT, item, VOID_ARG(), VOID_ARG()); 813 Q_D(QDirectFBPaintEngine); 814 d->lock(); 815 QRasterPaintEngine::drawStaticTextItem(item); 798 816 } 799 817 … … 820 838 821 839 case Qt::TexturePattern: { 840 const QPointF &brushOrigin = state()->brushOrigin; 841 const QTransform stateTransform = state()->matrix; 842 QTransform transform(stateTransform); 843 transform.translate(brushOrigin.x(), brushOrigin.y()); 844 transform = brush.transform() * transform; 822 845 if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) 823 || ( d->transformationType& QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)824 || (!d->supportsStretchBlit() && state()->matrix.isScaling())) {846 || (QDirectFBPaintEnginePrivate::getTransformationType(transform) & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) 847 || (!d->supportsStretchBlit() && transform.isScaling())) { 825 848 break; 826 849 } … … 830 853 break; 831 854 832 CLIPPED_PAINT(d->drawTiledPixmap( rect, texture, rect.topLeft() - state()->brushOrigin));855 CLIPPED_PAINT(d->drawTiledPixmap(stateTransform.mapRect(rect), texture, rect.topLeft() - brushOrigin, transform)); 833 856 return; } 834 857 default: … … 941 964 void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) 942 965 { 943 transformationType = transform.type(); 944 if (qMin(transform.m11(), transform.m22()) < 0) { 945 transformationType |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale; 946 } 966 transformationType = getTransformationType(transform); 947 967 setPen(q->state()->pen); 948 968 } … … 1040 1060 } 1041 1061 1042 void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) 1043 { 1044 DFBSurfaceBlittingFlags blittingFlags = alpha ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; 1062 void QDirectFBPaintEnginePrivate::prepareForBlit(uint flags) 1063 { 1064 DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX; 1065 if (flags & Premultiplied) 1066 blittingFlags |= DSBLIT_SRC_PREMULTIPLY; 1067 if (flags & HasAlpha) 1068 blittingFlags |= DSBLIT_BLEND_ALPHACHANNEL; 1045 1069 if (opacity != 255) { 1046 1070 blittingFlags |= DSBLIT_BLEND_COLORALPHA; 1047 } 1048 surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); 1071 surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); 1072 } 1073 1049 1074 surface->SetBlittingFlags(surface, blittingFlags); 1050 1075 } … … 1141 1166 } 1142 1167 1143 void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off)1144 { 1145 Q_ASSERT(!(transformationType & Matrix_BlitsUnsupported)); 1168 void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, 1169 const QPointF &off, const QTransform &pixmapTransform) 1170 { 1146 1171 const QTransform &transform = q->state()->matrix; 1172 Q_ASSERT(!(getTransformationType(transform) & Matrix_BlitsUnsupported) && 1173 !(getTransformationType(pixmapTransform) & Matrix_BlitsUnsupported)); 1147 1174 const QRect destinationRect = transform.mapRect(dest).toRect().normalized(); 1148 1175 QRect newClip = destinationRect; … … 1161 1188 surface->SetClip(surface, &clip); 1162 1189 1163 QPointF offset = off;1190 QPointF offset = pixmapTransform.inverted().map(off); 1164 1191 Q_ASSERT(transform.type() <= QTransform::TxScale); 1165 prepareForBlit(pixmap.hasAlphaChannel());1166 1192 QPixmapData *data = pixmap.pixmapData(); 1167 1193 Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); 1168 1194 QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); 1195 IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); 1196 uint blitFlags = 0; 1197 if (dfbData->hasAlphaChannel()) 1198 blitFlags |= HasAlpha; 1199 if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat())) 1200 blitFlags |= Premultiplied; 1201 prepareForBlit(blitFlags); 1169 1202 QDirectFBPaintEnginePrivate::unlock(dfbData); 1170 1203 const QSize pixmapSize = dfbData->size(); 1171 IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); 1172 if (transform.isScaling()) { 1204 if (transform.isScaling() || pixmapTransform.isScaling()) { 1173 1205 Q_ASSERT(supportsStretchBlit()); 1174 1206 Q_ASSERT(qMin(transform.m11(), transform.m22()) >= 0); … … 1176 1208 offset.ry() *= transform.m22(); 1177 1209 1178 const QSizeF mappedSize(pixmapSize.width() * transform.m11(), pixmapSize.height() * transform.m22());1210 const QSizeF mappedSize(pixmapSize.width() * pixmapTransform.m11(), pixmapSize.height() * pixmapTransform.m22()); 1179 1211 qreal y = fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); 1180 1212 const qreal startX = fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); … … 1355 1387 } 1356 1388 1357 #if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DEBUG1358 1389 template <typename T> inline const T *ptr(const T &t) { return &t; } 1359 1390 template <> inline const bool* ptr<bool>(const bool &) { return 0; } … … 1396 1427 } 1397 1428 1398 #endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS1399 1400 1429 QT_END_NAMESPACE 1401 1430
Note:
See TracChangeset
for help on using the changeset viewer.