Skip to content
This repository
Browse code

Merge pull request #3210 from popcornmix/passthrough_capture

[rendercapture] Fix passthrough rendercapture interface
  • Loading branch information...
commit 3b7bf8d2a2594c0be464466a7f6382fc2726a54f 2 parents 2ef8929 + c02a7e1
huceke authored September 09, 2013
8  xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -1421,6 +1421,14 @@ bool CLinuxRendererGLES::RenderCapture(CRenderCapture* capture)
1421 1421
   if (!m_bValidated)
1422 1422
     return false;
1423 1423
 
  1424
+  // If rendered directly by the hardware
  1425
+  if (m_renderMethod & RENDER_BYPASS)
  1426
+  {
  1427
+    capture->BeginRender();
  1428
+    capture->EndRender();
  1429
+    return true;
  1430
+  }
  1431
+
1424 1432
   // save current video rect
1425 1433
   CRect saveSize = m_destRect;
1426 1434
   saveRotatedCoords();//backup current m_rotatedDestCoords
37  xbmc/linux/RBP.cpp
@@ -89,7 +89,7 @@ void CRBP::GetDisplaySize(int &width, int &height)
89 89
   vc_dispmanx_display_close(display );
90 90
 }
91 91
 
92  
-unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool swap_red_blue)
  92
+unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool swap_red_blue, bool video_only)
93 93
 {
94 94
   DISPMANX_DISPLAY_HANDLE_T display;
95 95
   DISPMANX_RESOURCE_HANDLE_T resource;
@@ -97,6 +97,14 @@ unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool sw
97 97
   unsigned char *image = NULL;
98 98
   uint32_t vc_image_ptr;
99 99
   int stride;
  100
+  uint32_t flags = 0;
  101
+
  102
+  if (video_only)
  103
+    flags |= DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL;
  104
+  if (swap_red_blue)
  105
+    flags |= DISPMANX_SNAPSHOT_SWAP_RED_BLUE;
  106
+  if (!pstride)
  107
+    flags |= DISPMANX_SNAPSHOT_PACK;
100 108
 
101 109
   display = vc_dispmanx_display_open( 0 /*screen*/ );
102 110
   stride = ((width + 15) & ~15) * 4;
@@ -106,37 +114,12 @@ unsigned char *CRBP::CaptureDisplay(int width, int height, int *pstride, bool sw
106 114
   {
107 115
     resource = vc_dispmanx_resource_create( VC_IMAGE_RGBA32, width, height, &vc_image_ptr );
108 116
 
109  
-    vc_dispmanx_snapshot(display, resource, (DISPMANX_TRANSFORM_T)0);
  117
+    vc_dispmanx_snapshot(display, resource, (DISPMANX_TRANSFORM_T)flags);
110 118
 
111 119
     vc_dispmanx_rect_set(&rect, 0, 0, width, height);
112 120
     vc_dispmanx_resource_read_data(resource, &rect, image, stride);
113 121
     vc_dispmanx_resource_delete( resource );
114 122
     vc_dispmanx_display_close(display );
115  
-
116  
-    // we need to save in BGRA order so Swap RGBA -> BGRA
117  
-    if (swap_red_blue)
118  
-    {
119  
-      for (int y = 0; y < height; y++)
120  
-      {
121  
-        unsigned char *p = image + y * stride;
122  
-        for (int x = 0; x < width; x++, p+=4)
123  
-        {
124  
-          unsigned char t = p[0];
125  
-          p[0] = p[2];
126  
-          p[2] = t;
127  
-        }
128  
-      }
129  
-    }
130  
-    // assume we need to pack image if caller doesn't want stride
131  
-    if (!pstride && stride > width*4)
132  
-    {
133  
-      for (int y = 0; y < height; y++)
134  
-      {
135  
-        unsigned char *in  = image + y * stride;
136  
-        unsigned char *out = image + y * width * 4;
137  
-        memmove(out, in, width*4);
138  
-      }
139  
-    }
140 123
   }
141 124
   if (pstride)
142 125
     *pstride = stride;
2  xbmc/linux/RBP.h
@@ -51,7 +51,7 @@ class CRBP
51 51
   int GetGpuMem() { return m_gpu_mem; }
52 52
   void GetDisplaySize(int &width, int &height);
53 53
   // stride can be null for packed output
54  
-  unsigned char *CaptureDisplay(int width, int height, int *stride, bool swap_red_blue);
  54
+  unsigned char *CaptureDisplay(int width, int height, int *stride, bool swap_red_blue, bool video_only = true);
55 55
 
56 56
 private:
57 57
   DllBcmHost *m_DllBcmHost;
2  xbmc/utils/Screenshot.cpp
@@ -62,7 +62,7 @@ bool CScreenshotSurface::capture()
62 62
 {
63 63
 #if defined(TARGET_RASPBERRY_PI)
64 64
   g_RBP.GetDisplaySize(m_width, m_height);
65  
-  m_buffer = g_RBP.CaptureDisplay(m_width, m_height, &m_stride, true);
  65
+  m_buffer = g_RBP.CaptureDisplay(m_width, m_height, &m_stride, true, false);
66 66
   if (!m_buffer)
67 67
     return false;
68 68
 #elif defined(HAS_DX)

3 notes 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.