diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/integration_tests/llimage_libtest/CMakeLists.txt | 122 | ||||
-rw-r--r-- | indra/integration_tests/llimage_libtest/llimage_libtest.cpp | 138 | ||||
-rw-r--r-- | indra/llplugin/llpluginclassmedia.cpp | 5 | ||||
-rw-r--r-- | indra/llplugin/llpluginclassmedia.h | 1 | ||||
-rw-r--r-- | indra/llplugin/llplugininstance.cpp | 20 | ||||
-rw-r--r-- | indra/llplugin/llplugininstance.h | 2 | ||||
-rw-r--r-- | indra/llplugin/llpluginprocesschild.cpp | 3 | ||||
-rw-r--r-- | indra/llplugin/llpluginprocesschild.h | 1 | ||||
-rw-r--r-- | indra/llplugin/llpluginprocessparent.cpp | 4 | ||||
-rw-r--r-- | indra/llplugin/llpluginprocessparent.h | 2 | ||||
-rw-r--r-- | indra/newview/llviewermedia.cpp | 5 | ||||
-rw-r--r-- | indra/test_apps/llplugintest/llmediaplugintest.cpp | 4 |
12 files changed, 239 insertions, 68 deletions
diff --git a/indra/integration_tests/llimage_libtest/CMakeLists.txt b/indra/integration_tests/llimage_libtest/CMakeLists.txt index e3c508659b..0733e5e283 100644 --- a/indra/integration_tests/llimage_libtest/CMakeLists.txt +++ b/indra/integration_tests/llimage_libtest/CMakeLists.txt @@ -1,25 +1,22 @@ # -*- cmake -*- -# Integration tests of the llimage library (JPEG2000 images reading and writing) - -if (VIEWER) +# Integration tests of the llimage library (JPEG2000, PNG, jpeg, etc... images reading and writing) project (llimage_libtest) include(00-Common) include(LLCommon) +include(Linking) +include(LLSharedLibs) include(LLImage) include(LLImageJ2COJ) include(LLKDU) include(LLMath) -#include(LLVFS) # ugh, needed for LLDir -#include(LLXML) -#include(LLXUIXML) -include(Linking) -# include(Tut) +include(LLVFS) include_directories( ${LLCOMMON_INCLUDE_DIRS} + ${LLVFS_INCLUDE_DIRS} ${LLIMAGE_INCLUDE_DIRS} ${LLMATH_INCLUDE_DIRS} ) @@ -38,12 +35,23 @@ set_source_files_properties(${llimage_libtest_HEADER_FILES} list(APPEND llimage_libtest_SOURCE_FILES ${llimage_libtest_HEADER_FILES}) -add_executable(llimage_libtest ${llimage_libtest_SOURCE_FILES}) +add_executable(llimage_libtest + WIN32 + MACOSX_BUNDLE + ${llimage_libtest_SOURCE_FILES} +) -# Link with OS-specific libraries +set_target_properties(llimage_libtest + PROPERTIES + WIN32_EXECUTABLE + FALSE +) + +# OS-specific libraries if (DARWIN) - find_library(COCOA_LIBRARY Cocoa) - set(OS_LIBRARIES ${COCOA_LIBRARY}) + include(CMakeFindFrameworks) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + set(OS_LIBRARIES ${COREFOUNDATION_LIBRARY}) elseif (WINDOWS) #ll_stack_trace needs this now... list(APPEND WINDOWS_LIBRARIES dbghelp) @@ -51,64 +59,72 @@ elseif (WINDOWS) elseif (LINUX) set(OS_LIBRARIES) else (DARWIN) - message(FATAL_ERROR "unknown platform") + message(FATAL_ERROR "Unknown platform") endif (DARWIN) -# Libraries on which this library depends, needed for Linux builds +# Libraries on which this application depends on # Sort by high-level to low-level target_link_libraries(llimage_libtest + ${LLCOMMON_LIBRARIES} + ${LLVFS_LIBRARIES} ${LLIMAGE_LIBRARIES} ${LLKDU_LIBRARIES} ${KDU_LIBRARY} ${LLIMAGEJ2COJ_LIBRARIES} ${OS_LIBRARIES} - ${GOOGLE_PERFTOOLS_LIBRARIES} ) if (DARWIN) - set_target_properties(llimage_libtest - PROPERTIES - OUTPUT_NAME "llimage_libtest" - MACOSX_BUNDLE_INFO_STRING "llimage test utility" - MACOSX_BUNDLE_GUI_IDENTIFIER "llimage_libtest" - MACOSX_BUNDLE_LONG_VERSION_STRING "0.5" - MACOSX_BUNDLE_BUNDLE_NAME "llimage_libtest" - MACOSX_BUNDLE_SHORT_VERSION_STRING "v0.5" - MACOSX_BUNDLE_BUNDLE_VERSION "v0.5" - MACOSX_BUNDLE_COPYRIGHT "Copyright Linden Lab 2011" - ) - # TODO : Copy over libs in the bundle -elseif (WINDOWS) - set_target_properties(llimage_libtest - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:LIBCMT" - LINK_FLAGS_DEBUG "/NODEFAULTLIB:MSVCRT /NODEFAULTLIB:LIBCMTD" - ) - - # Copy over OpenJPEG.dll - # *NOTE: On Windows with VS2005, only the first comment prints - set(OPENJPEG_RELEASE - "${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/release/openjpeg.dll") - add_custom_command( TARGET llimage_libtest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${OPENJPEG_RELEASE} ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Copying OpenJPEG DLLs to binary directory" - ) - set(OPENJPEG_DEBUG - "${CMAKE_SOURCE_DIR}/../libraries/i686-win32/lib/debug/openjpegd.dll") - add_custom_command( TARGET llimage_libtest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${OPENJPEG_DEBUG} ${CMAKE_CURRENT_BINARY_DIR} - ) -elseif (LINUX) - # TODO : please help me get this to build and run for Linux! + # Path inside the app bundle where we'll need to copy libraries + set(LLIMAGE_LIBTEST_DESTINATION_DIR + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llimage_libtest.app/Contents/Resources + ) + # Create the Contents/Resources directory + add_custom_command( + TARGET llimage_libtest POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS + -E + make_directory + ${LLIMAGE_LIBTEST_DESTINATION_DIR} + COMMENT "Creating Resources directory in app bundle." + ) else (DARWIN) - message(FATAL_ERROR "unknown platform") + set(LLIMAGE_LIBTEST_DESTINATION_DIR + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/ + ) endif (DARWIN) +get_target_property(BUILT_LLCOMMON llcommon LOCATION) +add_custom_command(TARGET llimage_libtest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${BUILT_LLCOMMON} ${LLIMAGE_LIBTEST_DESTINATION_DIR} + DEPENDS ${BUILT_LLCOMMON} +) + +if (DARWIN) + # Copy the required libraries to the package app + add_custom_command(TARGET llimage_libtest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libapr-1.0.3.7.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR} + DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libapr-1.0.3.7.dylib + add_custom_command(TARGET llimage_libtest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libaprutil-1.0.3.8.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR} + DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libaprutil-1.0.3.8.dylib + add_custom_command(TARGET llimage_libtest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libexception_handler.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR} + DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libexception_handler.dylib + add_custom_command(TARGET llimage_libtest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libexpat.0.5.0.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR} + DEPENDS ${CMAKE_SOURCE_DIR}/../libraries/universal-darwin/lib_release/libexpat.0.5.0.dylib + ) +endif (DARWIN) + +if (WINDOWS) + # Check indra/test_apps/llplugintest/CMakeLists.txt for an example of what to copy over for Windows and how +endif (WINDOWS) + # Ensure people working on the viewer don't break this library # *NOTE: This could be removed, or only built by TeamCity, if the build # and link times become too long. add_dependencies(viewer llimage_libtest) -endif (VIEWER) +ll_deploy_sharedlibs_command(llimage_libtest) diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index a4a4d10bcb..e8fe4864fb 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -25,23 +25,151 @@ * $/LicenseInfo$ */ #include "linden_common.h" +#include "llpointer.h" #include "llimage_libtest.h" -// linden library includes +// Linden library includes +#include "llimage.h" +#include "llimagejpeg.h" +#include "llimagepng.h" +#include "llimagebmp.h" +#include "llimagetga.h" +#include "llimagej2c.h" +#include "lldir.h" +// system libraries #include <iostream> -// *TODO: switch to using TUT -// *TODO: teach TeamCity about this program, run automatically after full builds +static const char USAGE[] = "\n" +"usage:\tllimage_libtest [options]\n" +"\n" +" --help print this help\n" +"\n"; -void init_llimage() +LLPointer<LLImageRaw> load_image(const std::string &src_filename) { + std::string exten = gDirUtilp->getExtension(src_filename); + U32 codec = LLImageBase::getCodecFromExtension(exten); + + LLPointer<LLImageFormatted> image; + switch (codec) + { + case IMG_CODEC_BMP: + image = new LLImageBMP(); + break; + case IMG_CODEC_TGA: + image = new LLImageTGA(); + break; + case IMG_CODEC_JPEG: + image = new LLImageJPEG(); + break; + case IMG_CODEC_J2C: + image = new LLImageJ2C(); + break; + case IMG_CODEC_PNG: + image = new LLImagePNG(); + break; + default: + return NULL; + } + + if (!image->load(src_filename)) + { + return NULL; + } + + if( (image->getComponents() != 3) && (image->getComponents() != 4) ) + { + std::cout << "Image files with less than 3 or more than 4 components are not supported\n"; + return NULL; + } + + LLPointer<LLImageRaw> raw_image = new LLImageRaw; + if (!image->decode(raw_image, 0.0f)) + { + return NULL; + } + + return raw_image; +} + +bool save_image(const std::string &filepath, LLPointer<LLImageRaw> raw_image) +{ + std::string exten = gDirUtilp->getExtension(filepath); + U32 codec = LLImageBase::getCodecFromExtension(exten); + + LLPointer<LLImageFormatted> image; + switch (codec) + { + case IMG_CODEC_BMP: + image = new LLImageBMP(); + break; + case IMG_CODEC_TGA: + image = new LLImageTGA(); + break; + case IMG_CODEC_JPEG: + image = new LLImageJPEG(); + break; + case IMG_CODEC_J2C: + image = new LLImageJ2C(); + break; + case IMG_CODEC_PNG: + image = new LLImagePNG(); + break; + default: + return NULL; + } + + if (!image->encode(raw_image, 0.0f)) + { + return false; + } + + return image->save(filepath); } int main(int argc, char** argv) { - init_llimage(); + // Init whatever is necessary + ll_init_apr(); + LLImage::initClass(); + + // Analyze command line arguments + for (int arg=1; arg<argc; ++arg) + { + if (!strcmp(argv[arg], "--help")) + { + // always send the usage to standard out + std::cout << USAGE << std::endl; + return 0; + } + + } + + // List of (input,output) files + + // Load file + LLPointer<LLImageRaw> raw_image = load_image("lolcat-monorail.jpg"); + if (raw_image) + { + std::cout << "Image loaded\n" << std::endl; + } + else + { + std::cout << "Image not found\n" << std::endl; + } + + // Save file + if (raw_image) + { + save_image("monorail.png",raw_image); + } + + // Output stats on each file + + // Cleanup and exit + LLImage::cleanupClass(); return 0; } diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index 595c470a19..26a20cede8 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -64,9 +64,10 @@ LLPluginClassMedia::~LLPluginClassMedia() reset(); } -bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug) +bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::string &plugin_dir, const std::string &plugin_filename, bool debug) { LL_DEBUGS("Plugin") << "launcher: " << launcher_filename << LL_ENDL; + LL_DEBUGS("Plugin") << "dir: " << plugin_dir << LL_ENDL; LL_DEBUGS("Plugin") << "plugin: " << plugin_filename << LL_ENDL; mPlugin = new LLPluginProcessParent(this); @@ -77,7 +78,7 @@ bool LLPluginClassMedia::init(const std::string &launcher_filename, const std::s message.setValue("target", mTarget); sendMessage(message); - mPlugin->init(launcher_filename, plugin_filename, debug); + mPlugin->init(launcher_filename, plugin_dir, plugin_filename, debug); return true; } diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index c826e13c40..618e928a08 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -45,6 +45,7 @@ public: // local initialization, called by the media manager when creating a source virtual bool init(const std::string &launcher_filename, + const std::string &plugin_dir, const std::string &plugin_filename, bool debug); diff --git a/indra/llplugin/llplugininstance.cpp b/indra/llplugin/llplugininstance.cpp index c326961db4..7cde82a20e 100644 --- a/indra/llplugin/llplugininstance.cpp +++ b/indra/llplugin/llplugininstance.cpp @@ -32,6 +32,10 @@ #include "llapr.h" +#if LL_WINDOWS +#include "direct.h" // needed for _chdir() +#endif + /** Virtual destructor. */ LLPluginInstanceMessageListener::~LLPluginInstanceMessageListener() { @@ -73,10 +77,24 @@ LLPluginInstance::~LLPluginInstance() * @param[in] plugin_file Name of plugin dll/dylib/so. TODO:DOC is this correct? see .h * @return 0 if successful, APR error code or error code from the plugin's init function on failure. */ -int LLPluginInstance::load(std::string &plugin_file) +int LLPluginInstance::load(const std::string& plugin_dir, std::string &plugin_file) { pluginInitFunction init_function = NULL; + if ( plugin_dir.length() ) + { +#if LL_WINDOWS + // VWR-21275: + // *SOME* Windows systems fail to load the Qt plugins if the current working + // directory is not the same as the directory with the Qt DLLs in. + // This should not cause any run time issues since we are changing the cwd for the + // plugin shell process and not the viewer. + // Changing back to the previous directory is not necessary since the plugin shell + // quits once the plugin exits. + _chdir( plugin_dir.c_str() ); +#endif + }; + int result = apr_dso_load(&mDSOHandle, plugin_file.c_str(), gAPRPoolp); diff --git a/indra/llplugin/llplugininstance.h b/indra/llplugin/llplugininstance.h index 50531ca77f..e6926c3e37 100644 --- a/indra/llplugin/llplugininstance.h +++ b/indra/llplugin/llplugininstance.h @@ -56,7 +56,7 @@ public: // Load a plugin dll/dylib/so // Returns 0 if successful, APR error code or error code returned from the plugin's init function on failure. - int load(std::string &plugin_file); + int load(const std::string& plugin_dir, std::string &plugin_file); // Sends a message to the plugin. void sendMessage(const std::string &message); diff --git a/indra/llplugin/llpluginprocesschild.cpp b/indra/llplugin/llpluginprocesschild.cpp index 45a86476ac..0beb46d0e5 100644 --- a/indra/llplugin/llpluginprocesschild.cpp +++ b/indra/llplugin/llpluginprocesschild.cpp @@ -139,7 +139,7 @@ void LLPluginProcessChild::idle(void) if(!mPluginFile.empty()) { mInstance = new LLPluginInstance(this); - if(mInstance->load(mPluginFile) == 0) + if(mInstance->load(mPluginDir, mPluginFile) == 0) { mHeartbeat.start(); mHeartbeat.setTimerExpirySec(HEARTBEAT_SECONDS); @@ -348,6 +348,7 @@ void LLPluginProcessChild::receiveMessageRaw(const std::string &message) if(message_name == "load_plugin") { mPluginFile = parsed.getValue("file"); + mPluginDir = parsed.getValue("dir"); } else if(message_name == "shm_add") { diff --git a/indra/llplugin/llpluginprocesschild.h b/indra/llplugin/llpluginprocesschild.h index 22ff403ad6..a9d6794e40 100644 --- a/indra/llplugin/llpluginprocesschild.h +++ b/indra/llplugin/llpluginprocesschild.h @@ -92,6 +92,7 @@ private: LLSocket::ptr_t mSocket; std::string mPluginFile; + std::string mPluginDir; LLPluginInstance *mInstance; diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp index c002de0462..db4b8b1316 100644 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -157,10 +157,11 @@ void LLPluginProcessParent::errorState(void) setState(STATE_ERROR); } -void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug) +void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_dir, const std::string &plugin_filename, bool debug) { mProcess.setExecutable(launcher_filename); mPluginFile = plugin_filename; + mPluginDir = plugin_dir; mCPUUsage = 0.0f; mDebug = debug; setState(STATE_INITIALIZED); @@ -445,6 +446,7 @@ void LLPluginProcessParent::idle(void) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "load_plugin"); message.setValue("file", mPluginFile); + message.setValue("dir", mPluginDir); sendMessage(message); } diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h index 32394809ef..c66723f175 100644 --- a/indra/llplugin/llpluginprocessparent.h +++ b/indra/llplugin/llpluginprocessparent.h @@ -57,6 +57,7 @@ public: ~LLPluginProcessParent(); void init(const std::string &launcher_filename, + const std::string &plugin_dir, const std::string &plugin_filename, bool debug); @@ -151,6 +152,7 @@ private: LLProcessLauncher mProcess; std::string mPluginFile; + std::string mPluginDir; LLPluginProcessParentOwner *mOwner; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index f16d8814dd..9b02bdbe33 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -53,7 +53,7 @@ #include "llwebsharing.h" // For LLWebSharing::setOpenIDCookie(), *TODO: find a better way to do this! #include "llfilepicker.h" #include "llnotifications.h" - +#include "lldir_win32.h" #include "llevent.h" // LLSimpleListener #include "llnotificationsutil.h" #include "lluuid.h" @@ -1766,7 +1766,8 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_ media_source->setTarget(target); - if (media_source->init(launcher_name, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"))) + const std::string plugin_dir = gDirUtilp->getLLPluginDir(); + if (media_source->init(launcher_name, plugin_dir, plugin_name, gSavedSettings.getBOOL("PluginAttachDebuggerToPlugins"))) { return media_source; } diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp index 4a2272032b..e9d4d99753 100644 --- a/indra/test_apps/llplugintest/llmediaplugintest.cpp +++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp @@ -1620,7 +1620,7 @@ mediaPanel* LLMediaPluginTest::addMediaPanel( std::string url ) std::string user_data_path = std::string( cwd ) + "/"; #endif media_source->setUserDataPath(user_data_path); - media_source->init( launcher_name, plugin_name, false ); + media_source->init( launcher_name, user_data_path, plugin_name, false ); media_source->setDisableTimeout(mDisableTimeout); // make a new panel and save parameters @@ -1860,7 +1860,7 @@ mediaPanel* LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string #endif media_source->setUserDataPath(user_data_path); - media_source->init( launcher_name, plugin_name, false ); + media_source->init( launcher_name, user_data_path, plugin_name, false ); media_source->setDisableTimeout(mDisableTimeout); // make a new panel and save parameters |