Changeset 59668 in webkit
- Timestamp:
- May 18, 2010 6:25:04 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r59667 r59668 1 2010-05-18 Zoltan Herczeg <zherczeg@webkit.org> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Implementing clipToImageBuffer for Qt port. 6 https://bugs.webkit.org/show_bug.cgi?id=24289 7 8 The implementation combines pixmap layers and destinationIn 9 composition mode. 10 11 * platform/graphics/qt/GraphicsContextQt.cpp: 12 (WebCore::TransparencyLayer::TransparencyLayer): 13 (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate): 14 (WebCore::GraphicsContext::savePlatformState): 15 (WebCore::GraphicsContext::restorePlatformState): 16 (WebCore::GraphicsContext::inTransparencyLayer): 17 (WebCore::GraphicsContext::beginTransparencyLayer): 18 (WebCore::GraphicsContext::endTransparencyLayer): 19 (WebCore::GraphicsContext::clipToImageBuffer): 20 1 21 2010-05-18 Eric Seidel <eric@webkit.org> 2 22 -
trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r58949 r59668 168 168 169 169 struct TransparencyLayer : FastAllocBase { 170 TransparencyLayer(const QPainter* p, const QRect &rect )170 TransparencyLayer(const QPainter* p, const QRect &rect, qreal opacity, QPixmap& alphaMask) 171 171 : pixmap(rect.width(), rect.height()) 172 , opacity(opacity) 173 , alphaMask(alphaMask) 174 , saveCounter(1) // see the comment for saveCounter 172 175 { 173 176 offset = rect.topLeft(); … … 183 186 if (painter.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) 184 187 painter.setCompositionMode(p->compositionMode()); 185 painter.setClipPath(p->clipPath()); 188 // if the path is an empty region, this assignment disables all painting 189 if (!p->clipPath().isEmpty()) 190 painter.setClipPath(p->clipPath()); 186 191 } 187 192 … … 194 199 QPainter painter; 195 200 qreal opacity; 201 // for clipToImageBuffer 202 QPixmap alphaMask; 203 // saveCounter is only used in combination with alphaMask 204 // otherwise, its value is unspecified 205 int saveCounter; 196 206 private: 197 207 TransparencyLayer(const TransparencyLayer &) {} … … 218 228 219 229 QStack<TransparencyLayer*> layers; 230 // Counting real layers. Required by inTransparencyLayer() calls 231 // For example, layers with valid alphaMask are not real layers 232 int layerCount; 220 233 QPainter* redirect; 221 234 … … 236 249 { 237 250 painter = p; 251 layerCount = 0; 238 252 redirect = 0; 239 253 … … 290 304 void GraphicsContext::savePlatformState() 291 305 { 306 if (!m_data->layers.isEmpty() && !m_data->layers.top()->alphaMask.isNull()) 307 ++m_data->layers.top()->saveCounter; 292 308 m_data->p()->save(); 293 309 } … … 295 311 void GraphicsContext::restorePlatformState() 296 312 { 313 if (!m_data->layers.isEmpty() && !m_data->layers.top()->alphaMask.isNull()) 314 if (!--m_data->layers.top()->saveCounter) 315 endTransparencyLayer(); 316 297 317 m_data->p()->restore(); 298 318 … … 679 699 bool GraphicsContext::inTransparencyLayer() const 680 700 { 681 return !m_data->layers.isEmpty();701 return m_data->layerCount; 682 702 } 683 703 … … 838 858 h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2); 839 859 840 TransparencyLayer * layer = new TransparencyLayer(m_data->p(), QRect(x, y, w, h)); 841 842 layer->opacity = opacity; 843 m_data->layers.push(layer); 860 QPixmap emptyAlphaMask; 861 m_data->layers.push(new TransparencyLayer(m_data->p(), QRect(x, y, w, h), opacity, emptyAlphaMask)); 862 ++m_data->layerCount; 844 863 } 845 864 … … 850 869 851 870 TransparencyLayer* layer = m_data->layers.pop(); 871 if (!layer->alphaMask.isNull()) { 872 layer->painter.resetTransform(); 873 layer->painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); 874 layer->painter.drawPixmap(QPoint(), layer->alphaMask); 875 } else 876 --m_data->layerCount; // see the comment for layerCount 852 877 layer->painter.end(); 853 878 … … 1087 1112 } 1088 1113 1089 void GraphicsContext::clipToImageBuffer(const FloatRect&, const ImageBuffer*) 1090 { 1091 notImplemented(); 1114 void GraphicsContext::clipToImageBuffer(const FloatRect& floatRect, const ImageBuffer* image) 1115 { 1116 if (paintingDisabled()) 1117 return; 1118 1119 QPixmap* nativeImage = image->image()->nativeImageForCurrentFrame(); 1120 if (!nativeImage) 1121 return; 1122 1123 IntRect rect(floatRect); 1124 QPixmap alphaMask = *nativeImage; 1125 if (alphaMask.width() != rect.width() || alphaMask.height() != rect.height()) 1126 alphaMask = alphaMask.scaled(rect.width(), rect.height()); 1127 1128 m_data->layers.push(new TransparencyLayer(m_data->p(), rect, 1.0, alphaMask)); 1092 1129 } 1093 1130
Note: See TracChangeset
for help on using the changeset viewer.