Commit Graph

2538 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
d4ff5e2d31 clutter/actor: Remove deprecated clutter container foreach
This is deprecated, so replace it with ClutterActorIter or alternative funcs

https://gitlab.gnome.org/GNOME/mutter/merge_requests/816
2019-10-15 08:51:45 +00:00
Niels De Graef
0d0286d59e cogl: Remove COGL_INVALID_HANDLE
Just use `NULL`, which is the normal C convention

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
2019-10-14 17:05:28 +00:00
Niels De Graef
23f77a1b63 cogl: Remove cogl_handle_ref/unref
This is for all intents and purposes the same as
`cogl_object_ref/unref`, but still refers to handles rather than
objects (while we're trying to get rid of the former) so it's a bit of
unnecessary redundant API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
2019-10-14 17:05:28 +00:00
Daniel van Vugt
73eaf51770 cogl-pango/meson.build: Remove extraneous quoting
It wasn't necessary (see other instances of -DG_LOG_DOMAIN) and somewhere
along the line it was getting turned into forward slashes becoming a syntax
error:

```
/usr/include/glib-2.0/gobject/gobject.h:767: syntax error, unexpected '/' in
...
g_assertion_message (/"CoglPango/",
```

https://gitlab.gnome.org/GNOME/mutter/merge_requests/841
2019-10-10 17:29:44 +08:00
Olivier Fourdan
0cdf13ac12 cogl: Flush journal before blitting
Make sure to submit all pending primitives before blitting, otherwise
rendering from the shell may be incomplete leaving partial drawing of
the shell widgets.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/820
2019-10-03 10:12:21 +02:00
Adam Jackson
0f51ae7cf0 cogl: Remove unused CoglTextureDriver::prep_gl_for_pixels_upload
https://gitlab.gnome.org/GNOME/mutter/merge_requests/814
2019-09-28 14:50:07 +00:00
Jonas Ådahl
ecec9a7eaa cogl/egl: Just notify about failure to create high priority context
Warning about it causes test case failures if there are not enough
privileges, which is likely when running the test suite locally.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/797
2019-09-13 09:47:00 +02:00
Daniel van Vugt
6ed5d2e2b4 cogl: Remove GLX "threaded swap wait" used on Nvidia
Threaded swap wait was added for using together with the Nvidia GLX
driver due to the lack of anything equivalent to the INTEL_swap_event
GLX extension. The purpose was to avoid inhibiting the invocation of
idle callbacks when constantly rendering, as the combination of
throttling on swap-interval 1 and glxSwapBuffers() and the frame clock
source having higher priority than the default idle callback sources
meant they would never be invoked.

This was solved in gbz#779039 by introducing a thread that took care of
the vsync waiting, pushing frame completion events to the main thread
meaning the main thread could go idle while waiting to draw the next
frame instead of blocking on glxSwapBuffers().

As of https://gitlab.gnome.org/GNOME/mutter/merge_requests/363, the
main thread will instead use prediction to estimate when the next frame
should be drawn. A side effect of this is that even without
INTEL_swap_event, we would not block as much, or at all, on
glxSwapBuffers(), as at the time it is called, we have likely already
hit the vblank, or will hit it soon.

After having introduced the swap waiting thread, it was observed that
the Nvidia driver used a considerable amount of CPU waiting for the
vblank, effectively wasting CPU time. The need to call glFinish() was
also problematic as it would wait for the frame to finish, before
continuing. Due to this, remove the threaded swap wait, and rely only on
the frame clock not scheduling frames too early.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=781835
Related: https://gitlab.gnome.org/GNOME/mutter/issues/700

[jadahl: Rewrote commit message]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/602
2019-09-02 18:12:10 +08:00
Jonas Ådahl
ab1107973b backends/native: Add various cogl traces
Trace the time spent finishing a frame, posting KMS updates and some
other things.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/757
2019-08-31 12:22:39 +00:00
Adam Jackson
b7ef8796b2 cogl: Remove unused cogl_{begin,end}_gl API
Any GL calls we want to make should be inside cogl already.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/500
2019-08-16 06:35:35 +00:00
Adam Jackson
7e8a864992 cogl: Remove unused cogl-gles2 API
This was introduced in:

    commit 010d16f647
    Author: Robert Bragg <robert@linux.intel.com>
    Date:   Tue Mar 6 03:21:30 2012 +0000

        Adds initial GLES2 integration support

        This makes it possible to integrate existing GLES2 code with
        applications using Cogl as the rendering api.

That's maybe a reasonable thing for a standalone cogl to want, but our
cogl has only one consumer. So if we want additional rendering out of
our cogl layer, it makes more sense to just add that to cogl rather than
support clutter or mutter or the javascript bindings creating their own
GLES contexts.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/500
2019-08-16 06:35:35 +00:00
Iain Lane
59fb26cb00
cogl/tests: Only install run-tests.sh when building installed tests
This is a script for installed tests; leave it out otherwise.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/694
2019-07-22 22:07:39 +01:00
Jonas Ådahl
7868ab761f cogl/texture: Add EGLImage texture import flags
The flags are 'none', and 'no-get-data' meaning get_data() is not
supported.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/687
2019-07-18 14:09:22 +00:00
Jonas Ådahl
e6c8939c30 cogl/texture: Make is_get_data_supported() a bool on the texture
Comparing the gl target is not enough. More on that later.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/687
2019-07-18 14:09:22 +00:00
Pekka Paalanen
6061abbf90 cogl: Expose cogl_blit_framebuffer
The function will be used in copying from a primary GPU framebuffer to a
secondary GPU framebuffer using the primary GPU specifically when the
secondary GPU is not render-capable.

To allow falling back in case glBlitFramebuffer cannot be used, add boolean
return value, and GError argument for debugging purposes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
55c084e6e1 cogl: Rename feature OFFSCREEN_BLIT to BLIT_FRAMEBUFFER
The feature is not limited to offscreen framebuffer blits anymore since
"cogl: Allow glBlitFramebuffer between onscreen/offscreen".

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
45289b3d65 cogl: Allow glBlitFramebuffer between onscreen/offscreen
Depends on "cogl: Replace ANGLE with GLES3 and NV framebuffer_blit"

Allow blitting between onscreen and offscreen framebuffers by doing the y-flip
as necessary. This was not possible with ANGLE, but now with ANGLE gone,
glBlitFramebuffer supports flipping the copied image.

This will be useful in follow-up work to copy from onscreen primary GPU
framebuffer to an offscreen secondary GPU framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
6df34eb4b7 cogl: Relax formats on glBlitFramebuffer
Depends on: "cogl: Replace ANGLE with GLES3 and NV framebuffer_blit"

As a possible ANGLE implementation is not longer limiting the pixel format
matching, lift the requirement of having the same pixel format.

We still cannot do a premult <-> non-premult conversion during a blit, so guard
against that.

This will be useful in follow-up work to copy from onscreen primary GPU
framebuffer to an offscreen secondary GPU framebuffer if the formats do not
match exactly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
3e68c9e8fa cogl: Replace ANGLE with GLES3 and NV framebuffer_blit
ANGLE extensions are only provided by Google's Almost Native Graphics Layer
Engine (ANGLE) implementation. Therefore they do not seem too useful for
Mutter.

The reason to drop GL_ANGLE_framebuffer_blit support is that it has more
limitations compared to the glBlitFramebuffer in GL_EXT_framebuffer_blit,
GL_NV_framebuffer_bit, OpenGL 3.0 and OpenGL ES 3.0. Most importantly, the
ANGLE version cannot flip the image while copying, which limits
_cogl_blit_framebuffer to only off-screen <-> off-screen copies. Follow-up work
will need off-screen <-> on-screen copies.

Instead of adding yet more capability flags to Cogl, dropping ANGLE support
seems appropriate.

The NV extension is added to the list of glBlitFramebuffer providers because it
provides the same support as ANGLE and more.

Likewise OpenGL ES 3.0 is added to the list of glBlitFramebuffer providers
because e.g. Mesa GLES implementation usually provides it and that makes it
widely available, again surpassing the ANGLE supported features.

Follow-up patches will lift some of the Cogl assumptions of what
glBlitFramebuffer cannot do.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
fc0ce11fcd cogl: Fix doc for _cogl_blit_framebuffer
Commit 38921701e5 added explicit source and
destination parameters. Fix the documentation to match.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
c08a24bb40 cogl: Remove unused OFFSCREEN_BLIT feature flag
This named constant is never used anywhere.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Emmanuele Bassi
c17af6c794 Add fallback for semi-private symbols in Pango
Pango dropped the PANGO_ENABLE_BACKEND and PANGO_ENABLE_ENGINE symbols,
so we need to add our own defines to avoid breaking the build.

https://gitlab.gnome.org/GNOME/mutter/issues/667
2019-07-07 10:37:51 +01:00
Daniel van Vugt
d7d75dd8e7 cogl-trace: Include cogl-trace.h even when not tracing
Public functions in C should be declared before they are defined, and
often compilers warn you if you haven't:

```
../cogl/cogl/cogl-trace.c:237:1: warning: no previous prototype for
‘cogl_set_tracing_enabled_on_thread_with_fd’ [-Wmissing-prototypes]
 cogl_set_tracing_enabled_on_thread_with_fd (void       *data,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../cogl/cogl/cogl-trace.c:245:1: warning: no previous prototype for
‘cogl_set_tracing_enabled_on_thread’ [-Wmissing-prototypes]
 cogl_set_tracing_enabled_on_thread (void       *data,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../cogl/cogl/cogl-trace.c:253:1: warning: no previous prototype for
‘cogl_set_tracing_disabled_on_thread’ [-Wmissing-prototypes]
 cogl_set_tracing_disabled_on_thread (void *data)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

In this case the function declarations were not included because
`HAVE_TRACING` isn't defined. But we should still include `cogl-trace.h`
because it handles the case of `HAVE_TRACING` not being defined and
correctly still declares the functions defined in `cogl-trace.c`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/650
2019-06-26 16:36:05 +00:00
Niels De Graef
70bacb9402 cogl: Remove CoglError wrapper
CoglError was added at a certain point to remove the hard dependency on
GLib, but since this can't be avoided inside mutter, let's remove this
whole abstraction.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/631
2019-06-20 18:25:04 +02:00
Niels De Graef
769a02b630 cogl: Drop _COGL_RETURN_VAL_IF_FAIL macro
This was introduced when the Cogl maintainers tried to move away from
GLib. Since we always require it, we can just use
`g_return_val_if_fail()` immediately.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/629
2019-06-19 21:46:22 +02:00
Niels De Graef
576330edce cogl: Drop _COGL_RETURN_IF_FAIL macro
This was introduced when the Cogl maintainers tried to move away from
GLib. Since we always require it, we can just use `g_return_if_fail()`
immediately.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/629
2019-06-19 21:36:19 +02:00
Niels De Graef
a2a114e79c cogl: Remove unused _COGL_TYPEDEF_ASSERT() macro
We can safely remove it since it's used nowhere in the code base. If you
would still like to use someting similar, there's `G_STATIC_ASSERT`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/629
2019-06-19 21:03:31 +02:00
Niels De Graef
79e22853ea cogl: Remove cogl_util_ffs macro
Since commit 46942c24, we don't need the wrapper macro as we always
require its implementation to be available on the build system.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/629
2019-06-19 21:03:28 +02:00
Niels De Graef
be72b22964 cogl: Remove cogl_util_memmem() macro
`cogl_util_memmem` was used as a wrapper in case `memmem` wasn't
defined, but since commit 46942c24 these are required. In case of
`memmem`, we didn't explicitly require this in the meson build files, so
add that as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/629
2019-06-19 21:03:23 +02:00
Niels De Graef
2ff6beea35 cogl: Remove cogl_wayland_texture_2d_* functions
These are implemented in the Meta namespace these days, where we have
better abstractions for wayland-related types. They also weren't used
anymore, since we removed the unused ClutterWaylandSurface type in the
previous commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/624
2019-06-18 09:54:04 +02:00
Florian Müllner
8a06cfdd81 enum-types: Use @basename@ in header comment
@filename@ may contain arch-specific bits that introduce unnecessary
multi-lib issues.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/617
2019-06-12 18:01:36 +02:00
Georges Basile Stavracas Neto
9b53583945
cogl/trace: Fix typo
https://gitlab.gnome.org/GNOME/mutter/merge_requests/609
2019-06-07 12:58:10 -03:00
Georges Basile Stavracas Neto
7810f0e276
cogl/trace: Add user-visible group name
This way, it shows up as "Compositor" in Sysprof instead of
"t:XYZ".

https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
2019-05-31 11:57:09 -03:00
Georges Basile Stavracas Neto
9b8f9b65b8
clutter: Add more descriptive profiling sections
The idea here is to be able to visualize and immediately
understand what is happening. Something like:

```
                   [ view1 ] [ view2 ]
 [---- Layout ---][------ Paint ------][ Pick ]
[================== Update =====================]
```

But with colors. A few of the previous profiling data
sections were removed, since they didn't really add to
reading the graph.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
2019-05-31 11:57:08 -03:00
Georges Basile Stavracas Neto
e741cab3f4
profiler: Support setting output filename
So we can have some control over where the file will
be saved.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
2019-05-31 11:57:08 -03:00
Georges Basile Stavracas Neto
53748e3da7
cogl-trace: Cleanup context after disabling
This allows running the Capture() method multiple times,
with different arguments each time.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
2019-05-31 11:57:07 -03:00
Jonas Ådahl
e5e58f8075
cogl: Add libsysprof capture based tracing
Add the ability to add tracing instrumentation to the code. When
enabled, trace entries will generate a file with timing information
that will be processable by sysprof for generating visualization of
traces over time.

While enabled by default at compile time, it is possible to disable the
expansion of the macros completely by passing --disable-tracing to
./configure.

Tracing is so far only actually done if actually enabled on explicitly
specified threads.

This will be used by Mutter passing the write end of a pipe, where the
read end is sent to Sysprof itself via the D-Bus method 'Capture()'.

By passing that, we have to detect EPIPE that is sent when Sysprof stops
recording. Fortunately, we already ignore the signal at meta_init(), so
no need to add a custom signal handler.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/197
2019-05-31 11:55:56 -03:00
Robert Mader
a859d76c72 meson: Cleanup debug build handling
Add debug flags based on meson's `debug` option instead of `buildtype`.
This allows custom build configurations to behave like a debug or release build.

Add `-fno-omit-frame-pointer` to Mutter/Cogl. Not to Clutter though, as that would
require more changes to how Clutter's gir is created

Remove `-DG_DISABLE_CAST_CHECKS` from Clutter in debug builds

Add `-DG_DISABLE_CHECKS`, `-DG_DISABLE_ASSERT` and `-DG_DISABLE_CAST_CHECKS` to all
non-debug builds but `plain`, which explicitly should not have any compile flags

Use `cc.get_supported_arguments`, so it becomes more obvious to the user which flags
are set during compilation

https://gitlab.gnome.org/GNOME/mutter/merge_requests/497
2019-05-29 15:52:39 +00:00
Florian Müllner
80d11287eb cogl-path: Undeprecate framebuffer functions
It looks like deprecating the functions with explicit framebuffer/pipeline
arguments made it to (cogl) master by mistake:

https://mail.gnome.org/archives/clutter-list/2016-April/msg00008.html

We now use one of them, so this is a good time to undeprecate the lot.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/597
2019-05-27 22:48:19 +00:00
Marco Trevisan (Treviño)
7e0d185120 cogl/pipeline: Don't try to access to free'd pointer data
When free'ing a pipeline we destroy the BigState first and then the fragment and
vertex snippets lists using the big state pointer which is now invalid.
This causes a crash  when G_SLICE=always-malloc is set and using MALLOC_CHECK_.

So, invert the operations by free'ing the snippet lists first, and the big state
afterwards.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:23:54 -05:00
Marco Trevisan (Treviño)
61c173b777 cogl/xlib-renderer: Save Xlib renderer data in custom winsys pointer
XLib renderer saves its data as the object cogl user data, however this data
is free'd as part of the object destruction that happens before free'ing the
renderer in _cogl_renderer_free(), from where we're calling the renderer
disconnect vfunc.
Thus in _cogl_xlib_renderer_disconnect() we happen to get an invalid pointer to
CoglXlibRenderer and we try access to it in order to close the X11 display.

This causes all the cogl tests to crash when G_SLICE=always-malloc is set and
when using MALLOC_CHECK_.

Fix this using the renderer winsys custom data instead of using cogl object data
for storing the CoglXlibRenderer, and handling the destruction of it manually.

As bonus this also makes access to the renderer data faster.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
Marco Trevisan (Treviño)
9305b6d8ee cogl/tests: Remove configure_file workaround for installed tests
Since starting meson 0.50 `install: false` is honored when the install_dir is
set to a non-empty value, we can now remove the workaround we added in commit
dbe73c329

https://gitlab.gnome.org/GNOME/mutter/merge_requests/585
2019-05-21 12:36:15 -05:00
Marco Trevisan (Treviño)
ea0a89bde8 cogl/meson: Remove uneeded cogl-mutter-config.h generation
This was needed until we had autotools in place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/585
2019-05-21 12:36:10 -05:00
Niels De Graef
0d7a929b83 cogl: Map CoglPixelFormats to their specific properties
By providing an (internal) table to map `CoglPixelFormat`s to their
respective properties  we will be able to get rid of the unusual enum
values in the future. This is something we will need once we want to
have support for more pixel formats (such as YUV-based formats).

As an extra feature, we provide a `to_string()` method, which is quite
useful for debugging purposes (rather than deciphering enum values).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/524
2019-05-21 15:20:44 +02:00
Niels De Graef
991f9505ad cogl: Put CoglPixelFormat code into its own file
We're going to add some features and extra code to CoglPixelFormat, so
it's much nicer to have it in once place. Notice also that it doesn't
make sense that e.g. `_cogl_pixel_format_get_bytes_per_pixel()` were in
a private header, since they were being exported anyway.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/524
2019-05-21 15:20:44 +02:00
Marco Trevisan (Treviño)
7a17e236f7 Use free_full on GSList's instead of foreach + free
GList's used in legacy code were free'd using a g_slist_foreach + g_slist_free,
while we can just use g_slist_free_full as per GLib 2.28.

So replace code where we were using this legacy codepath.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/576
2019-05-15 14:49:56 -05:00
Marco Trevisan (Treviño)
df7d8e2cbf Use free_full on GList's instead of foreach + free
GList's used in legacy code were free'd using a g_list_foreach + g_list_free,
while we can just use g_list_free_full as per GLib 2.28.

So replace code where we were using this legacy codepath.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/576
2019-05-15 14:42:25 -05:00
Marco Trevisan (Treviño)
81ae886dda cogl/tests: Use less verbose run-tests.sh on single tests run by meson
Use less verbose output when run-tests.sh is running only a test and we're
requested for less verbose output.

Also write the test name first of running it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
63c40a9711 meson: Define srcdir and builddir using meson functions
No need to redefine paths starting from top src/build dirs, as meson can give us
this information for free using its functions.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
8374be46d2 cogl/tests: Export and run unit tests if they are enabled
Cogl unit tests are just functions inside normal code files that needs to be
dload'ed by the test binary.

So in case unit-tests are enabled, we need to export those symbols.
Since map file can't be overridden, use a configure_file to generate the map
file when tests are enabled, in order to export the needed symbols.

Then goes through the source files to look unit tests checking for their macro
definition and load them with the runner script.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
34312c272b cogl/tests: Run conform tests as single meson tests
Use find-conform-unit-tests.sh to create a meson list of tests to run.
This allows to run each test as single test with meson and to remove the timeout
for all the tests.

Instead of changing 'run-tests.sh' to take test-names as arguments we can just
generate simple dummy test-files for each test, without having to change the
tooling.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
2b8f5e65b6 cogl/tests: Run tests supports both test names and files as parameter
Make run-tests.sh to support as arguments both an unit-tests file or test names

This allows to run a test with this script without having to create fake files.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Marco Trevisan (Treviño)
a934fa07b8 tests: Use suites for test cases
They allows to filter tests better and so we can just launch tests with:
  meson test --suite [core|cogl|clutter] [single-test-name]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
Adam Jackson
7df86fb246 cogl: Use EGL_IMG_context_priority if available
We're the context closest to the display, so we should take priority
over other clients.

v2: Warn if we asked for a high-priority context and didn't get one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/454
2019-04-18 20:27:26 +00:00
Adam Jackson
3f29b47809 cogl: Generalize EGL context attribute initialization
No functional change, just makes the next change clearer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/454
2019-04-18 20:27:26 +00:00
Adam Jackson
9ab3a02a8a cogl: Remove unused TEXTURE_RECTANGLE feature flag
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:28 -04:00
Adam Jackson
ca2be8ef5b cogl: Remove CoglTextureType
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:26 -04:00
Adam Jackson
1783ea5af1 cogl: Remove unused texture_type argument from cogl_pipeline_set_layer_null_texture
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:24 -04:00
Adam Jackson
862e56f01d cogl: Remove unused CoglTextureVable::get_type
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:21 -04:00
Adam Jackson
2b9cd50e84 cogl: Eliminate _cogl_gl_util_get_texture_target_string
Its results are effectively constant now. Fold them into the callers and
remove the function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:19 -04:00
Adam Jackson
e71f44dbd6 cogl: Remove never-changing COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE state
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:17 -04:00
Adam Jackson
c881b4970d cogl: Remove unused CoglTextureRectangle
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:16 -04:00
Adam Jackson
d79f176142 cogl: Remove texture_rectangle awareness from the GLX TFP code
GL 2.1 implies ARB_texture_non_power_of_two so this will never be hit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:14 -04:00
Adam Jackson
ce6acf9dca cogl: Remove rectangle-texture tests
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:12 -04:00
Adam Jackson
fb40e2eefb cogl: Remove unused cogl_texture_new_from_foreign
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:09 -04:00
Adam Jackson
fc09fa50a5 cogl: NPOT textures are always available
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:07 -04:00
Adam Jackson
48f04c7968 cogl: COGL_FEATURE_TEXTURE_NPOT_BASIC is always available
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:06 -04:00
Adam Jackson
007297f1a6 cogl: COGL_FEATURE_TEXTURE_NPOT_MIPMAP is always available
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:04 -04:00
Adam Jackson
302a171c08 cogl: COGL_FEATURE_TEXTURE_NPOT_REPEAT is always available
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:03 -04:00
Adam Jackson
893e894fff cogl: Remove always-true COGL_FEATURE_SHADERS_GLSL
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:01 -04:00
Adam Jackson
2aaed7bdfc cogl: Remove debug disables for GLSL and NPOT textures
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:52:57 -04:00
Adam Jackson
249f9a4a2e cogl: Stop running non-NPOT tests
The minimum GL/GLES versions require working NPOT textures.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:52:54 -04:00
Adam Jackson
68166f33d9 cogl: Fix some misleading variable names
This was clearly blindly copypasta'd from the (now deleted) 3D texture
code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/487
2019-04-18 01:26:32 +00:00
Adam Jackson
28954e8271 cogl: Remove unused 3D texture support
We're not using this, and it's difficult to imagine we ever would.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/487
2019-04-18 01:26:32 +00:00
Robert Mader
db486ad897 cogl/texture-2d: Remove notes about COGL_FEATURE_ID_TEXTURE_NPOT
NPOT capabilities were made madatory in OpenGL 2.0 and GLES 2.0,
so let's stop encouraging developers to write new code with checks
for it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/467
2019-04-17 20:14:59 +00:00
Adam Jackson
8180927de2 cogl: Bump minimum GLES version to 2.0
This is already effectively true because there is only a GLSL backend.
It also implies OES_texture_npot.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/489
2019-04-17 20:06:47 +00:00
Adam Jackson
191c31b0f0 cogl: Bump minimum GL version to 2.1
We already effectively require GLSL, because there's no fixed-function
backend anymore. OpenGL 2.0 drivers don't really exist in the wild, so
just go ahead and require 2.1 or better. 2.1 implies GLSL 1.20 or
better, so simplify that as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/489
2019-04-17 20:06:47 +00:00
Adam Jackson
a94841abf1 cogl: Remove color write masks from the framebuffer and pipeline API
The only thing using this is its own tests, and it's difficult to
imagine a real use for it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/468
2019-04-17 19:57:14 +00:00
Adam Jackson
b624e94ab1 cogl: Remove viewport scissor workaround
This is effectively a revert of:

    commit 6cfc93f26f
    Author: Robert Bragg <robert@linux.intel.com>
    Date:   Tue Oct 2 11:44:00 2012 +0100

        clip-stack: workaround intel gen6 viewport clip bug

It's been over six years, if this bug is still present we should just
fix Mesa already.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/481
2019-04-17 19:48:03 +00:00
Daniel van Vugt
20c1295a33 cogl-winsys-glx: Fix frame notification race/leak
If a second `set_{sync,complete}_pending` was queued before the idle
handler had flushed the first then one of them would be forgotten.
It would stay queued forever and never emitted as a notification.

This could happen repeatedly causing a slow leak. But worse still,
`clutter-stage-cogl` would then have `pending_swaps` permanently stuck
above zero preventing the presentation timing logic from being used.

The problem is that a boolean can only count to one, but in some cases
(triple buffering, whether intentional or accidental #334) we need it to
count to two. So just change booleans to integers and count properly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/216
2019-04-12 11:09:00 +08:00
Heiher
afe8610b4a cogl/texture: Implement is_get_data_supported on GLES textures
https://gitlab.gnome.org/GNOME/mutter/merge_requests/515
2019-04-02 09:15:14 +00:00
Florian Müllner
a1e325f749 build: Don't use absolute paths with subdir keyword
Meson 0.50.0 made passing an absolute path to install_headers()'
subdir keyword a fatal error. This means we have to track both
relative (to includedir) paths for header subdirs and absolute
paths for generated headers now :-(

https://gitlab.gnome.org/GNOME/mutter/merge_requests/492
2019-03-18 12:37:14 +00:00
Florian Müllner
9aca31c814 cogl: Introspect CoglTexture2D(Sliced)
gnome-shell cannot use CoglTexture if gjs can't tell that an object
in question implements the CoglTexture interface.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1020
https://gitlab.gnome.org/GNOME/mutter/merge_requests/482
2019-03-11 23:57:08 +00:00
Adam Jackson
a555a2c8eb cogl: Remove unused CoglTextureDriver::try_setting_gl_border_color
https://gitlab.gnome.org/GNOME/mutter/merge_requests/480
2019-03-11 23:50:10 +00:00
Carlos Garnacho
a871d56f88 cogl: Revert swizzling for BGRA buffers
As it was originally reported on
https://bugzilla.gnome.org/show_bug.cgi?id=779234#c0, the hottest path was
convert_ubyte() in mesa. Reverting this shows no trace of those hot paths,
nor any higher than usual CPU activity.

As the improvements at the time were real, I can only conclude that pixel
conversion was happening somewhere further the pipeline, and swizzling just
helped indirectly. That got eventually fixed, so swizzling just stayed to
cause grief. And lots it caused.

Time to bin this, it seems.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/486
2019-03-08 10:41:25 +01:00
Carlos Garnacho
d83a325f98 Revert "Revert "cogl: Pick glReadPixels format by target, not source""
This reverts commit 4f72099023.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/486
2019-03-07 23:04:55 +01:00
Robert Mader
4f72099023 Revert "cogl: Pick glReadPixels format by target, not source"
This reverts commit 981b045459.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/418
2019-03-06 17:02:00 +01:00
Niels De Graef
1c6ea5d1db Use a consistent style for enum braces
https://gitlab.gnome.org/GNOME/mutter/merge_requests/361
2019-02-28 09:31:01 +01:00
Niels De Graef
a81435ab5f cogl: Remove CoglBool, use gboolean instead
This basically reverts commit 54735dec, which tried to avoid the
GLib-defined types in favor the standard C ones. One exception to this
is the bool type, for which the commit introduces a new type CoglBool.

Let's just get rid of this type in favor of having consistency with the
GLib types. Note by the way that neither CoglBool nor gboolean (which
has a size of `int`) are completely compatible with bool (size `char`).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/321
2019-02-15 16:35:46 +01:00
Marco Trevisan (Treviño)
dbe73c3296 meson: Do not install cogl config.env if installed tests are disabled
Until meson 0.50, setting the install parameter in 'configure_file' is ignored
if 'install_dir' is set. Then until mutter doesn't depend on such meson version
cogl_installed_tests_libexecdir should be empty unless have_installed_tests is
false, or this file will be installed anyway.

See https://github.com/mesonbuild/meson/issues/4160
2019-02-04 15:49:56 +00:00
Florian Müllner
5c3ec27b4b cogl: Fix builds with G_DISABLE_ASSERT
Commit 25f416c13d added additional compilation warnings, including
-Werror=return-type. There are several places where this results
in build failures if `g_assert_not_reached()` is disabled at compile
time and the compiler misses a return value.

https://gitlab.gnome.org/GNOME/mutter/issues/447
2019-01-25 00:48:12 +01:00
Marco Trevisan (Treviño)
7f551ba776 meson: Don't list libraries private dependencies in pc files
pkg-config files for mutter are generated using *_pkg_deps as requires, but
programs linked with libmutter doesn't need most of these private dependencies
which are only needed for building and linking mutter and its subprojects.

So list packages needed only by mutter itself inside *_pkg_private_deps and
don't expose such packages to pkg-config, but only use them at build time.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3955
2019-01-23 13:03:40 +00:00
Marco Trevisan (Treviño)
3838341d83 meson: Set cogl as dependency of libmutter-cogl dependency
Since a libmutter-cogl dependency is declared as libmutter_cogl_dep, it can be
used to avoid repeating cogl dependency everywhere.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3955
2019-01-23 13:03:40 +00:00
Marco Trevisan (Treviño)
08130912f0 meson: Set proper soversion and version to libraries
Soname of the libraries should be the major version number, while the version
triplet is currently used:
  objdump -p libmutter-4.so.0.0.0 | grep SONAME
    SONAME               libmutter-4.so.0.0.0

While is expected to be only libmutter-4.so.0

Fix all shared libraries by setting valid version and soversion.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/3955
2019-01-23 13:03:40 +00:00
Marco Trevisan (Treviño)
371b97af27 meson: Fix map files and load them to hide private symbols
Map files were using wrong syntax (missing final `;` or invalid chars).

Also, the map files were only monitored for rebuilding, but not really used by
ld, so pass the ldflags with version-script so that private symbols are really
hidden.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/395
2019-01-23 13:03:40 +00:00
Jonas Ådahl
c57ae7fc9c cogl/path: Don't depend on GL/glu.h
It's not needed for anything, and we can get rid of the dependency we
just added.

Also remove the installation step from Dockerfile.
2019-01-22 19:06:14 +01:00
Jonas Ådahl
982d135ace cogl: Add missing function declarations
In plenty of places a non-static function was defined but didn't have
the corresponding declaration. Fix this by adding them, or alternatively
making them static.
2019-01-22 18:31:52 +01:00
Jonas Ådahl
548c0f16f4 cogl: Remove redundant function declarations 2019-01-22 18:31:52 +01:00
Jonas Ådahl
bbd295ae09 cogl: Fix const qualifier usage 2019-01-22 18:31:52 +01:00
Jonas Ådahl
c55004864d cogl: Add missing void to functions with no arguments
I.e. foo () -> foo (void).
2019-01-22 18:31:52 +01:00
Jonas Ådahl
54685091f1 cogl-path: Remove own glu.h version
cogl-path uses types from glu.h, but to avoid a build dependency on glu,
it kept a minified copy of glu.h in tree. Drop this file and just use
the actual glu.h. To avoid linking to libGLU.so, just use the
includepath, instead of actually adding glu as a real dependency.

This means we can remove an includepath meant to make it possible to
include <GL/glu.h>.
2019-01-22 18:31:52 +01:00
Jonas Ådahl
d4a9535f04 cogl-path: Cast function pointer explicitly
gluTessCallback() expects an equivalent to a GFunc, but we pass
functions with arguments without casting. To get rid of warnings, cast
the callback function pointer to the expected type.
2019-01-22 18:31:52 +01:00
Georges Basile Stavracas Neto
763ae36cee
Drop Autotools
I saw Meson fade from the sky
On the wind I heard a sigh
As snowflakes cover fallen Makefiles
I will say this last goodbye

Meson is now coming
So ends Autotools days
Future is now coming
And we must away
Over Python and without Bashisms
Through lands where never Meson touched
By silver streams that run down to the Sea

Under parsers, beneath old legacy
Over snow one winter’s morn
I turned at last to paths that lead home
And though where the road then takes me
I cannot tell
We came all this way
But now comes the day
To bid you farewell

Many places I have been
Many sorrows I have seen
But I don’t regret
Nor will I forget
All Makefiles that took that road with me

I bid you all a very fond farewell.
2019-01-10 11:50:54 -02:00
Florian Müllner
d360b25b81 build: Install .pc files in correct location
If a library is provided in the positional arguments, then meson
defaults to installing the .pc file in a 'pkgconfig' subdirectory
in the library's install location. We want the files in the regular
$libdir/pkgconfig rather than $libdir/mutter-$api/pkgconfig, so
specify the location explicitly in the parameters.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/382
2019-01-08 22:36:20 +01:00
Jonas Ådahl
73ddd7cd48 build: Pass library as first argument to pkg.generate()
Dependencies are added automatically, and we no longer get warnings
like:

clutter/clutter/meson.build:628: DEPRECATION: Library mutter-clutter-4
was passed to the "libraries" keyword argument of a previous call to
generate() method instead of first positional argument. Adding
mutter-clutter-4 to "Requires" field, but this is a deprecated behaviour
that will change in a future version of Meson. Please report the issue
if this warning cannot be avoided in your case.
2019-01-08 09:05:08 +01:00
Jonas Ådahl
eac18647c3 cogl/texture: Add API to check whether _get_data() will work
Currently, GL_TEXTURE_EXTERNAL_OES textures doesn't support getting pixel data.
Make it possible for texture users to know this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
c681ccef3c cogl/texture-2d-gl: Bind correct target when getting data
While for normal textures, GL_TEXTURE_2D should be used, when it's an external
texture, binding it using GL_TEXTURE_2D results in an error.

Reading the specification for GL_TEXTURE_EXTERNAL_OES it is unclear whether
getting pixel data from a texture is possible, and tests show it doesn't result
in any data, but in case it would eventually start working, at least bind the
correct target for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
b329256113 cogl/texture-2d-gl: Try to determine format for external textures
Don't just set the internal format to the dummy format "any", as that causes
code intended to be unreachable code to be reached. It's not possible to
actually know the internal format of an external texture, however, so it might
not actually correspond to the real format.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/362
2019-01-03 10:26:13 +00:00
Jonas Ådahl
f7d4a727a8 build: Always pass --quiet to g-ir-scanner
This makes the build less verbose, as all .gir generation except for
clutters didn't pass --quiet to g-ir-scanner, making it output long
linking commands. Do this by adding a common introspection_args
variable.

While at it, put -U_GNU_SOURCE in there too, as it was always passed
everywhere as without it the scanner would log warnings.
2018-12-22 11:31:10 +01:00
Georges Basile Stavracas Neto
ebb6c56f67
Add Meson support for installed tests
This is the last remaining feature necessary to achieve
parity with the Autotools build.

A few changes were made to the install locations of the
tests, in order to better acomodate them in Meson:

 * Tests are now installed under a versioned folder (e.g.
   /usr/share/installed-tests/mutter-4)

 * The mutter-cogl.test file is now generated from an .in
   file, instead of a series of $(echo)s from within Makefile.

Notice that those tests need very controlled environments
to run correctly. Mutter installed tests, for example, will
failed when running under a regular session due to D-Bus
failing to acquire the ScreenCast and/or RemoteScreen names.
2018-12-20 13:52:35 -02:00
Georges Basile Stavracas Neto
05ab8eebe8
cogl/tests: Use tmp file to dump test results
When running installed tests, the working directory for Cogl
tests is /usr/libexec/installed-tests/mutter-cogl-4/conform,
which isn't writable by normal users.

To avoid the adding stray hidden files to the current directory,
adapt the runner script to fallback to $(mktemp) - which is
available on all platform we care about - and avoid adding
hidden files everywhere.
2018-12-20 11:30:40 -02:00
Pekka Paalanen
981b045459 cogl: Pick glReadPixels format by target, not source
Presumably glReadPixels itself can be more performant with pixel format
conversions than doing a fix-up conversion on the CPU afterwards. Hence,
pick required_format based on the destination rather than the source, so
that it has a better chance to avoid the fix-up conversion.

With CoglOnscreen objects, CoglFramebuffer::internal_format (the source
format) is also wrong. It is left to a default value and never set to
reflect the reality. In other words, read-pixels had an arbitrary
intermediate pixel format that was used in glReadPixels and then fix-up
conversion made it work for the destination.

The render buffers (GBM surface) are allocated as DRM_FORMAT_XRGB8888.
If the destination buffer is allocated as the same format, the Cogl
read-pixels first converts with glReadPixels XRGB -> ABGR because of the
above default format, and then the fix-up conversion does ABGR -> XRGB.
This case was observed with DisplayLink outputs, where the native
renderer must use the CPU copy path to fill the "secondary GPU"
framebuffers.

This patch stops using internal_format and uses the desired destination
format instead.

_cogl_framebuffer_gl_read_pixels_into_bitmap() will still use
internal_format to determine alpha premultiplication state and multiply
or un-multiply as needed. Luckily all the formats involved in the
DisplayLink use case are always _PRE and so is the default
internal_format too, so things work in practise.

Furthermore, the GL texture_swizzle extension can never apply to
glReadPixels. Not even with FBOs, as found in this discussion:
https://gitlab.gnome.org/GNOME/mutter/issues/72
Therefore the target_format argument is hardcoded to something that can
never match anything, which will prevent the swizzle from being assumed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/313
2018-12-19 19:21:51 +00:00
Pekka Paalanen
6502735f01 cogl: Remove mesa_46631_slow_read_pixels_workaround
This function gets hit even today on relatively modern Intel systems (I
have a Haswell Desktop with Mesa 18.2.4) if the pixel format is right.
Presumably it makes things slower for no longer a reason.

According to cb146dc515, this
functionality was refactored into a workaround path in 2012. The commit
message mentions the problem existing before Mesa 8.0.2. The number
refers to https://bugs.freedesktop.org/show_bug.cgi?id=46631 .

The use case where I hit this is when improving support for DisplayLink
video outputs. These are used through a "secondary GPU", and since
DisplayLink does not have a GPU, Mutter uses the CPU copy path with Cogl
read-pixels[1]. If the DisplayLink framebuffer was allocated as
DRM_FORMAT_XRGB8888 (the only format it currently handles correctly),
mesa_46631_slow_read_pixels_workaround would get hit. The render buffer is
the same format as the framebuffer, yet doing the copy XRGB -> XRGB ends
up being slower than XRGB -> XBGR which makes no sense.

This patch is not sufficient to fix the XRGB -> XRGB copy performance,
but it is required.

This patch reverts CoglGpuInfoDriverBug into what it was before
cb146dc515.

[1] This is not actually true until
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/278 is
    merged.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/313
2018-12-19 19:21:51 +00:00
Carlos Garnacho
4139907a7e cogl: Ensure to only clear the depth buffer if depth testing is enabled
The depth buffer is marked as invalid when 1) the framebuffer is just created,
and 2) whenever GL_DEPTH_TEST is enabled on it. This will ensure the
framebuffers attached depth buffer (if any) is properly cleared before it's
actually used, while saving needless clears while depth testing is disabled
(the default).

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2018-12-18 12:51:28 +01:00
Ting-Wei Lan
b34bb773a4 tests: Don't show 'core dumped' messages 2018-12-11 12:53:31 -02:00
Georges Basile Stavracas Neto
7d20101198 cogl-framebuffer: Remove swap_throttled config
Since now we don't set the swap throttled value based
on sync-to-vblank, we can effectively remove it from
Cogl. Throttling swap buffers in Cogl is as much a
historical artifact as sync-to-vblank. Furthermore,
it doesn't make sense to disable it on a compositor,
which is the case with the embedded Cogl.

In addition to that, the winsys vfunc for updating
whenever swap throttling changes could also be removed,
since swap throttling is always enabled now.

Removing it means less code, less branches when running,
and one less config option to deal with.

This also removes the micro-perf test, since it doesn't
make sense for the case where Cogl is embedded into the
compositor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/191
2018-12-06 14:29:34 +00:00
Niels De Graef
9004253c4e cogl: remove CoglFuncPtr, use GCallback instead
They literally mean the same thing, so we shouldn't reinvent the wheel.
2018-12-05 13:20:43 +00:00
Ting-Wei Lan
319500e4f3 tests: Fix warnings reported by shellcheck
This commit includes following fixes for a few shell scripts:

1. Follow the best practice of quoting variables everywhere unless they
   are used in places where word-splitting and globbing can never happen.

2. Replace `command` with $(command) because the latter is easier to use
   and read.

3. Don't use "$@" in places expecting a string because it is an array
   of strings instead of a single string.
2018-12-01 13:07:29 +00:00
Ting-Wei Lan
b2e75b5da0 build: Don't hardcode the path of bash
Bash is not always installed in /bin and we should not hardcode the path
of it in source code which is expected to be built on many operating
systems and distributions.

Since most scripts using #!/bin/bash here doesn't have any bashism,
they can be converted to #!/bin/sh instead of using /usr/bin/env trick.
2018-12-01 12:56:12 +00:00
Niels De Graef
6834bedb95 cogl: remove COGL_GNUC_NULL_TERMINATED
This is already defined for us in GLib, so prefer that instead.
2018-11-23 08:55:43 +01:00
Niels De Graef
bf8a3b1c1c cogl: Remove unused macro COGL_GNUC_DEPRECATED
This is also already defined in GLib as G_GNUC_DEPRECATED.

(Note that it is also something different than COGL_DEPRECATED)
2018-11-23 08:55:43 +01:00
Niels De Graef
3a4a858ce3 cogl: use G_BEGIN_DECLS instead of COGL_BEGIN_DECLS
This macro was introduced so as to be able to be built without GLib.
However, this feature was long ago removed, and in Mutter we depend on
it anyway, so let's get rid of it in favor of more consistency.
2018-11-23 08:55:43 +01:00
Niels De Graef
081842bac6 cogl/object: add cogl_clear_object utility function
This is based on `g_clear_object`, so it will be a bit more consistent
to write (and prevents the headaches from accidentally forgetting a NULL
check).
2018-11-20 15:25:24 +01:00
Jonas Ådahl
5b3e439c5d cogl/tests: Increase the conform test timeout to 120 s
Running it on CI runners can take bit more time, so let it be for a bit
more until bailing out.
2018-11-14 15:55:45 +01:00
Jonas Ådahl
996949806a
cogl: Silence some introspection warnings
Mostly skipping functions of non-introspected types, but also added a
missing callback scope.
2018-11-08 16:20:19 -02:00
Daniel van Vugt
d21478b0f0 cogl-auto-texture: Avoid a double-free crash
If texture allocation fails (e.g. on an old GPU with size limit 2048)
then `cogl_texture_new_with_size` was trying to use the same CoglError
twice. The second time was after it had already been freed.

Bug reported and fix provided by Gert van de Kraats.

https://launchpad.net/bugs/1790525
2018-11-08 10:18:25 +00:00
Jonas Ådahl
b86d87453d build: Fix include and lib paths in autotools .pc files
Some hadn't been updated after lib/mutter/ changed to lib/mutter-N/.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/382
2018-11-07 14:29:30 +01:00
Jonas Ådahl
cf7c39e2c1 build: Add soversion to shared libraries
It's easier to add it now, then adding it later would so be needed.
2018-11-07 13:00:47 +00:00
Georges Basile Stavracas Neto
4ce4a2b134 cogl: Expose more headers for introspection
This will allow CoglFramebuffer and its implementations to be exposed
to GJS and other language bindings. This is a necessary part of the
bigger work to make framebuffer management explicit.
2018-11-07 11:27:51 +00:00
Georges Basile Stavracas Neto
93e20cf21c cogl/framebuffer: Mark CoglOffscreen as a CoglFramebuffer implementation
CoglOffscreen is effectively a CoglFramebuffer, but it isn't being marked as
such by the GType machinery. This makes it impossible for introspection to
correctly set this class up.

Fix that by adding a COGL_GTYPE_IMPLEMENT_INTERFACE() code into the declaration
of CoglOffscreen. This does not have any functional changes though.
2018-11-07 11:27:51 +00:00
Georges Basile Stavracas Neto
fe78467815
build: Make libmutter-cogl-path a dependency for test-journal
Otherwise, it might trigger the actual race condition that Continuous
is running into, and access the generated enum headers before they're
created.
2018-11-06 19:15:24 -02:00
Georges Basile Stavracas Neto
d1c4c46281
build: Prefer dependencies instead of link_with
Meson uses the 'dependencies' field to determine and
parallelize build steps, but that isn't entirely true
with 'link_with'; this might cause a race condition
when generating header files while trying to build
them.

Fix that by only using 'dependencies' instead of 'link_with'.
2018-11-06 17:50:24 -02:00
Jonas Ådahl
ef85d1a643 Add meson build support
This commit adds meson build support to mutter. It takes a step away
from the three separate code bases with three different autotools setups
into a single meson build system. There are still places that can be
unified better, for example by removing various "config.h" style files
from cogl and clutter, centralizing debug C flags and other configurable
macros, and similar artifacts that are there only because they were once
separate code bases.

There are some differences between the autotools setup and the new
meson. Here are a few:

The meson setup doesn't generate wrapper scripts for various cogl and
clutter test cases. What these tests did was more or less generate a
tiny script that called an executable with a test name as the argument.
To run particular tests, just run the test executable with the name of
the test as the argument.

The meson setup doesn't install test files anymore. The autotools test
suite was designed towards working with installed tests, but it didn't
really still, and now with meson, it doesn't install anything at all,
but instead makes sure that everything runs with the uninstalled input
files, binaries and libraries when running the test suite. Installable
tests may come later.

Tests from cogl, clutter and mutter are run on 'meson test'. In
autotools, only cogl and clutter tests were run on 'make check'.
2018-11-06 18:51:44 +01:00
Jonas Ådahl
bf42b54faa Make it possible to build without EGL support
This will avoid building anything related to EGL. For meson, this will
mean that both the native backend an the Wayland support must also be
disabled.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
d48d56f831 autotools: Make install directories paths more consistent
Install include files in
$prefix/include/mutter-$apiversion/[clutter,cogl,...,meta]/, and
datafiles in /usr/share/mutter-$apiversion/.... We still would conflict
e.g. given that our gettext name is "mutter", and how keybindings are
installed, but it's a step in the right direction.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
8894ec462a cogl: Pass unit-tests file to run-tests.sh
There are different unit-tests file generated containing lists of tests
the test-runner.sh should run. Running run-tests.sh read the unit-tests
in the current directory, which is inconvenient to do when using meson.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
331e830cf6 cogl: Fix HAVE_COGL_GL guard
Macro was only defined when defined to 1.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
d68fcbc887 cogl: Make cogl-config.h include check explicit
Don't rely on some combination of macros, but an explicit definition to
check whether cogl-config.h was included.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
9dbdf6b724 cogl: Require relative full paths when including
I.e. including a OpenGL driver file, the path "driver/gl/..." must be
specified when including.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
530861b24d cogl: Remove left-over WebGL paths 2018-11-06 17:17:36 +01:00
Jonas Ådahl
0163a0b0cd cogl: Unconditionally include cogl-config.h 2018-11-06 17:17:36 +01:00
Jonas Ådahl
12171e413b cogl: Unconditionally depend on cairo 2018-11-06 17:17:36 +01:00
Jonas Ådahl
99fb79f4cb cogl: Unconditionally include "strings.h" 2018-11-06 17:17:36 +01:00
Jonas Ådahl
24d8d40deb cogl/tests: Mark failing test as known failure
This allows us to enable running the tests again. Not fixing the
failure is at least better than not running the tests at all.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
97004e6114 cogl: Remove ARBfp pipeline support
As with fixed pipelines, we require the use of the GLSL pipeline in
mutter, and no point in supporting ARBfp anyway.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
8f58ad02fb cogl: Remove fixed pipeline support
We require being able to use shaders so stop supporting a pipeline that
wouldn't work to begin with.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
98af9bb251 cogl: Remove notion of a "cogl" version
Mutters copy of cogl isn't a separate library with its own version, so
remove the old version macros.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
7b2eaa76a4 cogl: Remove support for GLESv1
We have no need for it in mutters cogl variant.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
00a5523667 cogl: Remove some left over KMS backend stuff 2018-11-06 17:17:36 +01:00
Jonas Ådahl
f30cef3046 cogl: Always build CoglPango support 2018-11-06 17:17:36 +01:00
Jonas Ådahl
fba7d8c79c cogl: Always build CoglPath support 2018-11-06 17:17:36 +01:00
Jonas Ådahl
46942c24a3 cogl: Make various functions non-optional
Remove fallback implementations of some functions available in
gcc/clang and Linux/BSDs.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
9846a4d812 cogl: Make _Static_assert non-optional 2018-11-06 17:17:36 +01:00
Jonas Ådahl
da741ead25 cogl-gles2/Makefile.am: Add cogl/ includedir
Otherwise cogl-egl-defines.h isn't found when building out-of-tree.
2018-11-06 17:17:36 +01:00
Daniel van Vugt
c6691afa38 cogl: Fix cogl_frame_info_get_frame_counter docs
The docs previously suggested that `cogl_frame_info_get_frame_counter`
returned a timestamp of an unknown clock ID. That's not correct. The
cogl source code shows that it does and must use the same clock as
`cogl_get_clock_time`.

Related to https://gitlab.gnome.org/GNOME/mutter/issues/131
2018-07-20 15:48:56 +08:00
Jonas Ådahl
ae26cd0774 native: Restore previous EGL state after blitting onto secondary GPU
Before we just set it to "none", but this was not enough since various
calls will depend on not just the context being active, but the main
rendering surface.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/21
2018-04-25 17:22:24 +02:00
Marco Trevisan (Treviño)
3104d697c0 cogl: Do not unref a NULL object
Add return-if-fail statement to avoid deferencing NULL object
2018-04-25 09:03:58 +00:00
Carlos Garnacho
2f260edf19 cogl: Read pixels as per the stored format
By the looks of it, commit 95e9fa10ef was taping over an Intel DRI bug
that would make it return post-swizzling pixel data on glReadPixels().
There's been reports over time of that commit resulting in wrong colors
on other drivers, and lately Mesa >17.3 started showing the same symptoms
on Intel.

But texture swizzling works by changing parameters before fragment shaders
and reading pixels from an already drawn FBO/texture doesn't involve those.
This should thus use pixel_format_to_gl_with_target(), which will result in
correctly requesting the same pixel format than the underlying texture,
while still considering it BGRA for the upper layers in the swizzling case.

https://gitlab.gnome.org/GNOME/mutter/issues/72

Closes: #72
2018-03-21 18:45:20 +00:00
handsome-feng
b8a81128e0 Fix some spelling errors
https://gitlab.gnome.org/GNOME/mutter/merge_requests/45
2018-03-21 13:22:35 +08:00
Jonas Ådahl
712ec30cd9 renderer/native: Force EGL config pixel format
We just arbitrarily chose the first EGL config matching the passed
attributes, but we then assumed we always got GBM_FORMAT_XRGB8888. That
was not a correct assumption. Instead, make sure we always pick the
format we expect.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/2
2018-03-05 15:42:27 +00:00
Florian Müllner
748223b896 cogl-texture: Remove unused function
Commit d8f2f583e6 removed the only caller.
2018-02-09 14:01:12 +01:00
Jonas Ådahl
f2d0e5021a cogl/x11/renderer: Silence introspection warning
We don't introspect CoglRenderer, so we shouldn't introspect API using it
either.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2018-02-07 11:03:42 +08:00
George Kiagiadakis
d8f2f583e6 cogl-texture: refuse downloading textures in cogl_texture_get_data() on GLES
On drivers that do not support glGetTexImage2D (i.e. on GLES),
cogl_texture_get_data() has a "feature" that allows it to download
texture data by rendering the texture on an intermediate framebuffer
object and then reading back the data from there. However, this
feature requires the user to have previously set an "active"
framebuffer object in the context, which makes this very tricky
because it is not clear to the developer that he needs to do that
in order for some code to work on GLES (of course it works on
desktop GL, so nobody notices...) and additionally the code actually
crashes if an active fbo is not set!

This patch basically removes this feature in order to prevent
the crash and is in line with how this code has evolved in cogl-2.0:
https://git.gnome.org/browse/cogl/commit/?id=6d6a277b8e9a63a8268046e5258877ba94a1da5b

https://bugzilla.gnome.org/show_bug.cgi?id=789961
2018-02-05 11:22:36 +00:00
Jonas Ådahl
18eb66de06 cogl: Add way to pass user data when setting custom renderer winsys
When creating a renderer with a custom winsys (which is always how
mutter uses cogl) make it possible to pass a user data with the winsys.
Still unused.

https://bugzilla.gnome.org/show_bug.cgi?id=785381
2017-10-05 18:10:30 -04:00
Mario Sanchez Prada
483ed98777 cogl: Only do the swizzling hack for GL contexts
The GL_BGRA definition is not available for GLES2 contexts, which use
the EXT_texture_format_BGRA8888 instead, causing a build failure when
trying to use it in those contexts.

Fortunately, this hack is only relevant for GL, so let's guard it to
prevent the failure in GLES2, where that extension is used instead.

https://bugzilla.gnome.org/show_bug.cgi?id=786568
2017-08-21 16:29:39 +02:00
Carlos Garnacho
bc041e02b3 cogl: Mark vertex buffers as dynamic
Those are cached and reused across runs, which doesn't qualify to mesa
as "static" indeed. Properly marking those as dynamic is more true, and
brings in slight performance benefits just by avoiding the resulting
(and later silenced) mesa warning.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-05-22 17:27:11 +02:00
Carlos Garnacho
374bb630f0 cogl: Use pixel_format_to_gl_with_target in find_best_gl_get_data_format
Fixes cogl_texture_get_data() resorting to the wrong conversions when
extracting the texture data. This notably resulted in RGB/RGBA buffers
copied as-is into BGRA buffers, for instance for the fullscreen animation,
or single-window screenshots of such buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=779234
2017-05-18 23:32:39 +02:00
Mario Sanchez Prada
229ac9c9dc Consider the right CONTEXT_LOST token on OpenGL ES contexts
The KHR_robustness extension defined the following token as
returned by GetError (see spec at [1]):

  CONTEXT_LOST  0x0507

As noted in the spec, this token must have a "_KHR" suffix in
an OpenGL ES context, which is not being considered here, thus
making this type of builds fail.

[1] https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_robustness.txt

https://bugzilla.gnome.org/show_bug.cgi?id=781398
2017-04-17 12:58:52 +01:00
Mario Sanchez Prada
e435cf301f Define new tokens from the ARB_robustness extension if needed
The ARB_robustness extension defined the following tokens as
returned by GetGraphicsResetStatusARB (see spec at [1]):

  GUILTY_CONTEXT_RESET_ARB    0x8253
  INNOCENT_CONTEXT_RESET_ARB  0x8254
  UNKNOWN_CONTEXT_RESET_ARB   0x8255

These tokens might not be defined in some GL implementations,
such as Mesa 13's implementation of GLES 2.0, so we need to
define them ourselves not to break those builds.

[1] https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_robustness.txt

https://bugzilla.gnome.org/show_bug.cgi?id=781398
2017-04-17 12:58:52 +01:00
Jonas Ådahl
ac813d5285 x11: Use EGL instead of GLX when drawing using GLES
When running as a X11 CM we shouldn't use the GLX winsys when the
driver doesn't support it, i.e. OpenGL ES drivers.

https://bugzilla.gnome.org/show_bug.cgi?id=771636
2017-03-25 00:17:18 +08:00
Carlos Garnacho
35388fb33c cogl: Use pixel_format_to_gl_with_target on bitmap uploading paths
We already do have a texture with an internal format in these paths,
so we should check the required format according to it.

This fixes CoglAtlasTexture (and CoglPangoRenderer indirectly), as
it forces a RGBA format on its texture, but pixel_format_to_gl()
anyway assumed swizzling is performed on the texture, while it is
not the case.

https://bugzilla.gnome.org/show_bug.cgi?id=779234
2017-03-07 13:40:06 +01:00
Carlos Garnacho
aa5738c777 cogl: Add pixel_format_to_gl_with_target driver vfunc
This is used by the GL driver in order to determine whether swizzling
actually applies given the bitmap and target texture internal format.
If both agree that they store BGRA, then swizzling may apply.

https://bugzilla.gnome.org/show_bug.cgi?id=779234
2017-03-07 13:40:06 +01:00
Carlos Garnacho
95e9fa10ef cogl: Read pixels in the correct 32bit format as per the given bitmap
Fixes the gnome-shell screenshot tool from getting colors with the
wrong byte order.

https://bugzilla.gnome.org/show_bug.cgi?id=779234
2017-03-01 22:05:19 +01:00
Carlos Garnacho
1705a26fc7 cogl: Prefer swizzling to convert BGRA buffers
If the GL implementation/hw supports the GL_*_texture_swizzle extension,
pretend that BGRA textures shall contain RGBA data, and let the flipping
happen when the texture will be used in the rendering pipeline.

This avoids rather expensive format conversions when forcing BGRA buffers
into RGBA textures, which happens rather often with WL_SHM_FORMAT_ARGB8888
buffers (like gtk+ uses) in little-endian machines.

In intel/mesa/wayland, the performance improvement is rather noticeable,
CPU% as seen by top decreases from 45-50% to 25-30% when running
gtk+/tests/scrolling-performance with a cairo renderer.

https://bugzilla.gnome.org/show_bug.cgi?id=779234
2017-02-28 18:48:21 +01:00
Owen W. Taylor
d200868459 Add cogl_xlib_renderer_set_threaded_swap_wait_enabled()
Because the threaded-swap-wait functionality requires XInitThreads(),
and because it isn't clear that it is a win for all applications,
add a API function to conditionally enable it.

Fix the cogl-crate example not to just have a hard-coded dependency
on libX11.

https://bugzilla.gnome.org/show_bug.cgi?id=779039
2017-02-21 16:25:01 -05:00
Owen W. Taylor
690b232258 For NVIDIA proprietary drivers, implement sync events with a thread
It's a good guess that the buffer swap will occur at the next vblank,
so use glXWaitVideoSync in a separate thread to deliver a sync event
rather than just letting the client block when frame drawing, which
can signficantly change app logic as compared to the INTEL_swap_event
case.

https://bugzilla.gnome.org/show_bug.cgi?id=779039
2017-02-21 16:25:01 -05:00
Owen W. Taylor
e078838774 Fix the get_clock_time() without GLX_OML_sync_control
When we don't have GLX_OML_sync_control, we still can set the
frame presentation time, but we always use the system monotonic time,
so return that from get_clock_time().

https://bugzilla.gnome.org/show_bug.cgi?id=779039
2017-02-21 16:25:01 -05:00
Owen W. Taylor
1b03dd6704 Usability of SGI_video_sync is per-display not per-renderer
As previously commented in the code, SGI_video_sync is per-display, rather
than per-renderer. The is_direct flag for the renderer was tested before
it was initialized (per-display) and that resulted in SGI_video_sync
never being used.

https://bugzilla.gnome.org/show_bug.cgi?id=779039
2017-02-21 16:25:01 -05:00
Owen W. Taylor
1171c4f16d CoglWinsysGLX: factor out some duplicated code
Add a helper function for repeated calls to clock_gettime(CLOCK_MONOTONIC)

https://bugzilla.gnome.org/show_bug.cgi?id=779039
2017-02-21 16:25:01 -05:00
Owen W. Taylor
a9f139cab6 CoglGPUInfo - fix check for NVIDIA
NVIDIA drivers have a vendor of "NVIDIA Corporation" not "NVIDIA".
Check for both in case older drivers did use "NVIDIA"

https://bugzilla.gnome.org/show_bug.cgi?id=779039
2017-02-21 16:25:01 -05:00
Florian Müllner
827db6f7c7 build: Clean up .pc files 2017-02-15 23:54:07 +01:00
Lionel Landwerlin
1372690c7f cogl: fix get-value-func annotation
Found while trying to enable Cogl 2.0 APIs access from JS.

https://bugzilla.gnome.org/show_bug.cgi?id=778684
2017-02-15 14:53:43 +00:00
Jonas Ådahl
4ebc55f2b3 Make libmutter and friends parallel installable
In order to minimize the amount of breakage, while at the same time
making it easier to make backward incompatible changes needed to
continue turning libmutter into a capable Wayland compositor, make the
libmutter and friends (libmutter-clutter, libmutter-cogl*) parallel
installable by adding a version number to the name. This changes
various filenames, for example what previously was libmutter.so is now
libmutter-0.so (assuming the version for now is 0), and
libmutter-clutter-1.0.so is now libmutter-clutter-0.so. The pkg-config
filenames and GObject introspection has been renamed to reflect this as
well.

This enables a downstream compositor rely on a specific version of the
libmutter API, while gracefully handling API/ABI changes by having to
update to the new version at their own pace.

https://bugzilla.gnome.org/show_bug.cgi?id=777317
2017-02-14 11:16:45 +08:00
Adam Jackson
1f0659d516 Use eglGetPlatformDisplay
Different libEGL will do different things for eglGetDisplay since it has
to guess what kind of display it's been handed. Better to just use the
API that makes it explicit.

Signed-off-by: Adam Jackson <ajax@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=772422
2017-02-07 14:16:33 +01:00
Jonas Ådahl
5a43cc5cf9 cogl: Just define the needed GLES2 extension ourself
We need a GLES2 extension macro in cogl-texture-2d-gl.c, but we can't
include GLES2/gl2ext.h because it will conflict with things in
GL/glext.h. We can't rely on cogl including anything for us since it'd
only include GLES2/gl2ext.h if OpenGL support was explicitly disabled.

https://bugzilla.gnome.org/show_bug.cgi?id=774891
2017-01-03 17:50:03 +08:00
Florian Müllner
71077d582b cogl: Do not include both GLES2 and GL headers
EGLDevice requires a define from GLES2, even when GL is used instead.
As type definitions may conflict between the two, we shouldn't include
both at the same time. Instead, provide the missing define explicitly
when not using GLES2.

https://bugzilla.gnome.org/show_bug.cgi?id=774891
2016-12-02 18:15:39 +01:00
Florian Müllner
0aa6d9782c build: Fix cogl include paths
cogl-egl-defines.h is now referenced from a public header, so we need
to include its location whenever the header is used (directly or via
cogl.h).
2016-11-23 18:03:59 +01:00
Jonas Ådahl
1f0ce80fb4 cogl: Add support for creating custom EGL based textures
Add API to enable the caller to have a custom method for allocating an
external texture. This will enable the possibility for mutter to
generate a texture from for example an EGLStream without having to add
support for that in Cogl.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
23455985cd wayland: Make MetaWaylandBuffer handle texture generation itself
Don't rely on the Cogl layer having Wayland specific paths by
determining the buffer type and creating the EGLImage ourself, while
using the newly exposed CoglTexture from EGLImage API. This changes the
API used by MetaWaylandSurface to make the MetaWaylandBuffer API be
aware when the buffer is being attached. For SHM and EGL buffers, only
the first time it is attached will result in a new texture being
allocated, but later for EGLStream's, more logic on every attach is
needed.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
ecc1f56009 cogl: Expose API for creating texture from EGLImage
Later to be used by mutter to create EGLImage's from Wayland buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
8f716772c2 cogl: Make platforms set the EGL_SURFACE_TYPE
Cogl has no way to know how to properly set the surface type, so lets
outsource that to the platform layer.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
ce7573e2b7 cogl/egl: Fix non-Wayland build
Use #ifdef instead of #if, otherwise it won't compile when Wayland is
not available.

https://bugzilla.gnome.org/show_bug.cgi?id=770647
2016-09-02 17:04:11 +08:00
Sjoerd Simons
7d9af9585d Use _NO_CONTEXT when creating images for EGL_WAYLAND_BUFFER_WL
The WL_bind_wayland_display spec says that EGL images should be created
using EGL_WAYLAND_BUFFER_WL as the target and a NULL context. Mesa
seems to be lenient and accept any context, however some other stacks
aren't so forgiving and fail if anything apart from EGL_NO_CONTEXT is
used.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=769731
2016-08-29 16:31:36 +02:00
Jonas Ådahl
c55943d753 cogl: Fix a few GISCAN warnings
We tried to resolve non-introspected types; lets skip those. We didn't
have a vfunc scope on a for-each loop; declared it synchronous.

https://bugzilla.gnome.org/show_bug.cgi?id=769800
2016-08-18 11:32:33 +08:00
Thomas Hindoe Paaboel Andersen
720cbc5e5f cogl: fix indentation
https://bugzilla.gnome.org/show_bug.cgi?id=769054
2016-07-22 10:44:19 +08:00
Florian Müllner
991f2d696a cogl-gles2: Don't leak gles2 types into mutter
On i686, the GLsizeiptr typedef in cogl-gles2.h conflicts with the
system GL headers, so make sure we don't include both.

https://bugzilla.gnome.org/show_bug.cgi?id=769014
2016-07-21 00:02:53 +02:00
Florian Müllner
a310ba7649 build: Dist cogl-mutter/cogl-clutter headers 2016-07-20 14:30:57 +02:00
Jonas Ådahl
cd0f8e5cd1 cogl: Let the g-ir-scanner see the type structs typedefs
By only showing the g-ir-scanner void typedefs it will make it print
warnings. Lets please it by showing the actual typedef.

https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
75c3cf0589 cogl: Remove support for not building with glib/gtype support
https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
d62d780a95 Remove cogl-1.0 vs cogl-2.0 vs cogl experimental API split
Mutter (and libmutter users) are the only users of this version of
cogl, and will more or less only use the cogl-1.0, cogl-2.0 and cogl
experimental API variants, and having the possibility of having
different API versions of the same API depending on what file includes
it is error prone and confusing. Lets just remove the possibility of
having different versions of the same API.

https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
eed71654ba Don't pretend we don't have CoglShader
We bypass our build configuration to fetch API from a version which
isn't the one we actually use. Stop bypassing and just admit that the
1.0 API is still there, but still deprecated.

https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
835ded3f02 cogl: Remove deprecated CoglTexture functions
None were used; no reason to keep them.

https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
3450b51da1 cogl: Remove CoglClipState
We were not using it anywhere; lets get rid of it.

https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
1ca9d8ac02 cogl: Remove CoglFixed
We were no longer using anything from it; lets remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
ea64e0abfa cogl: Fix a bunch of GISCAN warnings
https://bugzilla.gnome.org/show_bug.cgi?id=768977
2016-07-20 14:23:48 +08:00
Jonas Ådahl
28a898a22f Use signals instead of onscreen framebuffer frame callbacks
CoglFrameInfo is a frame info container associated with a single
onscreen framebuffer. The clutter stage will eventually support drawing
a stage frame with multiple onscreen framebuffers, thus needs its own
frame info container.

This patch introduces a new stage signal 'presented' and a accompaning
ClutterFrameInfo and adapts the stage windows and past onscreen frame
callbacks users to use the signal and new info container.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
c498bce9e4 cogl: Add API to get the texture from an offscreen
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
e420f386d2 Move cogl KMS winsys into the native backend
Move the KMS interaction from cogl into mutter, where most of the other
KMS interaction already takes place. This also removes dead code which
were only excercised when non-mutter callers used the cogl KMS backend.

The cogl KMS API was updated to pass via MetaRendererNative instead of
via the different cogl objects.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
e05f48fc53 Make it possible to include private cogl API from mutter
If we want to put a cogl winsys backend in mutter, that backend need to
have access to the internal workings of cogl.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
d63e9452d9 cogl: Remove some now dead code
We require glib and don't support building on win32 any more.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
f1b7b41b8d Update .gitignore
The cogl/clutter merge made the .gitignore files in the respective
directories incorrect, due to the using absolute paths.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
bdc68efe45 cogl: Fix signage miss match warnings
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
bf71cb2e3c Don't use config.h in clutter and cogl
In cogl use cogl-config.h and in clutter use clutter-build-config.h. We
can't use clutter-config.h in clutter because its already used and
installed.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
4d13f6e2d0 cogl: Expose winsys vtable getters
This is so we can use as base in mutter's future winsys backends.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
d6cde4b043 cogl: Add API for setting custom winsys
https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Jonas Ådahl
e2f5579391 cogl: Don't undef __INSIDE_COGL_H__ in file not defining it
If you include a file that might define __INSIDE_COGL_H__, don't
undefine it if it wasn't defined in that file. This makes it possible
to include for example cogl-gles2.h from some other file which defines
__INSIDE_COGL_H__.

https://bugzilla.gnome.org/show_bug.cgi?id=768976
2016-07-20 14:23:48 +08:00
Rui Matos
d4d2bf0f6c cogl: Ignore GL_CONTEXT_LOST when checking for GL errors
When using a context with robustness, glGetError() may return
GL_CONTEXT_LOST at any time and this error doesn't get cleared until
the application calls glGetGraphicsResetStatus() . This means that our
error checking can't call glGetError() in a loop without checking for
that return value and returning in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2016-06-27 20:23:49 +02:00
Rui Matos
0f2be43af4 cogl-context: Add a cogl_get_graphics_reset_status API
If the driver supports the GL_ARB_robustness extension we can expose
the graphics reset status this way.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2016-06-27 20:23:49 +02:00
Rui Matos
87f9927375 cogl-winsys-glx: Add support for NV_robustness_video_memory_purge
This adds API to allow callers to specify that they're interested in
video memory purge errors.

https://bugzilla.gnome.org/show_bug.cgi?id=739178
2016-06-27 20:23:49 +02:00
Florian Müllner
28c9b6e1d7 build: Namespace installed tests of private libraries
Currently our private cogl/clutter forks still install tests as
cogl/clutter, which conflicts with the original libraries.
2016-04-29 14:49:03 +02:00
Rico Tzschichholz
29752b6b63 cogl/clutter: Drop soname versions of private libraries 2016-04-28 15:34:51 +02:00
Florian Müllner
6e5888853e build: Export correct pkg-config names in .girs 2016-04-28 15:22:50 +02:00
Rui Matos
f7ee6caa15 cogl: Fix distcheck 2016-04-27 20:37:47 +02:00
Rui Matos
1fa540bcb7 Fix the merged build
https://bugzilla.gnome.org/show_bug.cgi?id=760439
2016-04-27 20:37:47 +02:00
Rui Matos
2d2835f02a move everything into a cogl/ directory 2016-04-22 16:44:31 +02:00
Rui Matos
e6b14a36c5 cogl: make library private to mutter 2016-04-22 16:39:46 +02:00
Rui Matos
d6dd55171a build: get rid of specialized makefile snippets 2016-04-22 16:39:46 +02:00
Rui Matos
26c94951fc disable standalone builds and drop private glib copy 2016-04-22 16:39:46 +02:00
Rui Matos
9504eac68c po: drop translations 2016-04-22 16:39:45 +02:00
Rui Matos
8366fd5438 drop remaining traces of support for directly linking libGL 2016-04-22 16:39:45 +02:00
Rui Matos
0da00392e6 quartz: drop support 2016-04-22 16:39:45 +02:00
Ray Strode
865da1457a renderer: drop wayland client support 2016-04-22 16:39:35 +02:00
Ray Strode
b5648dc0cb renderer: drop android support 2016-04-18 19:12:23 +02:00
Ray Strode
ce8aa45fa4 renderer: drop MIR support 2016-04-18 19:12:23 +02:00
Ray Strode
639ef8e195 win32: drop support 2016-04-18 19:12:23 +02:00
Ray Strode
ed9f3fd50a renderer: drop support for SDL 2016-04-18 19:09:42 +02:00
Ray Strode
7e8e1dfc8f renderer: drop GDL support 2016-04-10 20:28:55 +02:00
Ray Strode
9246c9a505 renderer: drop PowerVR winsys 2016-04-10 20:25:06 +02:00
Ray Strode
1c1ad69f26 winsys-egl-kms: dont create 0x0 surface
commit 188752158 changed cogl to stop needlessly creating its own
monitor output configuration when mutter would just soon overwrite
it anyway.

Unfortunately, that commit is causing a crash in some cases because
cogl will now create and later draw to a 0x0 egl surface until mutter
sets the monitor layout.

This commit changes cogl to avoid creating and using a surface, before
it knows how big of a surface to create.

https://bugzilla.gnome.org/show_bug.cgi?id=758073
2016-02-22 13:39:04 -05:00
Ray Strode
1887521587 winsys-egl-kms: bypass initial output setup if kms fd passed in
if mutter is handling the output setup, then we shouldn't do it,
too.

https://bugzilla.gnome.org/show_bug.cgi?id=758073
2015-11-17 12:56:13 -05:00
Ray Strode
a583492ea2 kms-winsys: don't wait for a flip when page flipping fails
If we get EACCES from drmPageFlip we're not going to get
a flip event and shouldn't wait for one.

This commit changes the EACCES path to silently ignore the
failed flip request and just clean up the fb.

https://bugzilla.gnome.org/show_bug.cgi?id=756926
2015-10-21 16:00:45 -04:00
Emmanuele Bassi
b21de497d1 Fix compiler warning
Return a boolean value, not NULL.
2015-09-23 13:57:11 +01:00
Daniel Stone
5253264f2f GLES: Support glMapBufferRange from ES3
ES3 provides glMapBufferRange as core, with the added bonus that it also
supports read mappings. Use this where possible.

Signed-off-by: Daniel Stone <daniels@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=728355
2015-09-23 13:57:11 +01:00
Daniel Stone
d6f415d491 Journal: Skip journal dumping when unsupported
GLES2 does not support passing READ to glMapBuffer; attempting to call
cogl_buffer_map for read on ES2 will bring it down with an assert. Make
sure COGL_DEBUG=journal doesn't do this when it's not possible.

Signed-off-by: Daniel Stone <daniels@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=728355
2015-09-23 13:57:11 +01:00
Murray Cumming
85e0b08459 CoglBufferError: Remove trailing comma from enum.
This is helpful for C++ with g++'s -pedantic warnings complain
about it.
2015-09-17 17:11:57 +02:00
Lionel Landwerlin
00ea695ce2 winsys: glx: fix crash when inspecting onscreens
An unallocated onscreen might have a NULL winsys field.

https://bugzilla.gnome.org/show_bug.cgi?id=754888
2015-09-11 17:34:39 +02:00
Lionel Landwerlin
4cb750928e winsys: wayland: destroy eglsurface when destroying associated native window
On Wayland deinit() of an onscreen buffer is going to destroy the
associated native window of an EGLSurface. So we should destroy the
EGLSurface as well otherwise we might end up confusing the GL driver.

We also currently guard against setting a EGL_NO_SURFACE as current
EGLSurface, but this shouldn't be a problem if we have a surfaceless
context. So we allow surface destruction under that condition.

https://bugzilla.gnome.org/show_bug.cgi?id=754667
2015-09-07 17:27:50 +01:00
Ray Strode
6bd49c3dc8 kms-winsys: don't disable page flipping on EACCES
If the user switches VTs in the middle of a page flip, the
page flip operation may fail with EACCES. page flipping will
work next time the VT becomes active, so we shouldn't disable
page flipping in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=754540
2015-09-03 17:29:28 -04:00
Ray Strode
78c44ab132 kms-winsys: clean up error handling in _cogl_winsys_renderer_connect
If cogl fails to open the drm device, initialize gbm, or open the
egl display, then it closes the drm fd, uninitializes gbm, closes the
display and then calls _cogl_winsys_renderer_disconnect which does
most of those things again, on the, now deinitialized, members.

This commit removes the explicit failure handling in renderer_connect and
defers cleanup to disconnect.

https://bugzilla.gnome.org/show_bug.cgi?id=754540
2015-09-03 17:29:28 -04:00
Ray Strode
181176bdb1 kms-winsys: use correct surface format
gbm confusingly has two different format types, and cogl
is using the wrong one in some of its calls to gbm_surface_create

This commit fixes the calls that are wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=754540
2015-09-03 17:29:27 -04:00
Emmanuele Bassi
6f29e6f406 build: Enable subdir-objects
Depend on a more recent version of automake, and use the
forward-compatible subdir-objects option.
2015-09-03 09:03:39 +01:00
Emmanuele Bassi
ca5226513e Initialize out variables
Avoids a compiler warning with strict compilation flags.
2015-09-03 08:58:44 +01:00
Emmanuele Bassi
f20cc24292 gl: Do not use deprecated constants with the GL3 driver
glGetIntegerv (GL_DEPTH_BITS, ...) and friends are deprecated in GL3; we
have to use glGetFramebufferAttachmentParameteriv() instead, like we do
for offscreen framebuffers.

Based on a patch by: Adel Gadllah <adel.gadllah@gmail.com>
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=753295
2015-08-06 16:16:30 +01:00
Marek Chalupa
e7f54e6e60 egl-kms: append output after we know we found it
Otherwise we just append NULL output which is wrong and can
break things

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=752406
2015-07-28 15:32:51 +01:00
Adel Gadllah
4f8254f1ae winsys-glx: Add error traps in create_context
Both create_gl3_context and glXCreateNewContext can fail with an X error.

https://bugzilla.gnome.org/show_bug.cgi?id=742678
2015-07-26 16:04:14 +02:00
Emmanuele Bassi
812aba31e7 winsys: Drop xlib_get_visual_info from the vtable
We don't need the hack any more; CoglRenderer has the appropriate API
for the Xlib-based winsys backends.
2015-07-22 20:28:19 +01:00
Emmanuele Bassi
c9080b3e25 Use CoglRenderer for implementing deprecated, Clutter-only API
Instead of using the winsys vtable.
2015-07-22 20:27:33 +01:00
Emmanuele Bassi
8e9d3e92d8 onscreen: Use the CoglRenderer API for retrieving the X visual
Instead of peeking into the winsys vtable.
2015-07-22 20:21:33 +01:00
Emmanuele Bassi
e79d571453 Store the XVisualInfo in the X11-based winsys backends
Instead of freeing it after creating the relative GL contexts, store it
in the CoglXlibRenderer data.
2015-07-22 20:20:05 +01:00
Emmanuele Bassi
19ca856810 Store XVisualInfo into the Xlib renderer
We want to be able to retrieve the XVisualInfo used when creating the
GL context under GLX and EGL-X11, so that we can use the visual before
we have an onscreen frame buffer.
2015-07-22 20:17:52 +01:00
Emmanuele Bassi
0ad995746a Avoid compiler error for uninitialized value
Fixes Cogl compilation on build.gnome.org.
2015-06-10 18:42:39 +01:00
Emmanuele Bassi
3290240600 egl-x11: Fix compiler warnings
Stereo mode changed two fields in the winsys vtable, so we need to
update the signature of the implementation in the EGL-X11 winsys.
2015-06-10 15:20:17 +01:00
Emmanuele Bassi
838355afbd Fix compiler warnings
Initialize variables; GCC does not always catch all cases where the
variables are used after being initialized, especially when it comes to
out parameters.
2015-06-10 15:13:45 +01:00
Emmanuele Bassi
c5dc9542d5 Include deprecated header for cogl_read_pixels()
Avoids a compiler warning for a missing declaration.
2015-06-10 14:14:06 +01:00
Emmanuele Bassi
e7ef07652a Conditional call to g_type_init()
The explicit type system initialization has been deprecated since
GLib 2.36. It's done automatically, now.
2015-06-10 14:12:22 +01:00
Emmanuele Bassi
15b952e03e Fix compiler warnings
Simple enumeration checks.
2015-06-10 14:10:34 +01:00
Rui Matos
eb87ad165c framebuffer-deprecated: Unref the correct buffer
Looks like a thinko introduced by commit
79719347c8 .

Found by a coverity scan.

https://bugzilla.gnome.org/show_bug.cgi?id=749111
2015-05-08 15:39:27 +02:00
Jasper St. Pierre
f8cce5f6cb cogl-framebuffer-gl: Work again on GLESv2 2015-04-20 12:09:27 -07:00
Ray Strode
68d9ba3b65 kms-winsys: try to hobble along if driver doesn't support page flips
Some drivers ( like mgag200 ) don't yet support drmModePageFlip.

This commit forgoes waiting for vblank and flips right away
in those cases. That prevents the hardware from freezing up the screen,
but does mean there will be some visible tearing.

https://bugzilla.gnome.org/show_bug.cgi?id=746042
2015-03-23 10:11:46 -04:00
Robert Bragg
da0d9757e7 Add version 1.2 define + macros 2015-02-23 18:39:34 +00:00
Rui Matos
f82e9e2d22 kms-winsys: Remove a few unused variables 2015-02-23 18:36:56 +00:00
Rui Matos
200c4032ac kms-winsys: Defer setting new surfaces until swap buffers
We can't just destroy and replace the EGL and gbm surfaces while
they are still in use i.e. while there is a pending flip. In fact, in
that case, we were calling gbm_surface_destroy() on a surface that
still had the front buffer locked and then, on the flip handler,
gbm_surface_release_buffer() for a buffer that didn't belong to the
new surface.

Instead, we still allocate new surfaces when requested but they only
replace the old ones on the next swap buffers when we're sure that the
previous flip has been handled and buffers properly released.
2015-02-23 18:36:56 +00:00
Chris Wilson
5ccd2825c7 glx: Precisely wait for the next vblank
Currently the code queries the current msc then tries to approximate the
value of the next msc satisfing the modulus 2 for when to wait. This
introduces some instability as the msc may tick over during the
roundtrip leading to a 32ms wait instead of a 16ms wait. This happens
often enough to cause jerky animations, and affect gnome-shell-perf-tool.

A simpler solution is just use a single roundtrip by using WaitForMsc to
ask the driver to compute the next vblank itself.

Cc: Owen W. Taylor <otaylor@fishsoup.net>
Cc: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Robert Bragg <robert@sixbynine.org>
2015-02-04 19:31:40 +00:00
Rui Matos
b9640c091f wayland-winsys: Provide a wl_registry.global_remove callback
Otherwise libwayland-client will abort() when we get that event.

https://bugzilla.gnome.org/show_bug.cgi?id=743594
2015-01-30 16:05:41 +01:00
Rui Matos
c36e31401d kms-winsys: Mark the framebuffer to be bound when setting a new layout
We need to bind the context to the new EGL surface we just created.

https://bugzilla.gnome.org/show_bug.cgi?id=741881
2015-01-30 16:05:41 +01:00
Marco Trevisan (Treviño)
cd9676380f mir: use output names that are more conformat to the one used by Xmir
And by X itself...
2014-12-12 18:45:49 +01:00
Marco Trevisan (Treviño)
bc83282f4f mir: add renderer event listener support 2014-12-10 15:33:35 +01:00
Marco Trevisan (Treviño)
2872695fa7 mir: don't always allocate when getting the mir surface
Add proper documentation on header file
2014-12-09 22:01:32 +01:00
Marco Trevisan (Treviño)
7c71a06936 mir: fix mir surface recreation on resize, bind and update pointers
don't try to read from free'd memory allocation, copy stuff before
deinitializing the old onscreen.

Also, don't try to resize a foreign surface.
2014-12-09 20:22:53 +01:00
Marco Trevisan (Treviño)
a9a923c6f3 mir: correctly init/clear mutex and use prgname for surface 2014-12-09 20:16:36 +01:00
Marco Trevisan (Treviño)
1016fb64de mir: return proper surface / connection only when valid, without failing 2014-12-09 20:13:39 +01:00
Marco Trevisan (Treviño)
a144087085 mir: release surfaces on errors 2014-11-21 18:00:49 +01:00
Marco Trevisan (Treviño)
6aaeab0460 mir: add public method to resize a cogl onscreen
This will internally recreate a new surface with proper parameters
2014-11-21 18:00:10 +01:00
Marco Trevisan (Treviño)
bd6bfccc40 cogl.h: include mir renderer if the platform is supported 2014-11-20 19:11:05 +01:00
Marco Trevisan (Treviño)
77e28d4a77 mir: only allow to set foreign surfaces with hardware buffer
And return a CoglBool accordingly.
2014-11-20 07:18:26 +01:00
Marco Trevisan (Treviño)
8e6997db44 mir: return whether a foreign connection has been set or not 2014-11-20 07:17:19 +01:00
Marco Trevisan (Treviño)
e06a0b3d10 mir: release a connection on error 2014-11-18 22:16:38 +01:00
Marco Trevisan (Treviño)
b26466ad54 mir: improve error logging 2014-11-18 22:11:24 +01:00
Marco Trevisan (Treviño)
e5fd82e2a1 mir: use standard c types 2014-11-18 16:28:17 +01:00
Marco Trevisan (Treviño)
1cbc1c67a0 mir: add support for Mir Outputs 2014-11-17 18:50:30 +01:00
Marco Trevisan (Treviño)
a948c25116 mir: update the framebuffer size on resize events
We need to use a mutex as mir handles these on
different threads, also using an event idle prevents
to get initialization errors on cogl side.
2014-11-17 17:47:23 +01:00
Marco Trevisan (Treviño)
62f3f56d29 mir: set last state after initializing the surface 2014-11-17 17:45:59 +01:00
Marco Trevisan (Treviño)
1b9380ef3c mir: add support for foreign surfaces 2014-11-17 16:08:59 +01:00
Marco Trevisan (Treviño)
a3ae538c45 mir: add support for foreign display 2014-11-17 15:59:29 +01:00
Marco Trevisan (Treviño)
672eff0c6c cogl: add Mir EGL platform 2014-11-17 15:49:20 +01:00
Adel Gadllah
bf3954ebe3 cogl-kms-display: Fix doc comment 2014-10-03 11:50:37 +02:00
Owen W. Taylor
4d8771a8c2 CoglTexturePixmapX11: add support for stereo content
Add cogl_texture_pixmap_x11_new_left() and
cogl_texture_pixmap_x11_new_right() (which takes the left texture
as an argument) for texture pixmap rendering with stereo content.
The underlying GLXPixmap is created using a stereo visual and shared
between the left and right textures.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-17 19:27:13 -04:00
Owen W. Taylor
d16df5a5aa Add support for setting up stereo CoglOnscreens
If we want to show quad-buffer stereo with Cogl, we need to pick an
appropriate fbconfig for creating the CoglOnscreen objects. Add
cogl_onscreen_template_set_stereo_enabled() to indicate whether
stereo support is needed.

Add cogl_framebuffer_get_stereo_mode() to see if a framebuffer was
created with stereo support.

Add cogl_framebuffer_get_stereo_mode() to pick whether to draw to
the left, right, or both buffers.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-07-17 19:27:05 -04:00
Adel Gadllah
d9afc6dada kms-winsys: Add api that tells cogl to ignore a crtc
An application might for whatever reason want to control a specific output
directly and have cogl only swap the other outputs if any. So add an api that
allows setting a crtc to be ignored.

https://bugzilla.gnome.org/show_bug.cgi?id=730536
2014-06-30 20:26:05 +02:00
Adel Gadllah
fe183554ca kms_winsys: Add cogl_kms_renderer_get_gbm api
Applications might want to get the underlying gbm device so add a getter for it.

https://bugzilla.gnome.org/show_bug.cgi?id=730536
2014-06-30 20:25:52 +02:00
Neil Roberts
52a646abc5 Use the EGL_KHR_surfacless_context extension
The surfaceless context extension can be used to bind a context
without a surface. We can use this to avoid creating a dummy surface
when the CoglContext is first created. Otherwise we have to have the
dummy surface so that we can bind it before the first onscreen is
created.

The main awkward part of this patch is that theoretically according to
the GL and GLES spec if you first bind a context without a surface
then the default state for glDrawBuffers is GL_NONE instead of
GL_BACK. In practice Mesa doesn't seem to do this but we need to be
robust against a GL implementation that does. Therefore we track when
the CoglContext is first used with a CoglOnscreen and force the
glDrawBuffers state to be GL_BACK.

There is a further awkward part in that GLES2 doesn't actually have a
glDrawBuffers state but GLES3 does. GLES3 also defaults to GL_NONE in
this case so if GLES3 is available then we have to be sure to set the
state to GL_BACK. As far as I can tell that actually makes GLES3
incompatible with GLES2 because in theory if the application is not
aware of GLES3 then it should be able to assume the draw buffer is
always GL_BACK.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
(cherry picked from commit e5f28f1e75db9bdc4f2688f420a74f908f96cf76)

Conflicts:
	cogl/winsys/cogl-winsys-egl-kms.c
	cogl/winsys/cogl-winsys-egl-x11.c
2014-06-17 13:31:03 +01:00
Neil Roberts
eb7c37812a Add a COGL_EXT_IN_GLES3 option to specify extensions that are in GLES3
Some features that were previously available as an extension in GLES2
are now in core in GLES3 so we should be able to specify that with the
gles_availability mask of COGL_EXT_BEGIN so that GL implementations
advertising GLES3 don't have to additionally advertise the extension
for us to take advantage of it.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
(cherry picked from commit 4d892cd97558da61ba526f947ac0555ebab632d2)
2014-06-17 13:26:20 +01:00
Felix Riemann
5556241b67 atlas-texture: Keep reference on potential destination atlas
When a new CoglAtlasTexture tries to fit into an existing CoglAtlas
it should make sure the atlas stays valid while it expands.

https://bugzilla.gnome.org/show_bug.cgi?id=728064

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 2eec9758f67e9073371c2edd63379324849373c4)
2014-05-19 12:47:09 +01:00
Kristian Høgsberg
22378d572b cogl-winsys-egl-kms: Call swap notify handler even when pageflip ioctl fails
This can happen when we dpms off the output or when login1 takes away
drm master status from our drm fd.  In either case, we need to call
the swap notify handler so that the compositor dosn't get stuck waiting
for that notification.  The compositor should stop repainting shortly in
both cases, as it's either going into dpms off mode or vt switching away.

https://bugzilla.gnome.org/show_bug.cgi?id=728979

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-04-30 16:41:09 +01:00
Kristian Høgsberg
8fb9cea451 cogl-winsys-egl-kms: Never set EGL_PLATFORM
This environment variable predates the reliable platform detection in mesa
and typically just causes crashes when the specified platform doesn't
match what's passed in.  Aside from being unecessary and problematic
it also leaks into the GNOME session, preventing clients from
automatically detecting the wayland platform.

https://bugzilla.gnome.org/show_bug.cgi?id=728978

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-04-30 16:41:06 +01:00
Emanuele Aina
27dbf700d6 framebuffer: Fix linkage from C++ applications
Prevent Cogl function names from being mangled when a C++ compiler is
being used by adding some missing COGL_{BEGIN,END}_DECLS guards.

https://bugzilla.gnome.org/show_bug.cgi?id=728628

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-04-22 12:14:56 +01:00
Chun-wei Fan
93c90f1e05 cogl/cogl-gtype-private.h: Fix Build on non-GCC
Commit 1b2dd815 (Registers gtypes for all public objects and structs)
introduced GCCism's in its use of varargs, which broke the build of Cogl
on other non-GCC compilers, such as Visual Studio.

Define the COGL_GTYPE_DEFINE_BASE_CLASS and COGL_GTYPE_DEFINE_CLASS macros
using ISO-style varargs so that the build of Cogl can be fixed on non-GCC
compilers.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-04-22 12:17:46 +02:00
Chun-wei Fan
6feaaf2915 MSVC Builds: Don't Link to SDL Automatically
Remove #pragma directives that causes any applications that use Cogl to
link to the SDL libraries when Cogl was built with the SDL winsys.  This is
mainly due to the availability of both SDL-1.x and SDL-2.x support in the
SDL winsys, where different libraries are linked for SDL-1.x and SDL-2.x.

To avoid having to link to the SDL/SDL2 libraries when the application code
is not directly using SDL/SDL2, define SDL_MAIN_HANDLED in the CFLAGS so
that SDL's wrapper main() implementation will not be used when the
application is being built.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit c3035912833eabe1f6dadbea23c78e595aac79dc)
2014-04-16 12:39:20 +02:00
Chun-wei Fan
b2d74eed58 Update cogl.symbols and cogl-path.symbols
In Lionel's work for supporting introspection better for Cogl, a number of
public symbols were added for Cogl and Cogl-Path, so add these symbols to
cogl.symbols and cogl-path.symbols so that they can be exported, which will
fix the build of the Cogl conformance test and the introspection files
for the Windows-based builds.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-04-16 12:32:16 +02:00
Neil Roberts
2e6156ef5e Don't use the internal _G_DEFINE_TYPE_EXTENDED_CLASS_INIT macro
This macro is internal to gobject so using it risks breaking Cogl if
glib changes its API. Instead we just use its expansion. Note that
glib provides two expansions for this depending on the glib version
but this only uses the one for older versions.

Reviewed-by: Robert Bragg <robert.bragg@intel.com>
2014-03-21 17:16:34 +00:00
Lionel Landwerlin
263f6502c7 onscreen: make closure types visible to introspection
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-21 14:28:27 +00:00
Lionel Landwerlin
3aee3f63c4 cogl-gtype: add missing gtype macros in intermediate macros
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-21 14:28:27 +00:00
Lionel Landwerlin
1b2dd815b4 Registers gtypes for all public objects and structs
This adds much more comprehensive support for gobject-introspection
based bindings by registering all objects as fundamental types that
inherit from CoglObject, and all structs as boxed types.

Co-Author: Robert Bragg <robert@linux.intel.com>

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 18:27:12 +00:00
Chun-wei Fan
a4d2c78e2b Update cogl.symbols
Remove the symbols that are now in cogl-path (where cogl-path.symbols
already include), and add the symbols that were added to the Cogl API.

Also add internal symbols as required by cogl-path and cogl-pango.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 18:00:00 +00:00
Chun-wei Fan
001cffd783 cogl/cogl-renderer.c: Avoid Clash with Newer Windows SDKs
The DriverCallback is a function that is defined by the Windows SDK 8.0+
headers, which was initially used for device driver development.  The use
of DriverCallback would cause a clash, causing things to break when built
with newer Windows SDKs, so rename DriverCallback to CoglDriverCallback to
avoid this problem.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:56:52 +00:00
Robert Bragg
804082abd3 Expose EGL context/display and GLX context
To help facilitate integration with third party frameworks this exposes
the EGL context and display to applications as well as the GLX context.
(Note that the GLX display is already available via
cogl_xlib_renderer_get_display())

This adds a new top-level <cogl/cogl-glx.h> header that needs to be
included explicitly to access the glx specific api.

Anyone using these apis will be responsible for checking that Cogl
is indeed using EGL or GLX by calling cogl_renderer_get_winsys_id()

This will enable GStreamer, for example, to be able to create a GL
context that shares resources with Cogl's context.

https://bugzilla.gnome.org/show_bug.cgi?id=724992

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
081acdc146 move GLeglImageOES define into cogl-egl-private.h
This splits out the GLeglImageOES define in cogl-egl.h into a private
cogl-egl-private.h header and updates the guards in cogl-egl.h to be
consistent with other top-level headers where we need to be careful
about how __COGL_H_INSIDE__ is defined and undefined, esp when the
gobject introspection scanner is running.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
dca992a160 egl: remove NativeWindowType/NativeDisplayType defines
This ensures we use EGLNativeWindowType and EGLNativeDisplayType
everywhere instead. The previous names come from EGL 1.2 but it seems
reasonable to require more recent EGL versions. If someone wanted to add
compatibility for EGL 1.2 later it would be straightforward to define
the new names to the old.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
2beb7c40e0 sdl2: fix GL driver selection
SDL2 supports selecting between full OpenGL or OpenGL ES 1/2 but our
selection code was written before SDL 2.0 was officially released and
since then a new SDL_GL_CONTEXT_PROFILE_MASK attribute was added and
we have to explicitly set the SDL_GL_CONTEXT_MINOR_VERSION attribute.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
ad9db72f74 Expose COGL_FEATURE_ID_BUFFER_AGE feature id
This adds a new COGL_FEATURE_ID_BUFFER_AGE feature id that can be used
to determine if cogl_onscreen_get_buffer_age() will ever return an age
other than 0. This should be used instead of querying the winsys feature
via cogl_clutter_winsys_has_feature().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
beebbfc625 glx-feature-functions: update misleading comment
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:04 +00:00
Robert Bragg
3917690f5a egl: fix incorrect #ifdef guarding of features
We have an #ifdef EGL_WL_bind_wayland_display guard in
cogl-winsys-egl-feature-functions.h to avoid referencing wayland types
when the EGL header doesn't know about them, but somehow this guard also
ended up around the KHR_create_context and EXT_buffer age features too
even though they aren't wayland specific.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-03-20 17:34:01 +00:00
Neil Roberts
18b8035dcf Set COGL_WINSYS_FEATURE_BUFFER_AGE on EGL
This winsys feature flag is exposed via the deprecated
cogl_clutter_winsys_has_feature function and Clutter is curently
relying on it. Previously the EGL winsys was only setting the internal
COGL_EGL_WINSYS_FEATURE_BUFFER_AGE flag and there was no mapping to
the public flag. Therefore the feature would only be used on GLX. This
patch just adds the mapping.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 8418e98b2b1b25515a961ad1bb9f0c4770d6eb1d)
2014-03-14 13:51:39 +00:00
Jasper St. Pierre
e7011f1910 cogl-winsys-egl-kms: Make sure to close our connection to DRM at shutdown
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit dcdba60e95ae7be1b0253d28686d1562c35374ba)
2014-03-12 17:29:27 +00:00
Jasper St. Pierre
0d91085193 cogl-winsys-egl-kms: Add cogl_kms_renderer_set_kms_fd
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 7bc7ea4cb5e8134a3aeed9615477f4152b558509)

Conflicts:
	cogl/winsys/cogl-winsys-egl-kms.c
2014-03-12 17:29:21 +00:00
Jasper St. Pierre
76cdaabc15 cogl-winsys-egl-wayland: Report an error if we can't find the globals we need
Instead of spinning forever, do a roundtrip, which guarantees that the
global messages have been sent by the time we read the sync message.

If the proper globals aren't initialized yet, error out immediately. This
does mean that users can't use CoglOnscreen with foreign custom surface
types without xdg_shell, but when a use case comes for this, we'll
investigate then...

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit af9057d35f331e2c9509958fb40627917c477b80)
2014-03-12 14:41:01 +00:00
Robert Bragg
a0441778ad This re-licenses Cogl 1.18 under the MIT license
Since the Cogl 1.18 branch is actively maintained in parallel with the
master branch; this is a counter part to commit 1b83ef938fc16b which
re-licensed the master branch to use the MIT license.

This re-licensing is a follow up to the proposal that was sent to the
Cogl mailing list:
http://lists.freedesktop.org/archives/cogl/2013-December/001465.html

Note: there was a copyright assignment policy in place for Clutter (and
therefore Cogl which was part of Clutter at the time) until the 11th of
June 2010 and so we only checked the details after that point (commit
0bbf50f905)

For each file, authors were identified via this Git command:
$ git blame -p -C -C -C20 -M -M10  0bbf50f905..HEAD

We received blanket approvals for re-licensing all Red Hat and Collabora
contributions which reduced how many people needed to be contacted
individually:
- http://lists.freedesktop.org/archives/cogl/2013-December/001470.html
- http://lists.freedesktop.org/archives/cogl/2014-January/001536.html

Individual approval requests were sent to all the other identified authors
who all confirmed the re-license on the Cogl mailinglist:
http://lists.freedesktop.org/archives/cogl/2014-January

As well as updating the copyright header in all sources files, the
COPYING file has been updated to reflect the license change and also
document the other licenses used in Cogl such as the SGI Free Software
License B, version 2.0 and the 3-clause BSD license.

This patch was not simply cherry-picked from master; but the same
methodology was used to check the source files.
2014-02-22 02:02:53 +00:00
Andreas Oberritter
3669a89215 kms: include stddef.h before drm.h
Not doing so leads to the following error, if stddef.h is not included
indirectly through EGL headers:

| libdrm/drm.h:132:2: error: unknown type name 'size_t'
|   size_t name_len;   /**< Length of name buffer */

Signed-off-by: Andreas Oberritter <obi@saftware.de>

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 55c82476a93366a3e7d1a2537fccc3a7aab87c66)
2014-02-20 18:17:42 +00:00
Neil Roberts
dd7b1d53db Allocate immediately in _cogl_egl_texture_2d_new_from_image
The _cogl_egl_texture_2d_new_from_image function has a CoglError
argument which implies that it is unlike the other texture
constructors and returns errors immediately rather than having a
delayed-allocation mechanism. cogl_wayland_texture_2d_new_from_buffer
which calls it is also like this. We can't rely on delayed-allocation
semantics for this without changing the applications because the
texture needs to be allocated before the corresponding EGLImage is
destroyed. This patch just makes it immediately allocate.

A better patch might be to remove the error argument to make it
obvious that there are delayed-allocation semantics and then fix all
of the applications.

This was breaking Cogland and Mutter.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 0206c03d54823b2f6cbb2aa420d07a4db9bcd8a3)
2014-02-20 16:05:08 +00:00
Neil Roberts
7bf0fe9df8 Don't dereference an unitialised pointer in _cogl_container_of
The previous implementation was dereferencing the sample pointer in
order to get the offset to subtract from the member pointer. The
resulting value is then only used to get a pointer to the member in
order to calculate the offset so it doesn't actually read from the
memory location and shouldn't cause any problems. However this is
probably technically invalid and could have undefined behaviour. It
looks like clang takes advantage of this undefined behaviour and
doesn't actually offset the pointer. It also generates a warning when
it does this.

This patch splits the _cogl_container_of macro into two
implementations. Previously the macro was always used in the list
iterator macros like this:

SomeType *sample = _cogl_container_of(list_node, sample, link)

Instead of doing that there is now a new macro called
_cogl_list_set_iterator which explicitly assigns to the sample pointer
with an initial value before assigning to it again with the real
offset. This redundant initialisation gets optimised out by compiler.

The second macro is still called _cogl_container_of but instead of
taking a sample pointer it just directly takes the type name. That way
it can use the standard offsetof macro.

https://bugzilla.gnome.org/show_bug.cgi?id=723530

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 1efed1e0a2bce706eb4901979ed4e717bb13e4e2)
2014-02-20 13:38:43 +00:00
Owen W. Taylor
ee5dc42612 GLX winsys: fix feature handling for INTEL_swap_event
The declaration of INTEL_swap_event was treating winsys features as
if they were a bitfield, but they aren't. The end result was that
instead of reporting two features when INTEL_swap_event is present,
we report none.

https://bugzilla.gnome.org/show_bug.cgi?id=719741

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2014-02-05 13:44:38 +00:00
Neil Roberts
d3ecaf7a9a winsys-wgl: Don't include cogl.h
Since 248a76f5eac7e5ae4fb45208577f9a55360812a7 cogl.h can no longer be
included in internal source files so the WGL winsys was no longer
compiling.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 91af97a2a27ab5ad3e7eaabebd03503b685d4d42)
2014-01-20 16:41:13 +00:00
Neil Roberts
eb7ef457cb Add support for RG textures
This adds COGL_PIXEL_FORMAT_RG_88 and COGL_TEXTURE_COMPONENTS_RG in
order to support two-component textures. The RG components for a
texture is only supported if COGL_FEATURE_ID_TEXTURE_RG is advertised.
This is only available on GL 3, GL 2 with the GL_ARB_texture_rg
extension or GLES with the GL_EXT_texture_rg extension. The RG pixel
format is always supported for images because Cogl can easily do the
conversion if an application uses this format to upload to a texture
with a different format.

If an application tries to create an RG texture when the feature isn't
supported then it will raise an error when the texture is allocated.

https://bugzilla.gnome.org/show_bug.cgi?id=712830

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 568677ab3bcb62ababad1623be0d6b9b117d0a26)

Conflicts:
	cogl/cogl-bitmap-packing.h
	cogl/cogl-types.h
	cogl/driver/gl/gl/cogl-driver-gl.c
	tests/conform/test-read-texture-formats.c
	tests/conform/test-write-texture-formats.c
2014-01-20 14:40:45 +00:00
Neil Roberts
06c75ea2e7 Tweak documentation for the CoglTexture interface
The following changes are made to the documentation for CoglTexture:

• The description of the default value for the components property is
  changed to say that it is always RGBA for textures created by the
  ‘_with_size’ textures. Previously it said that the default is based
  on the pixel format used the first time data is set on the texture,
  but this is only true if the data is set using a constructor.

• Added documentation for the CoglTextureComponents enum.

• Changed it to say that it _specifies_ what components are required
  for sampling rather than determinging [sic] them.

• Added ‘Since: 1.18’ to
  cogl_texture_{set,get}_{components,premultiplied}

• Changed the since tag for CoglTextureError from 2.0 to 1.8.

• Added documentation for COGL_TEXTURE_ERROR_{FORMAT,TYPE}.

• Added the following to the cogl2-sections.txt file:
  COGL_TEXTURE_ERROR
  CoglTextureError
  cogl_texture_allocate
  cogl_texture_set_components
  cogl_texture_get_components
  cogl_texture_set_premultiplied
  cogl_texture_get_premultiplied

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 2f12c4329c519fa14b927b2dcd708dddcc903c32)
2014-01-20 14:32:39 +00:00
Neil Roberts
5085919acc pipeline-cache: Prune old unused pipelines when the cache gets too big
Previously when a pipeline is added to the cache it would never be
removed. If the application is generating a lot of unique pipelines
this can end up effectively leaking a large number of resources
including the GL program objects. Arguably this isn't really a problem
because if the application is generating that many unique pipelines
then it is doing something wrong anyway. It also implies that it will
be recompiling shaders very often so the cache leaking will likely be
the least of the problems.

This patch makes it keep track of which pipelines in the cache are in
use. The cache now returns a struct representing the entry instead of
directly returning the pipeline. This entry contains a usage counter
which the pipeline backends can use to mark when there is a pipeline
alive that is using the cache entry. When the hash table decides that
it's a good time to prune some entries, it will make a list of all of
the pipelines that are not in use and then remove the least recently
used half of the pipelines. That way it is less likely to remove
pipelines that the application is actually regenerating often even if
they aren't in use all of the time.

When the cache is pruned the hash table makes a note of how small the
cache could be if it removed all of the unused pipelines. The hash
table starts pruning when there are more entries than twice this
minimum expected size. The idea is that if that case it hit then the
hash table is more than half full of useless pipelines so the
application is generating lots of redundant pipelines and it is a good
time to remove them.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit c21aac22992bb7fef5a8d0913130b8245e67f2eb)

Conflicts:
	cogl/driver/gl/cogl-pipeline-fragend-glsl.c
	cogl/driver/gl/cogl-pipeline-progend-glsl.c
	cogl/driver/gl/cogl-pipeline-vertend-glsl.c
	cogl/driver/gl/gl/cogl-pipeline-fragend-arbfp.c
2014-01-14 12:05:17 +00:00
Robert Bragg
85a26ea785 texture: fix cogl_texture_get_components prototype
This fixes the cogl_texture_get_components() prototype to have a return
type of CoglTextureComponents instead of CoglBool which was probably a
copy and paste error.

(cherry picked from commit 55b09f8a939db71ee5ff41afa0ed08cbe937a4ec)
2014-01-13 19:10:27 +00:00
Robert Bragg
a77dc1319c texture-rectangle: update _new_with_size in line with master
This updates the cogl_texture_rectangle_new_with_size() api in line with
master to be consistent with other texture constructors. This removes
the internal_format and error arguments and allows the texture to be
allocated lazily which means the texture can be configured with apis
like cogl_texture_set_components() and cogl_texture_set_premultiplied()
before it is allocated.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-13 17:35:05 +00:00
Robert Bragg
8cedb43249 expose deprecated fb api regardless of COGL_ENABLE_EXPERIMENTAL_2_0_API
test-path for example uses COGL_ENABLE_EXPERIMENTAL_2_0_API to access
the 2.0 CoglPath api but also uses deprecated framebuffer api such as
cogl_push/pop_framebuffer. Similarly clutter-backend.c builds with
COGL_ENABLE_EXPERIMENTAL_2_0_API and uses cogl_set_framebuffer().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-09 17:10:21 +00:00
Robert Bragg
1932892b98 framebuffer: move fb stack under cogl/deprecated/
This moves the framebuffer stack apis out of cogl-framebuffer.c into
cogl/deprecated/cogl-framebuffer-deprecated.c so cogl-framebuffer.c is
more in-line with the master branch to ease cherry picking patches.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-09 16:29:14 +00:00
Robert Bragg
1472c5beb2 auto-texture: Adds cogl-auto-texture.h header
This moves all of the automagic texture constructor prototypes from
cogl-texture.h into a new deprecated/cogl-auto-texture.h file. This also
moves cogl_texture_new_from_sub_texture() into
deprecated/cogl-auto-texture.c

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-09 16:29:11 +00:00
Robert Bragg
af7398788a remove internal_format and redundant error arguments
Texture allocation is now consistently handled lazily such that the
internal format can now be controlled using
cogl_texture_set_components() and cogl_texture_set_premultiplied()
before allocating the texture with cogl_texture_allocate(). This means
that the internal_format arguments to texture constructors are now
redundant and since most of the texture constructors now can't ever fail
the error arguments are also redundant. This now means we no longer
use CoglPixelFormat in the public api for describing the internal format
of textures which had been bad solution originally due to how specific
CoglPixelFormat is which is missleading when we don't support such
explicit control over the internal format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 99a53c82e9ab0a1e5ee35941bf83dc334b1fbe87)

Note: there are numerous API changes for functions currently marked
as 'unstable' which we don't think are in use by anyone depending on
a stable 1.x api. Compared to the original patch though this avoids
changing the cogl_texture_rectangle_new_with_size() api which we know
is used by Mutter.
2014-01-09 15:49:47 +00:00
Robert Bragg
cbd6951134 introduce texture loaders to make allocations lazy
This introduces the internal idea of texture loaders that track the
state for loading and allocating a texture. This defers a lot more work
until the texture is allocated.

There are several intentions to this change:

- provides a means for extending how textures are allocated without
  requiring all the parameters to be supplied in a single _texture_new()
  function call.

- allow us to remove the internal_format argument from all
  _texture_new() apis since using CoglPixelFormat is bad way of
  expressing the internal format constraints because it is too specific.

  For now the internal_format arguments haven't actually been removed
  but this patch does introduce replacement apis for controlling the
  internal format:

    cogl_texture_set_components() lets you specify what components your
    texture needs when it is allocated.
    cogl_texture_set_premultiplied() lets you specify whether a texture
    data should be interpreted as premultiplied or not.

- Enable us to support asynchronous texture loading + allocation in the
  future.

Of note, the _new_from_data() texture constructors all continue to
allocate textures immediately so that existing code doesn't need to be
adapted to manage the lifetime of the data being uploaded.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6a83de9ef4210f380a31f410797447b365a8d02c)

Note: Compared to the original patch, the ->premultipled state for
textures isn't forced to be %TRUE in _cogl_texture_init since that
effectively ignores the users explicitly given internal_format which was
a mistake and on master that change should have been made in the patch
that followed. The gtk-doc comments for cogl_texture_set_premultiplied()
and cogl_texture_set_components() have also been updated in-line with
this fix.
2014-01-09 15:49:46 +00:00
Robert Bragg
3f780e2f3f get_texture_bits_via_offscreen(): use meta texture format
When reading a texture back by first wrapping it as an offscreen
framebuffer and using _read_pixels_into_bitmap() we now make sure the
offscreen framebuffer has an internal format that matches the
meta-texture being read not that of the current sub-texture being
iterated. In the case of atlas textures the subtexture is a shared
texture whose format doesn't reflect the premultipled alpha status of
individual atlas-textures, nor whether the alpha component is valid.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 6ee425d4f10acd8b008a2c17e5c701fc1d850f59)
2014-01-09 15:49:46 +00:00
Robert Bragg
99cdcc9e3c texture: make cogl_texture_get_format api private
CoglPixelFormat is not a good way of describing the internal
format of a texture because it's too specific given that we don't
actually have exact knowledge of the internal format used by the driver.

This makes cogl_texture_get_format private and in the future we'll
provide a better way of querying the channels and their precision.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit ffde82981f22bd0185a7f33e1e6e1479f4c295b8)

Note: Since we can't break API compatibility on the 1.x branch this adds
a cogl/deprecated/cogl-texture-deprecated.c file with a
cogl_texture_get_format() wrapper around the private api. This also
moves the cogl_texture_get_rowstride() and cogl_texture_ref/unref()
functions that were previously deprecated into cogl-texture-deprecated.c
2014-01-09 15:49:35 +00:00
Robert Bragg
bab33bf0f3 atlas: defer checks until allocation
This defers checking the internal format and whether accelerated
migration is supported until allocating the texture.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 83b05cbe3969789bc3ec78480c0937a6722efbf1)
2014-01-09 15:29:30 +00:00
Robert Bragg
46f5239664 atlas: make zero size a programmer error
Instead of throwing a CoglError exception if an application tries to
allocate a zero size atlas texture this make that a programmer error
instead.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit d3eaeedc86d408669b81d6c43ef2b0ab9d859c85)
2014-01-09 15:29:30 +00:00
Robert Bragg
40c6b1cc29 texture: allocate on slicing/hw repeat queries
The plan is to defer a lot more work in creating a texture until
allocation time. This means that for some texture backends we might not
know until after allocation whether the texture is sliced or can support
hardware repeating. This makes sure we trigger an allocation if either
of these are queried.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 4868582812dbcd5125495b312d858f751fc31e9d)
2014-01-09 15:29:30 +00:00
Robert Bragg
b9093839b4 ensure texture allocated in _get_gl_texture() in preparation
The plan is to defer a lot more work in creating a texture until
allocation time. This means we wont be able to assume that all textures
being used to render must have already been allocated when data was
specified.

The latest point at which we will generally require a texture to be
allocated will be when we need to know the underlying GL handle for a
texture and so this updates cogl_texture_get_gl_texture() to ensure the
texture is allocated.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 59f6fefc37524f492512a71b831760a218d9bb95)
2014-01-09 15:29:30 +00:00
Robert Bragg
96ed01cc18 framebuffer: defer calculating level size until allocation
The plan is to defer more of the work for creating a texture until
allocation time, but that means we won't be able to always assume
we can query the size of a texture when creating an offscreen
framebuffer from a texture (consider for example using
_texture_new_from_file() where the size isn't known until the file has
been loaded). This defers needing to know the size of the texture
underlying an offscreen framebuffer until calling
cogl_framebuffer_allocate().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 9688e7dc1eeae3144729dfd4a4bf409620346bf4)
2014-01-09 15:29:30 +00:00
Robert Bragg
08ba5c64b9 framebuffer: if size unknown; allocate for size/vp queries
This ensures framebuffers are implicitly allocated when querying the
width, height or viewport width/height if the framebuffer's size is
currently unknown. The plan is to allow texture backends to defer
calculating the size of textures until they are allocated which in turn
means we won't know the size of offscreen framebuffers until the texture
has been allocated. Potentially we could be more specific about this in
the future and only ensure the texture is allocated, but for now it will
be simplest to just ensure the framebuffer is allocated.

Note: in the case of onscreen buffers which are always initialized with
a requested size we are careful to avoid triggering an allocation when
this is queried otherwise we will see recursion when the winsys code
queries the requested size during allocation.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit f4b612f1b75e043f1852b9a32368cc37ab89308b)
2014-01-09 15:29:30 +00:00