Permalink
Browse files

[rbp] Support the split gui/display resolution. Gui is limited to 720…

…p. Display can be 1080p. Remove temporary hack of downsizing the textures.
  • Loading branch information...
1 parent 6274eb5 commit 23888b91a832c0392708fbc57b323389724d22d9 @popcornmix popcornmix 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();
@@ -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);

11 comments on commit 23888b9

@buxit
buxit commented on 23888b9 Oct 4, 2012

would there be a way to work around the memory limitation without scaling the whole gui? what was the drawback of the old solution?

@buxit
buxit commented on 23888b9 Oct 4, 2012

but one that allowed the gui to be drawn at full resolution ...

@huceke
Contributor
huceke commented on 23888b9 Oct 4, 2012

@buxit: yes, take out your solder iron :D

@s7mx1
s7mx1 commented on 23888b9 Oct 9, 2012

The effect of 720p GUI caps on 1080p screen is quite noticeable: image is blur and texts are not as sharp as they used to be. Instead of forcing everyone to have "low resolution" (unscaled from 720p) its better to have an option so user can turn the cap on/off. Remember not everyone use fanart.

@theuni
Member
theuni commented on 23888b9 Oct 9, 2012

Which skin?

@s7mx1
s7mx1 commented on 23888b9 Oct 9, 2012

The default skin confluence lite I believe with blue bubbles background. Its not just me, other users have confirmed the difference.

@theuni
Member
theuni commented on 23888b9 Oct 9, 2012

Confluence is 720p, as are almost all skins that would run on the Pi. It's always been scaled, so I'm calling BS.
In fact, the change here is that images that were previously scaled by 50% are now scaled down to 1280x720, so you're now getting twice the resolution for the bubbles.

For the 720p->1080p stretch, the scaling has moved from GL to the hardware scalers, which should be better anyway.

Text.. I could maybe buy that.

@twolife
twolife commented on 23888b9 Oct 9, 2012

Since this was commited, subtitles have disappeared on 720p video :(
subtitles still appear on lowres video (xvid), but they aren't visible anymore when i play a x264 720p video

(yes, i'm sure it's because of that patch. i reverted it & it works now)

@sraue
Member
sraue commented on 23888b9 Oct 9, 2012

i think the subtitle "issue" is more a question of calibrating the subtitle position, see:
http://www.raspihub.com/go/20fa93d823e8a56229c0aeb1d9e084952656b0cae2d873b103ce02a03dba0f10

but its something to look into

@huceke
Contributor
huceke commented on 23888b9 Oct 9, 2012

I'm pretty sure it is the initial calibrtation which is wrong. Fix is in the works ;)

@buxit
buxit commented on 23888b9 Oct 10, 2012

i don't care about fanart or other backdrops. i have fanart enabled and it all looks good when scaled (either by GL or hardware). i do care about ui and font sharpness though. subtitles specifically look a lot worse since the change.

Please sign in to comment.