Title: [254941] trunk/Source/WebCore
Revision
254941
Author
[email protected]
Date
2020-01-22 13:32:11 -0800 (Wed, 22 Jan 2020)

Log Message

Remove ImageBuffer::sizeForDestinationSize()
https://bugs.webkit.org/show_bug.cgi?id=206541

Patch by Said Abou-Hallawa <[email protected]> on 2020-01-22
Reviewed by Tim Horton.

-- Remove ImageBuffer::sizeForDestinationSize() since it is currently
   doing nothing. For CG and D2D ports, it scales a rect by the ratio
   backingStoreSize / internalSize which is always 1. The constructor
   ImageBuffer::ImageBuffer() sets m_size and m_data.backingStoreSize
   to the same value always.

-- Remove ImageBuffer::isCompatibleWithContext() since it is not used.

-- Remove ImageBuffer::fastCopyImageMode() since it returns
   DontCopyBackingStore on all ports.

* html/CustomPaintCanvas.cpp:
(WebCore::CustomPaintCanvas::copiedImage const):
* html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::texSubImage2D):
(WebCore::WebGLRenderingContextBase::texImage2D):
(WebCore::WebGLRenderingContextBase::drawImageIntoBuffer):
* platform/graphics/ImageBuffer.cpp:
(WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
(WebCore::ImageBuffer::isCompatibleWithContext const): Deleted.
* platform/graphics/ImageBuffer.h:
(WebCore::ImageBuffer::logicalSize const):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBuffer::fastCopyImageMode): Deleted.
* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::clipToImageBuffer):
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::ImageBuffer):
(WebCore::createBitmapImageAfterScalingIfNeeded):
(WebCore::ImageBuffer::copyImage const):
(WebCore::ImageBuffer::sinkIntoImage):
(WebCore::ImageBuffer::toCFData const):
(WebCore::scaleSizeToUserSpace): Deleted.
(WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
(WebCore::ImageBuffer::fastCopyImageMode): Deleted.
* platform/graphics/win/ImageBufferDirect2D.cpp:
(WebCore::scaleSizeToUserSpace): Deleted.
(WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
(WebCore::ImageBuffer::fastCopyImageMode): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (254940 => 254941)


--- trunk/Source/WebCore/ChangeLog	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/ChangeLog	2020-01-22 21:32:11 UTC (rev 254941)
@@ -1,3 +1,50 @@
+2020-01-22  Said Abou-Hallawa  <[email protected]>
+
+        Remove ImageBuffer::sizeForDestinationSize()
+        https://bugs.webkit.org/show_bug.cgi?id=206541
+
+        Reviewed by Tim Horton.
+
+        -- Remove ImageBuffer::sizeForDestinationSize() since it is currently
+           doing nothing. For CG and D2D ports, it scales a rect by the ratio
+           backingStoreSize / internalSize which is always 1. The constructor
+           ImageBuffer::ImageBuffer() sets m_size and m_data.backingStoreSize
+           to the same value always.
+
+        -- Remove ImageBuffer::isCompatibleWithContext() since it is not used.
+
+        -- Remove ImageBuffer::fastCopyImageMode() since it returns 
+           DontCopyBackingStore on all ports.
+
+        * html/CustomPaintCanvas.cpp:
+        (WebCore::CustomPaintCanvas::copiedImage const):
+        * html/canvas/WebGLRenderingContextBase.cpp:
+        (WebCore::WebGLRenderingContextBase::texSubImage2D):
+        (WebCore::WebGLRenderingContextBase::texImage2D):
+        (WebCore::WebGLRenderingContextBase::drawImageIntoBuffer):
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
+        (WebCore::ImageBuffer::isCompatibleWithContext const): Deleted.
+        * platform/graphics/ImageBuffer.h:
+        (WebCore::ImageBuffer::logicalSize const):
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBuffer::fastCopyImageMode): Deleted.
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::clipToImageBuffer):
+        * platform/graphics/cg/ImageBufferCG.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        (WebCore::createBitmapImageAfterScalingIfNeeded):
+        (WebCore::ImageBuffer::copyImage const):
+        (WebCore::ImageBuffer::sinkIntoImage):
+        (WebCore::ImageBuffer::toCFData const):
+        (WebCore::scaleSizeToUserSpace): Deleted.
+        (WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
+        (WebCore::ImageBuffer::fastCopyImageMode): Deleted.
+        * platform/graphics/win/ImageBufferDirect2D.cpp:
+        (WebCore::scaleSizeToUserSpace): Deleted.
+        (WebCore::ImageBuffer::sizeForDestinationSize const): Deleted.
+        (WebCore::ImageBuffer::fastCopyImageMode): Deleted.
+
 2020-01-22  Zalan Bujtas  <[email protected]>
 
         [LFC] Do not create a FormattingContext to compute intrinsic width unless there's some content.

Modified: trunk/Source/WebCore/html/CustomPaintCanvas.cpp (254940 => 254941)


--- trunk/Source/WebCore/html/CustomPaintCanvas.cpp	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/html/CustomPaintCanvas.cpp	2020-01-22 21:32:11 UTC (rev 254941)
@@ -102,7 +102,7 @@
         m_context->paintRenderingResultsToCanvas();
     m_destinationGraphicsContext = nullptr;
 
-    m_copiedImage = m_copiedBuffer->copyImage(m_copiedBuffer->fastCopyImageMode(), PreserveResolution::Yes);
+    m_copiedImage = m_copiedBuffer->copyImage(DontCopyBackingStore, PreserveResolution::Yes);
     return m_copiedImage.get();
 }
 

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (254940 => 254941)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp	2020-01-22 21:32:11 UTC (rev 254941)
@@ -3982,7 +3982,7 @@
         if (!buffer)
             return { };
 
-        RefPtr<Image> image = buffer->copyImage(ImageBuffer::fastCopyImageMode());
+        RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore);
         if (image)
             texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContextGL::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
@@ -4104,7 +4104,7 @@
         if (!validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement, target, level, internalFormat, video->videoWidth(), video->videoHeight(), 0, format, type, xoffset, yoffset))
             return { };
 
-        RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
+        RefPtr<Image> image = videoFrameToImage(video.get(), DontCopyBackingStore);
         if (!image)
             return { };
         texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get(), GraphicsContextGL::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
@@ -4551,7 +4551,7 @@
         }
 
         // Normal pure SW path.
-        RefPtr<Image> image = buffer->copyImage(ImageBuffer::fastCopyImageMode());
+        RefPtr<Image> image = buffer->copyImage(DontCopyBackingStore);
         if (image)
             texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContextGL::DOMSource::Image, m_unpackFlipY, m_unpackPremultiplyAlpha);
         return { };
@@ -4665,7 +4665,7 @@
         }
 
         // Normal pure SW path.
-        RefPtr<Image> image = videoFrameToImage(video.get(), ImageBuffer::fastCopyImageMode());
+        RefPtr<Image> image = videoFrameToImage(video.get(), DontCopyBackingStore);
         if (!image)
             return { };
         texImage2DImpl(target, level, internalformat, format, type, image.get(), GraphicsContextGL::DOMSource::Video, m_unpackFlipY, m_unpackPremultiplyAlpha);
@@ -4690,7 +4690,7 @@
     FloatRect srcRect(FloatPoint(), image.size());
     FloatRect destRect(FloatPoint(), size);
     buf->context().drawImage(image, destRect, srcRect);
-    return buf->copyImage(ImageBuffer::fastCopyImageMode());
+    return buf->copyImage(DontCopyBackingStore);
 }
 
 #if ENABLE(VIDEO)

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (254940 => 254941)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2020-01-22 21:32:11 UTC (rev 254941)
@@ -114,12 +114,6 @@
 #endif
 
 #if !(USE(CG) || USE(DIRECT2D))
-
-FloatSize ImageBuffer::sizeForDestinationSize(FloatSize size) const
-{
-    return size;
-}
-
 void ImageBuffer::transformColorSpace(ColorSpace srcColorSpace, ColorSpace dstColorSpace)
 {
     if (srcColorSpace == dstColorSpace)
@@ -244,11 +238,6 @@
     return expandedIntSize(size * context.scaleFactor());
 }
 
-bool ImageBuffer::isCompatibleWithContext(const GraphicsContext& context) const
-{
-    return areEssentiallyEqual(context.scaleFactor(), this->context().scaleFactor());
-}
-
 #if !USE(IOSURFACE_CANVAS_BACKING_STORE)
 size_t ImageBuffer::memoryCost() const
 {

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.h (254940 => 254941)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.h	2020-01-22 21:32:11 UTC (rev 254941)
@@ -85,7 +85,6 @@
     static std::unique_ptr<ImageBuffer> createCompatibleBuffer(const FloatSize&, float resolutionScale, ColorSpace, const GraphicsContext&);
 
     static IntSize compatibleBufferSize(const FloatSize&, const GraphicsContext&);
-    bool isCompatibleWithContext(const GraphicsContext&) const;
 
     WEBCORE_EXPORT ~ImageBuffer();
 
@@ -92,9 +91,6 @@
     // The actual resolution of the backing store
     const IntSize& internalSize() const { return m_size; }
     const IntSize& logicalSize() const { return m_logicalSize; }
-
-    FloatSize sizeForDestinationSize(FloatSize) const;
-
     float resolutionScale() const { return m_resolutionScale; }
 
     WEBCORE_EXPORT GraphicsContext& context() const;
@@ -101,9 +97,6 @@
 
     WEBCORE_EXPORT RefPtr<Image> copyImage(BackingStoreCopy = CopyBackingStore, PreserveResolution = PreserveResolution::No) const;
     WEBCORE_EXPORT static RefPtr<Image> sinkIntoImage(std::unique_ptr<ImageBuffer>, PreserveResolution = PreserveResolution::No);
-    // Give hints on the faster copyImage Mode, return DontCopyBackingStore if it supports the DontCopyBackingStore behavior
-    // or return CopyBackingStore if it doesn't.  
-    static BackingStoreCopy fastCopyImageMode();
 
     enum CoordinateSystem { LogicalCoordinateSystem, BackingStoreCoordinateSystem };
 

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (254940 => 254941)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2020-01-22 21:32:11 UTC (rev 254941)
@@ -351,11 +351,6 @@
     return BitmapImage::create(RefPtr<cairo_surface_t>(m_data.m_surface));
 }
 
-BackingStoreCopy ImageBuffer::fastCopyImageMode()
-{
-    return DontCopyBackingStore;
-}
-
 void ImageBuffer::drawConsuming(std::unique_ptr<ImageBuffer> imageBuffer, GraphicsContext& destContext, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& options)
 {
     imageBuffer->draw(destContext, destRect, srcRect, options);

Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (254940 => 254941)


--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp	2020-01-22 21:32:11 UTC (rev 254941)
@@ -512,7 +512,7 @@
     if (paintingDisabled())
         return;
 
-    FloatSize bufferDestinationSize = buffer.sizeForDestinationSize(destRect.size());
+    FloatSize bufferDestinationSize = destRect.size();
     RetainPtr<CGImageRef> image = buffer.copyNativeImage(DontCopyBackingStore);
 
     CGContextRef context = platformContext();

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


--- trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp	2020-01-22 21:32:11 UTC (rev 254941)
@@ -66,13 +66,6 @@
 DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBuffer);
 DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(ImageBuffer);
 
-static FloatSize scaleSizeToUserSpace(const FloatSize& logicalSize, const IntSize& backingStoreSize, const IntSize& internalSize)
-{
-    float xMagnification = static_cast<float>(backingStoreSize.width()) / internalSize.width();
-    float yMagnification = static_cast<float>(backingStoreSize.height()) / internalSize.height();
-    return FloatSize(logicalSize.width() * xMagnification, logicalSize.height() * yMagnification);
-}
-
 std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
 {
     if (size.isEmpty())
@@ -155,7 +148,7 @@
     RetainPtr<CGContextRef> cgContext;
     if (accelerateRendering) {
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
-        FloatSize userBounds = sizeForDestinationSize(FloatSize(width.unsafeGet(), height.unsafeGet()));
+        FloatSize userBounds = FloatSize(width.unsafeGet(), height.unsafeGet());
         m_data.surface = IOSurface::create(m_data.backingStoreSize, IntSize(userBounds), colorSpace);
         if (m_data.surface) {
             cgContext = m_data.surface->ensurePlatformContext(hostWindow);
@@ -210,11 +203,6 @@
 
 ImageBuffer::~ImageBuffer() = default;
 
-FloatSize ImageBuffer::sizeForDestinationSize(FloatSize destinationSize) const
-{
-    return scaleSizeToUserSpace(destinationSize, m_data.backingStoreSize, internalSize());
-}
-
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
 size_t ImageBuffer::memoryCost() const
 {
@@ -259,7 +247,7 @@
     return image;
 }
 
-static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>&& image, IntSize internalSize, IntSize logicalSize, IntSize backingStoreSize, float resolutionScale, PreserveResolution preserveResolution)
+static RefPtr<Image> createBitmapImageAfterScalingIfNeeded(RetainPtr<CGImageRef>&& image, IntSize logicalSize, IntSize internalSize, float resolutionScale, PreserveResolution preserveResolution)
 {
     if (resolutionScale == 1 || preserveResolution == PreserveResolution::Yes)
         image = createCroppedImageIfNecessary(image.get(), internalSize);
@@ -267,7 +255,7 @@
         auto context = adoptCF(CGBitmapContextCreate(0, logicalSize.width(), logicalSize.height(), 8, 4 * logicalSize.width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
         CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
         CGContextClipToRect(context.get(), FloatRect(FloatPoint::zero(), logicalSize));
-        FloatSize imageSizeInUserSpace = scaleSizeToUserSpace(logicalSize, backingStoreSize, internalSize);
+        FloatSize imageSizeInUserSpace = logicalSize;
         CGContextDrawImage(context.get(), FloatRect(FloatPoint::zero(), imageSizeInUserSpace), image.get());
         image = adoptCF(CGBitmapContextCreateImage(context.get()));
     }
@@ -286,7 +274,7 @@
     else
         image = copyNativeImage(DontCopyBackingStore);
 
-    return createBitmapImageAfterScalingIfNeeded(WTFMove(image), internalSize(), logicalSize(), m_data.backingStoreSize, m_resolutionScale, preserveResolution);
+    return createBitmapImageAfterScalingIfNeeded(WTFMove(image), logicalSize(), internalSize(), m_resolutionScale, preserveResolution);
 }
 
 RefPtr<Image> ImageBuffer::sinkIntoImage(std::unique_ptr<ImageBuffer> imageBuffer, PreserveResolution preserveResolution)
@@ -293,17 +281,11 @@
 {
     IntSize internalSize = imageBuffer->internalSize();
     IntSize logicalSize = imageBuffer->logicalSize();
-    IntSize backingStoreSize = imageBuffer->m_data.backingStoreSize;
     float resolutionScale = imageBuffer->m_resolutionScale;
 
-    return createBitmapImageAfterScalingIfNeeded(sinkIntoNativeImage(WTFMove(imageBuffer)), internalSize, logicalSize, backingStoreSize, resolutionScale, preserveResolution);
+    return createBitmapImageAfterScalingIfNeeded(sinkIntoNativeImage(WTFMove(imageBuffer)), logicalSize, internalSize, resolutionScale, preserveResolution);
 }
 
-BackingStoreCopy ImageBuffer::fastCopyImageMode()
-{
-    return DontCopyBackingStore;
-}
-
 RetainPtr<CGImageRef> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
 {
 #if USE(IOSURFACE_CANVAS_BACKING_STORE)
@@ -493,7 +475,7 @@
         auto context = adoptCF(CGBitmapContextCreate(0, logicalSize().width(), logicalSize().height(), 8, 4 * logicalSize().width(), sRGBColorSpaceRef(), kCGImageAlphaPremultipliedLast));
         CGContextSetBlendMode(context.get(), kCGBlendModeCopy);
         CGContextClipToRect(context.get(), CGRectMake(0, 0, logicalSize().width(), logicalSize().height()));
-        FloatSize imageSizeInUserSpace = sizeForDestinationSize(logicalSize());
+        FloatSize imageSizeInUserSpace = logicalSize();
         CGContextDrawImage(context.get(), CGRectMake(0, 0, imageSizeInUserSpace.width(), imageSizeInUserSpace.height()), image.get());
         image = adoptCF(CGBitmapContextCreateImage(context.get()));
     }

Modified: trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp (254940 => 254941)


--- trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp	2020-01-22 21:21:58 UTC (rev 254940)
+++ trunk/Source/WebCore/platform/graphics/win/ImageBufferDirect2D.cpp	2020-01-22 21:32:11 UTC (rev 254941)
@@ -51,13 +51,6 @@
 
 namespace WebCore {
 
-static FloatSize scaleSizeToUserSpace(const FloatSize& logicalSize, const IntSize& backingStoreSize, const IntSize& internalSize)
-{
-    float xMagnification = static_cast<float>(backingStoreSize.width()) / internalSize.width();
-    float yMagnification = static_cast<float>(backingStoreSize.height()) / internalSize.height();
-    return FloatSize(logicalSize.width() * xMagnification, logicalSize.height() * yMagnification);
-}
-
 std::unique_ptr<ImageBuffer> ImageBuffer::createCompatibleBuffer(const FloatSize& size, const GraphicsContext& context)
 {
     if (size.isEmpty())
@@ -132,11 +125,6 @@
 
 ImageBuffer::~ImageBuffer() = default;
 
-FloatSize ImageBuffer::sizeForDestinationSize(FloatSize destinationSize) const
-{
-    return scaleSizeToUserSpace(destinationSize, m_data.backingStoreSize, internalSize());
-}
-
 GraphicsContext& ImageBuffer::context() const
 {
     return *m_data.context;
@@ -206,11 +194,6 @@
     return createBitmapImageAfterScalingIfNeeded(bitmapTarget.get(), sinkIntoNativeImage(WTFMove(imageBuffer)), internalSize, logicalSize, backingStoreSize, resolutionScale, preserveResolution);
 }
 
-BackingStoreCopy ImageBuffer::fastCopyImageMode()
-{
-    return DontCopyBackingStore;
-}
-
 COMPtr<ID2D1Bitmap> ImageBuffer::sinkIntoNativeImage(std::unique_ptr<ImageBuffer> imageBuffer)
 {
     // FIXME: See if we can reuse the on-hardware image.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to