commit | 075931ac30dcae1739e575539dfc139918725298 | [log] [tgz] |
---|---|---|
author | heycam@apple.com <heycam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Fri Jun 17 01:38:03 2022 +0000 |
committer | heycam@apple.com <heycam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Fri Jun 17 01:38:03 2022 +0000 |
tree | 6399ea07ef6e0d1b14fcabb35fd9b5427c7e9848 | |
parent | 60038767ed9b7b31dc145416674e02e151cd169b [diff] |
Add a new DrawDecomposedGlyphs display list item to avoid repeatedly sending glyphs when using the GlyphDisplayListCache https://bugs.webkit.org/show_bug.cgi?id=240497 <rdar://93387615> Reviewed by Simon Fraser. The GlyphDisplayListCache is used to record a display list for frequently painting text content. With GPU Process DOM rendering, there is significant overhead in sending the contents of these display lists over IPC. The contents of these display lists don't change if the text content in the document doesn't change, so we could greatly reduce the overhead by treating the data inside a display list item for glyph drawing as a remote resource. This commit adds: * a new display list item, DrawDecomposedGlyphs, to represent drawing a glyph list resource * a new class, DecomposedGlyphs, which is the resource type * a new struct, PositionedGlyphs, to provide a common place for the glyph drawing fields (the vector of glyph IDs, the anchor position, etc.) to live, so that we don't have duplication between DisplayList::DrawGlyphs and DecomposedGlyphs So that a DrawDecomposedGlyphs command can be replayed from a GlyphDisplayListCache's in-memory display list and recorded to a RemoteDisplayListRecorder, the GraphicsContext API gains a new drawDecomposedGlyphs function. A new argument to the DisplayList::RecordImpl constructor (and the DrawGlyphsRecorder) is added to represent how to record drawText commands: * DrawGlyphsMode::Normal, which records each GraphicsContext::drawText call with a single DrawText command * DrawGlyphsMode::DeconstructToDrawGlyphsCommands, which ensures different text layers get deconstructed into separate DrawText commands * DrawGlyphsMode::DeconstructToDrawDecomposedGlyphsCommands, which ensures different text layers get desconstructed into separate DrawDecomposedGlyphs commands FontCascade::displayListForTextRun is updated to use that last value. Additionally, GlyphDisplayListCache is extended to cache display lists keyed off TextRun/FontCascade/etc. values. This allows sharing of the same cached display list between different elements on the page that have the same text content. This sharing would not be valid if the two elements have different values for the color property, and the text contains COLRv0 glyphs that alternate painting of specific colors and the color fill color, since the recording would incorrectly record a setFillBrush command corresponding to the first element's fill color. Rather than extend the glyph recorder to parameterize the current fill (and stroke) colors, we detect when outlines are drawn with colors other than the context's initial colors, and prevent sharing. This is done by checking whether the recorded display list contains items that aren't known to be safe for sharing. Similarly, if the sharing would not be valid if the contains bitmap images (like those from emoji fonts) or SVG glyphs, both of which are captured as DrawNativeImage commands, if the text is drawn at different scales. This is because the size of the images is dependent on the scale. We detect and prevent reuse across different text runs if the scale is different, by checking the recorded display list for DrawNativeImage commands and by storing the context scale on the GlyphDisplayListCache::Entry. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-color-expected.txt: * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-colr-unshared-expected.txt: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-colr-unshared.html: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-scaled-unshared-expected.txt: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-scaled-unshared.html: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shadow-unshared-expected.txt: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shadow-unshared.html: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shared-expected.txt: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-shared.html: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-svg-unshared-expected.txt: Added. * LayoutTests/fast/text/glyph-display-lists/glyph-display-list-svg-unshared.html: Added. * Source/WTF/wtf/PlatformHave.h: * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/page/MemoryRelease.cpp: (WebCore::releaseNoncriticalMemory): * Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp: (WebCore::BifurcatedGraphicsContext::drawDecomposedGlyphs): * Source/WebCore/platform/graphics/BifurcatedGraphicsContext.h: * Source/WebCore/platform/graphics/DecomposedGlyphs.cpp: Added. (WebCore::DecomposedGlyphs::create): (WebCore::DecomposedGlyphs::DecomposedGlyphs): (WebCore::m_renderingResourceIdentifier): * Source/WebCore/platform/graphics/DecomposedGlyphs.h: Added. (WebCore::DecomposedGlyphs::positionedGlyphs const): (WebCore::DecomposedGlyphs::bounds const): (WebCore::DecomposedGlyphs::addObserver): (WebCore::DecomposedGlyphs::removeObserver): (WebCore::DecomposedGlyphs::renderingResourceIdentifier const): * Source/WebCore/platform/graphics/FontCascade.cpp: (WebCore::FontCascade::displayListForTextRun const): * Source/WebCore/platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::drawDecomposedGlyphs): * Source/WebCore/platform/graphics/GraphicsContext.h: (WebCore::GraphicsContext::drawGlyphsAndCacheResources): (WebCore::GraphicsContext::drawGlyphsAndCacheFont): Deleted. * Source/WebCore/platform/graphics/NullGraphicsContext.h: * Source/WebCore/platform/graphics/PositionedGlyphs.cpp: Copied from Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp. (WebCore::PositionedGlyphs::computeBounds const): * Source/WebCore/platform/graphics/PositionedGlyphs.h: Added. (WebCore::PositionedGlyphs::PositionedGlyphs): (WebCore::PositionedGlyphs::encode const): (WebCore::PositionedGlyphs::decode): * Source/WebCore/platform/graphics/TextRun.cpp: (WebCore::operator<<): * Source/WebCore/platform/graphics/TextRun.h: (WebCore::TextRun::TextRun): (WebCore::TextRun::isHashTableEmptyValue const): (WebCore::TextRun::isHashTableDeletedValue const): (WebCore::TextRun::isolatedCopy const): * Source/WebCore/platform/graphics/TextRunHash.h: Added. (WebCore::add): (WebCore::TextRun::operator== const): (WebCore::TextRunHash::hash): (WebCore::TextRunHash::equal): (WTF::HashTraits<WebCore::TextRun>::isDeletedValue): (WTF::HashTraits<WebCore::TextRun>::isEmptyValue): (WTF::HashTraits<WebCore::TextRun>::constructDeletedValue): (WTF::HashTraits<WebCore::TextRun>::emptyValue): * Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContextCairo::drawDecomposedGlyphs): * Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.h: * Source/WebCore/platform/graphics/coretext/DrawGlyphsRecorderCoreText.cpp: (WebCore::DrawGlyphsRecorder::createInternalContext): (WebCore::DrawGlyphsRecorder::updateCTM): (WebCore::DrawGlyphsRecorder::recordDrawGlyphs): * Source/WebCore/platform/graphics/displaylists/DisplayList.cpp: (WebCore::DisplayList::DisplayList::description const): (WebCore::DisplayList::DisplayList::append): * Source/WebCore/platform/graphics/displaylists/DisplayList.h: (WebCore::DisplayList::DisplayList::cacheDecomposedGlyphs): * Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp: (WebCore::DisplayList::ItemHandle::apply): (WebCore::DisplayList::ItemHandle::destroy): (WebCore::DisplayList::ItemHandle::safeCopy const): * Source/WebCore/platform/graphics/displaylists/DisplayListItemType.cpp: (WebCore::DisplayList::sizeOfItemInBytes): (WebCore::DisplayList::isDrawingItem): (WebCore::DisplayList::isInlineItem): * Source/WebCore/platform/graphics/displaylists/DisplayListItemType.h: * Source/WebCore/platform/graphics/displaylists/DisplayListItems.cpp: (WebCore::DisplayList::DrawGlyphs::DrawGlyphs): (WebCore::DisplayList::m_bounds): (WebCore::DisplayList::DrawGlyphs::apply const): (WebCore::DisplayList::DrawDecomposedGlyphs::apply const): (WebCore::DisplayList::operator<<): (WebCore::DisplayList::dumpItem): (WebCore::DisplayList::dumpItemHandle): (WebCore::DisplayList::DrawGlyphs::computeBounds): Deleted. * Source/WebCore/platform/graphics/displaylists/DisplayListItems.h: (WebCore::DisplayList::DrawGlyphs::localAnchor const): (WebCore::DisplayList::DrawGlyphs::anchorPoint const): (WebCore::DisplayList::DrawGlyphs::glyphs const): (WebCore::DisplayList::DrawGlyphs::encode const): (WebCore::DisplayList::DrawGlyphs::decode): (WebCore::DisplayList::DrawDecomposedGlyphs::DrawDecomposedGlyphs): (WebCore::DisplayList::DrawDecomposedGlyphs::fontIdentifier const): (WebCore::DisplayList::DrawDecomposedGlyphs::decomposedGlyphsIdentifier const): (WebCore::DisplayList::DrawDecomposedGlyphs::globalBounds const): (WebCore::DisplayList::DrawDecomposedGlyphs::localBounds const): * Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp: (WebCore::DisplayList::Recorder::Recorder): (WebCore::DisplayList::Recorder::shouldDeconstructDrawGlyphs const): (WebCore::DisplayList::Recorder::drawGlyphs): (WebCore::DisplayList::Recorder::drawDecomposedGlyphs): (WebCore::DisplayList::Recorder::drawGlyphsAndCacheResources): (WebCore::DisplayList::Recorder::drawGlyphsAndCacheFont): Deleted. * Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h: * Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.cpp: (WebCore::DisplayList::RecorderImpl::RecorderImpl): (WebCore::DisplayList::RecorderImpl::recordDrawDecomposedGlyphs): (WebCore::DisplayList::RecorderImpl::recordResourceUse): * Source/WebCore/platform/graphics/displaylists/DisplayListRecorderImpl.h: * Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.cpp: (WebCore::DisplayList::applyDrawDecomposedGlyphs): (WebCore::DisplayList::Replayer::applyItem): (WebCore::DisplayList::Replayer::replay): * Source/WebCore/platform/graphics/displaylists/DisplayListReplayer.h: * Source/WebCore/platform/graphics/displaylists/DisplayListResourceHeap.h: (WebCore::DisplayList::LocalResourceHeap::add): * Source/WebCore/platform/graphics/harfbuzz/DrawGlyphsRecorderHarfBuzz.cpp: (WebCore::DrawGlyphsRecorder::drawGlyphs): * Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.cpp: (Nicosia::CairoOperationRecorder::drawDecomposedGlyphs): * Source/WebCore/platform/graphics/nicosia/cairo/NicosiaCairoOperationRecorder.h: * Source/WebCore/platform/graphics/win/DrawGlyphsRecorderWin.cpp: (WebCore::DrawGlyphsRecorder::drawGlyphs): * Source/WebCore/platform/text/TextDirection.h: (WebCore::operator<<): * Source/WebCore/platform/text/TextFlags.cpp: (WebCore::operator<<): * Source/WebCore/platform/text/TextFlags.h: (WebCore::ExpansionBehavior::operator== const): * Source/WebCore/rendering/GlyphDisplayListCache.cpp: Added. (WebCore::canShareDisplayListWithItem): (WebCore::add): (WebCore::GlyphDisplayListCacheKeyTranslator::hash): (WebCore::GlyphDisplayListCacheKeyTranslator::equal): (WebCore::GlyphDisplayListCache::singleton): (WebCore::GlyphDisplayListCache::clear): (WebCore::GlyphDisplayListCache::size const): (WebCore::GlyphDisplayListCache::sizeInBytes const): (WebCore::GlyphDisplayListCache::get): (WebCore::GlyphDisplayListCache::getIfExists): (WebCore::GlyphDisplayListCache::remove): (WebCore::GlyphDisplayListCache::canShareDisplayList): (WebCore::GlyphDisplayListCacheEntry::~GlyphDisplayListCacheEntry): * Source/WebCore/rendering/GlyphDisplayListCache.h: (WebCore::GlyphDisplayListCacheEntry::create): (WebCore::GlyphDisplayListCacheEntry::operator== const): (WebCore::GlyphDisplayListCacheEntry::displayList): (WebCore::GlyphDisplayListCacheEntry::GlyphDisplayListCacheEntry): (WebCore::add): (WebCore::GlyphDisplayListCacheEntryHash::hash): (WebCore::GlyphDisplayListCacheEntryHash::equal): (WebCore::GlyphDisplayListCache::get): (WebCore::GlyphDisplayListCache::getIfExists): (WebCore::GlyphDisplayListCache::remove): (WebCore::GlyphDisplayListCache::singleton): Deleted. (WebCore::GlyphDisplayListCache::clear): Deleted. (WebCore::GlyphDisplayListCache::size const): Deleted. (WebCore::GlyphDisplayListCache::sizeInBytes const): Deleted. * Source/WebCore/rendering/RenderLayerCompositor.cpp: * Source/WebCore/rendering/TextPainter.cpp: (WebCore::TextPainter::clearGlyphDisplayLists): Deleted. * Source/WebCore/rendering/TextPainter.h: (WebCore::TextPainter::setGlyphDisplayListIfNeeded): (WebCore::TextPainter::removeGlyphDisplayList): (WebCore::TextPainter::glyphDisplayListIfExists): * Source/WebCore/testing/Internals.cpp: (WebCore::toDisplayListFlags): (WebCore::Internals::displayListForElement): (WebCore::Internals::replayDisplayListForElement): (WebCore::Internals::cachedGlyphDisplayListsForTextNode): * Source/WebCore/testing/Internals.h: * Source/WebCore/testing/Internals.idl: * Source/WebKit/GPUProcess/graphics/QualifiedResourceHeap.h: (WebKit::QualifiedResourceHeap::add): (WebKit::QualifiedResourceHeap::getDecomposedGlyphs const): (WebKit::QualifiedResourceHeap::removeDecomposedGlyphs): (WebKit::QualifiedResourceHeap::checkInvariants const): * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp: (WebKit::RemoteDisplayListRecorder::drawDecomposedGlyphs): (WebKit::RemoteDisplayListRecorder::drawDecomposedGlyphsWithQualifiedIdentifiers): * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h: * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.messages.in: * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp: (WebKit::RemoteRenderingBackend::cacheFontWithQualifiedIdentifier): (WebKit::RemoteRenderingBackend::cacheDecomposedGlyphs): (WebKit::RemoteRenderingBackend::cacheDecomposedGlyphsWithQualifiedIdentifier): * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h: * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.messages.in: * Source/WebKit/GPUProcess/graphics/RemoteResourceCache.cpp: (WebKit::RemoteResourceCache::cacheDecomposedGlyphs): (WebKit::RemoteResourceCache::cachedDecomposedGlyphs const): (WebKit::RemoteResourceCache::releaseRemoteResource): * Source/WebKit/GPUProcess/graphics/RemoteResourceCache.h: * Source/WebKit/Scripts/webkit/messages.py: * Source/WebKit/Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<DecomposedGlyphs>::encode): (IPC::ArgumentCoder<DecomposedGlyphs>::decode): * Source/WebKit/Shared/WebCoreArgumentCoders.h: * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp: (WebKit::RemoteDisplayListRecorderProxy::RemoteDisplayListRecorderProxy): (WebKit::RemoteDisplayListRecorderProxy::recordDrawDecomposedGlyphs): (WebKit::RemoteDisplayListRecorderProxy::recordResourceUse): * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h: * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp: (WebKit::RemoteRenderingBackendProxy::cacheDecomposedGlyphs): * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h: * Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.cpp: (WebKit::RemoteResourceCacheProxy::~RemoteResourceCacheProxy): (WebKit::RemoteResourceCacheProxy::recordDecomposedGlyphsUse): (WebKit::RemoteResourceCacheProxy::releaseDecomposedGlyphs): (WebKit::RemoteResourceCacheProxy::clearDecomposedGlyphsMap): (WebKit::RemoteResourceCacheProxy::remoteResourceCacheWasDestroyed): * Source/WebKit/WebProcess/GPU/graphics/RemoteResourceCacheProxy.h: Canonical link: https://commits.webkit.org/251626@main git-svn-id: http://svn.webkit.org/repository/webkit/trunk@295621 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.
On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
On Windows, follow the instructions on our website.
Run the following command to clone WebKit's Git SVN repository:
git clone https://github.com/WebKit/WebKit.git WebKit
If you want to be able to track Subversion revision from your git checkout, you can run the following command to do so:
Tools/Scripts/git-webkit setup-git-svn
For information about this, and other aspects of using Git with WebKit, read the wiki page.
Install Xcode and its command line tools if you haven't done so already:
xcode-select --install
Run the following command to build a debug build with debugging symbols and assertions:
Tools/Scripts/build-webkit --debug
For performance testing, and other purposes, use --release
instead.
You can open WebKit.xcworkspace
to build and debug WebKit within Xcode.
If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild
directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild
for both Products and Intermediates.
iOS, tvOS and watchOS are all considered embedded builds. The first time after you install a new Xcode, you will need to run:
sudo Tools/Scripts/configure-xcode-for-embedded-development
Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.
” when building target JSCLLIntOffsetsExtractor
of project JavaScriptCore
.
Run the following command to build a debug build with debugging symbols and assertions for embedded simulators:
Tools/Scripts/build-webkit --debug --<platform>-simulator
or embedded devices:
Tools/Scripts/build-webkit --debug --<platform>-device
where platform
is ios
, tvos
or watchos
.
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/gtk/install-dependencies Tools/Scripts/update-webkitgtk-libs Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK+, see the wiki page.
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/wpe/install-dependencies Tools/Scripts/update-webkitwpe-libs Tools/Scripts/build-webkit --wpe --debug
For building WebKit on Windows, see the wiki page.
Run the following command to launch Safari with your local build of WebKit:
Tools/Scripts/run-safari --debug
The run-safari
script sets the DYLD_FRAMEWORK_PATH
environment variable to point to your build products, and then launches /Applications/Safari.app
. DYLD_FRAMEWORK_PATH
tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks
.
To run other applications with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app <application-path>
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use --release
instead of --debug
.
If you have a development build, you can use the run-minibrowser script, e.g.:
run-minibrowser --debug --wpe
Pass one of --gtk
, --jsc-only
, or --wpe
to indicate the port to use.
Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.