4283 pixmapPainter.end(); |
4283 pixmapPainter.end(); |
4284 |
4284 |
4285 if (!subPix.isNull()) { |
4285 if (!subPix.isNull()) { |
4286 // Blit the subpixmap into the main pixmap. |
4286 // Blit the subpixmap into the main pixmap. |
4287 pixmapPainter.begin(pix); |
4287 pixmapPainter.begin(pix); |
|
4288 pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source); |
4288 pixmapPainter.setClipRegion(pixmapExposed); |
4289 pixmapPainter.setClipRegion(pixmapExposed); |
4289 pixmapPainter.drawPixmap(br.topLeft(), subPix); |
4290 pixmapPainter.drawPixmap(br.topLeft(), subPix); |
4290 pixmapPainter.end(); |
4291 pixmapPainter.end(); |
4291 } |
4292 } |
4292 } |
4293 } |
4448 oldPainterOpacity != newPainterOpacity, painterStateProtection); |
4449 oldPainterOpacity != newPainterOpacity, painterStateProtection); |
4449 return; |
4450 return; |
4450 } |
4451 } |
4451 |
4452 |
4452 // Create or reuse offscreen pixmap, possibly scroll/blit from the old one. |
4453 // Create or reuse offscreen pixmap, possibly scroll/blit from the old one. |
|
4454 // If the world transform is rotated we always recreate the cache to avoid |
|
4455 // wrong blending. |
4453 bool pixModified = false; |
4456 bool pixModified = false; |
4454 QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget]; |
4457 QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget]; |
4455 bool invertable = true; |
4458 bool invertable = true; |
4456 QTransform diff = deviceData->lastTransform.inverted(&invertable); |
4459 QTransform diff = deviceData->lastTransform.inverted(&invertable); |
4457 if (invertable) |
4460 if (invertable) |
4458 diff *= painter->worldTransform(); |
4461 diff *= painter->worldTransform(); |
4459 deviceData->lastTransform = painter->worldTransform(); |
4462 deviceData->lastTransform = painter->worldTransform(); |
4460 if (!invertable || diff.type() > QTransform::TxTranslate) { |
4463 if (!invertable |
|
4464 || diff.type() > QTransform::TxTranslate |
|
4465 || painter->worldTransform().type() > QTransform::TxScale) { |
4461 pixModified = true; |
4466 pixModified = true; |
4462 itemCache->allExposed = true; |
4467 itemCache->allExposed = true; |
4463 itemCache->exposed.clear(); |
4468 itemCache->exposed.clear(); |
4464 pix = QPixmap(); |
4469 pix = QPixmap(); |
4465 } |
4470 } |
4712 painter->setOpacity(opacity); |
4717 painter->setOpacity(opacity); |
4713 |
4718 |
4714 if (sourced->currentCachedSystem() != Qt::LogicalCoordinates |
4719 if (sourced->currentCachedSystem() != Qt::LogicalCoordinates |
4715 && sourced->lastEffectTransform != painter->worldTransform()) |
4720 && sourced->lastEffectTransform != painter->worldTransform()) |
4716 { |
4721 { |
4717 bool unclipped = false; |
|
4718 if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate |
4722 if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate |
4719 && painter->worldTransform().type() <= QTransform::TxTranslate) |
4723 && painter->worldTransform().type() <= QTransform::TxTranslate) |
4720 { |
4724 { |
4721 QRectF itemRect = item->boundingRect(); |
4725 QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates); |
4722 if (!item->d_ptr->children.isEmpty()) |
4726 QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect); |
4723 itemRect |= item->childrenBoundingRect(); |
4727 |
4724 |
4728 sourced->setCachedOffset(effectRect.topLeft()); |
4725 QRectF oldSourceRect = sourced->lastEffectTransform.mapRect(itemRect); |
4729 } else { |
4726 QRectF newSourceRect = painter->worldTransform().mapRect(itemRect); |
4730 sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged); |
4727 |
|
4728 QRect oldEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), oldSourceRect); |
|
4729 QRect newEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), newSourceRect); |
|
4730 |
|
4731 QRect deviceRect(0, 0, painter->device()->width(), painter->device()->height()); |
|
4732 if (deviceRect.contains(oldEffectRect) && deviceRect.contains(newEffectRect)) { |
|
4733 sourced->setCachedOffset(newEffectRect.topLeft()); |
|
4734 unclipped = true; |
|
4735 } |
|
4736 } |
4731 } |
4737 |
4732 |
4738 sourced->lastEffectTransform = painter->worldTransform(); |
4733 sourced->lastEffectTransform = painter->worldTransform(); |
4739 |
|
4740 if (!unclipped) |
|
4741 sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged); |
|
4742 } |
4734 } |
4743 |
4735 |
4744 item->d_ptr->graphicsEffect->draw(painter); |
4736 item->d_ptr->graphicsEffect->draw(painter); |
4745 painter->setWorldTransform(restoreTransform); |
4737 painter->setWorldTransform(restoreTransform); |
4746 sourced->info = 0; |
4738 sourced->info = 0; |