[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
ariya at webkit.org
ariya at webkit.org
Wed Dec 22 12:19:18 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 36eb3343047d9922f87f762a721d8da58bf9ffdd
Author: ariya at webkit.org <ariya at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Aug 19 05:59:53 2010 +0000
[Qt] Short lived shadow buffer for blur operation
https://bugs.webkit.org/show_bug.cgi?id=44094
Patch by Ariya Hidayat <ariya at sencha.com> on 2010-08-18
Reviewed by Kenneth Rohde Christiansen.
ContextShadow needs a scratch image as the buffer for the blur filter.
Instead of creating and destroying the buffer for every operation,
we create a buffer which will be automatically purged via a timer.
* platform/graphics/qt/ContextShadow.cpp:
(WebCore::):
(WebCore::ShadowBuffer::ShadowBuffer):
(WebCore::ShadowBuffer::scratchImage):
(WebCore::ShadowBuffer::schedulePurge):
(WebCore::ShadowBuffer::purgeBuffer):
(WebCore::ContextShadow::drawShadowRect):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65654 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index adc7b9d..9e8d269 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-08-18 Ariya Hidayat <ariya at sencha.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Short lived shadow buffer for blur operation
+ https://bugs.webkit.org/show_bug.cgi?id=44094
+
+ ContextShadow needs a scratch image as the buffer for the blur filter.
+ Instead of creating and destroying the buffer for every operation,
+ we create a buffer which will be automatically purged via a timer.
+
+ * platform/graphics/qt/ContextShadow.cpp:
+ (WebCore::):
+ (WebCore::ShadowBuffer::ShadowBuffer):
+ (WebCore::ShadowBuffer::scratchImage):
+ (WebCore::ShadowBuffer::schedulePurge):
+ (WebCore::ShadowBuffer::purgeBuffer):
+ (WebCore::ContextShadow::drawShadowRect):
+
2010-08-18 Alexey Marinichev <amarinichev at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebCore/platform/graphics/qt/ContextShadow.cpp b/WebCore/platform/graphics/qt/ContextShadow.cpp
index 0511218..80b17f9 100644
--- a/WebCore/platform/graphics/qt/ContextShadow.cpp
+++ b/WebCore/platform/graphics/qt/ContextShadow.cpp
@@ -28,8 +28,72 @@
#include "config.h"
#include "ContextShadow.h"
+#include "Timer.h"
+#include <wtf/Noncopyable.h>
+
namespace WebCore {
+// ContextShadow needs a scratch image as the buffer for the blur filter.
+// Instead of creating and destroying the buffer for every operation,
+// we create a buffer which will be automatically purged via a timer.
+
+class ShadowBuffer: public Noncopyable {
+public:
+ ShadowBuffer();
+
+ QImage* scratchImage(const QSize& size);
+
+ void schedulePurge();
+
+private:
+ QImage image;
+ void purgeBuffer(Timer<ShadowBuffer>*);
+ Timer<ShadowBuffer> purgeTimer;
+};
+
+ShadowBuffer::ShadowBuffer()
+ : purgeTimer(this, &ShadowBuffer::purgeBuffer)
+{
+}
+
+QImage* ShadowBuffer::scratchImage(const QSize& size)
+{
+ int width = size.width();
+ int height = size.height();
+
+ // We do not need to recreate the buffer if the buffer is reasonably
+ // larger than the requested size. However, if the requested size is
+ // much smaller than our buffer, reduce our buffer so that we will not
+ // keep too many allocated pixels for too long.
+ if (!image.isNull() && (image.width() > width) && (image.height() > height))
+ if (((2 * width) > image.width()) && ((2 * height) > image.height())) {
+ image.fill(Qt::transparent);
+ return ℑ
+ }
+
+ // Round to the nearest 32 pixels so we do not grow the buffer everytime
+ // there is larger request by 1 pixel.
+ width = (1 + (width >> 5)) << 5;
+ height = (1 + (height >> 5)) << 5;
+
+ image = QImage(width, height, QImage::Format_ARGB32_Premultiplied);
+ image.fill(Qt::transparent);
+ return ℑ
+}
+
+void ShadowBuffer::schedulePurge()
+{
+ static const double BufferPurgeDelay = 2; // seconds
+ purgeTimer.startOneShot(BufferPurgeDelay);
+}
+
+void ShadowBuffer::purgeBuffer(Timer<ShadowBuffer>*)
+{
+ image = QImage();
+}
+
+Q_GLOBAL_STATIC(ShadowBuffer, scratchShadowBuffer)
+
ContextShadow::ContextShadow()
: type(NoShadow)
, blurRadius(0)
@@ -235,16 +299,18 @@ void ContextShadow::drawShadowRect(QPainter* p, const QRectF& rect)
alignedBufferRect.adjust(-extra, -extra, extra, extra);
}
- QImage shadowImage(alignedBufferRect.size(), QImage::Format_ARGB32_Premultiplied);
- shadowImage.fill(Qt::transparent);
- QPainter shadowPainter(&shadowImage);
+ ShadowBuffer* shadowBuffer = scratchShadowBuffer();
+ QImage* shadowImage = shadowBuffer->scratchImage(alignedBufferRect.size());
+ QPainter shadowPainter(shadowImage);
shadowPainter.fillRect(shadowRect.translated(-alignedBufferRect.topLeft()), color);
shadowPainter.end();
- shadowBlur(shadowImage, blurRadius, color);
+ shadowBlur(*shadowImage, blurRadius, color);
+
+ p->drawImage(alignedBufferRect.topLeft(), *shadowImage);
- p->drawImage(alignedBufferRect.topLeft(), shadowImage);
+ shadowBuffer->schedulePurge();
return;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list