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

Device pixel ratio #5371

Merged
merged 4 commits into from
Nov 28, 2024
Merged

Device pixel ratio #5371

merged 4 commits into from
Nov 28, 2024

Conversation

belen-albeza
Copy link
Contributor

@belen-albeza belen-albeza commented Nov 25, 2024

Closes https://tree.taiga.io/project/penpot/task/9337 and fixes https://tree.taiga.io/project/penpot/task/9421

⚠️ A screen with a device pixel ratio > 1.0 is needed to test this PR fully. You can check the pixel ratio by typing in the browser console devicePixelRatio.

In this PR:

  • We take into account the device pixel ratio (aka DPR) to render shapes. This requires to have a bigger canvas to acomodate for higher pixel densities, and also bigger Skia surfaces.
  • Using the DPR is walled behind a config flag enable-render-wasm-dpr.
  • I introduced some refactors because the render code was a bit tricky and too long to follow.
    • The RenderState now holds the Viewbox (instead of State and passing it to RenderState in each method call)
    • Renamed Viewbox's x and y to pan_x and pan_y (since we stored them in the negative, like panning).
    • The logic to determined whether an image cached needed to be regenerated o no has been moved to its own method and now uses Skia's Rect.contains. I'm not sure if this logic mimics exactly what @superalex did (I think I need a drawing of the check he intended)

Note that a large DPR hits performance greatly (for instance 2.0 dpr for a 4K display means surfaces with 4x pixels). The avatars example file we're using gets a bit laggy when zoomed out (OTOH when we introduce more performance improvements, this will benefit as well)

@belen-albeza belen-albeza force-pushed the ladybenko-9337-pixel-ratio branch 3 times, most recently from aa6c638 to 15ed49e Compare November 27, 2024 11:29
@belen-albeza belen-albeza marked this pull request as ready for review November 27, 2024 11:29
@belen-albeza belen-albeza changed the title [WIP] Device pixel ratio Device pixel ratio Nov 27, 2024
@AzazelN28 AzazelN28 merged commit 9a9815e into develop Nov 28, 2024
5 checks passed
@AzazelN28 AzazelN28 deleted the ladybenko-9337-pixel-ratio branch November 28, 2024 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants