aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoakim Plate <elupus@ecce.se>2011-07-07 11:38:13 -0700
committerJoakim Plate <elupus@ecce.se>2011-07-07 11:38:13 -0700
commit5f3686ba98feded712449241b5f2c5e223252591 (patch)
treecc3c26acc2501ab2c97fb6f0573a2b2ce58187f9
parent8b611e7a624ba6fbd98372fb3c27e5758ef6c346 (diff)
parentf2d53f707964f7dc8963346fb0733034e048cd8f (diff)
Merge pull request #252 from elupus/renderclean
Cleanup of rendermanager and dvdplayer's usage of it
-rw-r--r--project/VS2010Express/XBMC.vcxproj2
-rw-r--r--project/VS2010Express/XBMC.vcxproj.filters6
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRenderer.cpp678
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRenderer.h198
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererATI.cpp388
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererATI.h57
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererGL.cpp60
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererGL.h1
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp56
-rw-r--r--xbmc/cores/VideoRenderers/LinuxRendererGLES.h1
-rw-r--r--xbmc/cores/VideoRenderers/Makefile.in1
-rw-r--r--xbmc/cores/VideoRenderers/RenderManager.cpp53
-rw-r--r--xbmc/cores/VideoRenderers/RenderManager.h69
-rw-r--r--xbmc/cores/VideoRenderers/WinRenderManager.cpp166
-rw-r--r--xbmc/cores/VideoRenderers/WinRenderManager.h110
-rw-r--r--xbmc/cores/VideoRenderers/WinRenderer.cpp72
-rw-r--r--xbmc/cores/VideoRenderers/WinRenderer.h1
-rw-r--r--xbmc/cores/dvdplayer/DVDOverlayRenderer.h3
-rw-r--r--xbmc/cores/dvdplayer/DVDPlayerVideo.cpp97
-rw-r--r--xbmc/cores/dvdplayer/DVDPlayerVideo.h2
20 files changed, 77 insertions, 1944 deletions
diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj
index 9443ad9d1c..2ace07f63d 100644
--- a/project/VS2010Express/XBMC.vcxproj
+++ b/project/VS2010Express/XBMC.vcxproj
@@ -962,7 +962,6 @@
</ClCompile>
<ClCompile Include="..\..\xbmc\cores\DllLoader\exports\util\EmuFileWrapper.cpp" />
<ClCompile Include="..\..\xbmc\cores\VideoRenderers\BaseRenderer.cpp" />
- <ClCompile Include="..\..\xbmc\cores\VideoRenderers\LinuxRenderer.cpp" />
<ClCompile Include="..\..\xbmc\cores\VideoRenderers\LinuxRendererGL.cpp" />
<ClCompile Include="..\..\xbmc\cores\VideoRenderers\OverlayRenderer.cpp" />
<ClCompile Include="..\..\xbmc\cores\VideoRenderers\OverlayRendererDX.cpp" />
@@ -1832,7 +1831,6 @@
<ClInclude Include="..\..\xbmc\cores\DllLoader\exports\emu_socket\emu_socket.h" />
<ClInclude Include="..\..\xbmc\cores\DllLoader\exports\util\EmuFileWrapper.h" />
<ClInclude Include="..\..\xbmc\cores\VideoRenderers\BaseRenderer.h" />
- <ClInclude Include="..\..\xbmc\cores\VideoRenderers\LinuxRenderer.h" />
<ClInclude Include="..\..\xbmc\cores\VideoRenderers\LinuxRendererGL.h" />
<ClInclude Include="..\..\xbmc\cores\VideoRenderers\OverlayRenderer.h" />
<ClInclude Include="..\..\xbmc\cores\VideoRenderers\OverlayRendererDX.h" />
diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters
index a57dd7f797..49ee6911f4 100644
--- a/project/VS2010Express/XBMC.vcxproj.filters
+++ b/project/VS2010Express/XBMC.vcxproj.filters
@@ -570,9 +570,6 @@
<ClCompile Include="..\..\xbmc\cores\VideoRenderers\BaseRenderer.cpp">
<Filter>cores\VideoRenderers</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\cores\VideoRenderers\LinuxRenderer.cpp">
- <Filter>cores\VideoRenderers</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\cores\VideoRenderers\LinuxRendererGL.cpp">
<Filter>cores\VideoRenderers</Filter>
</ClCompile>
@@ -2937,9 +2934,6 @@
<ClInclude Include="..\..\xbmc\cores\VideoRenderers\BaseRenderer.h">
<Filter>cores\VideoRenderers</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\cores\VideoRenderers\LinuxRenderer.h">
- <Filter>cores\VideoRenderers</Filter>
- </ClInclude>
<ClInclude Include="..\..\xbmc\cores\VideoRenderers\LinuxRendererGL.h">
<Filter>cores\VideoRenderers</Filter>
</ClInclude>
diff --git a/xbmc/cores/VideoRenderers/LinuxRenderer.cpp b/xbmc/cores/VideoRenderers/LinuxRenderer.cpp
deleted file mode 100644
index beec8ded68..0000000000
--- a/xbmc/cores/VideoRenderers/LinuxRenderer.cpp
+++ /dev/null
@@ -1,678 +0,0 @@
-/*
-* LinuxMediaCenter
-* Copyright (c) 2003 Frodo/jcmarshall
-* Portions Copyright (c) by the authors of ffmpeg / xvid /mplayer
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#include "system.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
- #include "config.h"
-#endif
-
-#ifdef HAS_SDL_2D
-
-#include "LinuxRenderer.h"
-#include "../../Application.h"
-#include "../../Util.h"
-#include "TextureManager.h"
-#include "../ffmpeg/DllSwScale.h"
-
-// http://www.martinreddy.net/gfx/faqs/colorconv.faq
-
-YUVRANGE yuv_range_lim = { 16, 235, 16, 240, 16, 240 };
-YUVRANGE yuv_range_full = { 0, 255, 0, 255, 0, 255 };
-
-YUVCOEF yuv_coef_bt601 = {
- 0.0f, 1.403f,
- -0.344f, -0.714f,
- 1.773f, 0.0f,
-};
-
-YUVCOEF yuv_coef_bt709 = {
- 0.0f, 1.5701f,
- -0.1870f, -0.4664f,
- 1.8556f, 0.0f, /* page above have the 1.8556f as negative */
-};
-
-YUVCOEF yuv_coef_ebu = {
- 0.0f, 1.140f,
- -0.396f, -0.581f,
- 2.029f, 0.0f,
-};
-
-YUVCOEF yuv_coef_smtp240m = {
- 0.0f, 1.5756f,
- -0.2253f, -0.5000f, /* page above have the 0.5000f as positive */
- 1.8270f, 0.0f,
-};
-
-
-CLinuxRenderer::CLinuxRenderer()
-{
- CLog::Log(LOGDEBUG,"Created LinuxRenderer...");
-
- for (int i = 0; i < NUM_BUFFERS; i++)
- {
- m_pOSDYTexture[i] = NULL;
- m_pOSDATexture[i] = NULL;
- }
-
- for (int p=0; p<MAX_PLANES; p++) {
- m_image.plane[p]=NULL;
- m_image.stride[p]=0;
- }
-
-#ifdef USE_SDL_OVERLAY
- m_overlay = NULL;
- m_screen = NULL;
-#else
- m_backbuffer = NULL;
- m_screenbuffer = NULL;
-#endif
-
- m_image.flags = 0;
-
- m_dllSwScale = new DllSwScale;
-}
-
-CLinuxRenderer::~CLinuxRenderer()
-{
- UnInit();
- delete m_dllSwScale;
-}
-
-//********************************************************************************************************
-void CLinuxRenderer::DeleteOSDTextures(int index)
-{
- CSingleLock lock(g_graphicsContext);
- if (m_pOSDYTexture[index])
- {
- SDL_FreeSurface(m_pOSDYTexture[index]);
- m_pOSDYTexture[index] = NULL;
- }
- if (m_pOSDATexture[index])
- {
- SDL_FreeSurface(m_pOSDATexture[index]);
- m_pOSDATexture[index] = NULL;
- CLog::Log(LOGDEBUG, "Deleted OSD textures (%i)", index);
- }
- m_iOSDTextureHeight[index] = 0;
-}
-
-//***********************************************************************************************************
-void CLinuxRenderer::CopyAlpha(int w, int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dst, unsigned char* dsta, int dststride)
-{
- for (int y = 0; y < h; ++y)
- {
- memcpy(dst, src, w);
- memcpy(dsta, srca, w);
- src += srcstride;
- srca += srcstride;
- dst += dststride;
- dsta += dststride;
- }
-}
-
-void CLinuxRenderer::DrawAlpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
-{
- // OSD is drawn after draw_slice / put_image
- // this means that the buffer has already been handed off to the RGB converter
- // solution: have separate OSD textures
-
- // if it's down the bottom, use sub alpha blending
- // m_SubsOnOSD = (y0 > (int)(m_sourceRect.bottom - m_sourceRect.top) * 4 / 5);
-
- //Sometimes happens when switching between fullscreen and small window
- if( w == 0 || h == 0 )
- {
- CLog::Log(LOGINFO, "Zero dimensions specified to DrawAlpha, skipping");
- return;
- }
-
- //use temporary rect for calculation to avoid messing with module-rect while other functions might be using it.
- DRAWRECT osdRect;
- RESOLUTION res = GetResolution();
-
- if (w > m_iOSDTextureWidth)
- {
- //delete osdtextures so they will be recreated with the correct width
- for (int i = 0; i < 2; ++i)
- {
- DeleteOSDTextures(i);
- }
- m_iOSDTextureWidth = w;
- }
- else
- {
- // clip to buffer
- if (w > m_iOSDTextureWidth) w = m_iOSDTextureWidth;
- if (h > g_settings.m_ResInfo[res].Overscan.bottom - g_settings.m_ResInfo[res].Overscan.top)
- {
- h = g_settings.m_ResInfo[res].Overscan.bottom - g_settings.m_ResInfo[res].Overscan.top;
- }
- }
-
- // scale to fit screen
- const CRect rv = g_graphicsContext.GetViewWindow();
-
- // Vobsubs are defined to be 720 wide.
- // NOTE: This will not work nicely if we are allowing mplayer to render text based subs
- // as it'll want to render within the pixel width it is outputting.
-
- float xscale;
- float yscale;
-
- if(true /*isvobsub*/) // xbox_video.cpp is fixed to 720x576 osd, so this should be fine
- { // vobsubs are given to us unscaled
- // scale them up to the full output, assuming vobsubs have same
- // pixel aspect ratio as the movie, and are 720 pixels wide
-
- float pixelaspect = m_fSourceFrameRatio * m_sourceHeight / m_sourceWidth;
- xscale = rv.Width() / 720.0f;
- yscale = xscale * g_settings.m_ResInfo[res].fPixelRatio / pixelaspect;
- }
- else
- { // text subs/osd assume square pixels, but will render to full size of view window
- // if mplayer could be fixed to use monitorpixelaspect when rendering it's osd
- // this would give perfect output, however monitorpixelaspect currently doesn't work
- // that way
- xscale = 1.0f;
- yscale = 1.0f;
- }
-
- // horizontal centering, and align to bottom of subtitles line
- osdRect.left = rv.x1 + (rv.Width() - (float)w * xscale) / 2.0f;
- osdRect.right = osdRect.left + (float)w * xscale;
- float relbottom = ((float)(g_settings.m_ResInfo[res].iSubtitles - g_settings.m_ResInfo[res].Overscan.top)) / (g_settings.m_ResInfo[res].Overscan.bottom - g_settings.m_ResInfo[res].Overscan.top);
- osdRect.bottom = rv.y1 + rv.Height() * relbottom;
- osdRect.top = osdRect.bottom - (float)h * yscale;
-
- int iOSDBuffer = (m_iOSDRenderBuffer + 1) % m_NumOSDBuffers;
-
- //if new height is heigher than current osd-texture height, recreate the textures with new height.
- if (h > m_iOSDTextureHeight[iOSDBuffer])
- {
- CSingleLock lock(g_graphicsContext);
-
- DeleteOSDTextures(iOSDBuffer);
- m_iOSDTextureHeight[iOSDBuffer] = h;
- // Create osd textures for this buffer with new size
- m_pOSDYTexture[iOSDBuffer] = SDL_CreateRGBSurface(SDL_HWSURFACE, m_iOSDTextureWidth, m_iOSDTextureHeight[iOSDBuffer],
- 32, RMASK, GMASK, BMASK, AMASK);
-
- m_pOSDATexture[iOSDBuffer] = SDL_CreateRGBSurface(SDL_HWSURFACE, m_iOSDTextureWidth, m_iOSDTextureHeight[iOSDBuffer],
- 32, RMASK, GMASK, BMASK, AMASK);
-
- if (m_pOSDYTexture[iOSDBuffer] == NULL || m_pOSDATexture[iOSDBuffer] == NULL)
- {
- CLog::Log(LOGERROR, "Could not create OSD/Sub textures");
- DeleteOSDTextures(iOSDBuffer);
- return;
- }
- else
- {
- CLog::Log(LOGDEBUG, "Created OSD textures (%i)", iOSDBuffer);
- }
- }
-
- //We know the resources have been used at this point (or they are the second buffer, wich means they aren't in use anyways)
- //reset these so the gpu doesn't try to block on these
- if (SDL_LockSurface(m_pOSDYTexture[iOSDBuffer]) == 0 &&
- SDL_LockSurface(m_pOSDATexture[iOSDBuffer]) == 0)
- {
- //clear the textures
- memset(m_pOSDYTexture[iOSDBuffer]->pixels, 0, m_pOSDYTexture[iOSDBuffer]->pitch*m_iOSDTextureHeight[iOSDBuffer]);
- memset(m_pOSDATexture[iOSDBuffer]->pixels, 0, m_pOSDATexture[iOSDBuffer]->pitch*m_iOSDTextureHeight[iOSDBuffer]);
-
- //draw the osd/subs
- CopyAlpha(w, h, src, srca, stride, (BYTE*)m_pOSDYTexture[iOSDBuffer]->pixels, (BYTE*)m_pOSDATexture[iOSDBuffer]->pixels, m_pOSDYTexture[iOSDBuffer]->pitch);
- }
- SDL_UnlockSurface(m_pOSDYTexture[iOSDBuffer]);
- SDL_UnlockSurface(m_pOSDATexture[iOSDBuffer]);
-
- //set module variables to calculated values
- m_OSDRect = osdRect;
- m_OSDWidth = (float)w;
- m_OSDHeight = (float)h;
- m_OSDRendered = true;
-}
-
-//********************************************************************************************************
-void CLinuxRenderer::RenderOSD()
-{
- int iRenderBuffer = m_iOSDRenderBuffer;
-
- if (!m_pOSDYTexture[iRenderBuffer] || !m_pOSDATexture[iRenderBuffer])
- return ;
- if (!m_OSDWidth || !m_OSDHeight)
- return ;
-
- CSingleLock lock(g_graphicsContext);
-
- //copy all static vars to local vars because they might change during this function by mplayer callbacks
- DRAWRECT osdRect = m_OSDRect;
-
- // Render the image
- SDL_Rect rect;
- rect.x = osdRect.left;
- rect.y = osdRect.top;
- rect.w = osdRect.right - osdRect.left;
- rect.h = osdRect.bottom - osdRect.top;
- g_graphicsContext.BlitToScreen(m_pOSDYTexture[iRenderBuffer],NULL,&rect);
-
-}
-
-void CLinuxRenderer::ManageTextures()
-{
- int neededbuffers = 0;
- //use 1 buffer in fullscreen mode and 2 buffers in windowed mode
- if (g_graphicsContext.IsFullScreenVideo())
- {
- if (m_NumOSDBuffers != 1)
- {
- m_iOSDRenderBuffer = 0;
- m_NumOSDBuffers = 1;
- m_OSDWidth = m_OSDHeight = 0;
- //delete second osd textures
- DeleteOSDTextures(1);
- }
- neededbuffers = 1;
- }
- else
- {
- if (m_NumOSDBuffers != 2)
- {
- m_NumOSDBuffers = 2;
- m_iOSDRenderBuffer = 0;
- m_OSDWidth = m_OSDHeight = 0;
- // buffers will be created on demand in DrawAlpha()
- }
- neededbuffers = 2;
- }
-
-}
-
-bool CLinuxRenderer::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags)
-{
- CLog::Log(LOGDEBUG,"CLinuxRenderer::Configure - w: %d, h: %d, dw: %d, dh: %d, fps: %4.2f", width, height, d_width, d_height, fps);
-
- m_sourceWidth = width;
- m_sourceHeight = height;
-
- // calculate the input frame aspect ratio
- CalculateFrameAspectRatio(d_width, d_height);
- ChooseBestResolution(fps);
- SetViewMode(g_settings.m_currentVideoSettings.m_ViewMode);
-
- ManageDisplay();
-
-#ifdef USE_SDL_OVERLAY
-
- m_screen = g_graphicsContext.getScreenSurface()->SDL();
-
- if (m_overlay && (m_overlay->w != width || m_overlay->h != height)) {
- SDL_FreeYUVOverlay(m_overlay);
- m_overlay = NULL;
- }
-
- if (m_overlay == NULL && m_screen != NULL) {
- m_overlay = SDL_CreateYUVOverlay(width, height, SDL_YV12_OVERLAY, m_screen);
- if (m_overlay == NULL) {
- CLog::Log(LOGERROR, "CLinuxRenderer::Configure - failed to create YUV overlay. w: %d, h: %d", width, height);
- return false;
- }
- }
-
- if (m_image.plane[0] == NULL) {
- m_image.stride[0] = m_overlay->pitches[0];
- m_image.stride[1] = m_overlay->pitches[1];
- m_image.stride[2] = m_overlay->pitches[2];
-
- m_image.plane[0] = m_overlay->pixels[0];
- m_image.plane[1] = m_overlay->pixels[1];
- m_image.plane[2] = m_overlay->pixels[2];
- }
-
-#else
- if (m_backbuffer && (m_backbuffer->w != (int)width || m_backbuffer->h != (int)height)) {
- SDL_FreeSurface(m_backbuffer);
- m_backbuffer=NULL;
-
- for (int p=0;p<MAX_PLANES;p++) {
- if (m_image.plane[p])
- delete [] m_image.plane[p];
- m_image.plane[p]=NULL;
- }
- }
-
- if (m_screenbuffer && (m_screenbuffer->w != (int)width || m_screenbuffer->h != (int)height)) {
- SDL_FreeSurface(m_screenbuffer);
- m_screenbuffer=NULL;
- }
-
- if (m_backbuffer == NULL)
- m_backbuffer = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 32, RMASK, GMASK, BMASK, AMASK);;
-
- if (m_screenbuffer == NULL)
- m_screenbuffer = SDL_CreateRGBSurface(SDL_HWSURFACE, width, height, 32, RMASK, GMASK, BMASK, AMASK);;
-
- if (m_image.plane[0] == NULL) {
- m_image.stride[0] = m_sourceWidth;
- m_image.stride[1] = m_sourceWidth>>1;
- m_image.stride[2] = m_sourceWidth>>1;
-
- m_image.plane[0] = new BYTE[m_image.stride[0] * height];
- if (m_image.plane[1])
- delete [] m_image.plane[1];
- m_image.plane[1] = new BYTE[m_image.stride[1] * height];
- if (m_image.plane[2])
- delete [] m_image.plane[2];
- m_image.plane[2] = new BYTE[m_image.stride[2] * height];
- }
-
-#endif
-
- m_image.width = width;
- m_image.height = height;
- m_image.cshift_x = 1;
- m_image.cshift_y = 1;
-
- CLog::Log(LOGDEBUG,"Allocated image. source w: %d, strides: %d,%d,%d", m_sourceWidth, m_image.stride[0], m_image.stride[1], m_image.stride[2]);
-
- return true;
-}
-
-int CLinuxRenderer::GetImage(YV12Image *image, int source, bool readonly)
-{
-
- if (!image) return -1;
-
- CSingleLock lock(g_graphicsContext);
-
- if (!m_image.plane[0]) {
- CLog::Log(LOGDEBUG, "CLinuxRenderer::GetImage - image planes not allocated");
- return -1;
- }
-
- if (m_image.flags != 0) {
- CLog::Log(LOGDEBUG, "CLinuxRenderer::GetImage - request image but none to give");
- return -1;
- }
-
- if( source != AUTOSOURCE ) {
- CLog::Log(LOGERROR,"CLinuxRenderer::GetImage - currently supporting only single image. no source selection");
- }
-
- m_image.flags = readonly?IMAGE_FLAG_READING:IMAGE_FLAG_WRITING;
-
-#ifdef USE_SDL_OVERLAY
- SDL_LockYUVOverlay(m_overlay);
-#endif
-
- // copy the image - should be operator of YV12Image
- for (int p=0;p<MAX_PLANES;p++) {
- image->plane[p]=m_image.plane[p];
- image->stride[p] = m_image.stride[p];
- }
- image->width = m_image.width;
- image->height = m_image.height;
- image->flags = m_image.flags;
- image->cshift_x = m_image.cshift_x;
- image->cshift_y = m_image.cshift_y;
-
- return 0;
-}
-
-void CLinuxRenderer::ReleaseImage(int source, bool preserve)
-{
- CSingleLock lock(g_graphicsContext);
- m_image.flags = 0;
-
-#ifdef USE_SDL_OVERLAY
- if (m_overlay)
- SDL_UnlockYUVOverlay(m_overlay);
-#else
-
- if (!m_backbuffer) {
- return;
- }
-
- // copy image to backbuffer
-
- SDL_LockSurface(m_backbuffer);
-
- // transform from YUV to RGB
- struct SwsContext *context = m_dllSwScale->sws_getContext(m_image.width, m_image.height, PIX_FMT_YUV420P, m_backbuffer->w, m_backbuffer->h, PIX_FMT_BGRA, SWS_BILINEAR, NULL, NULL, NULL);
- uint8_t *src[] = { m_image.plane[0], m_image.plane[1], m_image.plane[2], 0 };
- int srcStride[] = { m_image.stride[0], m_image.stride[1], m_image.stride[2], 0 };
- uint8_t *dst[] = { (uint8_t*)m_backbuffer->pixels, 0, 0, 0 };
- int dstStride[] = { m_backbuffer->pitch, 0, 0, 0 };
-
- m_dllSwScale->sws_scale(context, src, srcStride, 0, m_image.height, dst, dstStride);
-
- for (int n=0; n<720*90;n++) {
- *(((uint8_t*)m_backbuffer->pixels) + (720*10) + n) = 70;
- }
-
- m_dllSwScale->sws_freeContext(context);
-
- SDL_UnlockSurface(m_backbuffer);
-
- FlipPage(0);
-#endif
-
-
-}
-
-void CLinuxRenderer::Reset()
-{
-}
-
-void CLinuxRenderer::Update(bool bPauseDrawing)
-{
- if (!m_bConfigured) return;
- CSingleLock lock(g_graphicsContext);
- ManageDisplay();
- ManageTextures();
-}
-
-void CLinuxRenderer::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
-{
-
- CSingleLock lock(g_graphicsContext);
- ManageDisplay();
- ManageTextures();
-
-// TODO: prepare for render in RenderUpdate
-
- Render(flags);
-
-
-}
-
-void CLinuxRenderer::FlipPage(int source)
-{
-// TODO: if image buffer changed (due to DrawSlice) than re-copy its content (convert from YUV).
-
- // copy back buffer to screen buffer
-#ifndef USE_SDL_OVERLAY
- if (m_screenbuffer) {
- SDL_BlitSurface(m_backbuffer, NULL, m_screenbuffer, NULL);
- }
-#endif
-
- return;
-}
-
-
-unsigned int CLinuxRenderer::DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y)
-{
- BYTE *s;
- BYTE *d;
- int i, p;
-
- YV12Image &im = m_image;
- // copy Y
- p = 0;
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
-
- w >>= im.cshift_x; h >>= im.cshift_y;
- x >>= im.cshift_x; y >>= im.cshift_y;
-
- // copy U
- p = 1;
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
-
- // copy V
- p = 2;
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
-
- return 0;
-}
-
-unsigned int CLinuxRenderer::PreInit()
-{
- CSingleLock lock(g_graphicsContext);
- m_bConfigured = false;
- UnInit();
- m_resolution = PAL_4x3;
-
- m_iOSDRenderBuffer = 0;
- m_NumOSDBuffers = 0;
- m_OSDHeight = m_OSDWidth = 0;
- m_OSDRendered = false;
-
- m_iOSDTextureWidth = 0;
- m_iOSDTextureHeight[0] = 0;
- m_iOSDTextureHeight[1] = 0;
-
- // setup the background colour
- m_clearColour = (g_advancedSettings.m_videoBlackBarColour & 0xff) * 0x010101;
-
- if (!m_dllSwScale->Load())
- CLog::Log(LOGERROR,"CLinuxRendererGL::PreInit - failed to load rescale libraries!");
-
- return 0;
-}
-
-void CLinuxRenderer::UnInit()
-{
- CSingleLock lock(g_graphicsContext);
-
- for (int i=0; i< NUM_BUFFERS; i++) {
- DeleteOSDTextures(i);
- }
-
-#ifdef USE_SDL_OVERLAY
- if (m_overlay)
- SDL_FreeYUVOverlay(m_overlay);
-
-#else
- if (m_backbuffer) {
- SDL_FreeSurface(m_backbuffer);
- m_backbuffer=NULL;
- }
-
- if (m_screenbuffer) {
- SDL_FreeSurface(m_screenbuffer);
- m_screenbuffer=NULL;
- }
-#endif
-
- for (int p=0; p<MAX_PLANES;p++) {
- if (m_image.plane[p]) {
-#ifndef USE_SDL_OVERLAY
- delete [] m_image.plane[p];
-#endif
- m_image.plane[p] = NULL;
- m_image.stride[p]=0;
- }
- }
-
-}
-
-void CLinuxRenderer::Render(DWORD flags)
-{
- if( flags & RENDER_FLAG_NOOSD ) return;
-
- /* general stuff */
- RenderLowMem(flags);
- RenderOSD();
-}
-
-void CLinuxRenderer::RenderLowMem(DWORD flags)
-{
- CSingleLock lock(g_graphicsContext);
-
-#if defined (USE_SDL_OVERLAY)
-
- SDL_Rect rect;
- rect.x = (int)m_sourceRect.x1;
- rect.y = (int)m_sourceRect.y1;
- rect.w = (int)m_sourceRect.Width();
- rect.h = (int)m_sourceRect.Height();
-
- int nRet = SDL_DisplayYUVOverlay(m_overlay, &rect);
-#else
-
- SDL_Rect rect;
- rect.x = (int)m_sourceRect.x1;
- rect.y = (int)m_sourceRect.y1;
- rect.w = (int)m_sourceRect.Width();
- rect.h = (int)m_sourceRect.Height();
- g_graphicsContext.BlitToScreen(m_screenbuffer,NULL,&rect);
-
-#endif
-}
-
-void CLinuxRenderer::CreateThumbnail(CBaseTexture *texture, unsigned int width, unsigned int height)
-{
- CSingleLock lock(g_graphicsContext);
-#ifndef USE_SDL_OVERLAY
- // we use backbuffer for the thumbnail cause screen buffer isnt used when opengl is used.
- if (m_backbuffer && texture) {
- SDL_BlitSurface(m_backbuffer, NULL, texture->GetPixels(), NULL);
- }
-#endif
-}
-
-// called from GUI thread after playback has finished to release resources
-void CLinuxRenderer::OnClose()
-{
-}
-
-#endif // HAS_SDL_2D
diff --git a/xbmc/cores/VideoRenderers/LinuxRenderer.h b/xbmc/cores/VideoRenderers/LinuxRenderer.h
deleted file mode 100644
index f665bce41e..0000000000
--- a/xbmc/cores/VideoRenderers/LinuxRenderer.h
+++ /dev/null
@@ -1,198 +0,0 @@
-#ifndef LINUX_RENDERER
-#define LINUX_RENDERER
-
-/*
- * Copyright (C) 2007-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifdef HAS_SDL_2D
-
-#include <SDL/SDL.h>
-#include "GraphicContext.h"
-#ifdef _LINUX
-#include "PlatformDefs.h"
-#endif
-#include "BaseRenderer.h"
-
-#define MAX_PLANES 3
-#define MAX_FIELDS 3
-
-#define ALIGN(value, alignment) (((value)+((alignment)-1))&~((alignment)-1))
-#define CLAMP(a, min, max) ((a) > (max) ? (max) : ( (a) < (min) ? (min) : a ))
-
-typedef struct YV12Image
-{
- BYTE * plane[MAX_PLANES];
- unsigned stride[MAX_PLANES];
- unsigned width;
- unsigned height;
- unsigned flags;
-
- unsigned cshift_x; /* this is the chroma shift used */
- unsigned cshift_y;
-} YV12Image;
-
-#define AUTOSOURCE -1
-
-#define IMAGE_FLAG_WRITING 0x01 /* image is in use after a call to GetImage, caller may be reading or writing */
-#define IMAGE_FLAG_READING 0x02 /* image is in use after a call to GetImage, caller is only reading */
-#define IMAGE_FLAG_DYNAMIC 0x04 /* image was allocated due to a call to GetImage */
-#define IMAGE_FLAG_RESERVED 0x08 /* image is reserved, must be asked for specifically used to preserve images */
-
-#define IMAGE_FLAG_INUSE (IMAGE_FLAG_WRITING | IMAGE_FLAG_READING | IMAGE_FLAG_RESERVED)
-
-
-#define RENDER_FLAG_BOT 0x01
-#define RENDER_FLAG_TOP 0x02
-#define RENDER_FLAG_BOTH (RENDER_FLAG_BOT | RENDER_FLAG_TOP)
-#define RENDER_FLAG_FIELDMASK 0x03
-
-#define RENDER_FLAG_NOOSD 0x04 /* don't draw any osd */
-
-/* these two flags will be used if we need to render same image twice (bob deinterlacing) */
-#define RENDER_FLAG_NOLOCK 0x10 /* don't attempt to lock texture before rendering */
-#define RENDER_FLAG_NOUNLOCK 0x20 /* don't unlock texture after rendering */
-
-/* this defines what color translation coefficients */
-#define CONF_FLAGS_YUVCOEF_MASK(a) ((a) & 0x07)
-#define CONF_FLAGS_YUVCOEF_BT709 0x01
-#define CONF_FLAGS_YUVCOEF_BT601 0x02
-#define CONF_FLAGS_YUVCOEF_240M 0x03
-#define CONF_FLAGS_YUVCOEF_EBU 0x04
-
-#define CONF_FLAGS_YUV_FULLRANGE 0x08
-#define CONF_FLAGS_FULLSCREEN 0x10
-
-struct DRAWRECT
-{
- float left;
- float top;
- float right;
- float bottom;
-};
-
-enum EFIELDSYNC
-{
- FS_NONE,
- FS_TOP,
- FS_BOT,
- FS_BOTH,
-};
-
-struct YUVRANGE
-{
- int y_min, y_max;
- int u_min, u_max;
- int v_min, v_max;
-};
-
-struct YUVCOEF
-{
- float r_up, r_vp;
- float g_up, g_vp;
- float b_up, b_vp;
-};
-
-extern YUVRANGE yuv_range_lim;
-extern YUVRANGE yuv_range_full;
-extern YUVCOEF yuv_coef_bt601;
-extern YUVCOEF yuv_coef_bt709;
-extern YUVCOEF yuv_coef_ebu;
-extern YUVCOEF yuv_coef_smtp240m;
-
-class CLinuxRenderer : public CBaseRenderer
-{
-public:
- CLinuxRenderer();
- virtual ~CLinuxRenderer();
-
- virtual void Update(bool bPauseDrawing);
- virtual void SetupScreenshot() {};
-
- void CreateThumbnail(CBaseTexture *texture, unsigned int width, unsigned int height);
-
- // Player functions
- virtual bool Configure(unsigned int width,
- unsigned int height, unsigned int d_width, unsigned int d_height,
- float fps, unsigned flags);
- virtual bool IsConfigured() { return m_bConfigured; }
- virtual int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
- virtual void ReleaseImage(int source, bool preserve = false);
- virtual unsigned int DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y);
- virtual void DrawAlpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride);
- virtual void FlipPage(int source);
- virtual unsigned int PreInit();
- virtual void UnInit();
- virtual void Reset(); /* resets renderer after seek for example */
- virtual void OnClose(); // called from main GUI thread
-
- // Feature support
- virtual bool SupportsMultiPassRendering() { return false; }
-
- void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
-
-protected:
- virtual void Render(DWORD flags);
- void CopyAlpha(int w, int h, unsigned char* src, unsigned char *srca, int srcstride, unsigned char* dst, unsigned char* dsta, int dststride);
- virtual void ManageTextures();
- void DeleteOSDTextures(int index);
- void RenderOSD();
-
- // not really low memory. name is misleading... simply a renderer
- void RenderLowMem(DWORD flags);
-
- bool m_bConfigured;
-
- // OSD stuff
-#define NUM_BUFFERS 2
- SDL_Surface * m_pOSDYTexture[NUM_BUFFERS];
- SDL_Surface * m_pOSDATexture[NUM_BUFFERS];
-
- float m_OSDWidth;
- float m_OSDHeight;
- DRAWRECT m_OSDRect;
- int m_iOSDRenderBuffer;
- int m_iOSDTextureWidth;
- int m_iOSDTextureHeight[NUM_BUFFERS];
- int m_NumOSDBuffers;
- bool m_OSDRendered;
-
- // Raw data used by renderer - we now use single image - when released, it will be copied to
- // the back buffer. will not cut it for all cases.
- YV12Image m_image;
-
-// USE_SDL_OVERLAY - is temporary - just to get the framework going. temporary hack.
-#ifdef USE_SDL_OVERLAY
- SDL_Overlay *m_overlay;
- SDL_Surface *m_screen;
-#else
- SDL_Surface *m_backbuffer;
- SDL_Surface *m_screenbuffer;
-#endif
-
- // clear colour for "black" bars
- DWORD m_clearColour;
-
- DllSwScale *m_dllSwScale;
-};
-
-#endif
-
-#endif
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererATI.cpp b/xbmc/cores/VideoRenderers/LinuxRendererATI.cpp
deleted file mode 100644
index ce2e52ec9c..0000000000
--- a/xbmc/cores/VideoRenderers/LinuxRendererATI.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
-* XBMC Media Center
-* Linux OpenGL Renderer for ATI cards
-* Copyright (c) 2007 Frodo/jcmarshall/vulkanr/d4rk
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-#include "stdafx.h"
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
- #include "config.h"
-#endif
-#ifndef HAS_SDL_2D
-#include "LinuxRendererATI.h"
-#include "../../Application.h"
-#include "../../Util.h"
-#include "../../Settings.h"
-#include "../../XBVideoConfig.h"
-#include "../../../guilib/Surface.h"
-
-#ifdef HAS_SDL_OPENGL
-
-using namespace Surface;
-
-CLinuxRendererATI::CLinuxRendererATI(bool enableshaders):CLinuxRendererGL()
-{
- if (enableshaders)
- m_renderMethod = RENDER_GLSL;
- else
- m_renderMethod = RENDER_SW;
-}
-
-CLinuxRendererATI::~CLinuxRendererATI()
-{
-}
-
-bool CLinuxRendererATI::ValidateRenderTarget()
-{
- if (!m_pBuffer)
- {
- CLog::Log(LOGNOTICE, "GL: Selected ATI Mode");
- m_pBuffer = new CSurface(g_graphicsContext.getScreenSurface());
- }
- return true;
-}
-
-
-void CLinuxRendererATI::ReleaseImage(int source, bool preserve)
-{
- // Eventual FIXME
- if (source!=0)
- source=0;
-
- m_image[source].flags = 0;
-
- YV12Image &im = m_image[source];
-
- m_image[source].flags &= ~IMAGE_FLAG_INUSE;
- m_image[source].flags = 0;
-
- // if we don't have a shader, fallback to SW YUV2RGB for now
- if (m_renderMethod & RENDER_SW)
- {
-#ifdef HAS_DVD_SWSCALE
- struct SwsContext *context = m_dllSwScale.sws_getContext(im.width, im.height, PIX_FMT_YUV420P, im.width, im.height, PIX_FMT_BGRA, SWS_BILINEAR, NULL, NULL, NULL);
- uint8_t *src[] = { im.plane[0], im.plane[1], im.plane[2] };
- int srcStride[] = { im.stride[0], im.stride[1], im.stride[2] };
- uint8_t *dst[] = { m_rgbBuffer, 0, 0 };
- int dstStride[] = { m_iSourceWidth*4, 0, 0 };
- m_dllSwScale.sws_scale(context, src, srcStride, 0, im.height, dst, dstStride);
-
- m_dllSwScale.sws_freeContext(context);
-#endif
- }
-}
-
-
-void CLinuxRendererATI::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
-{
- static bool firsttime = true;
- const int source = 0;
- static int imaging = -1;
- static GLfloat brightness = 0.0f;
- static GLfloat contrast = 0.0f;
-
- brightness = ((GLfloat)g_settings.m_currentVideoSettings.m_Brightness - 50.0f)/100.0f;
- contrast = ((GLfloat)g_settings.m_currentVideoSettings.m_Contrast)/50.0f;
-
-
- ManageDisplay();
- ManageTextures();
-
- g_graphicsContext.BeginPaint();
-
- m_image[source].flags = 0;
-
- YV12Image &im = m_image[source];
- YUVFIELDS &fields = m_YUVTexture[source];
-
- m_image[source].flags &= ~IMAGE_FLAG_INUSE;
- m_image[source].flags = 0;
-
- glEnable(m_textureTarget);
-
- if (!glIsTexture(fields[0][0])) //(firsttime)
- {
- firsttime = false;
- if (m_renderMethod & RENDER_GLSL)
- LoadShaders();
- CreateYV12Texture(0, false);
- }
-
- VerifyGLState();
-
- if (m_renderMethod & RENDER_SW) {
- if (imaging==-1)
- {
- imaging = 0;
- if (glewIsSupported("GL_ARB_imaging"))
- {
- CLog::Log(LOGINFO, "GL: ARB Imaging extension supported");
- imaging = 1;
- }
- else {
- int maj=0, min=0;
- g_graphicsContext.getScreenSurface()->GetGLVersion(maj, min);
- if (maj>=2)
- {
- imaging = 1;
- } else if (min>=2) {
- imaging = 1;
- }
- }
- }
- if (imaging)
- {
- glPixelTransferf(GL_RED_SCALE, contrast);
- glPixelTransferf(GL_GREEN_SCALE, contrast);
- glPixelTransferf(GL_BLUE_SCALE, contrast);
- glPixelTransferf(GL_RED_BIAS, brightness);
- glPixelTransferf(GL_GREEN_BIAS, brightness);
- glPixelTransferf(GL_BLUE_BIAS, brightness);
- VerifyGLState();
- }
- }
-
- glBindTexture(m_textureTarget, fields[0][0]);
- VerifyGLState();
-#ifdef HAS_DVD_SWSCALE
- if (m_renderMethod & RENDER_SW)
- glTexSubImage2D(m_textureTarget, 0, 0, 0, im.width, im.height, GL_BGRA, GL_UNSIGNED_BYTE, m_rgbBuffer);
- else
-#endif
- glTexSubImage2D(m_textureTarget, 0, 0, 0, im.width, im.height, GL_LUMINANCE, GL_UNSIGNED_BYTE, im.plane[0]);
- VerifyGLState();
- if (m_renderMethod & RENDER_GLSL)
- {
- glBindTexture(m_textureTarget, fields[0][1]);
- VerifyGLState();
- glTexSubImage2D(m_textureTarget, 0, 0, 0, im.width/2, im.height/2, GL_LUMINANCE, GL_UNSIGNED_BYTE, im.plane[1]);
- VerifyGLState();
- glBindTexture(m_textureTarget, fields[0][2]);
- VerifyGLState();
- glTexSubImage2D(m_textureTarget, 0, 0, 0, im.width/2, im.height/2, GL_LUMINANCE, GL_UNSIGNED_BYTE, im.plane[2]);
- VerifyGLState();
- }
-
- if (imaging)
- {
- glPixelTransferf(GL_RED_SCALE, 1.0);
- glPixelTransferf(GL_GREEN_SCALE, 1.0);
- glPixelTransferf(GL_BLUE_SCALE, 1.0);
- glPixelTransferf(GL_RED_BIAS, 0.0);
- glPixelTransferf(GL_GREEN_BIAS, 0.0);
- glPixelTransferf(GL_BLUE_BIAS, 0.0);
- VerifyGLState();
- }
-
- if (clear)
- {
- glClearColor((int)m_clearColour&0xff000000,
- (int)m_clearColour&0x00ff0000,
- (int)m_clearColour&0x0000ff00,
- 0);
- glClear(GL_COLOR_BUFFER_BIT);
- glClearColor(0,0,0,0);
- if (alpha<255)
- {
-#ifdef __GNUC__
-// FIXME: Alpha blending currently disabled
-#endif
- //glDisable(GL_BLEND);
- } else {
- //glDisable(GL_BLEND);
- }
- }
- glDisable(GL_BLEND);
- Render(flags,source);
- VerifyGLState();
- glEnable(GL_BLEND);
- g_graphicsContext.EndPaint();
-}
-
-void CLinuxRendererATI::FlipPage(int source)
-{
- CLog::Log(LOGNOTICE, "Calling ATI FlipPage");
- m_iYV12RenderBuffer = source;
-
- if( !m_OSDRendered )
- m_OSDWidth = m_OSDHeight = 0;
-
- m_OSDRendered = false;
-
- return;
-}
-
-
-
-unsigned int CLinuxRendererATI::PreInit()
-{
- CSingleLock lock(g_graphicsContext);
- m_bConfigured = false;
- UnInit();
- m_iResolution = PAL_4x3;
-
- m_iOSDRenderBuffer = 0;
- m_iYV12RenderBuffer = 0;
- m_NumOSDBuffers = 0;
- m_NumYV12Buffers = 1;
- m_OSDHeight = m_OSDWidth = 0;
- m_OSDRendered = false;
-
- m_iOSDTextureWidth = 0;
- m_iOSDTextureHeight[0] = 0;
- m_iOSDTextureHeight[1] = 0;
-
- // setup the background colour
- m_clearColour = 0 ; //(g_advancedSettings.m_videoBlackBarColour & 0xff) * 0x010101;
-
- // make sure we have a valid context that supports rendering
- if (!ValidateRenderTarget())
- return false;
-
-#ifdef HAS_DVD_SWSCALE
- if (!m_dllSwScale.Load())
- CLog::Log(LOGERROR,"CLinuxRendererATI::PreInit - failed to load rescale libraries!");
-#endif
-
- return true;
-}
-
-void CLinuxRendererATI::UnInit()
-{
- CSingleLock lock(g_graphicsContext);
-
- // YV12 textures, subtitle and osd stuff
- for (int i = 0; i < NUM_BUFFERS; ++i)
- {
- DeleteYV12Texture(i);
- DeleteOSDTextures(i);
- }
-
- if (m_pBuffer)
- {
- delete m_pBuffer;
- m_pBuffer = 0;
- }
-
- if (m_rgbBuffer != NULL)
- {
- delete [] m_rgbBuffer;
- m_rgbBuffer = NULL;
- }
-
-}
-
-bool CLinuxRendererATI::CreateYV12Texture(int index, bool clear)
-{
- /* since we also want the field textures, pitch must be texture aligned */
- unsigned p;
-
- YV12Image &im = m_image[index];
- YUVFIELDS &fields = m_YUVTexture[index];
-
- if (clear)
- {
- DeleteYV12Texture(index);
-
- im.height = m_iSourceHeight;
- im.width = m_iSourceWidth;
-
- im.stride[0] = m_iSourceWidth;
- im.stride[1] = m_iSourceWidth/2;
- im.stride[2] = m_iSourceWidth/2;
- im.plane[0] = new BYTE[m_iSourceWidth * m_iSourceHeight];
- im.plane[1] = new BYTE[(m_iSourceWidth/2) * (m_iSourceHeight/2)];
- im.plane[2] = new BYTE[(m_iSourceWidth/2) * (m_iSourceHeight/2)];
-
- im.cshift_x = 1;
- im.cshift_y = 1;
- im.texcoord_x = 1.0;
- im.texcoord_y = 1.0;
- return true;
- }
-
- g_graphicsContext.BeginPaint(m_pBuffer);
-
- glEnable(m_textureTarget);
- for(int f = 0;f<MAX_FIELDS;f++)
- {
- for(p = 0;p<MAX_PLANES;p++)
- {
- if (!glIsTexture(fields[f][p]))
- {
- glGenTextures(1, &fields[f][p]);
- VerifyGLState();
- }
- }
- }
-
- // YUV
- p = 0;
- glBindTexture(m_textureTarget, fields[0][0]);
- if (m_renderMethod & RENDER_SW)
- {
- // require Power Of Two textures?
- if (m_renderMethod & RENDER_POT)
- {
- static unsigned long np2x = 0, np2y = 0;
- np2x = NP2(im.width);
- np2y = NP2(im.height);
- CLog::Log(LOGNOTICE, "GL: Creating power of two texture of size %ld x %ld", np2x, np2y);
- glTexImage2D(m_textureTarget, 0, GL_RGBA, np2x, np2y, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
- im.texcoord_x = ((float)im.width / (float)np2x);
- im.texcoord_y = ((float)im.height / (float)np2y);
- }
- else
- {
- glTexImage2D(m_textureTarget, 0, GL_RGBA, im.width, im.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
- }
- }
- else
- glTexImage2D(m_textureTarget, 0, GL_LUMINANCE, im.width, im.height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
-
- glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP);
- VerifyGLState();
-
- if (m_renderMethod & RENDER_GLSL)
- {
- glBindTexture(m_textureTarget, fields[0][1]);
- glTexImage2D(m_textureTarget, 0, GL_LUMINANCE, im.width/2, im.height/2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP);
- VerifyGLState();
-
- glBindTexture(m_textureTarget, fields[0][2]);
- glTexImage2D(m_textureTarget, 0, GL_LUMINANCE, im.width/2, im.height/2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP);
- VerifyGLState();
- }
-
- g_graphicsContext.EndPaint(m_pBuffer);
- return true;
-}
-
-#endif
-
-#endif
-
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererATI.h b/xbmc/cores/VideoRenderers/LinuxRendererATI.h
deleted file mode 100644
index af6a993a47..0000000000
--- a/xbmc/cores/VideoRenderers/LinuxRendererATI.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef LINUXRENDERERATI_RENDERER
-#define LINUXRENDERERATI_RENDERER
-
-/*
- * Copyright (C) 2007-2010 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "../../../guilib/Surface.h"
-#include "../ffmpeg/DllSwScale.h"
-#include "../ffmpeg/DllAvCodec.h"
-#include "../ffmpeg/DllAvUtil.h"
-#include "LinuxRendererGL.h"
-
-#ifdef HAS_SDL_OPENGL
-
-using namespace Surface;
-
-class CLinuxRendererATI:public CLinuxRendererGL
-{
-public:
- CLinuxRendererATI(bool enableshaders=false);
- virtual ~CLinuxRendererATI();
-
- // Player functions
- virtual void ReleaseImage(int source, bool preserve = false);
- virtual void FlipPage(int source);
- virtual unsigned int PreInit();
- virtual void UnInit();
-
- virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
-
-protected:
- virtual bool CreateYV12Texture(int index, bool clear=true);
- virtual bool ValidateRenderTarget();
-};
-
-#endif
-
-#endif
-
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
index 611c52512a..f487a6ae01 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
@@ -711,66 +711,6 @@ void CLinuxRendererGL::FlipPage(int source)
return;
}
-
-unsigned int CLinuxRendererGL::DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y)
-{
- BYTE *s;
- BYTE *d;
- int i, p;
-
- int index = NextYV12Texture();
- if( index < 0 )
- return -1;
-
- YV12Image &im = m_buffers[index].image;
- // copy Y
- p = 0;
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
-
- w >>= im.cshift_x; h >>= im.cshift_y;
- x >>= im.cshift_x; y >>= im.cshift_y;
-
- // copy U
- p = 1;
- //check for valid second plane, YUY2 and UYVY don't have one
- if(im.plane[p] && src[p])
- {
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
- }
-
- // copy V
- p = 2;
- //check for valid third plane, NV12, YUY2 and UYVY don't have one
- if(im.plane[p] && src[p])
- {
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
- }
-
- m_eventTexturesDone[index]->Set();
- return 0;
-}
-
unsigned int CLinuxRendererGL::PreInit()
{
CSingleLock lock(g_graphicsContext);
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.h b/xbmc/cores/VideoRenderers/LinuxRendererGL.h
index 01be38b5d8..1f0d296369 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGL.h
+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.h
@@ -136,7 +136,6 @@ public:
virtual bool IsConfigured() { return m_bConfigured; }
virtual int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
virtual void ReleaseImage(int source, bool preserve = false);
- virtual unsigned int DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y);
virtual void FlipPage(int source);
virtual unsigned int PreInit();
virtual void UnInit();
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
index fde8330917..5b88fc7248 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
+++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.cpp
@@ -470,62 +470,6 @@ void CLinuxRendererGLES::FlipPage(int source)
return;
}
-
-unsigned int CLinuxRendererGLES::DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y)
-{
- BYTE *s;
- BYTE *d;
- int i, p;
-
- int index = NextYV12Texture();
- if( index < 0 )
- return -1;
-
- YV12Image &im = m_buffers[index].image;
- // copy Y
- p = 0;
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
-
- w >>= im.cshift_x; h >>= im.cshift_y;
- x >>= im.cshift_x; y >>= im.cshift_y;
-
- // copy U
- p = 1;
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
-
- // copy V
- p = 2;
- // check for valid yv12, nv12 does not use the third plane.
- if(im.plane[p] && src[p])
- {
- d = (BYTE*)im.plane[p] + im.stride[p] * y + x;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += im.stride[p];
- }
- }
-
- m_eventTexturesDone[index]->Set();
- return 0;
-}
-
unsigned int CLinuxRendererGLES::PreInit()
{
CSingleLock lock(g_graphicsContext);
diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGLES.h b/xbmc/cores/VideoRenderers/LinuxRendererGLES.h
index 43ce8fdb7d..efd28fbb43 100644
--- a/xbmc/cores/VideoRenderers/LinuxRendererGLES.h
+++ b/xbmc/cores/VideoRenderers/LinuxRendererGLES.h
@@ -137,7 +137,6 @@ public:
virtual bool IsConfigured() { return m_bConfigured; }
virtual int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
virtual void ReleaseImage(int source, bool preserve = false);
- virtual unsigned int DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y);
virtual void FlipPage(int source);
virtual unsigned int PreInit();
virtual void UnInit();
diff --git a/xbmc/cores/VideoRenderers/Makefile.in b/xbmc/cores/VideoRenderers/Makefile.in
index 9eecdd0178..5bcaf6a8e4 100644
--- a/xbmc/cores/VideoRenderers/Makefile.in
+++ b/xbmc/cores/VideoRenderers/Makefile.in
@@ -1,5 +1,4 @@
SRCS=BaseRenderer.cpp \
- LinuxRenderer.cpp \
OverlayRenderer.cpp \
OverlayRendererUtil.cpp \
RenderCapture.cpp \
diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp
index 28750168ab..d47561236f 100644
--- a/xbmc/cores/VideoRenderers/RenderManager.cpp
+++ b/xbmc/cores/VideoRenderers/RenderManager.cpp
@@ -49,6 +49,8 @@
/* to use the same as player */
#include "../dvdplayer/DVDClock.h"
+#include "../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
+#include "../dvdplayer/DVDCodecs/DVDCodecUtils.h"
#define MAXPRESENTDELAY 0.500
@@ -684,3 +686,54 @@ void CXBMCRenderManager::UpdateResolution()
m_bReconfigured = false;
}
}
+
+
+int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic)
+{
+ CSharedLock lock(m_sharedSection);
+ if (!m_pRenderer)
+ return -1;
+
+ YV12Image image;
+ int index = m_pRenderer->GetImage(&image);
+
+ if(index < 0)
+ return index;
+
+ if(pic.format == DVDVideoPicture::FMT_YUV420P)
+ {
+ CDVDCodecUtils::CopyPicture(&image, &pic);
+ }
+ else if(pic.format == DVDVideoPicture::FMT_NV12)
+ {
+ CDVDCodecUtils::CopyNV12Picture(&image, &pic);
+ }
+ else if(pic.format == DVDVideoPicture::FMT_YUY2
+ || pic.format == DVDVideoPicture::FMT_UYVY)
+ {
+ CDVDCodecUtils::CopyYUV422PackedPicture(&image, &pic);
+ }
+#ifdef HAS_DX
+ else if(pic.format == DVDVideoPicture::FMT_DXVA)
+ m_pRenderer->AddProcessor(pic.proc, pic.proc_id);
+#endif
+#ifdef HAVE_LIBVDPAU
+ else if(pic.format == DVDVideoPicture::FMT_VDPAU)
+ m_pRenderer->AddProcessor(pic.vdpau);
+#endif
+#ifdef HAVE_LIBOPENMAX
+ else if(pic.format == DVDVideoPicture::FMT_OMXEGL)
+ m_pRenderer->AddProcessor(pic.openMax, &pic);
+#endif
+#ifdef HAVE_VIDEOTOOLBOXDECODER
+ else if(pic.format == DVDVideoPicture::FMT_CVBREF)
+ m_pRenderer->AddProcessor(pic.vtb, &pic);
+#endif
+#ifdef HAVE_LIBVA
+ else if(pic.format == DVDVideoPicture::FMT_VAAPI)
+ m_pRenderer->AddProcessor(*pic.vaapi);
+#endif
+ m_pRenderer->ReleaseImage(index, false);
+
+ return index;
+}
diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h
index 27cb7d9477..e7e8d0ade4 100644
--- a/xbmc/cores/VideoRenderers/RenderManager.h
+++ b/xbmc/cores/VideoRenderers/RenderManager.h
@@ -43,6 +43,7 @@ class CRenderCapture;
namespace DXVA { class CProcessor; }
namespace VAAPI { class CSurfaceHolder; }
class CVDPAU;
+struct DVDVideoPicture;
#define ERRORBUFFSIZE 30
@@ -70,78 +71,12 @@ public:
bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags);
bool IsConfigured();
- // a call to GetImage must be followed by a call to releaseimage if getimage was successfull
- // failure to do so will result in deadlock
- inline int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- return m_pRenderer->GetImage(image, source, readonly);
- return -1;
- }
- inline void ReleaseImage(int source = AUTOSOURCE, bool preserve = false)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->ReleaseImage(source, preserve);
- }
- inline unsigned int DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- return m_pRenderer->DrawSlice(src, stride, w, h, x, y);
- return 0;
- }
+ int AddVideoPicture(DVDVideoPicture& picture);
void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
unsigned int PreInit();
void UnInit();
-#ifdef HAS_DX
- void AddProcessor(DXVA::CProcessor* processor, int64_t id)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->AddProcessor(processor, id);
- }
-#endif
-
-#ifdef HAVE_LIBVDPAU
- void AddProcessor(CVDPAU* vdpau)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->AddProcessor(vdpau);
- }
-#endif
-
-#ifdef HAVE_LIBOPENMAX
- void AddProcessor(COpenMax *openmax, DVDVideoPicture *picture)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->AddProcessor(openmax, picture);
- }
-#endif
-
-#ifdef HAVE_LIBVA
- void AddProcessor(VAAPI::CHolder& holder)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->AddProcessor(holder);
- }
-#endif
-
-#ifdef HAVE_VIDEOTOOLBOXDECODER
- void AddProcessor(CDVDVideoCodecVideoToolBox* vtb, DVDVideoPicture *picture)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->AddProcessor(vtb, picture);
- }
-#endif
-
void AddOverlay(CDVDOverlay* o, double pts)
{
CSharedLock lock(m_sharedSection);
diff --git a/xbmc/cores/VideoRenderers/WinRenderManager.cpp b/xbmc/cores/VideoRenderers/WinRenderManager.cpp
deleted file mode 100644
index e5bc87ee3a..0000000000
--- a/xbmc/cores/VideoRenderers/WinRenderManager.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "stdafx.h"
-#include "WinRenderManager.h"
-
-
-CWinRenderManager g_renderManager;
-
-
-#define MAXPRESENTDELAY 500
-
-/* at any point we want an exclusive lock on rendermanager */
-/* we must make sure we don't have a graphiccontext lock */
-
-CWinRenderManager::CWinRenderManager()
-{
- m_pRenderer = NULL;
- m_bPauseDrawing = false;
- m_bIsStarted = false;
-}
-
-CWinRenderManager::~CWinRenderManager()
-{
- DWORD locks = ExitCriticalSection(g_graphicsContext);
- CExclusiveLock lock(m_sharedSection);
- RestoreCriticalSection(g_graphicsContext, locks);
-
- delete m_pRenderer;
- m_pRenderer = NULL;
-}
-
-bool CWinRenderManager::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags)
-{
- DWORD locks = ExitCriticalSection(g_graphicsContext);
- CExclusiveLock lock(m_sharedSection);
-
- if(!m_pRenderer)
- {
- RestoreCriticalSection(g_graphicsContext, locks);
- return false;
- }
-
- bool result = m_pRenderer->Configure(width, height, d_width, d_height, fps, flags);
- if(result)
- {
- if( flags & CONF_FLAGS_FULLSCREEN )
- {
- lock.Leave();
- g_applicationMessenger.SwitchToFullscreen();
- lock.Enter();
- }
- m_pRenderer->Update(false);
- m_bIsStarted = true;
- }
-
- RestoreCriticalSection(g_graphicsContext, locks);
- return result;
-}
-
-void CWinRenderManager::Update(bool bPauseDrawing)
-{
- DWORD locks = ExitCriticalSection(g_graphicsContext);
- CExclusiveLock lock(m_sharedSection);
- RestoreCriticalSection(g_graphicsContext, locks);
-
- m_bPauseDrawing = bPauseDrawing;
- if (m_pRenderer)
- m_pRenderer->Update(bPauseDrawing);
-}
-
-void CWinRenderManager::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
-{
- DWORD locks = ExitCriticalSection(g_graphicsContext);
- CSharedLock lock(m_sharedSection);
- RestoreCriticalSection(g_graphicsContext, locks);
-
- if (m_pRenderer)
- m_pRenderer->RenderUpdate(clear, flags, alpha);
-}
-
-unsigned int CWinRenderManager::PreInit()
-{
- DWORD locks = ExitCriticalSection(g_graphicsContext);
- CExclusiveLock lock(m_sharedSection);
- RestoreCriticalSection(g_graphicsContext, locks);
-
- m_bIsStarted = false;
- m_bPauseDrawing = false;
-
- if (!m_pRenderer)
- { // no renderer
- CLog::Log(LOGDEBUG, __FUNCTION__" - Selected Win RGB-Renderer ");
- m_pRenderer = new CPixelShaderRenderer(g_graphicsContext.Get3DDevice());
- }
- return m_pRenderer->PreInit();
-}
-
-void CWinRenderManager::UnInit()
-{
- DWORD locks = ExitCriticalSection(g_graphicsContext);
- CExclusiveLock lock(m_sharedSection);
- RestoreCriticalSection(g_graphicsContext, locks);
-
- m_bIsStarted = false;
- if (m_pRenderer)
- {
- m_pRenderer->UnInit();
- delete m_pRenderer;
- m_pRenderer = NULL;
- }
-}
-
-void CWinRenderManager::SetupScreenshot()
-{
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->SetupScreenshot();
-}
-
-void CWinRenderManager::CreateThumbnail(SurfacePtr surface, unsigned int width, unsigned int height)
-{
- DWORD locks = ExitCriticalSection(g_graphicsContext);
- CExclusiveLock lock(m_sharedSection);
- RestoreCriticalSection(g_graphicsContext, locks);
-
- if (m_pRenderer)
- m_pRenderer->CreateThumbnail(surface, width, height);
-}
-
-void CWinRenderManager::FlipPage(DWORD delay /* = 0LL*/, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/)
-{
- DWORD timestamp = 0;
-
- if(delay > MAXPRESENTDELAY) delay = MAXPRESENTDELAY;
- if(delay > 0)
- timestamp = GetTickCount() + delay;
-
- while( timestamp > GetTickCount() )
- Sleep(1);
-
- CSharedLock lock(m_sharedSection);
-
- if(!m_pRenderer)
- return;
-
- m_pRenderer->FlipPage(source);
-}
diff --git a/xbmc/cores/VideoRenderers/WinRenderManager.h b/xbmc/cores/VideoRenderers/WinRenderManager.h
deleted file mode 100644
index cb32536ca5..0000000000
--- a/xbmc/cores/VideoRenderers/WinRenderManager.h
+++ /dev/null
@@ -1,110 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifndef _LINUX
-
-#include "WinRenderer.h"
-#include "utils/SharedSection.h"
-
-class CWinRenderManager
-{
-public:
- CWinRenderManager();
- ~CWinRenderManager();
-
- // Functions called from the GUI
- void GetVideoRect(RECT &rs, RECT &rd) { CSharedLock lock(m_sharedSection); if (m_pRenderer) m_pRenderer->GetVideoRect(rs, rd); };
- float GetAspectRatio() { CSharedLock lock(m_sharedSection); if (m_pRenderer) return m_pRenderer->GetAspectRatio(); else return 1.0f; };
- void Update(bool bPauseDrawing);
- void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
- void SetupScreenshot();
- void CreateThumbnail(XBMC::SurfacePtr surface, unsigned int width, unsigned int height);
- void SetViewMode(int iViewMode) { CSharedLock lock(m_sharedSection); if (m_pRenderer) m_pRenderer->SetViewMode(iViewMode); };
-
- // Functions called from mplayer
- bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags);
-
- // a call to GetImage must be followed by a call to releaseimage if getimage was successfull
- // failure to do so will result in deadlock
- inline int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- return m_pRenderer->GetImage(image, source, readonly);
- return -1;
- }
- inline void ReleaseImage(int source = AUTOSOURCE, bool preserve = false)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->ReleaseImage(source, preserve);
- }
- inline unsigned int DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- return m_pRenderer->DrawSlice(src, stride, w, h, x, y);
- return 0;
- }
-
- void FlipPage(DWORD timestamp = 0L, int source = -1, EFIELDSYNC sync = FS_NONE);
- unsigned int PreInit();
- void UnInit();
-
- inline void DrawAlpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->DrawAlpha(x0, y0, w, h, src, srca, stride);
- }
- inline void Reset()
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- m_pRenderer->Reset();
- }
- inline RESOLUTION GetResolution()
- {
- CSharedLock lock(m_sharedSection);
- if (m_pRenderer)
- return m_pRenderer->GetResolution();
- else
- return INVALID;
- }
- float GetMaximumFPS() { return 60.0; };
- inline DWORD GetPresentDelay() { return 0; }
- inline bool Paused() { return m_bPauseDrawing; };
- inline bool IsStarted() { return m_bIsStarted;}
-
- CWinRenderer *m_pRenderer;
-protected:
- bool m_bPauseDrawing; // true if we should pause rendering
- bool m_bIsStarted;
- CSharedSection m_sharedSection;
-};
-
-extern CWinRenderManager g_renderManager;
-
-#else
-#include "RenderManager.h"
-#endif
diff --git a/xbmc/cores/VideoRenderers/WinRenderer.cpp b/xbmc/cores/VideoRenderers/WinRenderer.cpp
index 94e9b8dfb6..14f15f8b9d 100644
--- a/xbmc/cores/VideoRenderers/WinRenderer.cpp
+++ b/xbmc/cores/VideoRenderers/WinRenderer.cpp
@@ -332,78 +332,6 @@ void CWinRenderer::FlipPage(int source)
return;
}
-
-unsigned int CWinRenderer::DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y)
-{
- /*
- BYTE *s;
- BYTE *d;
- int i, p;
-
- int index = NextYV12Texture();
- if( index < 0 )
- return -1;
-
- D3DLOCKED_RECT rect;
- RECT target;
-
- target.left = x;
- target.right = x+w;
- target.top = y;
- target.bottom = y+h;
-
- YUVPLANES &planes = m_YUVTexture[index];
-
- // copy Y
- p = 0;
- planes[p]->LockRect(0, &rect, &target, D3DLOCK_DISCARD);
- d = (BYTE*)rect.pBits;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += rect.Pitch;
- }
- planes[p]->UnlockRect(0);
-
- w >>= 1; h >>= 1;
- x >>= 1; y >>= 1;
- target.top>>=1;
- target.bottom>>=1;
- target.left>>=1;
- target.right>>=1;
-
- // copy U
- p = 1;
- planes[p]->LockRect(0, &rect, &target, D3DLOCK_DISCARD);
- d = (BYTE*)rect.pBits;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += rect.Pitch;
- }
- planes[p]->UnlockRect(0);
-
- // copy V
- p = 2;
- planes[p]->LockRect(0, &rect, &target, D3DLOCK_DISCARD);
- d = (BYTE*)rect.pBits;
- s = src[p];
- for (i = 0;i < h;i++)
- {
- memcpy(d, s, w);
- s += stride[p];
- d += rect.Pitch;
- }
- planes[p]->UnlockRect(0);
- */
-
- return 0;
-}
-
unsigned int CWinRenderer::PreInit()
{
CSingleLock lock(g_graphicsContext);
diff --git a/xbmc/cores/VideoRenderers/WinRenderer.h b/xbmc/cores/VideoRenderers/WinRenderer.h
index cccde7d3d5..02715718e6 100644
--- a/xbmc/cores/VideoRenderers/WinRenderer.h
+++ b/xbmc/cores/VideoRenderers/WinRenderer.h
@@ -196,7 +196,6 @@ public:
virtual bool Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags);
virtual int GetImage(YV12Image *image, int source = AUTOSOURCE, bool readonly = false);
virtual void ReleaseImage(int source, bool preserve = false);
- virtual unsigned int DrawSlice(unsigned char *src[], int stride[], int w, int h, int x, int y);
virtual void AddProcessor(DXVA::CProcessor* processor, int64_t id);
virtual void FlipPage(int source);
virtual unsigned int PreInit();
diff --git a/xbmc/cores/dvdplayer/DVDOverlayRenderer.h b/xbmc/cores/dvdplayer/DVDOverlayRenderer.h
index 10aadfeb86..64d25f3da4 100644
--- a/xbmc/cores/dvdplayer/DVDOverlayRenderer.h
+++ b/xbmc/cores/dvdplayer/DVDOverlayRenderer.h
@@ -72,6 +72,9 @@ public:
static void Render(DVDVideoPicture* pPicture, CDVDOverlay* pOverlay, double pts)
{
+ if(pPicture->format != DVDVideoPicture::FMT_YUV420P)
+ return;
+
DVDPictureRenderer p;
p.data[0] = pPicture->data[0];
diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
index ae76b513e4..45060e7f96 100644
--- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
@@ -815,7 +815,7 @@ void CDVDPlayerVideo::Flush()
}
#ifdef HAS_VIDEO_PLAYBACK
-void CDVDPlayerVideo::ProcessOverlays(DVDVideoPicture* pSource, YV12Image* pDest, double pts)
+void CDVDPlayerVideo::ProcessOverlays(DVDVideoPicture* pSource, double pts)
{
// remove any overlays that are out of time
m_pOverlayContainer->CleanUp(pts - m_iSubtitleDelay);
@@ -823,33 +823,22 @@ void CDVDPlayerVideo::ProcessOverlays(DVDVideoPicture* pSource, YV12Image* pDest
enum EOverlay
{ OVERLAY_AUTO // select mode auto
, OVERLAY_GPU // render osd using gpu
- , OVERLAY_VID // render osd directly on video memory
, OVERLAY_BUF // render osd on buffer
} render = OVERLAY_AUTO;
- if(render == OVERLAY_AUTO)
+ if(pSource->format == DVDVideoPicture::FMT_YUV420P)
{
- render = OVERLAY_GPU;
-
#ifdef _LINUX
// for now use cpu for ssa overlays as it currently allocates and
// frees textures for each frame this causes a hugh memory leak
// on some mesa intel drivers
- if(m_pOverlayContainer->ContainsOverlayType(DVDOVERLAY_TYPE_SSA) && pSource->format == DVDVideoPicture::FMT_YUV420P)
- render = OVERLAY_VID;
-#endif
- if(render == OVERLAY_VID)
- {
- if( m_pOverlayContainer->ContainsOverlayType(DVDOVERLAY_TYPE_SPU)
- || m_pOverlayContainer->ContainsOverlayType(DVDOVERLAY_TYPE_IMAGE)
- || m_pOverlayContainer->ContainsOverlayType(DVDOVERLAY_TYPE_SSA) )
- render = OVERLAY_BUF;
- }
- }
+ if(m_pOverlayContainer->ContainsOverlayType(DVDOVERLAY_TYPE_SPU)
+ || m_pOverlayContainer->ContainsOverlayType(DVDOVERLAY_TYPE_IMAGE)
+ || m_pOverlayContainer->ContainsOverlayType(DVDOVERLAY_TYPE_SSA) )
+ render = OVERLAY_BUF;
+#endif
- if(pSource->format == DVDVideoPicture::FMT_YUV420P)
- {
if(render == OVERLAY_BUF)
{
// rendering spu overlay types directly on video memory costs a lot of processing power.
@@ -870,14 +859,14 @@ void CDVDPlayerVideo::ProcessOverlays(DVDVideoPicture* pSource, YV12Image* pDest
return;
CDVDCodecUtils::CopyPicture(m_pTempOverlayPicture, pSource);
- }
- else
- {
- AutoCrop(pSource);
- CDVDCodecUtils::CopyPicture(pDest, pSource);
+ memcpy(pSource->data , m_pTempOverlayPicture->data , sizeof(pSource->data));
+ memcpy(pSource->iLineSize, m_pTempOverlayPicture->iLineSize, sizeof(pSource->iLineSize));
}
}
+ if(render == OVERLAY_AUTO)
+ render = OVERLAY_GPU;
+
{
CSingleLock lock(*m_pOverlayContainer);
@@ -902,57 +891,12 @@ void CDVDPlayerVideo::ProcessOverlays(DVDVideoPicture* pSource, YV12Image* pDest
if (render == OVERLAY_GPU)
g_renderManager.AddOverlay(pOverlay, pts2);
- if(pSource->format == DVDVideoPicture::FMT_YUV420P)
- {
- if (render == OVERLAY_BUF)
- CDVDOverlayRenderer::Render(m_pTempOverlayPicture, pOverlay, pts2);
- else if(render == OVERLAY_VID)
- CDVDOverlayRenderer::Render(pDest, pOverlay, pts2);
- }
-
+ if (render == OVERLAY_BUF)
+ CDVDOverlayRenderer::Render(pSource, pOverlay, pts2);
}
}
}
-
- if(pSource->format == DVDVideoPicture::FMT_YUV420P)
- {
- if(render == OVERLAY_BUF)
- {
- AutoCrop(m_pTempOverlayPicture);
- CDVDCodecUtils::CopyPicture(pDest, m_pTempOverlayPicture);
- }
- }
- else if(pSource->format == DVDVideoPicture::FMT_NV12)
- {
- AutoCrop(pSource);
- CDVDCodecUtils::CopyNV12Picture(pDest, pSource);
- }
- else if(pSource->format == DVDVideoPicture::FMT_YUY2 || pSource->format == DVDVideoPicture::FMT_UYVY)
- {
- AutoCrop(pSource);
- CDVDCodecUtils::CopyYUV422PackedPicture(pDest, pSource);
- }
-#ifdef HAS_DX
- else if(pSource->format == DVDVideoPicture::FMT_DXVA)
- g_renderManager.AddProcessor(pSource->proc, pSource->proc_id);
-#endif
-#ifdef HAVE_LIBVDPAU
- else if(pSource->format == DVDVideoPicture::FMT_VDPAU)
- g_renderManager.AddProcessor(pSource->vdpau);
-#endif
-#ifdef HAVE_LIBOPENMAX
- else if(pSource->format == DVDVideoPicture::FMT_OMXEGL)
- g_renderManager.AddProcessor(pSource->openMax, pSource);
-#endif
-#ifdef HAVE_VIDEOTOOLBOXDECODER
- else if(pSource->format == DVDVideoPicture::FMT_CVBREF)
- g_renderManager.AddProcessor(pSource->vtb, pSource);
-#endif
-#ifdef HAVE_LIBVA
- else if(pSource->format == DVDVideoPicture::FMT_VAAPI)
- g_renderManager.AddProcessor(*pSource->vaapi);
-#endif
}
#endif
@@ -1221,27 +1165,22 @@ int CDVDPlayerVideo::OutputPicture(DVDVideoPicture* pPicture, double pts)
mDisplayField = FS_BOT;
}
- // copy picture to overlay
- YV12Image image;
+ ProcessOverlays(pPicture, pts);
+ AutoCrop(pPicture);
- int index = g_renderManager.GetImage(&image);
+ int index = g_renderManager.AddVideoPicture(*pPicture);
// video device might not be done yet
while (index < 0 && !CThread::m_bStop &&
CDVDClock::GetAbsoluteClock(false) < iCurrentClock + iSleepTime + DVD_MSEC_TO_TIME(500) )
{
Sleep(1);
- index = g_renderManager.GetImage(&image);
+ index = g_renderManager.AddVideoPicture(*pPicture);
}
if (index < 0)
return EOS_DROPPED;
- ProcessOverlays(pPicture, &image, pts);
-
- // tell the renderer that we've finished with the image (so it can do any
- // post processing before FlipPage() is called.)
- g_renderManager.ReleaseImage(index);
g_renderManager.FlipPage(CThread::m_bStop, (iCurrentClock + iSleepTime) / DVD_TIME_BASE, -1, mDisplayField);
return result;
diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.h b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
index 851a69e93d..33e0434508 100644
--- a/xbmc/cores/dvdplayer/DVDPlayerVideo.h
+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
@@ -118,7 +118,7 @@ protected:
int OutputPicture(DVDVideoPicture* pPicture, double pts);
#ifdef HAS_VIDEO_PLAYBACK
- void ProcessOverlays(DVDVideoPicture* pSource, YV12Image* pDest, double pts);
+ void ProcessOverlays(DVDVideoPicture* pSource, double pts);
#endif
void ProcessVideoUserData(DVDVideoUserData* pVideoUserData, double pts);