gl: Adaptive image atlas

Initial image atlas size is 512x512, and will grow to max 2048x2048.
When existing image atlas is not big enough to hold new image cache,
a new image atlas is created.  Each image in the existing image atlas
is then copied to the new image atlas one by one.  After copying, the
existing image atlas is then destroyed.
gl/msaa: Implement hairline for stroke.

A hairline is a stroke of simplifies the tessellating algorithm
for stroking using other draw modes.
gl: Use color attributes for text rendering.
stroke: Fix stroking of arcs with large line widths

Fix test case, line-width-tolerance, for the stroke shaper (currently
used only by the GL MSAA compositor). Instead of drawing quads between
spline points, draw triangle based on the actual spline edges. This
roughly follows the approach of the tristrip and polygonal shapers.
gl/msaa: Avoid stencil buffer usage for simple curves

If the stroke path contains a single curve_to, we can avoid
stencil overlapping check.
Fix get-path-extent after changing the pen vertex range finders.

Now the result of the dots and multiple dots is just approximate.
gl/msaa:  We can prevent stencil overlapping check in these situations.

If single line and single arc both are continuous when width is 1.0 we
can avoid it, also in the general case if it is single line and
continuous.
gl: Scale radial gradient parameters down may introduce rounding error.

Instead of using scaled parametes to generate uniform values, we
compute them from origin radial gradient pattern.
gl/msaa: Lazy initialization for glyph compute bounding box.

We do the initialization creating a mask that is big enough for text
instead of whole surface.
gl/msaa: Draw trap optimization.
gl: Store GLSL ES uniform locations into a lookup table.

We are initializing lazily the values of the table.
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.
NOT-FOR-UPSTREAM: gl: Cache glyph masks

This avoids the overhead of constantly binding new framebuffers, which
can be very slow on non-Intel hardware. See:
http://lists.cairographics.org/archives/cairo/2013-February/024073.html
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.