diff options
author | Will Thompson <will@willthompson.co.uk> | 2012-05-16 17:13:13 +0100 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2012-05-16 17:34:44 +0100 |
commit | b940ecac836f4e889fe4d83595e3aee72b86d135 (patch) | |
tree | b07bfc1308c17747174114f2ae9f554304392b59 | |
parent | fbf0bd863cf2b8cbdeaf70ff01da2cb6ec42954c (diff) |
-rw-r--r-- | src/videocore-exa.c | 22 | ||||
-rw-r--r-- | src/videocore-shaders.c | 9 | ||||
-rw-r--r-- | src/videocore-shaders.h | 2 |
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 |