core,man: Fix range and default value of WAFFLE_*_SIZE attrs

For each of the WAFFLE_*_SIZE attributes:
  - change the default value from WAFFLE_DONT_CARE(-1) to 0, and
  - change the valid range of values from [-1, +inf) to [0, +inf).

This change aligns waffle's behavior to that of GLX [1], EGL [2], and (if
I interpreted the CGL documentation correctly) CGL [3].

This fixes a bug where, if the user didn't specify the value of a size
attribute, then waffle passed WAFFLE_DONT_CARE(-1) to glXChooseFBConfig
and eglChooseConfig. Per the GLX, EGL specs, -1 is an illegal value for
size attributes.

[1] GLX 1.4 spec (2005.12.16), Table 3.4
[2] EGL 1.4 spec (2011.04.06), Table 3.4
[3] https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/CGL_OpenGL/Reference/reference.html#//apple_ref/c/func/CGLChoosePixelFormat

Reported-by: Brian Paul <brian.e.paul@gmail.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
core: Simpify calculations of wcore_config_attris::rgb*_size

Now that the range of each size attribute is [0, +inf), we may eliminate
the special cases for WAFFLE_DONT_CARE(-1).

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
core: Fix unit tests wcore_config.gl*_defaults

The tests were broken by
  commit 8c2170870ec46a2f92c902140ac42a0836d44063
  core,man: Fix range and default value of WAFFLE_*_SIZE attrs
I forgot to update the unit tests in tandem with chaning the default
values.

Reported-by: Paul Berry <stereotype441@gmail.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
core,man: Accept WAFFLE_DONT_CARE for more config attrs

The affected attributes are:
    - integer attributes
	- WAFFLE_*_SIZE
	- WAFFLE_SAMPLES
    - boolean attributes
	- WAFFLE_ACCUM_BUFFER
	- WAFFLE_SAMPLE_BUFFERS
	- WAFFLE_DOUBLE_BUFFERED

Waffle needs to accept DONT_CARE for these attributes for two reasons:
    - Waffle attempts to follow the behavior of EGL and GLX when possible,
      and both accept DONT_CARE for the affected attributes. (See spec
      quotes in this patch).

    - Waffle will soon acquire a function that returns a *list* of
      matching configs, similar to eglChooseConfig. In order for that
      function to return a maximumally sized list, we must pass DONT_CARE
      to GLX and EGL, not the attribute's default value. As the EGL 1.4
      states concerning eglChooseConfig: "If EGL_DONT_CARE is specified
      as an attribute value, then the attribute will not be checked.".

Notes on commit 8c21708
-----------------------
Before commit 8c21708, WAFFLE_DONT_CARE was accepted for WAFFLE_*_SIZE and
WAFFLE_SAMPLES, and waffle passed DONT_CARE along to GLX and EGL.  Commit
8c21708 unwisely chose to cease accepting WAFFLE_DONT_CARE for those
attributes. In that commit message, I misinterpreted the GLX and EGL
specs.

Even though this patch reinstates the acceptance of WAFFLE_DONT_CARE for
those attributes, it does not restore all the old behavior. Before commit
8c21708, the default value for those attributes was incorrectly DONT_CARE;
now it is 0.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
glx: Fix gles regression

In glx_context_fill_attrib_list, recently a check was added to
work around a bug for OpenGL v1.0 contexts and NVidia. This
check introduced a bug where for OpenGL ES (all versions)
the attrib_list wasn't getting entries for
GLX_CONTEXT_MAJOR_VERSION_ARB or GLX_CONTEXT_MINOR_VERSION_ARB.
In piglit, this causes all OpenGL ES testcases to fail with
context failures.
This fix adjusts the comparison so that OpenGL ES will always
have the context version and not set it for a Open GL v1.0
context.

[chadv: Replace != OPENGL_ES1 with == OPENGL to improve readability.
 Double negatives are confusing.]

Signed-off-by: Tom Gall <tom.gall@linaro.org>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
wayland: Ensure that shell and compositor are registered

Waffle requires that wayland_display::wl_shell and ::wl_compositor are set
before wayland_display_connect() returns. In two ways Waffle failed to
ensure that:
  - wayland_display_connect() assumes that the requirement is satisified.
    It did not explicitly check it.

  - In an attempt to satisfy the requirement, wayland_display_connect()
    called wl_display_dispatch() before returning. That's not sufficient;
    a roundtrip to the server is needed.

This patch fixes the above mistakes by calling wl_display_roundtrip() and
then explicitly checking that the shell and compositor have been
registered.  This method follows that of Enlightenment's Wayland engine:
  https://svn.enlightenment.org/svn/e/trunk/expedite/src/bin/engine_wayland_egl.c?rev=83377

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
wayland: Rename method of registry listener

The function name wayland_display_listener(), though previously accurate,
became a misnomer when Waffle was updated for Wayland 1.0. It's now
a registry listener.

Rename wayland_display_listener() to registry_listener_global().

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
wayland: Minor whitespace fix

A 20-space indent should be 4.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
android: Fix createSurface compiler error

It looks like createSurface changed signature:

waffle/src/waffle/android/droid_surfaceflingerlink.cpp:113:36:
error: no matching function for call to
android::SurfaceComposerClient::createSurface(
  android::String8, int, const uint32_t&, const uint32_t&, android::<anonymous enum>, int)

Candidate is:
frameworks/native/include/gui/SurfaceComposerClient.h:80:24:
android::sp<android::SurfaceControl> android::SurfaceComposerClient::createSurface(
  const android::String8&, uint32_t, uint32 _t, android::PixelFormat, uint32_t)

Reviewed-by: Tom Gall <tom.gall@linaro.org>
Signed-off-by: Adrian Marius Negreanu <adrian.m.negreanu@intel.com>
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>