before_code stringlengths 14 465k | reviewer_comment stringlengths 16 64.5k | after_code stringlengths 9 467k | diff_context stringlengths 0 97k | file_path stringlengths 5 226 | comment_line int32 0 26 | language stringclasses 37
values | quality_score float32 0.07 1 | comment_type stringclasses 9
values | comment_length int32 16 64.5k | before_lines int32 1 17.2k | after_lines int32 1 12.1k | is_negative bool 2
classes | pr_title stringlengths 1 308 | pr_number int32 1 299k | repo_name stringclasses 533
values | repo_stars int64 321 419k | repo_language stringclasses 27
values | reviewer_username stringlengths 0 39 | author_username stringlengths 2 39 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
package com.wolt.blurhashapp
import android.os.Bundle
import android.os.SystemClock
import android.view.View
import android.widget.EditText
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.wolt.blurhashkt.BlurHashDecoder
import kotlinx.android.synthetic.main.activity_main.*
c... | Why not replace the `findViewById`s in this file with Kotlin synthetics as well | package com.wolt.blurhashapp
import android.graphics.Bitmap
import android.os.Bundle
import android.os.SystemClock
import androidx.appcompat.app.AppCompatActivity
import com.wolt.blurhashkt.BlurHashDecoder
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override f... | @@ -16,8 +17,11 @@ class MainActivity : AppCompatActivity() {
val etInput: EditText = findViewById(R.id.etInput)
val ivResult: ImageView = findViewById(R.id.ivResult)
findViewById<View>(R.id.tvDecode).setOnClickListener { | Kotlin/demo/src/main/java/com/wolt/blurhashapp/MainActivity.kt | 19 | Kotlin | 0.429 | suggestion | 79 | 29 | 36 | false | Kotlin optimize | 66 | woltapp/blurhash | 6,602 | C | connyduck | ignaciotcrespo |
package com.wolt.blurhashkt
import android.graphics.Bitmap
import android.graphics.Color
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.withSign
object BlurHashDecoder {
// cache Math.cos() calculations to improve performance.
// The number of calculations can be huge for many bitmaps: widt... | I see the cache is being clear only in test, so I have a few questions regarding this function:
- Can the test work without clearing the cache? Would this create some kind of cache conflict when decoding multiple image with the same `width * numCompX` and `height * numCompY`?
- If it does need clearing, when should u... | package com.wolt.blurhashkt
import android.graphics.Bitmap
import android.graphics.Color
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.withSign
object BlurHashDecoder {
// cache Math.cos() calculations to improve performance.
// The number of calculations can be huge for many bitmaps: widt... | @@ -2,14 +2,25 @@ package com.wolt.blurhashkt
import android.graphics.Bitmap
import android.graphics.Color
-import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.withSign
object BlurHashDecoder {
- fun decode(blurHash: String?, width: Int, height: Int, punch: Float = 1f):... | Kotlin/lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt | 25 | Kotlin | 0.643 | performance | 333 | 50 | 50 | false | Kotlin optimize | 66 | woltapp/blurhash | 6,602 | C | hangduykhiem | ignaciotcrespo |
j: Int,
numCompY: Int,
y: Int,
height: Int
): Double {
if (calculateCosY) {
cosinesY[j + numCompY * y] = cos(Math.PI * y * j / height)
}
return cosinesY[j + numCompY * y]
}
private fun getCosX(
calculateCosX: Bo... | Understanding that this is a get function for val `cosinesX`, but the naming of functions `getCosX` and `getCosinesX` is quite confusing first time I tried digging through the code. Same with `getCosinesY` and `getCosY`. | cacheCosinesY[height * numCompY] = it
}
}
else -> {
cacheCosinesY[height * numCompY]!!
}
}
private fun getArrayForCosinesX(calculate: Boolean, width: Int, numCompX: Int) = when {
calculate -> {
DoubleArray(width * numCompX).als... | @@ -77,27 +88,85 @@ object BlurHashDecoder {
private fun composeBitmap(
width: Int, height: Int,
numCompX: Int, numCompY: Int,
- colors: Array<FloatArray>
+ colors: Array<FloatArray>,
+ useCache: Boolean
): Bitmap {
- val bitmap = Bitmap.create... | Kotlin/lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt | 26 | Kotlin | 0.571 | style | 220 | 51 | 51 | false | Kotlin optimize | 66 | woltapp/blurhash | 6,602 | C | hangduykhiem | ignaciotcrespo |
package com.wolt.blurhashkt
import android.graphics.Bitmap
import android.graphics.Color
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.withSign
object BlurHashDecoder {
// cache Math.cos() calculations to improve performance.
// The number of calculations can be huge for many bitmaps: widt... | ```suggestion
```
I see other functions you wrote don't have the blank line. | package com.wolt.blurhashkt
import android.graphics.Bitmap
import android.graphics.Color
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.withSign
object BlurHashDecoder {
// cache Math.cos() calculations to improve performance.
// The number of calculations can be huge for many bitmaps: widt... | @@ -2,14 +2,25 @@ package com.wolt.blurhashkt
import android.graphics.Bitmap
import android.graphics.Color
-import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.withSign
object BlurHashDecoder {
- fun decode(blurHash: String?, width: Int, height: Int, punch: Float = 1f):... | Kotlin/lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt | 23 | Kotlin | 0.571 | suggestion | 80 | 48 | 48 | false | Kotlin optimize | 66 | woltapp/blurhash | 6,602 | C | hangduykhiem | ignaciotcrespo |
@Test
fun decode_smallImage_cacheEnabled_shouldGetTheSameBitmapInManyRequests() {
val bmp1 = decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 20, 12)!!
val bmp2 = decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 20, 12)!!
val bmp3 = decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 20, 12)!!
bmp1.assertEquals... | No issues found. | @Test
fun decode_smallImage_cacheEnabled_shouldGetTheSameBitmapInManyRequests() {
val bmp1 = decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 20, 12)!!
val bmp2 = decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 20, 12)!!
val bmp3 = decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 20, 12)!!
bmp1.assertEquals... | @@ -0,0 +1,88 @@
+package com.wolt.blurhashkt
+
+import android.graphics.Bitmap
+import com.wolt.blurhashkt.BlurHashDecoder.clearCache
+import com.wolt.blurhashkt.BlurHashDecoder.decode
+import junit.framework.Assert.assertTrue
+import org.junit.Before
+import org.junit.Test
+import java.nio.ByteBuffer
+import java.uti... | Kotlin/lib/src/androidTest/java/com/wolt/blurhashkt/BlurHashDecoderTest.kt | 0 | Kotlin | 1 | none | 16 | 51 | 51 | true | Kotlin optimize | 66 | woltapp/blurhash | 6,602 | C | ignaciotcrespo | |
#ifndef MOUSE_STAT_H
#define MOUSE_STAT_H
/*
* Copyright (C) 2005-2013 Team XBMC
* http://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 ... | Please re-align the MOUSE_BUTTON enum (like MOUSE_STATE). That line is way too long ;)
| #ifndef MOUSE_STAT_H
#define MOUSE_STAT_H
/*
* Copyright (C) 2005-2013 Team XBMC
* http://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 ... | @@ -32,20 +32,24 @@
#define XBMC_BUTTON_WHEELDOWN 5
#define XBMC_BUTTON_X1 6
#define XBMC_BUTTON_X2 7
+#define XBMC_BUTTON_X3 8
+#define XBMC_BUTTON_X4 9
#define XBMC_BUTTON_LMASK XBMC_BUTTON(XBMC_BUTTON_LEFT)
#define XBMC_BUTTON_MMASK XBMC_BUTTON(XBMC_BUTTON_MIDDLE)
#define XBMC_BUTTON_RMASK XBMC_BUTTON(XBMC... | xbmc/input/MouseStat.h | 0 | C/C++ | 0.357 | refactor | 87 | 188 | 206 | false | mouse: Increase number of buttons supported from 5 to 7 | 6,579 | xbmc/xbmc | 17,740 | C++ | mkortstiege | cjmayo |
CWinRenderer::CWinRenderer()
: CBaseRenderer()
, m_bConfigured(false)
, m_bUseHQScaler(false)
, m_bFilterInitialized(false)
, m_cmsOn(false)
, m_clutLoaded(true)
, m_toneMapping(false)
, m_destWidth(0)
, m_destHeight(0)
, m_frameIdx(0)
, m_iYV12RenderBuffer(0)
, m_NumYV12... | use default member initializers | , m_bConfigured(false)
, m_bUseHQScaler(false)
, m_bFilterInitialized(false)
, m_cmsOn(false)
, m_clutLoaded(true)
, m_toneMapping(false)
, m_destWidth(0)
, m_destHeight(0)
, m_frameIdx(0)
, m_iYV12RenderBuffer(0)
, m_NumYV12Buffers(0)
, m_neededBuffers(0)
, m_iRequestedMethod(RENDER_METHOD_AU... | @@ -62,31 +63,32 @@ bool CWinRenderer::Register()
return true;
}
-CWinRenderer::CWinRenderer() : CBaseRenderer()
- , m_bConfigured(false)
- , m_bUseHQScaler(false)
- , m_bFilterInitialized(false)
- , m_cmsOn(false)
- , m_clutLoaded(true)
- , m_toneMapping(false)
- , m_destWidth(0)
- , m_destHeight(0)
- ,... | xbmc/cores/VideoPlayer/VideoRenderers/WinRenderer.cpp | 26 | C++ | 0.286 | suggestion | 31 | 51 | 51 | false | VideoPlayer: WinRenderer - add smooth motion | 14,278 | xbmc/xbmc | 17,740 | C++ | Rechi | afedchin |
while (!m_pDS->eof())
{
artTypes.emplace_back(m_pDS->fv(0).get_asString());
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;
}
std::vector<std::string> CMusicDatabase::GetA... | Better as a doxygen `//! @todo`
Maybe raise a roadmap issue too for artist fanart to be handled along with all the other types of art, so it does not get forgotten |
while (!m_pDS->eof())
{
artTypes.emplace_back(m_pDS->fv(0).get_asString());
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;
}
std::vector<std::string> CMusicDatabase::GetA... | @@ -10231,6 +10231,48 @@ bool CMusicDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+std::vector<std::string> CMusicDatabase::GetAvailableArtTypesForItem(int mediaId,
+ const MediaType& mediaType)
+{
+ std::vector<std::string> result;
+ if (mediaType == MediaTypeArtist)
+ ... | xbmc/music/MusicDatabase.cpp | 26 | C++ | 1 | suggestion | 166 | 51 | 51 | false | Include user config and available artwork in music "Choose art type" dialog | 15,805 | xbmc/xbmc | 17,740 | C++ | DaveTBlake | rmrector |
If info is found, update the database and artwork with the new
information.
\param album [in/out] the album to update
\param scraper [in] the album scraper to use
\param bAllowSelection [in] should we allow the user to manually override the info with a GUI if the album is not found?
\param pDialog [in] a pr... | Now used by MusicUtils.cpp I wonder if this would be better moved there, and thus CMusicInfoScanner depending on MusicUtils rather than vica versa? | If info is found, update the database and artwork with the new
information.
\param album [in/out] the album to update
\param scraper [in] the album scraper to use
\param bAllowSelection [in] should we allow the user to manually override the info with a GUI if the album is not found?
\param pDialog [in] a pr... | @@ -74,6 +74,13 @@ class CMusicInfoScanner : public IRunnable, public CInfoScanner
*/
INFO_RET UpdateArtistInfo(CArtist& artist, const ADDON::ScraperPtr& scraper, bool bAllowSelection, CGUIDialogProgress* pDialog = NULL);
+ /*! \brief Get the types of art for an artist or album that are to be
+ automatically ... | xbmc/music/infoscanner/MusicInfoScanner.h | 26 | C/C++ | 0.5 | question | 147 | 51 | 51 | false | Include user config and available artwork in music "Choose art type" dialog | 15,805 | xbmc/xbmc | 17,740 | C++ | DaveTBlake | rmrector |
return true;
}
};
void UpdateArtJob(const CFileItemPtr pItem, const std::string& strType, const std::string& strArt)
{
// Asynchronously update that type of art in the database
CSetArtJob *job = new CSetArtJob(pItem, strType, strArt);
CJobManager::GetInstance().AddJob(job, NULL);
}
//... | GetArtTypesToScan is not in CMusicInfoScanner any more!
I suggest you correct and then squash the commits | return true;
}
};
void UpdateArtJob(const CFileItemPtr pItem, const std::string& strType, const std::string& strArt)
{
// Asynchronously update that type of art in the database
CSetArtJob *job = new CSetArtJob(pItem, strType, strArt);
CJobManager::GetInstance().AddJob(job, NULL);
}
// ... | @@ -177,42 +181,84 @@ namespace MUSIC_UTILS
CJobManager::GetInstance().AddJob(job, NULL);
}
- bool FillArtTypesList(CFileItem& musicitem, CFileItemList& artlist)
+ // Add art types required in Kodi
+ void AddHardCodedArtTypes(std::vector<std::string>& artTypes, const CMusicInfoTag& tag)
{
- CMusicInf... | xbmc/music/MusicUtils.cpp | 26 | C++ | 0.786 | suggestion | 106 | 51 | 51 | false | Include user config and available artwork in music "Choose art type" dialog | 15,805 | xbmc/xbmc | 17,740 | C++ | DaveTBlake | rmrector |
/*
* Copyright (C) 2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "MusicUtils.h"
#include "Application.h"
#include "dialogs/GUIDialogSelect.h"
#include "guilib/GUIKeyboardFactory.h"
#include... | Unneeded now dependancy other way around | /*
* Copyright (C) 2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "MusicUtils.h"
#include "Application.h"
#include "dialogs/GUIDialogSelect.h"
#include "guilib/GUIKeyboardFactory.h"
#include... | @@ -14,10 +14,14 @@
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
#include "music/MusicDatabase.h"
+#include "music/infoscanner/MusicInfoScanner.h" | xbmc/music/MusicUtils.cpp | 17 | C++ | 0.071 | suggestion | 40 | 42 | 42 | false | Include user config and available artwork in music "Choose art type" dialog | 15,805 | xbmc/xbmc | 17,740 | C++ | DaveTBlake | rmrector |
if (numRows <= 0)
return numRows == 0;
while (!m_pDS->eof())
{
artTypes.emplace_back(m_pDS->fv(0).get_asString());
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;... | Use the constant iterators `cbegin` and `cend`. | if (numRows <= 0)
return numRows == 0;
while (!m_pDS->eof())
{
artTypes.emplace_back(m_pDS->fv(0).get_asString());
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
{
artTypes.emplace_back(m_pDS->fv(0).get_asString());
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;
}
namespace
{
std::vector<std::string> GetBasicItemAvailableArtTypes(const... | Use urlEntry as a reference in the range-based for loop. | {
artTypes.emplace_back(m_pDS->fv(0).get_asString());
m_pDS->next();
}
m_pDS->close();
return true;
}
catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;
}
namespace
{
std::vector<std::string> GetBasicItemAvailableArtTypes(const... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.357 | suggestion | 56 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;
}
namespace
{
std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
{
std::vector<std::string> result;
//! @todo artwork: fanart stored separately, doesn't need to be
if (t... | Use the constant iterators `cbegin` and `cend`. | catch (...)
{
CLog::Log(LOGERROR, "%s(%s) failed", __FUNCTION__, mediaType.c_str());
}
return false;
}
namespace
{
std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
{
std::vector<std::string> result;
//! @todo artwork: fanart stored separately, doesn't need to be
if (t... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
// all other images
for (const auto urlEntry : tag.m_strPictureURL.m_url)
{
std::string artType = urlEntry.m_aspect;
if (artType.empty())
artType = tag.m_type == MediaTypeEpisode ? "thumb" : "poster";
if (urlEntry.m_type == CScraperUrl::URL_TYPE_GENERAL && // exclude season artwork for TV shows
... | Use urlEntry as a reference in the range-based for loop. | // all other images
for (const auto& urlEntry : tag.m_strPictureURL.m_url)
{
std::string artType = urlEntry.m_aspect;
if (artType.empty())
artType = tag.m_type == MediaTypeEpisode ? "thumb" : "poster";
if (urlEntry.m_type == CScraperUrl::URL_TYPE_GENERAL && // exclude season artwork for TV shows... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.357 | suggestion | 56 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
if (urlEntry.m_type == CScraperUrl::URL_TYPE_GENERAL && // exclude season artwork for TV shows
!StringUtils::StartsWith(artType, "set.") && // exclude movie set artwork for movies
std::find(result.begin(), result.end(), artType) == result.end())
{
result.push_back(artType);
}
}
return ... | Use the constant iterators `cbegin` and `cend`. | if (urlEntry.m_type == CScraperUrl::URL_TYPE_GENERAL && // exclude season artwork for TV shows
!StringUtils::StartsWith(artType, "set.") && // exclude movie set artwork for movies
std::find(result.cbegin(), result.cend(), artType) == result.cend())
{
result.push_back(artType);
}
}
retu... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
if (artType.empty())
artType = "poster";
if (urlEntry.m_type == CScraperUrl::URL_TYPE_SEASON && urlEntry.m_season == tag.m_iSeason &&
std::find(result.begin(), result.end(), artType) == result.end())
{
result.push_back(artType);
}
}
return result;
}
std::vector<std::string> GetMov... | Use the constant iterators `cbegin` and `cend`. | if (artType.empty())
artType = "poster";
if (urlEntry.m_type == CScraperUrl::URL_TYPE_SEASON && urlEntry.m_season == tag.m_iSeason &&
std::find(result.cbegin(), result.cend(), artType) == result.cend())
{
result.push_back(artType);
}
}
return result;
}
std::vector<std::string> Get... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
}
}
return result;
}
std::vector<std::string> GetMovieSetAvailableArtTypes(int mediaId, CVideoDatabase& db)
{
std::vector<std::string> result;
CFileItemList items;
std::string baseDir = StringUtils::Format("videodb://movies/sets/%d", mediaId);
if (db.GetMoviesNav(baseDir, items))
{
for (const aut... | Use urlEntry as a reference in the range-based for loop. | }
}
return result;
}
std::vector<std::string> GetMovieSetAvailableArtTypes(int mediaId, CVideoDatabase& db)
{
std::vector<std::string> result;
CFileItemList items;
std::string baseDir = StringUtils::Format("videodb://movies/sets/%d", mediaId);
if (db.GetMoviesNav(baseDir, items))
{
for (const aut... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.357 | suggestion | 56 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
CFileItemList items;
std::string baseDir = StringUtils::Format("videodb://movies/sets/%d", mediaId);
if (db.GetMoviesNav(baseDir, items))
{
for (const auto& item : items)
{
CVideoInfoTag* pTag = item->GetVideoInfoTag();
pTag->m_strPictureURL.Parse();
//! @todo artwork: fanart stored se... | Use the constant iterators `cbegin` and `cend`. | CFileItemList items;
std::string baseDir = StringUtils::Format("videodb://movies/sets/%d", mediaId);
if (db.GetMoviesNav(baseDir, items))
{
for (const auto& item : items)
{
CVideoInfoTag* pTag = item->GetVideoInfoTag();
pTag->m_strPictureURL.Parse();
//! @todo artwork: fanart stored se... | @@ -4668,6 +4668,117 @@ bool CVideoDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
return false;
}
+namespace
+{
+std::vector<std::string> GetBasicItemAvailableArtTypes(const CVideoInfoTag& tag)
+{
+ std::vector<std::string> result;
+
+ //! @todo artwork: fanart stored separately, doesn't ... | xbmc/video/VideoDatabase.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
if (m_movieItem->GetVideoInfoTag()->m_strFileNameAndPath.empty())
movie.SetPath(m_movieItem->GetPath());
CGUIWindowVideoNav* pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowVideoNav>(WINDOW_VIDEO_NAV);
if (pWindow)
{
// close our dialog
Close(true);
if (resume)
m... | Use the constant iterators `cbegin` and `cend`. | if (m_movieItem->GetVideoInfoTag()->m_strFileNameAndPath.empty())
movie.SetPath(m_movieItem->GetPath());
CGUIWindowVideoNav* pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowVideoNav>(WINDOW_VIDEO_NAV);
if (pWindow)
{
// close our dialog
Close(true);
if (resume)
m... | @@ -620,7 +620,72 @@ void CGUIDialogVideoInfo::Play(bool resume)
}
}
-std::string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, std::map<std::string, std::string> ¤tArt)
+namespace {
+// Add art types required in Kodi and configured by the user
+void AddHardCodedAndExtendedArtTypes(std::vec... | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
return;
}
pWindow->PlayMovie(&movie);
}
}
namespace {
// Add art types required in Kodi and configured by the user
void AddHardCodedAndExtendedArtTypes(std::vector<std::string>& artTypes, const CVideoInfoTag& tag)
{
for (const auto& artType : CVideoThumbLoader::GetArtTypes(tag.m_type))
{
if (fi... | Use the constant iterators `cbegin` and `cend`. | return;
}
pWindow->PlayMovie(&movie);
}
}
namespace
{
// Add art types required in Kodi and configured by the user
void AddHardCodedAndExtendedArtTypes(std::vector<std::string>& artTypes, const CVideoInfoTag& tag)
{
for (const auto& artType : CVideoThumbLoader::GetArtTypes(tag.m_type))
{
if (fi... | @@ -620,7 +620,72 @@ void CGUIDialogVideoInfo::Play(bool resume)
}
}
-std::string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, std::map<std::string, std::string> ¤tArt)
+namespace {
+// Add art types required in Kodi and configured by the user
+void AddHardCodedAndExtendedArtTypes(std::vec... | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
artTypes.emplace_back(artType);
}
}
// Add art types currently assigned to the media item
void AddCurrentArtTypes(std::vector<std::string>& artTypes, const CVideoInfoTag& tag,
CVideoDatabase& db)
{
std::map<std::string, std::string> currentArt;
db.GetArtForItem(tag.m_iDbId, tag.m_type, currentArt);
for... | Use the constant iterators `cbegin` and `cend`. | if (find(artTypes.cbegin(), artTypes.cend(), artType) == artTypes.cend())
artTypes.emplace_back(artType);
}
}
// Add art types currently assigned to the media item
void AddCurrentArtTypes(std::vector<std::string>& artTypes, const CVideoInfoTag& tag,
CVideoDatabase& db)
{
std::map<std::string, std::stri... | @@ -620,7 +620,72 @@ void CGUIDialogVideoInfo::Play(bool resume)
}
}
-std::string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, std::map<std::string, std::string> ¤tArt)
+namespace {
+// Add art types required in Kodi and configured by the user
+void AddHardCodedAndExtendedArtTypes(std::vec... | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
{
if (!art.second.empty() && find(artTypes.begin(), artTypes.end(), art.first) == artTypes.end())
artTypes.push_back(art.first);
}
}
// Add art types that exist for other media items of the same type
void AddMediaTypeArtTypes(std::vector<std::string>& artTypes, const CVideoInfoTag& tag,
CVideoDatabase&... | Use the constant iterators `cbegin` and `cend`. | for (const auto& art : currentArt)
{
if (!art.second.empty() && find(artTypes.cbegin(), artTypes.cend(), art.first) == artTypes.cend())
artTypes.push_back(art.first);
}
}
// Add art types that exist for other media items of the same type
void AddMediaTypeArtTypes(std::vector<std::string>& artTypes, con... | @@ -620,7 +620,72 @@ void CGUIDialogVideoInfo::Play(bool resume)
}
}
-std::string CGUIDialogVideoInfo::ChooseArtType(const CFileItem &videoItem, std::map<std::string, std::string> ¤tArt)
+namespace {
+// Add art types required in Kodi and configured by the user
+void AddHardCodedAndExtendedArtTypes(std::vec... | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 26 | C++ | 0.5 | suggestion | 47 | 51 | 51 | false | Add available artwork to the video 'Choose art type' dialog | 15,857 | xbmc/xbmc | 17,740 | C++ | Rechi | rmrector |
/*
* Copyright (C) 2017-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "RPBaseRenderer.h"
#include "ServiceBroker.h"
#include "windowing/GraphicContext.h"
#include "windowing/WinSystem.h"
#i... | A design constraint is that ServiceBroker.h isn't allowed in this file. See how other singletons are handled. | /*
* Copyright (C) 2017-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "RPBaseRenderer.h"
#include "cores/RetroPlayer/buffers/IRenderBuffer.h"
#include "cores/RetroPlayer/buffers/IRenderBuf... | @@ -7,7 +7,11 @@
*/
#include "RPBaseRenderer.h"
-
+#include "ServiceBroker.h" | xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp | 10 | C++ | 0.571 | suggestion | 109 | 35 | 35 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | garbear | slattann |
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "DRMAtomic.h"
#include "ServiceBroker.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "utils/log.h"
#inc... | please use `CDRMUtils::SupportsProperty`. You may also want to use `CDRMUtils::SupportsPropertyAndValue` | * SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "DRMAtomic.h"
#include "ServiceBroker.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "settings/lib/Setti... | @@ -22,6 +23,24 @@
#include <unistd.h>
using namespace KODI::WINDOWING::GBM;
+bool CDRMAtomic::SetScalingFilter(struct drm_object *object, const char *name, const char *type) {
+ uint32_t w_scale_factor;
+ uint32_t h_scale_factor;
+ for (uint32_t i = 0; i < object->props->count_props; i++)
+ if (!strcmp(obj... | xbmc/windowing/gbm/DRMAtomic.cpp | 26 | C++ | 0.714 | suggestion | 104 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
const std::string CSettings::SETTING_MASTERLOCK_LOCKCODE = "masterlock.lockcode";
const std::string CSettings::SETTING_MASTERLOCK_STARTUPLOCK = "masterlock.startuplock";
const std::string CSettings::SETTING_MASTERLOCK_MAXRETRIES = "masterlock.maxretries";
const std::string CSettings::SETTING_CACHE_HARDDISK = "cache.har... | This doesn't need to live here. Better to put it where it is used. (We have moved away from putting specific settings in CSettings) | const std::string CSettings::SETTING_NETWORK_HTTPPROXYPORT = "network.httpproxyport";
const std::string CSettings::SETTING_NETWORK_HTTPPROXYUSERNAME = "network.httpproxyusername";
const std::string CSettings::SETTING_NETWORK_HTTPPROXYPASSWORD = "network.httpproxypassword";
const std::string CSettings::SETTING_NETWORK_B... | @@ -422,6 +422,7 @@ const std::string CSettings::SETTING_GENERAL_ADDONBROKENFILTER = "general.addonb
const std::string CSettings::SETTING_SOURCE_VIDEOS = "source.videos";
const std::string CSettings::SETTING_SOURCE_MUSIC = "source.music";
const std::string CSettings::SETTING_SOURCE_PICTURES = "source.pictures";
+con... | xbmc/settings/Settings.cpp | 26 | C++ | 0.5 | suggestion | 131 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
dbs.SetVideoSettings(fileItem, vs);
}
else
{
dbs.EraseVideoSettings(fileItem);
}
dbs.Close();
}
}
bool CApplication::IsPlayingFullScreenVideo() const
{
return m_appPlayer.IsPlayingVideo() && CServiceBroker::GetWinSystem()->GetGfxContext().IsFullScreenVideo();
}
bool CApplication::I... | why call this here when it's used in the if block? You can also double up the winsystem call
```
auto winSystem = CServiceBroker::GetWinSystem();
``` | }
}
void CApplication::StoreVideoSettings(const CFileItem &fileItem, CVideoSettings vs)
{
CVideoDatabase dbs;
if (dbs.Open())
{
if (vs != CMediaSettings::GetInstance().GetDefaultVideoSettings())
{
dbs.SetVideoSettings(fileItem, vs);
}
else
{
dbs.EraseVideoSettings(fileItem);
... | @@ -3381,12 +3381,13 @@ bool CApplication::IsFullScreen()
void CApplication::StopPlaying()
{
CGUIComponent *gui = CServiceBroker::GetGUI();
-
+ RESOLUTION_INFO res = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo(); | xbmc/Application.cpp | 26 | C++ | 1 | question | 152 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
}
void CRPBaseRenderer::SetScalingMethod(SCALINGMETHOD method)
{
m_renderSettings.VideoSettings().SetScalingMethod(method);
}
void CRPBaseRenderer::SetStretchMode(STRETCHMODE stretchMode)
{
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
}
void CRPBaseRenderer::SetRenderRotation(unsigned int ... | `scaleMode` vs `scaleMOde`, same below where it's used | }
void CRPBaseRenderer::SetStretchMode(STRETCHMODE stretchMode)
{
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
}
void CRPBaseRenderer::SetRenderRotation(unsigned int rotationDegCCW)
{
m_renderSettings.VideoSettings().SetRenderRotation(rotationDegCCW);
}
void CRPBaseRenderer::ManageRenderAr... | @@ -129,8 +134,10 @@ void CRPBaseRenderer::ManageRenderArea(const IRenderBuffer& renderBuffer)
const unsigned int sourceRotationDegCCW = renderBuffer.GetRotation();
const float sourceAspectRatio =
static_cast<float>(sourceWidth) / static_cast<float>(sourceHeight);
-
+ const SCALINGMETHOD scaleMOde = m_ren... | xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp | 26 | C++ | 0.571 | suggestion | 54 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
#include "utils/log.h"
#include <errno.h>
#include <string.h>
#include <drm_fourcc.h>
#include <drm_mode.h>
#include <unistd.h>
using namespace KODI::WINDOWING::GBM;
const std::string SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
bool CDRMAtomic::SetScalingFilter(struct drm_object* object, c... | please use the new logging format (replace `%s` and `%d` with just `{}`) | #include "utils/log.h"
#include <errno.h>
#include <string.h>
#include <drm_fourcc.h>
#include <drm_mode.h>
#include <unistd.h>
using namespace KODI::WINDOWING::GBM;
const std::string CDRMAtomic::SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
enum drm_scaling_filter
{
DRM_SCALING_FILTER_D... | @@ -22,6 +24,35 @@
#include <unistd.h>
using namespace KODI::WINDOWING::GBM;
+const std::string SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
+bool CDRMAtomic::SetScalingFilter(struct drm_object* object, const char* name, const char* type)
+{
+ uint32_t w_scale_factor;
+ uint32_t h_scale_... | xbmc/windowing/gbm/DRMAtomic.cpp | 26 | C++ | 0.571 | style | 72 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
void CRPBaseRenderer::SetScalingMethod(SCALINGMETHOD method)
{
m_renderSettings.VideoSettings().SetScalingMethod(method);
}
void CRPBaseRenderer::SetStretchMode(STRETCHMODE stretchMode)
{
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
}
void CRPBaseRenderer::SetRenderRotation(unsigned int rot... | drop the `b` from `bhw` as we don't need to prefix with types | void CRPBaseRenderer::SetStretchMode(STRETCHMODE stretchMode)
{
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
}
void CRPBaseRenderer::SetRenderRotation(unsigned int rotationDegCCW)
{
m_renderSettings.VideoSettings().SetRenderRotation(rotationDegCCW);
}
void CRPBaseRenderer::ManageRenderArea(... | @@ -129,8 +134,10 @@ void CRPBaseRenderer::ManageRenderArea(const IRenderBuffer& renderBuffer)
const unsigned int sourceRotationDegCCW = renderBuffer.GetRotation();
const float sourceAspectRatio =
static_cast<float>(sourceWidth) / static_cast<float>(sourceHeight);
-
+ const SCALINGMETHOD scaleMode = m_ren... | xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp | 26 | C++ | 0.643 | suggestion | 61 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
{
m_renderSettings.VideoSettings().SetScalingMethod(method);
}
void CRPBaseRenderer::SetStretchMode(STRETCHMODE stretchMode)
{
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
}
void CRPBaseRenderer::SetRenderRotation(unsigned int rotationDegCCW)
{
m_renderSettings.VideoSettings().SetRenderRo... | we should check for nullptr when getting settings | {
m_renderSettings.VideoSettings().SetRenderStretchMode(stretchMode);
}
void CRPBaseRenderer::SetRenderRotation(unsigned int rotationDegCCW)
{
m_renderSettings.VideoSettings().SetRenderRotation(rotationDegCCW);
}
void CRPBaseRenderer::ManageRenderArea(const IRenderBuffer& renderBuffer)
{
// Get texture paramete... | @@ -129,8 +134,10 @@ void CRPBaseRenderer::ManageRenderArea(const IRenderBuffer& renderBuffer)
const unsigned int sourceRotationDegCCW = renderBuffer.GetRotation();
const float sourceAspectRatio =
static_cast<float>(sourceWidth) / static_cast<float>(sourceHeight);
-
+ const SCALINGMETHOD scaleMode = m_ren... | xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp | 26 | C++ | 0.571 | bug | 49 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
#include <drm_fourcc.h>
#include <drm_mode.h>
#include <unistd.h>
using namespace KODI::WINDOWING::GBM;
const std::string SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
enum drm_scaling_filter
{
DRM_SCALING_FILTER_DEFAULT,
DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
};
uint32_t CDRMAtomic::GetScal... | you can do this in the initialization, no need to add extra lines | #include <drm_fourcc.h>
#include <drm_mode.h>
#include <unistd.h>
using namespace KODI::WINDOWING::GBM;
const std::string CDRMAtomic::SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
enum drm_scaling_filter
{
DRM_SCALING_FILTER_DEFAULT,
DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
};
uint32_t CDRM... | @@ -22,7 +24,52 @@
#include <unistd.h>
using namespace KODI::WINDOWING::GBM;
-
+const std::string SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
+enum drm_scaling_filter
+{
+ DRM_SCALING_FILTER_DEFAULT,
+ DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+uint32_t CDRMAtomic::GetScalingFilterType(c... | xbmc/windowing/gbm/DRMAtomic.cpp | 26 | C++ | 0.143 | suggestion | 65 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | lrusak | slattann |
float zoomAmount = 1.0f;
m_sourceRect.x1 = 0.0f;
m_sourceRect.y1 = 0.0f;
m_sourceRect.x2 = static_cast<float>(sourceWidth);
m_sourceRect.y2 = static_cast<float>(sourceHeight);
if (scaleMode == SCALINGMETHOD::DISPLAY && stretchMode == STRETCHMODE::Original && bhw_filter)
{
RESOLUTION_INFO m_gameRes=m_c... | `CalculateStretchMode()` is duplicated here. It and other CRenderUtils friends encapsulate some pretty extensive math and logic, and I'd prefer calls to each on a single codepath instead of the two branches of an `if`.
The math and logic I stole from VideoPlayer. It was jumbled and full of globals, and I tediously u... | GetScreenDimensions(screenWidth, screenHeight, screenPixelRatio);
}
// Entire target rendering area for the video (including black bars)
const CRect viewRect = m_context.GetViewWindow();
// Calculate pixel ratio and zoom amount
float pixelRatio = 1.0f;
float zoomAmount = 1.0f;
CRenderUtils::Calculat... | @@ -139,32 +146,59 @@ void CRPBaseRenderer::ManageRenderArea(const IRenderBuffer& renderBuffer)
float screenHeight;
float screenPixelRatio;
GetScreenDimensions(screenWidth, screenHeight, screenPixelRatio);
-
- // Entire target rendering area for the video (including black bars)
- const CRect viewRect = m_con... | xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp | 26 | C++ | 0.857 | refactor | 572 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | garbear | slattann |
// Get screen parameters
float screenWidth;
float screenHeight;
float screenPixelRatio;
GetScreenDimensions(screenWidth, screenHeight, screenPixelRatio);
CRect viewRect = m_context.GetViewWindow();
CRect destRect;
float pixelRatio = 1.0f;
float zoomAmount = 1.0f;
m_sourceRect.x1 = 0.0f;
m_sourceR... | Is it safe to set the system to fullscreen 60 times per second? A function named `ManageRenderArea()` which does just geometry calculations shouldn't call into an external system or have non-render-geometry related side effects. | if (scaleMode == SCALINGMETHOD::NEAREST && stretchMode == STRETCHMODE::Original &&
m_context.DisplayHardwareScalingEnabled())
{
screenWidth = sourceWidth;
screenHeight = sourceHeight;
screenPixelRatio = 1.0;
}
else
{
GetScreenDimensions(screenWidth, screenHeight, screenPixelRatio);
}
... | @@ -139,32 +146,59 @@ void CRPBaseRenderer::ManageRenderArea(const IRenderBuffer& renderBuffer)
float screenHeight;
float screenPixelRatio;
GetScreenDimensions(screenWidth, screenHeight, screenPixelRatio);
-
- // Entire target rendering area for the video (including black bars)
- const CRect viewRect = m_con... | xbmc/cores/RetroPlayer/rendering/VideoRenderers/RPBaseRenderer.cpp | 26 | C++ | 0.786 | suggestion | 228 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | garbear | slattann |
bool CApplication::IsPlayingFullScreenVideo() const
{
return m_appPlayer.IsPlayingVideo() && CServiceBroker::GetWinSystem()->GetGfxContext().IsFullScreenVideo();
}
bool CApplication::IsFullScreen()
{
return IsPlayingFullScreenVideo() ||
(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WIN... | If you set your editor to show whitespace, then it can catch these tab errors | }
}
bool CApplication::IsPlayingFullScreenVideo() const
{
return m_appPlayer.IsPlayingVideo() && CServiceBroker::GetWinSystem()->GetGfxContext().IsFullScreenVideo();
}
bool CApplication::IsFullScreen()
{
return IsPlayingFullScreenVideo() ||
(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow()... | @@ -3394,6 +3394,12 @@ void CApplication::StopPlaying()
int iWin = gui->GetWindowManager().GetActiveWindow();
if (m_appPlayer.IsPlaying())
{
+ auto winSystem = CServiceBroker::GetWinSystem();
+ if (nullptr != winSystem)
+ {
+ RESOLUTION_INFO res = winSystem->GetGfxContext().GetResInfo();
+... | xbmc/Application.cpp | 26 | C++ | 0.429 | nitpick | 77 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | garbear | slattann |
uint32_t CDRMAtomic::GetScalingFilterType(const char* type)
{
if (!strcmp(type, "Nearest Neighbor"))
return DRM_SCALING_FILTER_NEAREST_NEIGHBOR;
else
return DRM_SCALING_FILTER_DEFAULT;
}
uint32_t CDRMAtomic::GetScalingFactor(uint32_t srcWidth,
uint32_t srcHeight,
... | We usually surround `if` blocks longer than a single line with `{}`. This style decision arose because indentation changes occurring far away can be confusing and harder to read. | uint32_t CDRMAtomic::GetScalingFilterType(const char* type)
{
if (!strcmp(type, "Nearest Neighbor"))
return DRM_SCALING_FILTER_NEAREST_NEIGHBOR;
else
return DRM_SCALING_FILTER_DEFAULT;
}
uint32_t CDRMAtomic::GetScalingFactor(uint32_t srcWidth,
uint32_t srcHeight,
... | @@ -23,6 +25,57 @@
using namespace KODI::WINDOWING::GBM;
+const std::string SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
+
+enum drm_scaling_filter
+{
+ DRM_SCALING_FILTER_DEFAULT,
+ DRM_SCALING_FILTER_NEAREST_NEIGHBOR,
+};
+
+uint32_t CDRMAtomic::GetScalingFilterType(const char* type)
... | xbmc/windowing/gbm/DRMAtomic.cpp | 26 | C++ | 0.714 | style | 178 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | garbear | slattann |
{
return m_appPlayer.IsPlayingVideo() && CServiceBroker::GetWinSystem()->GetGfxContext().IsFullScreenVideo();
}
bool CApplication::IsFullScreen()
{
return IsPlayingFullScreenVideo() ||
(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_VISUALISATION) ||
CServiceBroker::GetGU... | Immediately after posting my three changes, my GSoC student (working on Windows 10) came across a strange error. On game exit, the app went fullscreen and this happened:

Commenting this code block fixe... | {
return m_appPlayer.IsPlayingVideo() && CServiceBroker::GetWinSystem()->GetGfxContext().IsFullScreenVideo();
}
bool CApplication::IsFullScreen()
{
return IsPlayingFullScreenVideo() ||
(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_VISUALISATION) ||
CServiceBroker::GetGU... | @@ -3397,6 +3397,12 @@ void CApplication::StopPlaying()
int iWin = gui->GetWindowManager().GetActiveWindow();
if (m_appPlayer.IsPlaying())
{
+ auto winSystem = CServiceBroker::GetWinSystem();
+ if (nullptr != winSystem)
+ {
+ RESOLUTION_INFO res = winSystem->GetGfxContext().GetResIn... | xbmc/Application.cpp | 26 | C++ | 0.929 | question | 398 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | garbear | slattann |
#include "DRMAtomic.h"
#include "ServiceBroker.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "settings/Settings.h"
#include "utils/log.h"
#include <errno.h>
#include <string.h>
#include <drm_fourcc.h>
#include <drm_mode.h>
#include <unistd.h>
using namespace KODI::WINDOWING::GBM... | This incorrectly hard-codes the values of the DRM enum here.
The uAPI doesn't have this guarantee, e.g. "Nearest Neighbor" could be exposed as the integer 5 in some other driver. |
#include "DRMAtomic.h"
#include "ServiceBroker.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIWindowManager.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
#include "settings/lib/Setting.h"
#include "utils/log.h"
#include <errno.h>
#include <string.h>
#include <drm_fourcc.h>
#incl... | @@ -23,6 +25,57 @@
using namespace KODI::WINDOWING::GBM;
+const std::string CDRMAtomic::SETTING_VIDEOSCREEN_HW_SCALING_FILTER = "videoscreen.hwscalingfilter";
+
+enum drm_scaling_filter
+{
+ DRM_SCALING_FILTER_DEFAULT,
+ DRM_SCALING_FILTER_NEAREST_NEIGHBOR, | xbmc/windowing/gbm/DRMAtomic.cpp | 26 | C++ | 0.5 | bug | 181 | 51 | 51 | false | Integer Scaling support implementation to improve the viewing quality of Pixel Art games | 18,194 | xbmc/xbmc | 17,740 | C++ | emersion | slattann |
items.SetProperty(PROPERTY_SORT_ORDER, (int)playlist.GetOrder());
items.SetProperty(PROPERTY_SORT_ASCENDING, playlist.GetOrderDirection() == SortOrderAscending);
if (!group.empty())
{
items.SetProperty(PROPERTY_GROUP_BY, group);
items.SetProperty(PROPERTY_GROUP_MIXED, playlist.IsGroupMixed(... | maybe boil this to:
```c
// sort grouped list by label unless random was specified
if (items.Size() > 1 && !group.empty())
{
items.Sort(playlist.GetOrder() == SortByRandom ? SortByRandom : SortByLabel,
SortOrderAscending,
CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(... |
items.SetProperty(PROPERTY_SORT_ORDER, (int)playlist.GetOrder());
items.SetProperty(PROPERTY_SORT_ASCENDING, playlist.GetOrderDirection() == SortOrderAscending);
if (!group.empty())
{
items.SetProperty(PROPERTY_GROUP_BY, group);
items.SetProperty(PROPERTY_GROUP_MIXED, playlist.IsGroupMixed(... | @@ -282,9 +282,22 @@ namespace XFILE
items.SetProperty(PROPERTY_GROUP_MIXED, playlist.IsGroupMixed());
}
- // sort grouped list by label
+ // sort grouped list by label unless random was specified
if (items.Size() > 1 && !group.empty())
- items.Sort(SortByLabel, SortOrderAscending, CServic... | xbmc/filesystem/SmartPlaylistDirectory.cpp | 26 | C++ | 0.929 | style | 484 | 51 | 51 | false | [Filesystem][smartplaylists] Don't sort grouped items by label if random order specified in xsp | 18,397 | xbmc/xbmc | 17,740 | C++ | howie-f | the-black-eagle |
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "OverlayRenderer.h"
#include <string>
#define MAX_LINES 10
struct SInfo
{
std::string line[MAX_LINES... | What's the point of this structure? | /*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "DebugInfo.h"
#include "OverlayRenderer.h"
#include <string>
class CDVDOverlayText;
class CDebugRender... | @@ -12,14 +12,21 @@
#include <string>
+#define MAX_LINES 10
+
+struct SInfo | xbmc/cores/VideoPlayer/VideoRenderers/DebugRenderer.h | 17 | C/C++ | 0.071 | question | 35 | 42 | 41 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "OverlayRenderer.h"
#include <string>
#define MAX_LINES 10
struct SInfo
{
std::string line[MAX_LINES... | define not namespaced at all pollutes the global landscape | /*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "DebugInfo.h"
#include "OverlayRenderer.h"
#include <string>
class CDVDOverlayText;
class CDebugRender... | @@ -12,14 +12,21 @@
#include <string>
+#define MAX_LINES 10 | xbmc/cores/VideoPlayer/VideoRenderers/DebugRenderer.h | 15 | C/C++ | 0.143 | suggestion | 58 | 40 | 40 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
struct SInfo
{
std::string line[MAX_LINES];
};
class CDVDOverlayText;
class CDebugRenderer
{
public:
CDebugRenderer();
virtual ~CDebugRenderer();
void SetInfo(SInfo& info);
void Render(CRect &src, CRect &dst, CRect &view);
void Flush();
protected:
class CRenderer : public OVERLAY::CRenderer
{
publ... | I think `std::array<std::string, MAX_LINES>` would be better or even better would be to use `std::vector<std::string>` as we don't have a defined size at compile time. This would also simplify some of the interface methods | /*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "DebugInfo.h"
#include "OverlayRenderer.h"
#include <string>
class CDVDOverlayText;
class CDebugRender... | @@ -32,7 +39,7 @@ class CDebugRenderer
void Render(int idx) override;
};
- std::string m_strDebug[4];
- CDVDOverlayText *m_overlay[4];
+ std::string m_strDebug[MAX_LINES]; | xbmc/cores/VideoPlayer/VideoRenderers/DebugRenderer.h | 26 | C/C++ | 0.786 | refactor | 222 | 30 | 41 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
// Feature support
virtual bool SupportsMultiPassRendering() = 0;
virtual bool Supports(ERENDERFEATURE feature) { return false; };
virtual bool Supports(ESCALINGMETHOD method) = 0;
virtual bool WantsDoublePass() { return false; };
void SetViewMode(int viewMode);
/*! \brief Get video rectangle and view ... | I think a returning defined struct of `std::string` would be better suited here and more future proof. |
// Feature support
virtual bool SupportsMultiPassRendering() = 0;
virtual bool Supports(ERENDERFEATURE feature) { return false; };
virtual bool Supports(ESCALINGMETHOD method) = 0;
virtual bool WantsDoublePass() { return false; };
void SetViewMode(int viewMode);
/*! \brief Get video rectangle and view... | @@ -92,6 +92,13 @@ class CBaseRenderer
void SetVideoSettings(const CVideoSettings &settings);
+ // Get debug info from render buffer
+ virtual void GetDebugInfo(int idx, | xbmc/cores/VideoPlayer/VideoRenderers/BaseRenderer.h | 26 | C/C++ | 0.714 | suggestion | 102 | 51 | 51 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
// winsystem events
virtual bool MessagePump() { return false; }
// Access render system interface
CGraphicContext& GetGfxContext();
/**
* Get OS specific hardware context
*
* \return OS specific context or nullptr if OS not have
*
* \note This function is currently only related to Windows w... | `info1` and `info2` aren't great descriptors | void DriveRenderLoop();
// winsystem events
virtual bool MessagePump() { return false; }
// Access render system interface
CGraphicContext& GetGfxContext();
/**
* Get OS specific hardware context
*
* \return OS specific context or nullptr if OS not have
*
* \note This function is currently... | @@ -165,6 +165,9 @@ class CWinSystemBase
virtual HDR_STATUS ToggleHDR() { return HDR_STATUS::HDR_UNSUPPORTED; };
virtual HDR_STATUS GetOSHDRStatus() { return HDR_STATUS::HDR_UNSUPPORTED; };
+ // Get debug info from video output stage
+ virtual void GetDebugInfo(std::string& info1, std::string& info2){}; | xbmc/windowing/WinSystem.h | 26 | C/C++ | 0.286 | suggestion | 44 | 50 | 51 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
Resources should call this on destruction if they're a dependent on the Render System
\sa Register, ID3DResource
*/
void Unregister(ID3DResource *resource) const
{
m_deviceResources->Unregister(resource);
};
void Register(IDispResource *resource) override { CWinSystemWin10::Register(resource); };
v... | `info1` and `info2` aren't great descriptors | Resources should call this on destruction if they're a dependent on the Render System
\sa Register, ID3DResource
*/
void Unregister(ID3DResource *resource) const
{
m_deviceResources->Unregister(resource);
};
void Register(IDispResource *resource) override { CWinSystemWin10::Register(resource); };
v... | @@ -77,6 +77,9 @@ class CWinSystemWin10DX : public CWinSystemWin10, public CRenderSystemDX
void SetHdrMetaData(DXGI_HDR_METADATA_HDR10& hdr10) const;
void SetHdrColorSpace(const DXGI_COLOR_SPACE_TYPE colorSpace) const;
+ // Get debug info from swapchain
+ void GetDebugInfo(std::string& info1, std::string& inf... | xbmc/windowing/win10/WinSystemWin10DX.h | 26 | C/C++ | 0.286 | suggestion | 44 | 36 | 36 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
Resources should call this on destruction if they're a dependent on the Render System
\sa Register, ID3DResource
*/
void Unregister(ID3DResource *resource) const
{
m_deviceResources->Unregister(resource);
};
void Register(IDispResource *resource) override { CWinSystemWin32::Register(resource); };
... | `info1` and `info2` aren't great descriptors | Resources should call this on destruction if they're a dependent on the Render System
\sa Register, ID3DResource
*/
void Unregister(ID3DResource *resource) const
{
m_deviceResources->Unregister(resource);
};
void Register(IDispResource *resource) override { CWinSystemWin32::Register(resource); };
... | @@ -79,6 +79,9 @@ class CWinSystemWin32DX : public CWinSystemWin32, public CRenderSystemDX
void SetHdrMetaData(DXGI_HDR_METADATA_HDR10& hdr10) const;
void SetHdrColorSpace(const DXGI_COLOR_SPACE_TYPE colorSpace) const;
+ // Get debug info from swapchain
+ void GetDebugInfo(std::string& info1, std::string& inf... | xbmc/windowing/windows/WinSystemWin32DX.h | 26 | C/C++ | 0.286 | suggestion | 44 | 40 | 40 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
CD3DBuffer m_vb;
CD3DBuffer m_ib;
unsigned int m_vbsize = 0;
unsigned int m_vertsize = 0;
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout = nullptr;
};
class COutputShader : public CWinShader
{
public:
explicit COutputShader() = default;
~COutputShader() = default;
void ApplyEffectParameters(C... | why not just return a string here rather than passing by reference? | CD3DBuffer m_vb;
CD3DBuffer m_ib;
unsigned int m_vbsize = 0;
unsigned int m_vertsize = 0;
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout = nullptr;
};
class COutputShader : public CWinShader
{
public:
explicit COutputShader() = default;
~COutputShader() = default;
void ApplyEffectParameters(C... | @@ -70,6 +70,8 @@ class COutputShader : public CWinShader
bool hasLightMetadata, AVContentLightMetadata lightMetadata);
void SetToneMapParam(int method, float param);
+ void GetDebugInfo(std::string& info); | xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/WinVideoFilter.h | 26 | C/C++ | 0.357 | question | 67 | 51 | 51 | false | [Windows] Add video, HDR metadata, shader and swapchain infos to debug info OSD | 19,126 | xbmc/xbmc | 17,740 | C++ | lrusak | thexai |
std::string mediaType;
int mediaID = -1;
if (parameterObject["item"].isMember("albumid"))
{
mediaType = MediaTypeAlbum;
mediaID = parameterObject["item"]["albumid"].asInteger32();
}
if (parameterObject["item"].isMember("artistid"))
{
mediaType = MediaTypeArtist;
mediaID = parameterObject["... | `item["arttype"] = artentry.m_aspect;`
May also want to handle empty => "thumb" here, or in `CMusicDatabase::GetAvailableArtForItem` | std::string mediaType;
int mediaID = -1;
if (parameterObject["item"].isMember("albumid"))
{
mediaType = MediaTypeAlbum;
mediaID = parameterObject["item"]["albumid"].asInteger32();
}
if (parameterObject["item"].isMember("artistid"))
{
mediaType = MediaTypeArtist;
mediaID = parameterObject["... | @@ -663,6 +663,77 @@ JSONRPC_STATUS JSONRPC::CAudioLibrary::GetSources(const std::string& method, ITr
return OK;
}
+JSONRPC_STATUS CAudioLibrary::GetAvailableArtTypes(const std::string& method, ITransportLayer* transport, IClient* client, const CVariant& parameterObject, CVariant& result)
+{
+ std::string mediaT... | xbmc/interfaces/json-rpc/AudioLibrary.cpp | 26 | C++ | 1 | suggestion | 133 | 51 | 51 | false | [jsonrpc] get available-but-not-assigned artwork | 19,185 | xbmc/xbmc | 17,740 | C++ | DaveTBlake | rmrector |
}
std::vector<CScraperUrl::SUrlEntry> CMusicDatabase::GetAvailableArtForItem(
int mediaId, const MediaType& mediaType, const std::string& artType)
{
CScraperUrl thumbURL;
if (mediaType == MediaTypeArtist)
{
CArtist artist;
if (GetArtist(mediaId, artist))
thumbURL = artist.thumbURL;
}
else if ... | if (artType.empty() || itemArtType == artType) | }
std::vector<CScraperUrl::SUrlEntry> CMusicDatabase::GetAvailableArtForItem(
int mediaId, const MediaType& mediaType, const std::string& artType)
{
CScraperUrl thumbURL;
if (mediaType == MediaTypeArtist)
{
CArtist artist;
if (GetArtist(mediaId, artist))
thumbURL = artist.thumbURL;
}
else if ... | @@ -12228,36 +12228,57 @@ bool CMusicDatabase::GetArtTypes(const MediaType &mediaType, std::vector<std::st
std::vector<std::string> CMusicDatabase::GetAvailableArtTypesForItem(int mediaId,
const MediaType& mediaType)
{
+ CScraperUrl thumbURL;
+ if (mediaType == MediaTypeArtist)
+ {
+ CArtist artist;
+ if ... | xbmc/music/MusicDatabase.cpp | 26 | C++ | 0.357 | suggestion | 47 | 51 | 51 | false | [jsonrpc] get available-but-not-assigned artwork | 19,185 | xbmc/xbmc | 17,740 | C++ | DaveTBlake | rmrector |
///
/// ------------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ..
/// success = xbmcvfs.mkdirs(path)
/// ..
/// ~~~~~~~~~~~~~
///
mkdirs(...);
#else
bool mkdirs(const String& path);
#endif
#ifdef DOXYGEN_S... | Your changes are good, is it worthwhile just altering the grammar on this line as well while you are at it?
```
/// @return True if succeeded
```
or alternatively successful would work as weill | ///
/// ------------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ..
/// success = xbmcvfs.mkdirs(path)
/// ..
/// ~~~~~~~~~~~~~
///
mkdirs(...);
#else
bool mkdirs(const String& path);
#endif
#ifdef DOXYGEN_S... | @@ -278,10 +278,13 @@ namespace XBMCAddon
#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcvfs
- /// @brief \python_func{ xbmcvfs.rmdir(path) }
+ /// @brief \python_func{ xbmcvfs.rmdir(path, [force]) }
/// Remove a folder.
///
- /// @param path Folder to remove
+... | xbmc/interfaces/legacy/ModuleXbmcvfs.h | 26 | C/C++ | 1 | nitpick | 207 | 51 | 51 | false | [docs] Document missing force opt for xbmcvfs.rmdir() | 19,430 | xbmc/xbmc | 17,740 | C++ | fuzzard | enen92 |
std::unique_ptr<ISavestate> savestate = CSavestateDatabase::AllocateSavestate();
if (m_savestateDatabase->GetSavestate(path, *savestate) &&
savestate->GetMemorySize() == memorySize)
{
{
std::unique_lock<CCriticalSection> lock(m_mutex);
if (m_memoryStream)
{
m_memoryStream->SetF... | If I am not wrong there is no other way to save the progress, so if you have loaded a manual save state the progress will never be saved. The only way to save will be to create a new save state | // Game client must support serialization
if (memorySize == 0)
return false;
bool bSuccess = false;
std::unique_ptr<ISavestate> savestate = CSavestateDatabase::AllocateSavestate();
if (m_savestateDatabase->GetSavestate(path, *savestate) &&
savestate->GetMemorySize() == memorySize)
{
{
... | @@ -224,8 +224,9 @@ bool CReversiblePlayback::LoadSavestate(const std::string& path)
if (m_gameClient->Deserialize(savestate->GetMemoryData(), memorySize))
{
m_totalFrameCount = savestate->TimestampFrames();
- m_autosavePath = path;
bSuccess = true;
+ if (savestate->Type() == SAVE_TYPE... | xbmc/cores/RetroPlayer/playback/ReversiblePlayback.cpp | 26 | C++ | 0.286 | bug | 193 | 51 | 51 | false | Retroplayer: Savestate manager fixes | 22,490 | xbmc/xbmc | 17,740 | C++ | NikosSiak | KOPRajs |
std::string CReversiblePlayback::CreateSavestate(bool autosave)
{
const size_t memorySize = m_gameClient->SerializeSize();
// Game client must support serialization
if (memorySize == 0)
return "";
//! @todo Handle savestates for standalone game clients
if (m_gameClient->GetGamePath().empty())
{
re... | The savestate object has a `Type()` method that can tell if it's an autosave. Should we use that? |
std::string CReversiblePlayback::CreateSavestate(bool autosave)
{
const size_t memorySize = m_gameClient->SerializeSize();
// Game client must support serialization
if (memorySize == 0)
return "";
//! @todo Handle savestates for standalone game clients
if (m_gameClient->GetGamePath().empty())
{
r... | @@ -134,11 +134,16 @@ std::string CReversiblePlayback::CreateSavestate(bool autosave)
std::string caption = m_cheevos->GetRichPresenceEvaluation();
- if (!m_autosavePath.empty())
+ if (autosave)
{
- std::unique_ptr<ISavestate> loadedSavestate = CSavestateDatabase::AllocateSavestate();
- if (m_savestat... | xbmc/cores/RetroPlayer/playback/ReversiblePlayback.cpp | 26 | C++ | 0.857 | question | 97 | 51 | 51 | false | Retroplayer: Savestate manager fixes | 22,490 | xbmc/xbmc | 17,740 | C++ | garbear | KOPRajs |
const size_t memorySize = m_gameClient->SerializeSize();
// Game client must support serialization
if (memorySize == 0)
return "";
//! @todo Handle savestates for standalone game clients
if (m_gameClient->GetGamePath().empty())
{
return "";
}
std::string label = "";
std::string caption = m... | This should come from translations. | {
const size_t memorySize = m_gameClient->SerializeSize();
// Game client must support serialization
if (memorySize == 0)
return "";
//! @todo Handle savestates for standalone game clients
if (m_gameClient->GetGamePath().empty())
{
return "";
}
std::string label = "";
std::string caption =... | @@ -134,11 +134,16 @@ std::string CReversiblePlayback::CreateSavestate(bool autosave)
std::string caption = m_cheevos->GetRichPresenceEvaluation();
- if (!m_autosavePath.empty())
+ if (autosave)
{
- std::unique_ptr<ISavestate> loadedSavestate = CSavestateDatabase::AllocateSavestate();
- if (m_savestat... | xbmc/cores/RetroPlayer/playback/ReversiblePlayback.cpp | 26 | C++ | 0.286 | suggestion | 35 | 51 | 51 | false | Retroplayer: Savestate manager fixes | 22,490 | xbmc/xbmc | 17,740 | C++ | garbear | KOPRajs |
{
if (!CEGLUtils::HasExtension(m_eglDisplay, "EGL_KHR_partial_update"))
return;
std::vector<EGLint> rects;
if (dirtyRegions.empty())
{
rects.push_back((EGLint)0);
rects.push_back((EGLint)0);
rects.push_back((EGLint)0);
rects.push_back((EGLint)0);
}
else
{
EGLint height = CServiceB... | This could be a little bit faster but I can't test it lacking a GPU with `EGL_KHR_partial_update`.
```suggestion
using Rect = std::array<EGLint, 4>;
if (dirtyRegions.empty())
{
static Rect zeroRect{};
m_eglSetDamageRegionKHR(m_eglDisplay, m_eglSurface, zeroRect.data(), 1);
}
else
{
E... | {
if (m_eglDisplay == EGL_NO_DISPLAY || m_eglUploadContext == EGL_NO_CONTEXT)
{
CLog::LogF(LOGERROR, "No texture upload context found.");
return false;
}
m_textureUploadLock.lock();
if (!eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, m_eglUploadContext))
{
m_textureUploadLock.unl... | @@ -596,3 +590,48 @@ bool CEGLContextUtils::TrySwapBuffers()
return (eglSwapBuffers(m_eglDisplay, m_eglSurface) == EGL_TRUE);
}
+
+int32_t CEGLContextUtils::GetBufferAge()
+{
+ int32_t bufferAge = 2;
+ if (CEGLUtils::HasExtension(m_eglDisplay, "EGL_KHR_partial_update"))
+ eglQuerySurface(m_eglDisplay, m_eglS... | xbmc/utils/EGLUtils.cpp | 26 | C++ | 1 | suggestion | 802 | 28 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | neo1973 | sarbes |
}
bool CEGLContextUtils::TrySwapBuffers()
{
if (m_eglDisplay == EGL_NO_DISPLAY || m_eglSurface == EGL_NO_SURFACE)
{
return false;
}
return (eglSwapBuffers(m_eglDisplay, m_eglSurface) == EGL_TRUE);
}
int32_t CEGLContextUtils::GetBufferAge()
{
int32_t bufferAge = 2;
if (CEGLUtils::HasExtension(m_eglDis... | Is it necessary to query the extensions every time or can this be cached? E.g. in a static variable. | {
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroySurface(m_eglDisplay, m_eglSurface);
m_eglSurface = EGL_NO_SURFACE;
}
}
bool CEGLContextUtils::SetVSync(bool enable)
{
if (m_eglDisplay == EGL_NO_DISPLAY)
{
return false;
}
return (eglSwapInterval(m_... | @@ -596,3 +590,48 @@ bool CEGLContextUtils::TrySwapBuffers()
return (eglSwapBuffers(m_eglDisplay, m_eglSurface) == EGL_TRUE);
}
+
+int32_t CEGLContextUtils::GetBufferAge()
+{
+ int32_t bufferAge = 2;
+ if (CEGLUtils::HasExtension(m_eglDisplay, "EGL_KHR_partial_update"))
+ eglQuerySurface(m_eglDisplay, m_eglS... | xbmc/utils/EGLUtils.cpp | 26 | C++ | 0.286 | performance | 100 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | neo1973 | sarbes |
* disable HDR.
*
*/
virtual bool SetHDR(const VideoPicture* videoPicture) { return false; }
virtual bool IsHDRDisplay() { return false; }
virtual HDR_STATUS ToggleHDR() { return HDR_STATUS::HDR_UNSUPPORTED; }
virtual HDR_STATUS GetOSHDRStatus() { return HDR_STATUS::HDR_UNSUPPORTED; }
virtual CHDRCapa... | Why int32_t? Why not just int or unsigned int? | *
* \return true if the windowing system supports moving windows across screens, false otherwise
*/
virtual bool SupportsScreenMove() { return true; }
virtual void UpdateResolutions();
void SetWindowResolution(int width, int height);
std::vector<RESOLUTION_WHR> ScreenResolutions(float refreshrate);
... | @@ -181,6 +182,32 @@ class CWinSystemBase
virtual std::vector<std::string> GetConnectedOutputs() { return {}; }
+ /*!
+ * @brief Queries the age of the current backbuffer.
+ *
+ * @return Returns the buffer age. Usual values are: 1 for double buffering,
+ * 2 for triple buffering.
+ *
+ * @note Shou... | xbmc/windowing/WinSystem.h | 26 | C/C++ | 0.286 | question | 46 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | lrusak | sarbes |
{
errorStr = eglError->second;
}
CLog::Log(logLevel, "{} ({})", what, errorStr);
}
CEGLContextUtils::CEGLContextUtils(EGLenum platform, std::string const& platformExtension)
: m_platform{platform}
{
if (CEGLUtils::HasClientExtension("EGL_KHR_debug"))
{
auto eglDebugMessageControl = CEGLUtils::GetReq... | CEGLUtils has a helper for this | auto eglError = eglErrors.find(error);
if (eglError != eglErrors.end())
{
errorStr = eglError->second;
}
CLog::Log(logLevel, "{} ({})", what, errorStr);
}
CEGLContextUtils::CEGLContextUtils(EGLenum platform, std::string const& platformExtension)
: m_platform{platform}
{
if (CEGLUtils::HasClientExtensi... | @@ -185,6 +187,8 @@ CEGLContextUtils::CEGLContextUtils(EGLenum platform, std::string const& platform
}
m_platformSupported = CEGLUtils::HasClientExtension("EGL_EXT_platform_base") && CEGLUtils::HasClientExtension(platformExtension);
+ m_eglSetDamageRegionKHR =
+ (PFNEGLSETDAMAGEREGIONKHRPROC)eglGetProcAdd... | xbmc/utils/EGLUtils.cpp | 26 | C++ | 0.071 | refactor | 31 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | lrusak | sarbes |
bool CEGLContextUtils::HasDamagedRegionSupport()
{
return CEGLUtils::HasExtension(m_eglDisplay, "EGL_KHR_partial_update");
}
void CEGLContextUtils::SetDamagedRegions(const CDirtyRegionList& dirtyRegions)
{
if (!CEGLUtils::HasExtension(m_eglDisplay, "EGL_KHR_partial_update"))
return;
std::vector<EGLint> rect... | C++ cast, same thing elsewhere. | }
return (eglSwapBuffers(m_eglDisplay, m_eglSurface) == EGL_TRUE);
}
bool CEGLContextUtils::BindTextureUploadContext()
{
if (m_eglDisplay == EGL_NO_DISPLAY || m_eglUploadContext == EGL_NO_CONTEXT)
{
CLog::LogF(LOGERROR, "No texture upload context found.");
return false;
}
m_textureUploadLock.lock... | @@ -596,3 +590,48 @@ bool CEGLContextUtils::TrySwapBuffers()
return (eglSwapBuffers(m_eglDisplay, m_eglSurface) == EGL_TRUE);
}
+
+int32_t CEGLContextUtils::GetBufferAge()
+{
+ int32_t bufferAge = 2;
+ if (CEGLUtils::HasExtension(m_eglDisplay, "EGL_KHR_partial_update"))
+ eglQuerySurface(m_eglDisplay, m_eglS... | xbmc/utils/EGLUtils.cpp | 26 | C++ | 0.357 | suggestion | 31 | 34 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | lrusak | sarbes |
m_lastRenderTime = std::chrono::steady_clock::now();
}
// render video layer
CServiceBroker::GetGUI()->GetWindowManager().RenderEx();
CServiceBroker::GetRenderSystem()->EndRender();
// reset our info cache - we do this at the end of Render so that it is
// fresh for the next process(), or after a win... | This now seems to execute after the flip, should it be renamed BeforeRender? | //if the action would start or stop inertial scrolling
//by gesture - bypass the normal OnAction handler of current window
if( !m_pInertialScrollingHandler->CheckForInertialScrolling(&action) )
{
// in normal case
// just pass the action to the current window and let it handle it
if (CServiceBroker:... | @@ -934,6 +932,9 @@ void CApplication::Render()
CServiceBroker::GetWinSystem()->GetGfxContext().Flip(hasRendered,
appPlayer->IsRenderingVideoLayer());
+ if (appPower->GetRenderGUI() && !m_skipGuiRender)
+ CServiceBroker::GetGUI()->GetWindowManager().After... | xbmc/application/Application.cpp | 26 | C++ | 0.357 | question | 76 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | lrusak | sarbes |
/*!
* @brief Queries the age of the current backbuffer.
*
* @return Returns the buffer age. Usual values are: 1 for double buffering,
* 2 for triple buffering.
*
* @note Should be called once before any draw call, as it triggers damaged
* regions rendering.
*/
virtual int32_t GetBufferAge()... | ```suggestion
virtual void SetDamagedRegions(const CDirtyRegionList& damagedRegions) {}
``` | // Display event callback
virtual void Register(IDispResource *resource) = 0;
virtual void Unregister(IDispResource *resource) = 0;
// render loop
void RegisterRenderLoop(IRenderLoop *client);
void UnregisterRenderLoop(IRenderLoop *client);
void DriveRenderLoop();
// winsystem events
virtual bool Me... | @@ -181,6 +182,32 @@ class CWinSystemBase
virtual std::vector<std::string> GetConnectedOutputs() { return {}; }
+ /*!
+ * @brief Queries the age of the current backbuffer.
+ *
+ * @return Returns the buffer age. Usual values are: 1 for double buffering,
+ * 2 for triple buffering.
+ *
+ * @note Shou... | xbmc/windowing/WinSystem.h | 26 | C/C++ | 0.857 | suggestion | 95 | 48 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | yol | sarbes |
bool CEGLContextUtils::SetVSync(bool enable)
{
if (m_eglDisplay == EGL_NO_DISPLAY)
{
return false;
}
return (eglSwapInterval(m_eglDisplay, enable) == EGL_TRUE);
}
bool CEGLContextUtils::TrySwapBuffers()
{
if (m_eglDisplay == EGL_NO_DISPLAY || m_eglSurface == EGL_NO_SURFACE)
{
return false;
}
... | please cache this, it doesn't make sense to parse the extension list on every frame ;) | if (m_eglUploadContext)
{
eglDestroyContext(m_eglDisplay, m_eglUploadContext);
m_eglUploadContext = EGL_NO_CONTEXT;
}
}
void CEGLContextUtils::DestroySurface()
{
if (m_eglSurface != EGL_NO_SURFACE)
{
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglDestroySurfa... | @@ -596,3 +590,48 @@ bool CEGLContextUtils::TrySwapBuffers()
return (eglSwapBuffers(m_eglDisplay, m_eglSurface) == EGL_TRUE);
}
+
+int32_t CEGLContextUtils::GetBufferAge()
+{
+ int32_t bufferAge = 2;
+ if (CEGLUtils::HasExtension(m_eglDisplay, "EGL_KHR_partial_update")) | xbmc/utils/EGLUtils.cpp | 26 | C++ | 0.143 | performance | 86 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | yol | sarbes |
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
// always define GL_GLEXT_PROTOTYPES before include gl headers
#include "commons/ilog.h"
#if !defined(GL_GLEXT_PROTOTYPES)
#de... | Is there no runtime check necessary to check if `EGL_BUFFER_AGE_EXT` is supported (like in `CEGLContextUtils::GetBufferAge()`)? |
m_textureUploadLock.unlock();
return true;
}
bool CGLContextEGL::HasContext()
{
return eglGetCurrentContext() != EGL_NO_CONTEXT;
}
void CGLContextEGL::QueryExtensions()
{
std::string extensions = eglQueryString(m_eglDisplay, EGL_EXTENSIONS);
m_extensions = std::string(" ") + extensions + " ";
CLog::Log... | @@ -541,3 +542,16 @@ void CGLContextEGL::QueryExtensions()
CLog::Log(LOGDEBUG, "EGL_EXTENSIONS:{}", m_extensions);
}
+
+int CGLContextEGL::GetBufferAge()
+{
+#ifdef EGL_BUFFER_AGE_EXT
+ EGLint age;
+ eglQuerySurface(m_eglDisplay, m_eglSurface, EGL_BUFFER_AGE_EXT, &age);
+ if (age < 1)
+ age = 2;
+ return s... | xbmc/windowing/X11/GLContextEGL.cpp | 26 | C++ | 0.5 | question | 127 | 558 | 30 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | neo1973 | sarbes |
if (pWindow)
pWindow->RenderEx();
// We don't call RenderEx for now on dialogs since it is used
// to trigger non gui video rendering. We can activate it later at any time.
/*
vector<CGUIWindow *> &activeDialogs = m_activeDialogs;
for (iDialog it = activeDialogs.begin(); it != activeDialogs.end(); ++it... | I assume `GetBufferAge()` returns a value `>=0` so this check shouldn't be necessary? If true then the same for the `bufferAge == 0` check below. | if (pWindow)
pWindow->RenderEx();
// We don't call RenderEx for now on dialogs since it is used
// to trigger non gui video rendering. We can activate it later at any time.
/*
vector<CGUIWindow *> &activeDialogs = m_activeDialogs;
for (iDialog it = activeDialogs.begin(); it != activeDialogs.end(); ++it... | @@ -1350,11 +1350,23 @@ bool CGUIWindowManager::Render()
assert(CServiceBroker::GetAppMessenger()->IsProcessThread());
CSingleExit lock(CServiceBroker::GetWinSystem()->GetGfxContext());
+ int bufferAge = CServiceBroker::GetWinSystem()->GetBufferAge() + 1;
+ bool visualizeDirtyRegions =
+ CServiceBroker::... | xbmc/guilib/GUIWindowManager.cpp | 26 | C++ | 0.714 | suggestion | 145 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | neo1973 | sarbes |
{
return eglGetCurrentContext() != EGL_NO_CONTEXT;
}
void CEGLContextUtils::SetDamagedRegions(const CDirtyRegionList& dirtyRegions)
{
if (!m_partialUpdateSupport)
return;
using Rect = std::array<EGLint, 4>;
if (dirtyRegions.empty())
{
// add a single (empty) entry, otherwise the whole frame gets ren... | In case all regions were empty should we add an empty Rect to rects? | {
return eglGetCurrentContext() != EGL_NO_CONTEXT;
}
void CEGLContextUtils::SetDamagedRegions(const CDirtyRegionList& dirtyRegions)
{
if (!m_partialUpdateSupport)
return;
using Rect = std::array<EGLint, 4>;
if (dirtyRegions.empty())
{
// add a single (empty) entry, otherwise the whole frame gets ren... | @@ -655,3 +652,53 @@ bool CEGLContextUtils::HasContext()
{
return eglGetCurrentContext() != EGL_NO_CONTEXT;
}
+
+void CEGLContextUtils::SetDamagedRegions(const CDirtyRegionList& dirtyRegions)
+{
+ if (!m_partialUpdateSupport)
+ return;
+
+ using Rect = std::array<EGLint, 4>;
+ if (dirtyRegions.empty())
+ {
... | xbmc/utils/EGLUtils.cpp | 26 | C++ | 0.357 | question | 68 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | neo1973 | sarbes |
#include <cstdint>
#include "system_egl.h"
#include <EGL/eglext.h>
#ifdef HAVE_EGLEXTANGLE
#include <EGL/eglext_angle.h>
#else
#include <EGL/eglextchromium.h>
#endif
#include <X11/Xutil.h>
class CGLContextEGL : public CGLContext
{
public:
explicit CGLContextEGL(Display *dpy, EGLint renderingApi);
~CGLContextEGL... | maybe make this return a bool instead and adapt the main logic? |
#include <cstdint>
#include "system_egl.h"
#include <EGL/eglext.h>
#ifdef HAVE_EGLEXTANGLE
#include <EGL/eglext_angle.h>
#else
#include <EGL/eglextchromium.h>
#endif
#include <X11/Xutil.h>
class CGLContextEGL : public CGLContext
{
public:
explicit CGLContextEGL(Display *dpy, EGLint renderingApi);
~CGLContextEGL... | @@ -35,6 +35,11 @@ class CGLContextEGL : public CGLContext
void SetVSync(bool enable) override;
void SwapBuffers() override;
void QueryExtensions() override;
+ void CheckBufferAgeSupport() override | xbmc/windowing/X11/GLContextEGL.h | 26 | C/C++ | 0.357 | question | 63 | 51 | 51 | false | Fix/improve dirty regions on GBM/Wayland/X11 (EGL) | 22,998 | xbmc/xbmc | 17,740 | C++ | enen92 | sarbes |
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include <memory>
#include <string>
class CTexture;
namespace IMAGE_FILES
{
/*!
* @brief An interface to load special image files into a texture for the cache.
*
* Special image files are generated or... | I know this is legacy but in a future PR it would be nice if this was an enum class rather than a string.
Having an enum is much nicer for comparison and for tacking the available types. | * SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include <memory>
#include <string>
class CTexture;
namespace IMAGE_FILES
{
/*!
* @brief An interface to load special image files into a texture for the cache.
*
* Special image files are generated or... | @@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+class CTexture;
+
+namespace IMAGE_FILES
+{
+
+/*!
... | xbmc/imagefiles/SpecialImageFileLoader.h | 26 | C/C++ | 0.571 | suggestion | 187 | 33 | 33 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
#pragma once
#include <memory>
#include <string>
class CTexture;
namespace IMAGE_FILES
{
/*!
* @brief An interface to load special image files into a texture for the cache.
*
* Special image files are generated or embedded images, like album covers embedded
* in music files or thumbnails generated from video fi... | ```suggestion
virtual ~ISpecialImageFileLoader() = default;
```
| #pragma once
#include <memory>
#include <string>
class CTexture;
namespace IMAGE_FILES
{
/*!
* @brief An interface to load special image files into a texture for the cache.
*
* Special image files are generated or embedded images, like album covers embedded
* in music files or thumbnails generated from video fi... | @@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include <memory>
+#include <string>
+
+class CTexture;
+
+namespace IMAGE_FILES
+{
+
+/*!
... | xbmc/imagefiles/SpecialImageFileLoader.h | 26 | C/C++ | 0.857 | suggestion | 66 | 29 | 29 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
#include <memory>
#include <string>
#include <vector>
class CTexture;
namespace IMAGE_FILES
{
class CSpecialImageLoaderFactory
{
public:
CSpecialImageLoaderFactory();
std::unique_ptr<CTexture> Load(
std::string specialType,
std::string fi... | Since the size of this array it would be nice to use const std::array if possible.
This is only relevant if you don't plan to have some sort of registration mechanism in the future where more image loaders can by dynamically registered. |
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
#include <array>
#include <memory>
#include <string>
class CTexture;
namespace IMAGE_FILES
{
class CSpecialImageLoaderFactory
{
public:
CSpecialImageLoaderFactory();
std::unique_ptr<CTexture> Load(std::string specialType,
... | @@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "imagefiles/SpecialImageFileLoader.h"
+
+#include <memory>
+#include <string>
+#in... | xbmc/imagefiles/SpecialImageLoaderFactory.h | 26 | C/C++ | 0.571 | style | 237 | 29 | 28 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "MusicEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "music/tags/ImusicInfoTagLoader.h"
#include "music/tags/MusicInfoTag.h"
#include "music/tags/MusicInfoTagLoaderFactory... | ```suggestion
std::unique_ptr<IMusicInfoTagLoader> loader(CMusicInfoTagLoaderFactory::CreateLoader(item));
```
| * SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "MusicEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "music/tags/ImusicInfoTagLoader.h"
#include "music/tags/MusicInfoTag.h"
#include "music/tags/MusicInfoTagLoaderFactory... | @@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "MusicEmbeddedImageFileLoader.h"
+
+#include "FileItem.h"
+#include "guilib/Texture.h"
+#include "... | xbmc/music/MusicEmbeddedImageFileLoader.cpp | 26 | C++ | 1 | suggestion | 113 | 47 | 46 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
*/
#include "MusicEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "music/tags/ImusicInfoTagLoader.h"
#include "music/tags/MusicInfoTag.h"
#include "music/tags/MusicInfoTagLoaderFactory.h"
#include "utils/EmbeddedArt.h"
using namespace MUSIC_INFO;
bool CMusicEmbeddedImageFileLo... | ```suggestion
if (loader)
```
| */
#include "MusicEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "music/tags/ImusicInfoTagLoader.h"
#include "music/tags/MusicInfoTag.h"
#include "music/tags/MusicInfoTagLoaderFactory.h"
#include "utils/EmbeddedArt.h"
using namespace MUSIC_INFO;
bool CMusicEmbeddedImageFileLo... | @@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "MusicEmbeddedImageFileLoader.h"
+
+#include "FileItem.h"
+#include "guilib/Texture.h"
+#include "... | xbmc/music/MusicEmbeddedImageFileLoader.cpp | 26 | C++ | 0.786 | suggestion | 32 | 45 | 44 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
* See LICENSES/README.md for more information.
*/
#include "VideoEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "utils/EmbeddedArt.h"
#include "utils/StringUtils.h"
#include "video/VideoInfoTag.h"
#include "video/tags/IVideoInfoTagLoader.h"
#include "video/tags/VideoInfoTagLo... | ```suggestion
std::unique_ptr<IVideoInfoTagLoader> loader;
```
| * See LICENSES/README.md for more information.
*/
#include "VideoEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "utils/EmbeddedArt.h"
#include "utils/StringUtils.h"
#include "video/VideoInfoTag.h"
#include "video/tags/IVideoInfoTagLoader.h"
#include "video/tags/VideoInfoTagLo... | @@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "VideoEmbeddedImageFileLoader.h"
+
+#include "FileItem.h"
+#include "guilib/Texture.h"
+#include "... | xbmc/video/VideoEmbeddedImageFileLoader.cpp | 26 | C++ | 0.857 | suggestion | 65 | 51 | 51 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
*/
#include "VideoEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "utils/EmbeddedArt.h"
#include "utils/StringUtils.h"
#include "video/VideoInfoTag.h"
#include "video/tags/IVideoInfoTagLoader.h"
#include "video/tags/VideoInfoTagLoaderFactory.h"
using namespace VIDEO;
bool CVid... | Just assign this in he last line
```suggestion
= CVideoInfoTagLoaderFactory::CreateLoader(item, ADDON::ScraperPtr(), false);
```
| */
#include "VideoEmbeddedImageFileLoader.h"
#include "FileItem.h"
#include "guilib/Texture.h"
#include "utils/EmbeddedArt.h"
#include "utils/StringUtils.h"
#include "video/VideoInfoTag.h"
#include "video/tags/IVideoInfoTagLoader.h"
#include "video/tags/VideoInfoTagLoaderFactory.h"
using namespace VIDEO;
bool CVid... | @@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "VideoEmbeddedImageFileLoader.h"
+
+#include "FileItem.h"
+#include "guilib/Texture.h"
+#include "... | xbmc/video/VideoEmbeddedImageFileLoader.cpp | 26 | C++ | 1 | suggestion | 132 | 51 | 51 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
#include "utils/EmbeddedArt.h"
#include "utils/StringUtils.h"
#include "video/VideoInfoTag.h"
#include "video/tags/IVideoInfoTagLoader.h"
#include "video/tags/VideoInfoTagLoaderFactory.h"
using namespace VIDEO;
bool CVideoEmbeddedImageFileLoader::CanLoad(std::string specialType) const
{
return StringUtils::StartsWi... | ```suggestion
for (const auto& it : artv)
```
| #include "utils/EmbeddedArt.h"
#include "utils/StringUtils.h"
#include "video/VideoInfoTag.h"
#include "video/tags/IVideoInfoTagLoader.h"
#include "video/tags/VideoInfoTagLoaderFactory.h"
using namespace VIDEO;
bool CVideoEmbeddedImageFileLoader::CanLoad(std::string specialType) const
{
return StringUtils::StartsWi... | @@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "VideoEmbeddedImageFileLoader.h"
+
+#include "FileItem.h"
+#include "guilib/Texture.h"
+#include "... | xbmc/video/VideoEmbeddedImageFileLoader.cpp | 26 | C++ | 0.786 | suggestion | 48 | 50 | 49 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
std::unique_ptr<IVideoInfoTagLoader> pLoader;
pLoader.reset(CVideoInfoTagLoaderFactory::CreateLoader(item, ADDON::ScraperPtr(), false));
CVideoInfoTag tag;
std::vector<EmbeddedArt> artv;
if (pLoader)
pLoader->Load(tag, false, &artv);
for (const EmbeddedArt& it : artv)
{
if (it.m_type == type)
... | What's with the substring here? | std::unique_ptr<IVideoInfoTagLoader> loader(
CVideoInfoTagLoaderFactory::CreateLoader(item, ADDON::ScraperPtr(), false));
CVideoInfoTag tag;
std::vector<EmbeddedArt> artv;
if (loader)
loader->Load(tag, false, &artv);
for (const auto& it : artv)
{
if (it.m_type == type)
{
art = it;
... | @@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "VideoEmbeddedImageFileLoader.h"
+
+#include "FileItem.h"
+#include "guilib/Texture.h"
+#include "... | xbmc/video/VideoEmbeddedImageFileLoader.cpp | 26 | C++ | 0.071 | question | 31 | 32 | 31 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "SpecialImageLoaderFactory.h"
#include "guilib/Texture.h"
#include "music/MusicEmbeddedImageFileLoader.h"
#include "video/VideoEmbeddedImageFileLoader.h"
using namespace IMAGE_FILES;
CSpecialImageLoaderFac... | Can you invert and return early instead of nesting? | *
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "SpecialImageLoaderFactory.h"
#include "guilib/Texture.h"
#include "music/MusicEmbeddedImageFileLoader.h"
#include "video/VideoEmbeddedImageFileLoader.h"
using namespace IMAGE_FILES;
CSpecialImageLoaderFac... | @@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "SpecialImageLoaderFactory.h"
+
+#include "guilib/Texture.h"
+#include "music/MusicEmbeddedImageFi... | xbmc/imagefiles/SpecialImageLoaderFactory.cpp | 26 | C++ | 0.357 | question | 51 | 40 | 38 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
/*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
namespace MUSIC_INFO
{
class CMusicEmbeddedImageFileLoader : public IM... | I'm not sure if you care about being explicit and adding default ctors and detors here. Not required just a style thing. | /*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
namespace MUSIC_INFO
{
class CMusicEmbeddedImageFileLoader : public IM... | @@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "imagefiles/SpecialImageFileLoader.h"
+
+namespace MUSIC_INFO
+{
+
+class CMusicEm... | xbmc/music/MusicEmbeddedImageFileLoader.h | 18 | C/C++ | 0.286 | style | 120 | 27 | 29 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
/*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
namespace VIDEO
{
class CVideoEmbeddedImageFileLoader : public IMAGE_F... | ```suggestion
~CVideoEmbeddedImageFileLoader() override = default;
``` | /*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
namespace VIDEO
{
class CVideoEmbeddedImageFileLoader : public IMAGE_F... | @@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "imagefiles/SpecialImageFileLoader.h"
+
+namespace VIDEO
+{
+
+class CVideoEmbedde... | xbmc/video/VideoEmbeddedImageFileLoader.h | 20 | C/C++ | 0.857 | suggestion | 74 | 30 | 30 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
/*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
namespace MUSIC_INFO
{
class CMusicEmbeddedImageFileLoader : public IM... | ```suggestion
~CMusicEmbeddedImageFileLoader() override = default;
``` | /*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "imagefiles/SpecialImageFileLoader.h"
namespace MUSIC_INFO
{
class CMusicEmbeddedImageFileLoader : public IM... | @@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#pragma once
+
+#include "imagefiles/SpecialImageFileLoader.h"
+
+namespace MUSIC_INFO
+{
+
+class CMusicEm... | xbmc/music/MusicEmbeddedImageFileLoader.h | 20 | C/C++ | 0.857 | suggestion | 74 | 29 | 29 | false | [guilib][vfs][imagecache] Load special images into texture cache when viewed, like standard images | 23,197 | xbmc/xbmc | 17,740 | C++ | lrusak | rmrector |
/*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "PictureFolderImageFileLoader.h"
#include "FileItem.h"
#include "Picture.h"
#include "ServiceBroker.h"
#include "TextureCac... | ```c++
const std::string& specialType
``` | /*
* Copyright (C) 2023 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "PictureFolderImageFileLoader.h"
#include "FileItem.h"
#include "Picture.h"
#include "ServiceBroker.h"
#include "TextureCac... | @@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2023 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "PictureFolderImageFileLoader.h"
+
+#include "FileItem.h"
+#include "Picture.h"
+#include "Service... | xbmc/pictures/PictureFolderImageFileLoader.cpp | 23 | C++ | 0.857 | suggestion | 43 | 48 | 48 | false | [guilib][vfs][imagecache] Load picture folder images into texture cache when viewed, like standard images | 23,517 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
if (!orientation ||
OrientateImage(buffer, dest_width, dest_height, orientation, dest_width_aligned))
{
success = CreateThumbnailFromSurface((unsigned char*)buffer, dest_width, dest_height,
dest_width_aligned * 4, dest);
}
... | Please use c++ casts like static_cast | if (!orientation ||
OrientateImage(buffer, dest_width, dest_height, orientation, dest_width_aligned))
{
success = CreateThumbnailFromSurface((unsigned char*)buffer, dest_width, dest_height,
dest_width_aligned * 4, dest);
}
... | @@ -277,6 +279,73 @@ bool CPicture::CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, ui
return false;
}
+std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::string>& files)
+{
+ if (!files.size())
+ return {};
+
+ unsigned int num_across = (unsigned int)ceil(sqrt((float)... | xbmc/pictures/Picture.cpp | 26 | C++ | 0.571 | suggestion | 37 | 51 | 51 | false | [guilib][vfs][imagecache] Load picture folder images into texture cache when viewed, like standard images | 23,517 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
unsigned int num_down = (files.size() + num_across - 1) / num_across;
unsigned int imageRes = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_imageRes;
unsigned int tile_width = imageRes / num_across;
unsigned int tile_height = imageRes / num_down;
unsigned int tile_gap = 1;
bool success ... | Avoid raw pointers, use std::unique_ptr. You can scale into the pixel memory via `scaled.get()`. Then you can avoid the delete command below. | static_cast<unsigned int>(std::ceil(std::sqrt(static_cast<float>(files.size()))));
unsigned int num_down = (files.size() + num_across - 1) / num_across;
unsigned int imageRes = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_imageRes;
unsigned int tile_width = imageRes / num_across;
uns... | @@ -277,6 +279,73 @@ bool CPicture::CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, ui
return false;
}
+std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::string>& files)
+{
+ if (!files.size())
+ return {};
+
+ unsigned int num_across = (unsigned int)ceil(sqrt((float)... | xbmc/pictures/Picture.cpp | 26 | C++ | 1 | suggestion | 141 | 51 | 51 | false | [guilib][vfs][imagecache] Load picture folder images into texture cache when viewed, like standard images | 23,517 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
// create a buffer for the resulting thumb
uint32_t* buffer = static_cast<uint32_t*>(calloc(imageRes * imageRes, 4));
if (!buffer)
return {};
for (unsigned int i = 0; i < files.size(); ++i)
{
int x = i % num_across;
int y = i / num_across;
// load in the image
unsigned int width = tile_wid... | I would put the documentation here with the declaration. |
// create a buffer for the resulting thumb
std::unique_ptr<uint32_t[]> buffer = std::make_unique<uint32_t[]>(imageRes * imageRes);
if (!buffer)
return {};
for (unsigned int i = 0; i < files.size(); ++i)
{
int x = i % num_across;
int y = i / num_across;
// load in the image
unsigned int wi... | @@ -277,6 +279,73 @@ bool CPicture::CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, ui
return false;
}
+std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::string>& files)
+{
+ if (!files.size())
+ return {};
+
+ unsigned int num_across = (unsigned int)ceil(sqrt((float)... | xbmc/pictures/Picture.cpp | 26 | C++ | 0.143 | suggestion | 56 | 51 | 51 | false | [guilib][vfs][imagecache] Load picture folder images into texture cache when viewed, like standard images | 23,517 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
{
int x = i % num_across;
int y = i / num_across;
// load in the image
unsigned int width = tile_width - 2 * tile_gap, height = tile_height - 2 * tile_gap;
std::unique_ptr<CTexture> texture = CTexture::LoadFromFile(files[i], width, height, true);
if (texture && texture->GetWidth() && texture->... | source pixels are const* because you copy from them, not too them. | for (unsigned int i = 0; i < files.size(); ++i)
{
int x = i % num_across;
int y = i / num_across;
// load in the image
unsigned int width = tile_width - 2 * tile_gap, height = tile_height - 2 * tile_gap;
std::unique_ptr<CTexture> texture = CTexture::LoadFromFile(files[i], width, height, true);
... | @@ -277,6 +279,73 @@ bool CPicture::CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, ui
return false;
}
+std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::string>& files)
+{
+ if (!files.size())
+ return {};
+
+ unsigned int num_across = (unsigned int)ceil(sqrt((float)... | xbmc/pictures/Picture.cpp | 26 | C++ | 0.357 | suggestion | 66 | 51 | 51 | false | [guilib][vfs][imagecache] Load picture folder images into texture cache when viewed, like standard images | 23,517 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
unsigned int imageRes = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_imageRes;
unsigned int tile_width = imageRes / num_across;
unsigned int tile_height = imageRes / num_down;
unsigned int tile_gap = 1;
bool success = false;
// create a buffer for the resulting thumb
uint32_t* buffer... | `(uint8_t*)scaled` should be `reinterpret_cast<uint8_t*>(scaled)` to use C++ casts |
unsigned int imageRes = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_imageRes;
unsigned int tile_width = imageRes / num_across;
unsigned int tile_height = imageRes / num_down;
unsigned int tile_gap = 1;
bool success = false; // Flag that we at least had one successful image processed
... | @@ -277,6 +279,73 @@ bool CPicture::CacheTexture(uint8_t *pixels, uint32_t width, uint32_t height, ui
return false;
}
+std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::string>& files)
+{
+ if (!files.size())
+ return {};
+
+ unsigned int num_across = (unsigned int)ceil(sqrt((float)... | xbmc/pictures/Picture.cpp | 26 | C++ | 0.857 | suggestion | 82 | 51 | 51 | false | [guilib][vfs][imagecache] Load picture folder images into texture cache when viewed, like standard images | 23,517 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
{ // no orientation needed
dest_width = width;
dest_height = height;
return CreateThumbnailFromSurface(pixels, width, height, pitch, dest);
}
return false;
}
std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::string>& files)
{
if (!files.size())
return {};
unsigned i... | Good job with this change. The only other step would be to use `std::make_unique`. That way, the pointer is hidden entirely, which should be our goal. | { // no orientation needed
dest_width = width;
dest_height = height;
return CreateThumbnailFromSurface(pixels, width, height, pitch, dest);
}
return false;
}
std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::string>& files)
{
if (!files.size())
return {};
unsigned i... | @@ -284,18 +284,19 @@ std::unique_ptr<CTexture> CPicture::CreateTiledThumb(const std::vector<std::stri
if (!files.size())
return {};
- unsigned int num_across = (unsigned int)ceil(sqrt((float)files.size()));
+ unsigned int num_across =
+ static_cast<unsigned int>(std::ceil(std::sqrt(static_cast<float>(... | xbmc/pictures/Picture.cpp | 26 | C++ | 0.714 | suggestion | 150 | 51 | 51 | false | [guilib][vfs][imagecache] Load picture folder images into texture cache when viewed, like standard images | 23,517 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
return true;
}
return false;
}
bool CTextureCacheJob::DoWork()
{
if (ShouldCancel(0, 0))
return false;
// check whether we need cache the job anyway
bool needsRecaching = false;
std::string path(CServiceBroker::GetTextureCache()->CheckCachedImage(m_url, needsRecaching));
if (!path.empty() && !... | please pass by const ref also for the other helper functions
```suggestion
bool IsPVROwnedImage(const std::string& additional_info)
``` | return true;
}
return false;
}
bool CTextureCacheJob::DoWork()
{
if (ShouldCancel(0, 0))
return false;
// check whether we need cache the job anyway
bool needsRecaching = false;
std::string path(CServiceBroker::GetTextureCache()->CheckCachedImage(m_url, needsRecaching));
if (!path.empty() && !... | @@ -68,6 +68,36 @@ bool CTextureCacheJob::DoWork()
return false;
}
+namespace
+{
+// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
+// cache cleaning, rather than special generated images
+bool IsPVROwnedImage(std::string additional_info) | xbmc/TextureCacheJob.cpp | 26 | C++ | 1 | refactor | 138 | 51 | 51 | false | [imagecache] Don't check special generated images for file changes every 24 hours | 23,567 | xbmc/xbmc | 17,740 | C++ | howie-f | rmrector |
return false;
}
namespace
{
// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
// cache cleaning, rather than special generated images
bool IsPVROwnedImage(std::string additional_info)
{
return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv" ||
... | ```suggestion
const bool isSpecialImage =
``` |
return false;
}
namespace
{
// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
// cache cleaning, rather than special generated images
bool IsPVROwnedImage(const std::string& additional_info)
{
return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv"... | @@ -68,6 +68,36 @@ bool CTextureCacheJob::DoWork()
return false;
}
+namespace
+{
+// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
+// cache cleaning, rather than special generated images
+bool IsPVROwnedImage(std::string additional_info)
+{
+ return additional_info == "pv... | xbmc/TextureCacheJob.cpp | 26 | C++ | 0.786 | suggestion | 49 | 51 | 51 | false | [imagecache] Don't check special generated images for file changes every 24 hours | 23,567 | xbmc/xbmc | 17,740 | C++ | howie-f | rmrector |
namespace
{
// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
// cache cleaning, rather than special generated images
bool IsPVROwnedImage(std::string additional_info)
{
return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv" ||
additional_inf... | ```suggestion
const bool isHTTP = StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
``` | namespace
{
// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
// cache cleaning, rather than special generated images
bool IsPVROwnedImage(const std::string& additional_info)
{
return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv" ||
additio... | @@ -68,6 +68,36 @@ bool CTextureCacheJob::DoWork()
return false;
}
+namespace
+{
+// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
+// cache cleaning, rather than special generated images
+bool IsPVROwnedImage(std::string additional_info)
+{
+ return additional_info == "pv... | xbmc/TextureCacheJob.cpp | 26 | C++ | 1 | suggestion | 126 | 51 | 51 | false | [imagecache] Don't check special generated images for file changes every 24 hours | 23,567 | xbmc/xbmc | 17,740 | C++ | howie-f | rmrector |
bool isSpecialImage =
!additional_info.empty() && !IsControl(additional_info) && !IsPVROwnedImage(additional_info);
if (isSpecialImage)
return false;
bool isHTTP = StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
return !isHTTP;
}
} // namespace
bool CTextureCacheJ... | `else` not needed (but doesn‘t harm and was there before) | const bool isSpecialImage =
!additional_info.empty() && !IsControl(additional_info) && !IsPVROwnedImage(additional_info);
if (isSpecialImage)
return false;
const bool isHTTP =
StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
return !isHTTP;
}
} // namespace
... | @@ -76,14 +106,17 @@ bool CTextureCacheJob::CacheTexture(std::unique_ptr<CTexture>* out_texture)
CPictureScalingAlgorithm::Algorithm scalingAlgorithm;
std::string image = DecodeImageURL(m_url, width, height, scalingAlgorithm, additional_info);
- m_details.updateable = additional_info != "music" && UpdateableUR... | xbmc/TextureCacheJob.cpp | 26 | C++ | 0.357 | suggestion | 57 | 51 | 51 | false | [imagecache] Don't check special generated images for file changes every 24 hours | 23,567 | xbmc/xbmc | 17,740 | C++ | howie-f | rmrector |
// cache cleaning, rather than special generated images
bool IsPVROwnedImage(const std::string& additional_info)
{
return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv" ||
additional_info == "pvrprovider" || additional_info == "pvrrecording" ||
StringUtils::StartsWith(ad... | ```cpp
const bool isSpecialImage =
!additional_info.empty() && !IsControl(additional_info) && !IsPVROwnedImage(additional_info);
if (isSpecialImage)
return false;
const bool isHTTP =
StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
return !isHTTP;... | // cache cleaning, rather than special generated images
bool IsPVROwnedImage(const std::string& additional_info)
{
return additional_info == "pvrchannel_radio" || additional_info == "pvrchannel_tv" ||
additional_info == "pvrprovider" || additional_info == "pvrrecording" ||
StringUtils::StartsWith(ad... | @@ -68,6 +68,37 @@ bool CTextureCacheJob::DoWork()
return false;
}
+namespace
+{
+// Most PVR images use "additional_info" to signify 'ownership' of basic images for easy
+// cache cleaning, rather than special generated images
+bool IsPVROwnedImage(const std::string& additional_info)
+{
+ return additional_info... | xbmc/TextureCacheJob.cpp | 26 | C++ | 0.929 | suggestion | 325 | 51 | 51 | false | [imagecache] Don't check special generated images for file changes every 24 hours | 23,567 | xbmc/xbmc | 17,740 | C++ | howie-f | rmrector |
StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
return !isHTTP;
}
} // namespace
bool CTextureCacheJob::CacheTexture(std::unique_ptr<CTexture>* out_texture)
{
// unwrap the URL as required
std::string additional_info;
unsigned int width, height;
CPictureScalingAlgor... | ```cpp
if (m_details.updateable)
{
// generate the hash
m_details.hash = GetImageHash(image);
if (m_details.hash.empty())
return false;
if (m_details.hash == m_oldHash)
return true;
}
``` | const bool isHTTP =
StringUtils::StartsWith(url, "http://") || StringUtils::StartsWith(url, "https://");
return !isHTTP;
}
} // namespace
bool CTextureCacheJob::CacheTexture(std::unique_ptr<CTexture>* out_texture)
{
// unwrap the URL as required
std::string additional_info;
unsigned int width, height;
... | @@ -76,14 +107,17 @@ bool CTextureCacheJob::CacheTexture(std::unique_ptr<CTexture>* out_texture)
CPictureScalingAlgorithm::Algorithm scalingAlgorithm;
std::string image = DecodeImageURL(m_url, width, height, scalingAlgorithm, additional_info);
- m_details.updateable = additional_info != "music" && UpdateableUR... | xbmc/TextureCacheJob.cpp | 26 | C++ | 0.857 | suggestion | 239 | 51 | 51 | false | [imagecache] Don't check special generated images for file changes every 24 hours | 23,567 | xbmc/xbmc | 17,740 | C++ | howie-f | rmrector |
bool finished = false;
while (!finished)
{
if (ManageVideoItemArtwork(m_movieItem, m_movieItem->GetVideoInfoTag()->m_type, finished))
{
m_hasUpdatedThumb = true;
// Update our screen
Update();
}
};
}
// Allow user to select a Fanart
void CGUIDialogVideoInfo::OnGetFanart()
{
CFi... | Better to use as:
```cpp
if (URIUtils::HasExtension(fileNameAndPath, ".mkv|.mp4|.avi|.m4v") )
{
```
The called function here https://github.com/xbmc/xbmc/blob/master/xbmc/utils/URIUtils.cpp#L91 already set to this way.
-------------
What you think to have a function to allow as this, maybe I can cr... | bool finished = false;
while (!finished)
{
if (ManageVideoItemArtwork(m_movieItem, m_movieItem->GetVideoInfoTag()->m_type, finished))
{
m_hasUpdatedThumb = true;
// Update our screen
Update();
}
};
}
namespace
{
std::string GetEmbeddedArt(const std::string& fileNameAndPath, const... | @@ -892,6 +892,38 @@ void CGUIDialogVideoInfo::OnGetArt()
};
}
+namespace
+{
+std::string GetEmbeddedArt(const std::string& fileNameAndPath, const std::string& artType)
+{
+ std::string embeddedArt;
+ if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
+ CSettings::SETTING_MYVIDEOS_USET... | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 26 | C++ | 1 | suggestion | 3,092 | 51 | 51 | false | [video] Art selection dialog: Fix support for embedded art. | 23,726 | xbmc/xbmc | 17,740 | C++ | AlwinEsch | ksooo |
CFileItemList items;
if (item.HasArt("fanart"))
{
CFileItemPtr itemCurrent(new CFileItem("fanart://Current", false));
itemCurrent->SetArt("thumb", item.GetArt("fanart"));
itemCurrent->SetLabel(g_localizeStrings.Get(20440));
items.Add(itemCurrent);
}
// add the none option
{
CFileItemPt... | Cool, good to check for the folder case :+1: | {
if (videoItem == nullptr || !videoItem->HasVideoInfoTag())
return false;
// update the db
CVideoDatabase videodb;
if (!videodb.Open())
return false;
CVideoThumbLoader loader;
CFileItem item(*videoItem);
loader.LoadItem(&item);
CFileItemList items;
if (item.HasArt("fanart"))
{
CFileI... | @@ -2324,7 +2336,7 @@ bool CGUIDialogVideoInfo::OnGetFanart(const std::shared_ptr<CFileItem>& videoIte
// add the none option
{
CFileItemPtr itemNone(new CFileItem("fanart://None", false));
- itemNone->SetArt("icon", "DefaultVideo.png");
+ itemNone->SetArt("icon", videoItem->m_bIsFolder ? "DefaultFolde... | xbmc/video/dialogs/GUIDialogVideoInfo.cpp | 26 | C++ | 0.071 | suggestion | 45 | 47 | 51 | false | [video] Art selection dialog: Fix support for embedded art. | 23,726 | xbmc/xbmc | 17,740 | C++ | AlwinEsch | ksooo |
// A list of filesystem types for LegalPath/FileName
#define LEGAL_NONE 0
#define LEGAL_WIN32_COMPAT 1
#define LEGAL_FATX 2
class CFileItem;
class CFileItemList;
class CURL;
struct ExternalStreamInfo
{
std::string name;
std::string language;
unsigned int flag = 0;
};
class CUtil
{
CU... | Was the change to the default value for `cleanChars` param of the original function intentional? | // A list of filesystem types for LegalPath/FileName
#define LEGAL_NONE 0
#define LEGAL_WIN32_COMPAT 1
#define LEGAL_FATX 2
class CFileItem;
class CFileItemList;
class CURL;
struct ExternalStreamInfo
{
std::string name;
std::string language;
unsigned int flag = 0;
};
class CUtil
{
CU... | @@ -37,10 +37,18 @@ class CUtil
{
CUtil() = delete;
public:
+ static void CleanString(const std::string& fileName,
+ std::string& title,
+ std::string& titleAndYear,
+ std::string& year,
+ bool removeExtension = fa... | xbmc/Util.h | 26 | C/C++ | 0.571 | question | 96 | 51 | 51 | false | [Scraper] Support for filename identifiers | 23,840 | xbmc/xbmc | 17,740 | C++ | rmrector | sundermann |
const std::string &action,
const std::string &pathSettings,
T &result)
{
std::stringstream str;
str << "plugin://" << ID << "?action=" << action << "&" << key << "=" << CURL::Encode(url);
str << "&pathSettings=" << CURL::Encode(pathSett... | Use a different term than "database". Maybe `idType` or `identifierType`, to somewhat match the term "type" used for unique IDs in NFOs. | return false;
}
template<class T>
static bool PythonDetails(const std::string& ID,
const std::string& key,
const std::string& url,
const std::string& action,
const std::string& pathSettings,
... | @@ -884,10 +884,13 @@ std::vector<CScraperUrl> CScraper::FindMovie(XFILE::CCurlFile &fcurl,
{
// prepare parameters for URL creation
std::string sTitle, sYear;
+ std::string database; | xbmc/addons/Scraper.cpp | 26 | C++ | 1 | suggestion | 136 | 51 | 51 | false | [Scraper] Support for filename identifiers | 23,840 | xbmc/xbmc | 17,740 | C++ | rmrector | sundermann |
else
{
sTitle = movieTitle;
sYear = std::to_string( movieYear );
}
CLog::Log(LOGDEBUG,
"{}: Searching for '{}' using {} scraper "
"(path: '{}', content: '{}', version: '{}')",
__FUNCTION__, sTitle, Name(), Path(), ADDON::TranslateContent(Content()),
Versi... | I am not a big fan of building even a tiny JSON object string with string formatting. I'd suggest creating a CVariant object with a single property and use `CJSONVariantWriter` to write to a string. | const std::string& key,
const std::string& url,
const std::string& action,
const std::string& pathSettings,
T& result)
{
const std::unordered_map<std::string, std::string> ids;
return Py... | @@ -910,6 +913,15 @@ std::vector<CScraperUrl> CScraper::FindMovie(XFILE::CCurlFile &fcurl,
if (m_isPython)
{
+ if (!database.empty() && !identifier.empty())
+ {
+ CScraperUrl scurl;
+ scurl.SetTitle(movieTitle);
+ std::string json = fmt::format(R"({{"{}":"{}"}})", database, identifier); | xbmc/addons/Scraper.cpp | 26 | C++ | 0.714 | suggestion | 198 | 51 | 51 | false | [Scraper] Support for filename identifiers | 23,840 | xbmc/xbmc | 17,740 | C++ | rmrector | sundermann |
std::string id;
return CleanString(fileName, title, titleAndYear, year, db, id, removeExtension, cleanChars);
}
void CUtil::CleanString(const std::string& strFileName,
std::string& strTitle,
std::string& strTitleAndYear,
std::string& strYear,
... | There is a lot of hardcoding going on here.
- move the regex pattern to an advanced setting
- use regex capture groups to gather the database / idType and identifier
- "id" should be a part of the regex pattern _outside_ of a capture group, if trimming is desired. I'm not sure it should be in the default pattern |
pos = std::string::npos;
number.clear();
// Handle Disc, Disk and locale specific spellings
std::string discStr{StringUtils::Format("/{} ", g_localizeStrings.Get(427))};
size_t discPos = path.rfind(discStr);
if (discPos == std::string::npos)
{
discStr = "/Disc ";
discPos = path.rfind(discStr);
... | @@ -391,6 +405,25 @@ void CUtil::CleanString(const std::string& strFileName,
CRegExp reTags(true, CRegExp::autoUtf8);
CRegExp reYear(false, CRegExp::autoUtf8);
+ CRegExp reIdentifier(true, CRegExp::autoUtf8);
+
+ if (reIdentifier.RegComp(R"((\{|\[)\w+(-|=)\w+(\}|\]))")) | xbmc/Util.cpp | 26 | C++ | 0.929 | suggestion | 316 | 51 | 51 | false | [Scraper] Support for filename identifiers | 23,840 | xbmc/xbmc | 17,740 | C++ | rmrector | sundermann |
template<>
bool DetailsFromFileItem<CVideoInfoTag>(const CFileItem& item, CVideoInfoTag& tag)
{
if (item.HasVideoInfoTag())
{
tag = *item.GetVideoInfoTag();
return true;
}
return false;
}
template<class T>
static bool PythonDetails(const std::string& ID,
const std::string& ke... | Pass to scrapers as the JSON structure with the name `uniqueIDs`. We can expand on that in the future. | }
template<>
bool DetailsFromFileItem<CVideoInfoTag>(const CFileItem& item, CVideoInfoTag& tag)
{
if (item.HasVideoInfoTag())
{
tag = *item.GetVideoInfoTag();
return true;
}
return false;
}
template<class T>
static bool PythonDetails(const std::string& ID,
const std::string& ... | @@ -846,34 +847,54 @@ void DetailsFromFileItem<CArtist>(const CFileItem &item, CArtist &artist)
for (unsigned int i = 0; i < fanart.GetNumFanarts(); i++)
artist.thumbURL.AddParsedUrl(fanart.GetImageURL(i), "fanart", fanart.GetPreviewURL(i));
}
+ return true;
}
template<>
-void DetailsFromFileItem<CV... | xbmc/addons/Scraper.cpp | 26 | C++ | 0.5 | suggestion | 102 | 51 | 51 | false | [Scraper] Support for filename identifiers | 23,840 | xbmc/xbmc | 17,740 | C++ | rmrector | sundermann |
URIUtils::PathHasParent(url, "special://temp", true) ||
URIUtils::PathHasParent(url, "resource://", true) ||
URIUtils::PathHasParent(url, "androidapp://", true) ||
URIUtils::PathHasParent(url, profileManager->GetThumbnailsFolder(), true);
}
bool CTextureCache::HasCachedImage(const std::string... | ```suggestion
return {};
```
will call the default constructor of std::string | URIUtils::PathHasParent(url, "special://temp", true) ||
URIUtils::PathHasParent(url, "resource://", true) ||
URIUtils::PathHasParent(url, "androidapp://", true) ||
URIUtils::PathHasParent(url, profileManager->GetThumbnailsFolder(), true);
}
bool CTextureCache::HasCachedImage(const std::string... | @@ -87,6 +87,9 @@ std::string CTextureCache::GetCachedImage(const std::string &image, CTextureDeta
// lookup the item in the database
if (GetCachedTexture(url, details))
{
+ if (details.file.empty())
+ return ""; | xbmc/TextureCache.cpp | 26 | C++ | 0.857 | suggestion | 86 | 51 | 51 | false | [imagecache] clarify logic around image revalidation, fixing some images returning 404 via HTTP | 23,956 | xbmc/xbmc | 17,740 | C++ | howie-f | rmrector |
\ingroup textures
\brief Simple class for passing texture detail around
*/
class CTextureDetails
{
public:
CTextureDetails()
{
id = -1;
width = height = 0;
updateable = false;
hashRevalidated = false;
};
bool operator==(const CTextureDetails &right) const
{
return (id == right.id ... | Please use `bool hashRevalidated{false};` (and line in constructor can be removed). | \ingroup textures
\brief Simple class for passing texture detail around
*/
class CTextureDetails
{
public:
bool operator==(const CTextureDetails &right) const
{
return (id == right.id &&
file == right.file &&
width == right.width );
};
int id{-1};
std::string file;
st... | @@ -44,6 +45,7 @@ class CTextureDetails
unsigned int width;
unsigned int height;
bool updateable;
+ bool hashRevalidated; | xbmc/TextureCacheJob.h | 26 | C/C++ | 0.571 | suggestion | 83 | 51 | 51 | false | [imagecache] clarify logic around image revalidation, fixing some images returning 404 via HTTP | 23,956 | xbmc/xbmc | 17,740 | C++ | garbear | rmrector |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.