WebKit Bugzilla
Attachment 347605 Details for
Bug 185764
: [WPE] Rendering on a HiDPI display looks scaled up instead of rendered at 2x
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
patch (text/plain), 7.56 KB, created by
Carlos Bentzen
on 2018-08-20 20:29:05 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Carlos Bentzen
Created:
2018-08-20 20:29:05 PDT
Size:
7.56 KB
patch
obsolete
>commit 2a9efb5d5165817bbd466c768f81bd5d37b677aa >Author: Carlos Eduardo Ramalho <cadubentzen@gmail.com> >Date: Tue Aug 21 00:23:16 2018 -0300 > > WIP > >diff --git a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >index fffcb11fee4..b6f2e092644 100644 >--- a/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >+++ b/Source/WebKit/UIProcess/API/wpe/WPEView.cpp >@@ -89,6 +89,13 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC > view.frameDisplayed(); > }, > // padding >+ // Maybe use one of these paddings to send device scale factor back here? >+ // like so: >+ // [](void* data, uint32_t scale) >+ // { >+ // auto& view = *reinterpret_cast<View*>(data); >+ // view.page().setIntrinsicDeviceScaleFactor(scale); >+ // } > nullptr, > nullptr, > nullptr, >@@ -140,6 +147,14 @@ View::View(struct wpe_view_backend* backend, const API::PageConfiguration& baseC > wpe_view_backend_initialize(m_backend); > > m_pageProxy->initializeWebPage(); >+ >+ // FIXME: figure out how to get device scale back here properly. >+ const gchar* WPE_SCALE = g_getenv("WPE_SCALE"); >+ int scale = 1; >+ if (WPE_SCALE) >+ scale = std::atoi(WPE_SCALE); >+ scale = std::max(1, std::min(scale, 10)); >+ m_pageProxy->setIntrinsicDeviceScaleFactor(scale); > } > > View::~View() >diff --git a/Tools/wpe/backends/ViewBackend.h b/Tools/wpe/backends/ViewBackend.h >index 63e9f8bfb02..235687f3f4c 100644 >--- a/Tools/wpe/backends/ViewBackend.h >+++ b/Tools/wpe/backends/ViewBackend.h >@@ -71,6 +71,7 @@ protected: > > uint32_t m_width { 0 }; > uint32_t m_height { 0 }; >+ uint32_t m_scale { 1 }; > EGLDisplay m_eglDisplay { nullptr }; > EGLContext m_eglContext { nullptr }; > EGLConfig m_eglConfig; >diff --git a/Tools/wpe/backends/WindowViewBackend.cpp b/Tools/wpe/backends/WindowViewBackend.cpp >index 65221e1db16..5e4e2585ed3 100644 >--- a/Tools/wpe/backends/WindowViewBackend.cpp >+++ b/Tools/wpe/backends/WindowViewBackend.cpp >@@ -103,14 +103,19 @@ const struct wl_registry_listener WindowViewBackend::s_registryListener = { > { > auto* window = static_cast<WindowViewBackend*>(data); > >- if (!std::strcmp(interface, "wl_compositor")) >- window->m_compositor = static_cast<struct wl_compositor*>(wl_registry_bind(registry, name, &wl_compositor_interface, 1)); >+ if (!std::strcmp(interface, "wl_compositor")) { >+ // Version 3 is required for wl_surface_set_buffer_scale() >+ window->m_compositor = static_cast<struct wl_compositor*>(wl_registry_bind(registry, name, &wl_compositor_interface, 3)); >+ } > > if (!std::strcmp(interface, "zxdg_shell_v6")) > window->m_xdg = static_cast<struct zxdg_shell_v6*>(wl_registry_bind(registry, name, &zxdg_shell_v6_interface, 1)); > > if (!std::strcmp(interface, "wl_seat")) > window->m_seat = static_cast<struct wl_seat*>(wl_registry_bind(registry, name, &wl_seat_interface, 4)); >+ >+ if (!std::strcmp(interface, "wl_output")) >+ window->m_output = static_cast<struct wl_output*>(wl_registry_bind(registry, name, &wl_output_interface, 2)); > }, > // global_remove > [](void*, struct wl_registry*, uint32_t) { }, >@@ -145,8 +150,8 @@ const struct wl_pointer_listener WindowViewBackend::s_pointerListener = { > [](void* data, struct wl_pointer*, uint32_t time, wl_fixed_t fixedX, wl_fixed_t fixedY) > { > auto& window = *static_cast<WindowViewBackend*>(data); >- int x = wl_fixed_to_int(fixedX); >- int y = wl_fixed_to_int(fixedY); >+ int x = wl_fixed_to_int(fixedX) * window.m_scale; >+ int y = wl_fixed_to_int(fixedY) * window.m_scale; > window.m_seatData.pointer.coords = { x, y }; > > if (window.m_seatData.pointer.target) { >@@ -442,6 +447,21 @@ const struct zxdg_toplevel_v6_listener WindowViewBackend::s_xdgToplevelListener > [](void*, struct zxdg_toplevel_v6*) { }, > }; > >+const struct wl_output_listener WindowViewBackend::s_outputListener = { >+ // geometry >+ [](void*, struct wl_output*, int, int, int, int, int, const char*, const char*, int32_t) { }, >+ // mode >+ [](void*, struct wl_output *, uint32_t, int, int, int) { }, >+ // done >+ [](void*, struct wl_output*) { }, >+ // scale >+ [](void* data, struct wl_output*, int32_t scale) >+ { >+ auto& window = *static_cast<WindowViewBackend*>(data); >+ window.m_scale = scale; >+ }, >+}; >+ > WindowViewBackend::WindowViewBackend(uint32_t width, uint32_t height) > : ViewBackend(width, height) > { >@@ -463,6 +483,12 @@ WindowViewBackend::WindowViewBackend(uint32_t width, uint32_t height) > > if (m_seat) > wl_seat_add_listener(m_seat, &s_seatListener, this); >+ >+ if (m_output) { >+ wl_output_add_listener(m_output, &s_outputListener, this); >+ // One more round to wait for the scale, as it is needed when creating the surface below >+ wl_display_roundtrip(m_display); >+ } > } > > m_eventSource = g_source_new(&EventSource::sourceFuncs, sizeof(EventSource)); >@@ -481,6 +507,7 @@ WindowViewBackend::WindowViewBackend(uint32_t width, uint32_t height) > } > > m_surface = wl_compositor_create_surface(m_compositor); >+ wl_surface_set_buffer_scale(m_surface, m_scale); > if (m_xdg) { > m_xdgSurface = zxdg_shell_v6_get_xdg_surface(m_xdg, m_surface); > zxdg_surface_v6_add_listener(m_xdgSurface, &s_xdgSurfaceListener, nullptr); >@@ -492,7 +519,19 @@ WindowViewBackend::WindowViewBackend(uint32_t width, uint32_t height) > } > } > >- m_eglWindow = wl_egl_window_create(m_surface, m_width, m_height); >+ // From the wayland protocol: >+ // "Note that if the scale is larger than 1, then you have to attach >+ // a buffer that is larger (by a factor of scale in each dimension) >+ // than the desired surface size." >+ m_eglWindow = wl_egl_window_create(m_surface, m_width * m_scale, m_height * m_scale); >+ >+ { >+ // FIXME: figure out how to pass this scale to WPEView properly. >+ // Maybe through wpe_view_backend_client? >+ gchar* scale = g_strdup_printf("%d", m_scale); >+ g_setenv("WPE_SCALE", scale, true); >+ g_free(scale); >+ } > > auto createPlatformWindowSurface = > reinterpret_cast<PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC>(eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT")); >@@ -576,6 +615,9 @@ WindowViewBackend::~WindowViewBackend() > if (m_seat) > wl_seat_destroy(m_seat); > >+ if (m_output) >+ wl_output_destroy(m_output); >+ > if (m_compositor) > wl_compositor_destroy(m_compositor); > >diff --git a/Tools/wpe/backends/WindowViewBackend.h b/Tools/wpe/backends/WindowViewBackend.h >index b7737fc1069..cffaf66f736 100644 >--- a/Tools/wpe/backends/WindowViewBackend.h >+++ b/Tools/wpe/backends/WindowViewBackend.h >@@ -53,6 +53,7 @@ private: > static const struct wl_callback_listener s_frameListener; > static const struct zxdg_surface_v6_listener s_xdgSurfaceListener; > static const struct zxdg_toplevel_v6_listener s_xdgToplevelListener; >+ static const struct wl_output_listener s_outputListener; > > void handleKeyEvent(uint32_t key, uint32_t state, uint32_t time); > uint32_t modifiers() const; >@@ -97,6 +98,7 @@ private: > struct wl_compositor* m_compositor { nullptr }; > struct zxdg_shell_v6* m_xdg { nullptr }; > struct wl_seat* m_seat { nullptr }; >+ struct wl_output* m_output { nullptr }; > GSource* m_eventSource { nullptr }; > struct wl_surface* m_surface { nullptr }; > struct zxdg_surface_v6* m_xdgSurface { nullptr };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185764
:
340688
|
343499
|
343891
|
347582
|
347583
| 347605 |
369485
|
369525
|
369667