xephyr: Don't forget to glViewport() before drawing the screen.

Fixes misrendering with cairogears.  I had noticed the failure while
trying to figure out what was going on with traps.  Cairogears was
apparently putting its results on the screen through putimage, which
is a texture upload, so the last GL drawing was done to the size of
the cairogears window, not the size of the xephyr screen.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
glamor: Drop the set of the context to NULL at the end of glamor ops.

The theory here was that it (which I copied from EGL) existed to fix
up context switching with indirect GLX.  But indirect GLX won't even
try to set the context again unless its lastContext field is cleared,
so we need to solve this a different way.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
glamor: Use epoxy_has_egl_extension() instead of rolling our own.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Move the EGL image to the normal pixmap private.

There's no reason to hide EGL from the rest of glamor, now that we
have epoxy.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Do glyph private init at screeninit time, and other stuff at CSR.

This hasn't actually been a problem, since the server hasn't allocated
any glyphs before our glyph private initialization during
CreateScreenResources.  But it's generally not X Server style to do
things this way.

Now that glamor itself drives both parts of glyphs setup, DDX drivers
no longer need to tell glamor to initialize glyphs.  We do retain the
old public symbol so they can keep running with no changes.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
sync: Add a header include necessary to use misyncstr.h

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
glamor: Drop the body of the function for enabling DRI3 extensions.

The flag is already being set at glamor_egl_screen_init() time, so no
need for the driver to separately call this.  That said, leave the
function around to keep the ABI compatibility.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Return the stride/size for glamor_dri3_name_from_pixmap(), too.

Just like for a caller of glamor_dri3_fd_from_pixmap(), otherwise the
consumer of that named buffer has no idea what GL chose for the
stride.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Drop duplicated lines for getting pixmap state in GetImage.

No change in generated code size -- apparently the compiler figured it
out.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Fix stack overflow in glamor_solid vertex handling.

ARRAY_SIZE(vertices) is 32 (floating point values), so we need to
divide by the number of floats in a box like we do in the overflow
case below.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Drop bogus _X_UNLIKELY.

nbox > 4 is actually quite common for spans handling.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Fix some integer overflow errors.

Imagine a nbox that was (UINT_MAX + small number) / (4 * 2 *
sizeof(float)).  We'd malloc a few bytes after the integer overflow,
but glamor_set_normalize_vcoords would write over gigabytes of heap.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Rename a variable to be more descriptive.

The "valid_" prefix was used above to describe our allocation that
gets reused multiple times, which is totally unrelated.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Rename more solid fill variables to clean up the code.

Now the error path of allocation is more obvious: We leave things in
the a-few-boxes-at-a-time stack memory state.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Fix up doxygen for glamor_fill.c.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Replace some goofy enum-likes with a real enum.

This unpacks the bitfield into an int size, but my experience has been
that packing bitfields doesn't matter for performance.

v2: Convert more comparisons against numbers or implicit bool
    comparisons to comparisons against the enum names, and fix up some
    comments.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Drop stale comment.

The old Xephyr codebase was using the GL window system framebuffer for
the screen pixmap, but that meant you couldn't texture from it to do
operations sourcing from the screen, so in the version that landed I
instead had the screen just be a plain texture.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
glamor: Drop unused GLAMOR_ACCESS_WO.

Nothing was using it, and it was going to complicate the
glamor_prepare_access bugfixing I'm going to do next.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Allow nested mapping of pixmaps.

The common pattern is to do nested if statements making calls to
prepare_access() and then pop those mappings back off in each set of
braces.  Some cases checked for src == dst to avoid leaking mappings,
but others didn't.  Others didn't even do the nested mappings, so a
failure in the outer map would result in trying to umap the inner and
failing.

By allowing nested mappings, we can fix both problems by not requiring
the care from the caller, plus we can allow a simpler nesting of all
the prepares in one if statement.

v2: Add a comment about nested unmap behavior, and just reuse the
    glamor_access_t enum.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>
glamor: Rely on nested mappings to handle src==dst and !prepare bugs.

Now that the core deals with that for us, we can avoid all this extra
carefulness.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Markus Wick <markus@selfnet.de>