This code was working at one point, so I must have broken it just before the putback
of 6274813. I noticed the visual problems recently but while debugging some unrelated
code I noticed that glGetError() was returning non-zero error codes after rendering
overlapping LCD glyphs. It turns out that there is a silly bug in
OGLTR_UpdateCachedDestination() when handling the overlapping case where we pass
a negative xoffset to glCopyTexSubImage2D(), which results in a GL_INVALID_VALUE
error to be generated and the operation fails. This explains why the readback fails
and the overlapping glyph is not blended properly with the previous glyph.
The problem is that we were calling:
cachedDestBounds.x1 - dx1,
cachedDestBounds.y2 - dy2, ...
The x/y values are relative to an upper-left origin, so dx1 will always be >=
cachedDestBounds.x1, and dy2 will always be <= cachedDestBounds.y2. So the y
calculation is okay (it will always be non-negative), but the x calculation is
broken such that it will always be non-positive. The fix is easy, we just need
to reverse the x calculation:
dx1 - cachedDestBounds.x1,
so that the xoffset is always non-negative.