Commit Graph

187 Commits

Author SHA1 Message Date
Kristian Høgsberg 9b8a82bf6d Merge remote-tracking branch 'pq/transform-fixes2' 2012-02-07 11:08:03 -05:00
Kristian Høgsberg 546a812004 compositor-wayland: Add window border 2012-02-07 11:02:59 -05:00
Pekka Paalanen 44ab69cfa3 compositor: add weston_surface transformation doc
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-07 13:18:00 +02:00
Pekka Paalanen ddae03cf9b compositor: q&d solution for surface drift
When a transformed (rotated) surface is continuously resized from its
top-left corner, its location will drift. This is due to accumulating
rounding errors in transforming an offset from surface-local to global
coordinates in surface_attach().

Diminish the drift down to unobservable level by changing the
weston_surface global position from integer to float.

The offset transformation is now done without rounding. To preserve the
precision, wl_shell::configure() interface must use floats, and so does
weston_surface_configure(), too.

The con of this patch is that it adds inconsistency to the surface
position coordinates: sometimes they are floats, sometimes integers.
2012-02-06 14:54:20 +02:00
Pekka Paalanen f55f544e4f compositor: fix and simplify shader uniform handling
The uniform location variables should be signed, according to the OpenGL
ES 2 specification. Moreover, GL_NONE, i.e. 0, is not an invalid nor
special location; it is actually used as a valid uniform location.

Change struct weston_shader uniform members to signed.

Stop using 0 for identifying a non-existing uniform, use -1 instead.
Furthermore, as the spec says a) glGetUniformLocation() will return -1
for non-active/existing uniforms, and b) glUniform*() function will
simply ignore all calls with location -1, we can simplify the code. We
don't have to avoid locating uniforms that don't exist, and we don't
need to test for them in weston_surface_draw() either.

Remove the micro-optimisation that avoids setting 'alpha' uniform if it
has not changed, in the name of simplification.

Unify shader creation by dropping init_solid_shader(), and calling
weston_shader_init() instead. The downside is that we compile the vertex
shader twice at startup now.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-02-02 16:49:05 +02:00
Kristian Høgsberg 18c93009c1 compositor: Only set surface geometry through weston_surface_configure()
There are too many things to keep track of now, so let's require going
through this.
2012-01-27 11:58:31 -05:00
Pekka Paalanen d581a8fcc8 Collabora copyright updates
which I forgot to add while working on these files.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:26:17 +02:00
Pekka Paalanen 60921e5787 compositor: move weston_surface::width,height into geometry
weston_surface::transform.boundingbox depends on width and height, and
therefore geometry.dirty flag, so move width and height into geometry.

Fix all users and check that the dirty flag is set.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 6720d8f3bd compositor: add weston_surface bounding box
Compute a surface bounding box, especially for transformed surfaces, for
which one cannot simply use x,y,width,height.

The bounding box depends on width and height, so these are now under the
geometry.dirty flag.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen ba3cf95c0e compositor: move weston_surface::x,y into geometry
weston_surface::transform.position depends on x,y, and therefore the
dirty flag, so move x and y into geometry.

Also add the missing dirty flags.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen cd40362bba compositor: make position a surface transformation
Put the surface translation (absolute position) into the surface
transformations list. This allows to set additional transformations
before and after the global translation.

Having the translation cached, changing the surface x,y now requires to
set the geometry.dirty flag.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 0e151bb487 compositor: honour repaint regions with transformed surfaces
Previously, if a surface was transformed, it repainted as a whole,
regardless of the computed repaint region. As damage regions determine
repaint regions and whether a surface is considered for drawing at all,
this lead to disappearing surfaces if all surfaces were considered
transformed. Also transparent transformed surfaces were redrawn without
the surfaces below being properly redrawn, leading to alpha-saturation.

Fix that by making texture_region() use the proper global-to-surface
coordinate transformation for texture coordinates. This makes it
possible to call texture_region() also for transformed surfaces.

As texture coordinates may now lie outside the valid texture image, the
fragment shader is modified to check the fragment texture coordinates.

The special path texture_transformed_surface() is no longer used and is
removed.

This change fixes many of the rendering artifacts related to transformed
surfaces.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 74abeac2f6 compositor: remove unused *_uniform members
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen e0f3cb25e8 compositor: rewrite draw and input coordinate transformations
For unifying the coordinate system handling, introduce functions for
converting explicitly between the global and the surface local
coordinate systems.

Use these functions in the input path, replacing
weston_surface_transform().

In the draw path, rewrite transform_vertex() to take in surface local
coordinates.

As shell now uses the new functions, the rotation origin is properly
placed in the middle of the surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen bc0b7e7756 compositor: restructure weston_surface::transform
Separate mutable data and cached immutable data in struct
weston_surface.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen 460099f143 shell: add key binding for rotating a surface
Add the key binding Super+Alt+MouseLeftButton to start rotating a
surface by dragging. The rotation is removed, when the drag is near the
rotation origin.

Rotated surface are a stress test for input event coordinate
transformations, damage region tracking, draw transformations, and
window move and resize orientation.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 16:15:02 +02:00
Pekka Paalanen d1f0ab6343 compositor: simplify the matrix inversion API
The compositor will likely do an order of magnitude less matrix
inversions than point transformations with an inverse, hence we do not
really need the optimised path for single-shot invert-and-transform.

Expose only the computing of the explicit inverse matrix in the API.

However, the matrix inversion tests need access to the internal
functions. Designate a unit test build by #defining UNIT_TEST, and
export the internal functions in that case.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:44:22 +02:00
Pekka Paalanen 75b47ec45d compositor: implement inverse matrix transformation
Implement 4x4 matrix inversion based on LU-decomposition with partial
pivoting.

Instead of simply computing the inverse matrix explicitly, introduce the
type struct weston_inverse_matrix for storing the LU-decomposition and
the permutation from pivoting. Using doubles, this struct has greater
precision than struct weston_matrix.

If you need only few (less than 5, presumably) multiplications with the
inverse matrix, is it cheaper to use weston_inverse_matrix, and not
compute the inverse matrix explicitly into a weston_matrix.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:44:22 +02:00
Pekka Paalanen 061b7471f1 compositor: drop inverse matrix from weston_transform
Remove the inverse matrix member from struct weston_transform. It is
easier (and probably faster, too) to create and store only forward
transformation matrices in a list, multiply them once, and then invert
the final matrix, rather than creating both forward and inverse
matrices, and multiplying both.

Add a stub for the 4x4 matrix inversion function.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:44:22 +02:00
Pekka Paalanen 668ca37b19 compositor: move matrix code to separate files
Move matrix code to separate files to allow writing unit tests for it.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:44:22 +02:00
Pekka Paalanen c61eca6002 compositor: implement a stack of surface transformations
Having at most one transformation object attached to a surface is not
enough anymore. If we have a surface that needs to be scaled to
fullscreen, and then we have the zoom animation, we already need two
transformations combined.

Implement support for multiple transformations by adding a transformation
list. The final transformation is the ordered composite of those in the
list. To avoid traversing the list every single time, add a dirty flag,
and cache the final transformation.

The existing transformation users (only zoom) are converted.

Note: surface drawing should honour all kinds of transformations, but
not damage region code nor input event translating code take
transformations into account, AFAICT. Therefore anything but translation
will probably behave badly until they are fixed.

Cc: Juan Zhao <juan.j.zhao@linux.intel.com>
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2012-01-27 10:43:49 +02:00
Kristian Høgsberg 681f9f4149 compositor: Keep fade surface around while we're fading
This removes more special cases from weston_output_repaint() and we
avoid creating and destroying the surface for each animation frame.
We gain another special case in weston_compositor_top(), but that's
less of a problem, and we'll fix that later.
2012-01-26 10:59:33 -05:00
Kristian Høgsberg 46e64ee3e1 compositor: Drop unused saved_texture surface field 2012-01-26 09:28:42 -05:00
Kristian Høgsberg a82c4860a1 compositor: Compute overlapped early and base hw cursor decision on that 2012-01-26 01:03:58 -05:00
Kristian Høgsberg 9f404b7ac8 compositor: Move tracking of scanout buffers to compositor-drm 2012-01-26 00:11:01 -05:00
Kristian Høgsberg 5f5e42ef50 compositor: Remove prepare_scanout_surface callout
For the drm backend, we just refactor setup_scanout_surface into
drm_output_prepare_scanout_surface and call it from drm_output_repaint.
2012-01-25 23:59:44 -05:00
Kristian Høgsberg 06cf6b0238 compositor: Pull prepare_render and present callouts into repaint
This dramatically simplifies the backend repaint abstractions and paves
the way for moving overlay and cursor setup into the backend.
2012-01-25 23:47:45 -05:00
Kristian Høgsberg 68c479af05 compositor: Move repaint loop into a backend function
We've trimmed down the actual repaint loop to just iterating through the
surface list and calling weston_surface_draw(), so we push that to the
backend without too much code duplication.
2012-01-25 23:32:28 -05:00
Kristian Høgsberg 0763262e3d compositor: Move shader setup to weston_surface_draw() 2012-01-25 23:02:06 -05:00
Kristian Høgsberg 765bcdf1fa compositor: Compute whether or not a surface is overlapped 2012-01-25 22:20:30 -05:00
Kristian Høgsberg 8e81df4503 Use new format codes 2012-01-11 14:24:46 -05:00
Kristian Høgsberg dade64968c Move wl_data_device implementation to wayland-server 2012-01-06 11:28:53 -05:00
Kristian Høgsberg 9ddb826077 Use new grab api 2012-01-05 11:00:01 -05:00
Kristian Høgsberg a33d0c38d2 data-device: Use a listener list to decouple the x11 selection bridge 2012-01-03 23:01:47 -05:00
Kristian Høgsberg 82d9ee929b data-device: Handle source going away instead of ref-counting it
We have to deal with the data source going away.  Even if we have a
reference to the server side data source, we can't do anything if the
client that provided the source went away.  So just NULL the offers
source pointer in the destroy callback for the source.
2012-01-03 14:11:18 -05:00
Kristian Høgsberg 3466bc8042 Merge remote-tracking branch 'pq/compositor-dtors-v1'
This collided with the big weston rename, but git did a good job of fixing
most cases.

Conflicts:
	compositor/compositor.h
	src/compositor-x11.c
	src/compositor.c
	src/screenshooter.c
	src/util.c
2012-01-03 11:36:37 -05:00
Kristian Høgsberg 8334bc1ef9 Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.

1) Initially, we had one big repository with protocol code, sample
compositor and sample clients.  We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code.  At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message.  The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.

2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor.  Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example.  Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.

We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 11:04:04 -05:00