diff options
Diffstat (limited to 'WebCore/rendering/RenderBoxModelObject.cpp')
-rw-r--r-- | WebCore/rendering/RenderBoxModelObject.cpp | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/WebCore/rendering/RenderBoxModelObject.cpp b/WebCore/rendering/RenderBoxModelObject.cpp index 1580b49..bd19165 100644 --- a/WebCore/rendering/RenderBoxModelObject.cpp +++ b/WebCore/rendering/RenderBoxModelObject.cpp @@ -50,12 +50,14 @@ bool RenderBoxModelObject::s_layerWasSelfPainting = false; static const double cInterpolationCutoff = 800. * 800.; static const double cLowQualityTimeThreshold = 0.500; // 500 ms -typedef HashMap<RenderBoxModelObject*, IntSize> LastPaintSizeMap; +typedef pair<RenderBoxModelObject*, const void*> LastPaintSizeMapKey; +typedef HashMap<LastPaintSizeMapKey, IntSize> LastPaintSizeMap; class ImageQualityController : public Noncopyable { public: ImageQualityController(); - bool shouldPaintAtLowQuality(GraphicsContext*, RenderBoxModelObject*, Image*, const IntSize&); + bool shouldPaintAtLowQuality(GraphicsContext*, RenderBoxModelObject*, Image*, const void* layer, const IntSize&); + void keyDestroyed(LastPaintSizeMapKey key); void objectDestroyed(RenderBoxModelObject*); private: @@ -73,21 +75,31 @@ ImageQualityController::ImageQualityController() { } -void ImageQualityController::objectDestroyed(RenderBoxModelObject* object) +void ImageQualityController::keyDestroyed(LastPaintSizeMapKey key) { - m_lastPaintSizeMap.remove(object); + m_lastPaintSizeMap.remove(key); if (m_lastPaintSizeMap.isEmpty()) { m_animatedResizeIsActive = false; m_timer.stop(); } } +void ImageQualityController::objectDestroyed(RenderBoxModelObject* object) +{ + Vector<LastPaintSizeMapKey> keysToDie; + for (LastPaintSizeMap::iterator it = m_lastPaintSizeMap.begin(); it != m_lastPaintSizeMap.end(); ++it) + if (it->first.first == object) + keysToDie.append(it->first); + for (Vector<LastPaintSizeMapKey>::iterator it = keysToDie.begin(); it != keysToDie.end(); ++it) + keyDestroyed(*it); +} + void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityController>*) { if (m_animatedResizeIsActive) { m_animatedResizeIsActive = false; for (LastPaintSizeMap::iterator it = m_lastPaintSizeMap.begin(); it != m_lastPaintSizeMap.end(); ++it) - it->first->repaint(); + it->first.first->repaint(); } } @@ -96,7 +108,7 @@ void ImageQualityController::restartTimer() m_timer.startOneShot(cLowQualityTimeThreshold); } -bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, RenderBoxModelObject* object, Image* image, const IntSize& size) +bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, RenderBoxModelObject* object, Image* image, const void *layer, const IntSize& size) { // If the image is not a bitmap image, then none of this is relevant and we just paint at high // quality. @@ -108,14 +120,15 @@ bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R IntSize imageSize(image->width(), image->height()); // Look ourselves up in the hashtable. - LastPaintSizeMap::iterator i = m_lastPaintSizeMap.find(object); + LastPaintSizeMapKey key(object, layer); + LastPaintSizeMap::iterator i = m_lastPaintSizeMap.find(key); const AffineTransform& currentTransform = context->getCTM(); bool contextIsScaled = !currentTransform.isIdentityOrTranslationOrFlipped(); if (!contextIsScaled && imageSize == size) { // There is no scale in effect. If we had a scale in effect before, we can just remove this object from the list. if (i != m_lastPaintSizeMap.end()) - m_lastPaintSizeMap.remove(object); + m_lastPaintSizeMap.remove(key); return false; } @@ -128,7 +141,7 @@ bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R } // If an animated resize is active, paint in low quality and kick the timer ahead. if (m_animatedResizeIsActive) { - m_lastPaintSizeMap.set(object, size); + m_lastPaintSizeMap.set(key, size); restartTimer(); return true; } @@ -137,19 +150,19 @@ bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, R // size and set the timer. if (i == m_lastPaintSizeMap.end() || size == i->second) { restartTimer(); - m_lastPaintSizeMap.set(object, size); + m_lastPaintSizeMap.set(key, size); return false; } // If the timer is no longer active, draw at high quality and don't // set the timer. if (!m_timer.isActive()) { - objectDestroyed(object); + keyDestroyed(key); return false; } // This object has been resized to two different sizes while the timer // is active, so draw at low quality, set the flag for animated resizes and // the object to the list for high quality redraw. - m_lastPaintSizeMap.set(object, size); + m_lastPaintSizeMap.set(key, size); m_animatedResizeIsActive = true; restartTimer(); return true; @@ -183,9 +196,9 @@ void RenderBoxModelObject::setSelectionState(SelectionState s) cb->setSelectionState(s); } -bool RenderBoxModelObject::shouldPaintAtLowQuality(GraphicsContext* context, Image* image, const IntSize& size) +bool RenderBoxModelObject::shouldPaintAtLowQuality(GraphicsContext* context, Image* image, const void* layer, const IntSize& size) { - return imageQualityController()->shouldPaintAtLowQuality(context, this, image, size); + return imageQualityController()->shouldPaintAtLowQuality(context, this, image, layer, size); } RenderBoxModelObject::RenderBoxModelObject(Node* node) @@ -684,7 +697,7 @@ void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op; RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this; Image* image = bg->image(clientForBackgroundImage, tileSize); - bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, tileSize); + bool useLowQualityScaling = shouldPaintAtLowQuality(context, image, bgLayer, tileSize); context->drawTiledImage(image, style()->colorSpace(), destRect, phase, tileSize, compositeOp, useLowQualityScaling); } } @@ -1051,7 +1064,6 @@ void RenderBoxModelObject::paintBorder(GraphicsContext* graphicsContext, int tx, graphicsContext->addRoundedRectClip(borderRect, topLeft, topRight, bottomLeft, bottomRight); graphicsContext->clipOutRoundedRect(innerBorderRect, innerTopLeft, innerTopRight, innerBottomLeft, innerBottomRight); roundedPath.addRoundedRect(borderRect, topLeft, topRight, bottomLeft, bottomRight); - graphicsContext->addPath(roundedPath); } } @@ -1792,13 +1804,10 @@ void RenderBoxModelObject::paintBoxShadow(GraphicsContext* context, int tx, int } else path.addRect(holeRect); - context->beginPath(); - context->addPath(path); - context->setFillRule(RULE_EVENODD); context->setFillColor(fillColor, s->colorSpace()); context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace()); - context->fillPath(); + context->fillPath(path); context->restore(); } |