aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp54
1 files changed, 52 insertions, 2 deletions
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
index 5b88fc7248..69e4f20e15 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
+++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -28,6 +28,7 @@
#include <locale.h>
#include "guilib/MatrixGLES.h"
#include "LinuxRendererGLES.h"
+#include "utils/fastmemcpy.h"
#include "utils/MathUtils.h"
#include "utils/GLUtils.h"
#include "settings/Settings.h"
@@ -1241,10 +1242,11 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
// clear framebuffer and invert Y axis to get non-inverted image
glDisable(GL_BLEND);
+
g_matrices.MatrixMode(MM_MODELVIEW);
g_matrices.PushMatrix();
- g_matrices.Translatef(0, capture->GetHeight(), 0);
- g_matrices.Scalef(1.0, -1.0f, 1.0f);
+ g_matrices.Translatef(0.0f, capture->GetHeight(), 0.0f);
+ g_matrices.Scalef(1.0f, -1.0f, 1.0f);
capture->BeginRender();
@@ -1253,6 +1255,54 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
glReadPixels(0, rv.y2 - capture->GetHeight(), capture->GetWidth(), capture->GetHeight(),
GL_RGBA, GL_UNSIGNED_BYTE, capture->GetRenderBuffer());
+ // OpenGLES returns byte in RGBA order but CRenderCapture needs BGRA order
+ /*
+ unsigned int pitch = capture->GetWidth() * 4;
+ unsigned char *dst, *pixels = (unsigned char*)capture->GetRenderBuffer();
+ for (unsigned int y = 0; y < capture->GetHeight(); y++)
+ {
+ dst = pixels + (y * pitch);
+ for (unsigned int x = 0; x < pitch; x+=4)
+ std::swap(dst[x], dst[x+2]);
+ }
+ */
+ // flip top/bottom and swap RGBA to BGRA.
+ // we should NOT have to do this as the matrix transform
+ // should take care of this. TODO: figure out why.
+ {
+ int top = 0;
+ int bot = capture->GetHeight() - 1;
+ int rowbytes = capture->GetWidth() * 4;
+ unsigned char *base_ptr = (unsigned char*)capture->GetRenderBuffer();
+ unsigned char *rowbuffer = (unsigned char*)malloc(rowbytes);
+ unsigned char *t1_ptr, *b1_ptr, *b2_ptr, *rb_ptr;
+ while ( top < bot )
+ {
+ t1_ptr = base_ptr + (rowbytes * top++);
+ b2_ptr = b1_ptr = base_ptr + (rowbytes * bot--);
+
+ // save out top line.
+ fast_memcpy(rowbuffer, t1_ptr, rowbytes);
+ // copy bottom line to top, swapping from RGBA to BGRA
+ for (int x = 0; x < rowbytes; x+=4, b1_ptr+=4)
+ {
+ *t1_ptr++ = b1_ptr[2];
+ *t1_ptr++ = b1_ptr[1];
+ *t1_ptr++ = b1_ptr[0];
+ *t1_ptr++ = b1_ptr[3];
+ }
+ // copy saved top line to bottom, swapping from RGBA to BGRA
+ rb_ptr = rowbuffer;
+ for (int x = 0; x < rowbytes; x+=4, rb_ptr+=4)
+ {
+ *b2_ptr++ = rb_ptr[2];
+ *b2_ptr++ = rb_ptr[1];
+ *b2_ptr++ = rb_ptr[0];
+ *b2_ptr++ = rb_ptr[3];
+ }
+ }
+ free(rowbuffer);
+ }
capture->EndRender();
// revert model view matrix