Fix removing layers when the pipeline is not the owner

If cogl_pipeline_remove_layer is called on a copied pipeline to remove
a parent layer then it will still end up calling
_cogl_pipeline_remove_layer_difference on the layer. This function
was directly trying to remove the layer from the pipeline's list of
layer differences. However in the child pipeline the layer isn't in
the list because it is unchanged from its parent. The function had an
assertion to verify that this situation wasn't hit so in a debug build
it would just bail out.

This patch removes the assertion and changes it to only remove the
layer if it is owned by the pipeline. Otherwise it just sets the
COGL_PIPELINE_STATE_LAYERS difference as normal and decrements the
number of layers. This will cause it to successfully remove the layer
because either it is the last layer in which case it will be ignored
after n_layers is decreased or if it is in the middle of the list then
the subsequent layers will all be shifted down so there will be a
replacement layer difference.

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

(cherry picked from commit 88e73dd93fa09a158064a946ab229591a5888b97)
Use the old GLSL extensions if GL 2.0 is not available

Some drivers have good support for GLSL but don't have the complete
set of features needed to advertise GL 2.0 support. We should accept
the three old GLSL extensions (GL_ARB_shader_objects,
GL_ARB_vertex_shader and GL_ARB_fragment_shader) to support shaders on
these drivers.

This patch splits the shader functions into four sections :- those
that are provided only in GL 2.0, those that have the same name in the
shader objects extension, those that are provided by the vertex
shader extension (they all share the same name) and those that have a
different name in the shader objects extension.

If GL 2.0 is not supported but all three of the extensions are then
the pointers to the GL2-only functions will be replaced to point to
the equivalent functions from the extensions. That way the rest of the
Cogl source doesn't have to worry about the name differences.

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

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

(cherry-picked from commit 71ecb51bd20dc3053b4221961b57e5a2b1029bdf)
Fix point sprite coordinates in shaders on GLES2

When using the GLES2 driver with a pipeline layer that has point
sprite coordinates enabled it extracts the texture coordinates from
the gl_PointCoord builtin instead of cogl_tex_coord_in[*].
gl_PointCoord is not quite the same as the regular texture coordinates
because it is only a vec2 instead of a vec4. This used to work ok
because either set of texture coordinates would always immediately be
accessed using a swizzle of '.st' so it would effectively be converted
to a vec2 anyway. However since the snippet hook for texture lookups
was added the texture coordinates are now passed to a function to
perform the actual lookup instead. This function always takes a vec4
so the shader would not compile. This patch fixes it to construct a
vec4 from gl_PointCoord by setting the third and fourth components to
0.0 and 1.0.

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

(cherry picked from commit cb3409b23caf324a548f82cfb88acc684cc71930)
Don't use the transpose argument of glUniformMatrix*

According to the GLES1/2 spec, the transpose argument of
glUniformMatrix* should always be FALSE. Cogl directly exposes the
transposedness of the uniform value in
cogl_pipeline_set_uniform_matrix and we were previously passing this
value on to GL. This patch makes it instead just always transpose the
matrix in Cogl itself when copying the value to the CoglBoxedValue. It
doesn't seem like there could be much advantage to letting GL
transpose the uniform value and at least Mesa just does a very similar
loop to handle the transpose.

Mesa has started being more pedantic about this which was making
test_pipeline_uniforms fail.

http://cgit.freedesktop.org/mesa/mesa/commit/?id=60e8a4944081b42127b3

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

(cherry picked from commit f42ee670ff663d03073d6b1038b21a0aa1b3ec2b)

Conflicts:
	cogl/cogl-boxed-value.h
build: Remove clutter-project.org from the release rules

clutter-project.org is no longer accessible for uploading releases so
this just removes all mention of it from the release rules.
Updates NEWS for the 1.10.4 release
Release 1.10.4 (release)
Post-release version bump to 1.10.5
Visual C++ support: Re-enable C4819 warnings

The C4819 warnings appear due to a bug on Visual C++ when running on
non-English locales, specifically CJK versions/locales of Windows.

Re-enable this, like what is done in GLib, and add a note in the Visual
C++ README.txt's to tell people about this, so that Cogl will be built
correctly.
pipeline: Remove the CoglPipelineFlag enum

This doesn't appear to be used anywhere in the code since it was added
in 1cc3ae69. Dead code is confusing so let's remove it.

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

(cherry picked from commit 41928d0ac528acf4ba89b5b27d7ca7ac5501b194)
Fix the header guards for cogl-texture-2d{,-private}.h

The header guard for cogl-texture-2d-private.h was
__COGL_TEXTURE_2D_H. This would conflict with the header guard for
cogl-texture-2d.h except there a small typo ('TEXURE') so that it
was subtly different. This fixes them both to make more sense.

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

(cherry picked from commit 222ec4d009973cb62020a9da05f72dea41460b33)
Support building with automake 1.12.x

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

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

(cherry picked from commit e5b5c5017487cec6426c93c364ff853831bc2080)
framebuffer: Take const pointers for the matrix setters

cogl_framebuffer_set_{projection,modelview}_matrix don't need to read
from the matrix argument so they should probably take a const pointer.

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

(cherry picked from commit 710d6af053aca97935b54f9ff68858ef51f4482b)
test(1) uses '=' to test if strings are identical

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

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

(cherry picked from commit 5cd15e7781466307a27c31e6e3f1e7f5ade5cfee)
pipeline: Ensure the pipeline layer cache is freed when pruning layers

When pruning layers from a pipeline the pipeline cache would once be
freed due to the call to pre_change_notify but it would immediately be
recreated again when foreach_layer_internal is called. When n_layers
is later set to 0 it would end up with an invalid cache lying around.
This patch changes the order so that it will iterate the layers first
before triggering the pre-change notify so that the cache will be
cleared correctly.

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

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

(cherry picked from commit 1c8efdc838cc5ace380365cb54e0741645856edf)
pipeline: Fix the layer index used when pruning layers

When pruning a pipeline to a set number of layers it records the index
of the first layer after the given number of layers have been found.
This is stored in a variable called 'first_index_to_prune' implying
that this layer should be included in the layers to be pruned. However
the subsequent if-statement was only pruning layers with an index
greater than the recorded index so it would presumably only prune the
following layers. This patch fixes it to use '>=' instead.

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

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

(cherry picked from commit d3063e8dea92a8f668acef6435cc68e0c901dc8d)
winsys-glx: Remove the vblank counter feature when indirect rendering

Previously when Cogl detects that the GLX context is indirect it
resets the function pointers for the VBLANK_COUNTER feature to NULL.
However it wasn't removing the VBLANK_COUNTER feature flag. Some other
parts of the winsys check for that feature flag rather than checking
whether the pointer is NULL so it would end up calling an invalid
function pointer and crashing. This just fixes it to also clear the
feature flag.

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

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

(cherry picked from commit e947c713a541086f80a308d22774229f0720196a)
Fix the terminator in one of the extension lists

The list of extension names in COGL_EXT_BEGIN should be a zero
separated list of strings which is terminated by an empty string. The
name for the GL_ARB_shader_objects extension was missing the zero
separator so presumably it was relying on the following byte to happen
to be a zero in order not to crash.

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

(cherry picked from commit f63381f23fa8b0b17e030561940b8a38efff221f)