Commit Graph

2541 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
dad710adaa cogl/matrix: Transpose using graphene matrices
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
0dbd6d3a80 cogl/matrix: Look-at using graphene matrices
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
2b7a73e0c3 cogl/matrix: Compare using graphene matrices
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
06db70ea28 cogl/matrix: Scale using graphene matrices
Boring.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
ade28eeaf3 cogl/matrix: Rotate using graphene matrices
This is pretty similar to the other conversions, except we need to
store the matrix flags before operating on it, and update it using
this old value after. That's because cogl_matrix_init_from_array()
marks the matrix as entirely dirty, and we don't want that.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
02a30f2a22 cogl/matrix: Multiply using graphene matrices
At this point, we are still only changing CoglMatrix APIs internally, and
it should still produce the same output as before.

To achieve this, using graphens matrix implementation, we need to exploit
some knowledge about conventions used in Cogl and graphene respectively.

In Cogl, transformation matrices are equivalent to those of affine
transformation matrices. The convention used by graphene, however, is to
operate on matrices that are transposed compared to their affine
counterparts.

So for example, let's say we want to multiply the affine matrices A and B,
to get C.

  A × B = C

The first step is to convert A and B to graphene matrices. We do this by
importing the floating point array, importing it directly using graphene.

Cogl exports its matrix to a column major floating point array. When we
import this in graphene, being row major, we end up with the same matrix,
only transposed.

Cogl       Graphene

  A   <===>   Aᵀ
  B   <===>   Bᵀ

We then multiply these imported matrices in reverse

  Bᵀ × Aᵀ

which in turn, due to ABᵀ = BᵀAᵀ, gives us

  Bᵀ × Aᵀ = (A × B)ᵀ

Our original goal was to find C, thus we know that

  A × B = C

That means we can shuffle things around a bit.

  A × B = C

  Bᵀ × Aᵀ = (A × B)ᵀ

  Bᵀ × Aᵀ = Cᵀ

With the same conversion as done when going from Cogl to graphene, only
the other way around, we still end up effectively transposing the matrix
during the conversion.

Graphene      Cogl

   Cᵀ  <===>   C

Thus when converting Cᵀ to Cogl, we in fact end up with C.

(Explanation authored by Jonas Ådahl)

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
2b9ce99ff2 cogl/matrix: Translate using graphene
Add conversion helpers (from and to graphene_matrix_t), and replace
the translation code to use graphene matrices internally.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
8e125fbab6 cogl/matrix: Add cogl_matrix_get_value
This will allow us stop accessing members of the structure
directly. Also mark all struct members as private.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
fe0a325e9f cogl/matrix: Import skew functions from Clutter
Graphene provides skewing as part of graphene_matrix_t API, and it'll
be easier for the transition to just expose similar API surfaces.

Move the matrix skew methods to CoglMatrix.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
566b081cd7 cogl/tests: Compare matrices using array
We'll remove direct access to CoglMatrix struct fields, so update
the test to not access them already.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
eee2e331fd cogl/matrix: Add constant identity initializer
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
a761caf079 cogl/matrix: Add cogl_matrix_init_from_matrix initializer
It does a simple memcpy() to clone the entire structure. This will
be necessary for a smoother removal of ClutterMatrix.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Georges Basile Stavracas Neto
1a9f9b0164 cogl: Remove unused header
Not included nor used anywhere.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1439
2020-10-06 15:34:46 +00:00
Simon McVittie
8ae641aa24 cogl tests: Show the actual output from tests if VERBOSE is set
Writing tests' output to a log file makes them difficult to debug when
the test might be running on an autobuilder or CI system where only
stdout/stderr are recorded. This is particularly troublesome if a
failure is only reproducible on a particular autobuilder.

Recent Automake versions have the convention that detailed output from
failing tests is written to stdout/stderr, not just to log files, when
the VERBOSE environment variable is set; borrow that convention as a
trigger for producing detailed test output.

This was originally cogl!14, but applies equally to mutter's fork of cogl.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1273

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-09-28 13:58:19 +00:00
Daniel van Vugt
647eec5f7f cogl: Flush specific framebuffers
This resolves a couple of FIXMEs. The FIXME comments were right in
stating that not *all* journals needed flushing, only the one we
are trying to put on screen needs flushing.

However we can't eliminate all flushes because the winsys swap calls
that follow go directly into OpenGL which knows nothing about cogl
journalling. So the journal *must* be flushed before the swap, to give
OpenGL the correct state.

P.S. If this turns out to cause any bugs then the next best answer is
to just remove the FIXME comments. Because flushing is still the right
thing to do.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1362
2020-09-18 11:59:52 +00:00
Jonas Ådahl
6e3ecadb79 backends/native: Fall back to compositing if direct scanout failed
Even when a direct client buffer has a compatible format, stride and
modifier for direct scanout, drmModePageFlip() may still fail sometimes.

From testing, it has been observed that it may seemingly randomly fail
with ENOSPC, where all subsequent attempts later on the same CRTC
failing with EBUSY.

Handle this by falling back to flipping after having composited a full
frame again.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1410
2020-09-17 12:17:35 +00:00
Jonas Ådahl
7d822459de cogl/renderer: Set error in dmabuf constructor fallback
When the CoglRenderer didn't set the DMA buffer constructor vfunc, we
return NULL. What we didn't do was set the error, meaning the caller
would crash if it tried to look up why DMA buffer construction failed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1430
2020-09-14 16:03:17 +00:00
Georges Basile Stavracas Neto
21a21e7f68 cogl/scanout: Allow blitting to framebuffer
This will be used when screencasting monitors so that if
there's scanout in place, it'll still be possible to blit
it to a PipeWire-owned framebuffer, and stream it.

Add a new 'blit_to_framebuffer' vfunc to CoglScanout, and
implement it in MetaDrmBufferGbm.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1421
2020-09-01 13:05:24 -03:00
Robert Mader
1f557a502b cogl/context: Add API to create named pipelines
In certain situations it's desirable to keep pipelines around for
the whole lifetime of the session. In order to not leak them and
properly clean them up on shutdown, introduce a new mechanism to
create named pipelines that are bound to their correstponding
context and may be used across file boundries.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1372
2020-08-31 15:47:08 +00:00
Björn Daase
285f2a2124 cogl: Fix spelling of CoglPipelineStateComparator
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1410
2020-08-29 09:10:31 +00:00
Björn Daase
5ec9bde64f *: Fix spelling mistakes found by codespell
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1410
2020-08-29 09:10:31 +00:00
Jonas Ådahl
0d95f4d854 tests/clutter: Always use stage from backend
This removes all occurrences of creating a custom stage from the tests,
making them always use the one from MetaBackend. This will allow for
further cleanups.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364
2020-08-13 17:51:56 +02:00
Jonas Ådahl
d857edf09c clutter: Remove support for transparent windows
We're only ever a compositor, so we're never asking to be transparent.
Thus remove support for requesting to paint to GLX or EGL displays with
an alpha channel.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364
2020-08-13 14:45:10 +02:00
Jonas Ådahl
d6b5f89a1c cogl: Add API to check whether a format is supported by the driver
Will let us advertise what we actually support at runtime.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:49 +00:00
Jonas Ådahl
6777a547ca cogl: Add 64 bit half-point pixel RGBA formats
In order to support the DRM formats DRM_FORMAT_ABGR16161616F and
friends, as well as the wl_shm formats WL_SHM_FORMAT_ABGR16161616F and
friends, cogl needs to have knowledge about said formats too.

We don't have a software implementation of the half point data types
however, so the pack/unpack methods remain unimplemented. We don't need
them for now, so it's not crucial that we add them.

For the GLES2 driver, currently only two formats are supported, and
since we don't currently have pack/unpack implementations, the other
formats will for now remain unsupported, until we have a half float
implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:48 +00:00
Jonas Ådahl
b191f89305 cogl/gles2: Add support for actual 10 bpc formats
Only for little-endian, depends on an extension, and needs unpack/pack
for many of the formats.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:48 +00:00
Jonas Ådahl
2fc8841416 cogl: Add private feature flags for 10 bpc and 16 bpc formats
10 bpc are enabled for OpenGL and GLES 2 with the right extension. 16
bpc (half float) are enabled for OpenGL 3 and higher, and GLES 2 with
the right extension.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:48 +00:00
Jonas Ådahl
598f536c51 cogl/bitmap-packing: Use hexadecimals for bit masks
It's easier to reason about what bits are 1 or 0 with e.g. 0x1f vs 0x3f
compared to 31 and 63.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/804
2020-08-07 09:02:48 +00:00
Daniel van Vugt
f3ad63e206 Remove unused flag COGL_WINSYS_FEATURE_SWAP_THROTTLE
This also removes an old comment about `wait_for_pending_flips` which
no longer exists.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1390
2020-08-04 08:43:57 +00:00
Olivier Fourdan
d0ee02fae7 cleanup: Remove duplicate semicolons in C code
No functional change, it just hurts my eyes when reading the code.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1385
2020-07-28 10:32:46 +02:00
Daniel van Vugt
3a474556b8 cogl-texture-2d: Flush the journal before mipmapping
In the case of indirect rendering like the first frame to use mutter's
background wallpaper:

  Texture_A -> FBO_B (Texture_B) -> FBO_C (screen)

we would be trying to render the contents of both FBO_B and FBO_C in
the same flush, before the contents of Texture_A had made it to FBO_B.
So when FBO_C wants to use mipmaps of Texture_B they didn't exist yet
and appeared all black. And the blackness would remain for subsequent
frames as cogl has now decided the mipmaps of FBO_B are no longer
"dirty" and don't need refreshing:

  FBO_B (Texture_B) (mipmaps_dirty==FALSE but black) -> FBO_C (screen)

We must flush FBO_B before referencing Texture_B for use in rendering
FBO_C. This only happens when Texture_A changes (e.g. when the user
changes their background wallpaper) so there's no ongoing performance
penalty from this flush.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1347
2020-07-07 16:15:24 +08:00
Jonas Ådahl
c00a8e98a3 clutter/cogl: Take over global frame count responsibility
The native backend had a plain counter, and the X11 backend used the
CoglOnscreen of the screen; change it into a plain counter in
ClutterStageCogl. This also moves the global frame count setting to the
frame info constuctor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Jonas Ådahl
2a6e8bda8d cogl/onscreen: Let swap buffer caller create frame info
We currently have mutter set a global frame counter on the frame info in
the native backend, but in order to do this from clutter, change the
frame info construction from being implicitly done so when swapping
buffers to having the caller create the frame info and passing that to
the swap buffers call.

While this commit doesn't introduce any other changes than the API, the
intention is later to have the caller be able to pass it's own state
(e.g. the global frame count) along with the frame info.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285
2020-07-02 19:36:50 +02:00
Georges Basile Stavracas Neto
ae49f89cf3 clutter/stage: Remove color property
The property is deprecated and the current implementation simply
redirects it to ClutterActor::background-color, so remove it.

Also update the tests to set the background color directly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
ce3e293a18 clutter: Drop ClutterGroup
It is now unused.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:46 +00:00
Georges Basile Stavracas Neto
d4953c77c3 clutter/actor: Remove clutter_actor_show_all
Actors are visible by default these days, and this function
is deprecated for a long time.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
2020-06-27 13:35:45 +00:00
Adam Jackson
1398c6dfa4 cogl: Remove some unused #define GL_BLAH safeties
None of these constants are referenced in the files defining them.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
ab9f241cc5 cogl: Remove some dead stores not flagged by the compiler
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
1f5d6a01f5 cogl: Remove unused driver includes
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
ca79073014 cogl: Move graphics reset status into the driver vtable
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
0b6f5c6f55 cogl: Move GL-specific uniform code to the driver vtable
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
e2c2a332e6 cogl: Add and use sampler init/free hooks in the CoglDriverVtable
next_fake_sampler_object_number moves to CoglGLContext.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
245977e525 cogl: Move texture unit state to CoglGLContext
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
e03c75bac7 cogl: Add a slot for driver-private state to CoglContext
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
4ff58cc63f cogl: Move some pre-layer-change-notify code into the driver
A CoglTextureUnit is a GL-specific type, this should happen in the
driver not the core.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
462df7e61a cogl: Move some GL-specific GLSL details into the driver
_cogl_shader_set_source_with_boilerplate and _cogl_shader_compile_real
have enough GL assumptions that it makes sense to push them into the
backend. Taken together their only callers are under driver/gl, so.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
1285619bcf cogl: Move GL context/version details into the driver
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
d6f5ac5603 cogl: Remove now-unused CoglGpuInfo
This had been an entirely-too-GL-aware collection of renderer queries,
mostly to work around driver bugs and handle software drivers
intelligently. The driver workarounds have been removed (fix your
driver, and if you can't because it's closed-source, fix that first),
and we now delegate the am-i-software-or-not logic to the backend, so
this can all go

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:55 -04:00
Adam Jackson
d133f94f8f cogl: Introduce and use cogl_context_is_hardware_accelerated
We delegate the answer through CoglDriverVtable::is_hardware_accelerated
since this is properly a property of the renderer, and not something the
cogl core should know about. The answer given for the nop driver is
admittedly arbitrary, yes it's infinitely fast but no there's not any
"hardware" making it so.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1194
2020-06-18 13:55:14 -04:00
Jonas Ådahl
83ee122fad cogl/frame-info: Stop passing the CoglOutput
It's unused, and if it would be, it'd be unreliable, as it'd only be
valid on the Xlib and GLX cogl backends.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
Simon McVittie
59a2bff8e2 cogl tests: Normally skip tests that are not expected to succeed
If a test is not expected to succeed, then running it could be considered
to be a waste of resources, particularly if the failure might manifest
as an indefinite hang (see cogl!11), or if the test is likely to dump core
and trigger "expensive" crash-reporting mechanisms like systemd-coredump,
corekeeper, abrt or apport.

Skip the tests that are expected to fail. They can still be requested via
an environment variable, which can be set after fixing a bug to check which
tests are now passing.

Originally cogl!15, adapted for mutter's fork of cogl to use gboolean
instead of CoglBool.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1272

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-06-02 20:15:26 +00:00
Simon McVittie
a3cc62c285 cogl tests: Force defined behaviour for 24-bit left-shifts
When r is 128 or more, running tests compiled with the undefined behaviour
sanitizer (ubsan) reports:

test-utils.c:312:45: runtime error: left shift of 128 by 24 places cannot be represented in type 'int'

which indeed it cannot. Force the type to be unsigned 32-bit so that we
get defined behaviour.

Similarly, in test-atlas-migration, the left-shifted guint8 is promoted
to int, which again does not have enough non-sign bits available to
left-shift a value >= 128 by 24 bits. Again, force the shift to be done
in unsigned 32-bit space.

This was originally cogl!22, but applies equally to mutter's fork of cogl.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1271

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-05-27 21:26:49 +00:00
Simon McVittie
c3bf10d19a cogl test-premult: Don't free texture data until CoglBitmap is freed
According to the cogl_bitmap_new_for_data documentation, the data is not
copied, so the application must keep the buffer alive for the lifetime
of the CoglBitmap. Freeing it too early led to a use-after-free in the
cogl unit tests. With that fixed, the test passes, so remove the known
failure annotation.

This AddressSanitizer trace is from the original cogl, but the bug and
fix apply equally to mutter's fork of cogl:

==6223==ERROR: AddressSanitizer: heap-use-after-free on address 0x62100001a500 at pc 0x7f3e2d4e7f4e bp 0x7ffcd9c41f30 sp 0x7ffcd9c416e0
READ of size 4096 at 0x62100001a500 thread T0
    #0 0x7f3e2d4e7f4d  (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x96f4d)
    #1 0x7f3e260c7f6b in util_copy_box ../src/gallium/auxiliary/util/u_surface.c:131
    #2 0x7f3e268c6c10 in u_default_texture_subdata ../src/gallium/auxiliary/util/u_transfer.c:67
    #3 0x7f3e26486459 in st_TexSubImage ../src/mesa/state_tracker/st_cb_texture.c:1480
    #4 0x7f3e26487029 in st_TexImage ../src/mesa/state_tracker/st_cb_texture.c:1709
    #5 0x7f3e26487029 in st_TexImage ../src/mesa/state_tracker/st_cb_texture.c:1691
    #6 0x7f3e2644bdba in teximage ../src/mesa/main/teximage.c:3105
    #7 0x7f3e2644bdba in teximage_err ../src/mesa/main/teximage.c:3132
    #8 0x7f3e2644d84f in _mesa_TexImage2D ../src/mesa/main/teximage.c:3170
    #9 0x7f3e2cd1f7df in _cogl_texture_driver_upload_to_gl driver/gl/gl/cogl-texture-driver-gl.c:347
    #10 0x7f3e2ccd441b in allocate_from_bitmap driver/gl/cogl-texture-2d-gl.c:255
    #11 0x7f3e2ccd441b in _cogl_texture_2d_gl_allocate driver/gl/cogl-texture-2d-gl.c:462
    #12 0x7f3e2ce3a6c0 in cogl_texture_allocate cogl/cogl-texture.c:1398
    #13 0x7f3e2ce3e116 in _cogl_texture_pre_paint cogl/cogl-texture.c:359
    #14 0x7f3e2cdee177 in _cogl_pipeline_layer_pre_paint cogl/cogl-pipeline-layer.c:864
    #15 0x7f3e2cd574af in _cogl_rectangles_validate_layer_cb cogl/cogl-primitives.c:542
    #16 0x7f3e2cdd742f in cogl_pipeline_foreach_layer cogl/cogl-pipeline.c:735
    #17 0x7f3e2cd5c8b0 in _cogl_framebuffer_draw_multitextured_rectangles cogl/cogl-primitives.c:658
    #18 0x7f3e2cd60152 in cogl_rectangle cogl/cogl-primitives.c:858
    #19 0x5570a71ed6a0 in check_texture tests/conform/test-premult.c:103
    #20 0x5570a71ed946 in test_premult tests/conform/test-premult.c:159
    #21 0x5570a71df0d6 in main tests/conform/test-conform-main.c:58
    #22 0x7f3e2bcd809a in __libc_start_main ../csu/libc-start.c:308
    #23 0x5570a71e0869 in _start (/home/smcv/src/debian/cogl/tests/conform/.libs/test-conformance+0x33869)

0x62100001a500 is located 0 bytes inside of 4096-byte region [0x62100001a500,0x62100001b500)
freed by thread T0 here:
    #0 0x7f3e2d5581d7 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x1071d7)
    #1 0x5570a71ed58b in make_texture tests/conform/test-premult.c:69

previously allocated by thread T0 here:
    #0 0x7f3e2d558588 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x107588)
    #1 0x7f3e2d384500 in g_malloc ../../../glib/gmem.c:99

This was originally cogl!12.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1274

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-05-27 15:50:36 +01:00
Jonas Ådahl
f8daa6bc70 cogl/dma-buf: Add mmap/munmap helpers
Avoids dealing directly with mmap() and munmap().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
5b07ccd0a7 cogl/dma-buf: Add API to synchronize reading
Used before and after accessing DMA buffer content using mmap().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
f60c485117 cogl: Make private BLIT_FRAMEBUFFER feature public
Will be a requirement for enabling shadow buffers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
4434a17d08 cogl/dma-buf-handle: Pass more metadata to handle constructor
Could be useful would one want to mmap the dmabuf and deal with its
content manually in CPU space.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Daniel van Vugt
c5fbab6bad cogl: Add new function cogl_pipeline_set_layer_max_mipmap_level()
To configure an exact value of `GL_TEXTURE_MAX_LEVEL` clamped to within
the range of possible levels.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
Daniel van Vugt
f4301b77fa cogl: Generalize maybe_update_max_level() into set_max_level()
This way the caller can choose their own precondition.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
Daniel van Vugt
a3f27dfd89 cogl: Ensure GL_TEXTURE_MAX_LEVEL is set before using it
Just in case it was lower before. So that `upload_subregion_to_gl` is
not trying to upload to a disallowed mipmap level.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
Daniel van Vugt
73ce9c2e81 cogl: Replace an outdated #ifdef
The feature `GL_TEXTURE_MAX_LEVEL` it is hiding actually exists
in ES>=3.0, so the #ifdef is not appropriate.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
Daniel van Vugt
fd27c7c444 cogl: Delete a duplicate (masked) variable declaration
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
Jonas Ådahl
753066598f clutter/view: Make it possible to assign a temporary direct scanout
Make it possible to cause the next frame to scan out directly from the
passed CoglScannout. This makes it possible to completely bypass
compositing for the following frame.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
3da8c1bfdc cogl/onscreen: Add API to scanout a buffer directly
Instead of always swapping buffers and flipping the back buffer, make it
possible to scan out a provided buffer directly without swapping any EGL
buffers.

A buffer is passed as an object implementing the empty CoglScanout
interface. It is only possible to do this in the native backend; and the
interface is implemented by MetaDrmBufferGbm. When directly scanned out,
instead of calling gbm_surface_lock_front_buffer() to get the gbm_bo and
fbid, get it directly from the MetaDrmBufferGbm, and use that to create
the page flip KMS update.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:15 +02:00
Marco Trevisan (Treviño)
645d596f9d cogl: Use autopointers to free structs on return
This is a potential leak discovered by static analysis, in fact if
_COGL_GET_CONTEXT returns, the newly allocated struct isn't released.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195
2020-04-12 21:40:20 +00:00
Adam Jackson
23d0bdd46d cogl: Remove unused fields from CoglContext
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1191
2020-04-09 11:48:03 -04:00
Carlos Garnacho
a5294ce55f cogl: Remove CoglPath and the tesselator
This was barely used, and doesn't represent the way we want to
do 2D rendering.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1126
2020-04-08 11:38:48 +02:00
Simon McVittie
c389aadff9 cogl: Defend against empty or unallocated framebuffers
It isn't immediately obvious that this is impossible, because there's some
"action at a distance" going on with framebuffers that have their size
set lazily, after their textures get allocated; so let's make this a
critical warning rather than crashing.

In particular, this works around a crash when gnome-shell tries to blur a
background that hasn't yet had any space allocated for it - which it seems
is really an actor layout bug, but more robustness seems good to have.

Workaround for <https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2538>.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1172

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-04-03 10:32:02 +01:00
Simon McVittie
37eda498f2 cogl: Don't allow creating sized textures with 0 pixels
A texture with no pixels isn't a useful thing to have, and breaks
assumptions elsewhere. For example, CoglFramebuffer assumes that after
a texture has been allocated, it will have width and height both greater
than 0.

In particular, this works around a crash when gnome-shell tries to blur a
background that hasn't yet had any space allocated for it - which it seems
is really an actor layout bug, but more robustness seems good to have.

Workaround for <https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2538>.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1172

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-04-03 10:31:54 +01:00
Carlos Garnacho
aa136f4515 cogl-pango: Special case alpha of 0 for color glyphs
Like ed10aea44d, but for color glyphs. Since they do use the alpha
component from the given color.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1161
2020-03-29 12:53:39 +00:00
Florian Müllner
8748841094 cogl: Export two more functions
cogl_object_[get|set]_value_object() are annotated as [get|set]-value-func
for objects and primitives, so they must be visible for any derived types
to be usable from introspection.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1146
2020-03-29 12:17:11 +00:00
Florian Müllner
86f2885e98 cogl: Remove obsolete .map file
Obsolete since commit 6885c37784.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1146
2020-03-29 12:17:11 +00:00
Carlos Garnacho
e8ea5ecd8a cogl-pango: Factor in default color alpha again
In commit d846fabda we moved to using the override color alpha, however
it was missed that the actor opacity is transferred to the PangoRenderer
through the default color alpha, and the reason it was used there.

We actually want to factor in both alpha values, in order to respect
both foreground color alpha and actor opacity. This is done on the
unpremultiplied color, so we just need to change the alpha value.

Fixes effects on text actors that involve actor opacity.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1158
2020-03-28 12:48:11 +01:00
Florian Müllner
ed10aea44d cogl-pango: Special case alpha of 0
pango_renderer_get_alpha() returns 0 to indicate that the alpha value
should be inherited from the environment, but we are passing it on
(and therefore making the text fully translucent).

Instead, make the text fully opaque as expected.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1156
2020-03-28 01:04:17 +01:00
Carlos Garnacho
d846fabda2 cogl-pango: Forward alpha from correct color
Use the override color alpha, if set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1155
2020-03-27 23:33:38 +01:00
Carlos Garnacho
2d94a34a14 cogl-pango: Honor foreground alpha PangoAttribute
Instead of hardcoding 0xff as alpha, forward this attribute.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1155
2020-03-27 23:33:35 +01:00
Georges Basile Stavracas Neto
3956ffd5e8 cogl/driver: Remove GError from context_init
It is not used by anyone, let's just remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1152
2020-03-27 09:01:43 -03:00
Georges Basile Stavracas Neto
05341221d4 cogl/renderer: Remove documentation of nonexistent enum
We don't want to delve into the philosohical study of the not-being,
so let's just not document an enum value that doesn't exist anymore.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1151
2020-03-26 18:44:13 -03:00
Georges Basile Stavracas Neto
95642d05a6 cogl/gl: Move shared functions to shared file
Cogl shares some GL functions between the GLES and the big
GL drivers. Namely, it shares _cogl_driver_gl_context_init
and _cogl_driver_gl_context_deinit between these two drivers.

The plot twist is: even though these functions are shared and
their prototypes are in cogl-util-gl-private.h, they're actually
implemented inside cogl-driver-gl.c, which is strictly only
about the big GL driver.

This is problematic when building Mutter on ARM v7, where we
need to disable OpenGL, but keep GLES enabled.

Fix this by moving the shared GL functions to a shared GL file.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1151
2020-03-26 18:43:32 -03:00
Jonas Ådahl
6885c37784 cogl: Mark exported cogl symbols using COGL_EXPORT
Just like libmutter-clutter, and libmutter, mark exported symbols with
an COGL_EXPORT macro. This removes the .map and .map.in files previously
used, containing a list of semi private symbols. This symbol was out of
date, i.e. pointed to non-existing symbols, and was also replaced with
COGL_EXPORT macros.

unit_test_* symbols are exported by the help of the unit test defining
macro. test_* symbols are no longer supported as it proved unnecessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1059
2020-03-26 09:05:38 +01:00
Jonas Ådahl
238e41d493 cogl: Install cogl-trace.h and include from cogl.h
This is so that cogl-trace.h can start using things from cogl-macros.h,
and so that it doesn't leak cogl-config.h into the world, while exposing
it to e.g. gnome-shell so that it can make use of it as well. There is
no practical reason why we shouldn't just include cogl-trace.h via
cogl.h as we do with everything else.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1059
2020-03-26 09:05:38 +01:00
Carlos Garnacho
3aece84499 cogl-pango: Make color glyphs unaffected by foreground color
Making color glyphs affected by the foreground color makes them become
"tinted" on any other color than white. Make it sure we always paint
those white by checking the cached glyph value, the foreground color
will be reset on the next iteration through glyphs.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/850

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1148
2020-03-25 11:14:33 +00:00
Carlos Garnacho
40fb06ca17 cogl-pango: Cache whether glyphs are backed up by a color font
This will be necessary later on.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1148
2020-03-25 11:14:33 +00:00
Corentin Noël
0053ef2e16 cogl-texture: Add some missing array annotations
This allows bindings to correctly understand that it is an array

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1130
2020-03-17 13:30:31 +01:00
Andre Moreira Magalhaes
6989fea767 cogl: Fix build error when GL_ARB_sync is not defined
Commit 41992757e0 introduced a change to use CoglContext.glFenceSync
but this method is only available when GL_ARB_sync is defined (as
defined on gl-prototypes/cogl-all-functions.h).

This change fixes that.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1123
2020-03-12 18:05:10 -03:00
Corentin Noël
df33255162 cogl: Add main header for Cogl
This allows bindings linking to the C header to actually have the right one.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1101
2020-03-12 13:35:25 +00:00
Jonas Dreßler
46e38ff61a cogl/clip-stack: Set color and depth mask when drawing rectangle clips
Just like with the other functions drawing to the stencil buffer, we
should make sure the depth and color masks are set to FALSE during
drawing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1096
2020-02-29 19:29:31 +00:00
Jonas Dreßler
1e0b015ce8 cogl/clip-stack: Explicitely initialize the stencil mask
We need the stencil buffer to consist of binary values of 0 and 1
because we're doing additions and subtractions on the buffer, so even
though this is the default, explicitely set the stencil mask to 0x1.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1096
2020-02-29 19:29:31 +00:00
Jonas Dreßler
72054332c5 cogl/clip-stack: Restore old matrices after drawing to stencil buffer
When using a region clip and something has a rectangle clip pushed, a
special drawing method for ClutterTexts (emit_vertex_buffer_geometry()
in cogl-pango-display-list.c) starts to fail and clipping issues with
long texts (because emit_vertex_buffer_geometry() is only used for texts
longer than 25 characters) start to appear. This specifically happened
in Looking Glass, where the StViewport of the ScrollView sets a
rectangle clips and the texts are usually longer than 25 characters.

This is caused by the changing of the perspective and modelview matrix
when drawing to the stencil buffer and started happening when
region-clipping was introduced with commit 8598b654. Even though the
changing of the matrices was done before that, too, the issue probably
didn't happen because `rect->can_be_scissor` was TRUE and no stencil
buffer clipping was used at all.

To fix this, temporarily save the old matrices, then set the new ones
and restore the old ones when we're done drawing to the stencil buffer.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/2246

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1096
2020-02-29 19:29:31 +00:00
Jonas Dreßler
d30ef0dd3b cogl/clip-stack: Use "merge" parameter for rectangle clips
Just like for the other sorts of clips, use a "merge" parameter instead
of a "first" parameter.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1096
2020-02-29 19:29:31 +00:00
Georges Basile Stavracas Neto
3881c1f952 cogl/context: Add cogl_renderer_create_dma_buf() and family
This is a winsys-specific API that allows exporting a DMA buffer fd.
The CoglDmaBufHandle structure allows passing the ownership of the
DMA buffer to whoever is using it, so the winsys doesn't need to
manually track it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 14:54:48 -03:00
Georges Basile Stavracas Neto
038a3170bf cogl/framebuffer: Add cogl_framebuffer_flush
In future patches, we'll create additional CoglFramebuffers that
will be shared via DMA-Buf with PipeWire. When recording frames,
we'll blit the current onscreen framebuffer into the shared one.

However, that presents a problem: cogl_framebuffer_blit() mimics
glBlitFramebuffer() semantics, and doesn't do an implicit flush
of the GPU command stream. As a consequence, clients may receive
unblitted or incomplete framebuffers.

We could use cogl_framebuffer_finish() to ensure the commands were
submitted to the GPU, but it is too harsh -- it blocks the CPU
completely until the commands are finished!

Add cogl_framebuffer_flush(), which ensures the command stream is
submitted to the GPU without blocking the CPU. Even though we don't
use the framebuffer specifically, it may be useful in the future
for e.g. a potential Vulkan backend to have access to the framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 10:52:34 -03:00
Adam Jackson
41992757e0 cogl: GLES3 has sync objects
https://gitlab.gnome.org/GNOME/mutter/merge_requests/882
2020-02-19 17:55:46 +00:00
Adam Jackson
445af61a68 cogl: GLES3 has vertex array objects
https://gitlab.gnome.org/GNOME/mutter/merge_requests/882
2020-02-19 17:55:46 +00:00
Adam Jackson
03ef335a70 cogl: GLES3 has sampler objects
https://gitlab.gnome.org/GNOME/mutter/merge_requests/882
2020-02-19 17:55:46 +00:00
Adam Jackson
b4226daadb cogl: GLES3 has glGetStringi
https://gitlab.gnome.org/GNOME/mutter/merge_requests/882
2020-02-19 17:55:46 +00:00
Adam Jackson
5c704e3f81 cogl: Remove no-op cogl_shader_compile and cogl_shader_get_info_log
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1024
2020-02-12 21:55:44 +00:00
Adam Jackson
c1bdaba5ac cogl: Inline cogl_use_program into its one caller
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1015
2020-01-31 17:26:25 +00:00
Adam Jackson
640ad4718e cogl: Inline _cogl_framebuffer_remove_all_dependencies into its one caller
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1015
2020-01-31 17:26:25 +00:00
Adam Jackson
985b3b32ce cogl: Remove unused _cogl_pipeline_get_layers
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1015
2020-01-31 17:26:25 +00:00