Skip to content

Conversation

fujii
Copy link
Contributor

@fujii fujii commented Nov 10, 2024

5bd5f37

[Win] Add an alternative Skia backend support
https://bugs.webkit.org/show_bug.cgi?id=269117

Reviewed by Carlos Garcia Campos.

Build out the bundled Skia. Harfbuzz is required.

> build-webkit --cmakeargs="-DUSE_SKIA=1"

There are still some problems.
* custom fonts don't work.
* pixel formats of video isn't correct
* linked font doesn't work.
* Not implemented yet: GraphicsContext::releaseWindowsContext, DragImageWin.cpp and ImageAdapterWin.cpp

* Source/ThirdParty/skia/CMakeLists.txt:
* Source/WebCore/PlatformWin.cmake:
* Source/WebCore/platform/graphics/Color.h:
* Source/WebCore/platform/graphics/FontCache.cpp:
* Source/WebCore/platform/graphics/FontCache.h:
* Source/WebCore/platform/graphics/FontCustomPlatformData.h:
* Source/WebCore/platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformDataAttributes::FontPlatformDataAttributes):
(WebCore::FontPlatformData::hfont const):
* Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp:
(WebCore::FontCache::platformInit):
(WebCore::FontCache::fontManager const):
* Source/WebCore/platform/graphics/skia/FontPlatformDataSkia.cpp:
(WebCore::FontPlatformData::create):
(WebCore::FontPlatformData::attributes const):
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaBackend.h:
* Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp:
(WebCore::BitmapTexture::updateContents):
* Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData):
* Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp:
(WebCore::GraphicsContext::releaseWindowsContext):
* Source/WebCore/platform/graphics/win/ImageAdapterWin.cpp:
(WebCore::ImageAdapter::getHBITMAPOfSize):
(WebCore::ImageAdapter::nativeImageOfHBITMAP):
* Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
(WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::paintCurrentFrame):
* Source/WebCore/platform/graphics/win/cairo/FontPlatformDataWinCairo.cpp:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::platformIsEqual const):
(WebCore::FontPlatformData::familyName const):
* Source/WebCore/platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink):
(WebCore::createDragImageFromImage):
(WebCore::scaleDragImage):
* Source/WebKit/PlatformWin.cmake:
* Source/WebKit/Platform/Skia.cmake:
* Source/WebKit/Shared/WebCoreArgumentCoders.h:
* Source/WebKit/Shared/WebCoreFont.serialization.in:
* Source/WebKit/Shared/skia/Skia.serialization.in: Added.
* Source/WebKit/Shared/skia/WebCoreArgumentCodersSkia.cpp:
(IPC::ArgumentCoder<SkString>::encode):
(IPC::ArgumentCoder<SkString>::decode):
(IPC::ArgumentCoder<SkFontStyle::Slant>::encode):
(IPC::ArgumentCoder<SkFontStyle::Slant>::decode):
* Source/WebKit/Shared/win/WebCoreArgumentCodersWin.cpp:
* Source/WebKit/UIProcess/BackingStore.h:
* Source/WebKit/UIProcess/skia/BackingStoreSkia.cpp:
(WebKit::BackingStore::paint):
* Source/WebKit/UIProcess/win/WebPopupMenuProxyWin.cpp:
(WebKit::WebPopupMenuProxyWin::paint):
* Source/WebKit/UIProcess/win/WebPopupMenuProxyWin.h:
* Source/WebKit/UIProcess/win/WebView.cpp:
(WebKit::WebView::paint):
* Source/cmake/OptionsWin.cmake:
* Tools/ImageDiff/PlatformWin.cmake:
* Tools/TestWebKitAPI/Tests/WebCore/win/LinkedFonts.cpp:
* Tools/WebKitTestRunner/PlatformWin.cmake:
* Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp:
(WTR::generateCairoSurfaceFromBitmap):
(WTR::PlatformWebView::windowSnapshotImage):

Canonical link: https://commits.webkit.org/286632@main

fc99e13

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🛠 🧪 jsc ✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 🧪 jsc-arm64 ✅ 🛠 vision 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 🧪 mac-intel-wk2 ✅ 🛠 jsc-armv7
✅ 🛠 🧪 unsafe-merge ✅ 🛠 tv ✅ 🛠 mac-safer-cpp ✅ 🧪 jsc-armv7-tests
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@fujii fujii self-assigned this Nov 10, 2024
@fujii fujii added the CMake Bugzilla component for CMake build system changes label Nov 10, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Nov 11, 2024
@fujii fujii removed the merging-blocked Applied to prevent a change from being merged label Nov 11, 2024
Copy link
Contributor

@donny-dont donny-dont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this is fine in terms of the build but have one large issue with it

We should not be hand rolling any serialization code and land #27902 . Can you check to see if it works for you?

Other thing is do we really need harfbuzz? If we can avoid adding it in that would be ideal.

Comment on lines +219 to +223
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this SkImage always unaccelerated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, at the moment.

// Making an unconditionally unaccelerated buffer here is OK because this code
// isn't used by any platforms that respect the accelerated bit.
auto imageBuffer = ImageBuffer::create(targetRect.size(), RenderingPurpose::Unspecified, 1, DestinationColorSpace::SRGB(), ImageBufferPixelFormat::BGRA8);

ImageBufferOptions::Accelerated has to be specified.

Comment on lines +23 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we add this to WebCoreFont with a skia ifdef? I'm not sure we want a generic Skia file for serializations, I think it's better to have different files for different things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all skia types SkString, SkFontStyle::Slant, SkColorSpace, SkData can be moved to this Skia.serialization.in.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Nov 14, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use serialization.in files instead of this.

Copy link
Contributor Author

@fujii fujii Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need more documents to migrate. It took hours to me to find out the undocumented "wrapped by" keyword.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapped by is only for ObjC type. I can't use it for Skia types now. Needs to modify generate-serializers.py. Will try in a follow up patch.

@fujii fujii removed the merging-blocked Applied to prevent a change from being merged label Nov 15, 2024
@fujii fujii added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 15, 2024
https://bugs.webkit.org/show_bug.cgi?id=269117

Reviewed by Carlos Garcia Campos.

Build out the bundled Skia. Harfbuzz is required.

> build-webkit --cmakeargs="-DUSE_SKIA=1"

There are still some problems.
* custom fonts don't work.
* pixel formats of video isn't correct
* linked font doesn't work.
* Not implemented yet: GraphicsContext::releaseWindowsContext, DragImageWin.cpp and ImageAdapterWin.cpp

* Source/ThirdParty/skia/CMakeLists.txt:
* Source/WebCore/PlatformWin.cmake:
* Source/WebCore/platform/graphics/Color.h:
* Source/WebCore/platform/graphics/FontCache.cpp:
* Source/WebCore/platform/graphics/FontCache.h:
* Source/WebCore/platform/graphics/FontCustomPlatformData.h:
* Source/WebCore/platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformDataAttributes::FontPlatformDataAttributes):
(WebCore::FontPlatformData::hfont const):
* Source/WebCore/platform/graphics/skia/FontCacheSkia.cpp:
(WebCore::FontCache::platformInit):
(WebCore::FontCache::fontManager const):
* Source/WebCore/platform/graphics/skia/FontPlatformDataSkia.cpp:
(WebCore::FontPlatformData::create):
(WebCore::FontPlatformData::attributes const):
* Source/WebCore/platform/graphics/skia/ImageBufferSkiaBackend.h:
* Source/WebCore/platform/graphics/texmap/BitmapTexture.cpp:
(WebCore::BitmapTexture::updateContents):
* Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData):
* Source/WebCore/platform/graphics/win/GraphicsContextWin.cpp:
(WebCore::GraphicsContext::releaseWindowsContext):
* Source/WebCore/platform/graphics/win/ImageAdapterWin.cpp:
(WebCore::ImageAdapter::getHBITMAPOfSize):
(WebCore::ImageAdapter::nativeImageOfHBITMAP):
* Source/WebCore/platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp:
(WebCore::MediaPlayerPrivateMediaFoundation::Direct3DPresenter::paintCurrentFrame):
* Source/WebCore/platform/graphics/win/cairo/FontPlatformDataWinCairo.cpp:
(WebCore::FontPlatformData::FontPlatformData):
(WebCore::FontPlatformData::platformIsEqual const):
(WebCore::FontPlatformData::familyName const):
* Source/WebCore/platform/win/DragImageWin.cpp:
(WebCore::createDragImageForLink):
(WebCore::createDragImageFromImage):
(WebCore::scaleDragImage):
* Source/WebKit/PlatformWin.cmake:
* Source/WebKit/Platform/Skia.cmake:
* Source/WebKit/Shared/WebCoreArgumentCoders.h:
* Source/WebKit/Shared/WebCoreFont.serialization.in:
* Source/WebKit/Shared/skia/Skia.serialization.in: Added.
* Source/WebKit/Shared/skia/WebCoreArgumentCodersSkia.cpp:
(IPC::ArgumentCoder<SkString>::encode):
(IPC::ArgumentCoder<SkString>::decode):
(IPC::ArgumentCoder<SkFontStyle::Slant>::encode):
(IPC::ArgumentCoder<SkFontStyle::Slant>::decode):
* Source/WebKit/Shared/win/WebCoreArgumentCodersWin.cpp:
* Source/WebKit/UIProcess/BackingStore.h:
* Source/WebKit/UIProcess/skia/BackingStoreSkia.cpp:
(WebKit::BackingStore::paint):
* Source/WebKit/UIProcess/win/WebPopupMenuProxyWin.cpp:
(WebKit::WebPopupMenuProxyWin::paint):
* Source/WebKit/UIProcess/win/WebPopupMenuProxyWin.h:
* Source/WebKit/UIProcess/win/WebView.cpp:
(WebKit::WebView::paint):
* Source/cmake/OptionsWin.cmake:
* Tools/ImageDiff/PlatformWin.cmake:
* Tools/TestWebKitAPI/Tests/WebCore/win/LinkedFonts.cpp:
* Tools/WebKitTestRunner/PlatformWin.cmake:
* Tools/WebKitTestRunner/win/PlatformWebViewWin.cpp:
(WTR::generateCairoSurfaceFromBitmap):
(WTR::PlatformWebView::windowSnapshotImage):

Canonical link: https://commits.webkit.org/286632@main
@webkit-commit-queue
Copy link
Collaborator

Committed 286632@main (5bd5f37): https://commits.webkit.org/286632@main

Reviewed commits have been landed. Closing PR #36469 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 5bd5f37 into WebKit:main Nov 15, 2024
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake Bugzilla component for CMake build system changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants