diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloaterflickr.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llimagefiltersmanager.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llimagefiltersmanager.h | 1 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llsnapshotlivepreview.h | 6 |
5 files changed, 32 insertions, 15 deletions
diff --git a/indra/newview/llfloaterflickr.cpp b/indra/newview/llfloaterflickr.cpp index 8395c0db5a..cff57bfa13 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 888e5ec5dd..14177b4f05 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 e916dc7187..5591e14a41 100644 --- a/indra/newview/llimagefiltersmanager.h +++ b/indra/newview/llimagefiltersmanager.h @@ -54,6 +54,7 @@ public: //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 2931178ace..c38798bbea 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 d5ae3b491b..6addc87de2 100644 --- a/indra/newview/llsnapshotlivepreview.h +++ b/indra/newview/llsnapshotlivepreview.h @@ -95,8 +95,8 @@ public: 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 @@ private: 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; |