diff options
author | Abdiel Janulgue <abdiel.janulgue@nokia.com> | 2010-07-21 01:08:23 +0300 |
---|---|---|
committer | Abdiel Janulgue <abdiel.janulgue@nokia.com> | 2010-07-21 01:08:23 +0300 |
commit | f5007f30eb96a256b5ef0b2a13473e01d1b33f8e (patch) | |
tree | 95dea31d4fddf4dc5dacf97839d38b81d0b491a1 /src/mtexturepixmapitem_glx.cpp | |
parent | ea02111b212af964e7d67ae4cb30d09367c1afcf (diff) |
Changes: merged merge req#9 with improvements and conflict resolution
RevBy: TrustMe
Diffstat (limited to 'src/mtexturepixmapitem_glx.cpp')
-rw-r--r-- | src/mtexturepixmapitem_glx.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/mtexturepixmapitem_glx.cpp b/src/mtexturepixmapitem_glx.cpp index e103c49..f2b3e94 100644 --- a/src/mtexturepixmapitem_glx.cpp +++ b/src/mtexturepixmapitem_glx.cpp @@ -88,7 +88,6 @@ void MTexturePixmapItem::init() if (isValid() && !pc->isMapped()) { qWarning("MTexturePixmapItem::%s(): Failed getting offscreen pixmap", __func__); - d->setValid(false); return; } else if (!isValid()) return; @@ -322,7 +321,43 @@ void MTexturePixmapItem::paint(QPainter *painter, glBindTexture(GL_TEXTURE_2D, d->custom_tfp ? d->ctextureId : d->textureId); - d->drawTexture(painter->combinedTransform(), boundingRect(), opacity()); + const QRegion &shape = propertyCache()->shapeRegion(); + bool shape_on = !QRegion(boundingRect().toRect()).subtracted(shape).isEmpty(); + bool scissor_on = d->damageRegion.numRects() > 1 || shape_on; + + if (scissor_on) + glEnable(GL_SCISSOR_TEST); + + // Damage regions taking precedence over shape rects + if (d->damageRegion.numRects() > 1) { + for (int i = 0; i < d->damageRegion.numRects(); ++i) { + glScissor(d->damageRegion.rects().at(i).x(), + d->brect.height() - + (d->damageRegion.rects().at(i).y() + + d->damageRegion.rects().at(i).height()), + d->damageRegion.rects().at(i).width(), + d->damageRegion.rects().at(i).height()); + d->drawTexture(painter->combinedTransform(), boundingRect(), opacity()); + } + } else if (shape_on) { + // draw a shaped window using glScissor + for (int i = 0; i < shape.numRects(); ++i) { + glScissor(shape.rects().at(i).x(), + d->brect.height() - + (shape.rects().at(i).y() + + shape.rects().at(i).height()), + shape.rects().at(i).width(), + shape.rects().at(i).height()); + d->drawTexture(painter->combinedTransform(), + boundingRect(), opacity()); + } + } else + d->drawTexture(painter->combinedTransform(), boundingRect(), opacity()); + + if (scissor_on) + glDisable(GL_SCISSOR_TEST); + + glDisable(GL_BLEND); #if (QT_VERSION >= 0x040600) painter->endNativePainting(); |