Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3210 from popcornmix/passthrough_capture

[rendercapture] Fix passthrough rendercapture interface
  • Loading branch information...
commit 3b7bf8d2a2594c0be464466a7f6382fc2726a54f 2 parents 2ef8929 + c02a7e1
@huceke huceke authored
View
8 xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -1421,6 +1421,14 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
if (!m_bValidated)
return false;
+ // If rendered directly by the hardware
+ if (m_renderMethod & RENDER_BYPASS)
+ {
+ capture->BeginRender();
+ capture->EndRender();
+ return true;
+ }
+
// save current video rect
CRect saveSize = m_destRect;
saveRotatedCoords();//backup current m_rotatedDestCoords
View
37 xbmc/linux/RBP.cpp
@@ -89,7 +89,7 @@ void CRBP::GetDisplaySize(int &width, int &height)
vc_dispmanx_display_close(display );
}
-unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool swap_red_blue)
+unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool swap_red_blue, bool video_only)
{
DISPMANX_DISPLAY_HANDLE_T display;
DISPMANX_RESOURCE_HANDLE_T resource;
@@ -97,6 +97,14 @@ unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool sw
unsigned char *image = NULL;
uint32_t vc_image_ptr;
int stride;
+ uint32_t flags = 0;
+
+ if (video_only)
+ flags |= DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL;
+ if (swap_red_blue)
+ flags |= DISPMANX_SNAPSHOT_SWAP_RED_BLUE;
+ if (!pstride)
+ flags |= DISPMANX_SNAPSHOT_PACK;
display = vc_dispmanx_display_open( 0 /*screen*/ );
stride = ((width + 15) & ~15) * 4;
@@ -106,37 +114,12 @@ unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool sw
{
resource = vc_dispmanx_resource_create( VC_IMAGE_RGBA32, width, height, &vc_image_ptr );
- vc_dispmanx_snapshot(display, resource, (DISPMANX_TRANSFORM_T)0);
+ vc_dispmanx_snapshot(display, resource, (DISPMANX_TRANSFORM_T)flags);
vc_dispmanx_rect_set(&rect, 0, 0, width, height);
vc_dispmanx_resource_read_data(resource, &rect, image, stride);
vc_dispmanx_resource_delete( resource );
vc_dispmanx_display_close(display );
-
- // we need to save in BGRA order so Swap RGBA -> BGRA
- if (swap_red_blue)
- {
- for (int y = 0; y < height; y++)
- {
- unsigned char *p = image + y * stride;
- for (int x = 0; x < width; x++, p+=4)
- {
- unsigned char t = p[0];
- p[0] = p[2];
- p[2] = t;
- }
- }
- }
- // assume we need to pack image if caller doesn't want stride
- if (!pstride && stride > width*4)
- {
- for (int y = 0; y < height; y++)
- {
- unsigned char *in = image + y * stride;
- unsigned char *out = image + y * width * 4;
- memmove(out, in, width*4);
- }
- }
}
if (pstride)
*pstride = stride;
View
2  xbmc/linux/RBP.h
@@ -51,7 +51,7 @@ class CRBP
int GetGpuMem() { return m_gpu_mem; }
void GetDisplaySize(int &width, int &height);
// stride can be null for packed output
- unsigned char *CaptureDisplay(int width, int height, int *stride, bool swap_red_blue);
+ unsigned char *CaptureDisplay(int width, int height, int *stride, bool swap_red_blue, bool video_only = true);
private:
DllBcmHost *m_DllBcmHost;
View
2  xbmc/utils/Screenshot.cpp
@@ -62,7 +62,7 @@ bool CScreenshotSurface::capture()
{
#if defined(TARGET_RASPBERRY_PI)
g_RBP.GetDisplaySize(m_width, m_height);
- m_buffer = g_RBP.CaptureDisplay(m_width, m_height, &m_stride, true);
+ m_buffer = g_RBP.CaptureDisplay(m_width, m_height, &m_stride, true, false);
if (!m_buffer)
return false;
#elif defined(HAS_DX)

3 comments on commit 3b7bf8d

@Koenkk

Causes a compilation error here

RBP.cpp: In member function 'unsigned char* CRBP::CaptureDisplay(int, int, int*, bool, bool)':
RBP.cpp:103:14: error: 'DISPMANX_SNAPSHOT_NO_RGB' was not declared in this scope
RBP.cpp:103:39: error: 'DISPMANX_SNAPSHOT_FILL' was not declared in this scope
RBP.cpp:105:14: error: 'DISPMANX_SNAPSHOT_SWAP_RED_BLUE' was not declared in this scope
RBP.cpp:107:14: error: 'DISPMANX_SNAPSHOT_PACK' was not declared in this scope
make[1]: *** [RBP.o] Error 1
make: *** [xbmc/linux/linux.a] Error 2

Full compile log: https://github.com/xbianonpi/xbian-package-xbmc/blob/bf6bdb4602ca2bde58a4c5f60b431fd716c686be/content/tmp/compile.log

@huceke
Collaborator

@Koenkk: You need an updated RPi firmware + headers.

@Koenkk

That fixed the problem, thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.