1
0
Fork 0
Commit graph

2607 commits

Author SHA1 Message Date
Jonas Ådahl
166ad34423 color-profile: Don't try to remove the wrong profile on finalize
If our profile wasn't fully initialized, we'd try to clean it up, in an
attempt to handle race conditions by finding synchronously then cleaning
it up, but don't attempt this if the profile is ready, as that means we
didn't create one in the first place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
3aecb1c262 color-profile: Rely on property on ICC for filename
This is instead of getting anything from the CdDevice. This avoids a
crash when CdDevice isn't successfully setup but something still tries
to look up the filename of the ICC profile.

This isn't a real bug fix for anything, but there is no reason having to
rely on CdDevice for this anyway, and as we don't really have control of
it, it's less reliable of containing something valid.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2622>
2022-09-15 11:22:54 +00:00
Jonas Ådahl
be4e6484ae render-device: Unmake the EGLContext after checking whether hw accelerated
When creating a render device, we create a temporary EGLContext where we
then query the `GL_RENDERER` string to check whether the renderer is any
of the known software renderers. After we're done, we destroy the
context and move on.

This should be fine as according to specification eglDestroyContext(),
with the context being actually destroyed a bit later when it's no
longer current, but mesa, when running RK3399 (Pinebook Pro), this
results in a crash in a future eglMakeCurrent():

  #0 in dri_unbind_context () at ../src/gallium/frontends/dri/dri_context.c:266
  #1 in driUnbindContext () at ../src/gallium/frontends/dri/dri_util.c:763
  #2 in dri2_make_current () at ../src/egl/drivers/dri2/egl_dri2.c:1814
  #3 in eglMakeCurrent () at ../src/egl/main/eglapi.c:907
  ...

We can avoid this, however, by calling eglMakeCurrent() with
EGL_NO_CONTEXT on the EGLDisplay, prior to destroying, effectively
avoiding the crash, so lets do that.

Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7194
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2414
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2612>
2022-09-03 18:34:49 +02:00
Jonas Ådahl
b1a687ae57 tests/color: Test that we handle devices with no GAMMA_LUT
We should create the color device etc, but we shouldn't attempt to set
the GAMMA_LUT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
2022-09-03 14:41:36 +00:00
Jonas Ådahl
255cd9a9ff color-device: Don't attempt to set GAMMA_LUT if LUT size is zero
This might happen on e.g. virtual machines. If we don't skip trying,
we'll end up crashing because we'll fail to create a look up table since
the size must be greater than zero to make any sense.

Fixes: baef39e603
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2415
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2611>
2022-09-03 14:41:36 +00:00
Jonas Ådahl
44dae3e160 kms: Only force legacy mode setting when using EGLStream
EGLStream is incompatible with atomic mode setting, but nvidia-drm when
using libgbm is not, so lets only deny using atomic mode setting when
the render device is an EGLStream based one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Jonas Ådahl
58c3734d78 backend/native: Prepare render devices earlier than KMS
The type of render device used for a specific GPU affects the mode
setting backend that can be used, more specifically, when the render
device is an EGLStream based one, atomic mode setting isn't possible, as
page flipping is done via EGL, not via atomic mode setting commits.

Preparing the render devices before KMS devices means can make a more
informed decision whether to deny-list atomic mode setting for when
a certain GPU uses a EGLStream based render device instance.

This also means we need to translate mode setting devices to render node
devices when creating the render device itself, as doing it later when
creating the mode setting device is already too late.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Jonas Ådahl
1a0bd44694 backend: Hook up to the parent constructed()
Doing an early out in a constructed() is a bit awkward, and unexpected,
and makes it tricky to call the parents constructed() method (which we
didn't), so clean that up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2578>
2022-09-02 20:43:05 +00:00
Carlos Garnacho
7a1beb817d backends: Expose InputMapping D-Bus path to determine tablet mapping
Currently, the peripheral "output" setting will be unset if Mutter is
deciding automatically the mapped output of a tablet device. In that
case, gnome-control-center will have a hard time figuring out itself
the better output to show the tablet calibration UI, unless it's hand
held by Mutter.

Add this private D-Bus interface so that gnome-control-center can look
up the output as determined by Mutter to bring the missing harmony
between both. This interface consists of a simple method to get the
mapped output for a input device node.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2605>
2022-09-02 18:34:36 +00:00
Sebastian Wick
449327093e backends: Implement gamma LUT virtual function for MetaCrtcDummy
Fixes a crash in the nested backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2606>
2022-09-02 14:53:56 +00:00
Erico Nunes
932351c2bb backends: Set up swap_region without damage history
Following the EGL_KHR_swap_buffers_with_damage specification, the
surface damage used by eglSwapBuffersWithDamage does not need to
contain the damage history.
Rework that to initialize swap_region earlier, before appending the
damage history.
This may help optimizing the composition process in some cases (at least
on X11 when EGL_KHR_swap_buffers_with_damage is available) by not
accumulating additional regions as damaged unnecessarily.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2241>
2022-09-02 11:06:04 +00:00
Alessandro Bono
db0f12135e output-xrand: Plug a memory leak
Fixes: 99d84ae1cc
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2608>
2022-09-02 09:51:47 +00:00
Daniel van Vugt
cc729def90 monitor-config-store: Format <rate> using the C locale (. decimal point)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2602>
2022-09-02 08:43:00 +00:00
Alberts Muktupāvels
3c50a9f8aa output-xrandr: Fix memory leak
Introduced in 99d84ae1cc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2589>
2022-09-02 07:02:30 +00:00
Jonas Ådahl
eb764e0f0d barrier/x11: Let the seat bind the input events for us
Without doing this, the events bound by the X11 barrier manager will get
overridden by the ones later bound by the seat.

Fixes: 0debb24e12
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2394
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2604>
2022-09-02 06:35:00 +00:00
Jonas Ådahl
73bb333000 backend: Remove unused barrier vfunc
It was added in error, and has been unused since its introduction. Lets
correct the error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2604>
2022-09-02 06:35:00 +00:00
Sebastian Keller
3e22eb35ed color-store: Fix two small leaks in init_profile_directory
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2603>
2022-09-01 21:39:38 +00:00
Sebastian Keller
48ff211762 color-store: Fix small file path leak in ensure_device_profile
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2603>
2022-09-01 21:39:38 +00:00
Sebastian Keller
57c7d75c43 color-device: Don't wrongly use Unknown vendor in ICC profile from EDID
If the vendor_name was previously successfully determined, we would end
up in the else case, overwriting it with "Unknown vendor" and leaking
the previous vendor_name.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2603>
2022-09-01 21:39:37 +00:00
Jonas Ådahl
9aa9cacb3d color-device: Pass calibration state separately when creating profile
This allows using two separate ICC profiles for one "color profile",
which is necessary to properly support color transform
calibration profiles from an EFI variable.

These types of profiles are intended to be applied using the color
transformation matrix (CTM) property on the output, which makes the
presented output match sRGB. In order to avoid color profile aware
clients making the wrong assumption, we must set the profile exposed
externally to be what is the expected perceived result, i.e. sRGB, while
still applying CTM from the real ICC profile.

The separation is done by introducing a MetaColorCalibration struct,
that is filled with relevant data. For profiles coming from EFI, a
created profile is practically an sRGB one, but the calibration data
comes from EFI, while for other profiles, the calibration data and the
ICC profile itself come from the same source.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2568>
2022-09-01 21:09:28 +00:00
Jonas Ådahl
5b251bd8a7 color-device: Add API to set test efivar path
This will be used by tests to set the special efivar calibration
profile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2568>
2022-09-01 21:09:28 +00:00
Robert Mader
2a87eb6226 renderer-view: Use common helper function to transform matrices
To deduplicate some code. Tested with all eight possible values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2468>
2022-09-01 20:40:35 +00:00
Robert Mader
d3b81d70f0 stage-impl: Use onscreen framebuffer for scanout
We may want to use scanout even if the default framebuffer
of the stage view is an offscreen, for example when a Wayland
client provides pre-rotated buffers. The caller is responsible
to ensure this is correct - we already asserted on that before.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2468>
2022-09-01 20:40:35 +00:00
Jonas Ådahl
39e01d8700 color-manager/x11: Set color transformation matrix
As was done in gsd-color, set the "CTM" of the output. This is only done
in X11, as it was only ever implemented for X11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2166>
2022-09-01 19:09:21 +02:00
Jonas Ådahl
17c99edfe0 x11: Add X11 color manager subclass
This is used as part of the X11 backend to updated X11 root window
properties according to the ICC Profiles in X Specification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2166>
2022-09-01 19:09:21 +02:00
Jonas Ådahl
ceedc0e5fb color: Emit signal when device is updated
Will be emitted when a device updated its color state. Will be used by
an X11 color manager implementation, and tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
b7d3c9e3c5 color-device: Maybe update brightness from profile when updating
Some profiles have brightness metadata that also needs to be applied.
Make sure this happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
71009779c8 color-manager: Update gamma LUTs when needed
This means on
  - hotplugs
  - color temperature changes
  - service availability (gsd-color, gsd-power)
  - when color devices become ready
  - when color devices change

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
baef39e603 color-device: Add API to update gamma LUTs
This will generate a gamma LUT from the profile and apply it to the
monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
3e1a3faa28 color-profile: Add gamma LUT generators
More or less copied from gnome-settings-daemon. The look up tables are
either calculated based on the VCGT (Video Card Gamma Table) and the
blackbody color for a given temperature, or the blackbody color for a
given temperature alone, if no VCGT is available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
69df2a368d color-store: Monitor for non-EDID color profiles
This means that e.g. custom profiles or calibrated profiles will be
added and registered with colord. This does not use CdIccStore for two
reasons: don't want to generate duplicate entries for auto-generated
EDID or EFI profiles, and we want to store profiles as MetaColorProfile.
It also happens to be the case that CdIcc does synchronous I/O, which
should be avoided everywhere except on startup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
22064055be color-profile: Add API to get file path
Each color profile has a corresponding ICC profile saved on the file
system. The getter returns a file path for that ICC profile file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
16149d7c25 color-manager: Keep track of temperature
It will be used to generate gamma look up tables depending on
temperature.

The temperature comes from org.gnome.SettingsDaemon.Color and
depends on the current night light state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
b3fa4a6cd8 color-manager: Add API to set brightness
It uses the org.gnome.SettingsDaemon.Power.Screen D-Bus API. Currently
brightness set if the proxy is not ready are ignored; whether the
brightness value should be cached and set once it appears or whether
color profiles should be reapplied is yet to be decided.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
7b71ec8ff0 color-device: Add new 'changed' signal for when the device changes
What triggers emission right now is the assigned profile changing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
985292c109 color-profile: Add getter for brightness profile
Will be used to set brightness from a color profile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
b59dc05b22 crtc: Get/set gamma via helper struct
Instead of passing 4 arguments (red, green and blue arrays as well as a
size), always pass them together in a new struct MetaGammaLut. Makes
things slightly less tedious.

The KMS layer still has its own variant, but lets leave it as that for
now, to keep the KMS layer "below" the cross backend CRTC layer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
9dda79b281 monitor-manager: Move gamma LUT manipulation API to MetaCrtc
In practice, for KMS backend CRTC's, we cache the gamma in the monitor
manager instance, so that anyone asking gets the pending or up to date
value, instead of the potentially not up to date value if one queries
after gamma was scheduled to be updated, and before it was actually
updated.

While this is true, lets still move the API to the MetaCrtc type; the
backend specific implementation can still look up cached values from the
MetaMonitorManager, but for users, it becomes less cumbersome to not
have to go via the monitor manager.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2165>
2022-09-01 17:52:01 +02:00
Jonas Ådahl
0a0fb2fda9 color: Create color profile for assigned profile
We created device profiles, that we manage the lifetime of in colord,
but color devices can be assigned profiles other than the ones it was
created for. For example, this can include the standard sRGB profile
provided by colord.

To achieve this, keep track of the default profile of the CdDevice as
the "assigned" color profile of the device. Given this profile
(CdProfile), construct a MetaColorProfile that can then be interacted
with as if it was generated by ourself.

The assigned profile (default profile in colord terms) does nothing
special so far, but will later be used to determine how to apply CRTC
gamma ramps etc.

The sRGB.icc file used in the tests was copied from colord. It was
stated in the repository that it has no known copyright restrictions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
cc84a45b56 color-profile: Create colord profiles
This works similiarly to how MetaColorDevice works, by creating them
asynchronously then signalling the 'ready' signal when done. Also
similarly to MetaColorDevice, the on-demand sync cleanup on finalize is
added, to avoid race conditions when hotplugs happens very rapidly,
e.g. in tests.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
062abe01b3 color: Generate and store ICC profiles from EDID or EFI
Just as gsd-color does, generate color profiles. This can either be done
from EFI, if available and the color device is associated with a built
in panel, or from the EDID. If no source for a profile is found, none is
created.

The ICC profiles are also stored on disk so that they can be read by
e.g. colord. The on disk stored profiles will only be used for storing,
not reading the profiles, as the autogenerated ones will no matter what
always be loaded to verify the on disk profiles are up to date. If a on
disk profile is not, it will be replaced. This is so that fixes or
improvements to the profile generation will be made available despite
having run an older version earlier.

After generating, add some metadata about the generated file itself
needed by colord, i.e. file MD5 checksum and the file path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
7a242ff1a1 monitor: Add API to check color transform support
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
083b788c74 color-manager: Maintain a lcms context
Will be used from other color related units later on. This also adds an
explicit dependency on LCMS2.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
f4be29eec7 tests: Add rudimentary color device test
Tests that test case EDID is setup correctly, and that color devices for
monitors are created.

tests/color: Add hotplugging tests

Checks that changing the number of connected monitors reflects the
number of current color devices, and that we end up with the correct end
state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
8826b29329 color-manager: Add ready state
Ready means it has established the connection to colord and can operate.
Will be used by tests to make sure tests don't fail due to race
conditions when connecting to colord.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
41ebf3b1bf color-device: Add getter for the associated monitor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
6403cfe170 color-manager: Add API to get the color device for a monitor
There is a 1-on-1 mapping between these two entities, so add a getter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
b8ddf7ad8b monitor: Add getter for EDID info struct
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
9ece224718 output: Keep the EDID struct with the other output info
Will be used later to retrieve other EDID details, e.g. for color
management.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00
Jonas Ådahl
43cd70089e color-manager: Set up a D-Bus proxy to org.gnome.SettingsDaemon.Color
gsd-color provides this API, which exposes details about the night light
state. Currently, gsd-color also turns this state into CRTC gamma
changes, but this will eventually change, and this is a preparation for
this.

The proxy isn't yet used for anything.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2164>
2022-09-01 16:54:04 +02:00