gl: Fix typo in gles2 shader cache lookup

When comparing shader cache entries, it's important that we actually
compare the variable type hash.
gl: Avoid redundant calls to make_current

When we detect that setting the destination does not affect what surface
is the current target, do not call make_current. On some drivers this
can be unreasonably expensive (up to a 1 millisecond).
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.