diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/rendering/ImageQualityController.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/rendering/ImageQualityController.cpp')
-rw-r--r-- | Source/WebCore/rendering/ImageQualityController.cpp | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/Source/WebCore/rendering/ImageQualityController.cpp b/Source/WebCore/rendering/ImageQualityController.cpp index 4ecd85a61..e82eed6dc 100644 --- a/Source/WebCore/rendering/ImageQualityController.cpp +++ b/Source/WebCore/rendering/ImageQualityController.cpp @@ -39,7 +39,9 @@ static const double cLowQualityTimeThreshold = 0.500; // 500 ms ImageQualityController::ImageQualityController(const RenderView& renderView) : m_renderView(renderView) - , m_timer(*this, &ImageQualityController::highQualityRepaintTimerFired) + , m_timer(this, &ImageQualityController::highQualityRepaintTimerFired) + , m_animatedResizeIsActive(false) + , m_liveResizeOptimizationIsActive(false) { } @@ -72,7 +74,7 @@ void ImageQualityController::removeObject(RenderBoxModelObject* object) } } -void ImageQualityController::highQualityRepaintTimerFired() +void ImageQualityController::highQualityRepaintTimerFired(Timer<ImageQualityController>&) { if (m_renderView.documentBeingDestroyed()) return; @@ -97,34 +99,26 @@ void ImageQualityController::restartTimer() m_timer.startOneShot(cLowQualityTimeThreshold); } -Optional<InterpolationQuality> ImageQualityController::interpolationQualityFromStyle(const RenderStyle& style) +bool ImageQualityController::shouldPaintAtLowQuality(GraphicsContext* context, RenderBoxModelObject* object, Image* image, const void *layer, const LayoutSize& size) { - switch (style.imageRendering()) { + // If the image is not a bitmap image, then none of this is relevant and we just paint at high + // quality. + if (!image || !(image->isBitmapImage() || image->isPDFDocumentImage()) || context->paintingDisabled()) + return false; + + switch (object->style().imageRendering()) { case ImageRenderingOptimizeSpeed: - return InterpolationLow; case ImageRenderingCrispEdges: - case ImageRenderingPixelated: - return InterpolationNone; + return true; case ImageRenderingOptimizeQuality: - return InterpolationDefault; // FIXME: CSS 3 Images says that optimizeQuality should behave like 'auto', but that prevents authors from overriding this low quality rendering behavior. + return false; case ImageRenderingAuto: break; } - return Nullopt; -} - -InterpolationQuality ImageQualityController::chooseInterpolationQuality(GraphicsContext& context, RenderBoxModelObject* object, Image& image, const void *layer, const LayoutSize& size) -{ - // If the image is not a bitmap image, then none of this is relevant and we just paint at high quality. - if (!(image.isBitmapImage() || image.isPDFDocumentImage()) || context.paintingDisabled()) - return InterpolationDefault; - - if (Optional<InterpolationQuality> styleInterpolation = interpolationQualityFromStyle(object->style())) - return styleInterpolation.value(); // Make sure to use the unzoomed image size, since if a full page zoom is in effect, the image // is actually being scaled. - IntSize imageSize(image.width(), image.height()); + IntSize imageSize(image->width(), image->height()); // Look ourselves up in the hashtables. auto i = m_objectLayerSizeMap.find(object); @@ -146,32 +140,32 @@ InterpolationQuality ImageQualityController::chooseInterpolationQuality(Graphics set(object, innerMap, layer, size); restartTimer(); m_liveResizeOptimizationIsActive = true; - return InterpolationLow; + return true; } if (m_liveResizeOptimizationIsActive) - return InterpolationDefault; + return false; } - const AffineTransform& currentTransform = context.getCTM(); + const AffineTransform& currentTransform = context->getCTM(); bool contextIsScaled = !currentTransform.isIdentityOrTranslationOrFlipped(); if (!contextIsScaled && size == imageSize) { // There is no scale in effect. If we had a scale in effect before, we can just remove this object from the list. removeLayer(object, innerMap, layer); - return InterpolationDefault; + return false; } // There is no need to hash scaled images that always use low quality mode when the page demands it. This is the iChat case. if (m_renderView.frame().page()->inLowQualityImageInterpolationMode()) { - double totalPixels = static_cast<double>(image.width()) * static_cast<double>(image.height()); + double totalPixels = static_cast<double>(image->width()) * static_cast<double>(image->height()); if (totalPixels > cInterpolationCutoff) - return InterpolationLow; + return true; } // If an animated resize is active, paint in low quality and kick the timer ahead. if (m_animatedResizeIsActive) { set(object, innerMap, layer, size); restartTimer(); - return InterpolationLow; + return true; } // If this is the first time resizing this image, or its size is the // same as the last resize, draw at high res, but record the paint @@ -179,13 +173,13 @@ InterpolationQuality ImageQualityController::chooseInterpolationQuality(Graphics if (isFirstResize || oldSize == size) { restartTimer(); set(object, innerMap, layer, size); - return InterpolationDefault; + return false; } // If the timer is no longer active, draw at high quality and don't // set the timer. if (!m_timer.isActive()) { removeLayer(object, innerMap, layer); - return InterpolationDefault; + 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 @@ -193,7 +187,7 @@ InterpolationQuality ImageQualityController::chooseInterpolationQuality(Graphics set(object, innerMap, layer, size); m_animatedResizeIsActive = true; restartTimer(); - return InterpolationLow; + return true; } } |