With the refactoring to centralize code into CoglBuffer,
_cogl_buffer_fini() was never actually implemented, so all GL
vertex and index buffer objects were leaked.
The duplicate call to glDeleteBuffers() in CoglPixelArray is
removed (it wasn't paying attention to whether the buffer had been
allocated as a PBO or not.)
http://bugzilla.clutter-project.org/show_bug.cgi?id=2423
Since we'll want to share the fallback logic with CoglVertexArray this
moves the malloc based fallback (for when OpenGL doesn't support vertex
or pixel buffer objects) into cogl-buffer.c.
This makes CoglBuffer track the last used bind target as a private
property. This is later used when binding a buffer to map instead of
always using the PIXEL_UNPACK target.
This also adds some additional sanity checks that code doesn't try to
nest binds to the same target or bind a buffer to multiple targets at
the same time.
This allows you to tell Cogl that you are planning to replace all the
buffer's data once it is mapped with cogl_buffer_map. This means if the
buffer is currently being accessed by the GPU then the driver doesn't
have to stall and wait for it to finish before it can access it from the
CPU and can instead potentially allocate a new buffer with undefined
data and map that.
This removes cogl_pixel_array_new which just took a size in bytes.
Without the image size and pixel format then the driver often doesn't
have enough information to allocate optimal GPU memory that can be
textured from directly. This is because GPUs often have ways to
spatially alter the layout of a texture to improve cache access patterns
which may require special alignment and padding dependant in the images
width, height and bpp.
Although currently we are limited by OpenGL because it doesn't let us
pass on the width and height when allocating a PBO, the hope is that we
can define a better extension at some point.