diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2009-07-01 13:42:15 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2009-07-01 13:42:15 -0400 |
commit | dc93fe6cc68115dd280881c0896fa3f0e8d46f2c (patch) | |
tree | 830c7f3086b938b09122ba436004f22dabffd3dc /indra | |
parent | ca798b4fb243fbd85f71ea1b384181dd07ab6f66 (diff) |
DEV-31980: Wrap LLViewerWindow::saveSnapshot() with an event API.
Add LLViewerWindowListener per Incremental_Viewer_Automation/Event_API.
Add LLViewerWindowListener pointer to LLViewerWindow, and initialize in ctor.
Add llviewerwindowlistener.{h,cpp} to newview/CMakeLists.txt.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.h | 4 | ||||
-rw-r--r-- | indra/newview/llviewerwindowlistener.cpp | 78 | ||||
-rw-r--r-- | indra/newview/llviewerwindowlistener.h | 34 |
5 files changed, 125 insertions, 1 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 20c59faae0..53a59031ed 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -415,6 +415,7 @@ set(viewer_SOURCE_FILES llviewerthrottle.cpp llviewervisualparam.cpp llviewerwindow.cpp + llviewerwindowlistener.cpp llvlcomposition.cpp llvlmanager.cpp llvoavatar.cpp @@ -835,6 +836,7 @@ set(viewer_HEADER_FILES llviewerthrottle.h llviewervisualparam.h llviewerwindow.h + llviewerwindowlistener.h llvlcomposition.h llvlmanager.h llvoavatar.h diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 5c9f8af216..dcd37d85da 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -30,6 +30,10 @@ * $/LicenseInfo$ */ +#if defined(LL_WINDOWS) +#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally +#endif + #include "llviewerprecompiledheaders.h" // system library includes @@ -189,6 +193,7 @@ #include "llfloaternotificationsconsole.h" #include "llnearbychathistory.h" +#include "llviewerwindowlistener.h" #if LL_WINDOWS #include <tchar.h> // For Unicode conversion methods @@ -1262,7 +1267,8 @@ LLViewerWindow::LLViewerWindow( mResDirty(false), mStatesDirty(false), mIsFullscreenChecked(false), - mCurrResolutionIndex(0) + mCurrResolutionIndex(0), + mViewerWindowListener(new LLViewerWindowListener("LLViewerWindow", this)) { LLNotificationChannel::buildChannel("VW_alerts", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "alert")); LLNotificationChannel::buildChannel("VW_alertmodal", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "alertmodal")); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index eae1bf0343..b729889631 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -50,6 +50,7 @@ #include "llnotifications.h" #include "llmousehandler.h" #include "llcursortypes.h" +#include <boost/scoped_ptr.hpp> class LLView; class LLViewerObject; @@ -62,6 +63,7 @@ class LLImageRaw; class LLHUDIcon; class LLWindow; class LLRootView; +class LLViewerWindowListener; #define PICK_HALF_WIDTH 5 #define PICK_DIAMETER (2 * PICK_HALF_WIDTH + 1) @@ -450,6 +452,8 @@ protected: bool mIsFullscreenChecked; // Did the user check the fullscreen checkbox in the display settings U32 mCurrResolutionIndex; + boost::scoped_ptr<LLViewerWindowListener> mViewerWindowListener; + protected: static std::string sSnapshotBaseName; static std::string sSnapshotDir; diff --git a/indra/newview/llviewerwindowlistener.cpp b/indra/newview/llviewerwindowlistener.cpp new file mode 100644 index 0000000000..ad90b1d2ab --- /dev/null +++ b/indra/newview/llviewerwindowlistener.cpp @@ -0,0 +1,78 @@ +/** + * @file llviewerwindowlistener.cpp + * @author Nat Goodspeed + * @date 2009-06-30 + * @brief Implementation for llviewerwindowlistener. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "llviewerprecompiledheaders.h" +// associated header +#include "llviewerwindowlistener.h" +// STL headers +#include <map> +// std headers +// external library headers +// other Linden headers +#include "llviewerwindow.h" + +LLViewerWindowListener::LLViewerWindowListener(const std::string& pumpname, LLViewerWindow* llviewerwindow): + LLDispatchListener(pumpname, "op"), + mViewerWindow(llviewerwindow) +{ + // add() every method we want to be able to invoke via this event API. + LLSD saveSnapshotArgs; + saveSnapshotArgs["filename"] = LLSD::String(); + saveSnapshotArgs["reply"] = LLSD::String(); + // The following are optional, so don't build them into required prototype. +// saveSnapshotArgs["width"] = LLSD::Integer(); +// saveSnapshotArgs["height"] = LLSD::Integer(); +// saveSnapshotArgs["showui"] = LLSD::Boolean(); +// saveSnapshotArgs["rebuild"] = LLSD::Boolean(); +// saveSnapshotArgs["type"] = LLSD::String(); + add("saveSnapshot", &LLViewerWindowListener::saveSnapshot, saveSnapshotArgs); +} + +void LLViewerWindowListener::saveSnapshot(const LLSD& event) const +{ + LLReqID reqid(event); + typedef std::map<LLSD::String, LLViewerWindow::ESnapshotType> TypeMap; + TypeMap types; +#define tp(name) types[#name] = LLViewerWindow::SNAPSHOT_TYPE_##name + tp(COLOR); + tp(DEPTH); + tp(OBJECT_ID); +#undef tp + // Our add() call should ensure that the incoming LLSD does in fact + // contain our required arguments. Deal with the optional ones. + S32 width (mViewerWindow->getWindowDisplayWidth()); + S32 height(mViewerWindow->getWindowDisplayHeight()); + if (event.has("width")) + width = event["width"].asInteger(); + if (event.has("height")) + height = event["height"].asInteger(); + // showui defaults to true, requiring special treatment + bool showui = true; + if (event.has("showui")) + showui = event["showui"].asBoolean(); + bool rebuild(event["rebuild"]); // defaults to false + LLViewerWindow::ESnapshotType type(LLViewerWindow::SNAPSHOT_TYPE_COLOR); + if (event.has("type")) + { + TypeMap::const_iterator found = types.find(event["type"]); + if (found == types.end()) + { + LL_ERRS("LLViewerWindowListener") << "LLViewerWindowListener::saveSnapshot(): " + << "unrecognized type " << event["type"] << LL_ENDL; + } + type = found->second; + } + bool ok = mViewerWindow->saveSnapshot(event["filename"], width, height, showui, rebuild, type); + LLSD response(reqid.makeResponse()); + response["ok"] = ok; + LLEventPumps::instance().obtain(event["reply"]).post(response); +} diff --git a/indra/newview/llviewerwindowlistener.h b/indra/newview/llviewerwindowlistener.h new file mode 100644 index 0000000000..f756a5310f --- /dev/null +++ b/indra/newview/llviewerwindowlistener.h @@ -0,0 +1,34 @@ +/** + * @file llviewerwindowlistener.h + * @author Nat Goodspeed + * @date 2009-06-30 + * @brief Event API for subset of LLViewerWindow methods + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * Copyright (c) 2009, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLVIEWERWINDOWLISTENER_H) +#define LL_LLVIEWERWINDOWLISTENER_H + +#include "lleventdispatcher.h" + +class LLViewerWindow; +class LLSD; + +/// Listen on an LLEventPump with specified name for LLViewerWindow request events. +class LLViewerWindowListener: public LLDispatchListener +{ +public: + /// Specify the pump name on which to listen, and bind the LLViewerWindow + /// instance to use (e.g. gViewerWindow). + LLViewerWindowListener(const std::string& pumpname, LLViewerWindow* llviewerwindow); + +private: + void saveSnapshot(const LLSD& event) const; + + LLViewerWindow* mViewerWindow; +}; + +#endif /* ! defined(LL_LLVIEWERWINDOWLISTENER_H) */ |