_cogl_bitmap_convert: Also handle premult conversions

If we are going to unpack the data into a known format anyway we might
as well do the premult conversion instead of delaying it to do
in-place. This helps because not all formats with alpha channels are
handled by the in-place premult conversion code. This removes the
_cogl_bitmap_convert_format_and_premult function so that now
_cogl_bitmap_convert is a completely general purpose function that can
convert from anything to anything. _cogl_bitmap_convert now includes a
fast path for when the base formats are the same and the premult
conversion can be handled with the in-place code so that we don't need
to unpack and can just copy the bitmap instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
bitmap: Add a function to convert into an existing buffer

This adds _cogl_bitmap_convert_into_bitmap which is the same as
_cogl_bitmap_convert except that it writes into an existing bitmap
instead of allocating a new one. _cogl_bitmap_convert now just
allocates a buffer and calls the new function. This is used in
_cogl_read_pixels to avoid allocating a second intermediate buffer
when the pixel format to store in is not GL_RGBA.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
bitmap: Support pre/unpre-multiplying any format

If the fast-path inplace premult conversion can't be used then it will
now fallback to unpacking the buffer into a row of guint16s and use
the generic conversion.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
cogl-buffer: Create the buffer store when bound

Whenever the buffer is bound with _cogl_buffer_bind Cogl now ensures
the buffer's data store has been created. Previously it would only
ensure it was created when it was first mapped or when the first data
was set on it. This is necessary if we are going to use CoglBuffers
for retrieving data from GL. In that case the buffer won't be mapped
or have data set on it before it is used.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Add a public cogl_framebuffer_read_pixels_into_bitmap

This adds a public function to read pixels from a framebuffer into a
CoglBitmap. This replaces the internal function
_cogl_read_pixels_with_rowstride because a CoglBitmap contains a
rowstride so it can be used for the same purpose. A CoglBitmap already
has public API to make one that points to a CoglPixelBuffer so this
function can be used to read pixels into a PBO. It also avoids the
need to push the framebuffer on to the context's stack so it provides
a function which can be used in the 2.0 API after the stack is
removed.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Change API so that CoglPixelBuffer no longer knows its w/h/format

The idea is that CoglPixelBuffer should just be a buffer that can be
used for pixel data and it has no idea about the details of any images
that are stored in it. This is analogous to CoglAttributeBuffer which
itself does not have any information about the attributes. When you
want to use a pixel buffer you should create a CoglBitmap which points
to a region of the attribute buffer and provides the extra needed
information such as the width, height and format. That way it is also
possible to use a single CoglPixelBuffer with multiple bitmaps.

The changes that are made are:

• cogl_pixel_buffer_new_with_size has been removed and in its place is
  cogl_bitmap_new_with_size. This will create a pixel buffer at the
  right size and rowstride for the given width/height/format and
  immediately create a single CoglBitmap to point into it. The old
  function had an out-parameter for the stride of the image but with
  the new API this should be queriable from the bitmap (although there
  is no function for this yet).

• There is now a public cogl_pixel_buffer_new constructor. This takes
  a size in bytes and data pointer similarly to
  cogl_attribute_buffer_new.

• cogl_texture_new_from_buffer has been removed. If you want to create
  a texture from a pixel buffer you should wrap it up in a bitmap
  first. There is already API to create a texture from a bitmap.

This patch also does a bit of header juggling because cogl-context.h
was including cogl-texture.h and cogl-framebuffer.h which were causing
some circular dependencies when cogl-bitmap.h includes cogl-context.h.
These weren't actually needed in cogl-context.h itself but a few other
headers were relying on them being included so this adds the #includes
where necessary.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Make _cogl_bitmap_get_{width,height,format,rowstride} public

This are now marked as public experimental

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Add the missing cast macros for some buffer objects

CoglPixelBuffer, CoglAttributeBuffer and CoglIndexBuffer were missing
public cast macros.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
cogl-bitmap: Add a public accessor for the underlying pixel buffer

This adds a small cogl_bitmap_get_buffer public function. Note that
this can return NULL if the bitmap was not created with a pixel
buffer. It might be nice to change this eventually so that all bitmaps
have a pixel buffer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Port the test-pixel-buffer test

This ports the text-pixel-buffer test from being a Clutter test to a
straight Cogl test.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Don't use cogl_get_draw_framebuffer when flushing pipeline state

Some of the state when flushing a pipeline depends on the current
framebuffer being used. These are:

• The matrix stack, so that it can flip vertically or not depending on
  whether the framebuffer is offscreen.
• The colormask. This is combined with the framebuffer's color mask.
• The cull face mode. If the framebuffer is offscreen then backface
  culling is translated to frontface culling and vice-versa.

These states were not working if the new framebuffer draw_primitive
API was used because in that case the framebuffer is not pushed to the
framebuffer stack so it would use the wrong one. This patch changes it
to use ctx->current_draw_buffer which is a pointer to the framebuffer
whose state was last flushed.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
wayland-renderer: remove the _EXP suffix from symbols

We are in the process of removing all _EXP suffix mangling for
experimental APIs (Ref: c6528c4b6c3c34) and adding missing gtk-doc
comments so that we can instead rely on the "Stability: unstable"
markers in the gtk-doc comments. This patch tackles the
cogl-wayland-renderer api symbols.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
cogl-hello: use glib mainloop for portability

To be a portable example this updates cogl-hello to use the glib
mainloop instead of using g_poll. On OSX we plan to provide custom
mainloop integration for glib which can't be abstracted by just using
g_poll.
docs: remove redundancies from doc/RELEASING

This removes the notes about explicitly testing a release on GLES2 and
with the different pipeline backends since the test suite now does this
for us.
test: remove FEATURE_GL requirement for sub_texture test

test-cogl-sub-texture was fixed to now run on GLES2 since commit
5928cade0b0 so this removes the TEST_REQUIREMENT_GL flag for this test
so it doesn't get flagged as an unexpected pass.
build: clean .log file in tests/conform dir

When running the conformance tests we write to a .log file which wasn't
being removed by make clean which was causing make release-check to
fail.
build: list cogl-bitmap-packing.h as source file

This fixes make release-check because cogl-bitmap-packing.h wasn't being
packaged.
docs: Make sure we check wayland support for releases

This updates the RELEASING notes to state that we should enable wayland
support when preparing and testing for a release.
Updates NEWS for the 1.9.8 release
Release 1.9.8 (snapshot)