Commit c97025cb authored by Gilles Caulier's avatar Gilles Caulier 🗼

Merge branch 'master' of invent.kde.org:kde/digikam

parents 8cc20a13 68f89cc6
......@@ -9,6 +9,7 @@ Name[et]=Reageeriv HTML5
Name[is]=Skalanlegt HTML5 (responsive)
Name[it]=HTML5 Responsive
Name[nl]=Reageert op HTML5
Name[nn]=HTML5 responsiv
Name[pt]=HTML5 Responsivo
Name[pt_BR]=HTML5 responsivo
Name[sl]=Odzivno na HTML5
......@@ -42,6 +43,7 @@ Name[es]=Bobulous
Name[is]=Bobulous
Name[it]=Bobulous
Name[nl]=Bobulous
Name[nn]=Bobulous
Name[pt]=Bolhas
Name[pt_BR]=Bolhas
Name[sl]=Bobulous
......@@ -61,6 +63,7 @@ Name[et]=Reageeriv HTML5
Name[is]=Skalanlegt HTML5 (responsive)
Name[it]=HTML5 Responsive
Name[nl]=Reageert op HTML5
Name[nn]=HTML5 responsiv
Name[pt]=HTML5 Responsivo
Name[pt_BR]=HTML5 responsivo
Name[sl]=Odzivno na HTML5
......@@ -267,6 +270,7 @@ Name[et]=PhotoSwipe'i kasutamine
Name[is]=Nota PhotoSwipe
Name[it]=Usa PhotoSwipe
Name[nl]=PhotoSwipe gebruiken
Name[nn]=Bruk PhotoSwipe
Name[pt]=Usar o PhotoSwipe
Name[pt_BR]=Usar o PhotoSwipe
Name[sl]=Uporabi PhotoSwipe
......@@ -291,6 +295,7 @@ Name[et]=PhotoSwipe'i tausta läbipaistmatus
Name[is]=Ógegnsæi bakgrunns PhotoSwipe
Name[it]=Opacità sfondo di PhotoSwipe
Name[nl]=Achtergronddekking van PhotoSwipe
Name[nn]=Gjennomsikt til bakgrunn for PhotoSwipe
Name[pt]=Opacidade do Fundo do PhotoSwipe
Name[pt_BR]=Opacidade do plano de fundo do PhotoSwipe
Name[sl]=Neprosojnost ozadja v PhotoSwipe
......@@ -313,6 +318,7 @@ Name[et]=PhotoSwipe'i jagamisnupp
Name[is]=Deilingarhnappur PhotoSwipe
Name[it]=Pulsante di condivisione PhotoSwipe
Name[nl]=Delenknop van PhotoSwipe
Name[nn]=Deleknapp for PhotoSwipe
Name[pt]=Botão de partilha do PhotoSwipe
Name[pt_BR]=Botão de compartilhamento do PhotoSwipe
Name[sl]=Gumb za skupno rabo PhotoSwipe
......@@ -360,6 +366,7 @@ Name[et]=GPS-andmete näitamine
Name[is]=Birta GPS-gögn
Name[it]=Mostra dati GPS
Name[nl]=GPS gegevens tonen
Name[nn]=Vis GPS-data
Name[pt]=Mostrar os dados de GPS
Name[pt_BR]=Mostrar dados de GPS
Name[sl]=Prikaži podatke GPS
......
......@@ -257,8 +257,8 @@ public:
uchar* scanLine(uint i) const;
bool hasAlpha() const;
bool sixteenBit() const;
uint numBytes() const;
uint numPixels() const;
quint64 numBytes() const;
quint64 numPixels() const;
/**
* Return the number of bytes depth of one pixel : 4 (non sixteenBit) or 8 (sixteen)
......
......@@ -166,7 +166,17 @@ void DImg::copyImageData(const QExplicitlySharedDataPointer<Private>& src)
size_t DImg::allocateData() const
{
size_t size = m_priv->width * m_priv->height * (m_priv->sixteenBit ? 8 : 4);
quint64 size = (quint64)m_priv->width *
(quint64)m_priv->height *
(quint64)(m_priv->sixteenBit ? 8 : 4);
if (size > (quint64)std::numeric_limits<size_t>::max())
{
m_priv->null = true;
return 0;
}
m_priv->data = DImgLoader::new_failureTolerant(size);
if (!m_priv->data)
......
......@@ -182,14 +182,17 @@ void DImg::setMetadata(const MetaEngineData& data)
m_priv->metaData = data;
}
uint DImg::numBytes() const
quint64 DImg::numBytes() const
{
return (width() * height() * bytesDepth());
return ((quint64)width() *
(quint64)height() *
(quint64)bytesDepth());
}
uint DImg::numPixels() const
quint64 DImg::numPixels() const
{
return (width() * height());
return ((quint64)width() *
(quint64)height());
}
int DImg::bytesDepth() const
......
......@@ -876,7 +876,7 @@ void BlurFXFilter::shakeBlur(DImg* const orgImage, DImg* const destImage, int Di
{
int progress;
int numBytes = orgImage->numBytes();
quint64 numBytes = orgImage->numBytes();
QScopedArrayPointer<uchar> layer1(new uchar[numBytes]);
QScopedArrayPointer<uchar> layer2(new uchar[numBytes]);
QScopedArrayPointer<uchar> layer3(new uchar[numBytes]);
......
......@@ -83,7 +83,7 @@ unsigned char*& DImgLoader::imageData()
return m_image->m_priv->data;
}
unsigned int DImgLoader::imageNumBytes() const
quint64 DImgLoader::imageNumBytes() const
{
return m_image->numBytes();
}
......
......@@ -103,7 +103,7 @@ public:
static qint64 checkAllocation(qint64 fullSize);
template <typename Type> static Type* new_failureTolerant(size_t unsecureSize);
template <typename Type> static Type* new_failureTolerant(quint64 w, quint64 h, uint typesPerPixel);
template <typename Type> static Type* new_failureTolerant(uint w, uint h, uint typesPerPixel);
protected:
......@@ -116,7 +116,7 @@ protected:
bool imageHasAlpha() const;
bool imageSixteenBit() const;
unsigned int imageNumBytes() const;
quint64 imageNumBytes() const;
int imageBitsDepth() const;
int imageBytesDepth() const;
......@@ -156,14 +156,14 @@ private:
* 32bit overflow and exceeding the size_t type
*/
template <typename Type>
Q_INLINE_TEMPLATE Type* DImgLoader::new_failureTolerant(quint64 w, quint64 h, uint typesPerPixel)
Q_INLINE_TEMPLATE Type* DImgLoader::new_failureTolerant(uint w, uint h, uint typesPerPixel)
{
quint64 requested = w * h * quint64(typesPerPixel);
quint64 requested = (quint64)w * (quint64)h * (quint64)typesPerPixel;
quint64 maximum = std::numeric_limits<size_t>::max();
if (requested > maximum)
{
qCCritical(DIGIKAM_DIMG_LOG) << "Requested memory of" << requested*quint64(sizeof(Type))
qCCritical(DIGIKAM_DIMG_LOG) << "Requested memory of" << requested * quint64(sizeof(Type))
<< "is larger than size_t supported by platform.";
return nullptr;
}
......
......@@ -197,16 +197,21 @@ DImg* LoadingCache::retrieveImage(const QString& cacheKey) const
bool LoadingCache::putImage(const QString& cacheKey, const DImg& img, const QString& filePath) const
{
int cost = img.numBytes();
bool successfulyInserted = d->imageCache.insert(cacheKey, new DImg(img), cost);
bool isInserted = false;
if (successfulyInserted && !filePath.isEmpty())
if (isCacheable(img))
{
d->mapImageFilePath(filePath, cacheKey);
d->fileWatch()->addedImage(filePath);
int cost = img.numBytes() / 1024;
isInserted = d->imageCache.insert(cacheKey, new DImg(img), cost);
if (isInserted && !filePath.isEmpty())
{
d->mapImageFilePath(filePath, cacheKey);
d->fileWatch()->addedImage(filePath);
}
}
return successfulyInserted;
return isInserted;
}
void LoadingCache::removeImage(const QString& cacheKey)
......@@ -223,7 +228,7 @@ bool LoadingCache::isCacheable(const DImg& img) const
{
// return whether image fits in cache
return (uint)d->imageCache.maxCost() >= img.numBytes();
return (quint64)d->imageCache.maxCost() >= (img.numBytes() / 1024);
}
void LoadingCache::addLoadingProcess(LoadingProcess* const process)
......@@ -253,7 +258,7 @@ void LoadingCache::notifyNewLoadingProcess(LoadingProcess* const process, const
void LoadingCache::setCacheSize(int megabytes)
{
qCDebug(DIGIKAM_GENERAL_LOG) << "Allowing a cache size of" << megabytes << "MB";
d->imageCache.setMaxCost(megabytes * 1024 * 1024);
d->imageCache.setMaxCost(megabytes * 1024);
}
// --- Thumbnails ----
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment