Advertisement
daryoon

XBMC Arbitrary Skin Resolution

Apr 21st, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.87 KB | None | 0 0
  1. diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
  2. index 57bffa3..95349a3 100644
  3. --- a/xbmc/Application.cpp
  4. +++ b/xbmc/Application.cpp
  5. @@ -1851,7 +1851,7 @@ void CApplication::RenderNoPresent()
  6. m_guiPointer.Render();
  7.  
  8. // reset image scaling and effect states
  9. - g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetVideoResolution(), false);
  10. + g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false);
  11.  
  12. RenderMemoryStatus();
  13. RenderScreenSaver();
  14. @@ -2113,7 +2113,7 @@ void CApplication::RenderMemoryStatus()
  15.  
  16. // reset the window scaling and fade status
  17. RESOLUTION res = g_graphicsContext.GetVideoResolution();
  18. - g_graphicsContext.SetRenderingResolution(res, false);
  19. + g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false);
  20.  
  21. static int yShift = 20;
  22. static int xShift = 40;
  23. @@ -2179,7 +2179,7 @@ void CApplication::RenderMemoryStatus()
  24. g_graphicsContext.SetScalingResolution(window->GetCoordsRes(), true);
  25. point.x *= g_graphicsContext.GetGUIScaleX();
  26. point.y *= g_graphicsContext.GetGUIScaleY();
  27. - g_graphicsContext.SetRenderingResolution(res, false);
  28. + g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false);
  29. }
  30. info.AppendFormat("Mouse: (%d,%d) ", (int)point.x, (int)point.y);
  31. if (window)
  32. diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp
  33. index 51ea49c..49908e9 100644
  34. --- a/xbmc/addons/AddonManager.cpp
  35. +++ b/xbmc/addons/AddonManager.cpp
  36. @@ -53,7 +53,6 @@ namespace ADDON
  37. cp_log_severity_t clog_to_cp(int lvl);
  38. void cp_fatalErrorHandler(const char *msg);
  39. void cp_logger(cp_log_severity_t level, const char *msg, const char *apid, void *user_data);
  40. -bool GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path);
  41.  
  42. /**********************************************************
  43. * CAddonMgr
  44. @@ -147,12 +146,11 @@ bool CAddonMgr::CheckUserDirs(const cp_cfg_element_t *settings)
  45. if (!userdirs)
  46. return false;
  47.  
  48. - DEQUEELEMENTS elements;
  49. - bool status = GetExtElementDeque(elements, (cp_cfg_element_t *)userdirs, "userdir");
  50. - if (!status)
  51. + ELEMENTS elements;
  52. + if (!GetExtElements((cp_cfg_element_t *)userdirs, "userdir", elements))
  53. return false;
  54.  
  55. - IDEQUEELEMENTS itr = elements.begin();
  56. + ELEMENTS::iterator itr = elements.begin();
  57. while (itr != elements.end())
  58. {
  59. CStdString path = GetExtValue(*itr++, "@path");
  60. @@ -548,25 +546,19 @@ const cp_cfg_element_t *CAddonMgr::GetExtElement(cp_cfg_element_t *base, const c
  61. return element;
  62. }
  63.  
  64. -/* Returns all duplicate elements from a base element */
  65. -bool GetExtElementDeque(DEQUEELEMENTS &elements, cp_cfg_element_t *base, const char *path)
  66. +bool CAddonMgr::GetExtElements(cp_cfg_element_t *base, const char *path, ELEMENTS &elements)
  67. {
  68. - if (!base)
  69. + if (!base || !path)
  70. return false;
  71.  
  72. - unsigned int i = 0;
  73. - while (true)
  74. + for (unsigned int i = 0; i < base->num_children; i++)
  75. {
  76. - if (i >= base->num_children)
  77. - break;
  78. - CStdString temp = (base->children+i)->name;
  79. + CStdString temp = base->children[i].name;
  80. if (!temp.compare(path))
  81. - elements.push_back(base->children+i);
  82. - i++;
  83. + elements.push_back(&base->children[i]);
  84. }
  85.  
  86. - if (elements.empty()) return false;
  87. - return true;
  88. + return !elements.empty();
  89. }
  90.  
  91. const cp_extension_t *CAddonMgr::GetExtension(const cp_plugin_info_t *props, const char *extension) const
  92. diff --git a/xbmc/addons/AddonManager.h b/xbmc/addons/AddonManager.h
  93. index fb464e0..4e6c1a7 100644
  94. --- a/xbmc/addons/AddonManager.h
  95. +++ b/xbmc/addons/AddonManager.h
  96. @@ -24,6 +24,8 @@
  97. #include "tinyXML/tinyxml.h"
  98. #include "threads/CriticalSection.h"
  99. #include "utils/StdString.h"
  100. +#include "utils/Job.h"
  101. +#include "utils/Stopwatch.h"
  102. #include <vector>
  103. #include <map>
  104. #include <deque>
  105. @@ -39,8 +41,7 @@ namespace ADDON
  106. {
  107. typedef std::map<TYPE, VECADDONS> MAPADDONS;
  108. typedef std::map<TYPE, VECADDONS>::iterator IMAPADDONS;
  109. - typedef std::deque<cp_cfg_element_t*> DEQUEELEMENTS;
  110. - typedef std::deque<cp_cfg_element_t*>::iterator IDEQUEELEMENTS;
  111. + typedef std::vector<cp_cfg_element_t*> ELEMENTS;
  112.  
  113. const CStdString ADDON_METAFILE = "description.xml";
  114. const CStdString ADDON_VIS_EXT = "*.vis";
  115. @@ -116,6 +117,14 @@ namespace ADDON
  116. /* libcpluff */
  117. CStdString GetExtValue(cp_cfg_element_t *base, const char *path);
  118.  
  119. + /*! \brief Retrieve a vector of repeated elements from a given configuration element
  120. + \param base the base configuration element.
  121. + \param path the path to the configuration element from the base element.
  122. + \param result [out] returned list of elements.
  123. + \return true if the configuration element is present and the list of elements is non-empty
  124. + */
  125. + bool GetExtElements(cp_cfg_element_t *base, const char *path, ELEMENTS &result);
  126. +
  127. /*! \brief Retrieve a list of strings from a given configuration element
  128. Assumes the configuration element or attribute contains a whitespace separated list of values (eg xs:list schema).
  129. \param base the base configuration element.
  130. diff --git a/xbmc/addons/Skin.cpp b/xbmc/addons/Skin.cpp
  131. index 675a116..802e2ec 100644
  132. --- a/xbmc/addons/Skin.cpp
  133. +++ b/xbmc/addons/Skin.cpp
  134. @@ -27,8 +27,12 @@
  135. #include "utils/URIUtils.h"
  136. #include "settings/Settings.h"
  137. #include "utils/log.h"
  138. +#include "utils/StringUtils.h"
  139. #include "settings/GUISettings.h"
  140.  
  141. +// fallback for new skin resolution code
  142. +#include "filesystem/Directory.h"
  143. +
  144. using namespace std;
  145. using namespace XFILE;
  146.  
  147. @@ -39,16 +43,44 @@ boost::shared_ptr<ADDON::CSkinInfo> g_SkinInfo;
  148. namespace ADDON
  149. {
  150.  
  151. -CSkinInfo::CSkinInfo(const AddonProps &props, RESOLUTION res)
  152. - : CAddon(props), m_DefaultResolution(res), m_DefaultResolutionWide(res)
  153. +CSkinInfo::CSkinInfo(const AddonProps &props, const RESOLUTION_INFO &resolution)
  154. + : CAddon(props), m_defaultRes(resolution)
  155. {
  156. }
  157.  
  158. CSkinInfo::CSkinInfo(const cp_extension_t *ext)
  159. : CAddon(ext)
  160. {
  161. - m_DefaultResolution = TranslateResolution(CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultresolution"), RES_PAL_4x3);
  162. - m_DefaultResolutionWide = TranslateResolution(CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultresolutionwide"), RES_INVALID);
  163. + ELEMENTS elements;
  164. + if (CAddonMgr::Get().GetExtElements(ext->configuration, "res", elements))
  165. + {
  166. + for (ELEMENTS::iterator i = elements.begin(); i != elements.end(); ++i)
  167. + {
  168. + float width = (float)atof(CAddonMgr::Get().GetExtValue(*i, "@width"));
  169. + float height = (float)atof(CAddonMgr::Get().GetExtValue(*i, "@height"));
  170. + bool defRes = CAddonMgr::Get().GetExtValue(*i, "@default").Equals("true");
  171. + CStdString folder = CAddonMgr::Get().GetExtValue(*i, "@folder");
  172. + float aspect = 0;
  173. + CStdStringArray fracs;
  174. + StringUtils::SplitString(CAddonMgr::Get().GetExtValue(*i, "@aspect"), ":", fracs);
  175. + if (fracs.size() == 2)
  176. + aspect = (float)atof(fracs[0].c_str())/atof(fracs[1].c_str());
  177. + if (width > 0 && height > 0)
  178. + {
  179. + RESOLUTION_INFO res(width, height, aspect, folder);
  180. + if (defRes)
  181. + m_defaultRes = res;
  182. + m_resolutions.push_back(res);
  183. + }
  184. + }
  185. + }
  186. + else
  187. + { // no resolutions specified -> backward compatibility
  188. + CStdString defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultwideresolution");
  189. + if (defaultWide.IsEmpty())
  190. + defaultWide = CAddonMgr::Get().GetExtValue(ext->configuration, "@defaultresolution");
  191. + TranslateResolution(defaultWide, m_defaultRes);
  192. + }
  193.  
  194. CStdString str = CAddonMgr::Get().GetExtValue(ext->configuration, "@effectslowdown");
  195. if (!str.IsEmpty())
  196. @@ -65,76 +97,69 @@ CSkinInfo::CSkinInfo(const cp_extension_t *ext)
  197. }
  198.  
  199. CSkinInfo::~CSkinInfo()
  200. -{}
  201. +{
  202. +}
  203.  
  204. -void CSkinInfo::Start(const CStdString& strSkinDir /* = "" */)
  205. +void CSkinInfo::Start(const CStdString &strBaseDir)
  206. {
  207. - CLog::Log(LOGINFO, "Default 4:3 resolution directory is %s", URIUtils::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolution)).c_str());
  208. - CLog::Log(LOGINFO, "Default 16:9 resolution directory is %s", URIUtils::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolutionWide)).c_str());
  209. + if (!m_resolutions.size())
  210. + { // try falling back to whatever resolutions exist in the directory
  211. + CFileItemList items;
  212. + CDirectory::GetDirectory(Path(), items, "", false);
  213. + for (int i = 0; i < items.Size(); i++)
  214. + {
  215. + RESOLUTION_INFO res;
  216. + if (items[i]->m_bIsFolder && TranslateResolution(items[i]->GetLabel(), res))
  217. + m_resolutions.push_back(res);
  218. + }
  219. + }
  220. LoadIncludes();
  221. }
  222.  
  223. -CStdString CSkinInfo::GetSkinPath(const CStdString& strFile, RESOLUTION *res, const CStdString& strBaseDir /* = "" */) const
  224. +struct closestRes
  225. {
  226. + closestRes(const RESOLUTION_INFO &target) : m_target(target) { };
  227. + bool operator()(const RESOLUTION_INFO &i, const RESOLUTION_INFO &j)
  228. + {
  229. + float diff = fabs(i.DisplayRatio() - m_target.DisplayRatio()) - fabs(j.DisplayRatio() - m_target.DisplayRatio());
  230. + if (diff < 0) return true;
  231. + if (diff > 0) return false;
  232. + diff = fabs((float)i.iHeight - m_target.iHeight) - fabs((float)j.iHeight - m_target.iHeight);
  233. + if (diff < 0) return true;
  234. + if (diff > 0) return false;
  235. + return fabs((float)i.iWidth - m_target.iWidth) < fabs((float)j.iWidth - m_target.iWidth);
  236. + }
  237. + RESOLUTION_INFO m_target;
  238. +};
  239. +
  240. +CStdString CSkinInfo::GetSkinPath(const CStdString& strFile, RESOLUTION_INFO *res, const CStdString& strBaseDir /* = "" */) const
  241. +{
  242. + if (m_resolutions.empty())
  243. + return ""; // invalid skin
  244. +
  245. CStdString strPathToUse = Path();
  246. if (!strBaseDir.IsEmpty())
  247. strPathToUse = strBaseDir;
  248.  
  249. // if the caller doesn't care about the resolution just use a temporary
  250. - RESOLUTION tempRes = RES_INVALID;
  251. + RESOLUTION_INFO tempRes;
  252. if (!res)
  253. res = &tempRes;
  254.  
  255. - // first try and load from the current resolution's directory
  256. - *res = g_graphicsContext.GetVideoResolution();
  257. - if (*res >= RES_WINDOW)
  258. - {
  259. - unsigned int pixels = g_settings.m_ResInfo[*res].iHeight * g_settings.m_ResInfo[*res].iWidth;
  260. - if (pixels >= 1600 * 900)
  261. - {
  262. - *res = RES_HDTV_1080i;
  263. - }
  264. - else if (pixels >= 900 * 600)
  265. - {
  266. - *res = RES_HDTV_720p;
  267. - }
  268. - else if (((float)g_settings.m_ResInfo[*res].iWidth) / ((float)g_settings.m_ResInfo[*res].iHeight) > 8.0f / (3.0f * sqrt(3.0f)))
  269. - {
  270. - *res = RES_PAL_16x9;
  271. - }
  272. - else
  273. - {
  274. - *res = RES_PAL_4x3;
  275. - }
  276. - }
  277. - CStdString strPath = URIUtils::AddFileToFolder(strPathToUse, GetDirFromRes(*res));
  278. + // find the closest resolution
  279. + const RESOLUTION_INFO &target = g_graphicsContext.GetResInfo();
  280. + *res = *std::min_element(m_resolutions.begin(), m_resolutions.end(), closestRes(target));
  281. +
  282. + CStdString strPath = URIUtils::AddFileToFolder(strPathToUse, res->strMode);
  283. strPath = URIUtils::AddFileToFolder(strPath, strFile);
  284. if (CFile::Exists(strPath))
  285. return strPath;
  286. - // if we're in 1080i mode, try 720p next
  287. - if (*res == RES_HDTV_1080i)
  288. - {
  289. - *res = RES_HDTV_720p;
  290. - strPath = URIUtils::AddFileToFolder(strPathToUse, GetDirFromRes(*res));
  291. - strPath = URIUtils::AddFileToFolder(strPath, strFile);
  292. - if (CFile::Exists(strPath))
  293. - return strPath;
  294. - }
  295. - // that failed - drop to the default widescreen resolution if where in a widemode
  296. - if (*res == RES_PAL_16x9 || *res == RES_NTSC_16x9 || *res == RES_HDTV_480p_16x9 || *res == RES_HDTV_720p)
  297. - {
  298. - *res = m_DefaultResolutionWide;
  299. - strPath = URIUtils::AddFileToFolder(strPathToUse, GetDirFromRes(*res));
  300. - strPath = URIUtils::AddFileToFolder(strPath, strFile);
  301. - if (CFile::Exists(strPath))
  302. - return strPath;
  303. - }
  304. - // that failed - drop to the default resolution
  305. - *res = m_DefaultResolution;
  306. - strPath = URIUtils::AddFileToFolder(strPathToUse, GetDirFromRes(*res));
  307. +
  308. + // use the default resolution
  309. + *res = m_defaultRes;
  310. +
  311. + strPath = URIUtils::AddFileToFolder(strPathToUse, res->strMode);
  312. strPath = URIUtils::AddFileToFolder(strPath, strFile);
  313. - // check if we don't have any subdirectories
  314. - if (*res == RES_INVALID) *res = RES_PAL_4x3;
  315. return strPath;
  316. }
  317.  
  318. @@ -143,39 +168,6 @@ bool CSkinInfo::HasSkinFile(const CStdString &strFile) const
  319. return CFile::Exists(GetSkinPath(strFile));
  320. }
  321.  
  322. -CStdString CSkinInfo::GetDirFromRes(RESOLUTION res) const
  323. -{
  324. - CStdString strRes;
  325. - switch (res)
  326. - {
  327. - case RES_PAL_4x3:
  328. - strRes = "PAL";
  329. - break;
  330. - case RES_PAL_16x9:
  331. - strRes = "PAL16x9";
  332. - break;
  333. - case RES_NTSC_4x3:
  334. - case RES_HDTV_480p_4x3:
  335. - strRes = "NTSC";
  336. - break;
  337. - case RES_NTSC_16x9:
  338. - case RES_HDTV_480p_16x9:
  339. - strRes = "ntsc16x9";
  340. - break;
  341. - case RES_HDTV_720p:
  342. - strRes = "720p";
  343. - break;
  344. - case RES_HDTV_1080i:
  345. - strRes = "1080i";
  346. - break;
  347. - case RES_INVALID:
  348. - default:
  349. - strRes = "";
  350. - break;
  351. - }
  352. - return strRes;
  353. -}
  354. -
  355. double CSkinInfo::GetMinVersion()
  356. {
  357. return SKIN_MIN_VERSION;
  358. @@ -210,69 +202,45 @@ int CSkinInfo::GetStartWindow() const
  359. bool CSkinInfo::LoadStartupWindows(const cp_extension_t *ext)
  360. {
  361. m_startupWindows.clear();
  362. - /*{ // yay, run through and grab the startup windows
  363. - const TiXmlElement *window = startup->FirstChildElement("window");
  364. - while (window && window->FirstChild())
  365. - {
  366. - int id;
  367. - window->Attribute("id", &id);
  368. - CStdString name = window->FirstChild()->Value();
  369. - m_startupWindows.push_back(CStartupWindow(id + WINDOW_HOME, name));
  370. - window = window->NextSiblingElement("window");
  371. - }
  372. - }*/
  373. -
  374. - // ok, now see if we have any startup windows
  375. - if (!m_startupWindows.size())
  376. - { // nope - add the default ones
  377. - m_startupWindows.push_back(CStartupWindow(WINDOW_HOME, "513"));
  378. - m_startupWindows.push_back(CStartupWindow(WINDOW_PROGRAMS, "0"));
  379. - m_startupWindows.push_back(CStartupWindow(WINDOW_PICTURES, "1"));
  380. - m_startupWindows.push_back(CStartupWindow(WINDOW_MUSIC, "2"));
  381. - m_startupWindows.push_back(CStartupWindow(WINDOW_VIDEOS, "3"));
  382. - m_startupWindows.push_back(CStartupWindow(WINDOW_FILES, "7"));
  383. - m_startupWindows.push_back(CStartupWindow(WINDOW_SETTINGS_MENU, "5"));
  384. - m_startupWindows.push_back(CStartupWindow(WINDOW_WEATHER, "8"));
  385. - m_onlyAnimateToHome = true;
  386. - }
  387. - else
  388. - m_onlyAnimateToHome = false;
  389. + m_startupWindows.push_back(CStartupWindow(WINDOW_HOME, "513"));
  390. + m_startupWindows.push_back(CStartupWindow(WINDOW_PROGRAMS, "0"));
  391. + m_startupWindows.push_back(CStartupWindow(WINDOW_PICTURES, "1"));
  392. + m_startupWindows.push_back(CStartupWindow(WINDOW_MUSIC, "2"));
  393. + m_startupWindows.push_back(CStartupWindow(WINDOW_VIDEOS, "3"));
  394. + m_startupWindows.push_back(CStartupWindow(WINDOW_FILES, "7"));
  395. + m_startupWindows.push_back(CStartupWindow(WINDOW_SETTINGS_MENU, "5"));
  396. + m_startupWindows.push_back(CStartupWindow(WINDOW_WEATHER, "8"));
  397. + m_onlyAnimateToHome = true;
  398. return true;
  399. }
  400.  
  401. -bool CSkinInfo::IsWide(RESOLUTION res) const
  402. -{
  403. - return (res == RES_PAL_16x9 || res == RES_NTSC_16x9 || res == RES_HDTV_480p_16x9 || res == RES_HDTV_720p || res == RES_HDTV_1080i);
  404. -}
  405. -
  406. void CSkinInfo::GetSkinPaths(std::vector<CStdString> &paths) const
  407. {
  408. - RESOLUTION resToUse = RES_INVALID;
  409. - GetSkinPath("Home.xml", &resToUse);
  410. - paths.push_back(URIUtils::AddFileToFolder(Path(), GetDirFromRes(resToUse)));
  411. - // see if we need to add other paths
  412. - if (resToUse != m_DefaultResolutionWide && IsWide(resToUse))
  413. - paths.push_back(URIUtils::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolutionWide)));
  414. - if (resToUse != m_DefaultResolution && (!IsWide(resToUse) || m_DefaultResolutionWide != m_DefaultResolution))
  415. - paths.push_back(URIUtils::AddFileToFolder(Path(), GetDirFromRes(m_DefaultResolution)));
  416. + RESOLUTION_INFO res;
  417. + GetSkinPath("Home.xml", &res);
  418. + if (!res.strMode.empty())
  419. + paths.push_back(URIUtils::AddFileToFolder(Path(), res.strMode));
  420. + if (res.strMode != m_defaultRes.strMode)
  421. + paths.push_back(URIUtils::AddFileToFolder(Path(), m_defaultRes.strMode));
  422. }
  423.  
  424. -RESOLUTION CSkinInfo::TranslateResolution(const CStdString &res, RESOLUTION def)
  425. +bool CSkinInfo::TranslateResolution(const CStdString &name, RESOLUTION_INFO &res)
  426. {
  427. - if (res.Equals("pal"))
  428. - return RES_PAL_4x3;
  429. - else if (res.Equals("pal16x9"))
  430. - return RES_PAL_16x9;
  431. - else if (res.Equals("ntsc"))
  432. - return RES_NTSC_4x3;
  433. - else if (res.Equals("ntsc16x9"))
  434. - return RES_NTSC_16x9;
  435. - else if (res.Equals("720p"))
  436. - return RES_HDTV_720p;
  437. - else if (res.Equals("1080i"))
  438. - return RES_HDTV_1080i;
  439. - CLog::Log(LOGERROR, "%s invalid resolution specified for %s", __FUNCTION__, res.c_str());
  440. - return def;
  441. + if (name.Equals("pal"))
  442. + res = RESOLUTION_INFO(720, 576, 4.0f/3, "pal");
  443. + else if (name.Equals("pal16x9"))
  444. + res = RESOLUTION_INFO(720, 576, 16.0f/9, "pal16x9");
  445. + else if (name.Equals("ntsc"))
  446. + res = RESOLUTION_INFO(720, 480, 4.0f/3, "ntsc");
  447. + else if (name.Equals("ntsc16x9"))
  448. + res = RESOLUTION_INFO(720, 480, 16.0f/9, "ntsc16x9");
  449. + else if (name.Equals("720p"))
  450. + res = RESOLUTION_INFO(1280, 720, 0, "720p");
  451. + else if (name.Equals("1080i"))
  452. + res = RESOLUTION_INFO(1920, 1080, 0, "1080i");
  453. + else
  454. + return false;
  455. + return true;
  456. }
  457.  
  458. int CSkinInfo::GetFirstWindow() const
  459. diff --git a/xbmc/addons/Skin.h b/xbmc/addons/Skin.h
  460. index e751b5c..11be79f 100644
  461. --- a/xbmc/addons/Skin.h
  462. +++ b/xbmc/addons/Skin.h
  463. @@ -46,7 +46,7 @@ public:
  464. };
  465.  
  466. //FIXME remove this, kept for current repo handling
  467. - CSkinInfo(const ADDON::AddonProps &props, RESOLUTION res = RES_HDTV_720p);
  468. + CSkinInfo(const ADDON::AddonProps &props, const RESOLUTION_INFO &res = RESOLUTION_INFO());
  469. CSkinInfo(const cp_extension_t *ext);
  470. virtual ~CSkinInfo();
  471.  
  472. @@ -64,7 +64,7 @@ public:
  473. \param baseDir [in] If non-empty, the given directory is searched instead of the skin's directory. Defaults to empty.
  474. \return path to the XML file
  475. */
  476. - CStdString GetSkinPath(const CStdString& file, RESOLUTION *res = NULL, const CStdString& baseDir = "") const;
  477. + CStdString GetSkinPath(const CStdString& file, RESOLUTION_INFO *res = NULL, const CStdString& baseDir = "") const;
  478.  
  479. double GetVersion() const { return m_Version; };
  480.  
  481. @@ -87,11 +87,11 @@ public:
  482. int GetStartWindow() const;
  483.  
  484. /*! \brief Translate a resolution string
  485. - \param res the string to translate
  486. - \param def the default to use if res is invalid
  487. - \return the translated resolution
  488. + \param name the string to translate
  489. + \param res [out] the resolution structure if name is valid
  490. + \return true if the resolution is valid, false otherwise
  491. */
  492. - static RESOLUTION TranslateResolution(const CStdString &res, RESOLUTION def);
  493. + static bool TranslateResolution(const CStdString &name, RESOLUTION_INFO &res);
  494.  
  495. void ResolveIncludes(TiXmlElement *node);
  496.  
  497. @@ -125,10 +125,10 @@ protected:
  498.  
  499. void LoadIncludes();
  500. bool LoadStartupWindows(const cp_extension_t *ext);
  501. - bool IsWide(RESOLUTION res) const;
  502.  
  503. - RESOLUTION m_DefaultResolution; // default resolution for the skin in 4:3 modes
  504. - RESOLUTION m_DefaultResolutionWide; // default resolution for the skin in 16:9 modes
  505. + RESOLUTION_INFO m_defaultRes;
  506. + std::vector<RESOLUTION_INFO> m_resolutions;
  507. +
  508. double m_Version;
  509.  
  510. float m_effectsSlowDown;
  511. diff --git a/xbmc/cores/DummyVideoPlayer.cpp b/xbmc/cores/DummyVideoPlayer.cpp
  512. index 821a39f..e6f9a10 100644
  513. --- a/xbmc/cores/DummyVideoPlayer.cpp
  514. +++ b/xbmc/cores/DummyVideoPlayer.cpp
  515. @@ -91,7 +91,7 @@ void CDummyVideoPlayer::Process()
  516. g_Windowing.Get3DDevice()->BeginScene();
  517. #endif
  518. g_graphicsContext.Clear();
  519. - g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetVideoResolution(), false);
  520. + g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false);
  521. Render();
  522. g_application.RenderNoPresent();
  523. #ifdef HAS_DX
  524. diff --git a/xbmc/dialogs/GUIDialogContextMenu.cpp b/xbmc/dialogs/GUIDialogContextMenu.cpp
  525. index 7694380..4982d7b 100644
  526. --- a/xbmc/dialogs/GUIDialogContextMenu.cpp
  527. +++ b/xbmc/dialogs/GUIDialogContextMenu.cpp
  528. @@ -151,11 +151,11 @@ void CGUIDialogContextMenu::SetupButtons()
  529.  
  530. void CGUIDialogContextMenu::SetPosition(float posX, float posY)
  531. {
  532. - if (posY + GetHeight() > g_settings.m_ResInfo[m_coordsRes].iHeight)
  533. - posY = g_settings.m_ResInfo[m_coordsRes].iHeight - GetHeight();
  534. + if (posY + GetHeight() > m_coordsRes.iHeight)
  535. + posY = m_coordsRes.iHeight - GetHeight();
  536. if (posY < 0) posY = 0;
  537. - if (posX + GetWidth() > g_settings.m_ResInfo[m_coordsRes].iWidth)
  538. - posX = g_settings.m_ResInfo[m_coordsRes].iWidth - GetWidth();
  539. + if (posX + GetWidth() > m_coordsRes.iWidth)
  540. + posX = m_coordsRes.iWidth - GetWidth();
  541. if (posX < 0) posX = 0;
  542. // we currently hack the positioning of the buttons from y position 0, which
  543. // forces skinners to place the top image at a negative y value. Thus, we offset
  544. diff --git a/xbmc/guilib/GUIFontManager.cpp b/xbmc/guilib/GUIFontManager.cpp
  545. index 98c4bd0..383226a 100644
  546. --- a/xbmc/guilib/GUIFontManager.cpp
  547. +++ b/xbmc/guilib/GUIFontManager.cpp
  548. @@ -39,7 +39,6 @@ GUIFontManager g_fontManager;
  549.  
  550. GUIFontManager::GUIFontManager(void)
  551. {
  552. - m_skinResolution=RES_INVALID;
  553. m_fontsetUnicode=false;
  554. m_canReload = true;
  555. }
  556. @@ -49,7 +48,7 @@ GUIFontManager::~GUIFontManager(void)
  557. Clear();
  558. }
  559.  
  560. -void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, RESOLUTION sourceRes, bool preserveAspect) const
  561. +void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect) const
  562. {
  563. // set scaling resolution so that we can scale our font sizes correctly
  564. // as fonts aren't scaled at render time (due to aliasing) we must scale
  565. @@ -66,8 +65,7 @@ void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, RESOLU
  566. // font streched like the rest of the UI, aspect parameter being the original aspect
  567.  
  568. // adjust aspect ratio
  569. - if (sourceRes == RES_PAL_16x9 || sourceRes == RES_PAL60_16x9 || sourceRes == RES_NTSC_16x9 || sourceRes == RES_HDTV_480p_16x9)
  570. - *aspect *= 0.75f;
  571. + *aspect *= sourceRes.fPixelRatio;
  572.  
  573. *aspect *= g_graphicsContext.GetGUIScaleY() / g_graphicsContext.GetGUIScaleX();
  574. }
  575. @@ -75,7 +73,7 @@ void GUIFontManager::RescaleFontSizeAndAspect(float *size, float *aspect, RESOLU
  576. *size /= g_graphicsContext.GetGUIScaleY();
  577. }
  578.  
  579. -CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border, float lineSpacing, float aspect, RESOLUTION sourceRes, bool preserveAspect)
  580. +CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border, float lineSpacing, float aspect, const RESOLUTION_INFO *sourceRes, bool preserveAspect)
  581. {
  582. float originalAspect = aspect;
  583.  
  584. @@ -84,11 +82,11 @@ CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdStrin
  585. if (pFont)
  586. return pFont;
  587.  
  588. - if (sourceRes == RES_INVALID) // no source res specified, so assume the skin res
  589. - sourceRes = m_skinResolution;
  590. + if (!sourceRes) // no source res specified, so assume the skin res
  591. + sourceRes = &m_skinResolution;
  592.  
  593. float newSize = (float)iSize;
  594. - RescaleFontSizeAndAspect(&newSize, &aspect, sourceRes, preserveAspect);
  595. + RescaleFontSizeAndAspect(&newSize, &aspect, *sourceRes, preserveAspect);
  596.  
  597. // First try to load the font from the skin
  598. CStdString strPath;
  599. @@ -151,7 +149,7 @@ CGUIFont* GUIFontManager::LoadTTF(const CStdString& strFontName, const CStdStrin
  600. fontInfo.aspect = originalAspect;
  601. fontInfo.fontFilePath = strPath;
  602. fontInfo.fileName = strFilename;
  603. - fontInfo.sourceRes = sourceRes;
  604. + fontInfo.sourceRes = *sourceRes;
  605. fontInfo.preserveAspect = preserveAspect;
  606. fontInfo.border = border;
  607. m_vecFontInfo.push_back(fontInfo);
  608. @@ -307,7 +305,7 @@ CGUIFont* GUIFontManager::GetDefaultFont(bool border)
  609. { // create it
  610. CGUIFont *font13 = m_vecFonts[font13index];
  611. OrigFontInfo fontInfo = m_vecFontInfo[font13index];
  612. - font13border = LoadTTF("__defaultborder__", fontInfo.fileName, 0xFF000000, 0, fontInfo.size, font13->GetStyle(), true, 1.0f, fontInfo.aspect, fontInfo.sourceRes, fontInfo.preserveAspect);
  613. + font13border = LoadTTF("__defaultborder__", fontInfo.fileName, 0xFF000000, 0, fontInfo.size, font13->GetStyle(), true, 1.0f, fontInfo.aspect, &fontInfo.sourceRes, fontInfo.preserveAspect);
  614. }
  615. return font13border;
  616. }
  617. diff --git a/xbmc/guilib/GUIFontManager.h b/xbmc/guilib/GUIFontManager.h
  618. index acdc46b..f0237e2 100644
  619. --- a/xbmc/guilib/GUIFontManager.h
  620. +++ b/xbmc/guilib/GUIFontManager.h
  621. @@ -44,7 +44,7 @@ struct OrigFontInfo
  622. float aspect;
  623. CStdString fontFilePath;
  624. CStdString fileName;
  625. - RESOLUTION sourceRes;
  626. + RESOLUTION_INFO sourceRes;
  627. bool preserveAspect;
  628. bool border;
  629. };
  630. @@ -63,7 +63,7 @@ public:
  631.  
  632. void Unload(const CStdString& strFontName);
  633. void LoadFonts(const CStdString& strFontSet);
  634. - CGUIFont* LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border = false, float lineSpacing = 1.0f, float aspect = 1.0f, RESOLUTION res = RES_INVALID, bool preserveAspect = false);
  635. + CGUIFont* LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border = false, float lineSpacing = 1.0f, float aspect = 1.0f, const RESOLUTION_INFO *res = NULL, bool preserveAspect = false);
  636. CGUIFont* GetFont(const CStdString& strFontName, bool fallback = true);
  637.  
  638. /*! \brief return a default font
  639. @@ -80,7 +80,7 @@ public:
  640. bool GetFirstFontSetUnicode(CStdString& strFontSet);
  641.  
  642. protected:
  643. - void RescaleFontSizeAndAspect(float *size, float *aspect, RESOLUTION sourceRes, bool preserveAspect) const;
  644. + void RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect) const;
  645. void ReloadTTFFonts();
  646. void LoadFonts(const TiXmlNode* fontNode);
  647. CGUIFontTTFBase* GetFontFile(const CStdString& strFontFile);
  648. @@ -90,7 +90,7 @@ protected:
  649. std::vector<CGUIFontTTFBase*> m_vecFontFiles;
  650. std::vector<OrigFontInfo> m_vecFontInfo;
  651. bool m_fontsetUnicode;
  652. - RESOLUTION m_skinResolution;
  653. + RESOLUTION_INFO m_skinResolution;
  654. bool m_canReload;
  655. };
  656.  
  657. diff --git a/xbmc/guilib/GUIWindow.cpp b/xbmc/guilib/GUIWindow.cpp
  658. index 7b37a6d..cf23daf 100644
  659. --- a/xbmc/guilib/GUIWindow.cpp
  660. +++ b/xbmc/guilib/GUIWindow.cpp
  661. @@ -24,7 +24,6 @@
  662. #include "GUIWindowManager.h"
  663. #include "Key.h"
  664. #include "LocalizeStrings.h"
  665. -#include "settings/Settings.h"
  666. #include "GUIControlFactory.h"
  667. #include "GUIControlGroup.h"
  668. #include "GUIControlProfiler.h"
  669. @@ -53,7 +52,6 @@ CGUIWindow::CGUIWindow(int id, const CStdString &xmlFile)
  670. m_idRange = 1;
  671. m_lastControlID = 0;
  672. m_overlayState = OVERLAY_STATE_PARENT_WINDOW; // Use parent or previous window's state
  673. - m_coordsRes = g_guiSettings.m_LookAndFeelResolution;
  674. m_isDialog = false;
  675. m_needsScaling = true;
  676. m_windowLoaded = false;
  677. @@ -83,7 +81,6 @@ bool CGUIWindow::Load(const CStdString& strFileName, bool bContainsPath)
  678. int64_t start;
  679. start = CurrentHostCounter();
  680. #endif
  681. - RESOLUTION resToUse = RES_INVALID;
  682. CLog::Log(LOGINFO, "Loading skin file: %s", strFileName.c_str());
  683.  
  684. // Find appropriate skin folder + resolution to load from
  685. @@ -94,13 +91,10 @@ bool CGUIWindow::Load(const CStdString& strFileName, bool bContainsPath)
  686. else
  687. {
  688. // FIXME: strLowerPath needs to eventually go since resToUse can get incorrectly overridden
  689. - strLowerPath = g_SkinInfo->GetSkinPath(CStdString(strFileName).ToLower(), &resToUse);
  690. - strPath = g_SkinInfo->GetSkinPath(strFileName, &resToUse);
  691. + strLowerPath = g_SkinInfo->GetSkinPath(CStdString(strFileName).ToLower(), &m_coordsRes);
  692. + strPath = g_SkinInfo->GetSkinPath(strFileName, &m_coordsRes);
  693. }
  694.  
  695. - if (!bContainsPath)
  696. - m_coordsRes = resToUse;
  697. -
  698. bool ret = LoadXML(strPath.c_str(), strLowerPath.c_str());
  699.  
  700. #ifdef _DEBUG
  701. @@ -176,7 +170,7 @@ bool CGUIWindow::Load(TiXmlDocument &xmlDoc)
  702. }
  703. else if (strValue == "animation" && pChild->FirstChild())
  704. {
  705. - CRect rect(0, 0, (float)g_settings.m_ResInfo[m_coordsRes].iWidth, (float)g_settings.m_ResInfo[m_coordsRes].iHeight);
  706. + CRect rect(0, 0, (float)m_coordsRes.iWidth, (float)m_coordsRes.iHeight);
  707. CAnimation anim;
  708. anim.Create(pChild, rect);
  709. m_animations.push_back(anim);
  710. @@ -241,7 +235,7 @@ void CGUIWindow::LoadControl(TiXmlElement* pControl, CGUIControlGroup *pGroup)
  711. // get control type
  712. CGUIControlFactory factory;
  713.  
  714. - CRect rect(0, 0, (float)g_settings.m_ResInfo[m_coordsRes].iWidth, (float)g_settings.m_ResInfo[m_coordsRes].iHeight);
  715. + CRect rect(0, 0, (float)m_coordsRes.iWidth, (float)m_coordsRes.iHeight);
  716. if (pGroup)
  717. {
  718. rect.x1 = pGroup->GetXPosition();
  719. @@ -288,8 +282,8 @@ void CGUIWindow::OnWindowLoaded()
  720.  
  721. void CGUIWindow::CenterWindow()
  722. {
  723. - m_posX = (g_settings.m_ResInfo[m_coordsRes].iWidth - GetWidth()) / 2;
  724. - m_posY = (g_settings.m_ResInfo[m_coordsRes].iHeight - GetHeight()) / 2;
  725. + m_posX = (m_coordsRes.iWidth - GetWidth()) / 2;
  726. + m_posY = (m_coordsRes.iHeight - GetHeight()) / 2;
  727. }
  728.  
  729. void CGUIWindow::Render()
  730. @@ -787,7 +781,7 @@ void CGUIWindow::SetDefaults()
  731. m_hasCamera = false;
  732. m_animationsEnabled = true;
  733. m_clearBackground = 0xff000000; // opaque black -> clear
  734. - m_hitRect.SetRect(0, 0, (float)g_settings.m_ResInfo[m_coordsRes].iWidth, (float)g_settings.m_ResInfo[m_coordsRes].iHeight);
  735. + m_hitRect.SetRect(0, 0, (float)m_coordsRes.iWidth, (float)m_coordsRes.iHeight);
  736. }
  737.  
  738. CRect CGUIWindow::GetScaledBounds() const
  739. diff --git a/xbmc/guilib/GUIWindow.h b/xbmc/guilib/GUIWindow.h
  740. index 5f3f3a6..1e77392 100644
  741. --- a/xbmc/guilib/GUIWindow.h
  742. +++ b/xbmc/guilib/GUIWindow.h
  743. @@ -135,8 +135,8 @@ public:
  744. virtual CFileItemPtr GetCurrentListItem(int offset = 0) { return CFileItemPtr(); };
  745. virtual int GetViewContainerID() const { return 0; };
  746. virtual bool IsActive() const;
  747. - void SetCoordsRes(RESOLUTION res) { m_coordsRes = res; };
  748. - RESOLUTION GetCoordsRes() const { return m_coordsRes; };
  749. + void SetCoordsRes(const RESOLUTION_INFO &res) { m_coordsRes = res; };
  750. + const RESOLUTION_INFO &GetCoordsRes() const { return m_coordsRes; };
  751. void LoadOnDemand(bool loadOnDemand) { m_loadOnDemand = loadOnDemand; };
  752. bool GetLoadOnDemand() { return m_loadOnDemand; }
  753. int GetRenderOrder() { return m_renderOrder; };
  754. @@ -249,7 +249,7 @@ protected:
  755.  
  756. int m_idRange;
  757. OVERLAY_STATE m_overlayState;
  758. - RESOLUTION m_coordsRes; // resolution that the window coordinates are in.
  759. + RESOLUTION_INFO m_coordsRes; // resolution that the window coordinates are in.
  760. bool m_needsScaling;
  761. bool m_windowLoaded; // true if the window's xml file has been loaded
  762. bool m_loadOnDemand; // true if the window should be loaded only as needed
  763. diff --git a/xbmc/guilib/GraphicContext.cpp b/xbmc/guilib/GraphicContext.cpp
  764. index f16ee27..0cab11d 100644
  765. --- a/xbmc/guilib/GraphicContext.cpp
  766. +++ b/xbmc/guilib/GraphicContext.cpp
  767. @@ -51,7 +51,7 @@ CGraphicContext::CGraphicContext(void) :
  768. m_bFullScreenVideo(false),
  769. m_bCalibrating(false),
  770. m_Resolution(RES_INVALID),
  771. - m_windowResolution(RES_INVALID),
  772. + /*m_windowResolution,*/
  773. m_guiScaleX(1.0f),
  774. m_guiScaleY(1.0f)
  775. /*,m_cameras, */
  776. @@ -543,7 +543,12 @@ void CGraphicContext::ApplyStateBlock()
  777. g_Windowing.ApplyStateBlock();
  778. }
  779.  
  780. -void CGraphicContext::SetScalingResolution(RESOLUTION res, bool needsScaling)
  781. +const RESOLUTION_INFO &CGraphicContext::GetResInfo() const
  782. +{
  783. + return g_settings.m_ResInfo[m_Resolution];
  784. +}
  785. +
  786. +void CGraphicContext::SetScalingResolution(const RESOLUTION_INFO &res, bool needsScaling)
  787. {
  788. Lock();
  789. m_windowResolution = res;
  790. @@ -558,8 +563,8 @@ void CGraphicContext::SetScalingResolution(RESOLUTION res, bool needsScaling)
  791. float fToHeight;
  792.  
  793. {
  794. - fFromWidth = (float)g_settings.m_ResInfo[res].iWidth;
  795. - fFromHeight = (float)g_settings.m_ResInfo[res].iHeight;
  796. + fFromWidth = (float)res.iWidth;
  797. + fFromHeight = (float)res.iHeight;
  798. fToPosX = (float)g_settings.m_ResInfo[m_Resolution].Overscan.left;
  799. fToPosY = (float)g_settings.m_ResInfo[m_Resolution].Overscan.top;
  800. fToWidth = (float)g_settings.m_ResInfo[m_Resolution].Overscan.right - fToPosX;
  801. @@ -608,7 +613,7 @@ void CGraphicContext::SetScalingResolution(RESOLUTION res, bool needsScaling)
  802. Unlock();
  803. }
  804.  
  805. -void CGraphicContext::SetRenderingResolution(RESOLUTION res, bool needsScaling)
  806. +void CGraphicContext::SetRenderingResolution(const RESOLUTION_INFO &res, bool needsScaling)
  807. {
  808. Lock();
  809. SetScalingResolution(res, needsScaling);
  810. @@ -631,16 +636,10 @@ void CGraphicContext::InvertFinalCoords(float &x, float &y) const
  811.  
  812. float CGraphicContext::GetScalingPixelRatio() const
  813. {
  814. - if (m_Resolution == m_windowResolution)
  815. - return GetPixelRatio(m_windowResolution);
  816. -
  817. - RESOLUTION checkRes = m_windowResolution;
  818. - if (checkRes == RES_INVALID)
  819. - checkRes = m_Resolution;
  820. - // resolutions are different - we want to return the aspect ratio of the video resolution
  821. + // assume the resolutions are different - we want to return the aspect ratio of the video resolution
  822. // but only once it's been corrected for the skin -> screen coordinates scaling
  823. - float winWidth = (float)g_settings.m_ResInfo[checkRes].iWidth;
  824. - float winHeight = (float)g_settings.m_ResInfo[checkRes].iHeight;
  825. + float winWidth = (float)m_windowResolution.iWidth;
  826. + float winHeight = (float)m_windowResolution.iHeight;
  827. float outWidth = (float)g_settings.m_ResInfo[m_Resolution].iWidth;
  828. float outHeight = (float)g_settings.m_ResInfo[m_Resolution].iHeight;
  829. float outPR = GetPixelRatio(m_Resolution);
  830. @@ -656,9 +655,8 @@ void CGraphicContext::SetCameraPosition(const CPoint &camera)
  831. if (m_origins.size())
  832. cam += m_origins.top();
  833.  
  834. - RESOLUTION windowRes = (m_windowResolution == RES_INVALID) ? m_Resolution : m_windowResolution;
  835. - cam.x *= (float)m_iScreenWidth / g_settings.m_ResInfo[windowRes].iWidth;
  836. - cam.y *= (float)m_iScreenHeight / g_settings.m_ResInfo[windowRes].iHeight;
  837. + cam.x *= (float)m_iScreenWidth / m_windowResolution.iWidth;
  838. + cam.y *= (float)m_iScreenHeight / m_windowResolution.iHeight;
  839.  
  840. m_cameras.push(cam);
  841. UpdateCameraPosition(m_cameras.top());
  842. diff --git a/xbmc/guilib/GraphicContext.h b/xbmc/guilib/GraphicContext.h
  843. index 1936a36..6fd1462 100644
  844. --- a/xbmc/guilib/GraphicContext.h
  845. +++ b/xbmc/guilib/GraphicContext.h
  846. @@ -102,8 +102,9 @@ public:
  847. void GetAllowedResolutions(std::vector<RESOLUTION> &res);
  848.  
  849. // output scaling
  850. - void SetRenderingResolution(RESOLUTION res, bool needsScaling); ///< Sets scaling up for rendering
  851. - void SetScalingResolution(RESOLUTION res, bool needsScaling); ///< Sets scaling up for skin loading etc.
  852. + const RESOLUTION_INFO &GetResInfo() const;
  853. + void SetRenderingResolution(const RESOLUTION_INFO &res, bool needsScaling); ///< Sets scaling up for rendering
  854. + void SetScalingResolution(const RESOLUTION_INFO &res, bool needsScaling); ///< Sets scaling up for skin loading etc.
  855. float GetScalingPixelRatio() const;
  856. void Flip();
  857. void InvertFinalCoords(float &x, float &y) const;
  858. @@ -203,7 +204,7 @@ protected:
  859. private:
  860. void UpdateCameraPosition(const CPoint &camera);
  861. void UpdateFinalTransform(const TransformMatrix &matrix);
  862. - RESOLUTION m_windowResolution;
  863. + RESOLUTION_INFO m_windowResolution;
  864. float m_guiScaleX;
  865. float m_guiScaleY;
  866. std::stack<CPoint> m_cameras;
  867. diff --git a/xbmc/guilib/Resolution.h b/xbmc/guilib/Resolution.h
  868. index 6e902f3..dc8fbc4 100644
  869. --- a/xbmc/guilib/Resolution.h
  870. +++ b/xbmc/guilib/Resolution.h
  871. @@ -92,12 +92,20 @@ struct RESOLUTION_INFO
  872. CStdString strMode;
  873. CStdString strOutput;
  874. CStdString strId;
  875. - public:
  876. - RESOLUTION_INFO()
  877. +public:
  878. + RESOLUTION_INFO(int width = 1280, int height = 720, float aspect = 0, const CStdString &mode = "")
  879. + {
  880. + iWidth = width;
  881. + iHeight = height;
  882. + fPixelRatio = aspect ? ((float)width)/height / aspect : 1.0f;
  883. + strMode = mode;
  884. + bFullScreen = true;
  885. + fRefreshRate = 0;
  886. + dwFlags = iSubtitles = iScreen = 0;
  887. + }
  888. + float DisplayRatio() const
  889. {
  890. - bFullScreen = false;
  891. - iScreen = iWidth = iHeight = iSubtitles = dwFlags = 0;
  892. - fPixelRatio = fRefreshRate = 0.f;
  893. + return iWidth * fPixelRatio / iHeight;
  894. }
  895. RESOLUTION_INFO(const RESOLUTION_INFO& res)
  896. {
  897. diff --git a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
  898. index f932810..33ee405 100644
  899. --- a/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
  900. +++ b/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
  901. @@ -51,7 +51,6 @@ CGUIPythonWindowXML::CGUIPythonWindowXML(int id, CStdString strXML, CStdString s
  902. m_threadState = NULL;
  903. m_actionEvent = CreateEvent(NULL, true, false, NULL);
  904. m_loadOnDemand = false;
  905. - m_coordsRes = RES_PAL_4x3;
  906. m_scriptPath = strFallBackPath;
  907. }
  908.  
  909. diff --git a/xbmc/interfaces/python/xbmcmodule/window.cpp b/xbmc/interfaces/python/xbmcmodule/window.cpp
  910. index 12e35e6..b7cd80c 100644
  911. --- a/xbmc/interfaces/python/xbmcmodule/window.cpp
  912. +++ b/xbmc/interfaces/python/xbmcmodule/window.cpp
  913. @@ -30,6 +30,7 @@
  914. #include "guilib/GUICheckMarkControl.h"
  915. #include "guilib/GUIRadioButtonControl.h"
  916. #include "guilib/GUIWindowManager.h"
  917. +#include "settings/Settings.h"
  918. #include "Application.h"
  919. #include "threads/SingleLock.h"
  920.  
  921. @@ -853,7 +854,7 @@ namespace PYXBMC
  922. }
  923.  
  924. CSingleLock lock(g_graphicsContext);
  925. - self->pWindow->SetCoordsRes((RESOLUTION)res);
  926. + self->pWindow->SetCoordsRes(g_settings.m_ResInfo[res]);
  927.  
  928. Py_INCREF(Py_None);
  929. return Py_None;
  930. diff --git a/xbmc/interfaces/python/xbmcmodule/winxml.cpp b/xbmc/interfaces/python/xbmcmodule/winxml.cpp
  931. index 34c0f56..c64ab94 100644
  932. --- a/xbmc/interfaces/python/xbmcmodule/winxml.cpp
  933. +++ b/xbmc/interfaces/python/xbmcmodule/winxml.cpp
  934. @@ -75,7 +75,7 @@ namespace PYXBMC
  935. if (pyRes) PyXBMCGetUnicodeString(resolution, pyRes);
  936.  
  937. // Check to see if the XML file exists in current skin. If not use fallback path to find a skin for the script
  938. - RESOLUTION res = RES_INVALID;
  939. + RESOLUTION_INFO res;
  940. CStdString strSkinPath = g_SkinInfo->GetSkinPath(strXMLname, &res);
  941.  
  942. if (!XFILE::CFile::Exists(strSkinPath))
  943. @@ -90,7 +90,8 @@ namespace PYXBMC
  944. // Finally fallback to the DefaultSkin as it didn't exist in either the XBMC Skin folder or the fallback skin folder
  945. CStdString str("none");
  946. AddonProps props(str, ADDON_SKIN, "", "");
  947. - CSkinInfo skinInfo(props, CSkinInfo::TranslateResolution(resolution, RES_HDTV_720p));
  948. + CSkinInfo::TranslateResolution(resolution, res);
  949. + CSkinInfo skinInfo(props, res);
  950. basePath = URIUtils::AddFileToFolder(fallbackPath, strDefault);
  951.  
  952. skinInfo.Start(basePath);
  953. diff --git a/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp b/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp
  954. index 79fb3d3..4c13a85 100644
  955. --- a/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp
  956. +++ b/xbmc/interfaces/python/xbmcmodule/winxmldialog.cpp
  957. @@ -76,7 +76,7 @@ namespace PYXBMC
  958. if (pyRes) PyXBMCGetUnicodeString(resolution, pyRes);
  959.  
  960. // Check to see if the XML file exists in current skin. If not use fallback path to find a skin for the script
  961. - RESOLUTION res = RES_INVALID;
  962. + RESOLUTION_INFO res;
  963. CStdString strSkinPath = g_SkinInfo->GetSkinPath(strXMLname, &res);
  964.  
  965. if (!XFILE::CFile::Exists(strSkinPath))
  966. @@ -91,7 +91,8 @@ namespace PYXBMC
  967. // Finally fallback to the DefaultSkin as it didn't exist in either the XBMC Skin folder or the fallback skin folder
  968. CStdString str("none");
  969. AddonProps props(str, ADDON_SKIN, "", "");
  970. - CSkinInfo skinInfo(props, CSkinInfo::TranslateResolution(resolution, RES_HDTV_720p));
  971. + CSkinInfo::TranslateResolution(resolution, res);
  972. + CSkinInfo skinInfo(props, res);
  973.  
  974. CStdString basePath = URIUtils::AddFileToFolder(fallbackPath, strDefault);
  975. skinInfo.Start(basePath);
  976. diff --git a/xbmc/music/karaoke/karaokelyricstext.cpp b/xbmc/music/karaoke/karaokelyricstext.cpp
  977. index bd1b419..bd07f2c 100644
  978. --- a/xbmc/music/karaoke/karaokelyricstext.cpp
  979. +++ b/xbmc/music/karaoke/karaokelyricstext.cpp
  980. @@ -315,7 +315,7 @@ void CKaraokeLyricsText::Render()
  981.  
  982. // Calculate drawing parameters
  983. RESOLUTION resolution = g_graphicsContext.GetVideoResolution();
  984. - g_graphicsContext.SetRenderingResolution(resolution, false);
  985. + g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false);
  986. float maxWidth = (float) g_settings.m_ResInfo[resolution].Overscan.right - g_settings.m_ResInfo[resolution].Overscan.left;
  987.  
  988. // We must only fall through for STATE_DRAW_SYLLABLE or STATE_PREAMBLE
  989. diff --git a/xbmc/utils/Splash.cpp b/xbmc/utils/Splash.cpp
  990. index 274dac9..572c5af 100644
  991. --- a/xbmc/utils/Splash.cpp
  992. +++ b/xbmc/utils/Splash.cpp
  993. @@ -52,7 +52,8 @@ void CSplash::Show()
  994. g_graphicsContext.Lock();
  995. g_graphicsContext.Clear();
  996.  
  997. - g_graphicsContext.SetRenderingResolution(RES_HDTV_720p, true);
  998. + RESOLUTION_INFO res(1280,720,0);
  999. + g_graphicsContext.SetRenderingResolution(res, true);
  1000. CGUIImage* image = new CGUIImage(0, 0, 0, 0, 1280, 720, m_ImageName);
  1001. image->SetAspectRatio(CAspectRatio::AR_CENTER);
  1002. image->AllocResources();
  1003. diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp
  1004. index f143641..ddcd229 100644
  1005. --- a/xbmc/video/windows/GUIWindowFullScreen.cpp
  1006. +++ b/xbmc/video/windows/GUIWindowFullScreen.cpp
  1007. @@ -586,8 +586,9 @@ bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message)
  1008. fontPath += g_guiSettings.GetString("subtitles.font");
  1009.  
  1010. // We scale based on PAL4x3 - this at least ensures all sizing is constant across resolutions.
  1011. - CGUIFont *subFont = g_fontManager.LoadTTF("__subtitle__", fontPath, color[g_guiSettings.GetInt("subtitles.color")], 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), false, 1.0f, 1.0f, RES_PAL_4x3, true);
  1012. - CGUIFont *borderFont = g_fontManager.LoadTTF("__subtitleborder__", fontPath, 0xFF000000, 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), true, 1.0f, 1.0f, RES_PAL_4x3, true);
  1013. + RESOLUTION_INFO pal(720, 576, 0);
  1014. + CGUIFont *subFont = g_fontManager.LoadTTF("__subtitle__", fontPath, color[g_guiSettings.GetInt("subtitles.color")], 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), false, 1.0f, 1.0f, &pal, true);
  1015. + CGUIFont *borderFont = g_fontManager.LoadTTF("__subtitleborder__", fontPath, 0xFF000000, 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), true, 1.0f, 1.0f, &pal, true);
  1016. if (!subFont || !borderFont)
  1017. CLog::Log(LOGERROR, "CGUIWindowFullScreen::OnMessage(WINDOW_INIT) - Unable to load subtitle font");
  1018. else
  1019. @@ -880,7 +881,7 @@ void CGUIWindowFullScreen::RenderTTFSubtitles()
  1020. subtitleText.Replace("</u", "");
  1021.  
  1022. RESOLUTION res = g_graphicsContext.GetVideoResolution();
  1023. - g_graphicsContext.SetRenderingResolution(res, false);
  1024. + g_graphicsContext.SetRenderingResolution(g_graphicsContext.GetResInfo(), false);
  1025.  
  1026. float maxWidth = (float) g_settings.m_ResInfo[res].Overscan.right - g_settings.m_ResInfo[res].Overscan.left;
  1027. m_subsLayout->Update(subtitleText, maxWidth * 0.9f, false, true); // true to force LTR reading order (most Hebrew subs are this format)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement