Title: [285017] trunk/Source
Revision
285017
Author
timothy_hor...@apple.com
Date
2021-10-28 20:49:24 -0700 (Thu, 28 Oct 2021)

Log Message

Yahoo.com has fragments of wrongly-scaled content throughout when using CGDisplayListImageBufferBackend
https://bugs.webkit.org/show_bug.cgi?id=232459

Reviewed by Dean Jackson.

Source/WebCore:

* platform/graphics/GraphicsContext.h:
Add a WEBCORE_EXPORT that the compiler now wants.

* platform/graphics/cg/GraphicsContextCG.h:
Add a `final` that was missing; not sure why the compiler didn't complain
about the lack of `final` OR `override`, but it does now!
Change getCTM and setCTM to `override` instead of `final` so that
GraphicsContextCGDisplayList can override them.

Source/WebKit:

Similar to r284991, 2D transforms that getCTM() from a CGBitmap context and set
the result on a CGDisplayList with setCTM() (via BifurcatedGraphicsContext)
corrupt the display list's CTM, because it starts out in a different initial state,
because the display list is always recorded with a 1x scale.

To fix this, sneak the fake scale into setCTM/getCTM (multiplying it in in get,
dividing it out in set) so that it appears to the outside as if it has
the same base transform as the CGBitmap context.

* Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp:
(WebKit::GraphicsContextCGDisplayList::GraphicsContextCGDisplayList):
(WebKit::CGDisplayListImageBufferBackend::create):
* Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::display):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285016 => 285017)


--- trunk/Source/WebCore/ChangeLog	2021-10-29 02:53:47 UTC (rev 285016)
+++ trunk/Source/WebCore/ChangeLog	2021-10-29 03:49:24 UTC (rev 285017)
@@ -1,3 +1,19 @@
+2021-10-28  Tim Horton  <timothy_hor...@apple.com>
+
+        Yahoo.com has fragments of wrongly-scaled content throughout when using CGDisplayListImageBufferBackend
+        https://bugs.webkit.org/show_bug.cgi?id=232459
+
+        Reviewed by Dean Jackson.
+
+        * platform/graphics/GraphicsContext.h:
+        Add a WEBCORE_EXPORT that the compiler now wants.
+
+        * platform/graphics/cg/GraphicsContextCG.h:
+        Add a `final` that was missing; not sure why the compiler didn't complain
+        about the lack of `final` OR `override`, but it does now!
+        Change getCTM and setCTM to `override` instead of `final` so that
+        GraphicsContextCGDisplayList can override them.
+
 2021-10-28  Gabriel Nava Marino  <gnavamar...@apple.com>
 
         Negative length returned by TextUtil::midWordBreak with surrogate pair

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (285016 => 285017)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2021-10-29 02:53:47 UTC (rev 285016)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h	2021-10-29 03:49:24 UTC (rev 285017)
@@ -415,7 +415,7 @@
 
     virtual void fillRect(const FloatRect&) = 0;
     virtual void fillRect(const FloatRect&, const Color&) = 0;
-    virtual void fillRect(const FloatRect&, Gradient&);
+    WEBCORE_EXPORT virtual void fillRect(const FloatRect&, Gradient&);
     WEBCORE_EXPORT virtual void fillRect(const FloatRect&, const Color&, CompositeOperator, BlendMode = BlendMode::Normal);
     virtual void fillRoundedRectImpl(const FloatRoundedRect&, const Color&) = 0;
     WEBCORE_EXPORT virtual void fillRoundedRect(const FloatRoundedRect&, const Color&, BlendMode = BlendMode::Normal);

Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h (285016 => 285017)


--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h	2021-10-29 02:53:47 UTC (rev 285016)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.h	2021-10-29 03:49:24 UTC (rev 285017)
@@ -82,7 +82,7 @@
 
     ~GraphicsContextCG();
 
-    bool hasPlatformContext() const;
+    bool hasPlatformContext() const final;
     CGContextRef platformContext() const final;
 
     void save() final;
@@ -143,9 +143,9 @@
     void translate(float x, float y) final;
 
     void concatCTM(const AffineTransform&) final;
-    void setCTM(const AffineTransform&) final;
+    void setCTM(const AffineTransform&) override;
 
-    AffineTransform getCTM(IncludeDeviceScale = PossiblyIncludeDeviceScale) const final;
+    AffineTransform getCTM(IncludeDeviceScale = PossiblyIncludeDeviceScale) const override;
 
     FloatRect roundToDevicePixels(const FloatRect&, RoundingMode = RoundAllSides) final;
 

Modified: trunk/Source/WebKit/ChangeLog (285016 => 285017)


--- trunk/Source/WebKit/ChangeLog	2021-10-29 02:53:47 UTC (rev 285016)
+++ trunk/Source/WebKit/ChangeLog	2021-10-29 03:49:24 UTC (rev 285017)
@@ -1,3 +1,25 @@
+2021-10-28  Tim Horton  <timothy_hor...@apple.com>
+
+        Yahoo.com has fragments of wrongly-scaled content throughout when using CGDisplayListImageBufferBackend
+        https://bugs.webkit.org/show_bug.cgi?id=232459
+
+        Reviewed by Dean Jackson.
+
+        Similar to r284991, 2D transforms that getCTM() from a CGBitmap context and set
+        the result on a CGDisplayList with setCTM() (via BifurcatedGraphicsContext)
+        corrupt the display list's CTM, because it starts out in a different initial state,
+        because the display list is always recorded with a 1x scale.
+
+        To fix this, sneak the fake scale into setCTM/getCTM (multiplying it in in get,
+        dividing it out in set) so that it appears to the outside as if it has
+        the same base transform as the CGBitmap context.
+
+        * Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp:
+        (WebKit::GraphicsContextCGDisplayList::GraphicsContextCGDisplayList):
+        (WebKit::CGDisplayListImageBufferBackend::create):
+        * Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:
+        (WebKit::RemoteLayerBackingStore::display):
+
 2021-10-28  Sihui Liu  <sihui_...@apple.com>
 
         Release FileSystemStorageHandle when it is not in use

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp (285016 => 285017)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp	2021-10-29 02:53:47 UTC (rev 285016)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/CGDisplayListImageBufferBackend.cpp	2021-10-29 03:49:24 UTC (rev 285017)
@@ -35,6 +35,30 @@
 
 namespace WebKit {
 
+class GraphicsContextCGDisplayList : public WebCore::GraphicsContextCG {
+public:
+    GraphicsContextCGDisplayList(CGContextRef cgContext, double immutableBaseScaleFactor)
+        : GraphicsContextCG(cgContext)
+        , m_scaleTransform(immutableBaseScaleFactor, 0, 0, immutableBaseScaleFactor, 0, 0)
+        , m_inverseScaleTransform(1. / immutableBaseScaleFactor, 0, 0, 1. / immutableBaseScaleFactor, 0, 0)
+    {
+    }
+
+    void setCTM(const WebCore::AffineTransform& transform) final
+    {
+        GraphicsContextCG::setCTM(m_inverseScaleTransform * transform);
+    }
+
+    WebCore::AffineTransform getCTM(IncludeDeviceScale includeDeviceScale) const final
+    {
+        return m_scaleTransform * GraphicsContextCG::getCTM(includeDeviceScale);
+    }
+
+private:
+    WebCore::AffineTransform m_scaleTransform;
+    WebCore::AffineTransform m_inverseScaleTransform;
+};
+
 WTF_MAKE_ISO_ALLOCATED_IMPL(CGDisplayListImageBufferBackend);
 
 size_t CGDisplayListImageBufferBackend::calculateMemoryCost(const Parameters& parameters)
@@ -55,7 +79,7 @@
     if (!cgContext)
         return nullptr;
 
-    auto context = makeUnique<WebCore::GraphicsContextCG>(cgContext.get());
+    auto context = makeUnique<GraphicsContextCGDisplayList>(cgContext.get(), parameters.resolutionScale);
     return std::unique_ptr<CGDisplayListImageBufferBackend>(new CGDisplayListImageBufferBackend(parameters, WTFMove(context)));
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to