Commit Graph

2666 Commits

Author SHA1 Message Date
Daniel van Vugt
936696afcf cogl/winsys-glx: Request 2 stencil bits
Just like we do on EGL. Two bits are required because
`cogl-clip-stack-gl.c` needs each stencil buffer element to be able to
count from 0 to 2.

This mistake probably went unnoticed because:

 * Drivers usually provide more than 1 anyway; and

 * Optimizations in `cogl-clip-stack-gl.c` avoid calling the code that
   needs to count past 1 in most cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:44:05 +08:00
Daniel van Vugt
216bb7f960 cogl/clip-stack-gl: Set glStencilMask correctly for clip regions
Previously we were using a mask of 0x1 for the lifetime of the stencil.
This was wrong for two reasons:

  * The intersection algorithm needs to count up to a maximum 2, so a
    mask of 1 would clamp to 1 instead. Then decrementing all pixels
    resulted in all pixels being zero even though we want some to be 1.
    So the stencil then blocked some color buffer pixels being rendered.

  * The lifetime of the mask was too long. By leaving it non-zero at
    the end of the function we could accidentally end up modifying the
    stencil contents during our later color buffer paints.

This fixes faulty rendering of some actors seen in gnome-shell with
test case: `env COGL_DEBUG=stencilling`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:44:01 +08:00
Daniel van Vugt
5991f53c84 cogl/clip-stack-gl: Set glStencilMask correctly for clip rectangles
Previously we were using a mask of 0x1 for the lifetime of the stencil.
This was wrong for two reasons:

  * The intersection algorithm needs to count up to a maximum 2, so a
    mask of 1 would clamp to 1 instead. Then decrementing all pixels
    resulted in all pixels being zero even though we want some to be 1.
    So the stencil then blocked some color buffer pixels being rendered.

  * The lifetime of the mask was too long. By leaving it non-zero at
    the end of the function we could accidentally end up modifying the
    stencil contents during our later color buffer paints.

This fixes missing rendering of some actors seen in gnome-shell with
test case: `env COGL_DEBUG=stencilling CLUTTER_PAINT=disable-clipped-redraws`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:43:33 +08:00
Daniel van Vugt
c3d64cc05b cogl: Add new option COGL_DEBUG=stencilling to disable optimizations
This means stencilling every clip stack entry even when stencilling could
be skipped. This visibly reveals some bugs in the stencilling logic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:42:52 +08:00
Daniel van Vugt
f390340da5 cogl/clip-stack-gl: Remove unused code: #define GL_CLIP_PLANEn
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
2021-06-01 15:42:52 +08:00
Marco Trevisan (Treviño)
7d88386ee1 mutter-cogl.test: Use xvfb-run to run the cogl tests
The cogl tests need to run with a display server set, however since we
use TestEnvironment, only the listed env variables will be exposed to
the test and so no DISPLAY will be set when launching it with
gnome-desktop-testing-runner.

As per this, just run the tests using xvfb-run so that we match what's
happening in CI and we ensure that the tests are run in a safe
environment.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1876>
2021-05-26 21:03:45 +02:00
Jonas Ådahl
72f03e9c74 cogl: Remove ability to bind Wayland EGL display
We do that in the Wayland infrastructure code now, so remove Cogl's
ability to do the same.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Carlos Garnacho
9e10d2fa88 cogl: Drop "volatile" from static GTypes in manual registration
As documented in g_once_init_enter(): "While @location has a volatile qualifier,
this is a historical artifact and the pointer passed to it should not be
volatile.". And effectively this now warns with modern glibc.

Drop the "volatile" qualifier from these static variables as it's expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1785>
2021-03-22 10:47:51 +00:00
Jonas Ådahl
ec14f51ae3 cogl/onscreen/egl: Remove platform pointer
It's not used anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1759>
2021-03-08 15:02:30 +00:00
Ivan Molodetskikh
47183a94eb cogl/frame-info: Add VSYNC flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
9123aa4e84 cogl/frame-info: Add ZERO_COPY flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
c96fb181ab cogl/frame-info: Add sequence
It will be used for the presentation-time Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
5d8cb2786b cogl: Remove get_monotonic_time_ns()
It's no longer needed. Everything else uses and assumes
g_get_monotonic_time().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4ba2df0bd2 cogl: Remove cogl_get_clock_time()
It's no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4810164885 cogl: Make presentation time always MONOTONIC
This concerns only the cases when the presentation timestamp is received
directly from the device (from KMS or from GLX). In the majority of
cases this timestamp is already MONOTONIC. When it isn't, after this
commit, the current value of the MONOTONIC clock is sampled instead.

The alternative is to store the clock id alongside the timestamp, with
possible values of MONOTONIC, REALTIME (from KMS) and GETTIMEOFDAY (from
GLX; this might be the same as REALTIME, I'm not sure), and then
"convert" the timestamp to MONOTONIC when needed. An example of such a
conversion was done in compositor.c (removed in this commit). It would
also be needed for the presentation-time Wayland protocol. However, it
seems that the vast majority of up-to-date systems are using MONOTONIC
anyway, making this effort not justified.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
d8606829c4 cogl: Report presentation time in microseconds
KMS and GLX device timestamps have microsecond precision, and whenever
we sample the time ourselves it's not the real presentation time anyway,
so nanosecond precision for that case is unnecessary.

The presentation timestamp in ClutterFrameInfo is in microseconds, too,
so this commit makes them have the same precision.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Ivan Molodetskikh
9d54ef3994 cogl/frame-info: Add HW_CLOCK flag
A flag indicating whether the presentation timestamp was provided by the
display hardware (rather than sampled in user space).

It will be used for the presentation-time Wayland protocol.

This is definitely the case for page_flip_handler(), and I'm assuming
this is also the case for the two instances in the GLX code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Robert Mader
df4508e8cf cogl: Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:51:30 +01:00
Jonas Ådahl
7ddbcd1fd2 cogl/journal: Don't sometimes hold a ref on the framebuffer
d42f1873fc introduced a semi circular
reference between the CoglFramebuffer, and CoglJournal, where
CoglJournal would keep a reference on the CoglFramebuffer when there
were any entries in the journal log.

To avoid risking leaking these objects indefinitely, when freeing
objects without doing anything that triggered a flush, CoglFramebuffer
had a "filter" on cogl_object_unref() calls, which knew
about under what conditions CoglJournal had a reference to it. When it
could detect that there were only the journal itself holding such a
reference, it'd flush the journal, effectively releasing the reference
the journal held, thus freeing itself, as well as the journal.

When CoglFramebuffer was ported to be implemented using GObject instead
of CoglObject, this "filter" was missed, causing not only awkward but
infrequent leaks, but also situations where we'd flush journals when
only the journal itself held the last reference to the framebuffer,
meaning the journal would free the framebuffer, thus itself, in the
middle of flushing, causing memory corruption and crashes.

A way to detect this, by asserting on CoglObject reference count during
flush, is by adding the `g_assert()` as described below, which will
assert instead cause memory corruption.

void
_cogl_journal_flush (CoglJournal *journal
{
   ...
   _cogl_journal_discard (journal);
+  g_assert (journal->_parent.ref_count > 0);
   ...
}

Fix this by making CoglFramebuffer the owner of the journal, which it
already was, and remove any circle referencing that was there before, as
it is not needed given that the CoglFramebuffer pointer is guaranteed to
be valid for the lifetime of CoglJournal as the framebuffer is the owner
of the journal.

However, to not miss flushing before tearing down, which is important as
this flushes painting calls to the driver that is important for e.g.
using the result of those journal entries, flush the journal the first
time cogl_framebuffer_dispose() is called, before doing anything else.

This also adds a test case. Without having broken the circular
reference, the test would fail on g_assert_null (offscreen), as it would
have been "leaked" at this point, but the actual memory corruption would
be a result of the `cogl_texture_get_data()` call, which flushes the
framebuffer, and causes the 'mid-flush' destruction of the journal
described above. Note that the texture keeps track of dependent
framebuffers, but it does not hold any references to them.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1474
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1735>
2021-02-18 16:59:00 +00:00
Jonas Ådahl
30e1c51b33 Change all g_memdup() to g_memdup2()
Using g_memdup() is dangerous due to the type of the size argument. See
https://gitlab.gnome.org/GNOME/glib/-/issues/2319 and
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1926 for details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1708>
2021-02-04 19:16:28 +01:00
Jonas Ådahl
9a21f97ce1 cogl/gl-framebuffer: Remove hard coding type name
Either "onscreen" or "offscreen" was logged as the type; replace this
with the actual type name.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:47 +00:00
Jonas Ådahl
b07994b606 cogl: Use 'is_y_flipped()' instead of instance-of checking
This is what it was effectively used for in these places, so use the
appropriate API instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:47 +00:00
Jonas Ådahl
6b5d7f45cb cogl/gl-framebuffer: Check Y-flipped-ness instead of framebuffer type
In a few places coordinates were flipped if driven framebuffer was or
wasn't a CoglOffscreen. Change this to use the existing Y-flipped-ness
class vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
102aa59ce3 cogl/gl-framebuffer: Move stereo mode state flushing to backend
It's currently only handled by a surface backend framebuffer (assuming
the right GLX extensions are available). While it's theoretically
possible to do the same with the offcreen by having multiple textures,
it's not supported, so leave the FBO variant with a single warning if we
end up there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
dd55c3699c cogl/gl-framebuffer: GObject:ify helper functions
The object was still pretending to be CoglFramebuffer itself, by using
naming and calling conventions making it seem like that. Fix that by
passing around the driver instead of the framebuffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0fcb26075f cogl/framebuffer: Move read_pixels_into_bitmap() to driver class
This was the last driver vfunc used specifically to implement the
CoglFramebuffer driver.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
1e5f105836 cogl/framebuffer: Move attribute drawing to driver class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
392ffaeeb4 cogl/framebuffer: Move discard_buffers() to driver sub types
It was implemented slightly different depending on whether it was for a
surface or FBO, so move it to their corresponding GL driver types.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
b7c6865225 cogl/framebuffer: Move flush() and finish() to driver class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
1b3937491c cogl/framebuffer: Move clear() to CoglFramebufferDriver
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
4f3b57c841 cogl/onscreen: Move buffer age getter vfunc to class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
b2482a2069 cogl: Add CoglX11Onscreen interface
Mutter needs to fetch the X11 Window ID from the onscreen and did that
by using an X11 specific API on the CoglOnscreen, where the X11 type was
"expanded" (Window -> uint32_t). Change this by introducing an interface
called CoglX11Onscreen, implemented by both the Xlib and GLX onscreen
implementations, that keeps the right type (Window), while avoiding X11
specific API for CoglOnscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
4ec0975e91 cogl/onscreen: Remove explicit 'resizable':ness
Mutter didn't use the APIs for resizeability of CoglOnscreens but
managed the size itself. For the native backend we don't ever resize
onscreens. Thus, remove this unused functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
e43b95cd11 cogl/onscreen: Remove show()/hide()
Not used, and not relevant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
b0ec3a3ad7 cogl/test-utils: Skip "showing" the onscreen
Tests pass anyway.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0fdf6a6405 cogl/onscreen: Move direct scanout to CoglOnscreen class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
f663567405 cogl/onscreen: Move binding to onscreen class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
fe72876b20 cogl/onscreen: Make swap_buffer/region CoglOnscreen class vfuncs
No need to go via the "winsys" vtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
60e1516b1c cogl/gl-framebuffer: Split up into FBO and back drivers
One is for when we're painting to the back buffer (onscreen), and the
other when we're painting to an FBO (offscreen).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
a6b0376a6c cogl: Add 'framebuffer' debug topic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
d136c6510b cogl: Init framebuffer driver up front
The framebuffer driver was lazilly initialized on demand in some cases
(onscreen), and up front other (offscreen). Replace this with a more
predictable up front initialization, done at framebuffer allocation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
58eb1e87bf cogl/offscreen: Move struct to C file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
ece714c5c6 cogl/gl-framebuffer: Move struct fields into private
This makes it possible to make type derivable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
e3de0be678 cogl: Move "flush framebuffers" under the context scope
It was namespaced as a CoglFramebuffer function, but was passed two
framebuffers, and operated on state kept in CoglContext. Move and rename
accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
5be5529269 cogl: Add CoglFramebufferDriver base type
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
c7ea0b3d54 cogl/offscreen: Pass ColgOffscreenFlag when allocating
So that the allocation functions don't need to peek at the cached flag
struct field.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
cac5938238 cogl/gl-framebuffer: Fix allocate flag variable name
It was called 'flags' which would conflict with a variable containing a
CoglOffscreenFlag that will be added later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
1bee9e0d53 cogl/offscreen: Remove alloation_flags struct field
Was unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
408d4c9f09 cogl/offscreen: Remove depth buffer texture field
It was never set, so it was just some dead code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
8910b3e7bc cogl/offscreen: Move CoglGlFbo struct to GL driver
It was only used there, so put it in the driver private struct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
e9e37dd0d1 cogl/offscreen: Move CoglOffscreen code to its own file
Moving the external direct struct access will come later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
391866d415 cogl/gl-framebuffer: Rename CoglGLFramebuffer CoglGlFbo
The CoglGLFramebuffer (not CoglGlFramebuffer) is a private struct for
keeping track of the framebuffer object. To avoid confusing with
CoglGlFramebuffer, rename it CoglGlFbo.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
f56b0abaef cogl/gl-framebuffer: Make it a GObject
This way we can have separate types per modes of operation (e.g. if it's
backed by an EGLSurface or single texture), instead of being dependent
on a certain type (onscreen vs offscreen).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
0e376f4dda cogl/framebuffer-gl: Rename from CoglFramebufferGl to CoglGlFramebuffer
This is to follow the convention [ParentName][ChildName] representing
inheritance. As this does not inherit CoglFramebuffer, rename it
CoglGlFramebuffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
0936d7bd06 cogl/onscreen: Use CoglFramebufferClass::allocate() to init
Instead of calling "init_onscreen()" on two different separate vtables
from the allocate() funtion, just have the CoglOnscreen sub types
themself implement allocate() and initialize in there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
0b568b68c6 Make all CoglOnscreen sub types inherit CoglOnscreen
Thins means that e.g. MetaOnscreenNative now inherits CoglOnscreenEgl,
which inherits CoglOnscreen which inherits CoglFramebuffer, all being
the same GObject instance.

This makes it necessary to the one creating the onscreen to know what it
wants to create. For the X11 backend, the type of renderer (Xlib EGL or
GLX) determines the type, and for the native backend, it's currently
always MetaOnscreenNative.

The "winsys" vfunc entries related to onscreens hasn't been moved yet,
that will come later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
f60943afc9 cogl/onscreen/egl: Move struct fields to instance private
This is so a derivable type can be declared later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
b5afa6db23 cogl/onscreen: Change to follow mutters naming convention
The mutter naming convention for types and their instance variables is:

Type name:
   [Namespace][BaseName][SubType]

Instance name:

   [base_name]_[sub_type]

This means that e.g. CoglOnscreenGLX is renamed CoglOnscreenGlx, and
glx_onscreen is renamed onscreen_glx. This is in preparation for
GObjectification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
8339c064c8 cogl/xlib: Move EGL XLIB onscreen to separate file
As with the other onscreens, separate it into its own file in
preparation for GObjectification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
a057432e3d cogl/glx: Move onscreen code to a separate file
Mostly in order to untangle it from the rest, preparing turning it into
a GObject.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
2eea373241 cogl/winsys/glx: Merge 'xlib' and 'glx' structs
The GLX winsys code had split up the GLX onscreen implementation into an
Xlib part (with a struct name confusingly enough identical to that of
the onscreen in the actual Xlib winsys). To remove some confusion,
combine the two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
7cf24ccc34 cogl/onscreen/egl: Move struct to C file
In praparation for declaring the EGL onscreen part using G_DECLARE*.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
760a07cc24 cogl/onscreen/egl: Move pending_resize_notify to Xlib platform
It's only used in the Xlib onscreen, so move it there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
b24d5ce1dd cogl/winsys/egl: Move out onscreen code to own file
As a preparation turning it into its own type, move the code related to
CoglOnscreen to its own file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
d4dbcf3983 cogl/onscreen: Move fields from CoglOnscreen struct to private
This means we can now make CoglOnscreen derivable using GObject macros.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:44 +00:00
Jonas Ådahl
d0831cbbcd cogl: Move CoglOnscreen struct to C file
That means all sub types need to use helper methods, so make them do
that too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:44 +00:00
Jonas Ådahl
6c4e01ea68 cogl: Fix license header in cogl-scanout and cogl-trace
As with cogl-graphene, the same mistake was made here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
c35335aad8 cogl/graphene: Fix license header
The intention was for these files to be licensed identically to the
other files in cogl, so fix this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
487ea0dd95 kms: Add symbolic page flips and cogl frame infos
This makes it possible to post a symbolic page flip and frame callback,
meant to be used by immediate symbolic page flip reply when emulating
cursor plane changes using legacy drmMode* functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
1c20ba4c32 cogl/onscreen: Add way to manually add frame infos
We will soon need to use CoglOnscreen frame events communicate cursor
plane changes; this means we need to have a way to queue them without
going through any of the current APIs that can do so, i.e. the swap
buffer functions and direct scanout.

Add a function that just adds a frame info to the queue. The one who
adds it is responsible for emitting it too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
447c51e68e renderer-native: Always post device wide updates during mode set
Don't mode set each CRTC in separate KMS updates, as reconfiguring one
CRTC might cause other CRTCs to be implicitly reset thus as well,
causing KMS return EBUSY if using atomic modesetting.

Prepare for this by compositing each CRTC first including adding steps
to the KMS update, but wait until all views has rendered at least once
before posting the initial update. After this each CRTC is posted
separately.

Using EGLStreams instead of normal page flipping seems to fail when
doing this though, so handle that the old way for the EGLStream case,
i.e. eglSwapBuffers() -> mode set with dumb buffer -> eglStream
"acquire" (resulting in page flip under the hood).

For this we also introduce a new error code so that we don't use client
buffers when doing mode sets, which could accidentally configure the
CRTC in a way that is incompatible with the primary plane buffers.

Do the same also when we're in power save mode, to only have one special
case path for this scenario in the regular swap-buffer path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
249512b068 cogl/onscreen: Add opaque user_data pointer to onscreen present calls
This argument is intended to be used by clutter to be able to
communicate with the onscreen backend, that happens to be the native
backend. It will be used to pass a ClutterFrame pointer, where the
result of page flips, mode sets etc can be communicated whenever it is
available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Daniel van Vugt
f0a9ec0519 cogl/journal: Invalidate framebuffer mipmaps on each journal insertion
Because the framebuffer itself might be backed by a texture, which might
have mipmapping enabled. If so then rendering to the framebuffer will make
those mipmaps out of date.

Technically we are flagging the framebuffer's mipmaps as dirty *before*
they are, because the journal hasn't been flushed yet. But we need to do
it early because ideally the next flush will both write the offscreen
framebuffer contents and then read them for use in rendering to an onscreen
framebuffer. And the `mipmaps_dirty` flag needs to be set before the read,
so therefore we need to do it before the next journal flush.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3146
where the offscreen framebuffer in question is meta-background's
`monitor->fbo`.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1664>
2021-01-08 15:51:09 +08:00
Jonas Ådahl
46ec29458d cogl/texture: Add a bit more debug logging
We fall back to slicing if the non-sliced allocation failed, but we
didn't log why. Also log why allocating a slice failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1648>
2020-12-18 16:19:05 +00:00
Jonas Ådahl
96842fc570 cogl/texture-2d-sliced: Don't double-free slice array when alloc failed
If texture allocation failed for a sliced 2D texture, the alloc()
function would free the slices immediately, but not clear the pointer to
the slices array. When the code attempting to allocate the texture then
freed the texture object, the cleanup functions tried to free the slices
array again, since it wasn't NULL.

Fix this by clearing the slices array after freeing it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1580
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1648>
2020-12-18 16:19:05 +00:00
Georges Basile Stavracas Neto
d57bdb0b44 cogl/framebuffer: Add COGL_EXPORT to public function
An oversight of 038a3170bf.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1627>
2020-12-14 09:21:30 -03:00
Daniel van Vugt
a793b4eef5 cogl: Add new 'sync-{primitive,frame}' options for COGL_DEBUG
This allows profilers to trace the callers of whatever is spending the
most time on the GPU, and to measure render times more accurately.
Previously such information was hidden as it completed in the
background (asynchronously) after we call swap buffers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1327>
2020-11-20 17:30:55 +00:00
Jonas Dreßler
4e63ed524e tests: Use ClutterStage "after-paint" instead of ClutterActor "paint"
The "paint" signal of ClutterActor is deprecated and will be removed. We
have a good replacement to get notified about stage paints nowadays,
that is "after-paint" on ClutterStage, so switch to that signal where it
makes sense.

I didn't bother to update the few tests (namely Clutters
conform/texture-fbo.c, conform/text-cache.c,
interactive/test-cogl-multitexture.c and Cogls
conform/test-multitexture.c, conform/test-texture-mipmaps.c) where it's
harder to replace the signal since we don't build those anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1522
2020-10-23 22:06:58 +02:00
Uday Kiran Pichika
d504086ebf cogl: correcting the cogl trace log
Remove the extra & symbol appearing in cogl debug log

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1517
2020-10-21 12:10:16 +00:00
Daniel van Vugt
0501d3020e cogl-winsys-egl: Log the color depth in use
Enable it with environment `COGL_DEBUG=winsys`.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1387
2020-10-20 09:53:52 +00:00
Georges Basile Stavracas Neto
1f99395d20 clutter: Use graphene_matrix_inverse()
Instead of our own implementation that upscales, then downscales back,
use graphene_matrix_inverse() directly. This is possible after switching
to a z-near value that doesn't have problems with float precision.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
2020-10-16 13:37:44 -03:00
Jonas Ådahl
2aea404b14 cogl: Use memory management helpers more
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
88c830b9ab cogl/framebuffer: Move allocation and y-flip-ness to non-abstract types
Now that CoglFramebuffer is a GObject, we can start moving things to the
proper places.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
eb14da3874 cogl: Turn CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects
A first step towards abandoning the CoglObject type system: convert
CoglFramebuffer, CoglOffscreen and CoglOnscreen into GObjects.
CoglFramebuffer is turned into an abstract GObject, while the two others
are currently final. The "winsys" and "platform" are still sprinkled
'void *' in the the non-abstract type instances however.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
ea2f4efaef cogl: Remove cogl_offscreen_new_to_texture()
It's no longer used, and has been deprecated for a long time.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
e7ac3e2715 cogl/framebuffer: Clean up cleanup function
Use cogl_clear_object() and g_clear_pointer() helpers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
aa99e505ad cogl/framebuffer: Move public struct fields to private struct
This will limit accidental manipulation of the framebuffer struct
fields, while also paving the way to change to GObject type hierarchy.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
ffde1c0124 cogl/onscreen: Remove unused _cogl_onscreen_new()
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
209b78afd8 cogl/framebuffer/gl: Move OpenGL driver fields to private struct
It's driver specific, so it shouldn't be kept in the generic data
structure.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:38 +00:00
Jonas Ådahl
e720ef1ceb cogl/framebuffer: Fix argument naming to blit_framebuffer()
The first argument is the framebuffer operated on, so in order to stay
consistest, rename 'src' to 'framebuffer'. The second is the
destination. The destination is commonly referred to as 'dst' elsewhere,
so rename 'dest' to 'dst'.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:37 +00:00
Jonas Ådahl
4edcc21a5c cogl/framebuffer: Remove alignment of struct fields
They weren't all aligned anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:37 +00:00
Jonas Ådahl
e7b923289a cogl/framebuffer: Fix enum declaration coding style
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1496
2020-10-16 16:17:37 +00:00
Daniel van Vugt
df65f05e27 cogl: Remove unused swap-related COGL_FEATURE_ID_ flags
What we actually use is `COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT`, which
is also set in the same locations.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1297
2020-10-14 16:27:23 +00:00
Georges Basile Stavracas Neto
b5749a8b27 Remove CoglMatrix
Adios, amiga.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
090973e538 cogl/tests: Use graphene APIs
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
182b51774e cogl: Use graphene APIs
These are the easy, trivial ones.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
9e1004da0c cogl/matrix-stack: Use graphene APIs
This one is a bit tricky. The tl;dr; is that switching from right-hand
multiplication to left-hand multiplication required applying the stack
from left to root. This actually allowed simplifying the code a bit,
since CoglMatrixEntry only stores a pointer to its parent, and that's
all we need to know for left-hand multiplication.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
d03ffe1e97 cogl/matrix-stack: Embed graphene matrices in entry structs
Instead of heap allocated graphene matrices, embed them into the
entries themselves. That makes the matrix magazine unused, and thus
also remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:48 +00:00
Georges Basile Stavracas Neto
5db1f67d44 clutter/stage: Setup 2D view internally
Move and simplify cogl_matrix_view_2d_in_perspective() to inside
ClutterStage, since it's the only consumer of this API, and remove
it from Cogl.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00
Georges Basile Stavracas Neto
db23ee5829 cogl/matrix: Move inverse calculation to cogl-graphene.c
This special precision-bearing calculation will be used in other
places, so better share them all here.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:47 +00:00