summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/videocore-exa.c22
-rw-r--r--src/videocore-shaders.c9
-rw-r--r--src/videocore-shaders.h2
3 files changed, 27 insertions, 6 deletions
diff --git a/src/videocore-exa.c b/src/videocore-exa.c
index b7a5466..78c6339 100644
--- a/src/videocore-exa.c
+++ b/src/videocore-exa.c
@@ -459,6 +459,22 @@ CopyToTexture(ScrnInfoPtr pScrn,
glBindTexture(GL_TEXTURE_2D, 0);
}
+static void
+flip_rows(char *data, unsigned short width, unsigned short height, unsigned short stride)
+{
+ unsigned short i;
+ char spare[stride];
+
+ for (i = 0; i < height / 2; i++) {
+ char *a = data + (i * stride);
+ char *b = data + ((height - i - 1) * stride);
+
+ memcpy(spare, a, stride);
+ memcpy(a, b, stride);
+ memcpy(b, spare, stride);
+ }
+}
+
/*
* PrepareAccess() sets up an offscreen pixmap for CPU access. We can't do this
* efficiently, but we have to implement it. :(
@@ -501,6 +517,10 @@ VideoCorePrepareAccess(PixmapPtr pPixmap, int index)
return FALSE;
}
+ if (priv->is_screen_pixmap) {
+ flip_rows(priv->data, width, height, width * 4);
+ }
+
pPixmap->devPrivate.ptr = priv->data;
DEBUG_MSG("allocated %p for pixmap %p", priv->data, pPixmap);
return TRUE;
@@ -543,7 +563,7 @@ VideoCoreFinishAccess(PixmapPtr pPixmap, int index)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, priv->data);
- if (VideoCoreDrawIdentity(pScrn)) {
+ if (VideoCoreDrawUpsideDown(pScrn)) {
eglSwapBuffers(vcExa->display, vcExa->surf);
CheckGLError("eglSwapBuffers");
}
diff --git a/src/videocore-shaders.c b/src/videocore-shaders.c
index f449cc9..7dc2f39 100644
--- a/src/videocore-shaders.c
+++ b/src/videocore-shaders.c
@@ -117,10 +117,11 @@ static GLuint identity_program = 0;
static GLint a_texCoord, s_texture, a_position;
/**
- * Draws the texture currently bound to GL_TEXTURE_2D over the entire screen.
+ * Draws the texture currently bound to GL_TEXTURE_2D over the entire screen,
+ * upside-down.
*/
Bool
-VideoCoreDrawIdentity(ScrnInfoPtr pScrn)
+VideoCoreDrawUpsideDown(ScrnInfoPtr pScrn)
{
float vertex_coords[] = {
-1.0, 1.0,
@@ -130,10 +131,10 @@ VideoCoreDrawIdentity(ScrnInfoPtr pScrn)
};
float tex_coords[] = {
- 0.0, 1.0,
0.0, 0.0,
- 1.0, 1.0,
+ 0.0, 1.0,
1.0, 0.0,
+ 1.0, 1.0,
};
GLushort indices[] = {
diff --git a/src/videocore-shaders.h b/src/videocore-shaders.h
index e4851a7..e895f7e 100644
--- a/src/videocore-shaders.h
+++ b/src/videocore-shaders.h
@@ -25,6 +25,6 @@
#include "xf86.h"
Bool VideoCoreShadersInit(ScrnInfoPtr pScrn);
-Bool VideoCoreDrawIdentity(ScrnInfoPtr pScrn);
+Bool VideoCoreDrawUpsideDown(ScrnInfoPtr pScrn);
#endif