diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp index 8395c0db5ad278791f60985e46bf2665ba99c1aa..cff57bfa139098d8c52c698766e439511c80f7c6 100644 --- a/indra/newview/llfloaterflickr.cpp +++ b/indra/newview/llfloaterflickr.cpp @@ -361,13 +361,12 @@ void LLFlickrPhotoPanel::updateResolution(BOOL do_update) // Merov : // Get the old filter, compare to the current one "filter_name" and set if changed // If changed, also force the updateSnapshot() here under - S32 original_filter = previewp->getFilter(); - S32 filter = ("Gray Scale" == filter_name ? 1 : 0); + std::string original_filter = previewp->getFilter(); - if ((original_width != width) || (original_height != height) || (original_filter != filter)) + if ((original_width != width) || (original_height != height) || (original_filter != filter_name)) { previewp->setSize(width, height); - previewp->setFilter(filter); + previewp->setFilter(filter_name); // hide old preview as the aspect ratio could be wrong lldebugs << "updating thumbnail" << llendl; diff --git a/indra/newview/llimagefiltersmanager.cpp b/indra/newview/llimagefiltersmanager.cpp index 888e5ec5dda58c94f3065a03217cef79d87b451f..14177b4f057aef546d8083ff6fbaedefebdf3a94 100644 --- a/indra/newview/llimagefiltersmanager.cpp +++ b/indra/newview/llimagefiltersmanager.cpp @@ -85,6 +85,13 @@ void LLImageFiltersManager::loadFiltersFromDir(const std::string& dir) } } - +std::string LLImageFiltersManager::getFilterPath(const std::string& filter_name) +{ + // *TODO : we should store (filter name, path) in a std::map + std::string file = filter_name + ".xml"; + std::string dir = getSysDir(); + std::string path = gDirUtilp->add(dir, file); + return path; +} //============================================================================ diff --git a/indra/newview/llimagefiltersmanager.h b/indra/newview/llimagefiltersmanager.h index e916dc71879cd3d1fff6f6cc33e8cfce2683fb69..5591e14a416bafaea49c000faf792d36292fa7a2 100644 --- a/indra/newview/llimagefiltersmanager.h +++ b/indra/newview/llimagefiltersmanager.h @@ -54,6 +54,7 @@ class LLImageFiltersManager : public LLSingleton<LLImageFiltersManager> //LLSD loadFilter(const std::string& filter_name); //void executeFilter(const LLSD& filter_data, LLPointer<LLImageRaw> raw_image); const std::vector<std::string> &getFiltersList() const { return mFiltersList; } + std::string getFilterPath(const std::string& filter_name); protected: private: diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 2931178ace02fabf32754d815088affbd82702b2..c38798bbea46687582381cbad548d58e0e8439b1 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -37,6 +37,8 @@ #include "llfloaterfacebook.h" #include "llfloaterflickr.h" #include "llfloatertwitter.h" +#include "llimagefilter.h" +#include "llimagefiltersmanager.h" #include "llimagebmp.h" #include "llimagej2c.h" #include "llimagejpeg.h" @@ -90,7 +92,7 @@ LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Param mCameraRot(LLViewerCamera::getInstance()->getQuaternion()), mSnapshotActive(FALSE), mSnapshotBufferType(LLViewerWindow::SNAPSHOT_TYPE_COLOR), - mFilterType(0) + mFilterName("") { setSnapshotQuality(gSavedSettings.getS32("SnapshotQuality")); mSnapshotDelayTimer.setTimerExpirySec(0.0f); @@ -586,10 +588,14 @@ void LLSnapshotLivePreview::generateThumbnailImage(BOOL force_update) if(raw) { raw->expandToPowerOfTwo(); - // Merov : Filter also the thumbnail? - if (getFilter() == 1) + // Filter the thumbnail + if (getFilter() != "") { - raw->filterGrayScale(); + LLImageFilter filter; + std::string filter_path = LLImageFiltersManager::getInstance()->getFilterPath(getFilter()); + filter.loadFromFile(filter_path); + filter.executeFilter(raw); + //raw->filterGrayScale(); } mThumbnailImage = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); mThumbnailUpToDate = TRUE ; @@ -695,10 +701,14 @@ BOOL LLSnapshotLivePreview::onIdle( void* snapshot_preview ) } else { - // Merov : Time to apply the filter to mPreviewImage!!! - if (previewp->getFilter() == 1) + // Apply the filter to mPreviewImage + if (previewp->getFilter() != "") { - previewp->mPreviewImage->filterGrayScale(); + LLImageFilter filter; + std::string filter_path = LLImageFiltersManager::getInstance()->getFilterPath(previewp->getFilter()); + filter.loadFromFile(filter_path); + filter.executeFilter(previewp->mPreviewImage); + //previewp->mPreviewImage->filterGrayScale(); } // delete any existing image diff --git a/indra/newview/llsnapshotlivepreview.h b/indra/newview/llsnapshotlivepreview.h index d5ae3b491ba6bc2a501abd0da188a37406aa9ca1..6addc87de2e647108a8b05bffd8d2747f6d57b64 100644 --- a/indra/newview/llsnapshotlivepreview.h +++ b/indra/newview/llsnapshotlivepreview.h @@ -95,8 +95,8 @@ class LLSnapshotLivePreview : public LLView void setSnapshotFormat(LLFloaterSnapshot::ESnapshotFormat type) { mSnapshotFormat = type; } bool setSnapshotQuality(S32 quality, bool set_by_user = true); void setSnapshotBufferType(LLViewerWindow::ESnapshotType type) { mSnapshotBufferType = type; } - void setFilter(S32 filter) { mFilterType = filter; } - S32 getFilter() { return mFilterType; } + void setFilter(std::string filter_name) { mFilterName = filter_name; } + std::string getFilter() { return mFilterName; } void updateSnapshot(BOOL new_snapshot, BOOL new_thumbnail = FALSE, F32 delay = 0.f); void saveWeb(); void saveTexture(); @@ -156,7 +156,7 @@ class LLSnapshotLivePreview : public LLView LLQuaternion mCameraRot; BOOL mSnapshotActive; LLViewerWindow::ESnapshotType mSnapshotBufferType; - S32 mFilterType; // *TODO: eventually use a string and a named filter + std::string mFilterName; public: static std::set<LLSnapshotLivePreview*> sList;