Compare commits

...

160 Commits

Author SHA1 Message Date
eb2405f0f4 cogl: Include DRM 4CC conversions into CoglPixelFormat
This is at the moment still part of both MetaRendererNative and
MetaDmaBuf, which means duplicated effort in code sections only barely
related to color formats. By doing this, we can keep more of the pixel
format code together, which is more future-proof as we want to add
support for new pixel formats (like YUV-based ones).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/594
2019-05-28 17:29:18 +02:00
a2c545c321 x11-display: Simplify bell handling
Since commit 956ab4bd made libcanberra mandatory, we never use
the system bell for handling the `audible-bell` setting. So
instead of reacting to settings changes with the exact same call
to XkbChangeEnabledControls(), just call it once when initializing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
3cd8f3b7dc workspace-manager: Remove unnecessary assignment
The initialization to -1 is never used, instead the variables are
re-initialized to 0 before the loop that uses them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
033ce2d956 input-mapper: Remove unnecessary return value
Since commit ae6d9e35bd, there is a fallback to META_MATCH_IS_BUILTIN,
so the condition for returning FALSE is never met.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
2b47e89405 renderer-x11-nested: Fix copy-and-paste error
The rounding added in commit c5471e5b8b mixed up some variables,
whoops.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/598
2019-05-28 14:34:32 +00:00
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
f869e4d54b headless-start-test: Ignore frame counter warnings
When running in slow or busy machines (hey CI!) or under valgrind headless
tests could fail because of a non fatal warning during initialization.

So define a fatal handler that ignores the frame counter warning.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:26:30 -05:00
c1059df7f9 test-runner: Always wait after creating a window
Creating a window could take some time, causing false-positive failures when
running in slower or busy hardware like:

  window 1/2 isn't known to Mutter

So before we proceed in doing any operation on it, wait for the client.
Do this in the test runner instead of repeating the same in every .metatest.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:23:55 -05:00
e3d3df985f gitlab-ci: Use G_SLICE=always-malloc in tests
This allows to catch errors better, as per MALLOC_CHECK_'s definition

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:23:55 -05:00
86ff3dfb3c gitlab-ci: Print error logs on failures
https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:23:54 -05:00
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
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
f99cd18254 clutter/tests/actor-destroy: Check destroying the actor clears the children
Commit df7d8e2cb highlights a crash on test_destroy_destroy, in fact it could
happen that calling clutter_actor_destroy on a child while iterating on the
list, would implicitly call test_destroy_remove that tries to modify the list
at the same time. Causing a memory error.

So instead of manually free the children list, just ensure that this list is
valid and that when the object destruction is done, this is free'd.

See: https://gitlab.gnome.org/GNOME/mutter/merge_requests/576

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
0405786573 wayland-seat: Use g_free to cleanup MetaWaylandSeat
MetaWaylandSeat is allocated using g_new0(), and thus we should use g_free() to
destroy it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
b016ff29f6 cursor-renderer-native: Free MetaCursorNativePrivate struct
Fix a small leak in native renderer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
3f2e86f67c theme: Remove DEBUG_FILL_STRUCT
This debug statement is actually applied all the times, while it could be useful
for crashes analysis, these days the same can be done using `MALLOC_CHECK_` and
`MALLOC_PERTURB_` env variables.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
0aa4a526c6 boxes: Use G_DEFINE_BOXED_TYPE to define the type
https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
85c2aef4bc display: Cleanup Edges when display is closed
This could happen if closing the display when dragging a window, unlikely, but
better to use the cleanup function since we have it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/581
2019-05-27 17:14:25 -05:00
76664ef891 clutter-text: Fix selection color drawing
Commit cabcad185 removed the call to cogl_set_source_color4ub() before
cogl_fill_path(), so instead of the previously assigned selection color,
the background is drawn with the last set source.

In order to honour the newly added framebuffer parameter and still apply
the correct color, switch from cogl_fill_path() to the (deprecated!)
cogl_framebuffer_fill_path() method.

https://gitlab.gnome.org/GNOME/mutter/issues/494
2019-05-27 18:39:39 +00:00
b1ea768949 wayland: Drop -terminate argument to Xwayland
This argument instructs Xwayland to exit when there are no further
client connections. However we eventually want to handle restarts
ourselves (where, notably, mutter's will be at least the last client
connection).

This behavior could also induce race conditions on startup with clients
that quickly open and close a display, which is a more pressing issue.

Also, add -noreset back (which was also removed in commit 054c25f693 that
added -terminate). We don't want to reset the X server to a pristine state
in that situation either.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
ea9d8a895b wayland: Drop error trap
Code underneath seems to handle errors properly, or be x11-agnostic
entirely, this is apparently here to save a few XSync()s on X11. Just
drop this windowing dependent bit to make things cleaner.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
38432da328 compositor: Drop error trap
Code underneath seems to handle errors properly, and this is apparently
here to save a few XSync()s on X11. Just drop this windowing dependent
bit to make things cleaner.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
430f354cd9 wayland: Split Xwayland initialization in 2 steps
It is now separated into meta_xwayland_start(), which picks an unused
display and sets up the sockets, and meta_xwayland_init_xserver(), which
does the actual exec of Xwayland and MetaX11Display initialization.

This differentiation will be useful when Mutter is able to launch Xwayland
lazily, currently the former calls into the latter.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
1cf4279745 x11: Initialize GdkDisplay together with MetaX11Display
It's no longer a "singleton", since it might be closed and opened again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
7713006f5b x11: Unmanage X11 windows on MetaX11Display finalization
This used to be relied upon meta_display_close(), but MetaDisplay
and MetaX11Display lifetimes may be unrelated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
465e13128b core: Add explicit init/shutdown_x11() MetaDisplay calls
The lifetime of MetaX11Display is still tied to MetaDisplay, but these
calls will be useful when it's actually affordable to decouple those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
86de79cfc5 core: Untangle input focus management
In all places (including src/wayland) we tap into meta_x11_display* focus
API, which then calls meta_display* API. This relation is backwards, so
rework input focus management so it's the other way around.

We now have high-level meta_display_(un)set_input_focus functions, which
perform the backend-independent maintenance, and calls into the X11
functions where relevant. These functions are what callers should use.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
1d77641f0b x11: Separate X11 focus handling into MetaX11Display method
Updating the MetaWindow focus and the X Window focus is interrelated but
independent. Call one after the other in the places we handle window focus
changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
2f217109aa core: Relax requirement that MetaWindow shall have icon/mini-icon
We use a GtkIconTheme (thus icon-theme, thus xsettings, thus x11) just to
grab a "missing icon" icon to show in place. Relax this requirement that
surfaces for icon/mini-icon will be set, and just let it have NULL here.

It seems better to have the callers (presumably UI layers) aware of this
and set a proper icon by themselves, but AFAICS there is none in sight,
not even plain mutter seems to use MetaWindow::[mini-]icon. Probably
worth a future cleanup.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
5e0523cc8b x11: Move X11 calls to map/unmap a MetaWindow to MetaWindowX11
Add 2 vmethods so that MetaWindowX11 may handle the X11 calls itself.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
dbe6e01e12 core: Separate checks for pointer barriers availability
If the check happens on --nested (X11 backend) while there is no X11
display we would get a crash. Since the barriers are non-effective on
nested, just take it out into a separate condition.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
103c469cc9 core: Avoid grab transfer shenanigans with non-X11 backend
This explicit ungrab is made to ensure the other X11 display connection
is able to start an active grab immediately on the device without receiving
AlreadyGrabbed.

This is just relevant if there's two X11 display connections to transfer
grabs across, which may just happen on X11 windowing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
ef074ea510 x11: Add MetaX11Stack object
This object takes care of the X11 representation of the window stack,
namely the _NET_CLIENT_LIST and _NET_CLIENT_LIST_STACKING root window
properties.

This code has been lifted from src/core/stack.c into src/x11 as it's
dependent on the X11 display availability. This also leaves MetaStack
squeaky clean of x11 specifics.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
39bac6eabd core: Turn MetaStack into a GObject
So we can have it emit signals and whatnot. Those are unused, yet.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:30 +00:00
0200f4fcd9 x11: Move focus sentinel to MetaX11Display
This focus sentinel is a mechanism to avoid some X11-specific race
conditions in focus-follows-pointer, using X11 mechanisms. Move it to
MetaX11Display altogether.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:30 +00:00
439afb3f19 window: Move all attached windows with parent
We'd break the loop for moving attached windows at the first window,
meaning we'd only ever move a single attached dialogs or popup if it was
the first window in the list. This doesn't work out well when there are
multiple popups open, so don't break out of the loop at all until all
windows are potentially moved.

This fixes an issue in gtk4 where one or more non-grabbing popups would
end up unattached if there were more than one and the parent window was
moved.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/592
2019-05-24 15:07:03 +00:00
b01edc22f3 backends/x11: Do not reload keymap on new keyboard notifications
XkbNewKeyboardNotify informs the client that there is a new keyboard
driving the VCK. It is essentially meant to notify that the keyboard
possibly has a different range of HW keycodes and/or a different
geometry.

But the translation of those keycodes remain the same, and we don't
do range checks or geometry checks (beyond using KEY_GRAVE as "key
under Esc", but that is hardly one). It seems we can avoid the
busywork that is releasing all our passive grabs, reloading the keymap
and regenerating the keycombos and restoring the passive grabs.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/398
2019-05-24 11:28:07 +02:00
e8bca5052a ci: Make MALLOC_PERTURB_ less random
The point is to not initialize to some non-zero value to find places
incorrectly relying on blocks being zero initialized. Thus, there is no
reason to have a different random number each time, and by having it the
same, we have slightly more reproducable triggers, would we ever trigger
anything due to this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/591
2019-05-24 10:57:46 +02:00
468882ecec ci: Run dconf update before running tests
Otherwise tests will fail due to the following warning:

(mutter-test-runner:3700): dconf-WARNING **: 06:39:42.124: unable to
open file '/etc/dconf/db/local': Failed to open file
“/etc/dconf/db/local”: open() failed: No such file or directory; expect
degraded performance

https://gitlab.gnome.org/GNOME/mutter/merge_requests/591
2019-05-24 09:23:22 +02:00
be3c89d823 Bump version to 3.33.2
Update NEWS.
2019-05-22 18:15:34 +00:00
7719e33e68 wayland/pointer-constraints: Reject invalid lifetime
https://gitlab.gnome.org/GNOME/mutter/issues/425
2019-05-22 15:06:14 +00:00
deef9960a4 Fix typo in RemoteDesktop dbus api
https://gitlab.gnome.org/GNOME/mutter/merge_requests/586
2019-05-22 16:21:57 +02:00
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
62de4b4f82 meson: Bump meson requirement to 0.50.0
We've been using configure_file's `install` property for some time now, but this
has been officially supported and works as expected only since meson 0.50, so,
bump version to avoid warnings and ensure the behavior is the one we want.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/585
2019-05-21 12:36:13 -05:00
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
4faeb12731 clutter/stage-cogl: Reschedule update on present
If an update (new frame) had been scheduled already before
`_clutter_stage_cogl_presented` was called then that means it was
scheduled for the wrong time. Because the `last_presentation_time` has
changed since then. And using an `update_time` based on an outdated
presentation time results in scheduling frames too early, filling the
buffer queue (triple buffering or worse) and high visual latency.

So if we do receive a presentation event when an update is already
scheduled, remember to reschedule the update based on the newer
`last_presentation_time`. This way we avoid overfilling the buffer queue
and limit ourselves to double buffering for less visible lag.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/334

Prerequisite: https://gitlab.gnome.org/GNOME/mutter/merge_requests/520

https://gitlab.gnome.org/GNOME/mutter/merge_requests/281
2019-05-21 16:23:49 +00:00
91ac64bb44 drm-buffer: Make the "types" actual types
There is no reason why we should have an internal type enum when we have
all the infrastructure to just use multiple GObject types. Also there
was no code sharing between the old "types", the only common API was
getting the framebuffer ID, so lets make that a vfunc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
ed56edc7ba drm-buffer: Remove useless soft-asserts
If triggered, many would result in crashes later anyway, so lets change
those to asserts. Some are simply useless, so remove those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
6eeba2434a drm-buffer: Clean up file descriptor variable naming
Nowhere else is it called 'drm_fd' so lets not get rid of this
inconsistency.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
7fb7b28cd6 kms-buffer: Rename to MetaDrmBuffer
MetaKms* will be a dedicated namespace, which MetaKmsBuffer doesn't fit
under.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
08aec58c22 kms-buffer: Clean up include order
https://gitlab.gnome.org/GNOME/mutter/merge_requests/584
2019-05-21 14:55:38 +00:00
52945f383d launcher: Explicitly look up object path for seat
If mutter is running as a systemd user service, then we cannot use the
magic "self" session for the ID lookup. For now we need to lookup the ID
explicitly. Eventually we can change to use the magic "auto" paths for
both the session and seat, but that will require systemd v243.

See also https://github.com/systemd/systemd/pull/12424#issuecomment-487962314

https://gitlab.gnome.org/GNOME/mutter/merge_requests/571
2019-05-21 16:43:09 +02:00
fecc57ddf0 renderer-native: Reference count front buffers
Start reference counting front buffers instead of assuming we know
their (scanout) lifetimes.

Functionally, this should not change anything.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/119
2019-05-21 15:49:42 +02:00
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
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
358b67871f boxes: Assign input to output rect when there's no transformation
https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
2b1acea1b0 place: Assign anchor rect using automatic copy
Set the offsets in different statements.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
91aee3d5c4 monitor: Assign monitor layout directly by crtc rect
There's no need to repeat what gcc can do alone.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
02812fb988 clutter/stage-cogl: Damage fb using ceiled scaled sizes
https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
29211c9020 clutter/util: Fix styling on functions definitions
https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
68fba458b3 boxes: Ensure we scale to a fully rounded rectangle
In order to scale a rectangle by a double value, we can reuse a ClutterRect
to do the scale computations in floating point math and then to convert it back
using the proper strategy that will take in account the subpixel compensation.

In this way we can be sure that the resulting rectangle can fully contain the
original scaled one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/469
2019-05-21 08:50:09 +00:00
9c2fdcdbb2 ci: Update Dockerfile to :v2
This commit is a bit deceitful: The main change in the image is *not* the
more recent Fedora base, but an updated (and not backward-compatible)
evolution-data-server package from the fmuellner/gnome-shell-ci copr.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/501 ports
gnome-shell to the new API, so to keep mutter and gnome-shell CI
working after that change, we need to build against the correct
EDS version.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/582
2019-05-20 19:44:57 +02:00
d4a0893d76 ci: Disable a11y bus for tests
While the regular session bus is provided by `dbus-run-session`, the
a11y bus is spawn by the "normal" D-Bus daemon (that is, dbus-broker
in F30). This currently fails, either due to a bug or some missing
dependencies in the container environment. But as we don't actually
need the additional bus, just disable it via the environment to make
not break tests when updating the base image to F30.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/582
2019-05-20 19:44:09 +02:00
7a6c755833 clutter: Add fribidi dependency and copy deprecated pango functions
Pango functions pango_unichar_direction() and pango_find_base_dir() have been
deprecated in pango 1.44, since these are used mostly clutter and gtk, copy the
code from pango and use fribidi dependency explicitly.

This is the same strategy used by Gtk.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/583
2019-05-17 18:11:43 -05:00
45244852ac clutter/stage-cogl: Don't skip over the next frame
The `last_presentation_time` is usually a little in the past (although
sometimes in the future depending on the driver). When it's over 2ms
(`sync_delay`) in the past that would trigger the while loop to count up so
that the next `update_time` is in the future.

The problem with that is for common values of `last_presentation_time`
which are only a few milliseconds ago, incrementing `update_time` by
`refresh_interval` also means counting past the next physical frame that
we haven't rendered yet. And so mutter would skip that frame.

**Example**

Given:
```
  last_presentation_time = now - 3ms
  sync_delay = 2ms
  refresh_interval = 16ms
  next_presentation_time = last_presentation_time + refresh_interval
                         = now + 13ms

          -3ms now        +13ms           +29ms           +45ms
        ----|--+------------|---------------|---------------|----
            :               :
  last_presentation_time  next_presentation_time
```

Old algorithm:
```
  update_time = last_presentation_time + sync_delay
              = now - 1ms
  while (update_time < now)
        (now - 1ms   < now)
    update_time = now - 1ms + 16ms
  update_time = now + 15ms
  next_presentation_time = now + 13ms
  available_render_time = next_presentation_time - max(now, update_time)
                        = (now + 13ms) - (now + 15ms)
                        = -2ms  so the next frame will be skipped.

          -3ms now        +13ms           +29ms           +45ms
        ----|--+------------|-+-------------|---------------|----
            :               : :
            :               : update_time (too late)
            :               :
  last_presentation_time  next_presentation_time (a missed frame)

```

New algorithm:
```
  min_render_time_allowed = refresh_interval / 2
                          = 8ms
  max_render_time_allowed = refresh_interval - sync_delay
                          = 14ms
  target_presentation_time = last_presentation_time + refresh_interval
                           = now - 3ms + 16ms
                           = now + 13ms
  while (target_presentation_time - min_render_time_allowed < now)
        (now + 13ms - 8ms < now)
        (5ms < 0ms)
    # loop is never entered
  update_time = target_presentation_time - max_render_time_allowed
              = now + 13ms - 14ms
              = now - 1ms
  next_presentation_time = now + 13ms
  available_render_time = next_presentation_time - max(now, update_time)
                        = (now + 13ms) - now
                        = 13ms  which is plenty of render time.

          -3ms now        +13ms           +29ms           +45ms
        ----|-++------------|---------------|---------------|----
            : :             :
            : update_time   :
            :               :
  last_presentation_time  next_presentation_time
```

The reason nobody noticed these missed frames very often was because
mutter has some accidental workarounds built-in:

 * Prior to 3.32, the offending code was only reachable in Xorg sessions.
   It was never reached in Wayland sessions because it hadn't been
   implemented yet (till e9e4b2b72).

 * Even though Wayland support is now implemented the native backend
   provides a `last_presentation_time` much faster than Xorg sessions
   (being in the same process) and so is less likely to spuriously enter
   the while loop to miss a frame.

 * For Xorg sessions we are accidentally triple buffering (#334). This
   is a good way to avoid the missed frames, but is also an accident.

 * `sync_delay` is presently just high enough (2ms by coincidence is very
   close to common values of `now - last_presentation_time`) to push the
   `update_time` into the future in some cases, which avoids entering the
   while loop. This is why the same missed frames problem was also noticed
   when experimenting with `sync_delay = 0`.

v2: adjust variable names and code style.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=789186
       and most of https://gitlab.gnome.org/GNOME/mutter/issues/571

https://gitlab.gnome.org/GNOME/mutter/merge_requests/520
2019-05-16 22:13:54 +00:00
e96136e418 gitlab-ci: Use MALLOC_CHECK_ and MALLOC_PERTURB_ env variables in tests
Linux glibc supports a malloc implementation that is allows to be tunable using
environment variables, to check allocation issues.

When MALLOC_CHECK_ is set to 3, a diagnostic message is printed on stderr and
the program is aborted.

Setting the MALLOC_PERTURB_ environment variable causes the malloc functions in
to return memory which has been wiped and initialized with the byte value of the
environment variable.

So use this features when running tests in order to catch better memory errors.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/578
2019-05-16 21:30:36 +00:00
eae6e7a889 Updated Spanish translation 2019-05-16 12:42:33 +02:00
a48b6cc9ca clutter/actor: Fix a wrong comment
https://gitlab.gnome.org/GNOME/mutter/merge_requests/547
2019-05-15 20:38:28 +00:00
786305f7d6 clutter/input-device: Replace device check with assertion
We only call _clutter_input_device_update with devices that are not
Keyboard devices. Also passing a Keyboard device to a function whose
primary purpose is picking should be considered a bug in the caller.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/547
2019-05-15 20:38:28 +00:00
30a2483e6e clutter/stage-cogl: Fix a comment-typo
https://gitlab.gnome.org/GNOME/mutter/merge_requests/547
2019-05-15 20:38:28 +00:00
f5f0aa1023 clutter/stage: Move a comment to a more appropriate place
https://gitlab.gnome.org/GNOME/mutter/merge_requests/547
2019-05-15 20:38:28 +00:00
b86fba2f3c clutter/stage: Avoid unnecessary call to add_redraw_clip
We're bailing out of clutter_stage_cogl_add_redraw_clip() early without
doing anything if we're ignoring redraw clips, so no need to call it if
we already know that will be the case.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/547
2019-05-15 20:38:28 +00:00
f7ecf3b618 meta: Remove meta_free_gslist_and_elements
This function was added for historic reasons, before that we had GSlist's
free_full function.

Since this can be now easily implemented with a function call and an explicit
GDestroyFunc, while no known dependency uses it let's move to use
g_slist_free_func instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/57
2019-05-15 14:49:56 -05:00
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
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
9e82f9af25 x11: Do not warn on cancelled X11 selection sources
This shouldn't happen frequently, but is just a sign that the source is
being replaced by something else. Just keep the warning for other possible
error situations.

Also, plug the potential GError leak.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/598
2019-05-15 13:14:12 +00:00
329c4bc5b3 Bump version to 3.33.1
Update NEWS.
2019-05-14 18:14:48 +00:00
706c5a7565 clutter: LEQUAL depth_testing on ClutterDeformEffect
Moving an actor with a ClutterDeformEffect applied flickers because
the depth_testing, setting the depth testing test function to
COGL_DEPTH_TEST_FUNCTION_LEQUAL fixes the problem.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/507
2019-05-14 17:44:38 +02:00
24b3467584 clutter: Send touch crossing events only to grab actor
When the pointer is grabbed, we send the crossing events that are
initiated by this pointer only to the actor that has the grab. For
grabbed touch sequences, we always capture and bubble the crossing
events right now.

Fix this and make grabbed pointers and touch sequences behave the same
by sending touch crossing events only to the grab actor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/422
2019-05-14 09:05:47 +00:00
9e0e35d2a7 clutter/click-action: Handle touch cancel events
It's important to cancel click actions when we get a touch cancel event,
otherwise the long press event might get emitted after the compositor
took over the touches because it detected a gesture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/396
2019-05-13 09:44:50 +00:00
dae2c1d420 backends/native: Add rt-scheduler experimental key to set RT scheduling
This is similar to a change in kwin:
https://blog.martin-graesslin.com/blog/2017/09/kwinwayland-goes-real-time/

If the experimental features key has "rt-scheduler", make it claim the lowest
of RT scheduler priorities, this will be both educated to other RT processes
and improves responsiveness wrt all other processes.

This can only work if mutter/gnome-shell process receives CAP_SYS_NICE
somehow, e.g.: "setcap CAP_SYS_NICE=+ep `which gnome-shell`"

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/921
https://gitlab.gnome.org/GNOME/mutter/merge_requests/460
2019-05-10 21:47:53 +00:00
01d0316fd7 wayland/dnd-surface: Propagate commit to parent class
We need to call the underlying actor-surface so the actor
state is synced, otherwise surface state like the scale factor
does not get applied.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/550

https://gitlab.gnome.org/GNOME/mutter/merge_requests/537
2019-05-09 09:06:52 +00:00
7e2a0ede16 wayland: Move check for present window out of the actor-surface class
All child classes of `MetaWaylandShellSurface` as well as
`MetaWaylandSurfaceRoleXWayland` should only sync their actor if
their toplevel surface has a window. Currently this check is done
in the actor-surface class, but not all surface classes have a
toplevel window, e.g. dnd-surfaces.
Move the check to the right places.

For subsurfaces this assumes that the subsurface is not the child of
a window-less surface (like, as stated above, e.g. a dnd-surface).
If we want to support subsurfaces of window-less surfaces in the future
we have to extend the check here.
But as this is not a regression, ignore this case for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/537
2019-05-09 09:06:52 +00:00
7738b5c00b core/window: Fix copy/paste error in size-changed docs
It appears it was copied from MetaWindow::position-changed and pasted
for MetaWindow::size-changed, without updating all the words.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/567
2019-05-08 09:28:16 +00:00
454651f79f Update Indonesian translation 2019-05-07 07:14:36 +00:00
bf8bc65cc9 core: Check environment variables before giving to GAppLaunchContext
Depending on the type of session, one or the other might be NULL, which
is not meant to be handled by these functions. Check for both DISPLAY
envvars before setting them on the GAppLaunchContext.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/586
2019-05-06 17:27:56 +02:00
6a89e7969f Update Friulian translation 2019-05-03 17:43:01 +00:00
3ffc4f8876 ci: Use mutter image to build GNOME Shell
https://gitlab.gnome.org/GNOME/mutter/merge_requests/548
2019-05-03 14:15:31 -03:00
b4d973fbe4 ci: Update gsettings-desktop-schema URLs
Copr keeps changing them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/548
2019-05-03 14:15:31 -03:00
da1e917b38 ci: Add GNOME Shell dependencies to Dockerfile
Embrace, extend and (soon) extinguish GNOME Shell's CI
image.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/548
2019-05-03 14:15:30 -03:00
160d2d56d9 ci: Install to Mutter and GNOME Shell to /usr
So GNOME Shell can find the pkg-config files properly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/548
2019-05-03 14:15:30 -03:00
3468144847 ci: Build GNOME Shell at the test stage
Hopefully this will allow us prevent merging branches
that accidentally break GNOME Shell.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/548
2019-05-03 14:15:30 -03:00
ae6d9e35bd backends: Fallback to builtin panel for devices where all heuristics fail
This is 1) relatively likely as not all touchscreens are nice enough to
report a device size that will help us here and 2) Better than nothing if
everything fails anyway, as it will break on multi-monitor and non-default
monitor rotations.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/581
2019-05-03 15:01:47 +00:00
ac15a8abca Updated Spanish translation 2019-05-03 14:31:16 +02:00
5480a3f238 Update POTFILES.in 2019-05-03 12:54:24 +02:00
0d50a37091 display: Fix a possible bug in meta_display_sync_wayland_focus
The check for the focus xwindow is called, but not used. Fix that by
renaming the variable to reflect better what it does and actually using
the return value of the check.

This was the original intention of the author in commit
05899596d1 and got broken in commit
8e7e1eeef5.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/535
2019-05-02 23:54:22 +00:00
1ca0fdc928 idle-monitor: Postpone dispatching of idle timeout if not ready
If we update the ready time while the source is already in the
to-dispatch list, changing the ready time doesn't have any effect, and
the source will still be dispatched. This could cause incorrect idle
watch firing causing the power management plugin in
gnome-settings-daemon to sometimes turn off monitors due to it believing
the user had been idle for some time, while in fact, they just logged
back in.

Fix this by not actually dispatching the idle timeout if the ready time
is in the future when actually dispatching.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/543
2019-05-02 23:46:43 +00:00
23a8ea2821 idle-monitor: Use G_SOURCE_CONTINUE instead of TRUE
Returning TRUE is confusing, as it doesn't carry any relevant meaning.
Use G_SOURCE_CONTINUE to make it clearer that the source is here to
stay.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/543
2019-05-02 23:46:43 +00:00
ee4bb2240b workspace: Activate a window also if it's already in workspace
meta_workspace_activate_with_focus is supposed to focus the passed window after
switching the workspace.

However if the passed workspace is already the active one, we just return
without activating the window.
So fix this calling meta_window_activate on the foucs_this window if that is
valid.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/562
2019-05-02 17:33:17 -05:00
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
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
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
5d1a87d355 meson: Add option flags to control test suites building
Now the `tests` meson option controls weather we should build all the test suites
while `core_tests` controls mutter tests.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
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
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
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
c6d1cf4af4 tests: Add single stacking tests with suite
Don't launch the stacking tests in one single shot, to allow better debugging
and being able to launch just one single test using meson test.

Those tests can now be all launched with:
  meson test --suite stacking [single-test-name]

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
8dbe4210b4 tests: Add missing stacking tests
List all .metatest files that were added only to autotools while they are
missing since the meson port.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/442
2019-05-02 19:56:23 +00:00
02c99524bf Make MetaSelection, MetaSelectionSource and MetaMemorySelectionSource public
This exposes the base so that we can reimplement StClipboard on top. Some
gtk-docs have been added for documentation and introspection purposes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:31:45 +02:00
17d00d49d4 wayland: Reduce MetaXWaylandSelection to just DnD
All the actual selection management functionality is superseded by
MetaSelection. Reduce it to just handling the XDND messaging and leave
selections to MetaSelection.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:31:45 +02:00
634f512bb0 wayland: Integrate with MetaSelection
Make MetaWaylandDataDevice use MetaSelection and MetaSelectionSource to
handle primary/clipboard/dnd.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:31:45 +02:00
5c009c20ab core: Add clipboard manager
This is a simple clipboard manager implementation on top of MetaSelection.
It will inspect the clipboard content for UTF-8 text and image data whenever
any other selection source claims ownership, and claim it for itself
whenever the clipboard goes unowned.

The stored text has a maximum size of 4MB and images 200MB, to prevent the
compositor from allocating indefinite amounts of memory.

This is not quite a X11 clipboard manager, but also works there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:45 +02:00
535ce00abb core: Add memory-based selection source
This is a simple implementation of a MetaSelectionSource, able to hold a
single mimetype, provided as GBytes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:45 +02:00
37144f0609 x11: Add X11 selection management
This code takes care of both setting up X11 selection sources whenever
X11 clients claim selection ownership, and claiming selection ownership
on a mutter X11 window whenever other selection sources claim ownership.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:45 +02:00
ab76576340 core: Set up MetaSelection on MetaDisplay
https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
09aa82db49 wayland: Add wayland MetaSelectionSource implementation
This object represents a Wayland selection owner. In order to invert the
FD direction (we hand an output fd, but want an inpu fd), create an
intermediate pipe so we can then create a GInputStream on top of it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
c95db7c542 x11: Add X11 MetaSelectionSource implementation
This object represents the selection ownership from an X11 client. The
list of supported targets is queried upfront, so its initialization is
asynchronous. Requests to read contents from the selection will hand
a MetaX11SelectionInputStream.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
a984622cd1 core: Add MetaSelection and MetaSelectionSource
MetaSelectionSource represents a primary/clipboard/dnd selection owner,
it is an abstract type so wayland/x11/etc implementations can be provided.
These 3 selections are managed by the MetaSelection object, the current
selection owners will be set there, and signals will be emitted so the
previous selection owner can clean itself up.

The actual data transfer is done through the meta_selection_transfer_async()
call, which will take a GOutputStream and create a corresponding
GInputStream from the MetaSelectionSource in order to splice them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
156980eff9 x11: Add X11 selection input/output streams
These are rip off of GTK+ ones, with some adaptions to integrate them in
mutter event dispatching code and make them easier to use in future
commits.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 15:40:13 +02:00
736cac43e9 compositor: Remove unused background_actor private reference
https://gitlab.gnome.org/GNOME/mutter/merge_requests/556
2019-04-30 16:15:42 -05:00
3ba79961fe compositor: Disconnect from stage signals on destruction
From this point there's not any need for the compositor to listen to signals
so we can disconnect from the stage ones we are connected to.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/556
2019-04-30 16:15:42 -05:00
7718e67f5c compositor: Destroy window actors list on destruction
When the compositor is destroyed we should cleanup the list of window actors we
created and destroy them.
Since all the actors are added to the window_group or top_window_group we can
just destroy these containers (together with the feedback_group), and simply
free the windows list.

This is particularly needed under X11 because before we destroy the display, we
might do some cleanups as detaching the surface pixmaps and freeing the damages
and if this happens at later point (for example when triggered by garbage
collector in gnome-shell), we might crash because the x11 dpy reference is
already gone.

Destroying the window actors instead, ensures we avoid any further call to X11
related functions and that we release the actors XServer resources.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/576
2019-04-30 16:15:42 -05:00
ba8f5a1178 clutter: Use g_signal_handler_disconnect to disconnect frequent signal
Clutter does the nicety of connecting just created PangoContexts to
ClutterBackend signals in order to update it on resolution/font changes.
However the way the signals are disconnected (automatically via
g_signal_connect_object() auto-disconnect feature) may incur into
performance issues with a high enough number of ClutterActors with a
PangoContext (eg. ClutterText) as the lookup by closure is linear across
all signals and handlers.

Keep the handler IDs around, and disconnect them specifically on dispose
so it is more O(1)-ish.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/556
2019-04-30 13:12:53 +00:00
502da973eb window: free close dialog before unmanaging window from compositor
When an application stops responding, the shell darkens its windows.

If a window from a not-responding application gets unmanaged
then the shell will currently throw an exception trying to retrieve
the now-dissociated window actor.

That leads to a "stuck window" ghost on screen and a traceback
in the log.

This commit addresses the problem by making sure the effect is cleaned
up before the actor is disocciated from its window.

https://gitlab.gnome.org/GNOME/mutter/issues/575
2019-04-29 14:06:12 -04:00
eccf7b105c input-settings: Use 0 initialized struct for kbd a11y
Make sure our keyboard accessibility settings structure is all zero
initialized, to avoid potential padding issues on some platform when
comparing settings.

Reported by Daniel van Vugt on IRC.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/552
2019-04-26 11:17:50 +02:00
bcee890434 ci: Ensure we clone a deep enough history for commit review
It seems gitlab changed something recently in the default clone depth
which made MRs with >10 commits to obscurely fail in the review stage.
As per https://docs.gitlab.com/ee/ci/yaml/#shallow-cloning, bump it
to 100 to allow bigger MRs.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/551
2019-04-24 12:29:22 +02:00
251fa024c4 clutter/x11: disable mousekeys with Numlock ON
GNOME documentation on accessibility features states that mousekeys
work only when NumLock is OFF:

  https://help.gnome.org/users/gnome-help/stable/mouse-mousekeys.html

Change the clutter/x11 implementation to match the documentation, i.e.
disable mousekeys when NumLock in ON so that switching NumLock ON
restores the numeric keypad behaviour.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/530
2019-04-19 13:51:35 +00:00
471b61bd14 clutter/evdev: disable mousekeys with Numlock ON
The clutter/evdev implementation of mousekeys is designed after the
current implementation in X11, and works when the setting is enabled
regardless of the status of NumLock.

The GNOME documentation on accessibility features states however that
mousekeys work only when NumLock is OFF:

  https://help.gnome.org/users/gnome-help/stable/mouse-mousekeys.html

Change the clutter/evdev implementation to match the documentation, i.e.
disable mousekeys when NumLock in ON so that switching NumLock ON
restores the numeric keypad behaviour.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/530
2019-04-19 13:51:35 +00:00
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
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
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
ca2be8ef5b cogl: Remove CoglTextureType
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:26 -04:00
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
862e56f01d cogl: Remove unused CoglTextureVable::get_type
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:21 -04:00
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
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
c881b4970d cogl: Remove unused CoglTextureRectangle
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:16 -04:00
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
ce6acf9dca cogl: Remove rectangle-texture tests
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:12 -04:00
2a15e5f16a compositor: Drop ARB_texture_rectangle awareness
The GL/GLES versions we require imply full NPOT texture support, so the
ARB_texture_rectangle path will never be hit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:10 -04:00
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
fc09fa50a5 cogl: NPOT textures are always available
https://gitlab.gnome.org/GNOME/mutter/merge_requests/546
2019-04-18 12:53:07 -04:00
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
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
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
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
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
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
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
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
22884b0b00 shaped-texture: Use draw_rectangle() for full paints
This reverts a change introduced in edfe5cc3 to use `paint_clipped_rectangle()`
instead of `cogl_framebuffer_draw_rectangle()` for full paints as it
contained logic necessary for viewport src-rects. This is not longer the case.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/504
2019-04-17 20:28:43 +00:00
d2415da0d4 shaped-texture: Use CoglMatrix for viewport src-rect
This brings the viewport src-rect code in line with how we handle
transforms, by applying a `CoglMatrix` to the pipeline instead of
changing the paint logic.
It also fixes not-y-inverted textures in combination with
transforms.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/504
2019-04-17 20:28:43 +00:00
96f7bf28f1 shaped-texture: Add checks to viewport reset functions
The set and reset functions are unconditionally called on every
commit. Add missings checks to the reset functions to bail out if
nothing changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/504
2019-04-17 20:28:42 +00:00
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
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
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
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
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
e3f3274bbf Bump version to 3.32.1
Update NEWS.
2019-04-17 19:40:01 +02:00
d2ca5cc26b display: Fix inconsistent behavior with demand attention
When focus stealing prevention kicks in, mutter would set the demand
attention flag on the window.

Focus stealing prevention would also prevent the window from being
raised and focused, which is expected as its precisely its purpose.

Yet, when that occurs, the user expects the window which has just been
prevented from being focused to be the next one in the MRU list, so
that pressing [Alt]-[Tab] would raise and give focus to that window.

This works fine when the window is placed on the primary monitor, but
not when placed on another monitor, in which case the window which has
been denied focus is placed ahead of the MRU list and pressing
[Alt]-[Tab] would leave the focus on the current window.

This is because of a mechanism in `meta_display_get_tab_list()` which
forces the windows with the demand attention flag set to be placed first
in the MRU list when they're placed on a workspace different from the
current one.

But because workspaces apply only to the primary monitor (by default),
the windows placed on other outputs have their workspace set to `NULL`
which forces them ahead of the MRU list by mistake.

Fix this by using the appropriate `meta_window_located_on_workspace()
function to check if the window is on another workspace.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/523
2019-04-17 18:53:04 +02:00
245 changed files with 8026 additions and 9093 deletions

View File

@ -1,4 +1,4 @@
image: registry.gitlab.gnome.org/gnome/mutter/master:v1
image: registry.gitlab.gnome.org/gnome/mutter/master:v2
stages:
- review
@ -7,6 +7,8 @@ stages:
check-commit-log:
stage: review
variables:
GIT_DEPTH: "100"
script:
- ./.gitlab-ci/check-commit-log.sh
only:
@ -15,7 +17,7 @@ check-commit-log:
build-mutter:
stage: build
script:
- meson . build -Dbuildtype=debugoptimized -Degl_device=true -Dwayland_eglstream=true --werror
- meson . build -Dbuildtype=debugoptimized -Degl_device=true -Dwayland_eglstream=true --werror --prefix /usr
- ninja -C build
- ninja -C build install
artifacts:
@ -33,12 +35,31 @@ test-mutter:
variables:
XDG_RUNTIME_DIR: "$CI_PROJECT_DIR/runtime-dir"
GSETTINGS_SCHEMA_DIR: "$CI_PROJECT_DIR/build/data"
G_SLICE: "always-malloc"
MALLOC_CHECK_: "3"
NO_AT_BRIDGE: "1"
MALLOC_PERTURB_: "123"
script:
- dconf update
- mkdir -m 700 $XDG_RUNTIME_DIR
- glib-compile-schemas $GSETTINGS_SCHEMA_DIR
- >
dbus-run-session -- xvfb-run -s '+iglx -noreset'
meson test -C build --no-rebuild -t 10 --verbose --no-stdsplit --wrap catchsegv
meson test -C build --no-rebuild -t 10 --verbose --no-stdsplit --print-errorlogs --wrap catchsegv
only:
- merge_requests
- /^.*$/
can-build-gnome-shell:
stage: test
dependencies:
- build-mutter
before_script:
- meson install --no-rebuild -C build
script:
- .gitlab-ci/checkout-gnome-shell.sh
- meson gnome-shell gnome-shell/build --prefix /usr
- ninja -C gnome-shell/build install
only:
- merge_requests
- /^.*$/

View File

@ -1,17 +1,26 @@
FROM fedora:29
FROM fedora:30
RUN dnf -y update && dnf -y upgrade && \
dnf install -y 'dnf-command(builddep)' && \
dnf install -y 'dnf-command(copr)' && \
dnf copr enable -y fmuellner/gnome-shell-ci && \
dnf builddep -y mutter && \
# Until Fedora catches up with meson build-deps
dnf install -y meson xorg-x11-server-Xorg gnome-settings-daemon-devel egl-wayland-devel xorg-x11-server-Xwayland && \
# For running unit tests
dnf install -y xorg-x11-server-Xvfb mesa-dri-drivers dbus dbus-x11 && \
dnf install -y xorg-x11-server-Xvfb mesa-dri-drivers dbus dbus-x11 '*/xvfb-run' gdm-lib accountsservice-libs && \
# Unpackaged versions
dnf install -y https://copr-be.cloud.fedoraproject.org/results/jadahl/mutter-ci/fedora-29-x86_64/00848426-gsettings-desktop-schemas/gsettings-desktop-schemas-3.30.1-1.20181206git918efdd69be53.fc29.x86_64.rpm https://copr-be.cloud.fedoraproject.org/results/jadahl/mutter-ci/fedora-29-x86_64/00848426-gsettings-desktop-schemas/gsettings-desktop-schemas-devel-3.30.1-1.20181206git918efdd69be53.fc29.x86_64.rpm && \
dnf install -y https://copr-be.cloud.fedoraproject.org/results/jadahl/mutter-ci/fedora-29-x86_64/00834984-gsettings-desktop-schemas/gsettings-desktop-schemas-3.30.1-1.20181206git918efdd69be53.fc29.x86_64.rpm https://copr-be.cloud.fedoraproject.org/results/jadahl/mutter-ci/fedora-29-x86_64/00834984-gsettings-desktop-schemas/gsettings-desktop-schemas-devel-3.30.1-1.20181206git918efdd69be53.fc29.x86_64.rpm && \
dnf install -y intltool redhat-rpm-config make && \
# GNOME Shell
dnf builddep -y gnome-shell --setopt=install_weak_deps=False && \
dnf remove -y gnome-bluetooth-libs-devel dbus-glib-devel upower-devel python3-devel && \
dnf remove -y --noautoremove mutter mutter-devel && \
dnf clean all

View File

@ -0,0 +1,35 @@
#!/usr/bin/bash
mutter_branch=$(git describe --contains --all HEAD)
gnome_shell_target=
git clone https://gitlab.gnome.org/GNOME/gnome-shell.git
if [ $? -ne 0 ]; then
echo Checkout failed
exit 1
fi
cd gnome-shell
if [ "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then
merge_request_remote=${CI_MERGE_REQUEST_SOURCE_PROJECT_URL//mutter/gnome-shell}
merge_request_branch=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
echo Looking for $merge_request_branch on remote ...
if git fetch -q $merge_request_remote $merge_request_branch 2>/dev/null; then
gnome_shell_target=FETCH_HEAD
else
gnome_shell_target=origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
echo Using $gnome_shell_target instead
fi
fi
if [ -z "$gnome_shell_target" ]; then
gnome_shell_target=$(git branch -r -l origin/$mutter_branch)
gnome_shell_target=${gnome_shell_target:-$(git branch -r -l ${mutter_branch#remotes/})}
gnome_shell_target=${gnome_shell_target:-origin/master}
echo Using $gnome_shell_target instead
fi
git checkout -q $gnome_shell_target

70
NEWS
View File

@ -1,3 +1,73 @@
3.33.2
======
* Fix rendering lag on Xorg [Daniel; !520, !281]
* Misc. bug fixes and cleanups [Carlos, Marco, Jonas D., Florian, Niels,
Daniel, Benjamin, Jonas Å., Ignacio, Vasilis; #598, !576, !547, !578,
!583, !582, !469, !524, !119, !571, !584, !585, !586, #425]
Contributors:
Jonas Ådahl, Benjamin Berg, Jonas Dreßler, Carlos Garnacho, Niels De Graef,
Vasilis Liaskovitis, Florian Müllner, Ignacio Casal Quinteiro,
Marco Trevisan (Treviño), Daniel van Vugt
Translators:
Daniel Mustieles [es]
3.33.1
======
* Remove unused APIs and outdated driver support
[Adam; !481, !468, !489, !487, !546]
* Enable EGL_IMG_context_priority [Adam; !454]
* Disable mouse keys with Numlock on [Olivier; #530]
* Fix crash when restarting on X11 [Marco; #576]
* Implement clipboard manager [Carlos; !320]
* Fix spurious idle signals that prevent session unblank [Jonas Å.; !543]
* Fix mapping of touchscreens that don't report dimensions [Carlos; #581]
* Fix propagating fractional scaling factor [Robert; !537]
* Add experimental RT scheduling support [Carlos; !460]
* Misc. bug fixes and cleanups [Robert, Carlos, Olivier, Ray, Marco, Jonas D.,
Georges, Daniel V., Daniel M; !467, !504, !551, !552, #575, #556, !557, !442,
!562, !535, !548, #586, !567, !396, !422, !507]
Contributors:
Jonas Ådahl, Piotr Drąg, Jonas Dreßler, Olivier Fourdan, Carlos Garnacho,
Adam Jackson, Robert Mader, Daniel García Moreno, Florian Müllner,
Georges Basile Stavracas Neto, Ray Strode, Marco Trevisan (Treviño),
Daniel van Vugt
Translators:
Daniel Mustieles [es], Fabio Tomat [fur], Kukuh Syafaat [id]
3.32.1
======
* Fix fallback app menu on wayland [Florian; #493]
* Fix elogind support [Tom; !491]
* Fix startup notifications not timing out [Carlos; #501]
* Fix keyboard accessibility toggle from keys
[Olivier, Carlos; !501, #529, !531]
* Fix touchscreen input on rotated displays [Carlos; #514]
* Work around hangul text input bug [Carlos; #1365]
* Fix blurry wallpaper scaling [Daniel; !505]
* Fix placement of window menu when using fractional scaling [Jan; #527]
* Fix repaint issues of offscreen effects on secondary monitors [Daniel; !511]
* Fix windows not getting focus after launch [Daniel; #505]
* Properly advertise support for 'underscan' property [Jonas; !507]
* Improve power-saving handling [Jonas; !506]
* Fix moving windows by super+touch [Jonas D.; !495]
* Misc. bug fixes and cleanups [Benjamin, Florian, Adam, Marco, Pablo,
Erik, Jonas, Heiher, Pekka, Daniel, Olivier, Carlos; !478, !475, !480,
!482, #490, !488, #491, #480, !477, !496, !492, !485, !515, !519, !521,
!216, !538, #541, #523]
Contributors:
Jonas Ådahl, Pablo Barciela, Benjamin Berg, Tom Briden, Jonas Dreßler,
Olivier Fourdan, Carlos Garnacho, Jan Alexander Steffens (heftig), Heiher,
Adam Jackson, Erik Kurzinger, Florian Müllner, Pekka Paalanen,
Marco Trevisan (Treviño), Daniel van Vugt
Translators:
Khaled Hosny [ar], Goran Vidović [hr], Daniel Mustieles [es]
3.32.0
======
* Fix deadlock when cancelling a theme sound [Andrea; !474]

View File

@ -1044,10 +1044,8 @@ _cally_actor_clean_action_list (CallyActor *cally_actor)
if (priv->action_list)
{
g_list_foreach (priv->action_list,
(GFunc) _cally_actor_destroy_action_info,
NULL);
g_list_free (priv->action_list);
g_list_free_full (priv->action_list,
(GDestroyNotify) _cally_actor_destroy_action_info);
priv->action_list = NULL;
}
}

View File

@ -577,8 +577,7 @@ _clutter_meta_group_clear_metas (ClutterMetaGroup *group)
{
g_list_foreach (group->meta, (GFunc) _clutter_actor_meta_set_actor, NULL);
g_list_foreach (group->meta, (GFunc) g_object_unref, NULL);
g_list_free (group->meta);
g_list_free_full (group->meta, g_object_unref);
group->meta = NULL;
}

View File

@ -807,6 +807,9 @@ struct _ClutterActorPrivate
gpointer create_child_data;
GDestroyNotify create_child_notify;
guint resolution_changed_id;
guint font_changed_id;
/* bitfields: KEEP AT THE END */
/* fixed position and sizes */
@ -5983,6 +5986,7 @@ clutter_actor_dispose (GObject *object)
{
ClutterActor *self = CLUTTER_ACTOR (object);
ClutterActorPrivate *priv = self->priv;
ClutterBackend *backend = clutter_get_default_backend ();
CLUTTER_NOTE (MISC, "Dispose actor (name='%s', ref_count:%d) of type '%s'",
_clutter_actor_get_debug_name (self),
@ -6019,6 +6023,18 @@ clutter_actor_dispose (GObject *object)
g_assert (!CLUTTER_ACTOR_IS_REALIZED (self));
}
if (priv->resolution_changed_id)
{
g_signal_handler_disconnect (backend, priv->resolution_changed_id);
priv->resolution_changed_id = 0;
}
if (priv->font_changed_id)
{
g_signal_handler_disconnect (backend, priv->font_changed_id);
priv->font_changed_id = 0;
}
g_clear_object (&priv->pango_context);
g_clear_object (&priv->actions);
g_clear_object (&priv->constraints);
@ -8833,9 +8849,9 @@ _clutter_actor_queue_redraw_full (ClutterActor *self,
*
* later during _clutter_stage_do_update(), once relayouting is done
* and the scenegraph has been updated we will call:
* _clutter_stage_finish_queue_redraws().
* clutter_stage_maybe_finish_queue_redraws().
*
* _clutter_stage_finish_queue_redraws() will call
* clutter_stage_maybe_finish_queue_redraws() will call
* _clutter_actor_finish_queue_redraw() for each listed actor.
*
* Note: actors *are* allowed to queue further redraws during this
@ -15884,10 +15900,12 @@ clutter_actor_get_pango_context (ClutterActor *self)
{
priv->pango_context = clutter_actor_create_pango_context (self);
g_signal_connect_object (backend, "resolution-changed",
G_CALLBACK (update_pango_context), priv->pango_context, 0);
g_signal_connect_object (backend, "font-changed",
G_CALLBACK (update_pango_context), priv->pango_context, 0);
priv->resolution_changed_id =
g_signal_connect_object (backend, "resolution-changed",
G_CALLBACK (update_pango_context), priv->pango_context, 0);
priv->font_changed_id =
g_signal_connect_object (backend, "font-changed",
G_CALLBACK (update_pango_context), priv->pango_context, 0);
}
else
update_pango_context (backend, priv->pango_context);

View File

@ -235,8 +235,7 @@ clutter_binding_pool_finalize (GObject *gobject)
g_hash_table_destroy (pool->entries_hash);
g_slist_foreach (pool->entries, (GFunc) binding_entry_free, NULL);
g_slist_free (pool->entries);
g_slist_free_full (pool->entries, (GDestroyNotify) binding_entry_free);
G_OBJECT_CLASS (clutter_binding_pool_parent_class)->finalize (gobject);
}

View File

@ -249,9 +249,7 @@ clutter_blur_effect_init (ClutterBlurEffect *self)
cogl_pipeline_add_layer_snippet (klass->base_pipeline, 0, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */
COGL_TEXTURE_TYPE_2D);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
}
self->pipeline = cogl_pipeline_copy (klass->base_pipeline);

View File

@ -438,9 +438,7 @@ clutter_brightness_contrast_effect_init (ClutterBrightnessContrastEffect *self)
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */
COGL_TEXTURE_TYPE_2D);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
}
self->pipeline = cogl_pipeline_copy (klass->base_pipeline);

View File

@ -355,6 +355,10 @@ on_captured_event (ClutterActor *stage,
switch (clutter_event_type (event))
{
case CLUTTER_TOUCH_CANCEL:
clutter_click_action_release (action);
break;
case CLUTTER_TOUCH_END:
has_button = FALSE;
case CLUTTER_BUTTON_RELEASE:

View File

@ -293,9 +293,7 @@ clutter_colorize_effect_init (ClutterColorizeEffect *self)
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */
COGL_TEXTURE_TYPE_2D);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
}
self->pipeline = cogl_pipeline_copy (klass->base_pipeline);

View File

@ -282,6 +282,7 @@ clutter_deform_effect_paint_target (ClutterOffscreenEffect *effect)
/* enable depth testing */
cogl_depth_state_init (&depth_state);
cogl_depth_state_set_test_enabled (&depth_state, TRUE);
cogl_depth_state_set_test_function (&depth_state, COGL_DEPTH_TEST_FUNCTION_LEQUAL);
cogl_pipeline_set_depth_state (pipeline, &depth_state, NULL);
/* enable backface culling if we have a back material */

View File

@ -297,9 +297,7 @@ clutter_desaturate_effect_init (ClutterDesaturateEffect *self)
cogl_pipeline_add_snippet (klass->base_pipeline, snippet);
cogl_object_unref (snippet);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline,
0, /* layer number */
COGL_TEXTURE_TYPE_2D);
cogl_pipeline_set_layer_null_texture (klass->base_pipeline, 0);
}
self->pipeline = cogl_pipeline_copy (klass->base_pipeline);

View File

@ -909,7 +909,6 @@ typedef enum
/**
* ClutterFeatureFlags:
* @CLUTTER_FEATURE_TEXTURE_NPOT: Set if NPOTS textures supported.
* @CLUTTER_FEATURE_SWAP_THROTTLE: Set if backend throttles buffer swaps.
* @CLUTTER_FEATURE_TEXTURE_YUV: Set if YUV based textures supported.
* @CLUTTER_FEATURE_TEXTURE_READ_PIXELS: Set if texture pixels can be read.
@ -928,7 +927,6 @@ typedef enum
*/
typedef enum
{
CLUTTER_FEATURE_TEXTURE_NPOT = (1 << 2),
CLUTTER_FEATURE_SWAP_THROTTLE = (1 << 3),
CLUTTER_FEATURE_TEXTURE_YUV = (1 << 4),
CLUTTER_FEATURE_TEXTURE_READ_PIXELS = (1 << 5),

View File

@ -1021,6 +1021,9 @@ clutter_event_get_event_sequence (const ClutterEvent *event)
event->type == CLUTTER_TOUCH_END ||
event->type == CLUTTER_TOUCH_CANCEL)
return event->touch.sequence;
else if (event->type == CLUTTER_ENTER ||
event->type == CLUTTER_LEAVE)
return event->crossing.sequence;
return NULL;
}

View File

@ -269,6 +269,7 @@ struct _ClutterCrossingEvent
gfloat x;
gfloat y;
ClutterInputDevice *device;
ClutterEventSequence *sequence;
ClutterActor *related;
};

View File

@ -64,17 +64,13 @@ clutter_features_from_cogl (guint cogl_flags)
{
ClutterFeatureFlags clutter_flags = 0;
if (cogl_flags & COGL_FEATURE_TEXTURE_NPOT)
clutter_flags |= CLUTTER_FEATURE_TEXTURE_NPOT;
if (cogl_flags & COGL_FEATURE_TEXTURE_YUV)
clutter_flags |= CLUTTER_FEATURE_TEXTURE_YUV;
if (cogl_flags & COGL_FEATURE_TEXTURE_READ_PIXELS)
clutter_flags |= CLUTTER_FEATURE_TEXTURE_READ_PIXELS;
if (cogl_flags & COGL_FEATURE_SHADERS_GLSL)
clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL;
clutter_flags |= CLUTTER_FEATURE_SHADERS_GLSL;
if (cogl_flags & COGL_FEATURE_OFFSCREEN)
clutter_flags |= CLUTTER_FEATURE_OFFSCREEN;

View File

@ -834,6 +834,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device,
event->crossing.x = device->current_x;
event->crossing.y = device->current_y;
event->crossing.related = actor;
event->crossing.sequence = sequence;
clutter_event_set_device (event, device);
/* we need to make sure that this event is processed
@ -870,6 +871,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device,
event->crossing.y = device->current_y;
event->crossing.source = actor;
event->crossing.related = old_actor;
event->crossing.sequence = sequence;
clutter_event_set_device (event, device);
/* see above */
@ -1034,9 +1036,10 @@ _clutter_input_device_update (ClutterInputDevice *device,
ClutterActor *new_cursor_actor;
ClutterActor *old_cursor_actor;
ClutterPoint point = { -1, -1 };
ClutterInputDeviceType device_type = device->device_type;
if (device->device_type == CLUTTER_KEYBOARD_DEVICE)
return NULL;
g_assert (device_type != CLUTTER_KEYBOARD_DEVICE &&
device_type != CLUTTER_PAD_DEVICE);
stage = device->stage;
if (G_UNLIKELY (stage == NULL))

View File

@ -2004,6 +2004,36 @@ emit_pointer_event (ClutterEvent *event,
}
}
static inline void
emit_crossing_event (ClutterEvent *event,
ClutterInputDevice *device)
{
ClutterMainContext *context = _clutter_context_get_default ();
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
ClutterActor *grab_actor = NULL;
if (_clutter_event_process_filters (event))
return;
if (sequence)
{
if (device->sequence_grab_actors != NULL)
grab_actor = g_hash_table_lookup (device->sequence_grab_actors, sequence);
}
else
{
if (context->pointer_grab_actor != NULL)
grab_actor = context->pointer_grab_actor;
else if (device != NULL && device->pointer_grab_actor != NULL)
grab_actor = device->pointer_grab_actor;
}
if (grab_actor != NULL)
clutter_actor_event (grab_actor, event, FALSE);
else
emit_event_chain (event);
}
static inline void
emit_touch_event (ClutterEvent *event,
ClutterInputDevice *device)
@ -2177,7 +2207,7 @@ _clutter_process_event_details (ClutterActor *stage,
{
ClutterActor *actor = NULL;
emit_pointer_event (event, device);
emit_crossing_event (event, device);
actor = _clutter_input_device_update (device, NULL, FALSE);
if (actor != stage)
@ -2189,12 +2219,12 @@ _clutter_process_event_details (ClutterActor *stage,
crossing->crossing.related = stage;
crossing->crossing.source = actor;
emit_pointer_event (crossing, device);
emit_crossing_event (crossing, device);
clutter_event_free (crossing);
}
}
else
emit_pointer_event (event, device);
emit_crossing_event (event, device);
break;
case CLUTTER_LEAVE:
@ -2213,10 +2243,10 @@ _clutter_process_event_details (ClutterActor *stage,
crossing->crossing.related = stage;
crossing->crossing.source = device->cursor_actor;
emit_pointer_event (crossing, device);
emit_crossing_event (crossing, device);
clutter_event_free (crossing);
}
emit_pointer_event (event, device);
emit_crossing_event (event, device);
break;
case CLUTTER_DESTROY_NOTIFY:

View File

@ -412,8 +412,7 @@ master_clock_advance_timelines (ClutterMasterClockDefault *master_clock)
for (l = timelines; l != NULL; l = l->next)
_clutter_timeline_do_tick (l->data, master_clock->cur_tick / 1000);
g_slist_foreach (timelines, (GFunc) g_object_unref, NULL);
g_slist_free (timelines);
g_slist_free_full (timelines, g_object_unref);
#ifdef CLUTTER_ENABLE_DEBUG
if (_clutter_diagnostic_enabled ())
@ -574,8 +573,7 @@ clutter_clock_dispatch (GSource *source,
master_clock_reschedule_stage_updates (master_clock, stages);
g_slist_foreach (stages, (GFunc) g_object_unref, NULL);
g_slist_free (stages);
g_slist_free_full (stages, g_object_unref);
master_clock->prev_tick = master_clock->cur_tick;

View File

@ -75,8 +75,7 @@ _clutter_paint_node_init_types (void)
cogl_pipeline_set_color (default_color_pipeline, &cogl_color);
default_texture_pipeline = cogl_pipeline_new (ctx);
cogl_pipeline_set_layer_null_texture (default_texture_pipeline, 0,
COGL_TEXTURE_TYPE_2D);
cogl_pipeline_set_layer_null_texture (default_texture_pipeline, 0);
cogl_pipeline_set_color (default_texture_pipeline, &cogl_color);
cogl_pipeline_set_layer_wrap_mode (default_texture_pipeline, 0,
COGL_PIPELINE_WRAP_MODE_AUTOMATIC);

View File

@ -295,8 +295,7 @@ clutter_path_clear (ClutterPath *path)
{
ClutterPathPrivate *priv = path->priv;
g_slist_foreach (priv->nodes, (GFunc) clutter_path_node_full_free, NULL);
g_slist_free (priv->nodes);
g_slist_free_full (priv->nodes, (GDestroyNotify) clutter_path_node_full_free);
priv->nodes = priv->nodes_tail = NULL;
priv->nodes_dirty = TRUE;
@ -659,8 +658,7 @@ clutter_path_parse_description (const gchar *p,
return TRUE;
fail:
g_slist_foreach (nodes, (GFunc) clutter_path_node_full_free, NULL);
g_slist_free (nodes);
g_slist_free_full (nodes, (GDestroyNotify) clutter_path_node_full_free);
return FALSE;
}

View File

@ -303,6 +303,11 @@ gboolean _clutter_util_matrix_decompose (const ClutterMatrix *src,
ClutterVertex *translate_p,
ClutterVertex4 *perspective_p);
PangoDirection _clutter_pango_unichar_direction (gunichar ch);
PangoDirection _clutter_pango_find_base_dir (const gchar *text,
gint length);
typedef struct _ClutterPlane
{
float v0[3];

View File

@ -2021,8 +2021,7 @@ add_children (ClutterScript *script,
clutter_container_add_actor (container, CLUTTER_ACTOR (object));
}
g_list_foreach (oinfo->children, (GFunc) g_free, NULL);
g_list_free (oinfo->children);
g_list_free_full (oinfo->children, g_free);
oinfo->children = unresolved;
}

View File

@ -346,15 +346,12 @@ object_info_free (gpointer data)
g_free (oinfo->class_name);
g_free (oinfo->type_func);
g_list_foreach (oinfo->properties, (GFunc) property_info_free, NULL);
g_list_free (oinfo->properties);
g_list_free_full (oinfo->properties, property_info_free);
g_list_foreach (oinfo->signals, (GFunc) signal_info_free, NULL);
g_list_free (oinfo->signals);
g_list_free_full (oinfo->signals, signal_info_free);
/* these are ids */
g_list_foreach (oinfo->children, (GFunc) g_free, NULL);
g_list_free (oinfo->children);
g_list_free_full (oinfo->children, g_free);
/* we unref top-level objects and leave the actors alone,
* unless we are unmerging in which case we have to destroy
@ -846,8 +843,7 @@ clutter_script_unmerge_objects (ClutterScript *script,
for (l = data.ids; l != NULL; l = l->next)
g_hash_table_remove (priv->objects, l->data);
g_slist_foreach (data.ids, (GFunc) g_free, NULL);
g_slist_free (data.ids);
g_slist_free_full (data.ids, g_free);
clutter_script_ensure_objects (script);
}

View File

@ -89,8 +89,8 @@ clutter_stage_manager_dispose (GObject *gobject)
stage_manager = CLUTTER_STAGE_MANAGER (gobject);
g_slist_foreach (stage_manager->stages, (GFunc) clutter_actor_destroy, NULL);
g_slist_free (stage_manager->stages);
g_slist_free_full (stage_manager->stages,
(GDestroyNotify) clutter_actor_destroy);
stage_manager->stages = NULL;
G_OBJECT_CLASS (clutter_stage_manager_parent_class)->dispose (gobject);

View File

@ -1303,14 +1303,8 @@ clutter_stage_real_queue_redraw (ClutterActor *actor,
return TRUE;
if (_clutter_stage_window_ignoring_redraw_clips (stage_window))
{
_clutter_stage_window_add_redraw_clip (stage_window, NULL);
return FALSE;
}
return FALSE;
/* Convert the clip volume into stage coordinates and then into an
* axis aligned stage coordinates bounding box...
*/
if (redraw_clip == NULL)
{
_clutter_stage_window_add_redraw_clip (stage_window, NULL);
@ -1320,6 +1314,8 @@ clutter_stage_real_queue_redraw (ClutterActor *actor,
if (redraw_clip->is_empty)
return TRUE;
/* Convert the clip volume into stage coordinates and then into an
* axis aligned stage coordinates bounding box... */
_clutter_paint_volume_get_stage_paint_box (redraw_clip,
stage,
&bounding_box);

View File

@ -751,7 +751,7 @@ clutter_text_create_layout_no_cache (ClutterText *text,
if (priv->password_char != 0)
pango_dir = PANGO_DIRECTION_NEUTRAL;
else
pango_dir = pango_find_base_dir (contents, contents_len);
pango_dir = _clutter_pango_find_base_dir (contents, contents_len);
if (pango_dir == PANGO_DIRECTION_NEUTRAL)
{
@ -1975,6 +1975,7 @@ selection_paint (ClutterText *self,
else
{
/* Paint selection background first */
CoglPipeline *color_pipeline = cogl_pipeline_copy (default_color_pipeline);
PangoLayout *layout = clutter_text_get_layout (self);
CoglPath *selection_path = cogl_path_new ();
CoglColor cogl_color = { 0, };
@ -1987,11 +1988,19 @@ selection_paint (ClutterText *self,
else
color = &priv->text_color;
cogl_color_init_from_4ub (&cogl_color,
color->red,
color->green,
color->blue,
paint_opacity * color->alpha / 255);
cogl_color_premultiply (&cogl_color);
cogl_pipeline_set_color (color_pipeline, &cogl_color);
clutter_text_foreach_selection_rectangle_prescaled (self,
add_selection_rectangle_to_path,
selection_path);
cogl_path_fill (selection_path);
cogl_framebuffer_fill_path (fb, color_pipeline, selection_path);
/* Paint selected text */
cogl_framebuffer_push_path_clip (fb, selection_path);

View File

@ -32,6 +32,7 @@
#include "clutter-build-config.h"
#include <fribidi.h>
#include <math.h>
#include "clutter-debug.h"
@ -105,8 +106,9 @@ _clutter_util_fully_transform_vertices (const CoglMatrix *modelview,
}
}
void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
ClutterRect *dest)
void
_clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
ClutterRect *dest)
{
*dest = (ClutterRect) {
.origin = {
@ -120,8 +122,9 @@ void _clutter_util_rect_from_rectangle (const cairo_rectangle_int_t *src,
};
}
void _clutter_util_rectangle_int_extents (const ClutterRect *src,
cairo_rectangle_int_t *dest)
void
_clutter_util_rectangle_int_extents (const ClutterRect *src,
cairo_rectangle_int_t *dest)
{
ClutterRect tmp = *src;
@ -135,10 +138,11 @@ void _clutter_util_rectangle_int_extents (const ClutterRect *src,
};
}
void _clutter_util_rectangle_offset (const cairo_rectangle_int_t *src,
int x,
int y,
cairo_rectangle_int_t *dest)
void
_clutter_util_rectangle_offset (const cairo_rectangle_int_t *src,
int x,
int y,
cairo_rectangle_int_t *dest)
{
*dest = *src;
@ -696,3 +700,45 @@ clutter_interval_register_progress_func (GType value_type,
G_UNLOCK (progress_funcs);
}
PangoDirection
_clutter_pango_unichar_direction (gunichar ch)
{
FriBidiCharType fribidi_ch_type;
G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
fribidi_ch_type = fribidi_get_bidi_type (ch);
if (!FRIBIDI_IS_STRONG (fribidi_ch_type))
return PANGO_DIRECTION_NEUTRAL;
else if (FRIBIDI_IS_RTL (fribidi_ch_type))
return PANGO_DIRECTION_RTL;
else
return PANGO_DIRECTION_LTR;
}
PangoDirection
_clutter_pango_find_base_dir (const gchar *text,
gint length)
{
PangoDirection dir = PANGO_DIRECTION_NEUTRAL;
const gchar *p;
g_return_val_if_fail (text != NULL || length == 0, PANGO_DIRECTION_NEUTRAL);
p = text;
while ((length < 0 || p < text + length) && *p)
{
gunichar wc = g_utf8_get_char (p);
dir = _clutter_pango_unichar_direction (wc);
if (dir != PANGO_DIRECTION_NEUTRAL)
break;
p = g_utf8_next_char (p);
}
return dir;
}

View File

@ -77,6 +77,10 @@ enum
PROP_LAST
};
static void
clutter_stage_cogl_schedule_update (ClutterStageWindow *stage_window,
gint sync_delay);
static void
clutter_stage_cogl_unrealize (ClutterStageWindow *stage_window)
{
@ -122,6 +126,16 @@ _clutter_stage_cogl_presented (ClutterStageCogl *stage_cogl,
}
_clutter_stage_presented (stage_cogl->wrapper, frame_event, frame_info);
if (frame_event == COGL_FRAME_EVENT_COMPLETE &&
stage_cogl->update_time != -1)
{
ClutterStageWindow *stage_window = CLUTTER_STAGE_WINDOW (stage_cogl);
stage_cogl->update_time = -1;
clutter_stage_cogl_schedule_update (stage_window,
stage_cogl->last_sync_delay);
}
}
static gboolean
@ -152,10 +166,15 @@ clutter_stage_cogl_schedule_update (ClutterStageWindow *stage_window,
gint64 now;
float refresh_rate;
gint64 refresh_interval;
int64_t min_render_time_allowed;
int64_t max_render_time_allowed;
int64_t next_presentation_time;
if (stage_cogl->update_time != -1)
return;
stage_cogl->last_sync_delay = sync_delay;
now = g_get_monotonic_time ();
if (sync_delay < 0)
@ -184,10 +203,18 @@ clutter_stage_cogl_schedule_update (ClutterStageWindow *stage_window,
if (refresh_interval == 0)
refresh_interval = 16667; /* 1/60th second */
stage_cogl->update_time = stage_cogl->last_presentation_time + 1000 * sync_delay;
min_render_time_allowed = refresh_interval / 2;
max_render_time_allowed = refresh_interval - 1000 * sync_delay;
while (stage_cogl->update_time < now)
stage_cogl->update_time += refresh_interval;
if (min_render_time_allowed > max_render_time_allowed)
min_render_time_allowed = max_render_time_allowed;
next_presentation_time = stage_cogl->last_presentation_time + refresh_interval;
while (next_presentation_time < now + min_render_time_allowed)
next_presentation_time += refresh_interval;
stage_cogl->update_time = next_presentation_time - max_render_time_allowed;
}
static gint64
@ -273,7 +300,7 @@ clutter_stage_cogl_ignoring_redraw_clips (ClutterStageWindow *stage_window)
}
/* A redraw clip represents (in stage coordinates) the bounding box of
* something that needs to be redraw. Typically they are added to the
* something that needs to be redrawn. Typically they are added to the
* StageWindow as a result of clutter_actor_queue_clipped_redraw() by
* actors such as ClutterGLXTexturePixmap. All redraw clips are
* discarded after the next paint.
@ -502,8 +529,8 @@ fill_current_damage_history_and_step (ClutterStageView *view)
*current_fb_damage = (cairo_rectangle_int_t) {
.x = 0,
.y = 0,
.width = view_rect.width * fb_scale,
.height = view_rect.height * fb_scale
.width = ceilf (view_rect.width * fb_scale),
.height = ceilf (view_rect.height * fb_scale)
};
view_priv->damage_index++;
}

View File

@ -59,6 +59,8 @@ struct _ClutterStageCogl
* junk frames to start with. */
unsigned int frame_count;
gint last_sync_delay;
cairo_rectangle_int_t bounding_redraw_clip;
guint initialized_redraw_clip : 1;

View File

@ -1277,9 +1277,7 @@ clutter_texture_init (ClutterTexture *self)
texture_template_pipeline = cogl_pipeline_new (ctx);
pipeline = COGL_PIPELINE (texture_template_pipeline);
cogl_pipeline_set_layer_null_texture (pipeline,
0, /* layer_index */
COGL_TEXTURE_TYPE_2D);
cogl_pipeline_set_layer_null_texture (pipeline, 0);
}
g_assert (texture_template_pipeline != NULL);

View File

@ -855,6 +855,14 @@ emulate_pointer_motion (ClutterInputDeviceEvdev *device,
clutter_virtual_input_device_notify_relative_motion (device->mousekeys_virtual_device,
time_us, dx_motion, dy_motion);
}
static gboolean
is_numlock_active (ClutterInputDeviceEvdev *device)
{
ClutterSeatEvdev *seat = device->seat;
return xkb_state_mod_name_is_active (seat->xkb,
"Mod2",
XKB_STATE_MODS_LOCKED);
}
static void
enable_mousekeys (ClutterInputDeviceEvdev *device)
@ -1013,6 +1021,10 @@ handle_mousekeys_press (ClutterEvent *event,
if (!(event->key.flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
stop_mousekeys_move (device);
/* Do not handle mousekeys if NumLock is ON */
if (is_numlock_active (device))
return FALSE;
/* Button selection */
switch (event->key.keyval)
{
@ -1084,6 +1096,10 @@ static gboolean
handle_mousekeys_release (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
{
/* Do not handle mousekeys if NumLock is ON */
if (is_numlock_active (device))
return FALSE;
switch (event->key.keyval)
{
case XKB_KEY_KP_0:

View File

@ -54,6 +54,7 @@
#include "clutter-main.h"
#include "clutter-private.h"
#include "clutter-settings-private.h"
#include "clutter-xkb-a11y-x11.h"
G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND)
@ -276,6 +277,20 @@ clutter_backend_x11_create_device_manager (ClutterBackendX11 *backend_x11)
_clutter_backend_add_event_translator (backend, translator);
}
static void
on_keymap_state_change (ClutterKeymapX11 *keymap_x11,
gpointer data)
{
ClutterDeviceManager *device_manager = CLUTTER_DEVICE_MANAGER (data);
ClutterKbdA11ySettings kbd_a11y_settings;
/* On keymaps state change, just reapply the current settings, it'll
* take care of enabling/disabling mousekeys based on NumLock state.
*/
clutter_device_manager_get_kbd_a11y_settings (device_manager, &kbd_a11y_settings);
clutter_device_manager_x11_apply_kbd_a11y_settings (device_manager, &kbd_a11y_settings);
}
static void
clutter_backend_x11_create_keymap (ClutterBackendX11 *backend_x11)
{
@ -292,6 +307,11 @@ clutter_backend_x11_create_keymap (ClutterBackendX11 *backend_x11)
backend = CLUTTER_BACKEND (backend_x11);
translator = CLUTTER_EVENT_TRANSLATOR (backend_x11->keymap);
_clutter_backend_add_event_translator (backend, translator);
g_signal_connect (backend_x11->keymap,
"state-changed",
G_CALLBACK (on_keymap_state_change),
backend->device_manager);
}
}

View File

@ -250,7 +250,8 @@ get_direction (XkbDescPtr xkb,
{
int level = 0;
KeySym sym = XkbKeySymEntry (xkb, code, level, group);
PangoDirection dir = pango_unichar_direction (clutter_keysym_to_unicode (sym));
PangoDirection dir =
_clutter_pango_unichar_direction (clutter_keysym_to_unicode (sym));
switch (dir)
{

View File

@ -241,8 +241,13 @@ clutter_device_manager_x11_apply_kbd_a11y_settings (ClutterDeviceManager *devi
}
/* mouse keys */
if (set_xkb_ctrl (desc, kbd_a11y_settings->controls,
CLUTTER_A11Y_MOUSE_KEYS_ENABLED, XkbMouseKeysMask | XkbMouseKeysAccelMask))
if (clutter_keymap_get_num_lock_state (CLUTTER_KEYMAP (backend_x11->keymap)))
{
/* Disable mousekeys when NumLock is ON */
desc->ctrls->enabled_ctrls &= ~(XkbMouseKeysMask | XkbMouseKeysAccelMask);
}
else if (set_xkb_ctrl (desc, kbd_a11y_settings->controls,
CLUTTER_A11Y_MOUSE_KEYS_ENABLED, XkbMouseKeysMask | XkbMouseKeysAccelMask))
{
gint mk_max_speed;
gint mk_accel_time;

View File

@ -1,7 +1,5 @@
clutter_includesubdir = join_paths(pkgname, 'clutter')
clutter_includedir = join_paths(includedir, clutter_includesubdir)
clutter_srcdir = join_paths(top_srcdir, 'clutter')
clutter_builddir = join_paths(builddir, 'clutter')
clutter_includepath = include_directories('.', 'clutter')
clutter_includes = [clutter_includepath, cogl_includepath]
@ -40,6 +38,7 @@ clutter_pkg_deps = [
]
clutter_pkg_private_deps = [
fribidi_dep,
gdk_pixbuf_dep,
gthread_dep,
gmodule_no_export_dep,

View File

@ -114,12 +114,12 @@ test_destroy_destroy (ClutterActor *self)
test->tex = NULL;
}
g_list_foreach (test->children, (GFunc) clutter_actor_destroy, NULL);
g_list_free (test->children);
test->children = NULL;
g_assert_nonnull (test->children);
if (CLUTTER_ACTOR_CLASS (test_destroy_parent_class)->destroy)
CLUTTER_ACTOR_CLASS (test_destroy_parent_class)->destroy (self);
g_assert_null (test->children);
}
static void

View File

@ -1,6 +1,3 @@
clutter_tests_conform_srcdir = join_paths(clutter_srcdir, 'tests/conform')
clutter_tests_conform_builddir = join_paths(clutter_builddir, 'tests/conform')
clutter_tests_conform_c_args = [
'-DG_LOG_DOMAIN="Clutter-Conform"',
'-DCOGL_DISABLE_DEPRECATION_WARNINGS',
@ -52,8 +49,8 @@ clutter_conform_tests += clutter_conform_tests_general_tests
clutter_conform_tests += clutter_conform_tests_deprecated_tests
test_env = environment()
test_env.set('G_TEST_SRCDIR', clutter_tests_conform_srcdir)
test_env.set('G_TEST_BUILDDIR', clutter_tests_conform_builddir)
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
test_env.set('G_ENABLE_DIAGNOSTIC', '0')
test_env.set('CLUTTER_ENABLE_DIAGNOSTIC', '0')
test_env.set('CLUTTER_SCALE', '1')
@ -74,7 +71,8 @@ foreach test : clutter_conform_tests
install: false,
)
test('clutter/conform/@0@'.format(test), test_executable,
test(test, test_executable,
suite: ['clutter', 'clutter/conform'],
env: test_env
)
endforeach

View File

@ -38,8 +38,7 @@ timeline_data_init (TimelineData *data, int timeline_num)
static void
timeline_data_destroy (TimelineData *data)
{
g_slist_foreach (data->markers_hit, (GFunc) g_free, NULL);
g_slist_free (data->markers_hit);
g_slist_free_full (data->markers_hit, g_free);
}
static void

View File

@ -1,7 +1,5 @@
clutter_tests_interactive_srcdir = join_paths(clutter_srcdir, 'tests/interactive')
clutter_tests_interactive_srcdir = meson.current_source_dir()
clutter_tests_interactive_includepath = include_directories('.')
#clutter_tests_interactive_builddir = join_paths(clutter_builddir, 'tests/interactive')
clutter_tests_interactive_c_args = [
'-DTESTS_DATADIR="@0@"'.format(clutter_tests_interactive_srcdir),
@ -31,7 +29,6 @@ clutter_tests_interactive_test_sources = [
'test-fbo.c',
'test-cogl-tex-tile.c',
'test-cogl-tex-convert.c',
'test-cogl-tex-foreign.c',
'test-cogl-offscreen.c',
'test-cogl-tex-polygon.c',
'test-cogl-multitexture.c',

View File

@ -1,276 +0,0 @@
#include <glib.h>
#include <gmodule.h>
#include <stdlib.h>
#include <clutter/clutter.h>
#include <cogl/cogl.h>
#ifndef GL_UNPACK_ALIGNMENT
#define GL_UNPACK_ALIGNMENT 0x0CF5
#endif
#ifndef GL_TEXTURE_BINDING_2D
#define GL_TEXTURE_BINDING_2D 0x8069
#endif
#ifndef GL_TEXTURE_2D
#define GL_TEXTURE_2D 0x0DE1
#endif
#ifndef GL_RGB
#define GL_RGB 0x1907
#endif
#ifndef GL_UNSIGNED_BYTE
#define GL_UNSIGNED_BYTE 0x1401
#endif
#ifndef GL_TEXTURE_MAG_FILTER
#define GL_TEXTURE_MAG_FILTER 0x2800
#endif
#ifndef GL_LINEAR
#define GL_LINEAR 0x1208
#endif
#ifndef GL_TEXTURE_MIN_FILTER
#define GL_TEXTURE_MIN_FILTER 0x2801
#endif
/* Coglbox declaration
*--------------------------------------------------*/
G_BEGIN_DECLS
#define TEST_TYPE_COGLBOX test_coglbox_get_type()
#define TEST_COGLBOX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
TEST_TYPE_COGLBOX, TestCoglboxClass))
#define TEST_COGLBOX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
TEST_TYPE_COGLBOX, TestCoglboxClass))
#define TEST_IS_COGLBOX(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
TEST_TYPE_COGLBOX))
#define TEST_IS_COGLBOX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
TEST_TYPE_COGLBOX))
#define TEST_COGLBOX_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
TEST_TYPE_COGLBOX, TestCoglboxClass))
typedef struct _TestCoglbox TestCoglbox;
typedef struct _TestCoglboxClass TestCoglboxClass;
typedef struct _TestCoglboxPrivate TestCoglboxPrivate;
const char *
test_cogl_tex_foreign_describe (void);
struct _TestCoglbox
{
ClutterActor parent;
/*< private >*/
TestCoglboxPrivate *priv;
};
struct _TestCoglboxClass
{
ClutterActorClass parent_class;
/* padding for future expansion */
void (*_test_coglbox1) (void);
void (*_test_coglbox2) (void);
void (*_test_coglbox3) (void);
void (*_test_coglbox4) (void);
};
static GType test_coglbox_get_type (void) G_GNUC_CONST;
G_END_DECLS
/* Coglbox private declaration
*--------------------------------------------------*/
struct _TestCoglboxPrivate
{
guint gl_handle;
CoglHandle cogl_handle;
void
(* glGetIntegerv) (guint pname, int *params);
void
(* glPixelStorei) (guint pname, int param);
void
(* glTexParameteri) (guint target, guint pname, int param);
void
(* glTexImage2D) (guint target, int level,
int internalFormat,
int width, int height,
int border, guint format, guint type,
const void *pixels);
void
(* glGenTextures) (int n, guint *textures);
void
(* glDeleteTextures) (int n, const guint *textures);
void
(* glBindTexture) (guint target, guint texture);
};
G_DEFINE_TYPE_WITH_PRIVATE (TestCoglbox, test_coglbox, CLUTTER_TYPE_ACTOR);
#define TEST_COGLBOX_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), TEST_TYPE_COGLBOX, TestCoglboxPrivate))
int
test_cogl_tex_foreign_main (int argc, char *argv[]);
/* Coglbox implementation
*--------------------------------------------------*/
static void
test_coglbox_paint(ClutterActor *self)
{
TestCoglboxPrivate *priv = TEST_COGLBOX_GET_PRIVATE (self);
gfloat texcoords[4] = { 0.3f, 0.3f, 0.7f, 0.7f };
cogl_set_source_color4ub (0x66, 0x66, 0xdd, 0xff);
cogl_rectangle (0,0,400,400);
cogl_push_matrix ();
cogl_translate (100,100,0);
cogl_set_source_texture (priv->cogl_handle);
cogl_rectangle_with_texture_coords (0, 0, 200, 200,
texcoords[0], texcoords[1],
texcoords[2], texcoords[3]);
cogl_pop_matrix();
}
static void
test_coglbox_finalize (GObject *object)
{
G_OBJECT_CLASS (test_coglbox_parent_class)->finalize (object);
}
static void
test_coglbox_dispose (GObject *object)
{
TestCoglboxPrivate *priv;
priv = TEST_COGLBOX_GET_PRIVATE (object);
cogl_handle_unref (priv->cogl_handle);
priv->glDeleteTextures (1, &priv->gl_handle);
G_OBJECT_CLASS (test_coglbox_parent_class)->dispose (object);
}
static void
test_coglbox_init (TestCoglbox *self)
{
TestCoglboxPrivate *priv;
guchar data[12];
int prev_unpack_alignment;
int prev_2d_texture_binding;
self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self);
/* Prepare a 2x2 pixels texture */
data[0] = 255; data[1] = 0; data[2] = 0;
data[3] = 0; data[4] = 255; data[5] = 0;
data[6] = 0; data[7] = 0; data[8] = 255;
data[9] = 0; data[10] = 0; data[11] = 0;
priv->glGetIntegerv = (void *) cogl_get_proc_address ("glGetIntegerv");
priv->glPixelStorei = (void *) cogl_get_proc_address ("glPixelStorei");
priv->glTexParameteri = (void *) cogl_get_proc_address ("glTexParameteri");
priv->glTexImage2D = (void *) cogl_get_proc_address ("glTexImage2D");
priv->glGenTextures = (void *) cogl_get_proc_address ("glGenTextures");
priv->glDeleteTextures = (void *) cogl_get_proc_address ("glDeleteTextures");
priv->glBindTexture = (void *) cogl_get_proc_address ("glBindTexture");
/* We are about to use OpenGL directly to create a TEXTURE_2D
* texture so we need to save the state that we modify so we can
* restore it afterwards and be sure not to interfere with any state
* caching that Cogl may do internally.
*/
priv->glGetIntegerv (GL_UNPACK_ALIGNMENT, &prev_unpack_alignment);
priv->glGetIntegerv (GL_TEXTURE_BINDING_2D, &prev_2d_texture_binding);
priv->glGenTextures (1, &priv->gl_handle);
priv->glBindTexture (GL_TEXTURE_2D, priv->gl_handle);
priv->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
priv->glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB,
2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
/* Now restore the original GL state as Cogl had left it */
priv->glPixelStorei (GL_UNPACK_ALIGNMENT, prev_unpack_alignment);
priv->glBindTexture (GL_TEXTURE_2D, prev_2d_texture_binding);
priv->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
priv->glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
/* Create texture from foreign */
priv->cogl_handle =
cogl_texture_new_from_foreign (priv->gl_handle,
GL_TEXTURE_2D,
2, 2, 0, 0,
COGL_PIXEL_FORMAT_RGB_888);
if (priv->cogl_handle == COGL_INVALID_HANDLE)
{
printf ("Failed creating texture from foreign!\n");
return;
}
}
static void
test_coglbox_class_init (TestCoglboxClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
gobject_class->finalize = test_coglbox_finalize;
gobject_class->dispose = test_coglbox_dispose;
actor_class->paint = test_coglbox_paint;
}
static ClutterActor*
test_coglbox_new (void)
{
return g_object_new (TEST_TYPE_COGLBOX, NULL);
}
G_MODULE_EXPORT int
test_cogl_tex_foreign_main (int argc, char *argv[])
{
ClutterActor *stage;
ClutterActor *coglbox;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;
/* Stage */
stage = clutter_stage_new ();
clutter_actor_set_size (stage, 400, 400);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Cogl Foreign Textures");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
/* Cogl Box */
coglbox = test_coglbox_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (stage), coglbox);
clutter_actor_show_all (stage);
clutter_main ();
return 0;
}
G_MODULE_EXPORT const char *
test_cogl_tex_foreign_describe (void)
{
return "Foreign textures support in Cogl.";
}

View File

@ -1,5 +1,5 @@
clutter_tests_performance_c_args = [
'-DTESTS_DATA_DIR="@0@"'.format(join_paths(clutter_srcdir, 'tests/interactive')),
'-DTESTS_DATA_DIR="@0@"'.format(clutter_tests_interactive_srcdir),
'-DG_DISABLE_SINGLE_INCLUDES',
'-DGLIB_DISABLE_DEPRECATION_WARNINGS',
'-DCOGL_DISABLE_DEPRECATION_WARNINGS',

View File

@ -483,8 +483,8 @@ _cogl_pango_display_list_node_free (CoglPangoDisplayListNode *node)
void
_cogl_pango_display_list_clear (CoglPangoDisplayList *dl)
{
g_slist_foreach (dl->nodes, (GFunc) _cogl_pango_display_list_node_free, NULL);
g_slist_free (dl->nodes);
g_slist_free_full (dl->nodes, (GDestroyNotify)
_cogl_pango_display_list_node_free);
dl->nodes = NULL;
dl->last_node = NULL;
}

View File

@ -460,9 +460,7 @@ cogl_path_fill (CoglPath *path);
* use while filling a path.</note>
*
* Stability: unstable
* Deprecated: 1.16: Use cogl_path_fill() instead
*/
COGL_DEPRECATED_FOR (cogl_path_fill)
void
cogl_framebuffer_fill_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
@ -492,9 +490,7 @@ cogl_path_stroke (CoglPath *path);
* regardless of the current transformation matrix.
*
* Stability: unstable
* Deprecated: 1.16: Use cogl_path_stroke() instead
*/
COGL_DEPRECATED_FOR (cogl_path_stroke)
void
cogl_framebuffer_stroke_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
@ -529,9 +525,7 @@ cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer,
*
* Since: 1.8
* Stability: Unstable
* Deprecated: 1.16: Use cogl_framebuffer_push_path_clip() instead
*/
COGL_DEPRECATED_FOR (cogl_framebuffer_push_path_clip)
void
cogl_clip_push_from_path (CoglPath *path);

View File

@ -1504,7 +1504,6 @@ cogl_framebuffer_push_path_clip (CoglFramebuffer *framebuffer,
COGL_FRAMEBUFFER_STATE_CLIP;
}
/* XXX: deprecated */
void
cogl_clip_push_from_path (CoglPath *path)
{
@ -1575,7 +1574,6 @@ _cogl_path_build_stroke_attribute_buffer (CoglPath *path)
data->stroke_n_attributes = n_attributes;
}
/* XXX: deprecated */
void
cogl_framebuffer_fill_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,
@ -1588,7 +1586,6 @@ cogl_framebuffer_fill_path (CoglFramebuffer *framebuffer,
_cogl_path_fill_nodes (path, framebuffer, pipeline, 0 /* flags */);
}
/* XXX: deprecated */
void
cogl_framebuffer_stroke_path (CoglFramebuffer *framebuffer,
CoglPipeline *pipeline,

View File

@ -1013,12 +1013,6 @@ _cogl_atlas_texture_remove_reorganize_callback (CoglContext *ctx,
g_hook_destroy_link (&ctx->atlas_reorganize_callbacks, hook);
}
static CoglTextureType
_cogl_atlas_texture_get_type (CoglTexture *tex)
{
return COGL_TEXTURE_TYPE_2D;
}
static const CoglTextureVtable
cogl_atlas_texture_vtable =
{
@ -1040,7 +1034,6 @@ cogl_atlas_texture_vtable =
_cogl_atlas_texture_gl_flush_legacy_texobj_wrap_modes,
_cogl_atlas_texture_get_format,
_cogl_atlas_texture_get_gl_format,
_cogl_atlas_texture_get_type,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
};

View File

@ -562,29 +562,21 @@ create_migration_texture (CoglContext *ctx,
CoglTexture *tex;
CoglError *skip_error = NULL;
if ((_cogl_util_is_pot (width) && _cogl_util_is_pot (height)) ||
(cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP)))
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx, width, height));
_cogl_texture_set_internal_format (tex, internal_format);
/* TODO: instead of allocating storage here it would be better
* if we had some api that let us just check that the size is
* supported by the hardware so storage could be allocated
* lazily when uploading data. */
if (!cogl_texture_allocate (tex, &skip_error))
{
/* First try creating a fast-path non-sliced texture */
tex = COGL_TEXTURE (cogl_texture_2d_new_with_size (ctx,
width, height));
_cogl_texture_set_internal_format (tex, internal_format);
/* TODO: instead of allocating storage here it would be better
* if we had some api that let us just check that the size is
* supported by the hardware so storage could be allocated
* lazily when uploading data. */
if (!cogl_texture_allocate (tex, &skip_error))
{
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
cogl_error_free (skip_error);
cogl_object_unref (tex);
tex = NULL;
}
else
tex = NULL;
if (!tex)
{

View File

@ -43,6 +43,7 @@ typedef struct _CoglBitmap CoglBitmap;
#include <cogl/cogl-buffer.h>
#include <cogl/cogl-context.h>
#include <cogl/cogl-pixel-buffer.h>
#include <cogl/cogl-pixel-format.h>
#include <glib-object.h>

View File

@ -50,8 +50,6 @@
#include "cogl-texture-driver.h"
#include "cogl-pipeline-cache.h"
#include "cogl-texture-2d.h"
#include "cogl-texture-3d.h"
#include "cogl-texture-rectangle.h"
#include "cogl-sampler-cache-private.h"
#include "cogl-gpu-info-private.h"
#include "cogl-gl-header.h"
@ -103,9 +101,6 @@ struct _CoglContext
unsigned long private_features
[COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_N_PRIVATE_FEATURES)];
gboolean needs_viewport_scissor_workaround;
CoglFramebuffer *viewport_scissor_workaround_framebuffer;
CoglPipeline *default_pipeline;
CoglPipelineLayer *default_layer_0;
CoglPipelineLayer *default_layer_n;
@ -169,8 +164,6 @@ struct _CoglContext
/* Textures */
CoglTexture2D *default_gl_texture_2d_tex;
CoglTexture3D *default_gl_texture_3d_tex;
CoglTextureRectangle *default_gl_texture_rect_tex;
/* Central list of all framebuffers so all journals can be flushed
* at any time. */
@ -269,7 +262,6 @@ struct _CoglContext
GLuint current_gl_program;
gboolean current_gl_dither_enabled;
CoglColorMask current_gl_color_mask;
GLenum current_gl_draw_buffer;
/* Clipping */
@ -301,8 +293,6 @@ struct _CoglContext
gboolean buffer_map_fallback_in_use;
size_t buffer_map_fallback_offset;
CoglWinsysRectangleState rectangle_state;
CoglSamplerCache *sampler_cache;
/* FIXME: remove these when we remove the last xlib based clutter

View File

@ -40,8 +40,6 @@
#include "cogl-journal-private.h"
#include "cogl-texture-private.h"
#include "cogl-texture-2d-private.h"
#include "cogl-texture-3d-private.h"
#include "cogl-texture-rectangle-private.h"
#include "cogl-pipeline-private.h"
#include "cogl-framebuffer-private.h"
#include "cogl-onscreen-private.h"
@ -106,30 +104,6 @@ _cogl_init_feature_overrides (CoglContext *ctx)
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_PBOS)))
COGL_FLAGS_SET (ctx->private_features, COGL_PRIVATE_FEATURE_PBOS, FALSE);
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_GLSL)))
{
ctx->feature_flags &= ~COGL_FEATURE_SHADERS_GLSL;
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_GLSL, FALSE);
COGL_FLAGS_SET (ctx->features,
COGL_FEATURE_ID_PER_VERTEX_POINT_SIZE,
FALSE);
}
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_NPOT_TEXTURES)))
{
ctx->feature_flags &= ~(COGL_FEATURE_TEXTURE_NPOT |
COGL_FEATURE_TEXTURE_NPOT_BASIC |
COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
COGL_FEATURE_TEXTURE_NPOT_REPEAT);
COGL_FLAGS_SET (ctx->features, COGL_FEATURE_ID_TEXTURE_NPOT, FALSE);
COGL_FLAGS_SET (ctx->features,
COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, FALSE);
COGL_FLAGS_SET (ctx->features,
COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP, FALSE);
COGL_FLAGS_SET (ctx->features,
COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT, FALSE);
}
}
const CoglWinsysVtable *
@ -153,10 +127,8 @@ cogl_context_new (CoglDisplay *display,
{
CoglContext *context;
uint8_t white_pixel[] = { 0xff, 0xff, 0xff, 0xff };
CoglBitmap *white_pixel_bitmap;
const CoglWinsysVtable *winsys;
int i;
CoglError *internal_error = NULL;
_cogl_init ();
@ -197,9 +169,6 @@ cogl_context_new (CoglDisplay *display,
memset (context->features, 0, sizeof (context->features));
context->feature_flags = 0;
memset (context->private_features, 0, sizeof (context->private_features));
context->rectangle_state = COGL_WINSYS_RECTANGLE_STATE_UNKNOWN;
memset (context->winsys_features, 0, sizeof (context->winsys_features));
if (!display)
@ -265,22 +234,6 @@ cogl_context_new (CoglDisplay *display,
/* Initialise the driver specific state */
_cogl_init_feature_overrides (context);
/* XXX: ONGOING BUG: Intel viewport scissor
*
* Intel gen6 drivers don't currently correctly handle offset
* viewports, since primitives aren't clipped within the bounds of
* the viewport. To workaround this we push our own clip for the
* viewport that will use scissoring to ensure we clip as expected.
*
* TODO: file a bug upstream!
*/
if (context->gpu.driver_package == COGL_GPU_INFO_DRIVER_PACKAGE_MESA &&
context->gpu.architecture == COGL_GPU_INFO_ARCHITECTURE_SANDYBRIDGE &&
!getenv ("COGL_DISABLE_INTEL_VIEWPORT_SCISSORT_WORKAROUND"))
context->needs_viewport_scissor_workaround = TRUE;
else
context->needs_viewport_scissor_workaround = FALSE;
context->sampler_cache = _cogl_sampler_cache_new (context);
_cogl_pipeline_init_default_pipeline ();
@ -323,8 +276,6 @@ cogl_context_new (CoglDisplay *display,
context->legacy_state_set = 0;
context->default_gl_texture_2d_tex = NULL;
context->default_gl_texture_3d_tex = NULL;
context->default_gl_texture_rect_tex = NULL;
context->framebuffers = NULL;
context->current_draw_buffer = NULL;
@ -366,7 +317,6 @@ cogl_context_new (CoglDisplay *display,
context->current_gl_program = 0;
context->current_gl_dither_enabled = TRUE;
context->current_gl_color_mask = COGL_COLOR_MASK_ALL;
context->gl_blend_enable_cache = FALSE;
@ -453,41 +403,6 @@ cogl_context_new (CoglDisplay *display,
white_pixel,
NULL); /* abort on error */
/* If 3D or rectangle textures aren't supported then these will
* return errors that we can simply ignore. */
internal_error = NULL;
context->default_gl_texture_3d_tex =
cogl_texture_3d_new_from_data (context,
1, 1, 1, /* width, height, depth */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
0, /* rowstride */
0, /* image stride */
white_pixel,
&internal_error);
if (internal_error)
cogl_error_free (internal_error);
/* TODO: add cogl_texture_rectangle_new_from_data() */
white_pixel_bitmap =
cogl_bitmap_new_for_data (context,
1, 1, /* width/height */
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
4, /* rowstride */
white_pixel);
internal_error = NULL;
context->default_gl_texture_rect_tex =
cogl_texture_rectangle_new_from_bitmap (white_pixel_bitmap);
/* XXX: we need to allocate the texture now because the white_pixel
* data is on the stack */
cogl_texture_allocate (COGL_TEXTURE (context->default_gl_texture_rect_tex),
&internal_error);
if (internal_error)
cogl_error_free (internal_error);
cogl_object_unref (white_pixel_bitmap);
cogl_push_source (context->opaque_color_pipeline);
context->atlases = NULL;
@ -526,10 +441,6 @@ _cogl_context_free (CoglContext *context)
if (context->default_gl_texture_2d_tex)
cogl_object_unref (context->default_gl_texture_2d_tex);
if (context->default_gl_texture_3d_tex)
cogl_object_unref (context->default_gl_texture_3d_tex);
if (context->default_gl_texture_rect_tex)
cogl_object_unref (context->default_gl_texture_rect_tex);
if (context->opaque_color_pipeline)
cogl_object_unref (context->opaque_color_pipeline);

View File

@ -174,33 +174,14 @@ cogl_is_context (void *object);
* experimental since it's only useable with experimental API... */
/**
* CoglFeatureID:
* @COGL_FEATURE_ID_TEXTURE_NPOT_BASIC: The hardware supports non power
* of two textures, but you also need to check the
* %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT
* features to know if the hardware supports npot texture mipmaps
* or repeat modes other than
* %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively.
* @COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP: Mipmapping is supported in
* conjuntion with non power of two textures.
* @COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT: Repeat modes other than
* %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE are supported by the
* hardware.
* @COGL_FEATURE_ID_TEXTURE_NPOT: Non power of two textures are supported
* by the hardware. This is a equivalent to the
* %COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, %COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP
* and %COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT features combined.
* @COGL_FEATURE_ID_TEXTURE_RECTANGLE: Support for rectangular
* textures with non-normalized texture coordinates.
* @COGL_FEATURE_ID_TEXTURE_RG: Support for
* %COGL_TEXTURE_COMPONENTS_RG as the internal components of a
* texture.
* @COGL_FEATURE_ID_TEXTURE_3D: 3D texture support
* @COGL_FEATURE_ID_OFFSCREEN: Offscreen rendering support
* @COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE: Multisample support for
* offscreen framebuffers
* @COGL_FEATURE_ID_ONSCREEN_MULTIPLE: Multiple onscreen framebuffers
* supported.
* @COGL_FEATURE_ID_GLSL: GLSL support
* @COGL_FEATURE_ID_UNSIGNED_INT_INDICES: Set if
* %COGL_INDICES_TYPE_UNSIGNED_INT is supported in
* cogl_indices_new().
@ -236,13 +217,6 @@ cogl_is_context (void *object);
*/
typedef enum _CoglFeatureID
{
COGL_FEATURE_ID_TEXTURE_NPOT_BASIC = 1,
COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP,
COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT,
COGL_FEATURE_ID_TEXTURE_NPOT,
COGL_FEATURE_ID_TEXTURE_RECTANGLE,
COGL_FEATURE_ID_TEXTURE_3D,
COGL_FEATURE_ID_GLSL,
COGL_FEATURE_ID_OFFSCREEN,
COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE,
COGL_FEATURE_ID_ONSCREEN_MULTIPLE,

View File

@ -130,22 +130,11 @@ OPT (DISABLE_TEXTURING,
"disable-texturing",
N_("Disable texturing"),
N_("Disable texturing any primitives"))
OPT (DISABLE_GLSL,
N_("Root Cause"),
"disable-glsl",
N_("Disable GLSL"),
N_("Disable use of GLSL"))
OPT (DISABLE_BLENDING,
N_("Root Cause"),
"disable-blending",
N_("Disable blending"),
N_("Disable use of blending"))
OPT (DISABLE_NPOT_TEXTURES,
N_("Root Cause"),
"disable-npot-textures",
N_("Disable non-power-of-two textures"),
N_("Makes Cogl think that the GL driver doesn't support NPOT textures "
"so that it will create sliced textures or textures with waste instead."))
OPT (DISABLE_SOFTWARE_CLIP,
N_("Root Cause"),
"disable-software-clip",

View File

@ -77,9 +77,7 @@ static const GDebugKey cogl_behavioural_debug_keys[] = {
{ "disable-atlas", COGL_DEBUG_DISABLE_ATLAS },
{ "disable-shared-atlas", COGL_DEBUG_DISABLE_SHARED_ATLAS },
{ "disable-texturing", COGL_DEBUG_DISABLE_TEXTURING},
{ "disable-glsl", COGL_DEBUG_DISABLE_GLSL},
{ "disable-blending", COGL_DEBUG_DISABLE_BLENDING},
{ "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES},
{ "wireframe", COGL_DEBUG_WIREFRAME},
{ "disable-software-clip", COGL_DEBUG_DISABLE_SOFTWARE_CLIP},
{ "disable-program-caches", COGL_DEBUG_DISABLE_PROGRAM_CACHES},

View File

@ -61,12 +61,10 @@ typedef enum
COGL_DEBUG_DISABLE_SHARED_ATLAS,
COGL_DEBUG_OPENGL,
COGL_DEBUG_DISABLE_TEXTURING,
COGL_DEBUG_DISABLE_GLSL,
COGL_DEBUG_SHOW_SOURCE,
COGL_DEBUG_DISABLE_BLENDING,
COGL_DEBUG_TEXTURE_PIXMAP,
COGL_DEBUG_BITMAP,
COGL_DEBUG_DISABLE_NPOT_TEXTURES,
COGL_DEBUG_WIREFRAME,
COGL_DEBUG_DISABLE_SOFTWARE_CLIP,
COGL_DEBUG_DISABLE_PROGRAM_CACHES,

View File

@ -83,11 +83,10 @@ typedef enum _CoglFramebufferStateIndex
COGL_FRAMEBUFFER_STATE_INDEX_DITHER = 3,
COGL_FRAMEBUFFER_STATE_INDEX_MODELVIEW = 4,
COGL_FRAMEBUFFER_STATE_INDEX_PROJECTION = 5,
COGL_FRAMEBUFFER_STATE_INDEX_COLOR_MASK = 6,
COGL_FRAMEBUFFER_STATE_INDEX_FRONT_FACE_WINDING = 7,
COGL_FRAMEBUFFER_STATE_INDEX_DEPTH_WRITE = 8,
COGL_FRAMEBUFFER_STATE_INDEX_STEREO_MODE = 9,
COGL_FRAMEBUFFER_STATE_INDEX_MAX = 10
COGL_FRAMEBUFFER_STATE_INDEX_FRONT_FACE_WINDING = 6,
COGL_FRAMEBUFFER_STATE_INDEX_DEPTH_WRITE = 7,
COGL_FRAMEBUFFER_STATE_INDEX_STEREO_MODE = 8,
COGL_FRAMEBUFFER_STATE_INDEX_MAX = 9
} CoglFramebufferStateIndex;
typedef enum _CoglFramebufferState
@ -98,10 +97,9 @@ typedef enum _CoglFramebufferState
COGL_FRAMEBUFFER_STATE_DITHER = 1<<3,
COGL_FRAMEBUFFER_STATE_MODELVIEW = 1<<4,
COGL_FRAMEBUFFER_STATE_PROJECTION = 1<<5,
COGL_FRAMEBUFFER_STATE_COLOR_MASK = 1<<6,
COGL_FRAMEBUFFER_STATE_FRONT_FACE_WINDING = 1<<7,
COGL_FRAMEBUFFER_STATE_DEPTH_WRITE = 1<<8,
COGL_FRAMEBUFFER_STATE_STEREO_MODE = 1<<9
COGL_FRAMEBUFFER_STATE_FRONT_FACE_WINDING = 1<<6,
COGL_FRAMEBUFFER_STATE_DEPTH_WRITE = 1<<7,
COGL_FRAMEBUFFER_STATE_STEREO_MODE = 1<<8
} CoglFramebufferState;
#define COGL_FRAMEBUFFER_STATE_ALL ((1<<COGL_FRAMEBUFFER_STATE_INDEX_MAX) - 1)
@ -155,7 +153,6 @@ struct _CoglFramebuffer
gboolean dither_enabled;
gboolean depth_writing_enabled;
CoglColorMask color_mask;
CoglStereoMode stereo_mode;
/* We journal the textured rectangles we want to submit to OpenGL so

View File

@ -123,8 +123,6 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
framebuffer->dirty_bitmasks = TRUE;
framebuffer->color_mask = COGL_COLOR_MASK_ALL;
framebuffer->samples_per_pixel = 0;
framebuffer->clip_stack = NULL;
@ -191,9 +189,6 @@ _cogl_framebuffer_free (CoglFramebuffer *framebuffer)
cogl_object_unref (framebuffer->journal);
if (ctx->viewport_scissor_workaround_framebuffer == framebuffer)
ctx->viewport_scissor_workaround_framebuffer = NULL;
ctx->framebuffers = g_list_remove (ctx->framebuffers, framebuffer);
if (ctx->current_draw_buffer == framebuffer)
@ -260,13 +255,11 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
float blue,
float alpha)
{
CoglContext *ctx = framebuffer->context;
CoglClipStack *clip_stack = _cogl_framebuffer_get_clip_stack (framebuffer);
int scissor_x0;
int scissor_y0;
int scissor_x1;
int scissor_y1;
gboolean saved_viewport_scissor_workaround;
if (!framebuffer->depth_buffer_clear_needed &&
(buffers & COGL_BUFFER_BIT_DEPTH))
@ -361,31 +354,6 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
_cogl_framebuffer_flush_journal (framebuffer);
/* XXX: ONGOING BUG: Intel viewport scissor
*
* The semantics of cogl_framebuffer_clear() are that it should not
* be affected by the current viewport and so if we are currently
* applying a workaround for viewport scissoring we need to
* temporarily disable the workaround before clearing so any
* special scissoring for the workaround will be removed first.
*
* Note: we only need to disable the workaround if the current
* viewport doesn't match the framebuffer's size since otherwise
* the workaround wont affect clearing anyway.
*/
if (ctx->needs_viewport_scissor_workaround &&
(framebuffer->viewport_x != 0 ||
framebuffer->viewport_y != 0 ||
framebuffer->viewport_width != framebuffer->width ||
framebuffer->viewport_height != framebuffer->height))
{
saved_viewport_scissor_workaround = TRUE;
ctx->needs_viewport_scissor_workaround = FALSE;
ctx->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_CLIP;
}
else
saved_viewport_scissor_workaround = FALSE;
/* NB: _cogl_framebuffer_flush_state may disrupt various state (such
* as the pipeline state) when flushing the clip stack, so should
* always be done first when preparing to draw. */
@ -395,16 +363,6 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
_cogl_framebuffer_clear_without_flush4f (framebuffer, buffers,
red, green, blue, alpha);
/* XXX: ONGOING BUG: Intel viewport scissor
*
* See comment about temporarily disabling this workaround above
*/
if (saved_viewport_scissor_workaround)
{
ctx->needs_viewport_scissor_workaround = TRUE;
ctx->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_CLIP;
}
/* This is a debugging variable used to visually display the quad
* batches from the journal. It is reset here to increase the
* chances of getting the same colours for each frame during an
@ -552,12 +510,7 @@ cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
framebuffer->viewport_age++;
if (context->current_draw_buffer == framebuffer)
{
context->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_VIEWPORT;
if (context->needs_viewport_scissor_workaround)
context->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_CLIP;
}
context->current_draw_buffer_changes |= COGL_FRAMEBUFFER_STATE_VIEWPORT;
}
float
@ -831,27 +784,7 @@ _cogl_framebuffer_compare_viewport_state (CoglFramebuffer *a,
/* NB: we render upside down to offscreen framebuffers and that
* can affect how we setup the GL viewport... */
a->type != b->type)
{
unsigned long differences = COGL_FRAMEBUFFER_STATE_VIEWPORT;
CoglContext *context = a->context;
/* XXX: ONGOING BUG: Intel viewport scissor
*
* Intel gen6 drivers don't currently correctly handle offset
* viewports, since primitives aren't clipped within the bounds of
* the viewport. To workaround this we push our own clip for the
* viewport that will use scissoring to ensure we clip as expected.
*
* This workaround implies that a change in viewport state is
* effectively also a change in the clipping state.
*
* TODO: file a bug upstream!
*/
if (G_UNLIKELY (context->needs_viewport_scissor_workaround))
differences |= COGL_FRAMEBUFFER_STATE_CLIP;
return differences;
}
return COGL_FRAMEBUFFER_STATE_VIEWPORT;
else
return 0;
}
@ -894,17 +827,6 @@ _cogl_framebuffer_compare_projection_state (CoglFramebuffer *a,
return COGL_FRAMEBUFFER_STATE_PROJECTION;
}
static unsigned long
_cogl_framebuffer_compare_color_mask_state (CoglFramebuffer *a,
CoglFramebuffer *b)
{
if (cogl_framebuffer_get_color_mask (a) !=
cogl_framebuffer_get_color_mask (b))
return COGL_FRAMEBUFFER_STATE_COLOR_MASK;
else
return 0;
}
static unsigned long
_cogl_framebuffer_compare_front_face_winding_state (CoglFramebuffer *a,
CoglFramebuffer *b)
@ -971,10 +893,6 @@ _cogl_framebuffer_compare (CoglFramebuffer *a,
differences |=
_cogl_framebuffer_compare_projection_state (a, b);
break;
case COGL_FRAMEBUFFER_STATE_INDEX_COLOR_MASK:
differences |=
_cogl_framebuffer_compare_color_mask_state (a, b);
break;
case COGL_FRAMEBUFFER_STATE_INDEX_FRONT_FACE_WINDING:
differences |=
_cogl_framebuffer_compare_front_face_winding_state (a, b);
@ -1080,29 +998,6 @@ cogl_framebuffer_get_is_stereo (CoglFramebuffer *framebuffer)
return framebuffer->config.stereo_enabled;
}
CoglColorMask
cogl_framebuffer_get_color_mask (CoglFramebuffer *framebuffer)
{
return framebuffer->color_mask;
}
void
cogl_framebuffer_set_color_mask (CoglFramebuffer *framebuffer,
CoglColorMask color_mask)
{
if (framebuffer->color_mask == color_mask)
return;
/* XXX: Currently color mask changes don't go through the journal */
_cogl_framebuffer_flush_journal (framebuffer);
framebuffer->color_mask = color_mask;
if (framebuffer->context->current_draw_buffer == framebuffer)
framebuffer->context->current_draw_buffer_changes |=
COGL_FRAMEBUFFER_STATE_COLOR_MASK;
}
CoglStereoMode
cogl_framebuffer_get_stereo_mode (CoglFramebuffer *framebuffer)
{
@ -2097,15 +1992,6 @@ get_wire_line_indices (CoglContext *ctx,
return ret;
}
static gboolean
remove_layer_cb (CoglPipeline *pipeline,
int layer_index,
void *user_data)
{
cogl_pipeline_remove_layer (pipeline, layer_index);
return TRUE;
}
static void
pipeline_destroyed_cb (CoglPipeline *weak_pipeline, void *user_data)
{
@ -2157,6 +2043,8 @@ draw_wireframe (CoglContext *ctx,
if (!wire_pipeline)
{
static CoglSnippet *snippet = NULL;
wire_pipeline =
_cogl_pipeline_weak_copy (pipeline, pipeline_destroyed_cb, NULL);
@ -2168,29 +2056,20 @@ draw_wireframe (CoglContext *ctx,
* vertex program and since we'd like to see the results of the
* vertex program in the wireframe we just add a final clobber
* of the wire color leaving the rest of the state untouched. */
if (cogl_has_feature (framebuffer->context, COGL_FEATURE_ID_GLSL))
{
static CoglSnippet *snippet = NULL;
/* The snippet is cached so that it will reuse the program
* from the pipeline cache if possible */
if (snippet == NULL)
{
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
NULL,
NULL);
cogl_snippet_set_replace (snippet,
"cogl_color_out = "
"vec4 (0.0, 1.0, 0.0, 1.0);\n");
}
cogl_pipeline_add_snippet (wire_pipeline, snippet);
}
else
/* The snippet is cached so that it will reuse the program
* from the pipeline cache if possible */
if (snippet == NULL)
{
cogl_pipeline_foreach_layer (wire_pipeline, remove_layer_cb, NULL);
cogl_pipeline_set_color4f (wire_pipeline, 0, 1, 0, 1);
snippet = cogl_snippet_new (COGL_SNIPPET_HOOK_FRAGMENT,
NULL,
NULL);
cogl_snippet_set_replace (snippet,
"cogl_color_out = "
"vec4 (0.0, 1.0, 0.0, 1.0);\n");
}
cogl_pipeline_add_snippet (wire_pipeline, snippet);
}
/* temporarily disable the wireframe to avoid recursion! */

View File

@ -816,38 +816,6 @@ void
cogl_framebuffer_set_depth_write_enabled (CoglFramebuffer *framebuffer,
gboolean depth_write_enabled);
/**
* cogl_framebuffer_get_color_mask:
* @framebuffer: a pointer to a #CoglFramebuffer
*
* Gets the current #CoglColorMask of which channels would be written to the
* current framebuffer. Each bit set in the mask means that the
* corresponding color would be written.
*
* Returns: A #CoglColorMask
* Since: 1.8
* Stability: unstable
*/
CoglColorMask
cogl_framebuffer_get_color_mask (CoglFramebuffer *framebuffer);
/**
* cogl_framebuffer_set_color_mask:
* @framebuffer: a pointer to a #CoglFramebuffer
* @color_mask: A #CoglColorMask of which color channels to write to
* the current framebuffer.
*
* Defines a bit mask of which color channels should be written to the
* given @framebuffer. If a bit is set in @color_mask that means that
* color will be written.
*
* Since: 1.8
* Stability: unstable
*/
void
cogl_framebuffer_set_color_mask (CoglFramebuffer *framebuffer,
CoglColorMask color_mask);
/**
* cogl_framebuffer_get_stereo_mode:
* @framebuffer: a pointer to a #CoglFramebuffer
@ -1161,8 +1129,8 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
* This drawing api doesn't support high-level meta texture types such
* as #CoglTexture2DSliced so it is the user's responsibility to
* ensure that only low-level textures that can be directly sampled by
* a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
* are associated with layers of the given @pipeline.
* a GPU such as #CoglTexture2D are associated with layers of the given
* @pipeline.
*
* <note>This api doesn't support any of the legacy global state options such
* as cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
@ -1203,8 +1171,8 @@ cogl_framebuffer_draw_primitive (CoglFramebuffer *framebuffer,
* This drawing api doesn't support high-level meta texture types such
* as #CoglTexture2DSliced so it is the user's responsibility to
* ensure that only low-level textures that can be directly sampled by
* a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
* are associated with layers of the given @pipeline.
* a GPU such as #CoglTexture2D are associated with layers of the given
* @pipeline.
*
* Stability: unstable
* Since: 1.10
@ -1246,8 +1214,8 @@ cogl_framebuffer_vdraw_attributes (CoglFramebuffer *framebuffer,
* This drawing api doesn't support high-level meta texture types such
* as #CoglTexture2DSliced so it is the user's responsibility to
* ensure that only low-level textures that can be directly sampled by
* a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
* are associated with layers of the given @pipeline.
* a GPU such as #CoglTexture2D are associated with layers of the given
* @pipeline.
*
* <note>This api doesn't support any of the legacy global state options such
* as cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
@ -1312,8 +1280,8 @@ cogl_framebuffer_draw_attributes (CoglFramebuffer *framebuffer,
* This drawing api doesn't support high-level meta texture types such
* as #CoglTexture2DSliced so it is the user's responsibility to
* ensure that only low-level textures that can be directly sampled by
* a GPU such as #CoglTexture2D, #CoglTextureRectangle or
* #CoglTexture3D are associated with layers of the given @pipeline.
* a GPU such as #CoglTexture2D are associated with layers of the given
* @pipeline.
*
* <note>This api doesn't support any of the legacy global state
* options such as cogl_set_depth_test_enabled(),
@ -1380,8 +1348,8 @@ cogl_framebuffer_vdraw_indexed_attributes (CoglFramebuffer *framebuffer,
* This drawing api doesn't support high-level meta texture types such
* as #CoglTexture2DSliced so it is the user's responsibility to
* ensure that only low-level textures that can be directly sampled by
* a GPU such as #CoglTexture2D, #CoglTextureRectangle or
* #CoglTexture3D are associated with layers of the given @pipeline.
* a GPU such as #CoglTexture2D are associated with layers of the given
* @pipeline.
*
* <note>This api doesn't support any of the legacy global state
* options such as cogl_set_depth_test_enabled(),
@ -1475,11 +1443,6 @@ cogl_framebuffer_draw_rectangle (CoglFramebuffer *framebuffer,
* bottom right. To map an entire texture across the rectangle pass
* in @s_1=0, @t_1=0, @s_2=1, @t_2=1.
*
* <note>Even if you have associated a #CoglTextureRectangle texture
* with one of your @pipeline layers which normally implies working
* with non-normalized texture coordinates this api should still be
* passed normalized texture coordinates.</note>
*
* Since: 1.10
* Stability: unstable
*/
@ -1532,9 +1495,7 @@ cogl_framebuffer_draw_textured_rectangle (CoglFramebuffer *framebuffer,
* <note>This api can not currently handle multiple high-level meta
* texture layers. The first layer may be a high level meta texture
* such as #CoglTexture2DSliced but all other layers much be low
* level textures such as #CoglTexture2D and additionally they
* should be textures that can be sampled using normalized coordinates
* (so not #CoglTextureRectangle textures).</note>
* level textures such as #CoglTexture2D.
*
* The top left texture coordinate for layer 0 of any pipeline will be
* (tex_coords[0], tex_coords[1]) and the bottom right coordinate will
@ -1548,11 +1509,6 @@ cogl_framebuffer_draw_textured_rectangle (CoglFramebuffer *framebuffer,
* in tex_coords[0]=0, tex_coords[1]=0, tex_coords[2]=1,
* tex_coords[3]=1.
*
* <note>Even if you have associated a #CoglTextureRectangle texture
* which normally implies working with non-normalized texture
* coordinates this api should still be passed normalized texture
* coordinates.</note>
*
* The first pair of coordinates are for the first layer (with the
* smallest layer index) and if you supply less texture coordinates
* than there are layers in the current source material then default
@ -1656,11 +1612,6 @@ cogl_framebuffer_draw_rectangles (CoglFramebuffer *framebuffer,
* in tex_coords[0]=0, tex_coords[1]=0, tex_coords[2]=1,
* tex_coords[3]=1.
*
* <note>Even if you have associated a #CoglTextureRectangle texture
* which normally implies working with non-normalized texture
* coordinates this api should still be passed normalized texture
* coordinates.</note>
*
* Since: 1.10
* Stability: unstable
*/

View File

@ -366,9 +366,8 @@ cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx,
* GLES2 context.</note>
*
* <note>This function will only return %TRUE for low-level
* #CoglTexture<!-- -->s such as #CoglTexture2D or #CoglTexture3D but
* not for high level meta textures such as
* #CoglTexture2DSliced</note>
* #CoglTexture<!-- -->s such as #CoglTexture2D but not for high level
* meta textures such as #CoglTexture2DSliced</note>
*
* <note>The handle returned should not be passed directly to a system
* OpenGL ES 2.0 library, the handle is only intended to be used via

View File

@ -100,21 +100,12 @@ _cogl_glsl_shader_set_source_with_boilerplate (CoglContext *ctx,
strings[count] = version_string;
lengths[count++] = -1;
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_EMBEDDED) &&
cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
{
static const char texture_3d_extension[] =
"#extension GL_OES_texture_3D : enable\n";
strings[count] = texture_3d_extension;
lengths[count++] = sizeof (texture_3d_extension) - 1;
}
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_EGL_IMAGE_EXTERNAL))
{
static const char texture_3d_extension[] =
static const char image_external_extension[] =
"#extension GL_OES_EGL_image_external : require\n";
strings[count] = texture_3d_extension;
lengths[count++] = sizeof (texture_3d_extension) - 1;
strings[count] = image_external_extension;
lengths[count++] = sizeof (image_external_extension) - 1;
}
if (shader_gl_type == GL_VERTEX_SHADER)

View File

@ -36,7 +36,7 @@
#include "cogl-matrix.h"
#include "cogl-spans.h"
#include "cogl-meta-texture.h"
#include "cogl-texture-rectangle-private.h"
#include "cogl-texture-private.h"
#include <string.h>
#include <math.h>
@ -316,16 +316,9 @@ foreach_clamped_region (CoglMetaTexture *meta_texture,
if (wrap_s == COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE)
{
float max_s_coord;
float max_s_coord = 1.0;
float half_texel_width;
/* Consider that rectangle textures have non-normalized
* coordinates... */
if (cogl_is_texture_rectangle (meta_texture))
max_s_coord = width;
else
max_s_coord = 1.0;
half_texel_width = max_s_coord / (width * 2);
/* Handle any left clamped region */
@ -375,16 +368,9 @@ foreach_clamped_region (CoglMetaTexture *meta_texture,
if (wrap_t == COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE)
{
float height = cogl_texture_get_height (COGL_TEXTURE (meta_texture));
float max_t_coord;
float max_t_coord = 1.0;
float half_texel_height;
/* Consider that rectangle textures have non-normalized
* coordinates... */
if (cogl_is_texture_rectangle (meta_texture))
max_t_coord = height;
else
max_t_coord = 1.0;
half_texel_height = max_t_coord / (height * 2);
/* Handle any top clamped region */
@ -466,33 +452,6 @@ normalize_meta_coords_cb (CoglTexture *slice_texture,
data->user_data);
}
typedef struct _UnNormalizeData
{
CoglMetaTextureCallback callback;
void *user_data;
float width;
float height;
} UnNormalizeData;
static void
un_normalize_slice_coords_cb (CoglTexture *slice_texture,
const float *slice_coords,
const float *meta_coords,
void *user_data)
{
UnNormalizeData *data = user_data;
float un_normalized_slice_coords[4] = {
slice_coords[0] * data->width,
slice_coords[1] * data->height,
slice_coords[2] * data->width,
slice_coords[3] * data->height
};
data->callback (slice_texture,
un_normalized_slice_coords, meta_coords,
data->user_data);
}
void
cogl_meta_texture_foreach_in_region (CoglMetaTexture *meta_texture,
float tx_1,
@ -539,19 +498,16 @@ cogl_meta_texture_foreach_in_region (CoglMetaTexture *meta_texture,
* coordinates beyond this point and only re-normalize just before
* calling the user's callback... */
if (!cogl_is_texture_rectangle (COGL_TEXTURE (meta_texture)))
{
normalize_data.callback = callback;
normalize_data.user_data = user_data;
normalize_data.s_normalize_factor = 1.0f / width;
normalize_data.t_normalize_factor = 1.0f / height;
callback = normalize_meta_coords_cb;
user_data = &normalize_data;
tx_1 *= width;
ty_1 *= height;
tx_2 *= width;
ty_2 *= height;
}
normalize_data.callback = callback;
normalize_data.user_data = user_data;
normalize_data.s_normalize_factor = 1.0f / width;
normalize_data.t_normalize_factor = 1.0f / height;
callback = normalize_meta_coords_cb;
user_data = &normalize_data;
tx_1 *= width;
ty_1 *= height;
tx_2 *= width;
ty_2 *= height;
/* XXX: at some point this wont be routed through the CoglTexture
* vtable, instead there will be a separate CoglMetaTexture
@ -609,21 +565,6 @@ cogl_meta_texture_foreach_in_region (CoglMetaTexture *meta_texture,
CoglSpan x_span = { 0, width, 0 };
CoglSpan y_span = { 0, height, 0 };
float meta_region_coords[4] = { tx_1, ty_1, tx_2, ty_2 };
UnNormalizeData un_normalize_data;
/* If we are dealing with a CoglTextureRectangle then we need a shim
* callback that un_normalizes the slice coordinates we get from
* _cogl_texture_spans_foreach_in_region before passing them to
* the user's callback. */
if (cogl_is_texture_rectangle (meta_texture))
{
un_normalize_data.callback = callback;
un_normalize_data.user_data = user_data;
un_normalize_data.width = width;
un_normalize_data.height = height;
callback = un_normalize_slice_coords_cb;
user_data = &un_normalize_data;
}
_cogl_texture_spans_foreach_in_region (&x_span, 1,
&y_span, 1,

View File

@ -42,8 +42,7 @@ G_BEGIN_DECLS
/**
* SECTION:cogl-meta-texture
* @short_description: Interface for high-level textures built from
* low-level textures like #CoglTexture2D and
* #CoglTexture3D.
* low-level textures like #CoglTexture2D.
*
* Cogl helps to make it easy to deal with high level textures such
* as #CoglAtlasTexture<!-- -->s, #CoglSubTexture<!-- -->s,
@ -52,12 +51,11 @@ G_BEGIN_DECLS
*
* A #CoglMetaTexture is a texture that might internally be
* represented by one or more low-level #CoglTexture<!-- -->s
* such as #CoglTexture2D or #CoglTexture3D. These low-level textures
* are the only ones that a GPU really understands but because
* applications often want more high-level texture abstractions
* (such as storing multiple textures inside one larger "atlas"
* texture) it's desirable to be able to deal with these
* using a common interface.
* such as #CoglTexture2D. These low-level textures are the only ones
* that a GPU really understands but because applications often want
* more high-level texture abstractions (such as storing multiple
* textures inside one larger "atlas" texture) it's desirable to be
* able to deal with these using a common interface.
*
* For example the GPU is not able to automatically handle repeating a
* texture that is part of a larger atlas texture but if you use

View File

@ -31,7 +31,7 @@
#ifndef __COGL_MUTTER_H___
#define __COGL_MUTTER_H___
#include "cogl-mutter-config.h"
#include "cogl-config.h"
#include "cogl-defines.h"
#include <cogl/cogl-texture.h>

View File

@ -75,8 +75,8 @@ GType cogl_offscreen_get_gtype (void);
* destroy the offscreen buffer before you can use the @texture again.
*
* <note>This api only works with low-level #CoglTexture types such as
* #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not
* with meta-texture types such as #CoglTexture2DSliced.</note>
* #CoglTexture2D and not with meta-texture types such as
* #CoglTexture2DSliced.</note>
*
* The storage for the framebuffer is actually allocated lazily
* so this function will never return %NULL to indicate a runtime
@ -110,8 +110,8 @@ cogl_offscreen_new_with_texture (CoglTexture *texture);
* you can use the @texture again.
*
* <note>This only works with low-level #CoglTexture types such as
* #CoglTexture2D, #CoglTexture3D and #CoglTextureRectangle, and not
* with meta-texture types such as #CoglTexture2DSliced.</note>
* #CoglTexture2D and not with meta-texture types such as
* #CoglTexture2DSliced.</note>
*
* Return value: (transfer full): a newly instantiated #CoglOffscreen
* framebuffer or %NULL if it wasn't possible to create the

View File

@ -55,7 +55,6 @@ typedef enum
{
/* sparse state */
COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
COGL_PIPELINE_LAYER_STATE_SAMPLER_INDEX,
COGL_PIPELINE_LAYER_STATE_COMBINE_INDEX,
@ -82,8 +81,6 @@ typedef enum
{
COGL_PIPELINE_LAYER_STATE_UNIT =
1L<<COGL_PIPELINE_LAYER_STATE_UNIT_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE =
1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX,
COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA =
1L<<COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX,
COGL_PIPELINE_LAYER_STATE_SAMPLER =
@ -237,11 +234,6 @@ struct _CoglPipelineLayer
/* Each layer is directly associated with a single texture unit */
int unit_index;
/* The type of the texture. This is always set even if the texture
is NULL and it will be used to determine what type of texture
lookups to use in any shaders generated by the pipeline
backends. */
CoglTextureType texture_type;
/* The texture for this layer, or NULL for an empty
* layer */
CoglTexture *texture;
@ -347,9 +339,6 @@ _cogl_pipeline_layer_get_texture (CoglPipelineLayer *layer);
CoglTexture *
_cogl_pipeline_layer_get_texture_real (CoglPipelineLayer *layer);
CoglTextureType
_cogl_pipeline_layer_get_texture_type (CoglPipelineLayer *layer);
CoglPipelineFilter
_cogl_pipeline_layer_get_min_filter (CoglPipelineLayer *layer);

View File

@ -50,11 +50,6 @@ CoglPipelineFilter
_cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline,
int layer_index);
gboolean
_cogl_pipeline_layer_texture_type_equal (CoglPipelineLayer *authority0,
CoglPipelineLayer *authority1,
CoglPipelineEvalFlags flags);
gboolean
_cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
CoglPipelineLayer *authority1,
@ -93,11 +88,6 @@ _cogl_pipeline_layer_hash_unit_state (CoglPipelineLayer *authority,
CoglPipelineLayer **authorities,
CoglPipelineHashState *state);
void
_cogl_pipeline_layer_hash_texture_type_state (CoglPipelineLayer *authority,
CoglPipelineLayer **authorities,
CoglPipelineHashState *state);
void
_cogl_pipeline_layer_hash_texture_data_state (CoglPipelineLayer *authority,
CoglPipelineLayer **authorities,

View File

@ -136,87 +136,6 @@ cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
return _cogl_pipeline_layer_get_texture (layer);
}
CoglTextureType
_cogl_pipeline_layer_get_texture_type (CoglPipelineLayer *layer)
{
CoglPipelineLayer *authority =
_cogl_pipeline_layer_get_authority (layer,
COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE);
return authority->texture_type;
}
static void
_cogl_pipeline_set_layer_texture_type (CoglPipeline *pipeline,
int layer_index,
CoglTextureType texture_type)
{
CoglPipelineLayerState change = COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE;
CoglPipelineLayer *layer;
CoglPipelineLayer *authority;
CoglPipelineLayer *new;
/* Note: this will ensure that the layer exists, creating one if it
* doesn't already.
*
* Note: If the layer already existed it's possibly owned by another
* pipeline. If the layer is created then it will be owned by
* pipeline. */
layer = _cogl_pipeline_get_layer (pipeline, layer_index);
/* Now find the ancestor of the layer that is the authority for the
* state we want to change */
authority = _cogl_pipeline_layer_get_authority (layer, change);
if (texture_type == authority->texture_type)
return;
new = _cogl_pipeline_layer_pre_change_notify (pipeline, layer, change);
if (new != layer)
layer = new;
else
{
/* If the original layer we found is currently the authority on
* the state we are changing see if we can revert to one of our
* ancestors being the authority. */
if (layer == authority &&
_cogl_pipeline_layer_get_parent (authority) != NULL)
{
CoglPipelineLayer *parent =
_cogl_pipeline_layer_get_parent (authority);
CoglPipelineLayer *old_authority =
_cogl_pipeline_layer_get_authority (parent, change);
if (old_authority->texture_type == texture_type)
{
layer->differences &= ~change;
g_assert (layer->owner == pipeline);
if (layer->differences == 0)
_cogl_pipeline_prune_empty_layer_difference (pipeline,
layer);
goto changed;
}
}
}
layer->texture_type = texture_type;
/* If we weren't previously the authority on this state then we need
* to extended our differences mask and so it's possible that some
* of our ancestry will now become redundant, so we aim to reparent
* ourselves if that's true... */
if (layer != authority)
{
layer->differences |= change;
_cogl_pipeline_layer_prune_redundant_ancestry (layer);
}
changed:
pipeline->dirty_real_blend_enable = TRUE;
}
static void
_cogl_pipeline_set_layer_texture_data (CoglPipeline *pipeline,
int layer_index,
@ -301,69 +220,13 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
int layer_index,
CoglTexture *texture)
{
/* For the convenience of fragend code we separate texture state
* into the "type" and the "data", and setting a layer texture
* updates both of these properties.
*
* One example for why this is helpful is that the fragends may
* cache programs they generate and want to re-use those programs
* with all pipelines having equivalent fragment processing state.
* For the sake of determining if pipelines have equivalent fragment
* processing state we don't need to compare that the same
* underlying texture objects are referenced by the pipelines but we
* do need to see if they use the same texture types. Making this
* distinction is much simpler if they are in different state
* groups.
*
* Note: if a NULL texture is set then we leave the type unchanged
* so we can avoid needlessly invalidating any associated fragment
* program.
*/
if (texture)
{
CoglTextureType texture_type =
_cogl_texture_get_type (texture);
_cogl_pipeline_set_layer_texture_type (pipeline,
layer_index,
texture_type);
}
_cogl_pipeline_set_layer_texture_data (pipeline, layer_index, texture);
}
void
cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline,
int layer_index,
CoglTextureType texture_type)
int layer_index)
{
CoglContext *ctx = _cogl_context_get_default ();
/* Disallow setting texture types that aren't supported */
switch (texture_type)
{
case COGL_TEXTURE_TYPE_2D:
break;
case COGL_TEXTURE_TYPE_3D:
if (ctx->default_gl_texture_3d_tex == NULL)
{
g_warning ("The default 3D texture was set on a pipeline but "
"3D textures are not supported");
texture_type = COGL_TEXTURE_TYPE_2D;
return;
}
break;
case COGL_TEXTURE_TYPE_RECTANGLE:
if (ctx->default_gl_texture_rect_tex == NULL)
{
g_warning ("The default rectangle texture was set on a pipeline but "
"rectangle textures are not supported");
texture_type = COGL_TEXTURE_TYPE_2D;
}
break;
}
_cogl_pipeline_set_layer_texture_type (pipeline, layer_index, texture_type);
_cogl_pipeline_set_layer_texture_data (pipeline, layer_index, NULL);
}
@ -950,14 +813,6 @@ cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
snippet);
}
gboolean
_cogl_pipeline_layer_texture_type_equal (CoglPipelineLayer *authority0,
CoglPipelineLayer *authority1,
CoglPipelineEvalFlags flags)
{
return authority0->texture_type == authority1->texture_type;
}
gboolean
_cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
CoglPipelineLayer *authority1,
@ -966,8 +821,7 @@ _cogl_pipeline_layer_texture_data_equal (CoglPipelineLayer *authority0,
if (authority0->texture == NULL)
{
if (authority1->texture == NULL)
return (_cogl_pipeline_layer_get_texture_type (authority0) ==
_cogl_pipeline_layer_get_texture_type (authority1));
return TRUE;
else
return FALSE;
}
@ -1647,18 +1501,6 @@ _cogl_pipeline_layer_hash_unit_state (CoglPipelineLayer *authority,
_cogl_util_one_at_a_time_hash (state->hash, &unit, sizeof (unit));
}
void
_cogl_pipeline_layer_hash_texture_type_state (CoglPipelineLayer *authority,
CoglPipelineLayer **authorities,
CoglPipelineHashState *state)
{
CoglTextureType texture_type = authority->texture_type;
state->hash = _cogl_util_one_at_a_time_hash (state->hash,
&texture_type,
sizeof (texture_type));
}
void
_cogl_pipeline_layer_hash_texture_data_state (CoglPipelineLayer *authority,
CoglPipelineLayer **authorities,

View File

@ -159,13 +159,9 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
* cogl_pipeline_set_layer_null_texture:
* @pipeline: A #CoglPipeline
* @layer_index: The layer number to modify
* @texture_type: The type of the default texture to use
*
* Sets the texture for this layer to be the default texture for the
* given type. This is equivalent to calling
* cogl_pipeline_set_layer_texture() with %NULL for the texture
* argument except that you can also specify the type of default
* texture to use. The default texture is a 1x1 pixel white texture.
* given type. The default texture is a 1x1 pixel white texture.
*
* This function is mostly useful if you want to create a base
* pipeline that you want to create multiple copies from using
@ -178,8 +174,7 @@ cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
*/
void
cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline,
int layer_index,
CoglTextureType texture_type);
int layer_index);
/**
* cogl_pipeline_get_layer_texture:

View File

@ -187,10 +187,6 @@ _cogl_pipeline_layer_copy_differences (CoglPipelineLayer *dest,
g_warn_if_reached ();
break;
case COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX:
dest->texture_type = src->texture_type;
break;
case COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX:
dest->texture = src->texture;
if (dest->texture)
@ -272,7 +268,6 @@ _cogl_pipeline_layer_init_multi_property_sparse_state (
/* XXX: avoid using a default: label so we get a warning if we
* don't explicitly handle a newly defined state-group here. */
case COGL_PIPELINE_LAYER_STATE_UNIT:
case COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE:
case COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA:
case COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS:
case COGL_PIPELINE_LAYER_STATE_USER_MATRIX:
@ -662,16 +657,6 @@ _cogl_pipeline_layer_equal (CoglPipelineLayer *layer0,
layers_difference,
authorities1);
if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE)
{
CoglPipelineLayerStateIndex state_index =
COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX;
if (!_cogl_pipeline_layer_texture_type_equal (authorities0[state_index],
authorities1[state_index],
flags))
return FALSE;
}
if (layers_difference & COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA)
{
CoglPipelineLayerStateIndex state_index =
@ -767,7 +752,6 @@ _cogl_pipeline_init_default_layers (void)
layer->unit_index = 0;
layer->texture = NULL;
layer->texture_type = COGL_TEXTURE_TYPE_2D;
layer->sampler_cache_entry =
_cogl_sampler_cache_get_default_entry (ctx->sampler_cache);

View File

@ -87,7 +87,6 @@ typedef enum
COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE_INDEX,
COGL_PIPELINE_STATE_POINT_SIZE_INDEX,
COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE_INDEX,
COGL_PIPELINE_STATE_LOGIC_OPS_INDEX,
COGL_PIPELINE_STATE_CULL_FACE_INDEX,
COGL_PIPELINE_STATE_UNIFORMS_INDEX,
COGL_PIPELINE_STATE_VERTEX_SNIPPETS_INDEX,
@ -140,8 +139,6 @@ typedef enum _CoglPipelineState
1L<<COGL_PIPELINE_STATE_POINT_SIZE_INDEX,
COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE =
1L<<COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE_INDEX,
COGL_PIPELINE_STATE_LOGIC_OPS =
1L<<COGL_PIPELINE_STATE_LOGIC_OPS_INDEX,
COGL_PIPELINE_STATE_CULL_FACE =
1L<<COGL_PIPELINE_STATE_CULL_FACE_INDEX,
COGL_PIPELINE_STATE_UNIFORMS =
@ -188,7 +185,6 @@ typedef enum _CoglPipelineState
COGL_PIPELINE_STATE_NON_ZERO_POINT_SIZE | \
COGL_PIPELINE_STATE_POINT_SIZE | \
COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE | \
COGL_PIPELINE_STATE_LOGIC_OPS | \
COGL_PIPELINE_STATE_CULL_FACE | \
COGL_PIPELINE_STATE_UNIFORMS | \
COGL_PIPELINE_STATE_VERTEX_SNIPPETS | \
@ -200,7 +196,6 @@ typedef enum _CoglPipelineState
COGL_PIPELINE_STATE_BLEND | \
COGL_PIPELINE_STATE_DEPTH | \
COGL_PIPELINE_STATE_FOG | \
COGL_PIPELINE_STATE_LOGIC_OPS | \
COGL_PIPELINE_STATE_CULL_FACE | \
COGL_PIPELINE_STATE_UNIFORMS | \
COGL_PIPELINE_STATE_VERTEX_SNIPPETS | \
@ -265,11 +260,6 @@ typedef struct
float z_far;
} CoglPipelineFogState;
typedef struct
{
CoglColorMask color_mask;
} CoglPipelineLogicOpsState;
typedef struct
{
CoglPipelineCullFaceMode mode;
@ -301,7 +291,6 @@ typedef struct
float point_size;
unsigned int non_zero_point_size : 1;
unsigned int per_vertex_point_size : 1;
CoglPipelineLogicOpsState logic_ops_state;
CoglPipelineCullFaceState cull_face_state;
CoglPipelineUniformsState uniforms_state;
CoglPipelineSnippetList vertex_snippets;

View File

@ -218,16 +218,6 @@ _cogl_pipeline_per_vertex_point_size_equal (CoglPipeline *authority0,
authority1->big_state->per_vertex_point_size);
}
gboolean
_cogl_pipeline_logic_ops_state_equal (CoglPipeline *authority0,
CoglPipeline *authority1)
{
CoglPipelineLogicOpsState *logic_ops_state0 = &authority0->big_state->logic_ops_state;
CoglPipelineLogicOpsState *logic_ops_state1 = &authority1->big_state->logic_ops_state;
return logic_ops_state0->color_mask == logic_ops_state1->color_mask;
}
gboolean
_cogl_pipeline_cull_face_state_equal (CoglPipeline *authority0,
CoglPipeline *authority1)
@ -1203,49 +1193,6 @@ cogl_pipeline_get_depth_state (CoglPipeline *pipeline,
*state = authority->big_state->depth_state;
}
CoglColorMask
cogl_pipeline_get_color_mask (CoglPipeline *pipeline)
{
CoglPipeline *authority;
_COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), 0);
authority =
_cogl_pipeline_get_authority (pipeline, COGL_PIPELINE_STATE_LOGIC_OPS);
return authority->big_state->logic_ops_state.color_mask;
}
void
cogl_pipeline_set_color_mask (CoglPipeline *pipeline,
CoglColorMask color_mask)
{
CoglPipelineState state = COGL_PIPELINE_STATE_LOGIC_OPS;
CoglPipeline *authority;
CoglPipelineLogicOpsState *logic_ops_state;
_COGL_RETURN_IF_FAIL (cogl_is_pipeline (pipeline));
authority = _cogl_pipeline_get_authority (pipeline, state);
logic_ops_state = &authority->big_state->logic_ops_state;
if (logic_ops_state->color_mask == color_mask)
return;
/* - Flush journal primitives referencing the current state.
* - Make sure the pipeline has no dependants so it may be modified.
* - If the pipeline isn't currently an authority for the state being
* changed, then initialize that state from the current authority.
*/
_cogl_pipeline_pre_change_notify (pipeline, state, NULL, FALSE);
logic_ops_state = &pipeline->big_state->logic_ops_state;
logic_ops_state->color_mask = color_mask;
_cogl_pipeline_update_authority (pipeline, authority, state,
_cogl_pipeline_logic_ops_state_equal);
}
void
_cogl_pipeline_set_fog_state (CoglPipeline *pipeline,
const CoglPipelineFogState *fog_state)
@ -1951,15 +1898,6 @@ _cogl_pipeline_hash_per_vertex_point_size_state (CoglPipeline *authority,
sizeof (per_vertex_point_size));
}
void
_cogl_pipeline_hash_logic_ops_state (CoglPipeline *authority,
CoglPipelineHashState *state)
{
CoglPipelineLogicOpsState *logic_ops_state = &authority->big_state->logic_ops_state;
state->hash = _cogl_util_one_at_a_time_hash (state->hash, &logic_ops_state->color_mask,
sizeof (CoglColorMask));
}
void
_cogl_pipeline_hash_cull_face_state (CoglPipeline *authority,
CoglPipelineHashState *state)

View File

@ -571,38 +571,6 @@ cogl_pipeline_set_per_vertex_point_size (CoglPipeline *pipeline,
gboolean
cogl_pipeline_get_per_vertex_point_size (CoglPipeline *pipeline);
/**
* cogl_pipeline_get_color_mask:
* @pipeline: a #CoglPipeline object.
*
* Gets the current #CoglColorMask of which channels would be written to the
* current framebuffer. Each bit set in the mask means that the
* corresponding color would be written.
*
* Returns: A #CoglColorMask
* Since: 1.8
* Stability: unstable
*/
CoglColorMask
cogl_pipeline_get_color_mask (CoglPipeline *pipeline);
/**
* cogl_pipeline_set_color_mask:
* @pipeline: a #CoglPipeline object.
* @color_mask: A #CoglColorMask of which color channels to write to
* the current framebuffer.
*
* Defines a bit mask of which color channels should be written to the
* current framebuffer. If a bit is set in @color_mask that means that
* color will be written.
*
* Since: 1.8
* Stability: unstable
*/
void
cogl_pipeline_set_color_mask (CoglPipeline *pipeline,
CoglColorMask color_mask);
/**
* cogl_pipeline_get_user_program:
* @pipeline: a #CoglPipeline object.
@ -658,10 +626,6 @@ cogl_pipeline_get_user_program (CoglPipeline *pipeline);
* meantime we hope this will handle most practical GLSL and ARBfp
* requirements.
*
* Also remember you need to check for either the
* %COGL_FEATURE_SHADERS_GLSL or %COGL_FEATURE_SHADERS_ARBFP before
* using the cogl_program or cogl_shader API.
*
* Since: 2.0
* Stability: Unstable
*/

View File

@ -99,7 +99,6 @@ _cogl_pipeline_init_default_pipeline (void)
CoglPipelineLightingState *lighting_state = &big_state->lighting_state;
CoglPipelineAlphaFuncState *alpha_state = &big_state->alpha_state;
CoglPipelineBlendState *blend_state = &big_state->blend_state;
CoglPipelineLogicOpsState *logic_ops_state = &big_state->logic_ops_state;
CoglPipelineCullFaceState *cull_face_state = &big_state->cull_face_state;
CoglPipelineUniformsState *uniforms_state = &big_state->uniforms_state;
@ -189,8 +188,6 @@ _cogl_pipeline_init_default_pipeline (void)
big_state->point_size = 0.0f;
logic_ops_state->color_mask = COGL_COLOR_MASK_ALL;
cull_face_state->mode = COGL_PIPELINE_CULL_FACE_MODE_NONE;
cull_face_state->front_winding = COGL_WINDING_COUNTER_CLOCKWISE;
@ -455,15 +452,8 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
_cogl_bitmask_destroy (&uniforms_state->changed_mask);
}
if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE)
g_slice_free (CoglPipelineBigState, pipeline->big_state);
if (pipeline->differences & COGL_PIPELINE_STATE_LAYERS)
{
g_list_foreach (pipeline->layer_differences,
(GFunc)cogl_object_unref, NULL);
g_list_free (pipeline->layer_differences);
}
g_list_free_full (pipeline->layer_differences, cogl_object_unref);
if (pipeline->differences & COGL_PIPELINE_STATE_VERTEX_SNIPPETS)
_cogl_pipeline_snippet_list_free (&pipeline->big_state->vertex_snippets);
@ -471,6 +461,9 @@ _cogl_pipeline_free (CoglPipeline *pipeline)
if (pipeline->differences & COGL_PIPELINE_STATE_FRAGMENT_SNIPPETS)
_cogl_pipeline_snippet_list_free (&pipeline->big_state->fragment_snippets);
if (pipeline->differences & COGL_PIPELINE_STATE_NEEDS_BIG_STATE)
g_slice_free (CoglPipelineBigState, pipeline->big_state);
g_list_free (pipeline->deprecated_get_layers_list);
recursively_free_layer_caches (pipeline);
@ -940,12 +933,7 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
if (dest->differences & COGL_PIPELINE_STATE_LAYERS &&
dest->layer_differences)
{
g_list_foreach (dest->layer_differences,
(GFunc)cogl_object_unref,
NULL);
g_list_free (dest->layer_differences);
}
g_list_free_full (dest->layer_differences, cogl_object_unref);
for (l = src->layer_differences; l; l = l->next)
{
@ -1030,13 +1018,6 @@ _cogl_pipeline_copy_differences (CoglPipeline *dest,
if (differences & COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE)
big_state->per_vertex_point_size = src->big_state->per_vertex_point_size;
if (differences & COGL_PIPELINE_STATE_LOGIC_OPS)
{
memcpy (&big_state->logic_ops_state,
&src->big_state->logic_ops_state,
sizeof (CoglPipelineLogicOpsState));
}
if (differences & COGL_PIPELINE_STATE_CULL_FACE)
{
memcpy (&big_state->cull_face_state,
@ -1150,13 +1131,6 @@ _cogl_pipeline_init_multi_property_sparse_state (CoglPipeline *pipeline,
sizeof (CoglPipelineFogState));
break;
}
case COGL_PIPELINE_STATE_LOGIC_OPS:
{
memcpy (&pipeline->big_state->logic_ops_state,
&authority->big_state->logic_ops_state,
sizeof (CoglPipelineLogicOpsState));
break;
}
case COGL_PIPELINE_STATE_CULL_FACE:
{
memcpy (&pipeline->big_state->cull_face_state,
@ -1921,7 +1895,6 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
{
CoglPipelineFallbackState *state = user_data;
CoglPipeline *pipeline = state->pipeline;
CoglTextureType texture_type = _cogl_pipeline_layer_get_texture_type (layer);
CoglTexture *texture = NULL;
COGL_STATIC_COUNTER (layer_fallback_counter,
"layer fallback counter",
@ -1936,20 +1909,7 @@ fallback_layer_cb (CoglPipelineLayer *layer, void *user_data)
COGL_COUNTER_INC (_cogl_uprof_context, layer_fallback_counter);
switch (texture_type)
{
case COGL_TEXTURE_TYPE_2D:
texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex);
break;
case COGL_TEXTURE_TYPE_3D:
texture = COGL_TEXTURE (ctx->default_gl_texture_3d_tex);
break;
case COGL_TEXTURE_TYPE_RECTANGLE:
texture = COGL_TEXTURE (ctx->default_gl_texture_rect_tex);
break;
}
texture = COGL_TEXTURE (ctx->default_gl_texture_2d_tex);
if (texture == NULL)
{
@ -2323,11 +2283,6 @@ _cogl_pipeline_equal (CoglPipeline *pipeline0,
authorities1[bit]))
goto done;
break;
case COGL_PIPELINE_STATE_LOGIC_OPS_INDEX:
if (!_cogl_pipeline_logic_ops_state_equal (authorities0[bit],
authorities1[bit]))
goto done;
break;
case COGL_PIPELINE_STATE_USER_SHADER_INDEX:
if (!_cogl_pipeline_user_shader_equal (authorities0[bit],
authorities1[bit]))
@ -2647,8 +2602,6 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
CoglPipelineLayerStateIndex _index;
layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_UNIT_INDEX] =
_cogl_pipeline_layer_hash_unit_state;
layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE_INDEX] =
_cogl_pipeline_layer_hash_texture_type_state;
layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_TEXTURE_DATA_INDEX] =
_cogl_pipeline_layer_hash_texture_data_state;
layer_state_hash_functions[COGL_PIPELINE_LAYER_STATE_SAMPLER_INDEX] =
@ -2671,7 +2624,7 @@ _cogl_pipeline_init_layer_state_hash_functions (void)
{
/* So we get a big error if we forget to update this code! */
_COGL_STATIC_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 10,
_COGL_STATIC_ASSERT (COGL_PIPELINE_LAYER_STATE_SPARSE_COUNT == 9,
"Don't forget to install a hash function for new "
"pipeline state and update assert at end of "
"_cogl_pipeline_init_state_hash_functions");
@ -2776,8 +2729,6 @@ _cogl_pipeline_init_state_hash_functions (void)
_cogl_pipeline_hash_point_size_state;
state_hash_functions[COGL_PIPELINE_STATE_PER_VERTEX_POINT_SIZE_INDEX] =
_cogl_pipeline_hash_per_vertex_point_size_state;
state_hash_functions[COGL_PIPELINE_STATE_LOGIC_OPS_INDEX] =
_cogl_pipeline_hash_logic_ops_state;
state_hash_functions[COGL_PIPELINE_STATE_UNIFORMS_INDEX] =
_cogl_pipeline_hash_uniforms_state;
state_hash_functions[COGL_PIPELINE_STATE_VERTEX_SNIPPETS_INDEX] =
@ -2787,7 +2738,7 @@ _cogl_pipeline_init_state_hash_functions (void)
{
/* So we get a big error if we forget to update this code! */
_COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 18,
_COGL_STATIC_ASSERT (COGL_PIPELINE_STATE_SPARSE_COUNT == 17,
"Make sure to install a hash function for "
"newly added pipeline state and update assert "
"in _cogl_pipeline_init_state_hash_functions");
@ -3078,15 +3029,13 @@ _cogl_pipeline_get_layer_state_for_fragment_codegen (CoglContext *context)
{
CoglPipelineLayerState state =
(COGL_PIPELINE_LAYER_STATE_COMBINE |
COGL_PIPELINE_LAYER_STATE_TEXTURE_TYPE |
COGL_PIPELINE_LAYER_STATE_UNIT |
COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS);
/* If the driver supports GLSL then we might be using gl_PointCoord
/* Since the driver supports GLSL then we might be using gl_PointCoord
* to implement the sprite coords. In that case the generated code
* depends on the point sprite state */
if (cogl_has_feature (context, COGL_FEATURE_ID_GLSL))
state |= COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
state |= COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
return state;
}

View File

@ -0,0 +1,374 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2007,2008,2009,2010 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
*/
#include "cogl-config.h"
#include "cogl-defines.h"
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include "cogl-pixel-format.h"
/* An entry to map CoglPixelFormats to their respective properties */
typedef struct _CoglPixelFormatInfo
{
CoglPixelFormat cogl_format;
const char *format_str;
int bpp; /* Bytes per pixel */
int aligned; /* Aligned components? (-1 if n/a) */
} CoglPixelFormatInfo;
static const CoglPixelFormatInfo format_info_table[] = {
{
.cogl_format = COGL_PIXEL_FORMAT_ANY,
.format_str = "ANY",
.bpp = 0,
.aligned = -1
},
{
.cogl_format = COGL_PIXEL_FORMAT_A_8,
.format_str = "A_8",
.bpp = 1,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGB_565,
.format_str = "RGB_565",
.bpp = 2,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_4444,
.format_str = "RGBA_4444",
.bpp = 2,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_5551,
.format_str = "RGBA_5551",
.bpp = 2,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_YUV,
.format_str = "YUV",
.bpp = 0,
.aligned = -1
},
{
.cogl_format = COGL_PIXEL_FORMAT_G_8,
.format_str = "G_8",
.bpp = 1,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_RG_88,
.format_str = "RG_88",
.bpp = 2,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGB_888,
.format_str = "RGB_888",
.bpp = 3,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_BGR_888,
.format_str = "BGR_888",
.bpp = 3,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_8888,
.format_str = "RGBA_8888",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_BGRA_8888,
.format_str = "BGRA_8888",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_ARGB_8888,
.format_str = "ARGB_8888",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_ABGR_8888,
.format_str = "ABGR_8888",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_1010102,
.format_str = "RGBA_1010102",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_BGRA_1010102,
.format_str = "BGRA_1010102",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_ARGB_2101010,
.format_str = "ARGB_2101010",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_ABGR_2101010,
.format_str = "ABGR_2101010",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE,
.format_str = "RGBA_8888_PRE",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_BGRA_8888_PRE,
.format_str = "BGRA_8888_PRE",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_ARGB_8888_PRE,
.format_str = "ARGB_8888_PRE",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_ABGR_8888_PRE,
.format_str = "ABGR_8888_PRE",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_4444_PRE,
.format_str = "RGBA_4444_PRE",
.bpp = 2,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_5551_PRE,
.format_str = "RGBA_5551_PRE",
.bpp = 2,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_RGBA_1010102_PRE,
.format_str = "RGBA_1010102_PRE",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_BGRA_1010102_PRE,
.format_str = "BGRA_1010102_PRE",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_ARGB_2101010_PRE,
.format_str = "ARGB_2101010_PRE",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_ABGR_2101010_PRE,
.format_str = "ABGR_2101010_PRE",
.bpp = 4,
.aligned = 0
},
{
.cogl_format = COGL_PIXEL_FORMAT_DEPTH_16,
.format_str = "DEPTH_16",
.bpp = 2,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_DEPTH_32,
.format_str = "DEPTH_32",
.bpp = 4,
.aligned = 1
},
{
.cogl_format = COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8,
.format_str = "DEPTH_24_STENCIL_8",
.bpp = 4,
.aligned = 1
},
};
/*
* Returns the number of bytes-per-pixel of a given format. The bpp
* can be extracted from the least significant nibble of the pixel
* format (see CoglPixelFormat).
*
* The mapping is the following (see discussion on bug #660188):
*
* 0 = undefined
* 1, 8 = 1 bpp (e.g. A_8, G_8)
* 2 = 3 bpp, aligned (e.g. 888)
* 3 = 4 bpp, aligned (e.g. 8888)
* 4-6 = 2 bpp, not aligned (e.g. 565, 4444, 5551)
* 7 = undefined yuv
* 9 = 2 bpp, aligned
* 10 = undefined
* 11 = undefined
* 12 = 3 bpp, not aligned
* 13 = 4 bpp, not aligned (e.g. 2101010)
* 14-15 = undefined
*/
int
_cogl_pixel_format_get_bytes_per_pixel (CoglPixelFormat format)
{
size_t i;
for (i = 0; i < G_N_ELEMENTS (format_info_table); i++)
{
if (format_info_table[i].cogl_format == format)
return format_info_table[i].bpp;
}
g_assert_not_reached ();
}
/* Note: this also refers to the mapping defined above for
* _cogl_pixel_format_get_bytes_per_pixel() */
gboolean
_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format)
{
int aligned = -1;
size_t i;
/* NB: currently checking whether the format components are aligned
* or not determines whether the format is endian dependent or not.
* In the future though we might consider adding formats with
* aligned components that are also endian independant. */
for (i = 0; i < G_N_ELEMENTS (format_info_table); i++)
{
if (format_info_table[i].cogl_format == format)
{
aligned = format_info_table[i].aligned;
break;
}
}
g_return_val_if_fail (aligned != -1, FALSE);
return aligned;
}
const char *
cogl_pixel_format_to_string (CoglPixelFormat format)
{
size_t i;
for (i = 0; i < G_N_ELEMENTS (format_info_table); i++)
{
if (format_info_table[i].cogl_format == format)
return format_info_table[i].format_str;
}
g_assert_not_reached ();
}
#ifdef COGL_HAS_LIBDRM
typedef struct _PixelFormatMap {
uint32_t drm_format;
CoglPixelFormat cogl_format;
CoglTextureComponents cogl_components;
} PixelFormatMap;
static const PixelFormatMap pixel_format_map[] = {
/* DRM formats are defined as little-endian, not machine endian. */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
{ DRM_FORMAT_RGB565, COGL_PIXEL_FORMAT_RGB_565, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
#elif G_BYTE_ORDER == G_BIG_ENDIAN
/* DRM_FORMAT_RGB565 cannot be expressed. */
{ DRM_FORMAT_ABGR8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XBGR8888, COGL_PIXEL_FORMAT_ABGR_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_ARGB8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_XRGB8888, COGL_PIXEL_FORMAT_ARGB_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_BGRA8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_BGRX8888, COGL_PIXEL_FORMAT_BGRA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
{ DRM_FORMAT_RGBA8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGBA },
{ DRM_FORMAT_RGBX8888, COGL_PIXEL_FORMAT_RGBA_8888_PRE, COGL_TEXTURE_COMPONENTS_RGB },
#else
#error "unexpected G_BYTE_ORDER"
#endif
};
gboolean
cogl_pixel_format_from_drm_format (uint32_t drm_format,
CoglPixelFormat *out_format,
CoglTextureComponents *out_components)
{
const size_t n = G_N_ELEMENTS (pixel_format_map);
size_t i;
for (i = 0; i < n; i++)
{
if (pixel_format_map[i].drm_format == drm_format)
break;
}
if (i == n)
return FALSE;
if (out_format)
*out_format = pixel_format_map[i].cogl_format;
if (out_components)
*out_components = pixel_format_map[i].cogl_components;
return TRUE;
}
#endif

View File

@ -0,0 +1,335 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2008,2009 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_PIXEL_FORMAT_H__
#define __COGL_PIXEL_FORMAT_H__
#include <stdint.h>
#include <stddef.h>
#ifdef COGL_HAS_LIBDRM
#include <drm_fourcc.h>
#endif
#include <cogl/cogl-defines.h>
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
/**
* SECTION:cogl-pixel-format
* @short_description: Pixel formats supported by Cogl
*
* The pixel format of an image descrbes how the bits of each pixel are
* represented in memory. For example: an image can be laid out as one long
* sequence of pixels, where each pixel is a sequence of 8 bits of Red, Green
* and Blue. The amount of bits that are used can be different for each pixel
* format, as well as the components (for example an Alpha layer to include
* transparency, or non_RGBA).
*
* Other examples of factors that can influence the layout in memory are the
* system's endianness.
*
* This file also contains methods to map Linux DRM 4CC codes to
* CoglPixelFormats.
*/
#define COGL_A_BIT (1 << 4)
#define COGL_BGR_BIT (1 << 5)
#define COGL_AFIRST_BIT (1 << 6)
#define COGL_PREMULT_BIT (1 << 7)
#define COGL_DEPTH_BIT (1 << 8)
#define COGL_STENCIL_BIT (1 << 9)
/* XXX: Notes to those adding new formats here...
*
* First this diagram outlines how we allocate the 32bits of a
* CoglPixelFormat currently...
*
* 6 bits for flags
* |-----|
* enum unused 4 bits for the bytes-per-pixel
* and component alignment info
* |------| |-------------| |--|
* 00000000 xxxxxxxx xxxxxxSD PFBA0000
* ^ stencil
* ^ depth
* ^ premult
* ^ alpha first
* ^ bgr order
* ^ has alpha
*
* The most awkward part about the formats is how we use the last 4
* bits to encode the bytes per pixel and component alignment
* information. Ideally we should have had 3 bits for the bpp and a
* flag for alignment but we didn't plan for that in advance so we
* instead use a small lookup table to query the bpp and whether the
* components are byte aligned or not.
*
* The mapping is the following (see discussion on bug #660188):
*
* 0 = undefined
* 1, 8 = 1 bpp (e.g. A_8, G_8)
* 2 = 3 bpp, aligned (e.g. 888)
* 3 = 4 bpp, aligned (e.g. 8888)
* 4-6 = 2 bpp, not aligned (e.g. 565, 4444, 5551)
* 7 = YUV: undefined bpp, undefined alignment
* 9 = 2 bpp, aligned
* 10 = depth, aligned (8, 16, 24, 32, 32f)
* 11 = undefined
* 12 = 3 bpp, not aligned
* 13 = 4 bpp, not aligned (e.g. 2101010)
* 14-15 = undefined
*
* Note: the gap at 10-11 is just because we wanted to maintain that
* all non-aligned formats have the third bit set in case that's
* useful later.
*
* Since we don't want to waste bits adding more and more flags, we'd
* like to see most new pixel formats that can't be represented
* uniquely with the existing flags in the least significant byte
* simply be enumerated with sequential values in the most significant
* enum byte.
*
* Note: Cogl avoids exposing any padded XRGB or RGBX formats and
* instead we leave it up to applications to decided whether they
* consider the A component as padding or valid data. We shouldn't
* change this policy without good reasoning.
*
* So to add a new format:
* 1) Use the mapping table above to figure out what to but in
* the lowest nibble.
* 2) OR in the COGL_PREMULT_BIT, COGL_AFIRST_BIT, COGL_A_BIT and
* COGL_BGR_BIT flags as appropriate.
* 3) If the result is not yet unique then also combine with an
* increment of the last sequence number in the most significant
* byte.
*
* The last sequence number used was 0 (i.e. no formats currently need
* a sequence number)
* Update this note whenever a new sequence number is used.
*/
/**
* CoglPixelFormat:
* @COGL_PIXEL_FORMAT_ANY: Any format
* @COGL_PIXEL_FORMAT_A_8: 8 bits alpha mask
* @COGL_PIXEL_FORMAT_RG_88: RG, 16 bits. Note that red-green textures
* are only available if %COGL_FEATURE_ID_TEXTURE_RG is advertised.
* See cogl_texture_set_components() for details.
* @COGL_PIXEL_FORMAT_RGB_565: RGB, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_4444: RGBA, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_5551: RGBA, 16 bits
* @COGL_PIXEL_FORMAT_YUV: Not currently supported
* @COGL_PIXEL_FORMAT_G_8: Single luminance component
* @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits
* @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits
* @COGL_PIXEL_FORMAT_RGBA_8888: RGBA, 32 bits
* @COGL_PIXEL_FORMAT_BGRA_8888: BGRA, 32 bits
* @COGL_PIXEL_FORMAT_ARGB_8888: ARGB, 32 bits
* @COGL_PIXEL_FORMAT_ABGR_8888: ABGR, 32 bits
* @COGL_PIXEL_FORMAT_RGBA_1010102 : RGBA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_BGRA_1010102 : BGRA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ARGB_2101010 : ARGB, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ABGR_2101010 : ABGR, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_RGBA_8888_PRE: Premultiplied RGBA, 32 bits
* @COGL_PIXEL_FORMAT_BGRA_8888_PRE: Premultiplied BGRA, 32 bits
* @COGL_PIXEL_FORMAT_ARGB_8888_PRE: Premultiplied ARGB, 32 bits
* @COGL_PIXEL_FORMAT_ABGR_8888_PRE: Premultiplied ABGR, 32 bits
* @COGL_PIXEL_FORMAT_RGBA_4444_PRE: Premultiplied RGBA, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_5551_PRE: Premultiplied RGBA, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_1010102_PRE: Premultiplied RGBA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_BGRA_1010102_PRE: Premultiplied BGRA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ARGB_2101010_PRE: Premultiplied ARGB, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ABGR_2101010_PRE: Premultiplied ABGR, 32 bits, 10 bpc
*
* Pixel formats used by Cogl. For the formats with a byte per
* component, the order of the components specify the order in
* increasing memory addresses. So for example
* %COGL_PIXEL_FORMAT_RGB_888 would have the red component in the
* lowest address, green in the next address and blue after that
* regardless of the endianness of the system.
*
* For the formats with non byte aligned components the component
* order specifies the order within a 16-bit or 32-bit number from
* most significant bit to least significant. So for
* %COGL_PIXEL_FORMAT_RGB_565, the red component would be in bits
* 11-15, the green component would be in 6-11 and the blue component
* would be in 1-5. Therefore the order in memory depends on the
* endianness of the system.
*
* When uploading a texture %COGL_PIXEL_FORMAT_ANY can be used as the
* internal format. Cogl will try to pick the best format to use
* internally and convert the texture data if necessary.
*
* Since: 0.8
*/
typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
{
COGL_PIXEL_FORMAT_ANY = 0,
COGL_PIXEL_FORMAT_A_8 = 1 | COGL_A_BIT,
COGL_PIXEL_FORMAT_RGB_565 = 4,
COGL_PIXEL_FORMAT_RGBA_4444 = 5 | COGL_A_BIT,
COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT,
COGL_PIXEL_FORMAT_YUV = 7,
COGL_PIXEL_FORMAT_G_8 = 8,
COGL_PIXEL_FORMAT_RG_88 = 9,
COGL_PIXEL_FORMAT_RGB_888 = 2,
COGL_PIXEL_FORMAT_BGR_888 = (2 | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_RGBA_8888 = (3 | COGL_A_BIT),
COGL_PIXEL_FORMAT_BGRA_8888 = (3 | COGL_A_BIT | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_ARGB_8888 = (3 | COGL_A_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_ABGR_8888 = (3 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_RGBA_1010102 = (13 | COGL_A_BIT),
COGL_PIXEL_FORMAT_BGRA_1010102 = (13 | COGL_A_BIT | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_ARGB_2101010 = (13 | COGL_A_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_ABGR_2101010 = (13 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_RGBA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_BGRA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_ARGB_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_ABGR_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_A_BIT | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_RGBA_1010102_PRE = (COGL_PIXEL_FORMAT_RGBA_1010102 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_BGRA_1010102_PRE = (COGL_PIXEL_FORMAT_BGRA_1010102 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_ARGB_2101010_PRE = (COGL_PIXEL_FORMAT_ARGB_2101010 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_ABGR_2101010_PRE = (COGL_PIXEL_FORMAT_ABGR_2101010 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_DEPTH_16 = (9 | COGL_DEPTH_BIT),
COGL_PIXEL_FORMAT_DEPTH_32 = (3 | COGL_DEPTH_BIT),
COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8 = (3 | COGL_DEPTH_BIT | COGL_STENCIL_BIT)
} CoglPixelFormat;
/*
* _cogl_pixel_format_get_bytes_per_pixel:
* @format: a #CoglPixelFormat
*
* Queries how many bytes a pixel of the given @format takes.
*
* Return value: The number of bytes taken for a pixel of the given
* @format.
*/
int
_cogl_pixel_format_get_bytes_per_pixel (CoglPixelFormat format);
/*
* _cogl_pixel_format_has_aligned_components:
* @format: a #CoglPixelFormat
*
* Queries whether the ordering of the components for the given
* @format depend on the endianness of the host CPU or if the
* components can be accessed using bit shifting and bitmasking by
* loading a whole pixel into a word.
*
* XXX: If we ever consider making something like this public we
* should really try to think of a better name and come up with
* much clearer documentation since it really depends on what
* point of view you consider this from whether a format like
* COGL_PIXEL_FORMAT_RGBA_8888 is endian dependent. E.g. If you
* read an RGBA_8888 pixel into a uint32
* it's endian dependent how you mask out the different channels.
* But If you already have separate color components and you want
* to write them to an RGBA_8888 pixel then the bytes can be
* written sequentially regardless of the endianness.
*
* Return value: %TRUE if you need to consider the host CPU
* endianness when dealing with the given @format
* else %FALSE.
*/
gboolean
_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format);
/*
* COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format):
* @format: a #CoglPixelFormat
*
* Returns TRUE if the pixel format can take a premult bit. This is
* currently true for all formats that have an alpha channel except
* COGL_PIXEL_FORMAT_A_8 (because that doesn't have any other
* components to multiply by the alpha).
*/
#define COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format) \
(((format) & COGL_A_BIT) && (format) != COGL_PIXEL_FORMAT_A_8)
/**
* cogl_pixel_format_to_string:
* @format: a #CoglPixelFormat
*
* Returns a string representation of @format, useful for debugging purposes.
*
* Returns: (transfer none): A string representation of @format.
*/
const char *
cogl_pixel_format_to_string (CoglPixelFormat format);
#ifdef COGL_HAS_LIBDRM
/* added in libdrm 2.4.95 */
#ifndef DRM_FORMAT_INVALID
#define DRM_FORMAT_INVALID 0
#endif
/**
* cogl_pixel_format_from_drm_format:
* @drm_format: The DRM 4CC code (as specified in drm_fourcc.h)
* @out_format: (optional): The corresponding #CoglPixelFormat (if successful)
* @out_components: (optional): The corresponding #CoglTextureComponents (if
* sucessful)
*
* Does an internal lookup to find a #CoglPixelFormat that matches the given
* DRM 4CC code. If no such format could be found, this function will return
* %FALSE and the output parameters will stay untouched.
*
* Returns: %TRUE if a #CoglPixelFormat corresponding to the 4CC code exists,
* %FALSE otherwise.
*/
gboolean
cogl_pixel_format_from_drm_format (uint32_t drm_format,
CoglPixelFormat *out_format,
CoglTextureComponents *out_components);
#endif
G_END_DECLS
#endif /* __COGL_PIXEL_FORMAT_H__ */

View File

@ -42,14 +42,13 @@ G_BEGIN_DECLS
/**
* SECTION:cogl-primitive-texture
* @short_description: Interface for low-level textures like
* #CoglTexture2D and #CoglTexture3D.
* #CoglTexture2D.
*
* A #CoglPrimitiveTexture is a texture that is directly represented
* by a single texture on the GPU. For example these could be a
* #CoglTexture2D, #CoglTexture3D or #CoglTextureRectangle. This is
* opposed to high level meta textures which may be composed of
* multiple primitive textures or a sub-region of another texture such
* as #CoglAtlasTexture and #CoglTexture2DSliced.
* by a single texture on the GPU. For example this could be a
* #CoglTexture2D. This is opposed to high level meta textures which
* may be composed of multiple primitive textures or a sub-region of
* another texture such as #CoglAtlasTexture and #CoglTexture2DSliced.
*
* A texture that implements this interface can be directly used with
* the low level cogl_primitive_draw() API. Other types of textures

View File

@ -926,8 +926,8 @@ cogl_primitive_foreach_attribute (CoglPrimitive *primitive,
* This drawing api doesn't support high-level meta texture types such
* as #CoglTexture2DSliced so it is the user's responsibility to
* ensure that only low-level textures that can be directly sampled by
* a GPU such as #CoglTexture2D, #CoglTextureRectangle or #CoglTexture3D
* are associated with layers of the given @pipeline.
* a GPU such as #CoglTexture2D are associated with layers of the given
* @pipeline.
*
* Stability: unstable
* Since: 1.16

View File

@ -187,8 +187,6 @@ validate_first_layer_cb (CoglPipeline *pipeline,
* texture coordinates require repeating,
* - CoglTexture2DAtlas: if the users given texture coordinates require
* repeating,
* - CoglTextureRectangle: if the users given texture coordinates require
* repeating,
* - CoglTexturePixmap: if the users given texture coordinates require
* repeating
*/
@ -427,11 +425,9 @@ validate_tex_coords_cb (CoglPipeline *pipeline,
* - CoglTexture2DSliced: if only comprised of a single slice with optional
* waste, assuming the users given texture coordinates don't require
* repeating.
* - CoglTexture{1D,2D,3D}: always.
* - CoglTexture{1D,2D}: always.
* - CoglTexture2DAtlas: assuming the users given texture coordinates don't
* require repeating.
* - CoglTextureRectangle: assuming the users given texture coordinates don't
* require repeating.
* - CoglTexturePixmap: assuming the users given texture coordinates don't
* require repeating.
*/

View File

@ -116,57 +116,6 @@ _cogl_get_enable_legacy_state (void);
#define _cogl_has_private_feature(ctx, feature) \
COGL_FLAGS_GET ((ctx)->private_features, (feature))
/*
* _cogl_pixel_format_get_bytes_per_pixel:
* @format: a #CoglPixelFormat
*
* Queries how many bytes a pixel of the given @format takes.
*
* Return value: The number of bytes taken for a pixel of the given
* @format.
*/
int
_cogl_pixel_format_get_bytes_per_pixel (CoglPixelFormat format);
/*
* _cogl_pixel_format_has_aligned_components:
* @format: a #CoglPixelFormat
*
* Queries whether the ordering of the components for the given
* @format depend on the endianness of the host CPU or if the
* components can be accessed using bit shifting and bitmasking by
* loading a whole pixel into a word.
*
* XXX: If we ever consider making something like this public we
* should really try to think of a better name and come up with
* much clearer documentation since it really depends on what
* point of view you consider this from whether a format like
* COGL_PIXEL_FORMAT_RGBA_8888 is endian dependent. E.g. If you
* read an RGBA_8888 pixel into a uint32
* it's endian dependent how you mask out the different channels.
* But If you already have separate color components and you want
* to write them to an RGBA_8888 pixel then the bytes can be
* written sequentially regardless of the endianness.
*
* Return value: %TRUE if you need to consider the host CPU
* endianness when dealing with the given @format
* else %FALSE.
*/
gboolean
_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format);
/*
* COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format):
* @format: a #CoglPixelFormat
*
* Returns TRUE if the pixel format can take a premult bit. This is
* currently true for all formats that have an alpha channel except
* COGL_PIXEL_FORMAT_A_8 (because that doesn't have any other
* components to multiply by the alpha).
*/
#define COGL_PIXEL_FORMAT_CAN_HAVE_PREMULT(format) \
(((format) & COGL_A_BIT) && (format) != COGL_PIXEL_FORMAT_A_8)
G_END_DECLS
#endif /* __COGL_PRIVATE_H__ */

View File

@ -194,10 +194,8 @@ _cogl_renderer_free (CoglRenderer *renderer)
if (renderer->libgl_module)
g_module_close (renderer->libgl_module);
g_slist_foreach (renderer->event_filters,
(GFunc) native_filter_closure_free,
NULL);
g_slist_free (renderer->event_filters);
g_slist_free_full (renderer->event_filters,
(GDestroyNotify) native_filter_closure_free);
g_array_free (renderer->poll_fds, TRUE);
@ -784,8 +782,7 @@ cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer)
_COGL_GET_CONTEXT (ctx, 0);
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2)
if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL))
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n));
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n));
#endif
return n;

View File

@ -40,7 +40,6 @@
#include "cogl-context-private.h"
#include "cogl-object.h"
#include "cogl-texture-driver.h"
#include "cogl-texture-rectangle-private.h"
#include "cogl-texture-2d.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-texture-gl-private.h"
@ -60,30 +59,13 @@ _cogl_sub_texture_unmap_quad (CoglSubTexture *sub_tex,
float *coords)
{
CoglTexture *tex = COGL_TEXTURE (sub_tex);
float width = cogl_texture_get_width (sub_tex->full_texture);
float height = cogl_texture_get_height (sub_tex->full_texture);
/* NB: coords[] come in as non-normalized if sub_tex->full_texture
* is a CoglTextureRectangle otherwhise they are normalized. The
* coordinates we write out though must always be normalized.
*
* NB: sub_tex->sub_x/y/width/height are in non-normalized
* coordinates.
*/
if (cogl_is_texture_rectangle (sub_tex->full_texture))
{
coords[0] = (coords[0] - sub_tex->sub_x) / tex->width;
coords[1] = (coords[1] - sub_tex->sub_y) / tex->height;
coords[2] = (coords[2] - sub_tex->sub_x) / tex->width;
coords[3] = (coords[3] - sub_tex->sub_y) / tex->height;
}
else
{
float width = cogl_texture_get_width (sub_tex->full_texture);
float height = cogl_texture_get_height (sub_tex->full_texture);
coords[0] = (coords[0] * width - sub_tex->sub_x) / tex->width;
coords[1] = (coords[1] * height - sub_tex->sub_y) / tex->height;
coords[2] = (coords[2] * width - sub_tex->sub_x) / tex->width;
coords[3] = (coords[3] * height - sub_tex->sub_y) / tex->height;
}
coords[0] = (coords[0] * width - sub_tex->sub_x) / tex->width;
coords[1] = (coords[1] * height - sub_tex->sub_y) / tex->height;
coords[2] = (coords[2] * width - sub_tex->sub_x) / tex->width;
coords[3] = (coords[3] * height - sub_tex->sub_y) / tex->height;
}
static void
@ -91,31 +73,13 @@ _cogl_sub_texture_map_quad (CoglSubTexture *sub_tex,
float *coords)
{
CoglTexture *tex = COGL_TEXTURE (sub_tex);
float width = cogl_texture_get_width (sub_tex->full_texture);
float height = cogl_texture_get_height (sub_tex->full_texture);
/* NB: coords[] always come in as normalized coordinates but may go
* out as non-normalized if sub_tex->full_texture is a
* CoglTextureRectangle.
*
* NB: sub_tex->sub_x/y/width/height are in non-normalized
* coordinates.
*/
if (cogl_is_texture_rectangle (sub_tex->full_texture))
{
coords[0] = coords[0] * tex->width + sub_tex->sub_x;
coords[1] = coords[1] * tex->height + sub_tex->sub_y;
coords[2] = coords[2] * tex->width + sub_tex->sub_x;
coords[3] = coords[3] * tex->height + sub_tex->sub_y;
}
else
{
float width = cogl_texture_get_width (sub_tex->full_texture);
float height = cogl_texture_get_height (sub_tex->full_texture);
coords[0] = (coords[0] * tex->width + sub_tex->sub_x) / width;
coords[1] = (coords[1] * tex->height + sub_tex->sub_y) / height;
coords[2] = (coords[2] * tex->width + sub_tex->sub_x) / width;
coords[3] = (coords[3] * tex->height + sub_tex->sub_y) / height;
}
coords[0] = (coords[0] * tex->width + sub_tex->sub_x) / width;
coords[1] = (coords[1] * tex->height + sub_tex->sub_y) / height;
coords[2] = (coords[2] * tex->width + sub_tex->sub_x) / width;
coords[3] = (coords[3] * tex->height + sub_tex->sub_y) / height;
}
typedef struct _CoglSubTextureForeachData
@ -165,8 +129,7 @@ _cogl_sub_texture_foreach_sub_texture_in_region (
_cogl_sub_texture_map_quad (sub_tex, mapped_coords);
/* TODO: Add something like cogl_is_low_level_texture() */
if (cogl_is_texture_2d (full_texture) ||
cogl_is_texture_rectangle (full_texture))
if (cogl_is_texture_2d (full_texture))
{
callback (sub_tex->full_texture,
mapped_coords,
@ -452,14 +415,6 @@ _cogl_sub_texture_get_gl_format (CoglTexture *tex)
return _cogl_texture_gl_get_format (sub_tex->full_texture);
}
static CoglTextureType
_cogl_sub_texture_get_type (CoglTexture *tex)
{
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
return _cogl_texture_get_type (sub_tex->full_texture);
}
static const CoglTextureVtable
cogl_sub_texture_vtable =
{
@ -481,7 +436,6 @@ cogl_sub_texture_vtable =
_cogl_sub_texture_gl_flush_legacy_texobj_wrap_modes,
_cogl_sub_texture_get_format,
_cogl_sub_texture_get_gl_format,
_cogl_sub_texture_get_type,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
};

View File

@ -585,65 +585,6 @@ _cogl_rect_slices_for_size (int size_to_fill,
return n_spans;
}
static int
_cogl_pot_slices_for_size (int size_to_fill,
int max_span_size,
int max_waste,
GArray *out_spans)
{
int n_spans = 0;
CoglSpan span;
/* Init first slice span */
span.start = 0;
span.size = max_span_size;
span.waste = 0;
/* Fix invalid max_waste */
if (max_waste < 0)
max_waste = 0;
while (TRUE)
{
/* Is the whole area covered? */
if (size_to_fill > span.size)
{
/* Not yet - add a span of this size */
if (out_spans)
g_array_append_val (out_spans, span);
span.start += span.size;
size_to_fill -= span.size;
n_spans++;
}
else if (span.size - size_to_fill <= max_waste)
{
/* Yes and waste is small enough */
/* Pick the next power of two up from size_to_fill. This can
sometimes be less than the span.size that would be chosen
otherwise */
span.size = _cogl_util_next_p2 (size_to_fill);
span.waste = span.size - size_to_fill;
if (out_spans)
g_array_append_val (out_spans, span);
return ++n_spans;
}
else
{
/* Yes but waste is too large */
while (span.size - size_to_fill > max_waste)
{
span.size /= 2;
g_assert (span.size > 0);
}
}
}
/* Can't get here */
return 0;
}
static void
_cogl_texture_2d_sliced_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
GLenum wrap_mode_s,
@ -700,18 +641,9 @@ setup_spans (CoglContext *ctx,
int (*slices_for_size) (int, int, int, GArray*);
/* Initialize size of largest slice according to supported features */
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT))
{
max_width = width;
max_height = height;
slices_for_size = _cogl_rect_slices_for_size;
}
else
{
max_width = _cogl_util_next_p2 (width);
max_height = _cogl_util_next_p2 (height);
slices_for_size = _cogl_pot_slices_for_size;
}
max_width = width;
max_height = height;
slices_for_size = _cogl_rect_slices_for_size;
/* Negative number means no slicing forced by the user */
if (max_waste <= -1)
@ -999,9 +931,7 @@ _cogl_texture_2d_sliced_new_from_foreign (CoglContext *ctx,
* in GLES, hence such a function prototype.
*/
/* This should only be called when the texture target is 2D. If a
rectangle texture is used then _cogl_texture_new_from_foreign
will create a cogl_texture_rectangle instead */
/* This should only be called when the texture target is 2D. */
_COGL_RETURN_VAL_IF_FAIL (gl_target == GL_TEXTURE_2D, NULL);
/* Assert it is a valid GL texture object */
@ -1512,12 +1442,6 @@ _cogl_texture_2d_sliced_get_gl_format (CoglTexture *tex)
return _cogl_texture_gl_get_format (COGL_TEXTURE (slice_tex));
}
static CoglTextureType
_cogl_texture_2d_sliced_get_type (CoglTexture *tex)
{
return COGL_TEXTURE_TYPE_2D;
}
static const CoglTextureVtable
cogl_texture_2d_sliced_vtable =
{
@ -1539,7 +1463,6 @@ cogl_texture_2d_sliced_vtable =
_cogl_texture_2d_sliced_gl_flush_legacy_texobj_wrap_modes,
_cogl_texture_2d_sliced_get_format,
_cogl_texture_2d_sliced_get_gl_format,
_cogl_texture_2d_sliced_get_type,
_cogl_texture_2d_sliced_is_foreign,
NULL /* set_auto_mipmap */
};

View File

@ -505,14 +505,7 @@ _cogl_texture_2d_is_sliced (CoglTexture *tex)
static gboolean
_cogl_texture_2d_can_hardware_repeat (CoglTexture *tex)
{
CoglContext *ctx = tex->context;
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT) ||
(_cogl_util_is_pot (tex->width) &&
_cogl_util_is_pot (tex->height)))
return TRUE;
else
return FALSE;
return TRUE;
}
static void
@ -674,12 +667,6 @@ _cogl_texture_2d_is_foreign (CoglTexture *tex)
return COGL_TEXTURE_2D (tex)->is_foreign;
}
static CoglTextureType
_cogl_texture_2d_get_type (CoglTexture *tex)
{
return COGL_TEXTURE_TYPE_2D;
}
static const CoglTextureVtable
cogl_texture_2d_vtable =
{
@ -701,7 +688,6 @@ cogl_texture_2d_vtable =
_cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes,
_cogl_texture_2d_get_format,
_cogl_texture_2d_get_gl_format,
_cogl_texture_2d_get_type,
_cogl_texture_2d_is_foreign,
_cogl_texture_2d_set_auto_mipmap
};

View File

@ -55,11 +55,6 @@ G_BEGIN_DECLS
* made up of multiple 2D textures, or atlas textures where Cogl must
* internally modify user texture coordinates before they can be used
* by the GPU.
*
* You should be aware that many GPUs only support power of two sizes
* for #CoglTexture2D textures. You can check support for non power of
* two textures by checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature
* via cogl_has_feature().
*/
typedef struct _CoglTexture2D CoglTexture2D;
@ -105,11 +100,6 @@ cogl_is_texture_2d (void *object);
* using cogl_texture_set_components() and
* cogl_texture_set_premultiplied().
*
* <note>Many GPUs only support power of two sizes for #CoglTexture2D
* textures. You can check support for non power of two textures by
* checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature via
* cogl_has_feature().</note>
*
* Returns: (transfer full): A new #CoglTexture2D object with no storage yet allocated.
*
* Since: 2.0
@ -138,11 +128,6 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
* using cogl_texture_set_components() and
* cogl_texture_set_premultiplied().
*
* <note>Many GPUs only support power of two sizes for #CoglTexture2D
* textures. You can check support for non power of two textures by
* checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature via
* cogl_has_feature().</note>
*
* Return value: (transfer full): A newly created #CoglTexture2D or %NULL on failure
* and @error will be updated.
*
@ -179,11 +164,6 @@ cogl_texture_2d_new_from_file (CoglContext *ctx,
* cogl_texture_2d_new_with_size() and then upload data using
* cogl_texture_set_data()</note>
*
* <note>Many GPUs only support power of two sizes for #CoglTexture2D
* textures. You can check support for non power of two textures by
* checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature via
* cogl_has_feature().</note>
*
* Returns: (transfer full): A newly allocated #CoglTexture2D, or if
* the size is not supported (because it is too large or a
* non-power-of-two size that the hardware doesn't support)
@ -218,11 +198,6 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
* using cogl_texture_set_components() and
* cogl_texture_set_premultiplied().
*
* <note>Many GPUs only support power of two sizes for #CoglTexture2D
* textures. You can check support for non power of two textures by
* checking for the %COGL_FEATURE_ID_TEXTURE_NPOT feature via
* cogl_has_feature().</note>
*
* Returns: (transfer full): A newly allocated #CoglTexture2D
*
* Since: 2.0

View File

@ -1,66 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2010 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Neil Roberts <neil@linux.intel.com>
*/
#ifndef __COGL_TEXTURE_3D_PRIVATE_H
#define __COGL_TEXTURE_3D_PRIVATE_H
#include "cogl-object-private.h"
#include "cogl-pipeline-private.h"
#include "cogl-texture-private.h"
#include "cogl-texture-3d.h"
struct _CoglTexture3D
{
CoglTexture _parent;
/* The internal format of the texture represented as a
CoglPixelFormat */
CoglPixelFormat internal_format;
int depth;
gboolean auto_mipmap;
gboolean mipmaps_dirty;
/* TODO: factor out these OpenGL specific members into some form
* of driver private state. */
/* The internal format of the GL texture represented as a GL enum */
GLenum gl_format;
/* The texture object number */
GLuint gl_texture;
GLenum gl_legacy_texobj_min_filter;
GLenum gl_legacy_texobj_mag_filter;
GLint gl_legacy_texobj_wrap_mode_s;
GLint gl_legacy_texobj_wrap_mode_t;
GLint gl_legacy_texobj_wrap_mode_p;
CoglTexturePixel first_pixel;
};
#endif /* __COGL_TEXTURE_3D_PRIVATE_H */

View File

@ -1,758 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2010 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Neil Roberts <neil@linux.intel.com>
*/
#include "cogl-config.h"
#include "cogl-private.h"
#include "cogl-util.h"
#include "cogl-texture-private.h"
#include "cogl-texture-3d-private.h"
#include "cogl-texture-3d.h"
#include "cogl-texture-driver.h"
#include "cogl-context-private.h"
#include "cogl-object-private.h"
#include "cogl-journal-private.h"
#include "cogl-pipeline-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-texture-gl-private.h"
#include "driver/gl/cogl-pipeline-opengl-private.h"
#include "driver/gl/cogl-util-gl-private.h"
#include <string.h>
#include <math.h>
/* These might not be defined on GLES */
#ifndef GL_TEXTURE_3D
#define GL_TEXTURE_3D 0x806F
#endif
#ifndef GL_TEXTURE_WRAP_R
#define GL_TEXTURE_WRAP_R 0x8072
#endif
static void _cogl_texture_3d_free (CoglTexture3D *tex_3d);
COGL_TEXTURE_DEFINE (Texture3D, texture_3d);
COGL_GTYPE_DEFINE_CLASS (Texture3D, texture_3d,
COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
static const CoglTextureVtable cogl_texture_3d_vtable;
static void
_cogl_texture_3d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
GLenum wrap_mode_s,
GLenum wrap_mode_t,
GLenum wrap_mode_p)
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
CoglContext *ctx = tex->context;
/* Only set the wrap mode if it's different from the current value
to avoid too many GL calls. */
if (tex_3d->gl_legacy_texobj_wrap_mode_s != wrap_mode_s ||
tex_3d->gl_legacy_texobj_wrap_mode_t != wrap_mode_t ||
tex_3d->gl_legacy_texobj_wrap_mode_p != wrap_mode_p)
{
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
tex_3d->gl_texture,
FALSE);
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
GL_TEXTURE_WRAP_S,
wrap_mode_s) );
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
GL_TEXTURE_WRAP_T,
wrap_mode_t) );
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
GL_TEXTURE_WRAP_R,
wrap_mode_p) );
tex_3d->gl_legacy_texobj_wrap_mode_s = wrap_mode_s;
tex_3d->gl_legacy_texobj_wrap_mode_t = wrap_mode_t;
tex_3d->gl_legacy_texobj_wrap_mode_p = wrap_mode_p;
}
}
static void
_cogl_texture_3d_free (CoglTexture3D *tex_3d)
{
if (tex_3d->gl_texture)
_cogl_delete_gl_texture (tex_3d->gl_texture);
/* Chain up */
_cogl_texture_free (COGL_TEXTURE (tex_3d));
}
static void
_cogl_texture_3d_set_auto_mipmap (CoglTexture *tex,
gboolean value)
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
tex_3d->auto_mipmap = value;
}
static CoglTexture3D *
_cogl_texture_3d_create_base (CoglContext *ctx,
int width,
int height,
int depth,
CoglPixelFormat internal_format,
CoglTextureLoader *loader)
{
CoglTexture3D *tex_3d = g_new (CoglTexture3D, 1);
CoglTexture *tex = COGL_TEXTURE (tex_3d);
_cogl_texture_init (tex, ctx, width, height,
internal_format, loader, &cogl_texture_3d_vtable);
tex_3d->gl_texture = 0;
tex_3d->depth = depth;
tex_3d->mipmaps_dirty = TRUE;
tex_3d->auto_mipmap = TRUE;
/* We default to GL_LINEAR for both filters */
tex_3d->gl_legacy_texobj_min_filter = GL_LINEAR;
tex_3d->gl_legacy_texobj_mag_filter = GL_LINEAR;
/* Wrap mode not yet set */
tex_3d->gl_legacy_texobj_wrap_mode_s = GL_FALSE;
tex_3d->gl_legacy_texobj_wrap_mode_t = GL_FALSE;
tex_3d->gl_legacy_texobj_wrap_mode_p = GL_FALSE;
return _cogl_texture_3d_object_new (tex_3d);
}
CoglTexture3D *
cogl_texture_3d_new_with_size (CoglContext *ctx,
int width,
int height,
int depth)
{
CoglTextureLoader *loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
loader->src.sized.width = width;
loader->src.sized.height = height;
loader->src.sized.depth = depth;
return _cogl_texture_3d_create_base (ctx, width, height, depth,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
loader);
}
CoglTexture3D *
cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
int height,
int depth)
{
CoglTextureLoader *loader;
_COGL_RETURN_VAL_IF_FAIL (bmp, NULL);
loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
loader->src.bitmap.bitmap = cogl_object_ref (bmp);
loader->src.bitmap.height = height;
loader->src.bitmap.depth = depth;
loader->src.bitmap.can_convert_in_place = FALSE; /* TODO add api for this */
return _cogl_texture_3d_create_base (_cogl_bitmap_get_context (bmp),
cogl_bitmap_get_width (bmp),
height,
depth,
cogl_bitmap_get_format (bmp),
loader);
}
CoglTexture3D *
cogl_texture_3d_new_from_data (CoglContext *context,
int width,
int height,
int depth,
CoglPixelFormat format,
int rowstride,
int image_stride,
const uint8_t *data,
CoglError **error)
{
CoglBitmap *bitmap;
CoglTexture3D *ret;
_COGL_RETURN_VAL_IF_FAIL (data, NULL);
_COGL_RETURN_VAL_IF_FAIL (format != COGL_PIXEL_FORMAT_ANY, NULL);
/* Rowstride from width if not given */
if (rowstride == 0)
rowstride = width * _cogl_pixel_format_get_bytes_per_pixel (format);
/* Image stride from height and rowstride if not given */
if (image_stride == 0)
image_stride = height * rowstride;
if (image_stride < rowstride * height)
return NULL;
/* GL doesn't support uploading when the image_stride isn't a
multiple of the rowstride. If this happens we'll just pack the
image into a new bitmap. The documentation for this function
recommends avoiding this situation. */
if (image_stride % rowstride != 0)
{
uint8_t *bmp_data;
int bmp_rowstride;
int z, y;
bitmap = _cogl_bitmap_new_with_malloc_buffer (context,
width,
depth * height,
format,
error);
if (!bitmap)
return NULL;
bmp_data = _cogl_bitmap_map (bitmap,
COGL_BUFFER_ACCESS_WRITE,
COGL_BUFFER_MAP_HINT_DISCARD,
error);
if (bmp_data == NULL)
{
cogl_object_unref (bitmap);
return NULL;
}
bmp_rowstride = cogl_bitmap_get_rowstride (bitmap);
/* Copy all of the images in */
for (z = 0; z < depth; z++)
for (y = 0; y < height; y++)
memcpy (bmp_data + (z * bmp_rowstride * height +
bmp_rowstride * y),
data + z * image_stride + rowstride * y,
bmp_rowstride);
_cogl_bitmap_unmap (bitmap);
}
else
bitmap = cogl_bitmap_new_for_data (context,
width,
image_stride / rowstride * depth,
format,
rowstride,
(uint8_t *) data);
ret = cogl_texture_3d_new_from_bitmap (bitmap,
height,
depth);
cogl_object_unref (bitmap);
if (ret &&
!cogl_texture_allocate (COGL_TEXTURE (ret), error))
{
cogl_object_unref (ret);
return NULL;
}
return ret;
}
static gboolean
_cogl_texture_3d_can_create (CoglContext *ctx,
int width,
int height,
int depth,
CoglPixelFormat internal_format,
CoglError **error)
{
GLenum gl_intformat;
GLenum gl_type;
/* This should only happen on GLES */
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
{
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"3D textures are not supported by the GPU");
return FALSE;
}
/* If NPOT textures aren't supported then the size must be a power
of two */
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT) &&
(!_cogl_util_is_pot (width) ||
!_cogl_util_is_pot (height) ||
!_cogl_util_is_pot (depth)))
{
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"A non-power-of-two size was requested but this is not "
"supported by the GPU");
return FALSE;
}
ctx->driver_vtable->pixel_format_to_gl (ctx,
internal_format,
&gl_intformat,
NULL,
&gl_type);
/* Check that the driver can create a texture with that size */
if (!ctx->texture_driver->size_supported_3d (ctx,
GL_TEXTURE_3D,
gl_intformat,
gl_type,
width,
height,
depth))
{
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"The requested dimensions are not supported by the GPU");
return FALSE;
}
return TRUE;
}
static gboolean
allocate_with_size (CoglTexture3D *tex_3d,
CoglTextureLoader *loader,
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (tex_3d);
CoglContext *ctx = tex->context;
CoglPixelFormat internal_format;
int width = loader->src.sized.width;
int height = loader->src.sized.height;
int depth = loader->src.sized.depth;
GLenum gl_intformat;
GLenum gl_format;
GLenum gl_type;
GLenum gl_texture;
internal_format =
_cogl_texture_determine_internal_format (tex, COGL_PIXEL_FORMAT_ANY);
if (!_cogl_texture_3d_can_create (ctx,
width,
height,
depth,
internal_format,
error))
return FALSE;
ctx->driver_vtable->pixel_format_to_gl (ctx,
internal_format,
&gl_intformat,
&gl_format,
&gl_type);
gl_texture =
ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, internal_format);
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
gl_texture,
FALSE);
/* Clear any GL errors */
_cogl_gl_util_clear_gl_errors (ctx);
ctx->glTexImage3D (GL_TEXTURE_3D, 0, gl_intformat,
width, height, depth,
0, gl_format, gl_type, NULL);
if (_cogl_gl_util_catch_out_of_memory (ctx, error))
{
GE( ctx, glDeleteTextures (1, &gl_texture) );
return FALSE;
}
tex_3d->gl_texture = gl_texture;
tex_3d->gl_format = gl_intformat;
tex_3d->depth = depth;
tex_3d->internal_format = internal_format;
_cogl_texture_set_allocated (tex, internal_format, width, height);
return TRUE;
}
static gboolean
allocate_from_bitmap (CoglTexture3D *tex_3d,
CoglTextureLoader *loader,
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (tex_3d);
CoglContext *ctx = tex->context;
CoglPixelFormat internal_format;
CoglBitmap *bmp = loader->src.bitmap.bitmap;
int bmp_width = cogl_bitmap_get_width (bmp);
int height = loader->src.bitmap.height;
int depth = loader->src.bitmap.depth;
CoglPixelFormat bmp_format = cogl_bitmap_get_format (bmp);
gboolean can_convert_in_place = loader->src.bitmap.can_convert_in_place;
CoglBitmap *upload_bmp;
CoglPixelFormat upload_format;
GLenum gl_intformat;
GLenum gl_format;
GLenum gl_type;
internal_format = _cogl_texture_determine_internal_format (tex, bmp_format);
if (!_cogl_texture_3d_can_create (ctx,
bmp_width, height, depth,
internal_format,
error))
return FALSE;
upload_bmp = _cogl_bitmap_convert_for_upload (bmp,
internal_format,
can_convert_in_place,
error);
if (upload_bmp == NULL)
return FALSE;
upload_format = cogl_bitmap_get_format (upload_bmp);
ctx->driver_vtable->pixel_format_to_gl (ctx,
upload_format,
NULL, /* internal format */
&gl_format,
&gl_type);
ctx->driver_vtable->pixel_format_to_gl (ctx,
internal_format,
&gl_intformat,
NULL,
NULL);
/* Keep a copy of the first pixel so that if glGenerateMipmap isn't
supported we can fallback to using GL_GENERATE_MIPMAP */
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
{
CoglError *ignore = NULL;
uint8_t *data = _cogl_bitmap_map (upload_bmp,
COGL_BUFFER_ACCESS_READ, 0,
&ignore);
tex_3d->first_pixel.gl_format = gl_format;
tex_3d->first_pixel.gl_type = gl_type;
if (data)
{
memcpy (tex_3d->first_pixel.data, data,
_cogl_pixel_format_get_bytes_per_pixel (upload_format));
_cogl_bitmap_unmap (upload_bmp);
}
else
{
g_warning ("Failed to read first pixel of bitmap for "
"glGenerateMipmap fallback");
cogl_error_free (ignore);
memset (tex_3d->first_pixel.data, 0,
_cogl_pixel_format_get_bytes_per_pixel (upload_format));
}
}
tex_3d->gl_texture =
ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, internal_format);
if (!ctx->texture_driver->upload_to_gl_3d (ctx,
GL_TEXTURE_3D,
tex_3d->gl_texture,
FALSE, /* is_foreign */
height,
depth,
upload_bmp,
gl_intformat,
gl_format,
gl_type,
error))
{
cogl_object_unref (upload_bmp);
return FALSE;
}
tex_3d->gl_format = gl_intformat;
cogl_object_unref (upload_bmp);
tex_3d->depth = loader->src.bitmap.depth;
tex_3d->internal_format = internal_format;
_cogl_texture_set_allocated (tex, internal_format,
bmp_width, loader->src.bitmap.height);
return TRUE;
}
static gboolean
_cogl_texture_3d_allocate (CoglTexture *tex,
CoglError **error)
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
CoglTextureLoader *loader = tex->loader;
_COGL_RETURN_VAL_IF_FAIL (loader, FALSE);
switch (loader->src_type)
{
case COGL_TEXTURE_SOURCE_TYPE_SIZED:
return allocate_with_size (tex_3d, loader, error);
case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
return allocate_from_bitmap (tex_3d, loader, error);
default:
break;
}
g_return_val_if_reached (FALSE);
}
static int
_cogl_texture_3d_get_max_waste (CoglTexture *tex)
{
return -1;
}
static gboolean
_cogl_texture_3d_is_sliced (CoglTexture *tex)
{
return FALSE;
}
static gboolean
_cogl_texture_3d_can_hardware_repeat (CoglTexture *tex)
{
return TRUE;
}
static void
_cogl_texture_3d_transform_coords_to_gl (CoglTexture *tex,
float *s,
float *t)
{
/* The texture coordinates map directly so we don't need to do
anything */
}
static CoglTransformResult
_cogl_texture_3d_transform_quad_coords_to_gl (CoglTexture *tex,
float *coords)
{
/* The texture coordinates map directly so we don't need to do
anything other than check for repeats */
gboolean need_repeat = FALSE;
int i;
for (i = 0; i < 4; i++)
if (coords[i] < 0.0f || coords[i] > 1.0f)
need_repeat = TRUE;
return (need_repeat ? COGL_TRANSFORM_HARDWARE_REPEAT
: COGL_TRANSFORM_NO_REPEAT);
}
static gboolean
_cogl_texture_3d_get_gl_texture (CoglTexture *tex,
GLuint *out_gl_handle,
GLenum *out_gl_target)
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
if (out_gl_handle)
*out_gl_handle = tex_3d->gl_texture;
if (out_gl_target)
*out_gl_target = GL_TEXTURE_3D;
return TRUE;
}
static void
_cogl_texture_3d_gl_flush_legacy_texobj_filters (CoglTexture *tex,
GLenum min_filter,
GLenum mag_filter)
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
CoglContext *ctx = tex->context;
if (min_filter == tex_3d->gl_legacy_texobj_min_filter
&& mag_filter == tex_3d->gl_legacy_texobj_mag_filter)
return;
/* Store new values */
tex_3d->gl_legacy_texobj_min_filter = min_filter;
tex_3d->gl_legacy_texobj_mag_filter = mag_filter;
/* Apply new filters to the texture */
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
tex_3d->gl_texture,
FALSE);
GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, mag_filter) );
GE( ctx, glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, min_filter) );
}
static void
_cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
CoglContext *ctx = tex->context;
/* Only update if the mipmaps are dirty */
if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
tex_3d->auto_mipmap && tex_3d->mipmaps_dirty)
{
/* glGenerateMipmap is defined in the FBO extension. If it's not
available we'll fallback to temporarily enabling
GL_GENERATE_MIPMAP and reuploading the first pixel */
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
_cogl_texture_gl_generate_mipmaps (tex);
#ifdef HAVE_COGL_GL
else if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_GL_FIXED))
{
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
tex_3d->gl_texture,
FALSE);
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
GL_GENERATE_MIPMAP,
GL_TRUE) );
GE( ctx, glTexSubImage3D (GL_TEXTURE_3D,
0, /* level */
0, /* xoffset */
0, /* yoffset */
0, /* zoffset */
1, /* width */
1, /* height */
1, /* depth */
tex_3d->first_pixel.gl_format,
tex_3d->first_pixel.gl_type,
tex_3d->first_pixel.data) );
GE( ctx, glTexParameteri (GL_TEXTURE_3D,
GL_GENERATE_MIPMAP,
GL_FALSE) );
}
#endif
tex_3d->mipmaps_dirty = FALSE;
}
}
static void
_cogl_texture_3d_ensure_non_quad_rendering (CoglTexture *tex)
{
/* Nothing needs to be done */
}
static gboolean
_cogl_texture_3d_set_region (CoglTexture *tex,
int src_x,
int src_y,
int dst_x,
int dst_y,
int dst_width,
int dst_height,
int level,
CoglBitmap *bmp,
CoglError **error)
{
/* This function doesn't really make sense for 3D textures because
it can't specify which image to upload to */
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Setting a 2D region on a 3D texture isn't "
"currently supported");
return FALSE;
}
static int
_cogl_texture_3d_get_data (CoglTexture *tex,
CoglPixelFormat format,
int rowstride,
uint8_t *data)
{
/* FIXME: we could probably implement this by assuming the data is
big enough to hold all of the images and that there is no stride
between the images. However it would be better to have an API
that can provide an image stride and this function probably isn't
particularly useful anyway so for now it just reports failure */
return 0;
}
static CoglPixelFormat
_cogl_texture_3d_get_format (CoglTexture *tex)
{
return COGL_TEXTURE_3D (tex)->internal_format;
}
static GLenum
_cogl_texture_3d_get_gl_format (CoglTexture *tex)
{
return COGL_TEXTURE_3D (tex)->gl_format;
}
static CoglTextureType
_cogl_texture_3d_get_type (CoglTexture *tex)
{
return COGL_TEXTURE_TYPE_3D;
}
static const CoglTextureVtable
cogl_texture_3d_vtable =
{
TRUE, /* primitive */
_cogl_texture_3d_allocate,
_cogl_texture_3d_set_region,
NULL, /* is_get_data_supported */
_cogl_texture_3d_get_data,
NULL, /* foreach_sub_texture_in_region */
_cogl_texture_3d_get_max_waste,
_cogl_texture_3d_is_sliced,
_cogl_texture_3d_can_hardware_repeat,
_cogl_texture_3d_transform_coords_to_gl,
_cogl_texture_3d_transform_quad_coords_to_gl,
_cogl_texture_3d_get_gl_texture,
_cogl_texture_3d_gl_flush_legacy_texobj_filters,
_cogl_texture_3d_pre_paint,
_cogl_texture_3d_ensure_non_quad_rendering,
_cogl_texture_3d_gl_flush_legacy_texobj_wrap_modes,
_cogl_texture_3d_get_format,
_cogl_texture_3d_get_gl_format,
_cogl_texture_3d_get_type,
NULL, /* is_foreign */
_cogl_texture_3d_set_auto_mipmap
};

View File

@ -1,202 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2010 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors:
* Neil Roberts <neil@linux.intel.com>
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef __COGL_TEXTURE_3D_H
#define __COGL_TEXTURE_3D_H
G_BEGIN_DECLS
/**
* SECTION:cogl-texture-3d
* @short_description: Functions for creating and manipulating 3D textures
*
* These functions allow 3D textures to be used. 3D textures can be
* thought of as layers of 2D images arranged into a cuboid
* shape. When choosing a texel from the texture, Cogl will take into
* account the 'r' texture coordinate to select one of the images.
*/
typedef struct _CoglTexture3D CoglTexture3D;
#define COGL_TEXTURE_3D(X) ((CoglTexture3D *)X)
/**
* cogl_texture_3d_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_3d_get_gtype (void);
/**
* cogl_texture_3d_new_with_size:
* @context: a #CoglContext
* @width: width of the texture in pixels.
* @height: height of the texture in pixels.
* @depth: depth of the texture in pixels.
*
* Creates a low-level #CoglTexture3D texture with the specified
* dimensions and pixel format.
*
* The storage for the texture is not allocated before this function
* returns. You can call cogl_texture_allocate() to explicitly
* allocate the underlying storage or preferably let Cogl
* automatically allocate storage lazily when it may know more about
* how the texture is going to be used and can optimize how it is
* allocated.
*
* The texture is still configurable until it has been allocated so
* for example you can influence the internal format of the texture
* using cogl_texture_set_components() and
* cogl_texture_set_premultiplied().
*
* <note>This texture will fail to allocate later if
* %COGL_FEATURE_ID_TEXTURE_3D is not advertised. Allocation can also
* fail if the requested dimensions are not supported by the
* GPU.</note>
*
* Returns: (transfer full): A new #CoglTexture3D object with no storage yet allocated.
* Since: 1.10
* Stability: Unstable
*/
CoglTexture3D *
cogl_texture_3d_new_with_size (CoglContext *context,
int width,
int height,
int depth);
/**
* cogl_texture_3d_new_from_data:
* @context: a #CoglContext
* @width: width of the texture in pixels.
* @height: height of the texture in pixels.
* @depth: depth of the texture in pixels.
* @format: the #CoglPixelFormat the buffer is stored in in RAM
* @rowstride: the memory offset in bytes between the starts of
* scanlines in @data or 0 to infer it from the width and format
* @image_stride: the number of bytes from one image to the next. This
* can be used to add padding between the images in a similar way
* that the rowstride can be used to add padding between
* rows. Alternatively 0 can be passed to infer the @image_stride
* from the @height.
* @data: pointer the memory region where the source buffer resides
* @error: A CoglError return location.
*
* Creates a low-level 3D texture and initializes it with @data. The
* data is assumed to be packed array of @depth images. There can be
* padding between the images using @image_stride.
*
* <note>This api will always immediately allocate GPU memory for the
* texture and upload the given data so that the @data pointer does
* not need to remain valid once this function returns. This means it
* is not possible to configure the texture before it is allocated. If
* you do need to configure the texture before allocation (to specify
* constraints on the internal format for example) then you can
* instead create a #CoglBitmap for your data and use
* cogl_texture_3d_new_from_bitmap().</note>
*
* Return value: (transfer full): the newly created #CoglTexture3D or
* %NULL if there was an error and an exception will be
* returned through @error.
* Since: 1.10
* Stability: Unstable
*/
CoglTexture3D *
cogl_texture_3d_new_from_data (CoglContext *context,
int width,
int height,
int depth,
CoglPixelFormat format,
int rowstride,
int image_stride,
const uint8_t *data,
CoglError **error);
/**
* cogl_texture_3d_new_from_bitmap:
* @bitmap: A #CoglBitmap object.
* @height: height of the texture in pixels.
* @depth: depth of the texture in pixels.
*
* Creates a low-level 3D texture and initializes it with the images
* in @bitmap. The images are assumed to be packed together after one
* another in the increasing y axis. The height of individual image is
* given as @height and the number of images is given in @depth. The
* actual height of the bitmap can be larger than @height × @depth. In
* this case it assumes there is padding between the images.
*
* The storage for the texture is not allocated before this function
* returns. You can call cogl_texture_allocate() to explicitly
* allocate the underlying storage or preferably let Cogl
* automatically allocate storage lazily when it may know more about
* how the texture is going to be used and can optimize how it is
* allocated.
*
* The texture is still configurable until it has been allocated so
* for example you can influence the internal format of the texture
* using cogl_texture_set_components() and
* cogl_texture_set_premultiplied().
*
* <note>This texture will fail to allocate later if
* %COGL_FEATURE_ID_TEXTURE_3D is not advertised. Allocation can also
* fail if the requested dimensions are not supported by the
* GPU.</note>
*
* Return value: (transfer full): a newly created #CoglTexture3D
* Since: 2.0
* Stability: unstable
*/
CoglTexture3D *
cogl_texture_3d_new_from_bitmap (CoglBitmap *bitmap,
int height,
int depth);
/**
* cogl_is_texture_3d:
* @object: a #CoglObject
*
* Checks whether the given object references a #CoglTexture3D
*
* Return value: %TRUE if the passed object represents a 3D texture
* and %FALSE otherwise
*
* Since: 1.4
* Stability: Unstable
*/
gboolean
cogl_is_texture_3d (void *object);
G_END_DECLS
#endif /* __COGL_TEXTURE_3D_H */

View File

@ -103,26 +103,6 @@ struct _CoglTextureDriver
GLuint source_gl_type,
CoglError **error);
/*
* Replaces the contents of the GL texture with the entire bitmap. The
* width of the texture is inferred from the bitmap. The height and
* depth of the texture is given directly. The 'image_height' (which
* is the number of rows between images) is inferred by dividing the
* height of the bitmap by the depth.
*/
gboolean
(* upload_to_gl_3d) (CoglContext *ctx,
GLenum gl_target,
GLuint gl_handle,
gboolean is_foreign,
GLint height,
GLint depth,
CoglBitmap *source_bmp,
GLint internal_gl_format,
GLuint source_gl_format,
GLuint source_gl_type,
CoglError **error);
/*
* This sets up the glPixelStore state for an download to a destination with
* the same size, and with no offset.
@ -162,15 +142,6 @@ struct _CoglTextureDriver
int width,
int height);
gboolean
(* size_supported_3d) (CoglContext *ctx,
GLenum gl_target,
GLenum gl_format,
GLenum gl_type,
int width,
int height,
int depth);
/*
* It may depend on the driver as to what texture targets may be used when
* creating a foreign texture. E.g. OpenGL supports ARB_texture_rectangle

View File

@ -146,8 +146,6 @@ struct _CoglTextureVtable
CoglPixelFormat (* get_format) (CoglTexture *tex);
GLenum (* get_gl_format) (CoglTexture *tex);
CoglTextureType (* get_type) (CoglTexture *tex);
gboolean (* is_foreign) (CoglTexture *tex);
/* Only needs to be implemented if is_primitive == TRUE */
@ -354,18 +352,6 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
CoglMetaTextureCallback callback,
void *user_data);
/*
* _cogl_texture_get_type:
* @texture: a #CoglTexture pointer
*
* Retrieves the texture type of the underlying hardware texture that
* this #CoglTexture will use.
*
* Return value: The type of the hardware texture.
*/
CoglTextureType
_cogl_texture_get_type (CoglTexture *texture);
gboolean
_cogl_texture_set_region (CoglTexture *texture,
int width,

View File

@ -1,66 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2009 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
*/
#ifndef __COGL_TEXTURE_RECTANGLE_H
#define __COGL_TEXTURE_RECTANGLE_H
#include "cogl-pipeline-private.h"
#include "cogl-texture-private.h"
#include "cogl-texture-rectangle.h"
struct _CoglTextureRectangle
{
CoglTexture _parent;
/* The internal format of the texture represented as a
CoglPixelFormat */
CoglPixelFormat internal_format;
/* TODO: factor out these OpenGL specific members into some form
* of driver private state. */
/* The internal format of the GL texture represented as a GL enum */
GLenum gl_format;
/* The texture object number */
GLuint gl_texture;
GLenum gl_legacy_texobj_min_filter;
GLenum gl_legacy_texobj_mag_filter;
GLint gl_legacy_texobj_wrap_mode_s;
GLint gl_legacy_texobj_wrap_mode_t;
gboolean is_foreign;
};
CoglTextureRectangle *
_cogl_texture_rectangle_new_from_foreign (GLuint gl_handle,
GLuint width,
GLuint height,
CoglPixelFormat format);
#endif /* __COGL_TEXTURE_RECTANGLE_H */

View File

@ -1,776 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2010 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
*
* Authors:
* Neil Roberts <neil@linux.intel.com>
*/
#include "cogl-config.h"
#include "cogl-private.h"
#include "cogl-util.h"
#include "cogl-texture-private.h"
#include "cogl-texture-rectangle-private.h"
#include "cogl-texture-driver.h"
#include "cogl-context-private.h"
#include "cogl-object-private.h"
#include "cogl-journal-private.h"
#include "cogl-error-private.h"
#include "cogl-gtype-private.h"
#include "driver/gl/cogl-pipeline-opengl-private.h"
#include "driver/gl/cogl-util-gl-private.h"
#include <string.h>
#include <math.h>
/* These aren't defined under GLES */
#ifndef GL_TEXTURE_RECTANGLE_ARB
#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
#endif
#ifndef GL_CLAMP
#define GL_CLAMP 0x2900
#endif
#ifndef GL_CLAMP_TO_BORDER
#define GL_CLAMP_TO_BORDER 0x812D
#endif
static void _cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect);
COGL_TEXTURE_DEFINE (TextureRectangle, texture_rectangle);
COGL_GTYPE_DEFINE_CLASS (TextureRectangle, texture_rectangle,
COGL_GTYPE_IMPLEMENT_INTERFACE (texture));
static const CoglTextureVtable cogl_texture_rectangle_vtable;
static gboolean
can_use_wrap_mode (GLenum wrap_mode)
{
return (wrap_mode == GL_CLAMP ||
wrap_mode == GL_CLAMP_TO_EDGE ||
wrap_mode == GL_CLAMP_TO_BORDER);
}
static void
_cogl_texture_rectangle_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
GLenum wrap_mode_s,
GLenum wrap_mode_t,
GLenum wrap_mode_p)
{
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
CoglContext *ctx = tex->context;
/* Only set the wrap mode if it's different from the current value
to avoid too many GL calls. Texture rectangle doesn't make use of
the r coordinate so we can ignore its wrap mode */
if (tex_rect->gl_legacy_texobj_wrap_mode_s != wrap_mode_s ||
tex_rect->gl_legacy_texobj_wrap_mode_t != wrap_mode_t)
{
g_assert (can_use_wrap_mode (wrap_mode_s));
g_assert (can_use_wrap_mode (wrap_mode_t));
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
tex_rect->gl_texture,
tex_rect->is_foreign);
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
GL_TEXTURE_WRAP_S, wrap_mode_s) );
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
GL_TEXTURE_WRAP_T, wrap_mode_t) );
tex_rect->gl_legacy_texobj_wrap_mode_s = wrap_mode_s;
tex_rect->gl_legacy_texobj_wrap_mode_t = wrap_mode_t;
}
}
static void
_cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect)
{
if (!tex_rect->is_foreign && tex_rect->gl_texture)
_cogl_delete_gl_texture (tex_rect->gl_texture);
/* Chain up */
_cogl_texture_free (COGL_TEXTURE (tex_rect));
}
static gboolean
_cogl_texture_rectangle_can_create (CoglContext *ctx,
unsigned int width,
unsigned int height,
CoglPixelFormat internal_format,
CoglError **error)
{
GLenum gl_intformat;
GLenum gl_format;
GLenum gl_type;
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
{
_cogl_set_error (error,
COGL_TEXTURE_ERROR,
COGL_TEXTURE_ERROR_TYPE,
"The CoglTextureRectangle feature isn't available");
return FALSE;
}
ctx->driver_vtable->pixel_format_to_gl (ctx,
internal_format,
&gl_intformat,
&gl_format,
&gl_type);
/* Check that the driver can create a texture with that size */
if (!ctx->texture_driver->size_supported (ctx,
GL_TEXTURE_RECTANGLE_ARB,
gl_intformat,
gl_format,
gl_type,
width,
height))
{
_cogl_set_error (error,
COGL_TEXTURE_ERROR,
COGL_TEXTURE_ERROR_SIZE,
"The requested texture size + format is unsupported");
return FALSE;
}
return TRUE;
}
static void
_cogl_texture_rectangle_set_auto_mipmap (CoglTexture *tex,
gboolean value)
{
/* Rectangle textures currently never support mipmapping so there's
no point in doing anything here */
}
static CoglTextureRectangle *
_cogl_texture_rectangle_create_base (CoglContext *ctx,
int width,
int height,
CoglPixelFormat internal_format,
CoglTextureLoader *loader)
{
CoglTextureRectangle *tex_rect = g_new (CoglTextureRectangle, 1);
CoglTexture *tex = COGL_TEXTURE (tex_rect);
_cogl_texture_init (tex, ctx, width, height,
internal_format, loader,
&cogl_texture_rectangle_vtable);
tex_rect->gl_texture = 0;
tex_rect->is_foreign = FALSE;
/* We default to GL_LINEAR for both filters */
tex_rect->gl_legacy_texobj_min_filter = GL_LINEAR;
tex_rect->gl_legacy_texobj_mag_filter = GL_LINEAR;
/* Wrap mode not yet set */
tex_rect->gl_legacy_texobj_wrap_mode_s = GL_FALSE;
tex_rect->gl_legacy_texobj_wrap_mode_t = GL_FALSE;
return _cogl_texture_rectangle_object_new (tex_rect);
}
CoglTextureRectangle *
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
int width,
int height)
{
CoglTextureLoader *loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
loader->src.sized.width = width;
loader->src.sized.height = height;
return _cogl_texture_rectangle_create_base (ctx, width, height,
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
loader);
}
static gboolean
allocate_with_size (CoglTextureRectangle *tex_rect,
CoglTextureLoader *loader,
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (tex_rect);
CoglContext *ctx = tex->context;
CoglPixelFormat internal_format;
int width = loader->src.sized.width;
int height = loader->src.sized.height;
GLenum gl_intformat;
GLenum gl_format;
GLenum gl_type;
GLenum gl_texture;
internal_format =
_cogl_texture_determine_internal_format (tex, COGL_PIXEL_FORMAT_ANY);
if (!_cogl_texture_rectangle_can_create (ctx,
width,
height,
internal_format,
error))
return FALSE;
ctx->driver_vtable->pixel_format_to_gl (ctx,
internal_format,
&gl_intformat,
&gl_format,
&gl_type);
gl_texture =
ctx->texture_driver->gen (ctx,
GL_TEXTURE_RECTANGLE_ARB,
internal_format);
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
gl_texture,
tex_rect->is_foreign);
/* Clear any GL errors */
_cogl_gl_util_clear_gl_errors (ctx);
ctx->glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, gl_intformat,
width, height, 0, gl_format, gl_type, NULL);
if (_cogl_gl_util_catch_out_of_memory (ctx, error))
{
GE( ctx, glDeleteTextures (1, &gl_texture) );
return FALSE;
}
tex_rect->internal_format = internal_format;
tex_rect->gl_texture = gl_texture;
tex_rect->gl_format = gl_intformat;
_cogl_texture_set_allocated (COGL_TEXTURE (tex_rect),
internal_format, width, height);
return TRUE;
}
static gboolean
allocate_from_bitmap (CoglTextureRectangle *tex_rect,
CoglTextureLoader *loader,
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (tex_rect);
CoglContext *ctx = tex->context;
CoglPixelFormat internal_format;
CoglBitmap *bmp = loader->src.bitmap.bitmap;
int width = cogl_bitmap_get_width (bmp);
int height = cogl_bitmap_get_height (bmp);
gboolean can_convert_in_place = loader->src.bitmap.can_convert_in_place;
CoglBitmap *upload_bmp;
GLenum gl_intformat;
GLenum gl_format;
GLenum gl_type;
internal_format =
_cogl_texture_determine_internal_format (tex, cogl_bitmap_get_format (bmp));
if (!_cogl_texture_rectangle_can_create (ctx,
width,
height,
internal_format,
error))
return FALSE;
upload_bmp = _cogl_bitmap_convert_for_upload (bmp,
internal_format,
can_convert_in_place,
error);
if (upload_bmp == NULL)
return FALSE;
ctx->driver_vtable->pixel_format_to_gl (ctx,
cogl_bitmap_get_format (upload_bmp),
NULL, /* internal format */
&gl_format,
&gl_type);
ctx->driver_vtable->pixel_format_to_gl (ctx,
internal_format,
&gl_intformat,
NULL,
NULL);
tex_rect->gl_texture =
ctx->texture_driver->gen (ctx,
GL_TEXTURE_RECTANGLE_ARB,
internal_format);
if (!ctx->texture_driver->upload_to_gl (ctx,
GL_TEXTURE_RECTANGLE_ARB,
tex_rect->gl_texture,
FALSE,
upload_bmp,
gl_intformat,
gl_format,
gl_type,
error))
{
cogl_object_unref (upload_bmp);
return FALSE;
}
tex_rect->gl_format = gl_intformat;
tex_rect->internal_format = internal_format;
cogl_object_unref (upload_bmp);
_cogl_texture_set_allocated (COGL_TEXTURE (tex_rect),
internal_format, width, height);
return TRUE;
}
static gboolean
allocate_from_gl_foreign (CoglTextureRectangle *tex_rect,
CoglTextureLoader *loader,
CoglError **error)
{
CoglTexture *tex = COGL_TEXTURE (tex_rect);
CoglContext *ctx = tex->context;
CoglPixelFormat format = loader->src.gl_foreign.format;
GLint gl_compressed = GL_FALSE;
GLenum gl_int_format = 0;
if (!ctx->texture_driver->allows_foreign_gl_target (ctx,
GL_TEXTURE_RECTANGLE_ARB))
{
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Foreign GL_TEXTURE_RECTANGLE textures are not "
"supported by your system");
return FALSE;
}
/* Make sure binding succeeds */
_cogl_gl_util_clear_gl_errors (ctx);
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
loader->src.gl_foreign.gl_handle, TRUE);
if (_cogl_gl_util_get_error (ctx) != GL_NO_ERROR)
{
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Failed to bind foreign GL_TEXTURE_RECTANGLE texture");
return FALSE;
}
/* Obtain texture parameters */
#ifdef HAVE_COGL_GL
if (_cogl_has_private_feature
(ctx, COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS))
{
GLint val;
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
GL_TEXTURE_COMPRESSED,
&gl_compressed) );
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_RECTANGLE_ARB, 0,
GL_TEXTURE_INTERNAL_FORMAT,
&val) );
gl_int_format = val;
/* If we can query GL for the actual pixel format then we'll ignore
the passed in format and use that. */
if (!ctx->driver_vtable->pixel_format_from_gl_internal (ctx,
gl_int_format,
&format))
{
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Unsupported internal format for foreign texture");
return FALSE;
}
}
else
#endif
{
/* Otherwise we'll assume we can derive the GL format from the
passed in format */
ctx->driver_vtable->pixel_format_to_gl (ctx,
format,
&gl_int_format,
NULL,
NULL);
}
/* Compressed texture images not supported */
if (gl_compressed == GL_TRUE)
{
_cogl_set_error (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Compressed foreign textures aren't currently supported");
return FALSE;
}
/* Setup bitmap info */
tex_rect->is_foreign = TRUE;
tex_rect->gl_texture = loader->src.gl_foreign.gl_handle;
tex_rect->gl_format = gl_int_format;
/* Unknown filter */
tex_rect->gl_legacy_texobj_min_filter = GL_FALSE;
tex_rect->gl_legacy_texobj_mag_filter = GL_FALSE;
tex_rect->internal_format = format;
_cogl_texture_set_allocated (COGL_TEXTURE (tex_rect),
format,
loader->src.gl_foreign.width,
loader->src.gl_foreign.height);
return TRUE;
}
static gboolean
_cogl_texture_rectangle_allocate (CoglTexture *tex,
CoglError **error)
{
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
CoglTextureLoader *loader = tex->loader;
_COGL_RETURN_VAL_IF_FAIL (loader, FALSE);
switch (loader->src_type)
{
case COGL_TEXTURE_SOURCE_TYPE_SIZED:
return allocate_with_size (tex_rect, loader, error);
case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
return allocate_from_bitmap (tex_rect, loader, error);
case COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN:
return allocate_from_gl_foreign (tex_rect, loader, error);
default:
break;
}
g_return_val_if_reached (FALSE);
}
CoglTextureRectangle *
cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp)
{
CoglTextureLoader *loader;
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
loader->src.bitmap.bitmap = cogl_object_ref (bmp);
loader->src.bitmap.can_convert_in_place = FALSE; /* TODO add api for this */
return _cogl_texture_rectangle_create_base (_cogl_bitmap_get_context (bmp),
cogl_bitmap_get_width (bmp),
cogl_bitmap_get_height (bmp),
cogl_bitmap_get_format (bmp),
loader);
}
CoglTextureRectangle *
cogl_texture_rectangle_new_from_foreign (CoglContext *ctx,
unsigned int gl_handle,
int width,
int height,
CoglPixelFormat format)
{
CoglTextureLoader *loader;
/* NOTE: width, height and internal format are not queriable in
* GLES, hence such a function prototype. Also in the case of full
* opengl the user may be creating a Cogl texture for a
* texture_from_pixmap object where glTexImage2D may not have been
* called and the texture_from_pixmap spec doesn't clarify that it
* is reliable to query back the size from OpenGL.
*/
/* Assert that it is a valid GL texture object */
_COGL_RETURN_VAL_IF_FAIL (ctx->glIsTexture (gl_handle), NULL);
/* Validate width and height */
_COGL_RETURN_VAL_IF_FAIL (width > 0 && height > 0, NULL);
loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN;
loader->src.gl_foreign.gl_handle = gl_handle;
loader->src.gl_foreign.width = width;
loader->src.gl_foreign.height = height;
loader->src.gl_foreign.format = format;
return _cogl_texture_rectangle_create_base (ctx, width, height,
format, loader);
}
static int
_cogl_texture_rectangle_get_max_waste (CoglTexture *tex)
{
return -1;
}
static gboolean
_cogl_texture_rectangle_is_sliced (CoglTexture *tex)
{
return FALSE;
}
static gboolean
_cogl_texture_rectangle_can_hardware_repeat (CoglTexture *tex)
{
return FALSE;
}
static void
_cogl_texture_rectangle_transform_coords_to_gl (CoglTexture *tex,
float *s,
float *t)
{
*s *= tex->width;
*t *= tex->height;
}
static CoglTransformResult
_cogl_texture_rectangle_transform_quad_coords_to_gl (CoglTexture *tex,
float *coords)
{
gboolean need_repeat = FALSE;
int i;
for (i = 0; i < 4; i++)
{
if (coords[i] < 0.0f || coords[i] > 1.0f)
need_repeat = TRUE;
coords[i] *= (i & 1) ? tex->height : tex->width;
}
return (need_repeat ? COGL_TRANSFORM_SOFTWARE_REPEAT
: COGL_TRANSFORM_NO_REPEAT);
}
static gboolean
_cogl_texture_rectangle_get_gl_texture (CoglTexture *tex,
GLuint *out_gl_handle,
GLenum *out_gl_target)
{
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
if (out_gl_handle)
*out_gl_handle = tex_rect->gl_texture;
if (out_gl_target)
*out_gl_target = GL_TEXTURE_RECTANGLE_ARB;
return TRUE;
}
static void
_cogl_texture_rectangle_gl_flush_legacy_texobj_filters (CoglTexture *tex,
GLenum min_filter,
GLenum mag_filter)
{
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
CoglContext *ctx = tex->context;
if (min_filter == tex_rect->gl_legacy_texobj_min_filter
&& mag_filter == tex_rect->gl_legacy_texobj_mag_filter)
return;
/* Rectangle textures don't support mipmapping */
g_assert (min_filter == GL_LINEAR || min_filter == GL_NEAREST);
/* Store new values */
tex_rect->gl_legacy_texobj_min_filter = min_filter;
tex_rect->gl_legacy_texobj_mag_filter = mag_filter;
/* Apply new filters to the texture */
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
tex_rect->gl_texture,
tex_rect->is_foreign);
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
mag_filter) );
GE( ctx, glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
min_filter) );
}
static void
_cogl_texture_rectangle_pre_paint (CoglTexture *tex,
CoglTexturePrePaintFlags flags)
{
/* Rectangle textures don't support mipmaps */
g_assert ((flags & COGL_TEXTURE_NEEDS_MIPMAP) == 0);
}
static void
_cogl_texture_rectangle_ensure_non_quad_rendering (CoglTexture *tex)
{
/* Nothing needs to be done */
}
static gboolean
_cogl_texture_rectangle_set_region (CoglTexture *tex,
int src_x,
int src_y,
int dst_x,
int dst_y,
int dst_width,
int dst_height,
int level,
CoglBitmap *bmp,
CoglError **error)
{
CoglBitmap *upload_bmp;
GLenum gl_format;
GLenum gl_type;
CoglContext *ctx = tex->context;
gboolean status;
upload_bmp =
_cogl_bitmap_convert_for_upload (bmp,
_cogl_texture_get_format (tex),
FALSE, /* can't convert in place */
error);
if (upload_bmp == NULL)
return FALSE;
ctx->driver_vtable->pixel_format_to_gl (ctx,
cogl_bitmap_get_format (upload_bmp),
NULL, /* internal format */
&gl_format,
&gl_type);
/* Send data to GL */
status =
ctx->texture_driver->upload_subregion_to_gl (ctx,
tex,
FALSE,
src_x, src_y,
dst_x, dst_y,
dst_width, dst_height,
level,
upload_bmp,
gl_format,
gl_type,
error);
cogl_object_unref (upload_bmp);
return status;
}
static gboolean
_cogl_texture_rectangle_get_data (CoglTexture *tex,
CoglPixelFormat format,
int rowstride,
uint8_t *data)
{
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
CoglContext *ctx = tex->context;
int bpp;
GLenum gl_format;
GLenum gl_type;
bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
ctx->driver_vtable->pixel_format_to_gl (ctx,
format,
NULL, /* internal format */
&gl_format,
&gl_type);
ctx->texture_driver->prep_gl_for_pixels_download (ctx,
rowstride,
tex->width,
bpp);
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
tex_rect->gl_texture,
tex_rect->is_foreign);
return ctx->texture_driver->gl_get_tex_image (ctx,
GL_TEXTURE_RECTANGLE_ARB,
gl_format,
gl_type,
data);
}
static CoglPixelFormat
_cogl_texture_rectangle_get_format (CoglTexture *tex)
{
return COGL_TEXTURE_RECTANGLE (tex)->internal_format;
}
static GLenum
_cogl_texture_rectangle_get_gl_format (CoglTexture *tex)
{
return COGL_TEXTURE_RECTANGLE (tex)->gl_format;
}
static gboolean
_cogl_texture_rectangle_is_foreign (CoglTexture *tex)
{
return COGL_TEXTURE_RECTANGLE (tex)->is_foreign;
}
static CoglTextureType
_cogl_texture_rectangle_get_type (CoglTexture *tex)
{
return COGL_TEXTURE_TYPE_RECTANGLE;
}
static const CoglTextureVtable
cogl_texture_rectangle_vtable =
{
TRUE, /* primitive */
_cogl_texture_rectangle_allocate,
_cogl_texture_rectangle_set_region,
NULL, /* is_get_data_supported */
_cogl_texture_rectangle_get_data,
NULL, /* foreach_sub_texture_in_region */
_cogl_texture_rectangle_get_max_waste,
_cogl_texture_rectangle_is_sliced,
_cogl_texture_rectangle_can_hardware_repeat,
_cogl_texture_rectangle_transform_coords_to_gl,
_cogl_texture_rectangle_transform_quad_coords_to_gl,
_cogl_texture_rectangle_get_gl_texture,
_cogl_texture_rectangle_gl_flush_legacy_texobj_filters,
_cogl_texture_rectangle_pre_paint,
_cogl_texture_rectangle_ensure_non_quad_rendering,
_cogl_texture_rectangle_gl_flush_legacy_texobj_wrap_modes,
_cogl_texture_rectangle_get_format,
_cogl_texture_rectangle_get_gl_format,
_cogl_texture_rectangle_get_type,
_cogl_texture_rectangle_is_foreign,
_cogl_texture_rectangle_set_auto_mipmap
};

View File

@ -1,216 +0,0 @@
/*
* Cogl
*
* A Low Level GPU Graphics and Utilities API
*
* Copyright (C) 2011 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*
* Authors:
* Robert Bragg <robert@linux.intel.com>
*/
#ifndef __COGL_TEXURE_RECTANGLE_H
#define __COGL_TEXURE_RECTANGLE_H
#include "cogl-context.h"
G_BEGIN_DECLS
/**
* SECTION:cogl-texture-rectangle
* @short_description: Functions for creating and manipulating rectangle
* textures for use with non-normalized coordinates.
*
* These functions allow low-level "rectangle" textures to be allocated.
* These textures are never constrained to power-of-two sizes but they
* also don't support having a mipmap and can only be wrapped with
* %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE.
*
* The most notable difference between rectangle textures and 2D
* textures is that rectangle textures are sampled using un-normalized
* texture coordinates, so instead of using coordinates (0,0) and
* (1,1) to map to the top-left and bottom right corners of the
* texture you would instead use (0,0) and (width,height).
*
* The use of non-normalized coordinates can be particularly
* convenient when writing glsl shaders that use a texture as a lookup
* table since you don't need to upload separate uniforms to map
* normalized coordinates to texels.
*
* If you want to sample from a rectangle texture from GLSL you should
* use the sampler2DRect sampler type.
*
* Applications wanting to use #CoglTextureRectangle should first check
* for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature using
* cogl_has_feature().
*/
typedef struct _CoglTextureRectangle CoglTextureRectangle;
#define COGL_TEXTURE_RECTANGLE(X) ((CoglTextureRectangle *)X)
/**
* cogl_texture_rectangle_get_gtype:
*
* Returns: a #GType that can be used with the GLib type system.
*/
GType cogl_texture_rectangle_get_gtype (void);
/**
* cogl_is_texture_rectangle:
* @object: A #CoglObject
*
* Gets whether the given object references an existing
* #CoglTextureRectangle object.
*
* Return value: %TRUE if the object references a
* #CoglTextureRectangle, %FALSE otherwise.
*/
gboolean
cogl_is_texture_rectangle (void *object);
/**
* cogl_texture_rectangle_new_with_size:
* @ctx: A #CoglContext pointer
* @width: The texture width to allocate
* @height: The texture height to allocate
*
* Creates a new #CoglTextureRectangle texture with a given @width,
* and @height. This texture is a low-level texture that the GPU can
* sample from directly unlike high-level textures such as
* #CoglTexture2DSliced and #CoglAtlasTexture.
*
* <note>Unlike for #CoglTexture2D textures, coordinates for
* #CoglTextureRectangle textures should not be normalized. So instead
* of using the coordinate (1, 1) to sample the bottom right corner of
* a rectangle texture you would use (@width, @height) where @width
* and @height are the width and height of the texture.</note>
*
* <note>If you want to sample from a rectangle texture from GLSL you
* should use the sampler2DRect sampler type.</note>
*
* <note>Applications wanting to use #CoglTextureRectangle should
* first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
* using cogl_has_feature().</note>
*
* The storage for the texture is not allocated before this function
* returns. You can call cogl_texture_allocate() to explicitly
* allocate the underlying storage or preferably let Cogl
* automatically allocate storage lazily when it may know more about
* how the texture is going to be used and can optimize how it is
* allocated.
*
* Returns value: (transfer full): A pointer to a new #CoglTextureRectangle
* object with no storage allocated yet.
*
* Since: 1.10
* Stability: unstable
*/
CoglTextureRectangle *
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
int width,
int height);
/**
* cogl_texture_rectangle_new_from_bitmap:
* @bitmap: A #CoglBitmap
*
* Allocates a new #CoglTextureRectangle texture which will be
* initialized with the pixel data from @bitmap. This texture is a
* low-level texture that the GPU can sample from directly unlike
* high-level textures such as #CoglTexture2DSliced and
* #CoglAtlasTexture.
*
* <note>Unlike for #CoglTexture2D textures, coordinates for
* #CoglTextureRectangle textures should not be normalized. So instead
* of using the coordinate (1, 1) to sample the bottom right corner of
* a rectangle texture you would use (@width, @height) where @width
* and @height are the width and height of the texture.</note>
*
* <note>If you want to sample from a rectangle texture from GLSL you
* should use the sampler2DRect sampler type.</note>
*
* <note>Applications wanting to use #CoglTextureRectangle should
* first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
* using cogl_has_feature().</note>
*
* The storage for the texture is not allocated before this function
* returns. You can call cogl_texture_allocate() to explicitly
* allocate the underlying storage or preferably let Cogl
* automatically allocate storage lazily when it may know more about
* how the texture is going to be used and can optimize how it is
* allocated.
*
* Return value: (transfer full): A pointer to a new
* #CoglTextureRectangle texture.
* Since: 2.0
* Stability: unstable
*/
CoglTextureRectangle *
cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bitmap);
/**
* cogl_texture_rectangle_new_from_foreign:
* @ctx: A #CoglContext
* @gl_handle: A GL handle for a GL_TEXTURE_RECTANGLE texture object
* @width: Width of the foreign GL texture
* @height: Height of the foreign GL texture
* @format: The format of the texture
*
* Wraps an existing GL_TEXTURE_RECTANGLE texture object as a
* #CoglTextureRectangle. This can be used for integrating Cogl with
* software using OpenGL directly.
*
* <note>Unlike for #CoglTexture2D textures, coordinates for
* #CoglTextureRectangle textures should not be normalized. So instead
* of using the coordinate (1, 1) to sample the bottom right corner of
* a rectangle texture you would use (@width, @height) where @width
* and @height are the width and height of the texture.</note>
*
* <note>The results are undefined for passing an invalid @gl_handle
* or if @width or @height don't have the correct texture
* geometry.</note>
*
* <note>If you want to sample from a rectangle texture from GLSL you
* should use the sampler2DRect sampler type.</note>
*
* <note>Applications wanting to use #CoglTextureRectangle should
* first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
* using cogl_has_feature().</note>
*
* The texture is still configurable until it has been allocated so
* for example you can declare whether the texture is premultiplied
* with cogl_texture_set_premultiplied().
*
* Return value: (transfer full): A new #CoglTextureRectangle texture
*/
CoglTextureRectangle *
cogl_texture_rectangle_new_from_foreign (CoglContext *ctx,
unsigned int gl_handle,
int width,
int height,
CoglPixelFormat format);
G_END_DECLS
#endif /* __COGL_TEXURE_RECTANGLE_H */

View File

@ -47,8 +47,6 @@
#include "cogl-texture-2d-sliced-private.h"
#include "cogl-texture-2d-private.h"
#include "cogl-texture-2d-gl.h"
#include "cogl-texture-3d-private.h"
#include "cogl-texture-rectangle-private.h"
#include "cogl-sub-texture-private.h"
#include "cogl-atlas-texture-private.h"
#include "cogl-pipeline.h"
@ -245,12 +243,6 @@ _cogl_texture_get_n_levels (CoglTexture *texture)
int height = cogl_texture_get_height (texture);
int max_dimension = MAX (width, height);
if (cogl_is_texture_3d (texture))
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (texture);
max_dimension = MAX (max_dimension, tex_3d->depth);
}
return _cogl_util_fls (max_dimension);
}
@ -263,17 +255,9 @@ _cogl_texture_get_level_size (CoglTexture *texture,
{
int current_width = cogl_texture_get_width (texture);
int current_height = cogl_texture_get_height (texture);
int current_depth;
int current_depth = 0;
int i;
if (cogl_is_texture_3d (texture))
{
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (texture);
current_depth = tex_3d->depth;
}
else
current_depth = 0;
/* NB: The OpenGL spec (like D3D) uses a floor() convention to
* round down the size of a mipmap level when dividing the size
* of the previous level results in a fraction...
@ -343,12 +327,6 @@ cogl_texture_get_gl_texture (CoglTexture *texture,
out_gl_handle, out_gl_target);
}
CoglTextureType
_cogl_texture_get_type (CoglTexture *texture)
{
return texture->vtable->get_type (texture);
}
void
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags)
{

View File

@ -53,6 +53,7 @@ typedef struct _CoglTexture CoglTexture;
#include <cogl/cogl-macros.h>
#include <cogl/cogl-defines.h>
#include <cogl/cogl-pixel-buffer.h>
#include <cogl/cogl-pixel-format.h>
#include <cogl/cogl-bitmap.h>
#include <glib-object.h>
@ -107,25 +108,6 @@ typedef enum
COGL_TEXTURE_ERROR_TYPE
} CoglTextureError;
/**
* CoglTextureType:
* @COGL_TEXTURE_TYPE_2D: A #CoglTexture2D
* @COGL_TEXTURE_TYPE_3D: A #CoglTexture3D
* @COGL_TEXTURE_TYPE_RECTANGLE: A #CoglTextureRectangle
*
* Constants representing the underlying hardware texture type of a
* #CoglTexture.
*
* Stability: unstable
* Since: 1.10
*/
typedef enum
{
COGL_TEXTURE_TYPE_2D,
COGL_TEXTURE_TYPE_3D,
COGL_TEXTURE_TYPE_RECTANGLE
} CoglTextureType;
uint32_t cogl_texture_error_quark (void);
/**

View File

@ -147,182 +147,10 @@ typedef struct _CoglTextureVertex CoglTextureVertex;
#define COGL_DEPTH_BIT (1 << 8)
#define COGL_STENCIL_BIT (1 << 9)
/* XXX: Notes to those adding new formats here...
*
* First this diagram outlines how we allocate the 32bits of a
* CoglPixelFormat currently...
*
* 6 bits for flags
* |-----|
* enum unused 4 bits for the bytes-per-pixel
* and component alignment info
* |------| |-------------| |--|
* 00000000 xxxxxxxx xxxxxxSD PFBA0000
* ^ stencil
* ^ depth
* ^ premult
* ^ alpha first
* ^ bgr order
* ^ has alpha
*
* The most awkward part about the formats is how we use the last 4
* bits to encode the bytes per pixel and component alignment
* information. Ideally we should have had 3 bits for the bpp and a
* flag for alignment but we didn't plan for that in advance so we
* instead use a small lookup table to query the bpp and whether the
* components are byte aligned or not.
*
* The mapping is the following (see discussion on bug #660188):
*
* 0 = undefined
* 1, 8 = 1 bpp (e.g. A_8, G_8)
* 2 = 3 bpp, aligned (e.g. 888)
* 3 = 4 bpp, aligned (e.g. 8888)
* 4-6 = 2 bpp, not aligned (e.g. 565, 4444, 5551)
* 7 = YUV: undefined bpp, undefined alignment
* 9 = 2 bpp, aligned
* 10 = depth, aligned (8, 16, 24, 32, 32f)
* 11 = undefined
* 12 = 3 bpp, not aligned
* 13 = 4 bpp, not aligned (e.g. 2101010)
* 14-15 = undefined
*
* Note: the gap at 10-11 is just because we wanted to maintain that
* all non-aligned formats have the third bit set in case that's
* useful later.
*
* Since we don't want to waste bits adding more and more flags, we'd
* like to see most new pixel formats that can't be represented
* uniquely with the existing flags in the least significant byte
* simply be enumerated with sequential values in the most significant
* enum byte.
*
* Note: Cogl avoids exposing any padded XRGB or RGBX formats and
* instead we leave it up to applications to decided whether they
* consider the A component as padding or valid data. We shouldn't
* change this policy without good reasoning.
*
* So to add a new format:
* 1) Use the mapping table above to figure out what to but in
* the lowest nibble.
* 2) OR in the COGL_PREMULT_BIT, COGL_AFIRST_BIT, COGL_A_BIT and
* COGL_BGR_BIT flags as appropriate.
* 3) If the result is not yet unique then also combine with an
* increment of the last sequence number in the most significant
* byte.
*
* The last sequence number used was 0 (i.e. no formats currently need
* a sequence number)
* Update this note whenever a new sequence number is used.
*/
/**
* CoglPixelFormat:
* @COGL_PIXEL_FORMAT_ANY: Any format
* @COGL_PIXEL_FORMAT_A_8: 8 bits alpha mask
* @COGL_PIXEL_FORMAT_RG_88: RG, 16 bits. Note that red-green textures
* are only available if %COGL_FEATURE_ID_TEXTURE_RG is advertised.
* See cogl_texture_set_components() for details.
* @COGL_PIXEL_FORMAT_RGB_565: RGB, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_4444: RGBA, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_5551: RGBA, 16 bits
* @COGL_PIXEL_FORMAT_YUV: Not currently supported
* @COGL_PIXEL_FORMAT_G_8: Single luminance component
* @COGL_PIXEL_FORMAT_RGB_888: RGB, 24 bits
* @COGL_PIXEL_FORMAT_BGR_888: BGR, 24 bits
* @COGL_PIXEL_FORMAT_RGBA_8888: RGBA, 32 bits
* @COGL_PIXEL_FORMAT_BGRA_8888: BGRA, 32 bits
* @COGL_PIXEL_FORMAT_ARGB_8888: ARGB, 32 bits
* @COGL_PIXEL_FORMAT_ABGR_8888: ABGR, 32 bits
* @COGL_PIXEL_FORMAT_RGBA_1010102 : RGBA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_BGRA_1010102 : BGRA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ARGB_2101010 : ARGB, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ABGR_2101010 : ABGR, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_RGBA_8888_PRE: Premultiplied RGBA, 32 bits
* @COGL_PIXEL_FORMAT_BGRA_8888_PRE: Premultiplied BGRA, 32 bits
* @COGL_PIXEL_FORMAT_ARGB_8888_PRE: Premultiplied ARGB, 32 bits
* @COGL_PIXEL_FORMAT_ABGR_8888_PRE: Premultiplied ABGR, 32 bits
* @COGL_PIXEL_FORMAT_RGBA_4444_PRE: Premultiplied RGBA, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_5551_PRE: Premultiplied RGBA, 16 bits
* @COGL_PIXEL_FORMAT_RGBA_1010102_PRE: Premultiplied RGBA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_BGRA_1010102_PRE: Premultiplied BGRA, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ARGB_2101010_PRE: Premultiplied ARGB, 32 bits, 10 bpc
* @COGL_PIXEL_FORMAT_ABGR_2101010_PRE: Premultiplied ABGR, 32 bits, 10 bpc
*
* Pixel formats used by Cogl. For the formats with a byte per
* component, the order of the components specify the order in
* increasing memory addresses. So for example
* %COGL_PIXEL_FORMAT_RGB_888 would have the red component in the
* lowest address, green in the next address and blue after that
* regardless of the endianness of the system.
*
* For the formats with non byte aligned components the component
* order specifies the order within a 16-bit or 32-bit number from
* most significant bit to least significant. So for
* %COGL_PIXEL_FORMAT_RGB_565, the red component would be in bits
* 11-15, the green component would be in 6-11 and the blue component
* would be in 1-5. Therefore the order in memory depends on the
* endianness of the system.
*
* When uploading a texture %COGL_PIXEL_FORMAT_ANY can be used as the
* internal format. Cogl will try to pick the best format to use
* internally and convert the texture data if necessary.
*
* Since: 0.8
*/
typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
{
COGL_PIXEL_FORMAT_ANY = 0,
COGL_PIXEL_FORMAT_A_8 = 1 | COGL_A_BIT,
COGL_PIXEL_FORMAT_RGB_565 = 4,
COGL_PIXEL_FORMAT_RGBA_4444 = 5 | COGL_A_BIT,
COGL_PIXEL_FORMAT_RGBA_5551 = 6 | COGL_A_BIT,
COGL_PIXEL_FORMAT_YUV = 7,
COGL_PIXEL_FORMAT_G_8 = 8,
COGL_PIXEL_FORMAT_RG_88 = 9,
COGL_PIXEL_FORMAT_RGB_888 = 2,
COGL_PIXEL_FORMAT_BGR_888 = (2 | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_RGBA_8888 = (3 | COGL_A_BIT),
COGL_PIXEL_FORMAT_BGRA_8888 = (3 | COGL_A_BIT | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_ARGB_8888 = (3 | COGL_A_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_ABGR_8888 = (3 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_RGBA_1010102 = (13 | COGL_A_BIT),
COGL_PIXEL_FORMAT_BGRA_1010102 = (13 | COGL_A_BIT | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_ARGB_2101010 = (13 | COGL_A_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_ABGR_2101010 = (13 | COGL_A_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_RGBA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_BGRA_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT),
COGL_PIXEL_FORMAT_ARGB_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_ABGR_8888_PRE = (3 | COGL_A_BIT | COGL_PREMULT_BIT | COGL_BGR_BIT | COGL_AFIRST_BIT),
COGL_PIXEL_FORMAT_RGBA_4444_PRE = (COGL_PIXEL_FORMAT_RGBA_4444 | COGL_A_BIT | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_RGBA_5551_PRE = (COGL_PIXEL_FORMAT_RGBA_5551 | COGL_A_BIT | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_RGBA_1010102_PRE = (COGL_PIXEL_FORMAT_RGBA_1010102 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_BGRA_1010102_PRE = (COGL_PIXEL_FORMAT_BGRA_1010102 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_ARGB_2101010_PRE = (COGL_PIXEL_FORMAT_ARGB_2101010 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_ABGR_2101010_PRE = (COGL_PIXEL_FORMAT_ABGR_2101010 | COGL_PREMULT_BIT),
COGL_PIXEL_FORMAT_DEPTH_16 = (9 | COGL_DEPTH_BIT),
COGL_PIXEL_FORMAT_DEPTH_32 = (3 | COGL_DEPTH_BIT),
COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8 = (3 | COGL_DEPTH_BIT | COGL_STENCIL_BIT)
} CoglPixelFormat;
/**
* CoglFeatureFlags:
* @COGL_FEATURE_TEXTURE_RECTANGLE: ARB_texture_rectangle support
* @COGL_FEATURE_TEXTURE_NPOT: Non power of two textures are supported
* by the hardware. This is a equivalent to the
* %COGL_FEATURE_TEXTURE_NPOT_BASIC, %COGL_FEATURE_TEXTURE_NPOT_MIPMAP
* and %COGL_FEATURE_TEXTURE_NPOT_REPEAT features combined.
* @COGL_FEATURE_TEXTURE_YUV: ycbcr conversion support
* @COGL_FEATURE_TEXTURE_READ_PIXELS: glReadPixels() support
* @COGL_FEATURE_SHADERS_GLSL: GLSL support
* @COGL_FEATURE_OFFSCREEN: FBO support
* @COGL_FEATURE_OFFSCREEN_MULTISAMPLE: Multisample support on FBOs
* @COGL_FEATURE_OFFSCREEN_BLIT: Blit support on FBOs
@ -334,20 +162,8 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
* %COGL_INDICES_TYPE_UNSIGNED_INT is supported in
* cogl_vertex_buffer_indices_new().
* @COGL_FEATURE_DEPTH_RANGE: cogl_material_set_depth_range() support
* @COGL_FEATURE_TEXTURE_NPOT_BASIC: The hardware supports non power
* of two textures, but you also need to check the
* %COGL_FEATURE_TEXTURE_NPOT_MIPMAP and %COGL_FEATURE_TEXTURE_NPOT_REPEAT
* features to know if the hardware supports npot texture mipmaps
* or repeat modes other than
* %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively.
* @COGL_FEATURE_TEXTURE_NPOT_MIPMAP: Mipmapping is supported in
* conjuntion with non power of two textures.
* @COGL_FEATURE_TEXTURE_NPOT_REPEAT: Repeat modes other than
* %COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE are supported by the
* hardware.
* @COGL_FEATURE_POINT_SPRITE: Whether
* cogl_material_set_layer_point_sprite_coords_enabled() is supported.
* @COGL_FEATURE_TEXTURE_3D: 3D texture support
* @COGL_FEATURE_MAP_BUFFER_FOR_READ: Whether cogl_buffer_map() is
* supported with CoglBufferAccess including read support.
* @COGL_FEATURE_MAP_BUFFER_FOR_WRITE: Whether cogl_buffer_map() is
@ -361,11 +177,8 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/
*/
typedef enum
{
COGL_FEATURE_TEXTURE_RECTANGLE = (1 << 1),
COGL_FEATURE_TEXTURE_NPOT = (1 << 2),
COGL_FEATURE_TEXTURE_YUV = (1 << 3),
COGL_FEATURE_TEXTURE_READ_PIXELS = (1 << 4),
COGL_FEATURE_SHADERS_GLSL = (1 << 5),
COGL_FEATURE_OFFSCREEN = (1 << 6),
COGL_FEATURE_OFFSCREEN_MULTISAMPLE = (1 << 7),
COGL_FEATURE_OFFSCREEN_BLIT = (1 << 8),
@ -375,11 +188,7 @@ typedef enum
COGL_FEATURE_PBOS = (1 << 12),
COGL_FEATURE_UNSIGNED_INT_INDICES = (1 << 13),
COGL_FEATURE_DEPTH_RANGE = (1 << 14),
COGL_FEATURE_TEXTURE_NPOT_BASIC = (1 << 15),
COGL_FEATURE_TEXTURE_NPOT_MIPMAP = (1 << 16),
COGL_FEATURE_TEXTURE_NPOT_REPEAT = (1 << 17),
COGL_FEATURE_POINT_SPRITE = (1 << 18),
COGL_FEATURE_TEXTURE_3D = (1 << 19),
COGL_FEATURE_MAP_BUFFER_FOR_READ = (1 << 21),
COGL_FEATURE_MAP_BUFFER_FOR_WRITE = (1 << 22),
COGL_FEATURE_ONSCREEN_MULTIPLE = (1 << 23),
@ -559,9 +368,7 @@ cogl_blend_string_error_quark (void);
*
* <itemizedlist>
* <listitem><para>You've tried to use a feature that is not
* advertised by cogl_has_feature(). This could happen if you create
* a 2d texture with a non-power-of-two size when
* %COGL_FEATURE_ID_TEXTURE_NPOT is not advertised.</para></listitem>
* advertised by cogl_has_feature().</para></listitem>
* <listitem><para>The GPU can not handle the configuration you have
* requested. An example might be if you try to use too many texture
* layers in a single #CoglPipeline</para></listitem>
@ -773,32 +580,6 @@ typedef enum _CoglWinsysFeature
COGL_WINSYS_FEATURE_N_FEATURES
} CoglWinsysFeature;
/**
* CoglColorMask:
* @COGL_COLOR_MASK_NONE: None of the color channels are masked
* @COGL_COLOR_MASK_RED: Masks the red color channel
* @COGL_COLOR_MASK_GREEN: Masks the green color channel
* @COGL_COLOR_MASK_BLUE: Masks the blue color channel
* @COGL_COLOR_MASK_ALPHA: Masks the alpha color channel
* @COGL_COLOR_MASK_ALL: All of the color channels are masked
*
* Defines a bit mask of color channels. This can be used with
* cogl_pipeline_set_color_mask() for example to define which color
* channels should be written to the current framebuffer when
* drawing something.
*/
typedef enum
{
COGL_COLOR_MASK_NONE = 0,
COGL_COLOR_MASK_RED = 1L<<0,
COGL_COLOR_MASK_GREEN = 1L<<1,
COGL_COLOR_MASK_BLUE = 1L<<2,
COGL_COLOR_MASK_ALPHA = 1L<<3,
/* XXX: glib-mkenums is a perl script that can't cope if we split
* this onto multiple lines! *sigh* */
COGL_COLOR_MASK_ALL = (COGL_COLOR_MASK_RED | COGL_COLOR_MASK_GREEN | COGL_COLOR_MASK_BLUE | COGL_COLOR_MASK_ALPHA)
} CoglColorMask;
/**
* CoglWinding:
* @COGL_WINDING_CLOCKWISE: Vertices are in a clockwise order

View File

@ -35,6 +35,7 @@
#include <math.h>
#include <cogl/cogl-defines.h>
#include <cogl/cogl-pixel-format.h>
#include "cogl-types.h"
#include <stdio.h>

View File

@ -54,41 +54,27 @@ static char *_cogl_x11_display_name = NULL;
static GList *_cogl_xlib_renderers = NULL;
static void
destroy_xlib_renderer_data (void *user_data)
_xlib_renderer_data_free (CoglXlibRenderer *data)
{
CoglXlibRenderer *data = user_data;
if (data->xvisinfo)
XFree (data->xvisinfo);
g_slice_free (CoglXlibRenderer, user_data);
g_slice_free (CoglXlibRenderer, data);
}
CoglXlibRenderer *
_cogl_xlib_renderer_get_data (CoglRenderer *renderer)
{
static CoglUserDataKey key;
CoglXlibRenderer *data;
/* Constructs a CoglXlibRenderer struct on demand and attaches it to
the object using user data. It's done this way instead of using a
subclassing hierarchy in the winsys data because all EGL winsys's
need the EGL winsys data but only one of them wants the Xlib
data. */
data = cogl_object_get_user_data (COGL_OBJECT (renderer), &key);
if (!renderer->custom_winsys_user_data)
renderer->custom_winsys_user_data = g_slice_new0 (CoglXlibRenderer);
if (data == NULL)
{
data = g_slice_new0 (CoglXlibRenderer);
cogl_object_set_user_data (COGL_OBJECT (renderer),
&key,
data,
destroy_xlib_renderer_data);
}
return data;
return renderer->custom_winsys_user_data;
}
static void
@ -570,6 +556,8 @@ _cogl_xlib_renderer_disconnect (CoglRenderer *renderer)
if (!renderer->foreign_xdpy && xlib_renderer->xdpy)
XCloseDisplay (xlib_renderer->xdpy);
g_clear_pointer (&renderer->custom_winsys_user_data, _xlib_renderer_data_free);
unregister_xlib_renderer (renderer);
}

View File

@ -764,55 +764,3 @@ _cogl_init (void)
initialized = TRUE;
}
}
/*
* Returns the number of bytes-per-pixel of a given format. The bpp
* can be extracted from the least significant nibble of the pixel
* format (see CoglPixelFormat).
*
* The mapping is the following (see discussion on bug #660188):
*
* 0 = undefined
* 1, 8 = 1 bpp (e.g. A_8, G_8)
* 2 = 3 bpp, aligned (e.g. 888)
* 3 = 4 bpp, aligned (e.g. 8888)
* 4-6 = 2 bpp, not aligned (e.g. 565, 4444, 5551)
* 7 = undefined yuv
* 9 = 2 bpp, aligned
* 10 = undefined
* 11 = undefined
* 12 = 3 bpp, not aligned
* 13 = 4 bpp, not aligned (e.g. 2101010)
* 14-15 = undefined
*/
int
_cogl_pixel_format_get_bytes_per_pixel (CoglPixelFormat format)
{
int bpp_lut[] = { 0, 1, 3, 4,
2, 2, 2, 0,
1, 2, 0, 0,
3, 4, 0, 0 };
return bpp_lut [format & 0xf];
}
/* Note: this also refers to the mapping defined above for
* _cogl_pixel_format_get_bytes_per_pixel() */
gboolean
_cogl_pixel_format_is_endian_dependant (CoglPixelFormat format)
{
int aligned_lut[] = { -1, 1, 1, 1,
0, 0, 0, -1,
1, 1, -1, -1,
0, 0, -1, -1};
int aligned = aligned_lut[format & 0xf];
_COGL_RETURN_VAL_IF_FAIL (aligned != -1, FALSE);
/* NB: currently checking whether the format components are aligned
* or not determines whether the format is endian dependent or not.
* In the future though we might consider adding formats with
* aligned components that are also endian independant. */
return aligned;
}

View File

@ -64,6 +64,7 @@
#include <cogl/cogl-matrix.h>
#include <cogl/cogl-matrix-stack.h>
#include <cogl/cogl-offscreen.h>
#include <cogl/cogl-pixel-format.h>
#include <cogl/cogl-primitives.h>
#include <cogl/cogl-texture.h>
#include <cogl/cogl-types.h>
@ -105,8 +106,6 @@
#include <cogl/cogl-quaternion.h>
#include <cogl/cogl-texture-2d.h>
#include <cogl/cogl-texture-2d-gl.h>
#include <cogl/cogl-texture-rectangle.h>
#include <cogl/cogl-texture-3d.h>
#include <cogl/cogl-texture-2d-sliced.h>
#include <cogl/cogl-sub-texture.h>
#include <cogl/cogl-atlas-texture.h>

Some files were not shown because too many files have changed in this diff Show More