diff options
Diffstat (limited to 'WebCore/platform/graphics/qt/ImageQt.cpp')
-rw-r--r-- | WebCore/platform/graphics/qt/ImageQt.cpp | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/WebCore/platform/graphics/qt/ImageQt.cpp b/WebCore/platform/graphics/qt/ImageQt.cpp index 99062f9..3bc67ae 100644 --- a/WebCore/platform/graphics/qt/ImageQt.cpp +++ b/WebCore/platform/graphics/qt/ImageQt.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2006 Dirk Mueller <mueller@kde.org> * Copyright (C) 2006 Zack Rusin <zack@kde.org> * Copyright (C) 2006 Simon Hausmann <hausmann@kde.org> + * Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ * * All rights reserved. * @@ -96,7 +97,26 @@ PassRefPtr<Image> Image::loadPlatformResource(const char* name) void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const TransformationMatrix& patternTransform, const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect) { - notImplemented(); + QPixmap* framePixmap = nativeImageForCurrentFrame(); + if (!framePixmap) // If it's too early we won't have an image yet. + return; + + QPixmap pixmap = *framePixmap; + QRect tr = QRectF(tileRect).toRect(); + if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height()) { + pixmap = pixmap.copy(tr); + } + + QBrush b(pixmap); + b.setTransform(patternTransform); + ctxt->save(); + ctxt->setCompositeOperation(op); + QPainter* p = ctxt->platformContext(); + if (!pixmap.hasAlpha() && p->compositionMode() == QPainter::CompositionMode_SourceOver) + p->setCompositionMode(QPainter::CompositionMode_Source); + p->setBrushOrigin(phase); + p->fillRect(destRect, b); + ctxt->restore(); } void BitmapImage::initPlatformData() @@ -131,6 +151,9 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, QPainter* painter(ctxt->platformContext()); + if (!image->hasAlpha() && painter->compositionMode() == QPainter::CompositionMode_SourceOver) + painter->setCompositionMode(QPainter::CompositionMode_Source); + // Test using example site at // http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html painter->drawPixmap(dst, *image, src); @@ -138,33 +161,20 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dst, ctxt->restore(); } -void BitmapImage::drawPattern(GraphicsContext* ctxt, const FloatRect& tileRect, const TransformationMatrix& patternTransform, - const FloatPoint& phase, CompositeOperator op, const FloatRect& destRect) +void BitmapImage::checkForSolidColor() { - QPixmap* framePixmap = nativeImageForCurrentFrame(); - if (!framePixmap) // If it's too early we won't have an image yet. - return; + m_isSolidColor = false; + m_checkedForSolidColor = true; - QPixmap pixmap = *framePixmap; - QRect tr = QRectF(tileRect).toRect(); - if (tr.x() || tr.y() || tr.width() != pixmap.width() || tr.height() != pixmap.height()) { - pixmap = pixmap.copy(tr); - } + if (frameCount() > 1) + return; - QBrush b(pixmap); - b.setMatrix(patternTransform); - ctxt->save(); - ctxt->setCompositeOperation(op); - QPainter* p = ctxt->platformContext(); - p->setBrushOrigin(phase); - p->fillRect(destRect, b); - ctxt->restore(); -} + QPixmap* framePixmap = frameAtIndex(0); + if (!framePixmap || framePixmap->width() != 1 || framePixmap->height() != 1) + return; -void BitmapImage::checkForSolidColor() -{ - // FIXME: It's easy to implement this optimization. Just need to check the RGBA32 buffer to see if it is 1x1. - m_isSolidColor = false; + m_isSolidColor = true; + m_solidColor = QColor::fromRgba(framePixmap->toImage().pixel(0, 0)); } } |