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

Allow querying configured size #237

Open
madsmtm opened this issue Sep 1, 2024 · 5 comments
Open

Allow querying configured size #237

madsmtm opened this issue Sep 1, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@madsmtm
Copy link
Member

madsmtm commented Sep 1, 2024

Surface::height / Surface::width would be nice to have, instead of having to query them from the window.

@MarijnS95
Copy link
Member

We should intrinsically take #177 into account when tackling this issue. On most platforms it appears window size (appearance on screen) != surface size (physical dimensions of a pixel buffer) is natively supported (by relying on scaling hardware via the compositor) and should be exposed to the user one way or the other.

@MarijnS95
Copy link
Member

On Android we "have to" call ANativeWindow_setBuffersGeometry() to change the buffer format, "and set a size". But it explicitly documents:

For all of these parameters, if 0 is supplied then the window's base value will come back in force.

And if I set the width and height to 0, the NativeWindowBufferLockGuard / ANativeWindow_Buffer struct returned by self.native_window.lock() contains the actual size of the buffer at that point in time, and follows resizes caused by the system.
(If we set a size ourselves, #177 with hardware scaling comes into effect).

So realistically (for #237) we should have the actual size available on the Buffer and allow Surface to either resize to a user-specified value, or to a "special value" where it automatically follows the "window size" all the time (which the user reads back on Buffer whenever it's "locked for writing")?

@MarijnS95
Copy link
Member

So it looks like we have 3 situations:

  1. User doesn't set (or discards/resets) a Surface size. They read back the size of Buffer every time they draw, and expect this to follow the Window size;
  2. User specifically requests a pixel size on Surface (which may or may not affect the size of the window on-screen) and can expect the returned Buffer to match;
  3. If the Window size doesn't change (or we have an API to control that separately, or they control it via e.g. winit), they get implicit (hardware) scaling?

@madsmtm
Copy link
Member Author

madsmtm commented Sep 4, 2024

Yeah, that sounds right to me.

Question now is, do we want to support all of them? Would we be fine with not having hardware scaling, and just always have the buffer be the size of the surface? So e.g. remove resize, and add Buffer::width and Buffer::height (in case the buffer is used concurrently with the surface being changed)?

@MarijnS95
Copy link
Member

@madsmtm removing resize() is a step in the right direction to remove confusion and backend inconsistencies (does the user call this on startup? When their windowing system raises a resized event? When they want to change the size of the surface and possibly even the wrapped window?). And we could always reintroduce hardware scaling via a different/new function that more clearly annotates this?

And also, if possible on all platforms, redirect the user to their windowing system docs to resize the window if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

No branches or pull requests

2 participants