Permalink
Browse files

Merge pull request #1529 from popcornmix/master

[rbp] Support the split gui/display resolution.
  • Loading branch information...
2 parents f9c7e41 + 23888b9 commit 57529e81ba7cec5c722cef3479de8847d042f8a6 @huceke huceke committed Oct 3, 2012
@@ -30,6 +30,8 @@
#include "linux/XMemUtils.h"
#include "DVDDemuxers/DVDDemuxUtils.h"
#include "settings/AdvancedSettings.h"
+#include "xbmc/guilib/GraphicContext.h"
+#include "settings/Settings.h"
#include <sys/time.h>
#include <inttypes.h>
@@ -875,8 +877,12 @@ void COMXVideo::SetVideoRect(const CRect& SrcRect, const CRect& DestRect)
OMX_CONFIG_DISPLAYREGIONTYPE configDisplay;
OMX_INIT_STRUCTURE(configDisplay);
configDisplay.nPortIndex = m_omx_render.GetInputPort();
+ RESOLUTION res = g_graphicsContext.GetVideoResolution();
+ // DestRect is in GUI coordinates, rather than display coordinates, so we have to scale
+ float xscale = (float)g_settings.m_ResInfo[res].iScreenWidth / (float)g_settings.m_ResInfo[res].iWidth;
+ float yscale = (float)g_settings.m_ResInfo[res].iScreenHeight / (float)g_settings.m_ResInfo[res].iHeight;
float sx1 = SrcRect.x1, sy1 = SrcRect.y1, sx2 = SrcRect.x2, sy2 = SrcRect.y2;
- float dx1 = DestRect.x1, dy1 = DestRect.y1, dx2 = DestRect.x2, dy2 = DestRect.y2;
+ float dx1 = DestRect.x1*xscale, dy1 = DestRect.y1*yscale, dx2 = DestRect.x2*xscale, dy2 = DestRect.y2*yscale;
float sw = SrcRect.Width() / DestRect.Width();
float sh = SrcRect.Height() / DestRect.Height();
View
@@ -224,8 +224,13 @@ bool CBaseTexture::LoadFromFileInternal(const CStdString& texturePath, unsigned
if(omx_image.ReadFile(texturePath))
{
- // TODO: we only decode as half width and height. this is a workaround for the PI memory limitation
- if(omx_image.Decode(omx_image.GetWidth() / 2, omx_image.GetHeight() / 2))
+ int width = omx_image.GetWidth();
+ int height = omx_image.GetHeight();
+
+ // We restict textures to the maximum GUI size. This is a workaround for the PI memory limitation
+ g_Windowing.ClampToGUIDisplayLimits(width, height);
+
+ if(omx_image.Decode(width, height))
{
Allocate(omx_image.GetDecodedWidth(), omx_image.GetDecodedHeight(), XB_FMT_A8R8G8B8);
@@ -100,7 +100,7 @@ bool CWinEGLPlatformRaspberryPI::SetDisplayResolution(RESOLUTION_INFO& res)
for (size_t i = 0; i < m_res.size(); i++)
{
- if(m_res[i].iWidth == res.iWidth && m_res[i].iHeight == res.iHeight && m_res[i].fRefreshRate == res.fRefreshRate)
+ if(m_res[i].iScreenWidth == res.iScreenWidth && m_res[i].iScreenHeight == res.iScreenHeight && m_res[i].fRefreshRate == res.fRefreshRate)
{
int score = 0;
@@ -152,8 +152,8 @@ bool CWinEGLPlatformRaspberryPI::SetDisplayResolution(RESOLUTION_INFO& res)
dst_rect.x = 0;
dst_rect.y = 0;
- dst_rect.width = res.iWidth;
- dst_rect.height = res.iHeight;
+ dst_rect.width = res.iScreenWidth;
+ dst_rect.height = res.iScreenHeight;
src_rect.x = 0;
src_rect.y = 0;
@@ -178,8 +178,8 @@ bool CWinEGLPlatformRaspberryPI::SetDisplayResolution(RESOLUTION_INFO& res)
if(bFound && (resSearch.dwFlags & D3DPRESENTFLAG_MODE3DSBS))
{
// right side
- dst_rect.x = res.iWidth;
- dst_rect.width >>= dst_rect.width - dst_rect.x;
+ dst_rect.x = res.iScreenWidth;
+ dst_rect.width = res.iScreenWidth;
m_dispman_element2 = m_DllBcmHost.vc_dispmanx_element_add(dispman_update,
m_dispman_display,
@@ -196,7 +196,7 @@ bool CWinEGLPlatformRaspberryPI::SetDisplayResolution(RESOLUTION_INFO& res)
// left side - fall through
dst_rect.x = 0;
- dst_rect.width = res.iWidth - dst_rect.x;
+ dst_rect.width = res.iScreenWidth;
}
m_dispman_element = m_DllBcmHost.vc_dispmanx_element_add(dispman_update,
@@ -227,7 +227,23 @@ bool CWinEGLPlatformRaspberryPI::SetDisplayResolution(RESOLUTION_INFO& res)
bool CWinEGLPlatformRaspberryPI::ClampToGUIDisplayLimits(int &width, int &height)
{
- return true;
+ const int max_width = 1280, max_height = 720;
+ float ar = (float)width/(float)height;
+ // bigger than maximum, so need to clamp
+ if (width > max_width || height > max_height) {
+ // wider than max, so clamp width first
+ if (ar > (float)max_width/(float)max_height)
+ {
+ width = max_width;
+ height = (float)max_width / ar + 0.5f;
+ // taller than max, so clamp height first
+ } else {
+ height = max_height;
+ width = (float)max_height * ar + 0.5f;
+ }
+ return true;
+ }
+ return false;
}
bool CWinEGLPlatformRaspberryPI::ProbeDisplayResolutions(std::vector<RESOLUTION_INFO> &resolutions)
@@ -317,4 +317,10 @@ bool CWinSystemGLES::Support3D(int width, int height, uint32_t mode) const
return bFound;
}
+bool CWinSystemGLES::ClampToGUIDisplayLimits(int &width, int &height)
+{
+ return m_eglplatform->ClampToGUIDisplayLimits(width, height);
+}
+
+
#endif
@@ -56,6 +56,7 @@ class CWinSystemGLES : public CWinSystemBase, public CRenderSystemGLES
EGLDisplay GetEGLDisplay();
EGLContext GetEGLContext();
virtual bool Support3D(int width, int height, uint32_t mode) const;
+ virtual bool ClampToGUIDisplayLimits(int &width, int &height);
protected:
virtual bool PresentRenderImpl(const CDirtyRegionList &dirty);

0 comments on commit 57529e8

Please sign in to comment.