Title: [292478] trunk
Revision
292478
Author
[email protected]
Date
2022-04-06 10:57:35 -0700 (Wed, 06 Apr 2022)

Log Message

[GPU Process] Text filled with pattern sometimes draw with incorrect color
https://bugs.webkit.org/show_bug.cgi?id=236924
rdar://89196811

Reviewed by Myles C. Maxfield.

Source/WebCore:

applyFillPattern() and applyStrokePattern() have to explicitly called
for the GraphicsContext or the DisplayList::Recorder before drawing
with the pattern. But this is not happening for the DrawGlyphsRecorder
internalContext. When CoreText calls DrawGlyphsRecorder::recordDrawGlyphs()
back, it applies the CGGState fill color to the DisplayList::Recorder so
it overrides what applyFillPattern() did before recording the glyphs.

* platform/graphics/DrawGlyphsRecorder.h:
* platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp:
(WebCore::DrawGlyphsRecorder::populateInternalContext):
(WebCore::DrawGlyphsRecorder::updateFillColor):
(WebCore::DrawGlyphsRecorder::updateStrokeColor):
(WebCore::DrawGlyphsRecorder::recordDrawGlyphs):

LayoutTests:

* platform/ios-wk2/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (292477 => 292478)


--- trunk/LayoutTests/ChangeLog	2022-04-06 17:48:44 UTC (rev 292477)
+++ trunk/LayoutTests/ChangeLog	2022-04-06 17:57:35 UTC (rev 292478)
@@ -1,3 +1,13 @@
+2022-04-06  Said Abou-Hallawa  <[email protected]>
+
+        [GPU Process] Text filled with pattern sometimes draw with incorrect color
+        https://bugs.webkit.org/show_bug.cgi?id=236924
+        rdar://89196811
+
+        Reviewed by Myles C. Maxfield.
+
+        * platform/ios-wk2/TestExpectations:
+
 2022-04-06  Oriol Brufau  <[email protected]>
 
         [css] Turn -webkit-border-image into a shorthand

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (292477 => 292478)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2022-04-06 17:48:44 UTC (rev 292477)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2022-04-06 17:57:35 UTC (rev 292478)
@@ -2208,10 +2208,6 @@
 # Wrong text color
 webkit.org/b/236913 imported/blink/fast/multicol/vertical-lr/float-content-break.html [ ImageOnlyFailure ]
 
-# No/bad gradient/pattern
-webkit.org/b/236924 svg/transforms/transformed-text-fill-pattern.html [ ImageOnlyFailure ]
-webkit.org/b/236924 imported/blink/svg/text/obb-paintserver.html [ ImageOnlyFailure ]
-
 # Media failures
 webkit.org/b/237295 fast/mediastream/video-rotation-gpu-process-crash.html [ Timeout Crash Pass ]
 webkit.org/b/236926 webrtc/vp8-then-h264-gpu-process-crash.html [ Timeout Pass ]

Modified: trunk/Source/WebCore/ChangeLog (292477 => 292478)


--- trunk/Source/WebCore/ChangeLog	2022-04-06 17:48:44 UTC (rev 292477)
+++ trunk/Source/WebCore/ChangeLog	2022-04-06 17:57:35 UTC (rev 292478)
@@ -1,3 +1,25 @@
+2022-04-06  Said Abou-Hallawa  <[email protected]>
+
+        [GPU Process] Text filled with pattern sometimes draw with incorrect color
+        https://bugs.webkit.org/show_bug.cgi?id=236924
+        rdar://89196811
+
+        Reviewed by Myles C. Maxfield.
+
+        applyFillPattern() and applyStrokePattern() have to explicitly called
+        for the GraphicsContext or the DisplayList::Recorder before drawing 
+        with the pattern. But this is not happening for the DrawGlyphsRecorder 
+        internalContext. When CoreText calls DrawGlyphsRecorder::recordDrawGlyphs()
+        back, it applies the CGGState fill color to the DisplayList::Recorder so
+        it overrides what applyFillPattern() did before recording the glyphs.
+
+        * platform/graphics/DrawGlyphsRecorder.h:
+        * platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp:
+        (WebCore::DrawGlyphsRecorder::populateInternalContext):
+        (WebCore::DrawGlyphsRecorder::updateFillColor):
+        (WebCore::DrawGlyphsRecorder::updateStrokeColor):
+        (WebCore::DrawGlyphsRecorder::recordDrawGlyphs):
+
 2022-04-06  Chris Dumez  <[email protected]>
 
         Reduce number of conversions from StringView to String

Modified: trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h (292477 => 292478)


--- trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h	2022-04-06 17:48:44 UTC (rev 292477)
+++ trunk/Source/WebCore/platform/graphics/DrawGlyphsRecorder.h	2022-04-06 17:57:35 UTC (rev 292478)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -95,6 +95,8 @@
     void updateShadow(const DropShadow&, ShadowsIgnoreTransforms);
 
 #if USE(CORE_TEXT) && !PLATFORM(WIN)
+    void updateFillColor(CGColorRef);
+    void updateStrokeColor(CGColorRef);
     void updateShadow(CGStyleRef);
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp (292477 => 292478)


--- trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp	2022-04-06 17:48:44 UTC (rev 292477)
+++ trunk/Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp	2022-04-06 17:57:35 UTC (rev 292478)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
+ * Copyright (C) 2020-2022 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -108,11 +108,14 @@
 
 void DrawGlyphsRecorder::populateInternalContext(const GraphicsContextState& contextState)
 {
+    m_internalContext->setCTM(m_originalState.ctm);
+
     m_internalContext->setFillBrush(m_originalState.fillBrush);
+    m_internalContext->applyFillPattern();
+
     m_internalContext->setStrokeBrush(m_originalState.strokeBrush);
+    m_internalContext->applyStrokePattern();
 
-    m_internalContext->setCTM(m_originalState.ctm);
-
     m_internalContext->setShadowsIgnoreTransforms(m_originalState.ignoreTransforms);
     m_internalContext->setDropShadow(m_originalState.dropShadow);
 
@@ -143,11 +146,29 @@
     updateShadow(m_originalState.dropShadow, m_originalState.ignoreTransforms ? ShadowsIgnoreTransforms::Yes : ShadowsIgnoreTransforms::No);
 }
 
+void DrawGlyphsRecorder::updateFillColor(CGColorRef fillColor)
+{
+    if (CGColorGetPattern(fillColor)) {
+        ASSERT(m_originalState.fillBrush.pattern());
+        return;
+    }
+    m_owner.setFillBrush(Color::createAndPreserveColorSpace(fillColor));
+}
+
 void DrawGlyphsRecorder::updateFillBrush(const SourceBrush& newBrush)
 {
     m_owner.setFillBrush(newBrush);
 }
 
+void DrawGlyphsRecorder::updateStrokeColor(CGColorRef strokeColor)
+{
+    if (CGColorGetPattern(strokeColor)) {
+        ASSERT(m_originalState.strokeBrush.pattern());
+        return;
+    }
+    m_owner.setStrokeBrush(Color::createAndPreserveColorSpace(strokeColor));
+}
+
 void DrawGlyphsRecorder::updateStrokeBrush(const SourceBrush& newBrush)
 {
     m_owner.setStrokeBrush(newBrush);
@@ -243,10 +264,8 @@
         ctmFixup = AffineTransform();
     m_owner.concatCTM(ctmFixup);
 
-    auto fillColor = CGGStateGetFillColor(gstate);
-    auto strokeColor = CGGStateGetStrokeColor(gstate);
-    updateFillBrush(Color::createAndPreserveColorSpace(fillColor));
-    updateStrokeBrush(Color::createAndPreserveColorSpace(strokeColor));
+    updateFillColor(CGGStateGetFillColor(gstate));
+    updateStrokeColor(CGGStateGetStrokeColor(gstate));
     updateShadow(CGGStateGetStyle(gstate));
 
     auto fontSize = CGGStateGetFontSize(gstate);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to