xbmc: add PR3210

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2013-09-08 03:36:50 +02:00
parent c58862239b
commit ac359292c5

View File

@ -0,0 +1,151 @@
From 67933a247943afe83bb885a5c3881bf03ce0b03b Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com>
Date: Sat, 7 Sep 2013 18:32:58 +0100
Subject: [PATCH 1/2] [rendercapture] Fix passthrough rendercapture interface
The RenderCapture function doesn't behave correctly for passthough video renderers,
and in fact segfaults on Pi when setting a bookmark.
There is no need to do a glReadPixels to get a video snapshot in the passthrough case,
so provide a shortcut.
---
xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
index f9f5aa4..ee03b2f 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
+++ b/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
--
1.8.4
From c02a7e15bfdba2743c9300fa8375cf22a908e8e7 Mon Sep 17 00:00:00 2001
From: popcornmix <popcornmix@gmail.com>
Date: Sat, 7 Sep 2013 18:33:32 +0100
Subject: [PATCH 2/2] [rbp] Support grabbing just the video layer through
rendercapture
As the bookmark snapshot doesn't want the OSD (and neither does boblight)
allow video, or video + GUI to be selectable.
While we're there, making the GPU do the red/blue swap and stride packing saves some cpu.
Requires updated firmware
---
xbmc/linux/RBP.cpp | 37 ++++++++++---------------------------
xbmc/linux/RBP.h | 2 +-
xbmc/utils/Screenshot.cpp | 2 +-
3 files changed, 12 insertions(+), 29 deletions(-)
diff --git a/xbmc/linux/RBP.cpp b/xbmc/linux/RBP.cpp
index 21b1e8c..b68fce6 100644
--- a/xbmc/linux/RBP.cpp
+++ b/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;
diff --git a/xbmc/linux/RBP.h b/xbmc/linux/RBP.h
index 58cdf57..58b6f05 100644
--- a/xbmc/linux/RBP.h
+++ b/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;
diff --git a/xbmc/utils/Screenshot.cpp b/xbmc/utils/Screenshot.cpp
index 05404c9..824c003 100644
--- a/xbmc/utils/Screenshot.cpp
+++ b/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)
--
1.8.4