add quick thumbnails to cache

This commit is contained in:
Steve Herrell
2010-11-04 21:36:52 -04:00
parent 791622c3a0
commit 9abe74d73a
5 changed files with 27 additions and 20 deletions

View File

@@ -23,7 +23,7 @@
CacheImageData::CacheImageData () CacheImageData::CacheImageData ()
: md5(""), supported(false), format(FT_Invalid), rank(0), inTrash(false), recentlySaved(false), : md5(""), supported(false), format(FT_Invalid), rank(0), inTrash(false), recentlySaved(false),
timeValid(false), exifValid(false) { timeValid(false), exifValid(false), thumbImgType(0) {
} }
int CacheImageData::load (const Glib::ustring& fname) { int CacheImageData::load (const Glib::ustring& fname) {

View File

@@ -59,6 +59,12 @@ class CacheImageData {
int thumbImgType; int thumbImgType;
int thumbOffset; int thumbOffset;
enum
{
FULL_THUMBNAIL = 0, // was the thumbnail generated from whole file
QUICK_THUMBNAIL = 1, // was rhe thumbnail generated from embedded jpeg
};
CacheImageData (); CacheImageData ();
int load (const Glib::ustring& fname); int load (const Glib::ustring& fname);

View File

@@ -136,7 +136,14 @@ FileThumbnailButtonSet* FileBrowserEntry::getThumbButtonSet () {
void FileBrowserEntry::procParamsChanged (Thumbnail* thm, int whoChangedIt) { void FileBrowserEntry::procParamsChanged (Thumbnail* thm, int whoChangedIt) {
refreshThumbnailImage (); if ( thumbnail->isQuick() )
{
refreshQuickThumbnailImage ();
}
else
{
refreshThumbnailImage ();
}
} }
struct tiupdate { struct tiupdate {

View File

@@ -35,7 +35,7 @@ using namespace rtengine::procparams;
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf) Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf)
: fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), : fname(fname), cfs(*cf), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL),
pparamsValid(false), needsReProcessing(true), lastImg(NULL), pparamsValid(false), needsReProcessing(true), lastImg(NULL),
quick_(false), initial_(false) { initial_(false) {
cfs.load (getCacheFileName ("data")+".txt"); cfs.load (getCacheFileName ("data")+".txt");
loadProcParams (); loadProcParams ();
@@ -46,7 +46,7 @@ Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageDa
Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5) Thumbnail::Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5)
: fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), pparamsValid(false), : fname(fname), cachemgr(cm), ref(1), enqueueNumber(0), tpp(NULL), pparamsValid(false),
needsReProcessing(true), lastImg(NULL), needsReProcessing(true), lastImg(NULL),
quick_(false), initial_(true) { initial_(true) {
cfs.md5 = md5; cfs.md5 = md5;
@@ -97,36 +97,32 @@ void Thumbnail::_generateThumbnailImage () {
// 1. if we are here it's because we aren't in the cache so load the JPG // 1. if we are here it's because we aren't in the cache so load the JPG
// image out of the RAW. Mark as "quick". // image out of the RAW. Mark as "quick".
// 2. if we don't find that then just grab the real image. // 2. if we don't find that then just grab the real image.
bool quick = false;
rtengine::RawMetaDataLocation ri; rtengine::RawMetaDataLocation ri;
if ( initial_ ) if ( initial_ )
{ {
quick_ = true; quick = true;
tpp = rtengine::Thumbnail::loadQuickFromRaw (fname, ri, tw, th, 1); tpp = rtengine::Thumbnail::loadQuickFromRaw (fname, ri, tw, th, 1);
} }
if ( tpp == 0 ) if ( tpp == 0 )
{ {
quick_ = false; quick = false;
tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, tw, th, 1); tpp = rtengine::Thumbnail::loadFromRaw (fname, ri, tw, th, 1);
} }
if (tpp) { if (tpp) {
cfs.format = FT_Raw; cfs.format = FT_Raw;
cfs.thumbImgType = quick ? CacheImageData::QUICK_THUMBNAIL : CacheImageData::FULL_THUMBNAIL;
infoFromImage (fname, &ri); infoFromImage (fname, &ri);
} }
} }
if (tpp ) if (tpp )
{ {
if ( !quick_ ) _saveThumbnail ();
{
_saveThumbnail ();
}
cfs.supported = true; cfs.supported = true;
} }
needsReProcessing = true; needsReProcessing = true;
if ( !quick_ ) cfs.save (getCacheFileName ("data")+".txt");
{
cfs.save (getCacheFileName ("data")+".txt");
}
generateExifDateTimeStrings (); generateExifDateTimeStrings ();
} }
@@ -282,7 +278,7 @@ rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::Pro
if (!tpp) if (!tpp)
return NULL; return NULL;
if ( quick_ ) if ( cfs.thumbImgType == CacheImageData::QUICK_THUMBNAIL )
{ {
return tpp->quickProcessImage (pparams, h, rtengine::TI_Nearest, scale); return tpp->quickProcessImage (pparams, h, rtengine::TI_Nearest, scale);
} }
@@ -296,12 +292,11 @@ rtengine::IImage8* Thumbnail::upgradeThumbImage (const rtengine::procparams::Pro
Glib::Mutex::Lock lock(mutex); Glib::Mutex::Lock lock(mutex);
if ( !quick_ ) if ( cfs.thumbImgType != CacheImageData::QUICK_THUMBNAIL )
{ {
return 0; return 0;
} }
quick_ = false;
_generateThumbnailImage(); _generateThumbnailImage();
return tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale); return tpp->processImage (pparams, h, rtengine::TI_Bilinear, scale);
} }
@@ -413,7 +408,7 @@ void Thumbnail::_loadThumbnail(bool firstTrial) {
delete tpp; delete tpp;
tpp = NULL; tpp = NULL;
} }
else { else if ( cfs.thumbImgType == CacheImageData::FULL_THUMBNAIL ) {
// load aehistogram // load aehistogram
tpp->readAEHistogram (getCacheFileName ("aehistograms")); tpp->readAEHistogram (getCacheFileName ("aehistograms"));

View File

@@ -59,7 +59,6 @@ class Thumbnail {
Glib::ustring dateTimeString; Glib::ustring dateTimeString;
bool initial_; bool initial_;
bool quick_;
// vector of listeners // vector of listeners
std::vector<ThumbnailListener*> listeners; std::vector<ThumbnailListener*> listeners;
@@ -84,7 +83,7 @@ class Thumbnail {
void clearProcParams (int whoClearedIt=-1); void clearProcParams (int whoClearedIt=-1);
void loadProcParams (); void loadProcParams ();
bool isQuick() { return quick_; } bool isQuick() { return cfs.thumbImgType == CacheImageData::QUICK_THUMBNAIL; }
bool isPParamsValid() { return pparamsValid; } bool isPParamsValid() { return pparamsValid; }
bool isRecentlySaved (); bool isRecentlySaved ();
void imageDeveloped (); void imageDeveloped ();