Diff
Modified: trunk/Source/WebCore/ChangeLog (279853 => 279854)
--- trunk/Source/WebCore/ChangeLog 2021-07-12 21:34:03 UTC (rev 279853)
+++ trunk/Source/WebCore/ChangeLog 2021-07-12 22:33:54 UTC (rev 279854)
@@ -1,3 +1,27 @@
+2021-07-12 Tim Horton <timothy_hor...@apple.com>
+
+ BifurcatedGraphicsContext can't draw text
+ https://bugs.webkit.org/show_bug.cgi?id=227883
+
+ Reviewed by Wenson Hsieh.
+
+ API test: BifurcatedGraphicsContextTests.TextInBifurcatedContext
+
+ * platform/graphics/BifurcatedGraphicsContext.cpp:
+ (WebCore::BifurcatedGraphicsContext::save):
+ (WebCore::BifurcatedGraphicsContext::restore):
+ (WebCore::BifurcatedGraphicsContext::paintFrameForMedia):
+ (WebCore::BifurcatedGraphicsContext::drawText):
+ (WebCore::BifurcatedGraphicsContext::drawGlyphs):
+ (WebCore::BifurcatedGraphicsContext::drawEmphasisMarks):
+ (WebCore::BifurcatedGraphicsContext::drawBidiText):
+ * platform/graphics/BifurcatedGraphicsContext.h:
+ Bifurcate a few methods I somehow missed in the original patch.
+
+ Also, call GraphicsContext's implementation of save and restore
+ from the overridden version, because we confusingly currently use
+ the top-level context's state stack.
+
2021-07-12 Simon Fraser <simon.fra...@apple.com>
Add a StyleSheets log channel and some logging
Modified: trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp (279853 => 279854)
--- trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp 2021-07-12 21:34:03 UTC (rev 279853)
+++ trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp 2021-07-12 22:33:54 UTC (rev 279854)
@@ -50,6 +50,9 @@
void BifurcatedGraphicsContext::save()
{
+ // FIXME: Consider not using the BifurcatedGraphicsContext's state stack at all,
+ // and making all of the state getters and setters virtual.
+ GraphicsContext::save();
m_primaryContext.save();
m_secondaryContext.save();
}
@@ -56,6 +59,7 @@
void BifurcatedGraphicsContext::restore()
{
+ GraphicsContext::restore();
m_primaryContext.restore();
m_secondaryContext.restore();
}
@@ -265,6 +269,12 @@
m_secondaryContext.drawPattern(nativeImage, imageSize, destRect, tileRect, patternTransform, phase, spacing, options);
}
+void BifurcatedGraphicsContext::paintFrameForMedia(MediaPlayer& player, const FloatRect& destination)
+{
+ m_primaryContext.paintFrameForMedia(player, destination);
+ m_secondaryContext.paintFrameForMedia(player, destination);
+}
+
void BifurcatedGraphicsContext::scale(const FloatSize& scale)
{
m_primaryContext.scale(scale);
@@ -331,6 +341,31 @@
}
#endif
+FloatSize BifurcatedGraphicsContext::drawText(const FontCascade& cascade, const TextRun& run, const FloatPoint& point, unsigned from, std::optional<unsigned> to)
+{
+ auto size = m_primaryContext.drawText(cascade, run, point, from, to);
+ m_secondaryContext.drawText(cascade, run, point, from, to);
+ return size;
+}
+
+void BifurcatedGraphicsContext::drawGlyphs(const Font& font, const GlyphBufferGlyph* glyphs, const GlyphBufferAdvance* advances, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode fontSmoothingMode)
+{
+ m_primaryContext.drawGlyphs(font, glyphs, advances, numGlyphs, point, fontSmoothingMode);
+ m_secondaryContext.drawGlyphs(font, glyphs, advances, numGlyphs, point, fontSmoothingMode);
+}
+
+void BifurcatedGraphicsContext::drawEmphasisMarks(const FontCascade& cascade, const TextRun& run, const AtomString& mark, const FloatPoint& point, unsigned from, std::optional<unsigned> to)
+{
+ m_primaryContext.drawEmphasisMarks(cascade, run, mark, point, from, to);
+ m_secondaryContext.drawEmphasisMarks(cascade, run, mark, point, from, to);
+}
+
+void BifurcatedGraphicsContext::drawBidiText(const FontCascade& cascade, const TextRun& run, const FloatPoint& point, FontCascade::CustomFontNotReadyAction customFontNotReadyAction)
+{
+ m_primaryContext.drawBidiText(cascade, run, point, customFontNotReadyAction);
+ m_secondaryContext.drawBidiText(cascade, run, point, customFontNotReadyAction);
+}
+
void BifurcatedGraphicsContext::drawLinesForText(const FloatPoint& point, float thickness, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle strokeStyle)
{
m_primaryContext.drawLinesForText(point, thickness, widths, printing, doubleLines, strokeStyle);
Modified: trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h (279853 => 279854)
--- trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h 2021-07-12 21:34:03 UTC (rev 279853)
+++ trunk/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h 2021-07-12 22:33:54 UTC (rev 279854)
@@ -100,6 +100,10 @@
void drawNativeImage(NativeImage&, const FloatSize& selfSize, const FloatRect& destRect, const FloatRect& srcRect, const ImagePaintingOptions& = { }) final;
void drawPattern(NativeImage&, const FloatSize& imageSize, const FloatRect& destRect, const FloatRect& tileRect, const AffineTransform& patternTransform, const FloatPoint& phase, const FloatSize& spacing, const ImagePaintingOptions& = { }) final;
+#if ENABLE(VIDEO)
+ void paintFrameForMedia(MediaPlayer&, const FloatRect& destination) final;
+#endif
+
using GraphicsContext::scale;
void scale(const FloatSize&) final;
void rotate(float angleInRadians) final;
@@ -119,6 +123,11 @@
void drawFocusRing(const Vector<FloatRect>&, double, bool&, const Color&) final;
#endif
+ FloatSize drawText(const FontCascade&, const TextRun&, const FloatPoint&, unsigned from = 0, std::optional<unsigned> to = std::nullopt) final;
+ void drawGlyphs(const Font&, const GlyphBufferGlyph*, const GlyphBufferAdvance*, unsigned numGlyphs, const FloatPoint&, FontSmoothingMode) final;
+ void drawEmphasisMarks(const FontCascade&, const TextRun&, const AtomString& mark, const FloatPoint&, unsigned from = 0, std::optional<unsigned> to = std::nullopt) final;
+ void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady) final;
+
void drawLinesForText(const FloatPoint&, float thickness, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle) final;
void drawDotsForDocumentMarker(const FloatRect&, DocumentMarkerLineStyle) final;
Modified: trunk/Tools/ChangeLog (279853 => 279854)
--- trunk/Tools/ChangeLog 2021-07-12 21:34:03 UTC (rev 279853)
+++ trunk/Tools/ChangeLog 2021-07-12 22:33:54 UTC (rev 279854)
@@ -1,3 +1,14 @@
+2021-07-12 Tim Horton <timothy_hor...@apple.com>
+
+ BifurcatedGraphicsContext can't draw text
+ https://bugs.webkit.org/show_bug.cgi?id=227883
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp:
+ (TestWebKitAPI::TEST):
+ Add a test ensuring that we get DrawGlyphs commands on both contexts.
+
2021-07-12 Jonathan Bedard <jbed...@apple.com>
[run-api-tests] Use Python 3 (Part 1)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp (279853 => 279854)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp 2021-07-12 21:34:03 UTC (rev 279853)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cg/BifurcatedGraphicsContextTestsCG.cpp 2021-07-12 22:33:54 UTC (rev 279854)
@@ -33,6 +33,7 @@
#include <WebCore/DisplayListItems.h>
#include <WebCore/DisplayListIterator.h>
#include <WebCore/DisplayListRecorder.h>
+#include <WebCore/FontCascade.h>
#include <WebCore/GraphicsContextCG.h>
#include <WebCore/InMemoryDisplayList.h>
@@ -86,6 +87,48 @@
EXPECT_TRUE(sawFillRect);
}
+TEST(BifurcatedGraphicsContextTests, TextInBifurcatedContext)
+{
+ InMemoryDisplayList primaryDisplayList;
+ Recorder primaryContext(primaryDisplayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
+
+ InMemoryDisplayList secondaryDisplayList;
+ Recorder secondaryContext(secondaryDisplayList, { }, FloatRect(0, 0, contextWidth, contextHeight), { });
+
+ BifurcatedGraphicsContext ctx(primaryContext, secondaryContext);
+
+ FontCascadeDescription description;
+ description.setOneFamily("Times");
+ description.setComputedSize(80);
+ FontCascade font(WTFMove(description));
+ font.update();
+
+ String string = "Hello!";
+ TextRun run(string);
+ ctx.drawText(font, run, { });
+
+ auto runTest = [&] (InMemoryDisplayList& displayList) {
+ EXPECT_FALSE(displayList.isEmpty());
+ bool sawDrawGlyphs = false;
+ for (auto displayListItem : displayList) {
+ auto handle = displayListItem->item;
+ if (handle.type() != ItemType::DrawGlyphs)
+ continue;
+
+ EXPECT_TRUE(handle.isDrawingItem());
+ EXPECT_TRUE(handle.is<DrawGlyphs>());
+ sawDrawGlyphs = true;
+ }
+
+ EXPECT_GT(displayList.sizeInBytes(), 0U);
+ EXPECT_TRUE(sawDrawGlyphs);
+ };
+
+ // Ensure that both contexts have text painting commands.
+ runTest(primaryDisplayList);
+ runTest(secondaryDisplayList);
+}
+
} // namespace TestWebKitAPI
#endif // USE(CG)