compositor: Consolidate output repaint logic

We move the EGL and GLES2 output repaint code into a new gles2-render.c
file.  The eglMakeCurrent, glViewPort, surface loop etc was duplicated
across all backends, but this patch moves it to a new file.
compositor: Move surface repaint code to gles2-renderer.c
compositor: Move non-GL initialization out of weston_compositor_init_gl()
compositor: Move gles2 initialization to gles2-renderer.h
compositor: Move update_shm_texture() to gles2-renderer.c

We rename it flush_damage() as it's the point where we update our rendering
API source (eg, the gles2 texture) according to the accumulated damage,
if necessary.
compositor: Move EGL/GLES2 parts of weston_surface_attach to gles2-renderer.c
compositor: Introduce a weston_renderer object

Move the gles2 render functions to vfuncs on the renderer object.
compositor: Create outputs before initializing GLES2 state

This way we can just use the first weston_output EGLSurface to make a
context current.
compositor: Move EGL context creation to gles2-renderer.c
compositor: Move unbind_display call into gles2-renderer.c
compositor: Destroy gles2 resource for weston_surface in gles2-renderer.c

This moves the last gles2 call out of compositor.c.
compositor: Remove unused 'fbo' field from weston_compositor
compositor: Make all non-backend modules use module_init() as entry point
compositor: Drop unused wl_shm field
compositor: Don't return the dlsym handle in load_module()

We don't use it.
compositor: Always set WAYLAND_DISPLAY

We used to only set it if we were given an argument on the command line.
It's useful to always set it so nested weston works out of the box.
compositor: Generalize module loading

We can now load any number of general modules, and the shell and xwayland
are just two of them.  We continue to use the mechanism for testing but
custom input drivers or logging mechanisms, for example are other use cases.
update .gitignores

Add workspaces-protocol.c, workspaces-server-protocol.h,
workspaces-client-protocol.h.

Remove wscreensaver.

Alphabetaize clients/.gitignore.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
clients: add cliptest program

Cliptest is for controlled testing of the calculate_edges() function in
compositor.c. The function is copied verbatim into cliptest.c.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
compositor: new intersection algorithm

The existing algorithm had some corner cases (pun!), where it failed to
produce correct vertices in the right order. This appeared only when the
surface was transformed (rotated). It also produced degenerate polygons
(3 or more vertices with zero polygon area) for non-transformed cases
where the clipping and surface rectangles were adjacent but not
overlapping.

Introduce a new algorithm for finding the boundary vertices of the
intersection of a coordinate axis aligned rectangle and an arbitrary
polygon (here a quadrilateral). The code is based on the
Sutherland-Hodgman algorithm, where a polygon is clipped by infinite
lines one at a time.

This new algorithm should always produce the correct vertices in the
clockwise winding order, and discard duplicate vertices and degenerate
polygons. It retains the fast paths of the existing algorithm for the
no-hit and non-transformed cases.

Benchmarking with earlier versions showed that the new algorithm is
a little slower (56 vs. 68 us/call) than the existing algorithm, for
the transformed case.  The 'cliptest f' command before and after this
commit can be used to compare the speed of the transformed case only.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
Acked-by: Rob Clark <rob.clark@linaro.org>