summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang Zengbo <zengbo.zhang@gmail.com>2014-06-17 18:12:24 +0800
committerZhang Zengbo <zengbo.zhang@gmail.com>2014-06-20 08:49:32 +0200
commitf45e84c4cb9b8837122eac3583d13f6f80f89ce5 (patch)
tree6f705cfb03c9b7935834efbb6e62092e6a821104
parentfb4fba15c7b3ad4b50403c030cbb2dc54f3a9768 (diff)
downloadqtwebkit-f45e84c4cb9b8837122eac3583d13f6f80f89ce5.tar.gz
GraphicsContext for Qt: add popTransparencyLayerInternal method.
It is harmful to just call endPlatformTransparencyLayer inside GraphicsContextQt.cpp,because the three calling sequences: 1. beginPlatformTransparenceyLayer endPlatformTransparencyLayer 2. pushTransparencyLayerInternal 3. savePlatformState restorePlatformState may interleave, which makes unexpected result. Task-number: QTBUG-39577 Change-Id: I676a85cd5210e0f944cf6b522dd21deec06f03bc Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
-rw-r--r--Source/WebCore/platform/graphics/GraphicsContext.h1
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp33
2 files changed, 27 insertions, 7 deletions
diff --git a/Source/WebCore/platform/graphics/GraphicsContext.h b/Source/WebCore/platform/graphics/GraphicsContext.h
index 9c5f4da19..2fd032f02 100644
--- a/Source/WebCore/platform/graphics/GraphicsContext.h
+++ b/Source/WebCore/platform/graphics/GraphicsContext.h
@@ -482,6 +482,7 @@ namespace WebCore {
#if PLATFORM(QT)
void pushTransparencyLayerInternal(const QRect&, qreal, QPixmap&);
+ void popTransparencyLayerInternal();
void takeOwnershipOfPlatformContext();
#endif
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index ffd88804a..f62ac6400 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -391,7 +391,7 @@ void GraphicsContext::restorePlatformState()
{
if (!m_data->layers.isEmpty() && !m_data->layers.top()->alphaMask.isNull())
if (!--m_data->layers.top()->saveCounter)
- endPlatformTransparencyLayer();
+ popTransparencyLayerInternal();
m_data->p()->restore();
}
@@ -1269,18 +1269,37 @@ void GraphicsContext::beginPlatformTransparencyLayer(float opacity)
++m_data->layerCount;
}
+void GraphicsContext::popTransparencyLayerInternal()
+{
+ TransparencyLayer* layer = m_data->layers.pop();
+ ASSERT(!layer->alphaMask.isNull());
+ ASSERT(layer->saveCounter == 0);
+ layer->painter.resetTransform();
+ layer->painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ layer->painter.drawPixmap(QPoint(), layer->alphaMask);
+ layer->painter.end();
+
+ QPainter* p = m_data->p();
+ p->save();
+ p->resetTransform();
+ p->setOpacity(layer->opacity);
+ p->drawPixmap(layer->offset, layer->pixmap);
+ p->restore();
+
+ delete layer;
+}
+
void GraphicsContext::endPlatformTransparencyLayer()
{
if (paintingDisabled())
return;
+ while ( ! m_data->layers.top()->alphaMask.isNull() ){
+ --m_data->layers.top()->saveCounter;
+ popTransparencyLayerInternal();
+ }
TransparencyLayer* layer = m_data->layers.pop();
- if (!layer->alphaMask.isNull()) {
- layer->painter.resetTransform();
- layer->painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- layer->painter.drawPixmap(QPoint(), layer->alphaMask);
- } else
- --m_data->layerCount; // see the comment for layerCount
+ --m_data->layerCount; // see the comment for layerCount
layer->painter.end();
QPainter* p = m_data->p();