NOT-FOR-UPSTREAM: gl: Don't check surface during context acquisition

Different drawable only means the gl context has different target window
or pixmap. In cairo case, we are OK because for offscreen rendering we
use FBO, for window or pixmap rendering, we always call _make_current.
In multithreaded application, different drivers behave differently.

For intel, the drawable is always 0 while context and display are not.
For nvidia, all three parameters are non-zero For fglrx, they are all 0.

FIXME: We can not upstream this patch until we can save/restore the
gl state properly.
NOT-FOR-UPSTREAM: gl: We must flush in gl_surface_clear.

This is a work-around for a bug in the Mali driver, but at this point we
don't know what bug or with what test case.
NOT-FOR-UPSTREAM: gl/msaa: Use cached clip on non-texture surfaces

Instead of just relying on a cached clip for texture surfaces only, also
allow for caching the clip on the stencil buffer of non-texture
surfaces. This will not work if the stencil buffer is modified outside
cairo.
NOT-FOR-UPSTREAM: test: Use a percentage to check if pixels have changed.

Increase the PERCEPTUAL_DIFF_THRESHOLD and use a percentage of the
size of the image to check it the change is perceptible.
NOT-FOR-UPSTREAM: gl/msaa: Cache more GL states to avoid redundant operations

Cache the active texture, the RGBA values of glClearColor,
blend functions, blend state, and depth mask state.

FIXME: this commit adds restrictions about how applications can use
the GL context when using cairo.
NOT-FOR-UPSTREAM: This is an ugly hack that deals with mali driver bug.
CHERRY-PICK: gl: Set up operands when the vertex size changes

Previously _cairo_gl_composite_setup_vbo was overwriting the old context
vertex_size, while _cairo_gl_context_setup_operand was relying on it to
determine if the vertex size changed. Instead of a fragile ordering of
statements, pass whether the context changed as an argument to enforce
the calling order via method parameters.
CHERRY-PICK: gl: Fix typo in gles2 shader cache lookup

When comparing shader cache entries, it's important that we actually
compare the variable type hash.
CHERRY-PICK: gl/msaa: Resolve multisampling on surface flush

When flushing a surface, we must resolve multisampling for desktop GL.
This allows use of the original surface texture in any following raw GL
operations. This fixes accelerated canvas with WebKitGTK+ using the MSAA
compositor.
CHERRY-PICK: gl: Separate framebuffer bind from destination selection

Disentangle the action of binding the framebuffer from setting the
destination. This straightens up the code a bit and avoids some redundant
operations (such as reacquiring the context) when simply switching from
the multi-sample framebuffer to the single-sample framebuffer and vice
versa.
CHERRY-PICK: gl: Update transformation when surface size changes

In my previous commit I mistakenly removed the transformation matrix
update when cairo_gl_surface_set_size is called. This change restores
it.