Drop ENABLE_IMAGE_DECODER_DOWN_SAMPLING code
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Nov 2017 06:54:50 +0000 (06:54 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Nov 2017 06:54:50 +0000 (06:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179921

Reviewed by Carlos Garcia Campos.

.:

* Source/cmake/WebKitFeatures.cmake: Remove the CMake option that
enabled IMAGE_DECODER_DOWN_SAMPLING code.

Source/WebCore:

Drop the ENABLE_IMAGE_DECODER_DOWN_SAMPLING code, along with the build
guard definitions in WTF and CMake.

This was apparently in use in the Qt port, but since then no port
enables this. It's not exposed in the Xcode build, and the CMake option
is disabled by default, with no way to enable it through build-webkit.

While the code guarded with this build guard is removed, there's still
code in the ScalableImageDecoder class that only operated when this
feature was enabled. This should be addressed in the future, after
evaluating the need for this scaling capability.

No new tests -- no change in behavior.

* platform/graphics/Image.cpp:
(WebCore::Image::adjustSourceRectForDownSampling const): Deleted.
* platform/graphics/Image.h:
* platform/graphics/cairo/CairoOperations.cpp:
(WebCore::Cairo::drawNativeImage):
* platform/image-decoders/ScalableImageDecoder.h:
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageReader::decode):
* platform/image-decoders/png/PNGImageDecoder.cpp:
(WebCore::PNGImageDecoder::rowAvailable):
(WebCore::PNGImageDecoder::frameComplete):

Source/WTF:

* wtf/FeatureDefines.h: Remove the ENABLE_IMAGE_DECODER_DOWN_SAMPLING
definition.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225091 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Image.cpp
Source/WebCore/platform/graphics/Image.h
Source/WebCore/platform/graphics/cairo/CairoOperations.cpp
Source/WebCore/platform/image-decoders/ScalableImageDecoder.h
Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp
Source/cmake/WebKitFeatures.cmake

index 04fa31c..7b5bb0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-11-21  Zan Dobersek  <zdobersek@igalia.com>
+
+        Drop ENABLE_IMAGE_DECODER_DOWN_SAMPLING code
+        https://bugs.webkit.org/show_bug.cgi?id=179921
+
+        Reviewed by Carlos Garcia Campos.
+
+        * Source/cmake/WebKitFeatures.cmake: Remove the CMake option that
+        enabled IMAGE_DECODER_DOWN_SAMPLING code.
+
 2017-11-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Update OptionsGTK.cmake and NEWS for 2.19.2 release.
index f161354..baa1a7a 100644 (file)
@@ -1,3 +1,13 @@
+2017-11-21  Zan Dobersek  <zdobersek@igalia.com>
+
+        Drop ENABLE_IMAGE_DECODER_DOWN_SAMPLING code
+        https://bugs.webkit.org/show_bug.cgi?id=179921
+
+        Reviewed by Carlos Garcia Campos.
+
+        * wtf/FeatureDefines.h: Remove the ENABLE_IMAGE_DECODER_DOWN_SAMPLING
+        definition.
+
 2017-11-19  Tim Horton  <timothy_horton@apple.com>
 
         Remove unused TOUCH_ICON_LOADING feature flag
index 1b3880e..8c3028e 100644 (file)
@@ -420,10 +420,6 @@ the public iOS SDK. See <https://webkit.org/b/179167>. */
 #define ENABLE_ICONDATABASE 1
 #endif
 
-#if !defined(ENABLE_IMAGE_DECODER_DOWN_SAMPLING)
-#define ENABLE_IMAGE_DECODER_DOWN_SAMPLING 0
-#endif
-
 #if !defined(ENABLE_INDEXED_DATABASE)
 #define ENABLE_INDEXED_DATABASE 0
 #endif
index b2a8c43..8bb28eb 100644 (file)
@@ -1,3 +1,36 @@
+2017-11-21  Zan Dobersek  <zdobersek@igalia.com>
+
+        Drop ENABLE_IMAGE_DECODER_DOWN_SAMPLING code
+        https://bugs.webkit.org/show_bug.cgi?id=179921
+
+        Reviewed by Carlos Garcia Campos.
+
+        Drop the ENABLE_IMAGE_DECODER_DOWN_SAMPLING code, along with the build
+        guard definitions in WTF and CMake.
+
+        This was apparently in use in the Qt port, but since then no port
+        enables this. It's not exposed in the Xcode build, and the CMake option
+        is disabled by default, with no way to enable it through build-webkit.
+
+        While the code guarded with this build guard is removed, there's still
+        code in the ScalableImageDecoder class that only operated when this
+        feature was enabled. This should be addressed in the future, after
+        evaluating the need for this scaling capability.
+
+        No new tests -- no change in behavior.
+
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::adjustSourceRectForDownSampling const): Deleted.
+        * platform/graphics/Image.h:
+        * platform/graphics/cairo/CairoOperations.cpp:
+        (WebCore::Cairo::drawNativeImage):
+        * platform/image-decoders/ScalableImageDecoder.h:
+        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+        (WebCore::JPEGImageReader::decode):
+        * platform/image-decoders/png/PNGImageDecoder.cpp:
+        (WebCore::PNGImageDecoder::rowAvailable):
+        (WebCore::PNGImageDecoder::frameComplete):
+
 2017-11-21  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r225089.
index 2f80ea7..7b9b6a3 100644 (file)
@@ -301,23 +301,6 @@ ImageDrawResult Image::drawTiled(GraphicsContext& ctxt, const FloatRect& dstRect
     return ImageDrawResult::DidDraw;
 }
 
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-FloatRect Image::adjustSourceRectForDownSampling(const FloatRect& srcRect, const IntSize& scaledSize) const
-{
-    const FloatSize unscaledSize = size();
-    if (unscaledSize == scaledSize)
-        return srcRect;
-
-    // Image has been down-sampled.
-    float xscale = static_cast<float>(scaledSize.width()) / unscaledSize.width();
-    float yscale = static_cast<float>(scaledSize.height()) / unscaledSize.height();
-    FloatRect scaledSrcRect = srcRect;
-    scaledSrcRect.scale(xscale, yscale);
-
-    return scaledSrcRect;
-}
-#endif
-
 void Image::computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio)
 {
 #if PLATFORM(IOS)
index 54a4f3b..d9a46da 100644 (file)
@@ -176,10 +176,6 @@ public:
     virtual void drawPattern(GraphicsContext&, const FloatRect& destRect, const FloatRect& srcRect, const AffineTransform& patternTransform,
         const FloatPoint& phase, const FloatSize& spacing, CompositeOperator, BlendMode = BlendModeNormal);
 
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-    FloatRect adjustSourceRectForDownSampling(const FloatRect& srcRect, const IntSize& scaledSize) const;
-#endif
-
 #if !ASSERT_DISABLED
     virtual bool notSolidColor() { return true; }
 #endif
index 439a389..2eca8e6 100644 (file)
@@ -656,15 +656,7 @@ void drawNativeImage(PlatformContextCairo& platformContext, cairo_surface_t* sur
     else
         Cairo::State::setCompositeOperation(platformContext, compositeOperator, blendMode);
 
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-    IntSize scaledSize = nativeImageSize(surface);
-    FloatRect src = adjustSourceRectForDownSampling(srcRect, scaledSize);
-#else
-    FloatRect src(srcRect);
-#endif
-
     FloatRect dst = destRect;
-
     if (orientation != DefaultImageOrientation) {
         // ImageOrientation expects the origin to be at (0, 0).
         Cairo::translate(platformContext, dst.x(), dst.y());
@@ -677,7 +669,7 @@ void drawNativeImage(PlatformContextCairo& platformContext, cairo_surface_t* sur
         }
     }
 
-    platformContext.drawSurfaceToContext(surface, dst, src, targetContext);
+    platformContext.drawSurfaceToContext(surface, dst, srcRect, targetContext);
     platformContext.restore();
 }
 
index ecf140c..7545262 100644 (file)
@@ -42,10 +42,7 @@ namespace WebCore {
 
 // ScalableImageDecoder is a base for all format-specific decoders
 // (e.g. JPEGImageDecoder). This base manages the ImageFrame cache.
-//
-// ENABLE(IMAGE_DECODER_DOWN_SAMPLING) allows image decoders to downsample
-// at decode time. Image decoders will downsample any images larger than
-// |m_maxNumPixels|. FIXME: Not yet supported by all decoders.
+
 class ScalableImageDecoder : public ImageDecoder {
     WTF_MAKE_NONCOPYABLE(ScalableImageDecoder); WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -221,11 +218,12 @@ private:
     IntSize m_size;
     EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::TypeAvailable };
     bool m_decodingSizeFromSetData { false };
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-    static const int m_maxNumPixels { 1024 * 1024 };
-#else
+
+    // FIXME: Evaluate the need for decoded data scaling. m_scaled,
+    // m_scaledColumns and m_scaledRows are member variables that are
+    // affected by this value, and are not used at all since the value
+    // is negavite (see prepareScaleDataIfNecessary()).
     static const int m_maxNumPixels { -1 };
-#endif
 };
 
 } // namespace WebCore
index fbc1b4a..4583cfd 100644 (file)
@@ -327,12 +327,6 @@ public:
 
             m_decoder->setOrientation(readImageOrientation(info()));
 
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING) && defined(TURBO_JPEG_RGB_SWIZZLE)
-            // There's no point swizzle decoding if image down sampling will
-            // be applied. Revert to using JSC_RGB in that case.
-            if (m_decoder->willDownSample() && turboSwizzled(m_info.out_color_space))
-                m_info.out_color_space = JCS_RGB;
-#endif
             // Don't allocate a giant and superfluous memory buffer when the
             // image is a sequential JPEG.
             m_info.buffered_image = jpeg_has_multiple_scans(&m_info);
index a1d5a47..bb3fd2d 100644 (file)
@@ -517,28 +517,16 @@ void PNGImageDecoder::rowAvailable(unsigned char* rowBuffer, unsigned rowIndex,
     int width = scaledSize().width();
     unsigned char nonTrivialAlphaMask = 0;
 
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-    if (m_scaled) {
-        for (int x = 0; x < width; ++x, ++address) {
-            png_bytep pixel = row + m_scaledColumns[x] * colorChannels;
-            unsigned alpha = hasAlpha ? pixel[3] : 255;
+    png_bytep pixel = row;
+    if (hasAlpha) {
+        for (int x = 0; x < width; ++x, pixel += 4, ++address) {
+            unsigned alpha = pixel[3];
             buffer.backingStore()->setPixel(address, pixel[0], pixel[1], pixel[2], alpha);
             nonTrivialAlphaMask |= (255 - alpha);
         }
-    } else
-#endif
-    {
-        png_bytep pixel = row;
-        if (hasAlpha) {
-            for (int x = 0; x < width; ++x, pixel += 4, ++address) {
-                unsigned alpha = pixel[3];
-                buffer.backingStore()->setPixel(address, pixel[0], pixel[1], pixel[2], alpha);
-                nonTrivialAlphaMask |= (255 - alpha);
-            }
-        } else {
-            for (int x = 0; x < width; ++x, pixel += 3, ++address)
-                *address = makeRGB(pixel[0], pixel[1], pixel[2]);
-        }
+    } else {
+        for (int x = 0; x < width; ++x, pixel += 3, ++address)
+            *address = makeRGB(pixel[0], pixel[1], pixel[2]);
     }
 
     if (nonTrivialAlphaMask && !buffer.hasAlpha())
@@ -835,21 +823,6 @@ void PNGImageDecoder::frameComplete()
         if (m_blend && !hasAlpha)
             m_blend = 0;
 
-#if ENABLE(IMAGE_DECODER_DOWN_SAMPLING)
-        for (int y = 0; y < rect.maxY() - rect.y(); ++y) {
-            png_bytep row = interlaceBuffer + (m_scaled ? m_scaledRows[y] : y) * colorChannels * size().width();
-            RGBA32* address = buffer.backingStore()->pixelAt(rect.x(), y + rect.y());
-            for (int x = 0; x < rect.maxX() - rect.x(); ++x) {
-                png_bytep pixel = row + (m_scaled ? m_scaledColumns[x] : x) * colorChannels;
-                unsigned alpha = hasAlpha ? pixel[3] : 255;
-                nonTrivialAlpha |= alpha < 255;
-                if (!m_blend)
-                    buffer.backingStore()->setPixel(address++, pixel[0], pixel[1], pixel[2], alpha);
-                else
-                    buffer.backingStore()->blendPixel(address++, pixel[0], pixel[1], pixel[2], alpha);
-            }
-        }
-#else
         ASSERT(!m_scaled);
         png_bytep row = interlaceBuffer;
         for (int y = rect.y(); y < rect.maxY(); ++y, row += colorChannels * size().width()) {
@@ -864,7 +837,6 @@ void PNGImageDecoder::frameComplete()
                     buffer.backingStore()->blendPixel(address++, pixel[0], pixel[1], pixel[2], alpha);
             }
         }
-#endif
 
         if (!nonTrivialAlpha) {
             IntRect rect = buffer.backingStore()->frameRect();
index 855aec0..022cdd8 100644 (file)
@@ -112,7 +112,6 @@ macro(WEBKIT_OPTION_BEGIN)
     WEBKIT_OPTION_DEFINE(ENABLE_GAMEPAD "Toggle Gamepad support" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_GEOLOCATION "Toggle Geolocation support" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_ICONDATABASE "Toggle Icon database support" PRIVATE ON)
-    WEBKIT_OPTION_DEFINE(ENABLE_IMAGE_DECODER_DOWN_SAMPLING "Toggle image decoder down sampling support" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_INDEXED_DATABASE "Toggle Indexed Database API support" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_INDEXED_DATABASE_IN_WORKERS "Toggle support for indexed database in workers" PRIVATE OFF)
     WEBKIT_OPTION_DEFINE(ENABLE_INDIE_UI "Toggle Indie UI support" PRIVATE OFF)