Navigation Menu

Skip to content

Commit

Permalink
[rbp] Support the split gui/display resolution. Gui is limited to 720…
Browse files Browse the repository at this point in the history
…p. Display can be 1080p. Remove temporary hack of downsizing the textures.
  • Loading branch information
popcornmix committed Oct 3, 2012
1 parent 6274eb5 commit 23888b9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
8 changes: 7 additions & 1 deletion xbmc/cores/omxplayer/OMXVideo.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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();

Expand Down
9 changes: 7 additions & 2 deletions xbmc/guilib/Texture.cpp
Expand Up @@ -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);

Expand Down
30 changes: 23 additions & 7 deletions xbmc/windowing/egl/WinEGLPlatformRaspberryPI.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions xbmc/windowing/egl/WinSystemGLES.cpp
Expand Up @@ -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
1 change: 1 addition & 0 deletions xbmc/windowing/egl/WinSystemGLES.h
Expand Up @@ -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);
Expand Down

11 comments on commit 23888b9

@buxit
Copy link

@buxit buxit commented on 23888b9 Oct 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@buxit buxit commented on 23888b9 Oct 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@huceke
Copy link
Contributor

@huceke huceke commented on 23888b9 Oct 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@s7mx1
Copy link

@s7mx1 s7mx1 commented on 23888b9 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@theuni theuni commented on 23888b9 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which skin?

@s7mx1
Copy link

@s7mx1 s7mx1 commented on 23888b9 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@theuni
Copy link
Contributor

@theuni theuni commented on 23888b9 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

@twolife twolife commented on 23888b9 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

@sraue sraue commented on 23888b9 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

@huceke huceke commented on 23888b9 Oct 9, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@buxit
Copy link

@buxit buxit commented on 23888b9 Oct 10, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.