Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Skia] Fix support for custom cursors #25372

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions Source/WebCore/platform/graphics/skia/ShareableBitmapSkia.cpp
Expand Up @@ -69,14 +69,21 @@ void ShareableBitmap::paint(GraphicsContext&, float /*scaleFactor*/, const IntPo

RefPtr<Image> ShareableBitmap::createImage()
{
notImplemented();
return nullptr;
return BitmapImage::create(createPlatformImage(BackingStoreCopy::DontCopyBackingStore));
}

PlatformImagePtr ShareableBitmap::createPlatformImage(BackingStoreCopy, ShouldInterpolate)
PlatformImagePtr ShareableBitmap::createPlatformImage(BackingStoreCopy backingStoreCopy, ShouldInterpolate)
{
notImplemented();
return nullptr;
sk_sp<SkData> pixelData;
if (backingStoreCopy == BackingStoreCopy::CopyBackingStore)
pixelData = SkData::MakeWithCopy(data(), sizeInBytes());
else {
ref();
pixelData = SkData::MakeWithProc(data(), sizeInBytes(), [](const void*, void* bitmap) -> void {
static_cast<ShareableBitmap*>(bitmap)->deref();
}, this);
}
return SkImages::RasterFromData(m_configuration.imageInfo(), pixelData, bytesPerRow());
}

void ShareableBitmap::setOwnershipOfMemory(const ProcessIdentity&)
Expand Down
22 changes: 21 additions & 1 deletion Source/WebKit/UIProcess/API/wpe/WPEWebView.cpp
Expand Up @@ -53,6 +53,12 @@
#include <cairo.h>
#endif

#if USE(SKIA)
IGNORE_CLANG_WARNINGS_BEGIN("cast-align")
#include <skia/core/SkPixmap.h>
IGNORE_CLANG_WARNINGS_END
#endif

#if ENABLE(WPE_PLATFORM)
#include "ScreenManager.h"
#include <wpe/wpe-platform.h>
Expand Down Expand Up @@ -952,7 +958,21 @@ void View::setCursor(const WebCore::Cursor& cursor)
WebCore::IntPoint hotspot = WebCore::determineHotSpot(image.get(), cursor.hotSpot());
wpe_view_set_cursor_from_bytes(m_wpeView.get(), bytes.get(), width, height, stride, hotspot.x(), hotspot.y());
#elif USE(SKIA)
// FIXME: implement.
auto nativeImage = cursor.image()->nativeImageForCurrentFrame();
if (!nativeImage)
return;

SkPixmap pixmap;
auto platformImage = nativeImage->platformImage();
ASSERT(platformImage->peekPixels(&pixmap));

platformImage->ref();
GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_with_free_func(pixmap.addr(), pixmap.computeByteSize(), [](gpointer data) {
static_cast<SkImage*>(data)->unref();
}, platformImage.get()));

WebCore::IntPoint hotspot = WebCore::determineHotSpot(cursor.image().get(), cursor.hotSpot());
wpe_view_set_cursor_from_bytes(m_wpeView.get(), bytes.get(), pixmap.width(), pixmap.height(), pixmap.rowBytes(), hotspot.x(), hotspot.y());
#endif
#else
UNUSED_PARAM(cursor);
Expand Down