Title: [226390] trunk/Source/WebCore
Revision
226390
Author
[email protected]
Date
2018-01-03 20:39:33 -0800 (Wed, 03 Jan 2018)

Log Message

Remove the 'resolutionScale' parameter from ImageBufferDataCG get/putBytes
https://bugs.webkit.org/show_bug.cgi?id=181268

Reviewed by Alex Christensen.

These functions were always called with resolutionScale=1.

* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::getUnmultipliedImageData const):
(WebCore::ImageBuffer::getPremultipliedImageData const):
(WebCore::ImageBuffer::putByteArray):
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::getData const):
(WebCore::ImageBufferData::putData):
(WebCore::affineWarpBufferData): Deleted.
* platform/graphics/cg/ImageBufferDataCG.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (226389 => 226390)


--- trunk/Source/WebCore/ChangeLog	2018-01-04 04:21:58 UTC (rev 226389)
+++ trunk/Source/WebCore/ChangeLog	2018-01-04 04:39:33 UTC (rev 226390)
@@ -1,3 +1,22 @@
+2018-01-03  Simon Fraser  <[email protected]>
+
+        Remove the 'resolutionScale' parameter from ImageBufferDataCG get/putBytes
+        https://bugs.webkit.org/show_bug.cgi?id=181268
+
+        Reviewed by Alex Christensen.
+
+        These functions were always called with resolutionScale=1.
+
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::getUnmultipliedImageData const):
+        (WebCore::ImageBuffer::getPremultipliedImageData const):
+        (WebCore::ImageBuffer::putByteArray):
+        * platform/graphics/cg/ImageBufferDataCG.cpp:
+        (WebCore::ImageBufferData::getData const):
+        (WebCore::ImageBufferData::putData):
+        (WebCore::affineWarpBufferData): Deleted.
+        * platform/graphics/cg/ImageBufferDataCG.h:
+
 2018-01-03  John Wilander  <[email protected]>
 
         Storage Access API: Refactor XPC for access removal to go straight from the web process to the network process

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp (226389 => 226390)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2018-01-04 04:21:58 UTC (rev 226389)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2018-01-04 04:39:33 UTC (rev 226390)
@@ -397,7 +397,7 @@
     if (pixelArrayDimensions)
         *pixelArrayDimensions = srcRect.size();
 
-    return m_data.getData(AlphaPremultiplication::Unpremultiplied, srcRect, internalSize(), context().isAcceleratedContext(), 1);
+    return m_data.getData(AlphaPremultiplication::Unpremultiplied, srcRect, internalSize(), context().isAcceleratedContext());
 }
 
 RefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRect& rect, IntSize* pixelArrayDimensions, CoordinateSystem coordinateSystem) const
@@ -412,7 +412,7 @@
     if (pixelArrayDimensions)
         *pixelArrayDimensions = srcRect.size();
 
-    return m_data.getData(AlphaPremultiplication::Premultiplied, srcRect, internalSize(), context().isAcceleratedContext(), 1);
+    return m_data.getData(AlphaPremultiplication::Premultiplied, srcRect, internalSize(), context().isAcceleratedContext());
 }
 
 void ImageBuffer::putByteArray(const Uint8ClampedArray& source, AlphaPremultiplication sourceFormat, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem coordinateSystem)
@@ -427,7 +427,7 @@
         scaledSourceSize.scale(m_resolutionScale);
     }
 
-    m_data.putData(source, sourceFormat, scaledSourceSize, scaledSourceRect, destPoint, internalSize(), context().isAcceleratedContext(), 1);
+    m_data.putData(source, sourceFormat, scaledSourceSize, scaledSourceRect, destPoint, internalSize(), context().isAcceleratedContext());
     
     // Force recreating the IOSurface cached image if it is requested through CGIOSurfaceContextCreateImage().
     // See https://bugs.webkit.org/show_bug.cgi?id=157966 for explaining why this is necessary.

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp (226389 => 226390)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp	2018-01-04 04:21:58 UTC (rev 226389)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.cpp	2018-01-04 04:39:33 UTC (rev 226390)
@@ -51,8 +51,7 @@
 
 namespace WebCore {
 
-#if USE(ACCELERATE)
-#if USE_ARGB32 || USE(IOSURFACE_CANVAS_BACKING_STORE)
+#if USE(ACCELERATE) && (USE_ARGB32 || USE(IOSURFACE_CANVAS_BACKING_STORE))
 static void unpremultiplyBufferData(const vImage_Buffer& src, const vImage_Buffer& dest)
 {
     ASSERT(src.data);
@@ -78,21 +77,8 @@
     const uint8_t map[4] = { 2, 1, 0, 3 };
     vImagePermuteChannels_ARGB8888(&dest, &dest, map, kvImageNoFlags);
 }
-#endif // USE_ARGB32 || USE(IOSURFACE_CANVAS_BACKING_STORE)
+#endif // USE(ACCELERATE) && (USE_ARGB32 || USE(IOSURFACE_CANVAS_BACKING_STORE))
 
-#if !PLATFORM(IOS_SIMULATOR)
-static void affineWarpBufferData(const vImage_Buffer& src, const vImage_Buffer& dest, float scale)
-{
-    ASSERT(src.data);
-    ASSERT(dest.data);
-
-    vImage_AffineTransform scaleTransform = { scale, 0, 0, scale, 0, 0 }; // FIXME: Add subpixel translation.
-    Pixel_8888 backgroundColor;
-    vImageAffineWarp_ARGB8888(&src, &dest, 0, &scaleTransform, backgroundColor, kvImageEdgeExtend);
-}
-#endif // !PLATFORM(IOS_SIMULATOR)
-#endif // USE(ACCELERATE)
-
 static inline void transferData(void* output, void* input, int width, int height, size_t inputBytesPerRow)
 {
 #if USE(ACCELERATE)
@@ -139,8 +125,7 @@
     return result;
 }
 
-
-RefPtr<Uint8ClampedArray> ImageBufferData::getData(AlphaPremultiplication outputFormat, const IntRect& rect, const IntSize& size, bool accelerateRendering, float resolutionScale) const
+RefPtr<Uint8ClampedArray> ImageBufferData::getData(AlphaPremultiplication outputFormat, const IntRect& rect, const IntSize& size, bool accelerateRendering) const
 {
     Checked<unsigned, RecordOverflow> area = 4;
     area *= rect.width();
@@ -154,9 +139,7 @@
         return nullptr;
 
     Checked<int> endx = rect.maxX();
-    endx *= ceilf(resolutionScale);
     Checked<int> endy = rect.maxY();
-    endy *= resolutionScale;
     if (rect.x() < 0 || rect.y() < 0 || endx.unsafeGet() > size.width() || endy.unsafeGet() > size.height())
         result->zeroFill();
     
@@ -168,8 +151,7 @@
         destx = -originx;
         originx = 0;
     }
-    destw = std::min<int>(destw.unsafeGet(), ceilf(size.width() / resolutionScale) - originx);
-    originx *= resolutionScale;
+    destw = std::min<int>(destw.unsafeGet(), size.width() - originx);
     if (endx.unsafeGet() > size.width())
         endx = size.width();
     Checked<int> width = endx - originx;
@@ -182,8 +164,7 @@
         desty = -originy;
         originy = 0;
     }
-    desth = std::min<int>(desth.unsafeGet(), ceilf(size.height() / resolutionScale) - originy);
-    originy *= resolutionScale;
+    desth = std::min<int>(desth.unsafeGet(), size.height() - originy);
     if (endy.unsafeGet() > size.height())
         endy = size.height();
     Checked<int> height = endy - originy;
@@ -222,12 +203,6 @@
 #if USE_ARGB32
             unpremultiplyBufferData(src, dest);
 #else
-            if (resolutionScale != 1) {
-                affineWarpBufferData(src, dest, 1 / resolutionScale);
-                // The unpremultiplying will be done in-place.
-                src = ""
-            }
-
             vImageUnpremultiplyData_RGBA8888(&src, &dest, kvImageNoFlags);
 #endif
 
@@ -234,20 +209,6 @@
             return result;
         }
 #endif
-        if (resolutionScale != 1) {
-            RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
-            RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
-            CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
-            if (outputFormat == AlphaPremultiplication::Premultiplied)
-                return result;
-
-            srcRows = destRows;
-            srcBytesPerRow = destBytesPerRow;
-            width = destw;
-            height = desth;
-        }
         if (outputFormat == AlphaPremultiplication::Unpremultiplied) {
             if ((width * 4).hasOverflowed())
                 CRASH();
@@ -318,12 +279,6 @@
         dest.rowBytes = destBytesPerRow;
         dest.data = ""
 
-        if (resolutionScale != 1) {
-            affineWarpBufferData(src, dest, 1 / resolutionScale);
-            // The unpremultiplying and channel-swapping will be done in-place.
-            src = ""
-        }
-
         if (outputFormat == AlphaPremultiplication::Unpremultiplied)
             unpremultiplyBufferData(src, dest);
         else {
@@ -332,19 +287,6 @@
             vImagePermuteChannels_ARGB8888(&src, &dest, map, kvImageNoFlags);
         }
 #else
-        if (resolutionScale != 1) {
-            RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(srcRows, width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
-            RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
-            CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
-
-            srcRows = destRows;
-            srcBytesPerRow = destBytesPerRow;
-            width = destw;
-            height = desth;
-        }
-        
         if ((width * 4).hasOverflowed())
             CRASH();
 
@@ -392,7 +334,7 @@
     return result;
 }
 
-void ImageBufferData::putData(const Uint8ClampedArray& source, AlphaPremultiplication sourceFormat, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, bool accelerateRendering, float resolutionScale)
+void ImageBufferData::putData(const Uint8ClampedArray& source, AlphaPremultiplication sourceFormat, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize& size, bool accelerateRendering)
 {
 #if ASSERT_DISABLED
     UNUSED_PARAM(size);
@@ -403,7 +345,6 @@
     
     Checked<int> originx = sourceRect.x();
     Checked<int> destx = (Checked<int>(destPoint.x()) + sourceRect.x());
-    destx *= resolutionScale;
     ASSERT(destx.unsafeGet() >= 0);
     ASSERT(destx.unsafeGet() < size.width());
     ASSERT(originx.unsafeGet() >= 0);
@@ -410,7 +351,6 @@
     ASSERT(originx.unsafeGet() <= sourceRect.maxX());
     
     Checked<int> endx = (Checked<int>(destPoint.x()) + sourceRect.maxX());
-    endx *= resolutionScale;
     ASSERT(endx.unsafeGet() <= size.width());
     
     Checked<int> width = sourceRect.width();
@@ -418,7 +358,6 @@
 
     Checked<int> originy = sourceRect.y();
     Checked<int> desty = (Checked<int>(destPoint.y()) + sourceRect.y());
-    desty *= resolutionScale;
     ASSERT(desty.unsafeGet() >= 0);
     ASSERT(desty.unsafeGet() < size.height());
     ASSERT(originy.unsafeGet() >= 0);
@@ -425,7 +364,6 @@
     ASSERT(originy.unsafeGet() <= sourceRect.maxY());
     
     Checked<int> endy = (Checked<int>(destPoint.y()) + sourceRect.maxY());
-    endy *= resolutionScale;
     ASSERT(endy.unsafeGet() <= size.height());
 
     Checked<int> height = sourceRect.height();
@@ -464,33 +402,12 @@
 #if USE_ARGB32
             premultiplyBufferData(src, dest);
 #else
-            if (resolutionScale != 1) {
-                affineWarpBufferData(src, dest, resolutionScale);
-                // The premultiplying will be done in-place.
-                src = ""
-            }
-
             vImagePremultiplyData_RGBA8888(&src, &dest, kvImageNoFlags);
 #endif
             return;
         }
 #endif
-        if (resolutionScale != 1) {
-            RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(const_cast<uint8_t*>(srcRows), width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
-            RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
-            CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
-            if (sourceFormat == AlphaPremultiplication::Premultiplied)
-                return;
 
-            // The premultiplying will be done in-place.
-            srcRows = destRows;
-            srcBytesPerRow = destBytesPerRow;
-            width = destw;
-            height = desth;
-        }
-
         for (int y = 0; y < height.unsafeGet(); ++y) {
             for (int x = 0; x < width.unsafeGet(); x++) {
                 int basex = x * 4;
@@ -540,12 +457,6 @@
         dest.rowBytes = destBytesPerRow;
         dest.data = ""
 
-        if (resolutionScale != 1) {
-            affineWarpBufferData(src, dest, resolutionScale);
-            // The unpremultiplying and channel-swapping will be done in-place.
-            src = ""
-        }
-
         if (sourceFormat == AlphaPremultiplication::Unpremultiplied)
             premultiplyBufferData(src, dest);
         else {
@@ -554,19 +465,6 @@
             vImagePermuteChannels_ARGB8888(&src, &dest, map, kvImageNoFlags);
         }
 #else
-        if (resolutionScale != 1) {
-            RetainPtr<CGContextRef> sourceContext = adoptCF(CGBitmapContextCreate(reinterpret_cast<void*>(const_cast<uint8_t*>(srcRows)), width.unsafeGet(), height.unsafeGet(), 8, srcBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            RetainPtr<CGImageRef> sourceImage = adoptCF(CGBitmapContextCreateImage(sourceContext.get()));
-            RetainPtr<CGContextRef> destinationContext = adoptCF(CGBitmapContextCreate(destRows, destw.unsafeGet(), desth.unsafeGet(), 8, destBytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast));
-            CGContextSetBlendMode(destinationContext.get(), kCGBlendModeCopy);
-            CGContextDrawImage(destinationContext.get(), CGRectMake(0, 0, width.unsafeGet() / resolutionScale, height.unsafeGet() / resolutionScale), sourceImage.get()); // FIXME: Add subpixel translation.
-
-            srcRows = const_cast<const uint8_t*>(destRows);
-            srcBytesPerRow = destBytesPerRow;
-            width = destw;
-            height = desth;
-        }
-
         for (int y = 0; y < height.unsafeGet(); ++y) {
             for (int x = 0; x < width.unsafeGet(); x++) {
                 int basex = x * 4;

Modified: trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h (226389 => 226390)


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h	2018-01-04 04:21:58 UTC (rev 226389)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferDataCG.h	2018-01-04 04:39:33 UTC (rev 226390)
@@ -62,8 +62,8 @@
 #endif
 
     Vector<uint8_t> toBGRAData(bool accelerateRendering, int width, int height) const;
-    RefPtr<Uint8ClampedArray> getData(AlphaPremultiplication, const IntRect&, const IntSize&, bool accelerateRendering, float resolutionScale) const;
-    void putData(const Uint8ClampedArray& source, AlphaPremultiplication sourceFormat, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize&, bool accelerateRendering, float resolutionScale);
+    RefPtr<Uint8ClampedArray> getData(AlphaPremultiplication, const IntRect&, const IntSize&, bool accelerateRendering) const;
+    void putData(const Uint8ClampedArray& source, AlphaPremultiplication sourceFormat, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, const IntSize&, bool accelerateRendering);
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to