diff options
| author | Erik Kundiman <erik@megapahit.org> | 2025-09-29 16:29:19 +0800 | 
|---|---|---|
| committer | Erik Kundiman <erik@megapahit.org> | 2025-10-01 16:56:56 +0800 | 
| commit | a954d290674db08ecaf3c1e6484a0cb6647b88b5 (patch) | |
| tree | 3b672bac3e7d6807cd485ad5f041f69a5c729f46 /indra | |
| parent | e6eaa7e29990431b5207dbb4f8ae5560cf884acb (diff) | |
| parent | a6d4c1d394eef2cea41f6c6bcd751fec746ec17d (diff) | |
Merge tag 'Second_Life_Release#a6d4c1d3-2025.07' into 2025.07
Diffstat (limited to 'indra')
198 files changed, 3182 insertions, 3474 deletions
| diff --git a/indra/CMakeLists.txt b/indra/CMakeLists.txt index e0e864ed70..adf30de2b5 100644 --- a/indra/CMakeLists.txt +++ b/indra/CMakeLists.txt @@ -10,7 +10,13 @@  ## Nicky: Ideally we want at least 3.21 for good preset support  ##   We're not there yet, but once done, there is a kludge in Linking.cmake  #    "if(${CMAKE_VERSION} VERSION_LESS "3.20.0")" that can also be removed -cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.16.0...4.0 FATAL_ERROR) +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.29.0") +    cmake_policy(SET CMP0156 NEW) +endif() +if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.31.0") +    cmake_policy(SET CMP0179 NEW) +endif()  set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING      "The root project/makefile/solution name. Defaults to SecondLife.") @@ -33,6 +39,14 @@ if (NOT DEFINED CMAKE_CXX_STANDARD)    set(CMAKE_CXX_STANDARD 20)  endif()  set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_SCAN_FOR_MODULES OFF) # This slows down build massively + +set(CMAKE_OPTIMIZE_DEPENDENCIES ON) + +set(CMAKE_COLOR_DIAGNOSTICS ON) + +# Speeds up cmake generation significantly in some cases +set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON)  include(Variables)  include(BuildVersion) diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 5cb0c23d6d..42e211c84d 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -85,6 +85,8 @@ if (NOT CMAKE_CXX_COMPILER_ID MATCHES GNU AND WINDOWS)        NOMINMAX  #     DOM_DYNAMIC                     # For shared library colladadom        _CRT_SECURE_NO_WARNINGS         # Allow use of sprintf etc +      _CRT_NONSTDC_NO_DEPRECATE       # Allow use of sprintf etc +      _CRT_OBSOLETE_NO_WARNINGS        _WINSOCK_DEPRECATED_NO_WARNINGS # Disable deprecated WinSock API warnings        )    add_compile_options( @@ -226,26 +228,17 @@ if (LINUX OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")  endif (LINUX OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")  if (DARWIN) +  # Use rpath loading on macos +  set(CMAKE_MACOSX_RPATH TRUE) +    # Warnings should be fatal -- thanks, Nicky Perian, for spotting reversed default    set(CLANG_DISABLE_FATAL_WARNINGS OFF)    set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}") -  set(DARWIN_extra_cstar_flags "-Wno-unused-local-typedef -Wno-deprecated-declarations") -  # Ensure that CMAKE_CXX_FLAGS has the correct -g debug information format -- -  # see Variables.cmake. -  string(REPLACE "-gdwarf-2" "-g${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}" -    CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DARWIN_extra_cstar_flags}") -  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  ${DARWIN_extra_cstar_flags}") -  # NOTE: it's critical that the optimization flag is put in front. -  # NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered. -## Really?? On developer machines too? -##set(ENABLE_SIGNING TRUE) -##set(SIGNING_IDENTITY "Developer ID Application: Linden Research, Inc.")    # required for clang-15/xcode-15 since our boost package still uses deprecated std::unary_function/binary_function    # see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#C++-Standard-Library -  add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) +  #add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)    set(GCC_WARNINGS -Wall -Wno-sign-compare -Wno-trigraphs) diff --git a/indra/cmake/APR.cmake b/indra/cmake/APR.cmake index 58a00c74da..4ce0d47f7f 100644 --- a/indra/cmake/APR.cmake +++ b/indra/cmake/APR.cmake @@ -23,35 +23,25 @@ use_system_binary( apr apr-util )  use_prebuilt_binary(apr_suite)  if (WINDOWS) -  if (LLCOMMON_LINK_SHARED) -    set(APR_selector "lib") -  else (LLCOMMON_LINK_SHARED) -    set(APR_selector "") -  endif (LLCOMMON_LINK_SHARED) -  target_link_libraries( ll::apr INTERFACE -          ${ARCH_PREBUILT_DIRS_RELEASE}/${APR_selector}apr-1.lib -          ${ARCH_PREBUILT_DIRS_RELEASE}/${APR_selector}aprutil-1.lib -          ) -  target_compile_definitions( ll::apr INTERFACE APR_DECLARE_STATIC=1 APU_DECLARE_STATIC=1 API_DECLARE_STATIC=1) -elseif (DARWIN) -  if (LLCOMMON_LINK_SHARED) -    set(APR_selector     "0.dylib") -    set(APRUTIL_selector "0.dylib") -  else (LLCOMMON_LINK_SHARED) -    set(APR_selector     "a") -    set(APRUTIL_selector "a") -  endif (LLCOMMON_LINK_SHARED) - -  target_link_libraries( ll::apr INTERFACE -          ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.${APR_selector} -          ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.${APR_selector} -          iconv -          ) -else() -  target_link_libraries( ll::apr INTERFACE -          ${ARCH_PREBUILT_DIRS_RELEASE}/libapr-1.a -          ${ARCH_PREBUILT_DIRS_RELEASE}/libaprutil-1.a -          rt -          ) +  target_compile_definitions(ll::apr INTERFACE APR_DECLARE_STATIC=1 APU_DECLARE_STATIC=1 API_DECLARE_STATIC=1)  endif () -target_include_directories( ll::apr SYSTEM INTERFACE  ${LIBS_PREBUILT_DIR}/include/apr-1 ) + +find_library(APR_LIBRARY +    NAMES +    apr-1.lib +    libapr-1.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +find_library(APRUTIL_LIBRARY +    NAMES +    aprutil-1.lib +    libaprutil-1.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::apr INTERFACE ${APR_LIBRARY} ${APRUTIL_LIBRARY}) + +if(DARWIN) +  target_link_libraries(ll::apr INTERFACE iconv) +endif() + +target_include_directories(ll::apr SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/apr-1) diff --git a/indra/cmake/Audio.cmake b/indra/cmake/Audio.cmake index c569fba4e8..db0969ff23 100644 --- a/indra/cmake/Audio.cmake +++ b/indra/cmake/Audio.cmake @@ -16,23 +16,29 @@ use_system_binary(vorbis)  use_prebuilt_binary(ogg_vorbis)  target_include_directories( ll::vorbis SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include ) -if (WINDOWS) -  target_link_libraries(ll::vorbis INTERFACE -        optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libogg.lib -        debug ${ARCH_PREBUILT_DIRS_DEBUG}/libogg.lib -        optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisenc.lib -        debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbisenc.lib -        optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisfile.lib -        debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbisfile.lib -        optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbis.lib -        debug ${ARCH_PREBUILT_DIRS_DEBUG}/libvorbis.lib -    ) -else (WINDOWS) -  target_link_libraries(ll::vorbis INTERFACE -        ${ARCH_PREBUILT_DIRS_RELEASE}/libogg.a -        ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisenc.a -        ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbisfile.a -        ${ARCH_PREBUILT_DIRS_RELEASE}/libvorbis.a -        ) -endif (WINDOWS) +find_library(OGG_LIBRARY +    NAMES +    libogg.lib +    libogg.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +find_library(VORBIS_LIBRARY +    NAMES +    libvorbis.lib +    libvorbis.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +find_library(VORBISENC_LIBRARY +    NAMES +    libvorbisenc.lib +    libvorbisenc.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +find_library(VORBISFILE_LIBRARY +    NAMES +    libvorbisfile.lib +    libvorbisfile.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::vorbis INTERFACE ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY} ) diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake index 8459214f59..ba9daeadf1 100644 --- a/indra/cmake/Boost.cmake +++ b/indra/cmake/Boost.cmake @@ -50,39 +50,118 @@ use_prebuilt_binary(boost)  set(addrsfx "-x${ADDRESS_SIZE}")  if (WINDOWS) -  target_link_libraries( ll::boost INTERFACE -          libboost_context-mt${addrsfx} -          libboost_fiber-mt${addrsfx} -          libboost_filesystem-mt${addrsfx} -          libboost_program_options-mt${addrsfx} -          libboost_regex-mt${addrsfx} -          libboost_system-mt${addrsfx} -          libboost_thread-mt${addrsfx} -          libboost_url-mt${addrsfx}) -elseif (LINUX) -  target_link_libraries( ll::boost INTERFACE -          boost_fiber-mt${addrsfx} -          boost_context-mt${addrsfx} -          boost_filesystem-mt${addrsfx} -          boost_program_options-mt${addrsfx} -          boost_regex-mt${addrsfx} -          boost_system-mt${addrsfx} -          boost_thread-mt${addrsfx} -          boost_url-mt${addrsfx}) -elseif (DARWIN) -  target_link_libraries( ll::boost INTERFACE -          boost_context-mt${addrsfx} -          boost_fiber-mt${addrsfx} -          boost_filesystem-mt${addrsfx} -          boost_program_options-mt${addrsfx} -          boost_regex-mt${addrsfx} -          boost_system-mt${addrsfx} -          boost_thread-mt${addrsfx} -          boost_url-mt${addrsfx}) + +    find_library(BOOST_CONTEXT_LIBRARY +        NAMES +        libboost_context-mt +        libboost_context-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_FIBER_LIBRARY +        NAMES +        libboost_fiber-mt +        libboost_fiber-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_FILESYSTEM_LIBRARY +        NAMES +        libboost_filesystem-mt +        libboost_filesystem-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_PROGRAMOPTIONS_LIBRARY +        NAMES +        libboost_program_options-mt +        libboost_program_options-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_REGEX_LIBRARY +        NAMES +        libboost_regex-mt +        libboost_regex-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_SYSTEM_LIBRARY +        NAMES +        libboost_system-mt +        libboost_system-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_THREAD_LIBRARY +        NAMES +        libboost_thread-mt +        libboost_thread-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_URL_LIBRARY +        NAMES +        libboost_url-mt +        libboost_url-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +else (WINDOWS) + +    find_library(BOOST_CONTEXT_LIBRARY +       NAMES +       boost_context-mt +       boost_context-mt${addrsfx} +       PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_FIBER_LIBRARY +        NAMES +        boost_fiber-mt +        boost_fiber-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_FILESYSTEM_LIBRARY +        NAMES +        boost_filesystem-mt +        boost_filesystem-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_PROGRAMOPTIONS_LIBRARY +        NAMES +        boost_program_options-mt +        boost_program_options-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_REGEX_LIBRARY +        NAMES +        boost_regex-mt +        boost_regex-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_SYSTEM_LIBRARY +        NAMES +        boost_system-mt +        boost_system-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_THREAD_LIBRARY +        NAMES +        boost_thread-mt +        boost_thread-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +    find_library(BOOST_URL_LIBRARY +        NAMES +        boost_url-mt +        boost_url-mt${addrsfx} +        PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) +  endif (WINDOWS) +target_link_libraries(ll::boost INTERFACE +    ${BOOST_FIBER_LIBRARY} +    ${BOOST_CONTEXT_LIBRARY} +    ${BOOST_FILESYSTEM_LIBRARY} +    ${BOOST_PROGRAMOPTIONS_LIBRARY} +    ${BOOST_REGEX_LIBRARY} +    ${BOOST_SYSTEM_LIBRARY} +    ${BOOST_THREAD_LIBRARY} +    ${BOOST_URL_LIBRARY}) +  if (LINUX) -    set(BOOST_SYSTEM_LIBRARY ${BOOST_SYSTEM_LIBRARY} rt) -    set(BOOST_THREAD_LIBRARY ${BOOST_THREAD_LIBRARY} rt) +    target_link_libraries(ll::boost INTERFACE rt)  endif (LINUX) diff --git a/indra/cmake/CEFPlugin.cmake b/indra/cmake/CEFPlugin.cmake index b70be7926f..9e2f6c0c1c 100644 --- a/indra/cmake/CEFPlugin.cmake +++ b/indra/cmake/CEFPlugin.cmake @@ -5,37 +5,7 @@ include(Prebuilt)  include_guard()  add_library( ll::cef INTERFACE IMPORTED ) -if (CMAKE_OSX_ARCHITECTURES MATCHES arm64) -    if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/dullahan_installed OR NOT ${dullahan_installed} EQUAL 0) -        if (NOT EXISTS ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070244.tar.bz2) -            file(DOWNLOAD -                https://megapahit.net/downloads/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070244.tar.bz2 -                ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070244.tar.bz2 -                SHOW_PROGRESS -                ) -        endif (NOT EXISTS ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070244.tar.bz2) -        file(ARCHIVE_EXTRACT -            INPUT ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070244.tar.bz2 -            DESTINATION ${LIBS_PREBUILT_DIR} -            ) -        file(WRITE ${PREBUILD_TRACKING_DIR}/dullahan_installed "0") -    endif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/dullahan_installed OR NOT ${dullahan_installed} EQUAL 0) -elseif (CMAKE_OSX_ARCHITECTURES MATCHES x86_64) -    if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/dullahan_installed OR NOT ${dullahan_installed} EQUAL 0) -        if (NOT EXISTS ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070158.tar.bz2) -            file(DOWNLOAD -                https://megapahit.net/downloads/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070158.tar.bz2 -                ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070158.tar.bz2 -                SHOW_PROGRESS -                ) -        endif (NOT EXISTS ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070158.tar.bz2) -        file(ARCHIVE_EXTRACT -            INPUT ${CMAKE_BINARY_DIR}/dullahan-1.14.0.202312131437_118.7.1_g99817d2_chromium-118.0.5993.119-darwin64-242070158.tar.bz2 -            DESTINATION ${LIBS_PREBUILT_DIR} -            ) -        file(WRITE ${PREBUILD_TRACKING_DIR}/dullahan_installed "0") -    endif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/dullahan_installed OR NOT ${dullahan_installed} EQUAL 0) -elseif (CMAKE_SYSTEM_PROCESSOR MATCHES aarch64) +if (CMAKE_SYSTEM_PROCESSOR MATCHES aarch64)      if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/dullahan_installed OR NOT ${dullahan_installed} EQUAL 0)          if (NOT EXISTS ${CMAKE_BINARY_DIR}/v1.14.0-r3.tar.gz)              file(DOWNLOAD @@ -84,9 +54,9 @@ elseif (CMAKE_SYSTEM_PROCESSOR MATCHES aarch64)              file(WRITE ${PREBUILD_TRACKING_DIR}/dullahan_installed "${dullahan_installed}")          endif (${DULLAHAN_RESULT})      endif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/dullahan_installed OR NOT ${dullahan_installed} EQUAL 0) -else (CMAKE_OSX_ARCHITECTURES MATCHES arm64) +else ()  use_prebuilt_binary(dullahan) -endif (CMAKE_OSX_ARCHITECTURES MATCHES arm64) +endif ()  execute_process(      COMMAND patchelf --remove-rpath bin/release/dullahan_host @@ -116,7 +86,6 @@ elseif (DARWIN)          ${ARCH_PREBUILT_DIRS_RELEASE}/libcef_dll_wrapper.a          ${ARCH_PREBUILT_DIRS_RELEASE}/libdullahan.a          ${APPKIT_LIBRARY} -        "-F ${CEF_LIBRARY}"         )  elseif (LINUX) diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index a77e0fca06..a3233f1c6f 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -56,6 +56,7 @@ set(cmake_SOURCE_FILES          TemplateCheck.cmake          TinyEXR.cmake          TinyGLTF.cmake +        Tracy.cmake          Tut.cmake          UI.cmake          UnixInstall.cmake diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake index 0153e69d5b..680f2f3ac2 100644 --- a/indra/cmake/Copy3rdPartyLibs.cmake +++ b/indra/cmake/Copy3rdPartyLibs.cmake @@ -59,11 +59,6 @@ if(WINDOWS)          openjp2.dll          ) -    if(LLCOMMON_LINK_SHARED) -        set(release_files ${release_files} libapr-1.dll) -        set(release_files ${release_files} libaprutil-1.dll) -    endif() -      # Filenames are different for 32/64 bit BugSplat file and we don't      # have any control over them so need to branch.      if (USE_BUGSPLAT) @@ -178,15 +173,6 @@ elseif(DARWIN)          libndofdev.dylib         ) -    if(LLCOMMON_LINK_SHARED) -        set(release_files ${release_files} -            libapr-1.0.dylib -            libapr-1.dylib -            libaprutil-1.0.dylib -            libaprutil-1.dylib -            ) -    endif() -      if (TARGET ll::discord_sdk)        list(APPEND release_files libdiscord_partner_sdk.dylib)      endif () @@ -236,13 +222,6 @@ elseif(LINUX)                   libgmodule-2.0.so                   libgobject-2.0.so                   ) - -        if(LLCOMMON_LINK_SHARED) -            set(release_files ${release_files} -                libapr-1.so.0 -                libaprutil-1.so.0 -                ) -        endif()       endif()  else(WINDOWS) diff --git a/indra/cmake/Discord.cmake b/indra/cmake/Discord.cmake index 1896c12853..33ad5e7c09 100644 --- a/indra/cmake/Discord.cmake +++ b/indra/cmake/Discord.cmake @@ -47,4 +47,8 @@ if (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKIN  endif ()  target_include_directories(ll::discord_sdk SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/discord_sdk) -target_link_libraries(ll::discord_sdk INTERFACE discord_partner_sdk) +find_library(DISCORD_LIBRARY +    NAMES +    discord_partner_sdk +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) +target_link_libraries(ll::discord_sdk INTERFACE ${DISCORD_LIBRARY}) diff --git a/indra/cmake/EXPAT.cmake b/indra/cmake/EXPAT.cmake index 1a0b8789dc..fe6dced795 100644 --- a/indra/cmake/EXPAT.cmake +++ b/indra/cmake/EXPAT.cmake @@ -2,18 +2,21 @@  include(Prebuilt)  include_guard() -add_library( ll::expat INTERFACE IMPORTED ) +add_library(ll::expat INTERFACE IMPORTED)  use_system_binary(expat)  use_prebuilt_binary(expat) +  if (WINDOWS) -    target_compile_definitions( ll::expat INTERFACE XML_STATIC=1) -    target_link_libraries( ll::expat  INTERFACE -            debug ${ARCH_PREBUILT_DIRS_DEBUG}/libexpatd.lib -            optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.lib) -else () -    target_link_libraries( ll::expat  INTERFACE -            debug ${ARCH_PREBUILT_DIRS_DEBUG}/libexpat.a -            optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libexpat.a) +    target_compile_definitions(ll::expat INTERFACE XML_STATIC=1)  endif () -target_include_directories( ll::expat SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include ) + +find_library(EXPAT_LIBRARY +    NAMES +    libexpat.lib +    libexpat.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::expat INTERFACE ${EXPAT_LIBRARY}) + +target_include_directories(ll::expat SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) diff --git a/indra/cmake/FreeType.cmake b/indra/cmake/FreeType.cmake index d5c7891032..09dc649515 100644 --- a/indra/cmake/FreeType.cmake +++ b/indra/cmake/FreeType.cmake @@ -16,9 +16,10 @@ use_system_binary(freetype)  use_prebuilt_binary(freetype)  target_include_directories( ll::freetype SYSTEM INTERFACE  ${LIBS_PREBUILT_DIR}/include/freetype2/) -if (WINDOWS) -    target_link_libraries( ll::freetype INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/freetype.lib) -else() -    target_link_libraries( ll::freetype INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libfreetype.a) -endif() +find_library(FREETYPE_LIBRARY +    NAMES +    freetype.lib +    libfreetype.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) +target_link_libraries(ll::freetype INTERFACE ${FREETYPE_LIBRARY}) diff --git a/indra/cmake/Hunspell.cmake b/indra/cmake/Hunspell.cmake index 129679febd..b063363bc0 100644 --- a/indra/cmake/Hunspell.cmake +++ b/indra/cmake/Hunspell.cmake @@ -8,17 +8,17 @@ use_prebuilt_binary(dictionaries)  add_library( ll::hunspell INTERFACE IMPORTED )  use_system_binary(hunspell)  use_prebuilt_binary(libhunspell) +  if (WINDOWS)      target_compile_definitions( ll::hunspell INTERFACE HUNSPELL_STATIC=1) -    target_link_libraries( ll::hunspell INTERFACE -        debug ${ARCH_PREBUILT_DIRS_DEBUG}/libhunspell.lib -        optimized ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell.lib -        ) -elseif(DARWIN) -    target_link_libraries( ll::hunspell INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell-1.7.a -        ) -elseif(LINUX) -    target_link_libraries( ll::hunspell INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libhunspell-1.7.a -        )  endif() + +find_library(HUNSPELL_LIBRARY +    NAMES +    libhunspell.lib +    libhunspell-1.7.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::hunspell INTERFACE ${HUNSPELL_LIBRARY}) +  target_include_directories( ll::hunspell SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/hunspell) diff --git a/indra/cmake/JPEG.cmake b/indra/cmake/JPEG.cmake index ade5a070cc..f864ca7f8d 100644 --- a/indra/cmake/JPEG.cmake +++ b/indra/cmake/JPEG.cmake @@ -8,13 +8,13 @@ add_library( ll::libjpeg INTERFACE IMPORTED )  use_system_binary(libjpeg)  use_prebuilt_binary(libjpeg-turbo) -if (LINUX) -  target_link_libraries( ll::libjpeg INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a) -elseif (DARWIN) -  target_link_libraries( ll::libjpeg INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libjpeg.a) -elseif (WINDOWS) -    target_link_libraries( ll::libjpeg INTERFACE -      debug ${ARCH_PREBUILT_DIRS_DEBUG}/jpeg.lib -      optimized ${ARCH_PREBUILT_DIRS_RELEASE}/jpeg.lib) -endif (LINUX) -target_include_directories( ll::libjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) + +find_library(JPEG_LIBRARY +    NAMES +    jpeg.lib +    libjpeg.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::libjpeg INTERFACE ${JPEG_LIBRARY}) + +target_include_directories(ll::libjpeg SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake index 5d96a4398f..15d5be235c 100644 --- a/indra/cmake/LLAddBuildTest.cmake +++ b/indra/cmake/LLAddBuildTest.cmake @@ -99,6 +99,13 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)      target_include_directories (PROJECT_${project}_TEST_${name} PRIVATE ${LIBS_OPEN_DIR}/test )      set_target_properties(PROJECT_${project}_TEST_${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}") +    if (DARWIN) +      set_target_properties(PROJECT_${project}_TEST_${name} +          PROPERTIES +          BUILD_WITH_INSTALL_RPATH 1 +          INSTALL_RPATH "@executable_path/Resources" +          ) +    endif(DARWIN)      #      # Per-codefile additional / external project dep and lib dep property extraction @@ -232,7 +239,10 @@ FUNCTION(LL_ADD_INTEGRATION_TEST      # test binaries always need to be signed for local development      set_target_properties(INTEGRATION_TEST_${testname}              PROPERTIES -            XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-") +            XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-" +            BUILD_WITH_INSTALL_RPATH 1 +            INSTALL_RPATH "@executable_path/Resources" +            )    endif ()    # Add link deps to the executable diff --git a/indra/cmake/LLKDU.cmake b/indra/cmake/LLKDU.cmake index 668b07ffab..7680ab7b54 100644 --- a/indra/cmake/LLKDU.cmake +++ b/indra/cmake/LLKDU.cmake @@ -13,14 +13,26 @@ add_library( ll::kdu INTERFACE IMPORTED )  if (USE_KDU)    include(Prebuilt)    use_prebuilt_binary(kdu) +    if (WINDOWS) -    target_link_libraries( ll::kdu INTERFACE kdu.lib) +    find_library(KDU_LIBRARY +      NAMES +      kdu +      PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) +    else (WINDOWS) -    target_link_libraries( ll::kdu INTERFACE libkdu.a) +    find_library(KDU_LIBRARY +      NAMES +      libkdu.a +      PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) +    endif (WINDOWS) +  target_link_libraries(ll::kdu INTERFACE ${KDU_LIBRARY}) +    target_include_directories( ll::kdu SYSTEM INTERFACE            ${AUTOBUILD_INSTALL_DIR}/include/kdu            ${LIBS_OPEN_DIR}/llkdu            ) +  target_compile_definitions(ll::kdu INTERFACE KDU_NO_THREADS=1)  endif (USE_KDU) diff --git a/indra/cmake/LLPrimitive.cmake b/indra/cmake/LLPrimitive.cmake index b092f064c2..f8a58e18a1 100644 --- a/indra/cmake/LLPrimitive.cmake +++ b/indra/cmake/LLPrimitive.cmake @@ -129,16 +129,24 @@ use_prebuilt_binary(colladadom)  use_prebuilt_binary(minizip-ng) # needed for colladadom  use_prebuilt_binary(libxml2) -if (WINDOWS) -    target_link_libraries( ll::minizip-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/minizip.lib ) -else() -    target_link_libraries( ll::minizip-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libminizip.a ) -endif() +find_library(MINIZIPNG_LIBRARY +    NAMES +    minizip.lib +    libminizip.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::minizip-ng INTERFACE ${MINIZIPNG_LIBRARY}) + +find_library(LIBXML2_LIBRARY +    NAMES +    libxml2.lib +    libxml2.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::libxml INTERFACE ${LIBXML2_LIBRARY})  if (WINDOWS) -    target_link_libraries( ll::libxml INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libxml2.lib Bcrypt.lib) -else() -    target_link_libraries( ll::libxml INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libxml2.a) +    target_link_libraries( ll::libxml INTERFACE Bcrypt.lib)  endif()  endif (FALSE) @@ -146,8 +154,11 @@ target_include_directories( ll::colladadom SYSTEM INTERFACE          ${LIBS_PREBUILT_DIR}/include/collada          ${LIBS_PREBUILT_DIR}/include/collada/1.4          ) -if (WINDOWS) -    target_link_libraries(ll::colladadom INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libcollada14dom23-s.lib ll::libxml ll::minizip-ng ) -else () -    target_link_libraries(ll::colladadom INTERFACE collada14dom ll::boost ll::libxml ll::minizip-ng) -endif() + +find_library(COLLADADOM_LIBRARY +    NAMES +    libcollada14dom23-s.lib +    collada14dom +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::colladadom INTERFACE ${COLLADADOM_LIBRARY} ll::boost ll::libxml ll::minizip-ng) diff --git a/indra/cmake/Linking.cmake b/indra/cmake/Linking.cmake index fab649fed8..c9a0d69afc 100644 --- a/indra/cmake/Linking.cmake +++ b/indra/cmake/Linking.cmake @@ -38,9 +38,10 @@ endif ()  # windows) and CMAKE_BUILD_TYPE on Makefile based generators (like linux).  The reason for this is  # that CMAKE_BUILD_TYPE is essentially meaningless at configuration time for IDE generators and  # CMAKE_CFG_INTDIR is meaningless at build time for Makefile generators - -link_directories(${AUTOBUILD_INSTALL_DIR}/lib/$<LOWER_CASE:$<CONFIG>>) -link_directories(${AUTOBUILD_INSTALL_DIR}/lib/release) +if(NOT DARWIN) +  link_directories(${AUTOBUILD_INSTALL_DIR}/lib/$<LOWER_CASE:$<CONFIG>>) +  link_directories(${AUTOBUILD_INSTALL_DIR}/lib/release) +endif(NOT DARWIN)  add_library( ll::oslibraries INTERFACE IMPORTED ) @@ -74,6 +75,8 @@ elseif (DARWIN)    find_library(APPKIT_LIBRARY AppKit)    find_library(COREAUDIO_LIBRARY CoreAudio) +  find_library(COREGRAPHICS_LIBRARY CoreGraphics) +  find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)    target_link_libraries( ll::oslibraries INTERFACE            ${COCOA_LIBRARY} @@ -82,6 +85,8 @@ elseif (DARWIN)            ${CARBON_LIBRARY}            ${APPKIT_LIBRARY}            ${COREAUDIO_LIBRARY} +          ${AUDIOTOOLBOX_LIBRARY} +          ${COREGRAPHICS_LIBRARY}            )  endif() diff --git a/indra/cmake/Meshoptimizer.cmake b/indra/cmake/Meshoptimizer.cmake index 5058614580..b1d2796915 100644 --- a/indra/cmake/Meshoptimizer.cmake +++ b/indra/cmake/Meshoptimizer.cmake @@ -49,10 +49,12 @@ elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRA    endif ()  endif () -if (WINDOWS) -  target_link_libraries( ll::meshoptimizer INTERFACE meshoptimizer.lib) -else () -  target_link_libraries( ll::meshoptimizer INTERFACE libmeshoptimizer.a) -endif (WINDOWS) +find_library(MESHOPTIMIZER_LIBRARY +    NAMES +    meshoptimizer.lib +    libmeshoptimizer.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) -target_include_directories( ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer) +target_link_libraries(ll::meshoptimizer INTERFACE ${MESHOPTIMIZER_LIBRARY}) + +target_include_directories(ll::meshoptimizer SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/meshoptimizer) diff --git a/indra/cmake/NDOF.cmake b/indra/cmake/NDOF.cmake index 9f33c6e220..50f0ea1f51 100644 --- a/indra/cmake/NDOF.cmake +++ b/indra/cmake/NDOF.cmake @@ -76,12 +76,13 @@ if (NDOF)      endif ()    endif () -  if (WINDOWS) -    target_link_libraries( ll::ndof INTERFACE libndofdev) -  elseif (DARWIN OR LINUX) -    target_link_libraries( ll::ndof INTERFACE ndofdev) -  endif (WINDOWS) -  target_compile_definitions( ll::ndof INTERFACE LIB_NDOF=1) -else() -  add_compile_options(-ULIB_NDOF) +  find_library(NDOF_LIBRARY +      NAMES +      libndofdev +      ndofdev +      PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +  target_link_libraries(ll::ndof INTERFACE ${NDOF_LIBRARY}) + +  target_compile_definitions(ll::ndof INTERFACE LIB_NDOF=1)  endif (NDOF) diff --git a/indra/cmake/NGHTTP2.cmake b/indra/cmake/NGHTTP2.cmake index 7b2aa5971f..e81204d716 100644 --- a/indra/cmake/NGHTTP2.cmake +++ b/indra/cmake/NGHTTP2.cmake @@ -6,9 +6,12 @@ add_library( ll::nghttp2 INTERFACE IMPORTED )  use_system_binary(nghttp2)  use_prebuilt_binary(nghttp2) -if (WINDOWS) -  target_link_libraries( ll::nghttp2 INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/nghttp2.lib) -else () -  target_link_libraries( ll::nghttp2 INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libnghttp2.a) -endif () + +find_library(NGHTTP2_LIBRARY +    NAMES +    nghttp2.lib +    libnghttp2.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::nghttp2 INTERFACE ${NGHTTP2_LIBRARY})  target_include_directories( ll::nghttp2 SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/nghttp2) diff --git a/indra/cmake/OPENAL.cmake b/indra/cmake/OPENAL.cmake index f63e55cdf3..1b7f9b9071 100644 --- a/indra/cmake/OPENAL.cmake +++ b/indra/cmake/OPENAL.cmake @@ -8,7 +8,7 @@ include_guard()  # to have memory leaks, has no option to play music streams  # It probably makes sense to to completely remove it -set(USE_OPENAL OFF CACHE BOOL "Enable OpenAL") +set(USE_OPENAL ON CACHE BOOL "Enable OpenAL")  # ND: To streamline arguments passed, switch from OPENAL to USE_OPENAL  # To not break all old build scripts convert old arguments but warn about it  if(OPENAL) @@ -31,20 +31,21 @@ if (USE_OPENAL)    target_compile_definitions( ll::openal INTERFACE LL_OPENAL=1)    use_prebuilt_binary(openal) -  if(WINDOWS) -    target_link_libraries( ll::openal INTERFACE -            OpenAL32 -            alut -            ) -  elseif(LINUX) -    target_link_libraries( ll::openal INTERFACE -            openal -            alut -            ) -  else() -    target_link_libraries( ll::openal INTERFACE -            openal -            alut -            ) -  endif() +  find_library(OPENAL_LIBRARY +      NAMES +      OpenAL32 +      openal +      libopenal.dylib +      libopenal.so +      PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +  find_library(ALUT_LIBRARY +      NAMES +      alut +      libalut.dylib +      libalut.so +      PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +  target_link_libraries(ll::openal INTERFACE ${OPENAL_LIBRARY} ${ALUT_LIBRARY}) +  endif () diff --git a/indra/cmake/OpenJPEG.cmake b/indra/cmake/OpenJPEG.cmake index 8886b74094..125f32e711 100644 --- a/indra/cmake/OpenJPEG.cmake +++ b/indra/cmake/OpenJPEG.cmake @@ -1,7 +1,9 @@  # -*- cmake -*- +include_guard() +  include(Prebuilt) +include(Linking) -include_guard()  add_library( ll::openjpeg INTERFACE IMPORTED )  #use_system_binary(openjpeg) diff --git a/indra/cmake/OpenSSL.cmake b/indra/cmake/OpenSSL.cmake index afa2ba377d..b30678d96c 100644 --- a/indra/cmake/OpenSSL.cmake +++ b/indra/cmake/OpenSSL.cmake @@ -9,6 +9,21 @@ if ($ENV{MSYSTEM_CARCH} MATCHES aarch64)  use_system_binary(openssl)  elseif (LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64 OR DARWIN OR WINDOWS)  use_prebuilt_binary(openssl) + +find_library(SSL_LIBRARY +    NAMES +    libssl.lib +    libssl.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +find_library(CRYPTO_LIBRARY +    NAMES +    libcrypto.lib +    libcrypto.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::openssl INTERFACE ${SSL_LIBRARY} ${CRYPTO_LIBRARY}) +    if (DARWIN)      execute_process(        COMMAND lipo -archs libcrypto.a @@ -68,13 +83,8 @@ elseif (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRA    file(WRITE ${PREBUILD_TRACKING_DIR}/openssl_installed "${openssl_installed}")  endif ()  if (WINDOWS) -  target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.lib ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.lib Crypt32.lib) -elseif (LINUX) -  target_link_libraries(ll::openssl INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libssl.a ${ARCH_PREBUILT_DIRS_RELEASE}/libcrypto.a dl) -else() -  target_link_libraries(ll::openssl INTERFACE ssl crypto) +  target_link_libraries(ll::openssl INTERFACE Crypt32.lib)  endif (WINDOWS) -if (NOT WINDOWS) -target_include_directories( ll::openssl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) -endif () + +target_include_directories(ll::openssl SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) diff --git a/indra/cmake/PNG.cmake b/indra/cmake/PNG.cmake index e5893e9a20..0c01e5ee78 100644 --- a/indra/cmake/PNG.cmake +++ b/indra/cmake/PNG.cmake @@ -6,9 +6,12 @@ add_library( ll::libpng INTERFACE IMPORTED )  use_system_binary(libpng)  use_prebuilt_binary(libpng) -if (WINDOWS) -  target_link_libraries(ll::libpng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libpng16.lib) -else() -  target_link_libraries(ll::libpng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libpng16.a) -endif() -target_include_directories( ll::libpng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/libpng16) + +find_library(LIBPNG_LIBRARY +    NAMES +    libpng16.lib +    libpng16.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::libpng INTERFACE ${LIBPNG_LIBRARY}) +target_include_directories(ll::libpng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/libpng16) diff --git a/indra/cmake/PluginAPI.cmake b/indra/cmake/PluginAPI.cmake index 114415e514..a2bf13db2c 100644 --- a/indra/cmake/PluginAPI.cmake +++ b/indra/cmake/PluginAPI.cmake @@ -1,5 +1,7 @@  # -*- cmake -*- +include(OpenGL) +  add_library( ll::pluginlibraries INTERFACE IMPORTED )  if (WINDOWS) @@ -13,4 +15,6 @@ if (WINDOWS)        )  endif (WINDOWS) +target_link_libraries( ll::pluginlibraries INTERFACE OpenGL::GL) +target_include_directories( ll::pluginlibraries INTERFACE ${CMAKE_SOURCE_DIR}/llimage ${CMAKE_SOURCE_DIR}/llrender) diff --git a/indra/cmake/SSE2NEON.cmake b/indra/cmake/SSE2NEON.cmake new file mode 100644 index 0000000000..797f2af80e --- /dev/null +++ b/indra/cmake/SSE2NEON.cmake @@ -0,0 +1,12 @@ +# -*- cmake -*- + +include(Prebuilt) + +add_library(ll::sse2neon INTERFACE IMPORTED) + +if (DARWIN) +    use_system_binary(sse2neon) +    use_prebuilt_binary(sse2neon) + +    target_include_directories( ll::sse2neon SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/sse2neon) +endif() diff --git a/indra/cmake/Tracy.cmake b/indra/cmake/Tracy.cmake index a7eac2711f..cb09337d15 100644 --- a/indra/cmake/Tracy.cmake +++ b/indra/cmake/Tracy.cmake @@ -15,6 +15,7 @@ endif()  if (USE_TRACY)    option(USE_TRACY_ON_DEMAND "Use on-demand Tracy profiling." ON)    option(USE_TRACY_LOCAL_ONLY "Disallow remote Tracy profiling." OFF) +  option(USE_TRACY_GPU "Use Tracy GPU profiling" OFF)    use_system_binary(tracy)    use_prebuilt_binary(tracy) @@ -31,9 +32,8 @@ if (USE_TRACY)      target_compile_definitions(ll::tracy INTERFACE -DTRACY_NO_BROADCAST=1 -DTRACY_ONLY_LOCALHOST=1)    endif () -  # GHA runners don't always provide invariant TSC support, but always build with LL_TESTS enabled -  if (DARWIN AND LL_TESTS) -    target_compile_definitions(ll::tracy INTERFACE -DTRACY_TIMER_FALLBACK=1) +  if (USE_TRACY_GPU AND NOT DARWIN) # Tracy OpenGL mode is incompatible with macOS/iOS +    target_compile_definitions(ll::tracy INTERFACE -DLL_PROFILER_ENABLE_TRACY_OPENGL=1)    endif ()    # See: indra/llcommon/llprofiler.h diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake index 0720bbf53b..da9be417d3 100644 --- a/indra/cmake/Variables.cmake +++ b/indra/cmake/Variables.cmake @@ -146,52 +146,19 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")    set(DARWIN 1)    string(REGEX MATCH "-mmacosx-version-min=([^ ]+)" scratch "$ENV{LL_BUILD}") -  set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}") +  set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}" CACHE STRING "macOS Deploy Target" FORCE)    message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET = '${CMAKE_OSX_DEPLOYMENT_TARGET}'") -  string(REGEX MATCH "-stdlib=([^ ]+)" scratch "$ENV{LL_BUILD}") -  set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "${CMAKE_MATCH_1}") -  message(STATUS "CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY = '${CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY}'") - -  string(REGEX MATCH " -g([^ ]*)" scratch "$ENV{LL_BUILD}") -  set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "${CMAKE_MATCH_1}") -  # -gdwarf-2 is passed in LL_BUILD according to 00-COMPILE-LINK-RUN.txt. -  # However, when CMake 3.9.2 sees -gdwarf-2, it silently deletes the whole -g -  # switch, producing no symbols at all! The same thing happens if we specify -  # plain -g ourselves, i.e. CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT is -  # the empty string. Specifying -gdwarf-with-dsym or just -gdwarf drives a -  # different CMake behavior: it substitutes plain -g. As of 2017-09-19, -  # viewer-build-variables/variables still passes -gdwarf-2, which is the -  # no-symbols case. Set -gdwarf, triggering CMake to substitute plain -g -- -  # at least that way we should get symbols, albeit mangled ones. It Would Be -  # Nice if CMake's behavior could be predicted from a consistent mental -  # model, instead of only observed experimentally. -  string(REPLACE "dwarf-2" "dwarf" -    CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT -    "${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}") -  message(STATUS "CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT = '${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}'") +  # Use dwarf symbols for most libraries for compilation speed +  set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")    string(REGEX MATCH "-O([^ ]*)" scratch "$ENV{LL_BUILD}")    set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL "${CMAKE_MATCH_1}")    message(STATUS "CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL = '${CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL}'") -  # allow disabling this check by setting LL_SKIP_REQUIRE_SYSROOT either ON as cmake cache var or non-empty as environment var -  set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side") -  if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT}) -    string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}") -    list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx) -    if ("${sysroot_idx}" LESS 0) -      message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'") -    endif () -    math(EXPR sysroot_idx "${sysroot_idx} + 1") -    list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT) -  endif() -  message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'") - -  set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")    set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)    set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO) -  set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS ssse3) +  set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS sse4.2)    # we must hard code this to off for now.  xcode's built in signing does not    # handle embedded app bundles such as CEF and others. Any signing for local    # development must be done after the build as we do in viewer_manifest.py for diff --git a/indra/cmake/WebRTC.cmake b/indra/cmake/WebRTC.cmake index 6fecc53234..535e1c0a9e 100644 --- a/indra/cmake/WebRTC.cmake +++ b/indra/cmake/WebRTC.cmake @@ -1,12 +1,12 @@  # -*- cmake -*- +include_guard() +  include(Linking)  include(Prebuilt) -include_guard() -  add_library( ll::webrtc INTERFACE IMPORTED )  target_include_directories( ll::webrtc SYSTEM INTERFACE "${LIBS_PREBUILT_DIR}/include/webrtc" "${LIBS_PREBUILT_DIR}/include/webrtc/third_party/abseil-cpp") -if (CMAKE_OSX_ARCHITECTURES MATCHES x86_64 OR WINDOWS) +if (DARWIN OR WINDOWS)  use_prebuilt_binary(webrtc)  elseif (NOT (CMAKE_SYSTEM_NAME MATCHES FreeBSD OR ($ENV{MSYSTEM_CARCH} MATCHES aarch64) OR (${LINUX_DISTRO} MATCHES debian AND CMAKE_SYSTEM_PROCESSOR MATCHES aarch64)))      target_compile_definitions(ll::webrtc INTERFACE CM_WEBRTC=1) @@ -20,7 +20,7 @@ elseif (NOT (CMAKE_SYSTEM_NAME MATCHES FreeBSD OR ($ENV{MSYSTEM_CARCH} MATCHES a          endif ()          if (NOT EXISTS ${CMAKE_BINARY_DIR}/libwebrtc-${WEBRTC_PLATFORM}.tar.xz)              file(DOWNLOAD -                https://github.com/crow-misia/libwebrtc-bin/releases/download/114.5735.6.1/libwebrtc-${WEBRTC_PLATFORM}.tar.xz +                https://github.com/crow-misia/libwebrtc-bin/releases/download/137.7151.3.1/libwebrtc-${WEBRTC_PLATFORM}.tar.xz                  ${CMAKE_BINARY_DIR}/libwebrtc-${WEBRTC_PLATFORM}.tar.xz                  SHOW_PROGRESS                  ) @@ -79,25 +79,17 @@ elseif (NOT (CMAKE_SYSTEM_NAME MATCHES FreeBSD OR ($ENV{MSYSTEM_CARCH} MATCHES a      endif ()  endif () -if (WINDOWS) -    target_link_libraries( ll::webrtc INTERFACE webrtc.lib ) -elseif (DARWIN) -    FIND_LIBRARY(COREAUDIO_LIBRARY CoreAudio) -    FIND_LIBRARY(COREGRAPHICS_LIBRARY CoreGraphics) -    FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox) -    FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) -    FIND_LIBRARY(COCOA_LIBRARY Cocoa) +find_library(WEBRTC_LIBRARY +    NAMES +    webrtc +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries( ll::webrtc INTERFACE ${WEBRTC_LIBRARY} ) -    target_link_libraries( ll::webrtc INTERFACE -        libwebrtc.a -        ${COREAUDIO_LIBRARY} -        ${AUDIOTOOLBOX_LIBRARY} -        ${COREGRAPHICS_LIBRARY} -        ${COREFOUNDATION_LIBRARY} -        ${COCOA_LIBRARY} -    ) +if (DARWIN) +    target_link_libraries( ll::webrtc INTERFACE ll::oslibraries )  elseif (LINUX) -    target_link_libraries( ll::webrtc INTERFACE libwebrtc.a X11 ) -endif (WINDOWS) +    target_link_libraries( ll::webrtc INTERFACE X11 ) +endif () diff --git a/indra/cmake/ZLIBNG.cmake b/indra/cmake/ZLIBNG.cmake index 7c2c59a68d..44d12227df 100644 --- a/indra/cmake/ZLIBNG.cmake +++ b/indra/cmake/ZLIBNG.cmake @@ -17,11 +17,14 @@ if(USE_CONAN )  endif()  use_prebuilt_binary(zlib-ng) -if (WINDOWS) -  target_link_libraries( ll::zlib-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/zlib.lib ) -else() -  target_link_libraries( ll::zlib-ng INTERFACE ${ARCH_PREBUILT_DIRS_RELEASE}/libz.a ) -endif (WINDOWS) + +find_library(ZLIBNG_LIBRARY +    NAMES +    zlib.lib +    libz.a +    PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) + +target_link_libraries(ll::zlib-ng INTERFACE ${ZLIBNG_LIBRARY})  if( NOT LINUX )    target_include_directories( ll::zlib-ng SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/zlib-ng) diff --git a/indra/cmake/xxHash.cmake b/indra/cmake/xxHash.cmake index 84f4f4e0f2..72758fa067 100644 --- a/indra/cmake/xxHash.cmake +++ b/indra/cmake/xxHash.cmake @@ -1,8 +1,5 @@  # -*- cmake -*- -if (XXHASH_CMAKE_INCLUDED) -  return() -endif (XXHASH_CMAKE_INCLUDED) -set (XXHASH_CMAKE_INCLUDED TRUE) +include_guard()  include(Prebuilt) diff --git a/indra/doxygen/CMakeLists.txt b/indra/doxygen/CMakeLists.txt index 354ae7b636..43ebf4ae26 100644 --- a/indra/doxygen/CMakeLists.txt +++ b/indra/doxygen/CMakeLists.txt @@ -1,13 +1,5 @@  # -*- cmake -*- -set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING -    "The root project/makefile/solution name. Defaults to SecondLife.") -project(${ROOT_PROJECT_NAME}) - -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") - -include(Variables) -  # add a target to generate API documentation with Doxygen  find_package(Doxygen)  if(DOXYGEN_FOUND) diff --git a/indra/integration_tests/CMakeLists.txt b/indra/integration_tests/CMakeLists.txt index ced2b3dbcf..1d5f0772b5 100644 --- a/indra/integration_tests/CMakeLists.txt +++ b/indra/integration_tests/CMakeLists.txt @@ -1,8 +1,3 @@  # -*- cmake -*-  add_subdirectory(llui_libtest) -IF (LLIMAGE_LIBTEST) -  MESSAGE(STATUS "Build llimage_libtest") -  add_subdirectory(llimage_libtest) -ELSE (LLIMAGE_LIBTEST) -  MESSAGE(STATUS "Skip llimage_libtest") -ENDIF (LLIMAGE_LIBTEST) +add_subdirectory(llimage_libtest) diff --git a/indra/integration_tests/llimage_libtest/CMakeLists.txt b/indra/integration_tests/llimage_libtest/CMakeLists.txt index ee2890778b..e6ff142626 100644 --- a/indra/integration_tests/llimage_libtest/CMakeLists.txt +++ b/indra/integration_tests/llimage_libtest/CMakeLists.txt @@ -1,6 +1,7 @@  # -*- cmake -*-  # Integration tests of the llimage library (JPEG2000, PNG, jpeg, etc... images reading and writing) +if (LL_TESTS)  project (llimage_libtest) @@ -8,9 +9,7 @@ include(00-Common)  include(LLCommon)  include(LLImage)  include(LLMath) -include(LLImageJ2COJ)   include(LLKDU) -include(LLFileSystem)  set(llimage_libtest_SOURCE_FILES      llimage_libtest.cpp @@ -24,17 +23,9 @@ set(llimage_libtest_HEADER_FILES  list(APPEND llimage_libtest_SOURCE_FILES ${llimage_libtest_HEADER_FILES})  add_executable(llimage_libtest -    WIN32 -    MACOSX_BUNDLE      ${llimage_libtest_SOURCE_FILES}      ) -set_target_properties(llimage_libtest -    PROPERTIES -    WIN32_EXECUTABLE -    FALSE -) -  # Libraries on which this application depends on  # Sort by high-level to low-level  target_link_libraries(llimage_libtest @@ -42,64 +33,9 @@ target_link_libraries(llimage_libtest          llfilesystem          llmath          llimage -        llkdu -        llimagej2coj          ) -     -if (DARWIN) -  # Path inside the app bundle where we'll need to copy libraries -  set(LLIMAGE_LIBTEST_DESTINATION_DIR -    ${CMAKE_CURRENT_BINARY_DIR}/$<IF:$<BOOL:${LL_GENERATOR_IS_MULTI_CONFIG}>,$<CONFIG>,>/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) -  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 ${AUTOBUILD_INSTALL_DIR}/lib/release/libapr-1.0.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR} -    DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libapr-1.0.dylib -  ) -  add_custom_command(TARGET llimage_libtest POST_BUILD -    COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libaprutil-1.0.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR} -    DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libaprutil-1.0.dylib -  ) -  add_custom_command(TARGET llimage_libtest POST_BUILD -    COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib ${LLIMAGE_LIBTEST_DESTINATION_DIR} -    DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib -  ) -  foreach(expat ${EXPAT_COPY}) -    add_custom_command(TARGET llimage_libtest POST_BUILD -      COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/${expat} ${LLIMAGE_LIBTEST_DESTINATION_DIR} -      DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/${expat} -    ) -  endforeach(expat) -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(LL_TESTS) diff --git a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp index 95102094ae..c45bd6fd01 100644 --- a/indra/integration_tests/llimage_libtest/llimage_libtest.cpp +++ b/indra/integration_tests/llimage_libtest/llimage_libtest.cpp @@ -43,6 +43,8 @@  #include "v4coloru.h"  #include "llsdserialize.h"  #include "llcleanup.h" +#include "lltrace.h" +#include "llfasttimer.h"  // system libraries  #include <iostream> @@ -573,10 +575,10 @@ int main(int argc, char** argv)      // Create the logging thread if required -    if (LLFastTimer::sMetricLog) +    if (LLTrace::BlockTimer::sMetricLog)      { -        LLFastTimer::sLogLock = new LLMutex(NULL); -        fast_timer_log_thread = new LogThread(LLFastTimer::sLogName); +        LLTrace::BlockTimer::setLogLock(new LLMutex()); +        fast_timer_log_thread = new LogThread(LLTrace::BlockTimer::sLogName);          fast_timer_log_thread->start();      } @@ -618,9 +620,9 @@ int main(int argc, char** argv)      // Output perf data if requested by user      if (analyze_performance)      { -        std::string baseline_name = LLFastTimer::sLogName + "_baseline.slp"; -        std::string current_name  = LLFastTimer::sLogName + ".slp"; -        std::string report_name   = LLFastTimer::sLogName + "_report.csv"; +        std::string baseline_name = LLTrace::BlockTimer::sLogName + "_baseline.slp"; +        std::string current_name  = LLTrace::BlockTimer::sLogName + ".slp"; +        std::string report_name   = LLTrace::BlockTimer::sLogName + "_report.csv";          std::cout << "Analyzing performance, check report in : " << report_name << std::endl; @@ -628,9 +630,9 @@ int main(int argc, char** argv)      }      // Stop the perf gathering system if needed -    if (LLFastTimer::sMetricLog) +    if (LLTrace::BlockTimer::sMetricLog)      { -        LLMetricPerformanceTesterBasic::deleteTester(LLFastTimer::sLogName); +        LLMetricPerformanceTesterBasic::deleteTester(LLTrace::BlockTimer::sLogName);          sAllDone = true;      } diff --git a/indra/llaudio/llvorbisencode.cpp b/indra/llaudio/llvorbisencode.cpp index 83e7fad92f..d115dc309d 100644 --- a/indra/llaudio/llvorbisencode.cpp +++ b/indra/llaudio/llvorbisencode.cpp @@ -34,38 +34,6 @@  #include "llmath.h"  #include "llapr.h" -//#if LL_DARWIN -// MBW -- XXX -- Getting rid of SecondLifeVorbis for now -#if 0 -#include "VorbisFramework.h" - -#define vorbis_analysis             mac_vorbis_analysis -#define vorbis_analysis_headerout   mac_vorbis_analysis_headerout -#define vorbis_analysis_init        mac_vorbis_analysis_init -#define vorbis_encode_ctl           mac_vorbis_encode_ctl -#define vorbis_encode_setup_init    mac_vorbis_encode_setup_init -#define vorbis_encode_setup_managed mac_vorbis_encode_setup_managed - -#define vorbis_info_init            mac_vorbis_info_init -#define vorbis_info_clear           mac_vorbis_info_clear -#define vorbis_comment_init         mac_vorbis_comment_init -#define vorbis_comment_clear        mac_vorbis_comment_clear -#define vorbis_block_init           mac_vorbis_block_init -#define vorbis_block_clear          mac_vorbis_block_clear -#define vorbis_dsp_clear            mac_vorbis_dsp_clear -#define vorbis_analysis_buffer      mac_vorbis_analysis_buffer -#define vorbis_analysis_wrote       mac_vorbis_analysis_wrote -#define vorbis_analysis_blockout    mac_vorbis_analysis_blockout - -#define ogg_stream_packetin         mac_ogg_stream_packetin -#define ogg_stream_init             mac_ogg_stream_init -#define ogg_stream_flush            mac_ogg_stream_flush -#define ogg_stream_pageout          mac_ogg_stream_pageout -#define ogg_page_eos                mac_ogg_page_eos -#define ogg_stream_clear            mac_ogg_stream_clear - -#endif -  S32 check_for_invalid_wav_formats(const std::string& in_fname, std::string& error_msg)  {      U16 num_channels = 0; diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index e8c51c4c8e..55dde5dc42 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -11,7 +11,6 @@ include(LLSharedLibs)  include(ZLIBNG)  include(Tracy) -  set(llcommon_SOURCE_FILES      apply.cpp      commoncontrol.cpp diff --git a/indra/llcommon/fsyspath.h b/indra/llcommon/fsyspath.h index e9c96edce3..2c900c02a7 100644 --- a/indra/llcommon/fsyspath.h +++ b/indra/llcommon/fsyspath.h @@ -12,7 +12,10 @@  #if ! defined(LL_FSYSPATH_H)  #define LL_FSYSPATH_H +#include <boost/iterator/transform_iterator.hpp>  #include <filesystem> +#include <string> +#include <string_view>  // While std::filesystem::path can be directly constructed from std::string on  // both Posix and Windows, that's not what we want on Windows. Per @@ -33,37 +36,43 @@  // char"), the "native narrow encoding" isn't UTF-8, so file paths containing  // non-ASCII characters get mangled.  // -// Once we're building with C++20, we could pass a UTF-8 std::string through a -// vector<char8_t> to engage std::filesystem::path's own UTF-8 conversion. But -// sigh, as of 2024-04-03 we're not yet there. -// -// Anyway, encapsulating the important UTF-8 conversions in our own subclass -// allows us to migrate forward to C++20 conventions without changing -// referencing code. +// Encapsulating the important UTF-8 conversions in our own subclass allows us +// to migrate forward to C++20 conventions without changing referencing code.  class fsyspath: public std::filesystem::path  {      using super = std::filesystem::path; +    // In C++20 (__cpp_lib_char8_t), std::filesystem::u8path() is deprecated. +    // std::filesystem::path(iter, iter) performs UTF-8 conversions when the +    // value_type of the iterators is char8_t. While we could copy into a +    // temporary std::u8string and from there into std::filesystem::path, to +    // minimize string copying we'll define a transform_iterator that accepts +    // a std::string_view::iterator and dereferences to char8_t. +    struct u8ify +    { +        char8_t operator()(char c) const { return char8_t(c); } +    }; +    using u8iter = boost::transform_iterator<u8ify, std::string_view::iterator>; +  public:      // default      fsyspath() {} -    // construct from UTF-8 encoded std::string -    fsyspath(const std::string& path): super(std::filesystem::u8path(path)) {} -    // construct from UTF-8 encoded const char* -    fsyspath(const char* path): super(std::filesystem::u8path(path)) {} +    // construct from UTF-8 encoded string +    fsyspath(const std::string& path): fsyspath(std::string_view(path)) {} +    fsyspath(const char* path):        fsyspath(std::string_view(path)) {} +    fsyspath(std::string_view path): +        super(u8iter(path.begin(), u8ify()), u8iter(path.end(), u8ify())) +    {}      // construct from existing path      fsyspath(const super& path): super(path) {} -    fsyspath& operator=(const super& p) { super::operator=(p); return *this; } -    fsyspath& operator=(const std::string& p) -    { -        super::operator=(std::filesystem::u8path(p)); -        return *this; -    } -    fsyspath& operator=(const char* p) +    fsyspath& operator=(const super& p)       { super::operator=(p); return *this; } +    fsyspath& operator=(const std::string& p) { return (*this) = std::string_view(p); } +    fsyspath& operator=(const char* p)        { return (*this) = std::string_view(p); } +    fsyspath& operator=(std::string_view p)      { -        super::operator=(std::filesystem::u8path(p)); +        assign(u8iter(p.begin(), u8ify()), u8iter(p.end(), u8ify()));          return *this;      } diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h index a918caa2e8..a41af153fe 100644 --- a/indra/llcommon/linden_common.h +++ b/indra/llcommon/linden_common.h @@ -28,12 +28,6 @@  #define LL_LINDEN_COMMON_H  #include "llprofiler.h" -#if TRACY_ENABLE && !defined(LL_PROFILER_ENABLE_TRACY_OPENGL)  // hooks for memory profiling -void *tracy_aligned_malloc(size_t size, size_t alignment); -void  tracy_aligned_free(void *memblock); -#define _aligned_malloc(X, Y) tracy_aligned_malloc((X), (Y)) -#define _aligned_free(X)      tracy_aligned_free((X)) -#endif  // *NOTE:  Please keep includes here to a minimum!  // diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 08a43983d3..c532620daa 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -229,7 +229,7 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)          if(wargv[ii][1] == '-') ++offset;  #if LL_WINDOWS -    name.assign(utf16str_to_utf8str(&wargv[ii][offset])); +    name.assign(ll_convert_wide_to_string(&wargv[ii][offset]));  #else      name.assign(wstring_to_utf8str(&wargv[ii][offset]));  #endif @@ -253,7 +253,7 @@ bool LLApp::parseCommandOptions(int argc, wchar_t** wargv)          ++ii;  #if LL_WINDOWS -    value.assign(utf16str_to_utf8str((wargv[ii]))); +    value.assign(ll_convert_wide_to_string((wargv[ii])));  #else      value.assign(wstring_to_utf8str((wargv[ii])));  #endif diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index 84b35749cc..7a22eaf203 100644 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -33,23 +33,23 @@  #include "lltracethreadrecorder.h"  #include "llcleanup.h" -thread_local bool gProfilerEnabled = false; - -#if (TRACY_ENABLE) +#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY && TRACY_ENABLE  // Override new/delete for tracy memory profiling  void* ll_tracy_new(size_t size)  { -    void* ptr; -    if (gProfilerEnabled) -    { -        //LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; -        ptr = (malloc)(size); -    } -    else +    void* ptr = (malloc)(size); +    if (!ptr)      { -        ptr = (malloc)(size); +        throw std::bad_alloc();      } +    LL_PROFILE_ALLOC(ptr, size); +    return ptr; +} + +void* ll_tracy_aligned_new(size_t size, size_t alignment) +{ +    void* ptr = ll_aligned_malloc_fallback(size, alignment);      if (!ptr)      {          throw std::bad_alloc(); @@ -58,6 +58,18 @@ void* ll_tracy_new(size_t size)      return ptr;  } +void ll_tracy_delete(void* ptr) +{ +    LL_PROFILE_FREE(ptr); +    (free)(ptr); +} + +void ll_tracy_aligned_delete(void* ptr) +{ +    LL_PROFILE_FREE(ptr); +    ll_aligned_free_fallback(ptr); +} +  void* operator new(size_t size)  {      return ll_tracy_new(size); @@ -68,18 +80,14 @@ void* operator new[](std::size_t count)      return ll_tracy_new(count);  } -void ll_tracy_delete(void* ptr) +void* operator new(size_t size, std::align_val_t align)  { -    LL_PROFILE_FREE(ptr); -    if (gProfilerEnabled) -    { -        //LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; -        (free)(ptr); -    } -    else -    { -        (free)(ptr); -    } +    return ll_tracy_aligned_new(size, (size_t)align); +} + +void* operator new[](std::size_t count, std::align_val_t align) +{ +    return ll_tracy_aligned_new(count, (size_t)align);  }  void operator delete(void *ptr) noexcept @@ -92,27 +100,17 @@ void operator delete[](void* ptr) noexcept      ll_tracy_delete(ptr);  } -// C-style malloc/free can't be so easily overridden, so we define tracy versions and use -// a pre-processor #define in linden_common.h to redirect to them. The parens around the native -// functions below prevents recursive substitution by the preprocessor. -// -// Unaligned mallocs are rare in LL code but hooking them causes problems in 3p lib code (looking at -// you, Havok), so we'll only capture the aligned version. - -void *tracy_aligned_malloc(size_t size, size_t alignment) +void operator delete(void *ptr, std::align_val_t align) noexcept  { -    auto ptr = ll_aligned_malloc_fallback(size, alignment); -    if (ptr) LL_PROFILE_ALLOC(ptr, size); -    return ptr; +    ll_tracy_aligned_delete(ptr);  } -void tracy_aligned_free(void *memblock) +void operator delete[](void* ptr, std::align_val_t align) noexcept  { -    LL_PROFILE_FREE(memblock); -    ll_aligned_free_fallback(memblock); +    ll_tracy_aligned_delete(ptr);  } -#endif +#endif // TRACY_ENABLE && !LL_PROFILER_ENABLE_TRACY_OPENGL  //static  bool LLCommon::sAprInitialized = false; diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index d834098994..3411e9c6bb 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -79,7 +79,7 @@ namespace {              //              if (s.size())              { -                OutputDebugString(utf8str_to_utf16str(s).c_str()); +                OutputDebugString(ll_convert<std::wstring>(s).c_str());                  OutputDebugString(TEXT("\n"));              }          } diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 7ceb57336e..be0cab36e3 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -64,7 +64,7 @@ bool        BlockTimer::sLog             = false;  std::string BlockTimer::sLogName         = "";  bool        BlockTimer::sMetricLog       = false; -#if LL_LINUX +#if LL_LINUX || (LL_DARWIN && LL_ARM64)  U64         BlockTimer::sClockResolution = 1000000000; // Nanosecond resolution  #else  U64         BlockTimer::sClockResolution = 1000000; // Microsecond resolution diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 8499655bfa..fde168b022 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -30,9 +30,14 @@  #include "llinstancetracker.h"  #include "lltrace.h"  #include "lltreeiterators.h" +#include "llprocessor.h" +#if LL_X86 || LL_X86_64  #if LL_WINDOWS  #include <intrin.h> +#else +#include <x86intrin.h> +#endif  #endif  #define LL_FAST_TIMER_ON 1 @@ -68,35 +73,10 @@ public:      //      // Windows implementation of CPU clock      // - -    // -    // NOTE: put back in when we aren't using platform sdk anymore -    // -    // because MS has different signatures for these functions in winnt.h -    // need to rename them to avoid conflicts -    //#define _interlockedbittestandset _renamed_interlockedbittestandset -    //#define _interlockedbittestandreset _renamed_interlockedbittestandreset -    //#include <intrin.h> -    //#undef _interlockedbittestandset -    //#undef _interlockedbittestandreset - -    //inline U32 getCPUClockCount32() -    //{ -    //  U64 time_stamp = __rdtsc(); -    //  return (U32)(time_stamp >> 8); -    //} -    // -    //// return full timer value, *not* shifted by 8 bits -    //inline U64 getCPUClockCount64() -    //{ -    //  return __rdtsc(); -    //} - - +#if LL_FASTTIMER_USE_RDTSC      // shift off lower 8 bits for lower resolution but longer term timing      // on 1Ghz machine, a 32-bit word will hold ~1000 seconds of timing -#if LL_FASTTIMER_USE_RDTSC      static U32 getCPUClockCount32()      {  #if _M_ARM64 @@ -181,23 +161,39 @@ public:  #endif // (LL_LINUX) && !(defined(__i386__) || defined(__amd64__)) +/* +#if LL_DARWIN && LL_ARM64 +    // +    // Mac implementation of CPU clock - non-x86. +    // +    static U64 getCPUClockCount64() +    { +        return clock_gettime_nsec_np(CLOCK_UPTIME_RAW); +    } + +    static U32 getCPUClockCount32() +    { +        return (U32)(getCPUClockCount64() >> 8); +    } +#endif // LL_DARWIN && LL_ARM64 +*/ +  #if (LL_LINUX || LL_DARWIN || __FreeBSD__) && (defined(__i386__) || defined(__amd64__))      //      // Mac+Linux FAST x86 implementation of CPU clock +    // +#if LL_FASTTIMER_USE_RDTSC      static U32 getCPUClockCount32()      { -        U32 low(0),high(0); -        __asm__ volatile (".byte 0x0f, 0x31": "=a"(low), "=d"(high) ); -        return (low>>8) | (high<<24); +        U64 time_stamp = __rdtsc() >> 8U; +        return static_cast<U32>(time_stamp);      }      static U64 getCPUClockCount64()      { -        U32 low(0),high(0); -        __asm__ volatile (".byte 0x0f, 0x31": "=a"(low), "=d"(high) ); -        return (U64)low | ( ((U64)high) << 32); +        return static_cast<U64>(__rdtsc());      } - +#endif  #endif      static BlockTimerStatHandle& getRootTimeBlock(); diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index d0bc8f7652..53659ac13f 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -178,8 +178,7 @@ int LLFile::mkdir(const std::string& dirname, int perms)  {  #if LL_WINDOWS      // permissions are ignored on Windows -    std::string utf8dirname = dirname; -    llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname); +    std::wstring utf16dirname = ll_convert<std::wstring>(dirname);      int rc = _wmkdir(utf16dirname.c_str());  #else      int rc = ::mkdir(dirname.c_str(), (mode_t)perms); @@ -201,8 +200,7 @@ int LLFile::rmdir(const std::string& dirname)  {  #if LL_WINDOWS      // permissions are ignored on Windows -    std::string utf8dirname = dirname; -    llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname); +    std::wstring utf16dirname = ll_convert<std::wstring>(dirname);      int rc = _wrmdir(utf16dirname.c_str());  #else      int rc = ::rmdir(dirname.c_str()); @@ -214,10 +212,8 @@ int LLFile::rmdir(const std::string& dirname)  LLFILE* LLFile::fopen(const std::string& filename, const char* mode)    /* Flawfinder: ignore */  {  #if LL_WINDOWS -    std::string utf8filename = filename; -    std::string utf8mode = std::string(mode); -    llutf16string utf16filename = utf8str_to_utf16str(utf8filename); -    llutf16string utf16mode = utf8str_to_utf16str(utf8mode); +    std::wstring utf16filename = ll_convert<std::wstring>(filename); +    std::wstring utf16mode = ll_convert<std::wstring>(std::string(mode));      return _wfopen(utf16filename.c_str(),utf16mode.c_str());  #else      return ::fopen(filename.c_str(),mode);  /* Flawfinder: ignore */ @@ -227,10 +223,8 @@ LLFILE* LLFile::fopen(const std::string& filename, const char* mode)    /* Flawf  LLFILE* LLFile::_fsopen(const std::string& filename, const char* mode, int sharingFlag)  {  #if LL_WINDOWS -    std::string utf8filename = filename; -    std::string utf8mode = std::string(mode); -    llutf16string utf16filename = utf8str_to_utf16str(utf8filename); -    llutf16string utf16mode = utf8str_to_utf16str(utf8mode); +    std::wstring utf16filename = ll_convert<std::wstring>(filename); +    std::wstring utf16mode = ll_convert<std::wstring>(std::string(mode));      return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag);  #else      llassert(0);//No corresponding function on non-windows @@ -270,8 +264,7 @@ std::string LLFile::getContents(const std::string& filename)  int LLFile::remove(const std::string& filename, int supress_error)  {  #if LL_WINDOWS -    std::string utf8filename = filename; -    llutf16string utf16filename = utf8str_to_utf16str(utf8filename); +    std::wstring utf16filename = ll_convert<std::wstring>(filename);      int rc = _wremove(utf16filename.c_str());  #else      int rc = ::remove(filename.c_str()); @@ -282,10 +275,8 @@ int LLFile::remove(const std::string& filename, int supress_error)  int LLFile::rename(const std::string& filename, const std::string& newname, int supress_error)  {  #if LL_WINDOWS -    std::string utf8filename = filename; -    std::string utf8newname = newname; -    llutf16string utf16filename = utf8str_to_utf16str(utf8filename); -    llutf16string utf16newname = utf8str_to_utf16str(utf8newname); +    std::wstring utf16filename = ll_convert<std::wstring>(filename); +    std::wstring utf16newname = ll_convert<std::wstring>(newname);      int rc = _wrename(utf16filename.c_str(),utf16newname.c_str());  #else      int rc = ::rename(filename.c_str(),newname.c_str()); @@ -327,8 +318,7 @@ bool LLFile::copy(const std::string& from, const std::string& to)  int LLFile::stat(const std::string& filename, llstat* filestatus)  {  #if LL_WINDOWS -    std::string utf8filename = filename; -    llutf16string utf16filename = utf8str_to_utf16str(utf8filename); +    std::wstring utf16filename = ll_convert<std::wstring>(filename);      int rc = _wstat(utf16filename.c_str(),filestatus);  #else      int rc = ::stat(filename.c_str(),filestatus); @@ -453,14 +443,14 @@ llifstream::llifstream() {}  // explicit  llifstream::llifstream(const std::string& _Filename, ios_base::openmode _Mode): -    std::ifstream(utf8str_to_utf16str( _Filename ).c_str(), +    std::ifstream(ll_convert<std::wstring>( _Filename ).c_str(),                    _Mode | ios_base::in)  {  }  void llifstream::open(const std::string& _Filename, ios_base::openmode _Mode)  { -    std::ifstream::open(utf8str_to_utf16str(_Filename).c_str(), +    std::ifstream::open(ll_convert<std::wstring>(_Filename).c_str(),                          _Mode | ios_base::in);  } @@ -472,14 +462,14 @@ llofstream::llofstream() {}  // explicit  llofstream::llofstream(const std::string& _Filename, ios_base::openmode _Mode): -    std::ofstream(utf8str_to_utf16str( _Filename ).c_str(), +    std::ofstream(ll_convert<std::wstring>( _Filename ).c_str(),                    _Mode | ios_base::out)  {  }  void llofstream::open(const std::string& _Filename, ios_base::openmode _Mode)  { -    std::ofstream::open(utf8str_to_utf16str( _Filename ).c_str(), +    std::ofstream::open(ll_convert<std::wstring>( _Filename ).c_str(),                          _Mode | ios_base::out);  } diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp index e999b8f597..c8ca586e7f 100644 --- a/indra/llcommon/llmd5.cpp +++ b/indra/llcommon/llmd5.cpp @@ -255,6 +255,11 @@ void LLMD5::raw_digest(unsigned char* s) const      memcpy(s, digest, 16); /* Flawfinder: ignore */  } +#if LL_DARWIN +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  void LLMD5::hex_digest(char* s) const  {      if (!finalized) @@ -273,6 +278,10 @@ void LLMD5::hex_digest(char* s) const      s[32] = '\0';  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  std::ostream& operator<<(std::ostream& stream, const LLMD5& context)  {      char s[33];     /* Flawfinder: ignore */ diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index d5802b9d95..c06ae93766 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -235,8 +235,6 @@ inline void* ll_aligned_malloc_32(size_t size) // returned hunk MUST be freed wi      LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;  #if defined(LL_WINDOWS)      void* ret = _aligned_malloc(size, 32); -#elif defined(LL_DARWIN) -    void* ret = ll_aligned_malloc_fallback( size, 32 );  #else      void *ret;      if (0 != posix_memalign(&ret, 32, size)) @@ -252,8 +250,31 @@ inline void ll_aligned_free_32(void *p)      LL_PROFILE_FREE(p);  #if defined(LL_WINDOWS)      _aligned_free(p); -#elif defined(LL_DARWIN) -    ll_aligned_free_fallback( p ); +#else +    free(p); // posix_memalign() is compatible with heap deallocator +#endif +} + +inline void* ll_aligned_malloc_64(size_t size) // returned hunk MUST be freed with ll_aligned_free_32(). +{ +    LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; +#if defined(LL_WINDOWS) +    void* ret = _aligned_malloc(size, 64); +#else +    void *ret; +    if (0 != posix_memalign(&ret, 64, size)) +        return nullptr; +#endif +    LL_PROFILE_ALLOC(ret, size); +    return ret; +} + +inline void ll_aligned_free_64(void *p) +{ +    LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; +    LL_PROFILE_FREE(p); +#if defined(LL_WINDOWS) +    _aligned_free(p);  #else      free(p); // posix_memalign() is compatible with heap deallocator  #endif @@ -265,19 +286,23 @@ LL_FORCE_INLINE void* ll_aligned_malloc(size_t size)  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY;      void* ret; -    if (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0) +    if constexpr (LL_DEFAULT_HEAP_ALIGN % ALIGNMENT == 0)      {          ret = malloc(size);          LL_PROFILE_ALLOC(ret, size);      } -    else if (ALIGNMENT == 16) +    else if constexpr (ALIGNMENT == 16)      {          ret = ll_aligned_malloc_16(size);      } -    else if (ALIGNMENT == 32) +    else if constexpr (ALIGNMENT == 32)      {          ret = ll_aligned_malloc_32(size);      } +    else if constexpr (ALIGNMENT == 64) +    { +        ret = ll_aligned_malloc_64(size); +    }      else      {          ret = ll_aligned_malloc_fallback(size, ALIGNMENT); @@ -289,16 +314,20 @@ template<size_t ALIGNMENT>  LL_FORCE_INLINE void ll_aligned_free(void* ptr)  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; -    if (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN) +    if constexpr (ALIGNMENT == LL_DEFAULT_HEAP_ALIGN)      {          LL_PROFILE_FREE(ptr);          free(ptr);      } -    else if (ALIGNMENT == 16) +    else if constexpr (ALIGNMENT == 16)      {          ll_aligned_free_16(ptr);      } -    else if (ALIGNMENT == 32) +    else if constexpr (ALIGNMENT == 32) +    { +        return ll_aligned_free_32(ptr); +    } +    else if constexpr (ALIGNMENT == 64)      {          return ll_aligned_free_32(ptr);      } @@ -314,6 +343,9 @@ LL_FORCE_INLINE void ll_aligned_free(void* ptr)  inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes)  {      LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; +#if defined(LL_ARM64) +    memcpy(dst, src, bytes); +#else      assert(src != NULL);      assert(dst != NULL);      assert(bytes > 0); @@ -379,6 +411,7 @@ inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __          dst += 16;          src += 16;      } +#endif  }  #ifndef __DEBUG_PRIVATE_MEM__ diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index 268109e8b7..cbcaf47cd2 100644 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -78,6 +78,23 @@      #endif  #endif +// Set up CPU architecture defines +#if LL_MSVC && defined(_M_ARM64) +#      define LL_ARM64 1 +#elif LL_GNUC && (defined(__arm64__) || defined(__aarch64__)) +#      define LL_ARM64 1 +#elif LL_MSVC && _M_X64 +#      define LL_X86_64 1 +#      define LL_X86 1 +#elif LL_MSVC && _M_IX86 +#      define LL_X86 1 +#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) ) +#      define LL_X86_64 1 +#      define LL_X86 1 +#elif LL_GNUC && ( defined(__i386__) ) +#      define LL_X86 1 +#endif +  // Deal with minor differences on Unixy OSes.  #if LL_DARWIN || LL_LINUX || __FreeBSD__      // Different name, same functionality. @@ -120,11 +137,8 @@  #if LL_WINDOWS  #define LL_DLLEXPORT __declspec(dllexport)  #define LL_DLLIMPORT __declspec(dllimport) -#elif LL_LINUX -#define LL_DLLEXPORT __attribute__ ((visibility("default"))) -#define LL_DLLIMPORT  #else -#define LL_DLLEXPORT +#define LL_DLLEXPORT __attribute__ ((visibility("default")))  #define LL_DLLIMPORT  #endif // LL_WINDOWS @@ -169,11 +183,7 @@  #define LL_TO_STRING_HELPER(x) #x  #define LL_TO_STRING(x) LL_TO_STRING_HELPER(x) -#if _M_ARM64  #define LL_TO_WSTRING_HELPER(x) L## #x -#else -#define LL_TO_WSTRING_HELPER(x) L#x -#endif  #define LL_TO_WSTRING(x) LL_TO_WSTRING_HELPER(x)  #define LL_FILE_LINENO_MSG(msg) __FILE__ "(" LL_TO_STRING(__LINE__) ") : " msg  #define LL_GLUE_IMPL(x, y) x##y @@ -193,4 +203,16 @@  #define LL_PRETTY_FUNCTION __PRETTY_FUNCTION__  #endif +#if LL_ARM64 +#define GLM_FORCE_NEON 1 +#else +#define GLM_FORCE_SSE2 1 +#endif + +#if LL_ARM64 +#define KDU_NEON_INTRINSICS 1 +#else +#define KDU_X86_INTRINSICS 1 +#endif +  #endif  //  not LL_LINDEN_PREPROCESSOR_H diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 7f2276ca2a..2b6e4be1c8 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -680,14 +680,14 @@ public:          setInfo(eFrequency, (F64)frequency  / (F64)1000000);      } -    virtual ~LLProcessorInfoDarwinImpl() {} +    virtual ~LLProcessorInfoDarwinImpl() = default;  private:      int getSysctlInt(const char* name)      {          int result = 0;          size_t len = sizeof(int); -        int error = sysctlbyname(name, (void*)&result, &len, NULL, 0); +        int error = sysctlbyname(name, (void*)&result, &len, nullptr, 0);          return error == -1 ? 0 : result;      } @@ -695,7 +695,7 @@ private:      {          uint64_t value = 0;          size_t size = sizeof(value); -        int result = sysctlbyname(name, (void*)&value, &size, NULL, 0); +        int result = sysctlbyname(name, (void*)&value, &size, nullptr, 0);          if ( result == 0 )          {              if ( size == sizeof( uint64_t ) ) diff --git a/indra/llcommon/llprocessor.h b/indra/llcommon/llprocessor.h index f8ccf686c8..b955f7f55c 100644 --- a/indra/llcommon/llprocessor.h +++ b/indra/llcommon/llprocessor.h @@ -28,20 +28,7 @@  #ifndef LLPROCESSOR_H  #define LLPROCESSOR_H  #include "llunits.h" - -#if LL_MSVC && _M_X64 -#      define LL_X86_64 1 -#      define LL_X86 1 -#elif LL_MSVC && _M_IX86 -#      define LL_X86 1 -#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) ) -#      define LL_X86_64 1 -#      define LL_X86 1 -#elif LL_GNUC && ( defined(__i386__) ) -#      define LL_X86 1 -#elif LL_GNUC && ( defined(__powerpc__) || defined(__ppc__) ) -#      define LL_PPC 1 -#endif +#include "llpreprocessor.h"  class LLProcessorInfoImpl; diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h index 9267c5cbda..e0f3cf1b73 100644 --- a/indra/llcommon/llprofiler.h +++ b/indra/llcommon/llprofiler.h @@ -74,23 +74,18 @@  #define LL_PROFILER_CONFIGURATION           0  #endif -extern thread_local bool gProfilerEnabled; -  #if defined(LL_PROFILER_CONFIGURATION) && (LL_PROFILER_CONFIGURATION > LL_PROFILER_CONFIG_NONE)      #if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY || LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY_FAST_TIMER          #include "tracy/Tracy.hpp" -        // Enable OpenGL profiling -        #define LL_PROFILER_ENABLE_TRACY_OPENGL 0 -          // Enable RenderDoc labeling -        #define LL_PROFILER_ENABLE_RENDER_DOC 0 +        //#define LL_PROFILER_ENABLE_RENDER_DOC 0      #endif      #if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY          #define LL_PROFILER_FRAME_END                   FrameMark -        #define LL_PROFILER_SET_THREAD_NAME( name )     tracy::SetThreadName( name );    gProfilerEnabled = true; +        #define LL_PROFILER_SET_THREAD_NAME( name )     tracy::SetThreadName( name );          #define LL_RECORD_BLOCK_TIME(name)              ZoneScoped // Want descriptive names; was: ZoneNamedN( ___tracy_scoped_zone, #name, true );          #define LL_PROFILE_ZONE_NAMED(name)             ZoneNamedN( ___tracy_scoped_zone, name, true );          #define LL_PROFILE_ZONE_NAMED_COLOR(name,color) ZoneNamedNC( ___tracy_scopped_zone, name, color, true ) // RGB @@ -133,7 +128,7 @@ extern thread_local bool gProfilerEnabled;      #endif      #if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY_FAST_TIMER          #define LL_PROFILER_FRAME_END                   FrameMark -        #define LL_PROFILER_SET_THREAD_NAME( name )     tracy::SetThreadName( name );    gProfilerEnabled = true; +        #define LL_PROFILER_SET_THREAD_NAME( name )     tracy::SetThreadName( name );          #define LL_RECORD_BLOCK_TIME(name)              ZoneNamedN(___tracy_scoped_zone, #name, true);   const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(name)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__);          #define LL_PROFILE_ZONE_NAMED(name)             ZoneNamedN( ___tracy_scoped_zone, #name, true );          #define LL_PROFILE_ZONE_NAMED_COLOR(name,color) ZoneNamedNC( ___tracy_scopped_zone, name, color, true ) // RGB @@ -180,23 +175,20 @@ extern thread_local bool gProfilerEnabled;  #endif // LL_PROFILER  #if LL_PROFILER_ENABLE_TRACY_OPENGL -#define LL_PROFILE_GPU_ZONE(name)        TracyGpuZone(name) -#define LL_PROFILE_GPU_ZONEC(name,color) TracyGpuZoneC(name,color) +#define LL_PROFILE_GPU_ZONE(name)         TracyGpuZone(name) +#define LL_PROFILE_GPU_ZONEC(name,color)  TracyGpuZoneC(name,color)  #define LL_PROFILER_GPU_COLLECT           TracyGpuCollect  #define LL_PROFILER_GPU_CONTEXT           TracyGpuContext - -// disable memory tracking (incompatible with GPU tracing -#define LL_PROFILE_ALLOC(ptr, size)             (void)(ptr); (void)(size); -#define LL_PROFILE_FREE(ptr)                    (void)(ptr); +#define LL_PROFILER_GPU_CONTEXT_NAMED     TracyGpuContextName  #else -#define LL_PROFILE_GPU_ZONE(name)        (void)name; -#define LL_PROFILE_GPU_ZONEC(name,color) (void)name;(void)color; +#define LL_PROFILE_GPU_ZONE(name)           (void)name; +#define LL_PROFILE_GPU_ZONEC(name,color)    (void)name;(void)color;  #define LL_PROFILER_GPU_COLLECT  #define LL_PROFILER_GPU_CONTEXT +#define LL_PROFILER_GPU_CONTEXT_NAMED(name) (void)name; +#endif // LL_PROFILER_ENABLE_TRACY_OPENGL -#define LL_LABEL_OBJECT_GL(type, name, length, label) - -#if !LL_DARWIN && LL_PROFILER_CONFIGURATION > 1 +#if LL_PROFILER_CONFIGURATION >= LL_PROFILER_CONFIG_TRACY  #define LL_PROFILE_ALLOC(ptr, size)             TracyAlloc(ptr, size)  #define LL_PROFILE_FREE(ptr)                    TracyFree(ptr)  #else @@ -204,8 +196,6 @@ extern thread_local bool gProfilerEnabled;  #define LL_PROFILE_FREE(ptr)                    (void)(ptr);  #endif -#endif -  #if LL_PROFILER_ENABLE_RENDER_DOC  #define LL_LABEL_OBJECT_GL(type, name, length, label) glObjectLabel(type, name, length, label)  #else diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 5c35aeb476..2c46c59aa5 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -197,6 +197,9 @@ LLOSInfo::LLOSInfo() :          GetSystemInfo(&si); //if it fails get regular system info      //(Warning: If GetSystemInfo it may result in incorrect information in a WOW64 machine, if the kernel fails to load) +#pragma warning(push) +#pragma warning(disable : 4996) // ignore 'deprecated.' GetVersionEx is deprecated +      // Try calling GetVersionEx using the OSVERSIONINFOEX structure.      OSVERSIONINFOEX osvi;      ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); @@ -215,6 +218,8 @@ LLOSInfo::LLOSInfo() :          }      } +#pragma warning(pop) +      S32 ubr = 0; // Windows 10 Update Build Revision, can be retrieved from a registry      if (mMajorVer == 10)      { @@ -1332,7 +1337,7 @@ bool gunzip_file(const std::string& srcfile, const std::string& dstfile)      S32 bytes = 0;      tmpfile = dstfile + ".t";  #ifdef LL_WINDOWS -    llutf16string utf16filename = utf8str_to_utf16str(srcfile); +    std::wstring utf16filename = ll_convert<std::wstring>(srcfile);      src = gzopen_w(utf16filename.c_str(), "rb");  #else      src = gzopen(srcfile.c_str(), "rb"); @@ -1376,7 +1381,7 @@ bool gzip_file(const std::string& srcfile, const std::string& dstfile)      tmpfile = dstfile + ".t";  #ifdef LL_WINDOWS -    llutf16string utf16filename = utf8str_to_utf16str(tmpfile); +    std::wstring utf16filename = ll_convert<std::wstring>(tmpfile);      dst = gzopen_w(utf16filename.c_str(), "wb");  #else      dst = gzopen(tmpfile.c_str(), "wb"); diff --git a/indra/llcommon/llthreadsafequeue.h b/indra/llcommon/llthreadsafequeue.h index 85fcbbacac..6532439dd9 100644 --- a/indra/llcommon/llthreadsafequeue.h +++ b/indra/llcommon/llthreadsafequeue.h @@ -452,11 +452,9 @@ ElementT LLThreadSafeQueue<ElementT, QueueT>::pop(void)          // so we can finish draining the queue.          pop_result popped = pop_(lock1, value);          if (popped == POPPED) -#if LL_LINUX              return value; -#else -            return std::move(value); -#endif +            // don't use std::move when returning local value because +            // it prevents the compiler from optimizing with copy elision          // Once the queue is DONE, there will never be any more coming.          if (popped == DONE) diff --git a/indra/llcommon/tests/stringize_test.cpp b/indra/llcommon/tests/stringize_test.cpp index a3ce7f8e3d..3f99041592 100644 --- a/indra/llcommon/tests/stringize_test.cpp +++ b/indra/llcommon/tests/stringize_test.cpp @@ -110,6 +110,17 @@ namespace tut      void stringize_object::test<3>()      {          //Tests rely on validity of wstring_to_utf8str() +#if LL_WINDOWS // Windows wstring is a 2byte UTF16 type +        ensure_equals(ll_convert<std::string>(wstringize(c)), ll_convert<std::string>(std::wstring(L"c"))); +        ensure_equals(ll_convert<std::string>(wstringize(s)), ll_convert<std::string>(std::wstring(L"17"))); +        ensure_equals(ll_convert<std::string>(wstringize(i)), ll_convert<std::string>(std::wstring(L"34"))); +        ensure_equals(ll_convert<std::string>(wstringize(l)), ll_convert<std::string>(std::wstring(L"68"))); +        ensure_equals(ll_convert<std::string>(wstringize(f)), ll_convert<std::string>(std::wstring(L"3.14159"))); +        ensure_equals(ll_convert<std::string>(wstringize(d)), ll_convert<std::string>(std::wstring(L"3.14159"))); +        ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(std::wstring(L"abc def"))); +        ensure_equals(ll_convert<std::string>(wstringize(abc)), ll_convert<std::string>(wstringize(abc.c_str()))); +        ensure_equals(ll_convert<std::string>(wstringize(def)), ll_convert<std::string>(std::wstring(L"def ghi"))); +#else          ensure_equals(wstring_to_utf8str(wstringize(c)),    wstring_to_utf8str(L"c"));          ensure_equals(wstring_to_utf8str(wstringize(s)),    wstring_to_utf8str(L"17"));          ensure_equals(wstring_to_utf8str(wstringize(i)),    wstring_to_utf8str(L"34")); @@ -119,6 +130,7 @@ namespace tut          ensure_equals(wstring_to_utf8str(wstringize(abc)),  wstring_to_utf8str(L"abc def"));          ensure_equals(wstring_to_utf8str(wstringize(abc)),  wstring_to_utf8str(wstringize(abc.c_str())));          ensure_equals(wstring_to_utf8str(wstringize(def)),  wstring_to_utf8str(L"def ghi")); +#endif   //       ensure_equals(wstring_to_utf8str(wstringize(llsd)), wstring_to_utf8str(L"{'abc':'abc def','d':r3.14159,'i':i34}"));      }  } // namespace tut diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp index 72e0c29a24..986e675d00 100644 --- a/indra/llcorehttp/examples/http_texture_load.cpp +++ b/indra/llcorehttp/examples/http_texture_load.cpp @@ -52,8 +52,6 @@  void init_curl();  void term_curl(); -void ssl_thread_id_callback(CRYPTO_THREADID*); -void ssl_locking_callback(int mode, int type, const char * file, int line);  void usage(std::ostream & out);  // Default command line settings @@ -606,63 +604,15 @@ void WorkingSet::loadAssetUuids(FILE * in)  } -int ssl_mutex_count(0); -LLCoreInt::HttpMutex ** ssl_mutex_list = NULL; -  void init_curl()  {      curl_global_init(CURL_GLOBAL_ALL); - -    ssl_mutex_count = CRYPTO_num_locks(); -    if (ssl_mutex_count > 0) -    { -        ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count]; - -        for (int i(0); i < ssl_mutex_count; ++i) -        { -            ssl_mutex_list[i] = new LLCoreInt::HttpMutex; -        } - -        CRYPTO_set_locking_callback(ssl_locking_callback); -        CRYPTO_THREADID_set_callback(ssl_thread_id_callback); -    }  }  void term_curl()  { -    CRYPTO_set_locking_callback(NULL); -    for (int i(0); i < ssl_mutex_count; ++i) -    { -        delete ssl_mutex_list[i]; -    } -    delete [] ssl_mutex_list; -} - - -void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid) -{ -#if defined(WIN32) -    CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread()); -#else -    CRYPTO_THREADID_set_pointer(pthreadid, pthread_self()); -#endif -} - - -void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */) -{ -    if (type >= 0 && type < ssl_mutex_count) -    { -        if (mode & CRYPTO_LOCK) -        { -            ssl_mutex_list[type]->lock(); -        } -        else -        { -            ssl_mutex_list[type]->unlock(); -        } -    } +    curl_global_cleanup();  } diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp index c0cc2c8030..c7c50e6166 100755 --- a/indra/llcorehttp/tests/llcorehttp_test.cpp +++ b/indra/llcorehttp/tests/llcorehttp_test.cpp @@ -41,11 +41,7 @@  #include "test_httpstatus.hpp"  #include "test_refcounted.hpp"  #include "test_httpoperation.hpp" -// As of 2019-06-28, test_httprequest.hpp consistently crashes on Mac Release -// builds for reasons not yet diagnosed. -#if ! (LL_DARWIN && LL_RELEASE)  #include "test_httprequest.hpp" -#endif  #include "test_httpheaders.hpp"  #include "test_httprequestqueue.hpp"  #include "_httpservice.h" @@ -53,9 +49,6 @@  #include "llproxy.h"  #include "llcleanup.h" -void ssl_thread_id_callback(CRYPTO_THREADID*); -void ssl_locking_callback(int mode, int type, const char * file, int line); -  #if 0   // lltut provides main and runner  namespace tut @@ -80,27 +73,10 @@ int main()  #endif // 0 -int ssl_mutex_count(0); -LLCoreInt::HttpMutex ** ssl_mutex_list = NULL; -  void init_curl()  {      curl_global_init(CURL_GLOBAL_ALL); -    ssl_mutex_count = CRYPTO_num_locks(); -    if (ssl_mutex_count > 0) -    { -        ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count]; - -        for (int i(0); i < ssl_mutex_count; ++i) -        { -            ssl_mutex_list[i] = new LLCoreInt::HttpMutex; -        } - -        CRYPTO_set_locking_callback(ssl_locking_callback); -        CRYPTO_THREADID_set_callback(ssl_thread_id_callback); -    } -      LLProxy::getInstance();  } @@ -108,39 +84,6 @@ void init_curl()  void term_curl()  {      SUBSYSTEM_CLEANUP(LLProxy); - -    CRYPTO_set_locking_callback(NULL); -    for (int i(0); i < ssl_mutex_count; ++i) -    { -        delete ssl_mutex_list[i]; -    } -    delete [] ssl_mutex_list; -} - - -void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid) -{ -#if defined(WIN32) -    CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread()); -#else -    CRYPTO_THREADID_set_pointer(pthreadid, pthread_self()); -#endif -} - - -void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */) -{ -    if (type >= 0 && type < ssl_mutex_count) -    { -        if (mode & CRYPTO_LOCK) -        { -            ssl_mutex_list[type]->lock(); -        } -        else -        { -            ssl_mutex_list[type]->unlock(); -        } -    }  } diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index aed906bb8f..77ed8df066 100644 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -454,6 +454,10 @@ void HttpRequestTestObjectType::test<4>()  template <> template <>  void HttpRequestTestObjectType::test<5>()  { +#ifndef LL_WINDOWS +    skip("Skip due to issues with testing pthread cancellation"); +#endif +      ScopedCurlInit ready;      set_test_name("HttpRequest Spin (soft) + NoOp + hard termination"); @@ -517,6 +521,9 @@ void HttpRequestTestObjectType::test<5>()  template <> template <>  void HttpRequestTestObjectType::test<6>()  { +#ifndef LL_WINDOWS +    skip("Skip due to issues with testing pthread cancellation"); +#endif      ScopedCurlInit ready;      set_test_name("HttpRequest Spin + NoOp + hard termination"); @@ -2779,7 +2786,7 @@ void HttpRequestTestObjectType::test<22>()          for (int i(0); i < test_count; ++i)          {              char buffer[128]; -            sprintf(buffer, "/bug2295/%d/", i); +            snprintf(buffer, sizeof(buffer), "/bug2295/%d/", i);              HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,                                                           url_base + buffer,                                                           0, @@ -2810,7 +2817,7 @@ void HttpRequestTestObjectType::test<22>()          for (int i(0); i < test2_count; ++i)          {              char buffer[128]; -            sprintf(buffer, "/bug2295/00000012/%d/", i); +            snprintf(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);              HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,                                                           url_base + buffer,                                                           0, @@ -2841,7 +2848,7 @@ void HttpRequestTestObjectType::test<22>()          for (int i(0); i < test3_count; ++i)          {              char buffer[128]; -            sprintf(buffer, "/bug2295/inv_cont_range/%d/", i); +            snprintf(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);              HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,                                                           url_base + buffer,                                                           0, diff --git a/indra/llcorehttp/tests/test_refcounted.hpp b/indra/llcorehttp/tests/test_refcounted.hpp index c0c8e78413..eb23a25545 100644 --- a/indra/llcorehttp/tests/test_refcounted.hpp +++ b/indra/llcorehttp/tests/test_refcounted.hpp @@ -28,8 +28,6 @@  #include "_refcounted.h" -// disable all of this because it's hanging win64 builds? -#if ! (LL_WINDOWS && ADDRESS_SIZE == 64)  using namespace LLCoreInt;  namespace tut @@ -122,5 +120,4 @@ namespace tut          ensure(rc->getRefCount() == RefCounted::NOT_REF_COUNTED);      }  } -#endif  // disabling on Win64  #endif  // TEST_LLCOREINT_REF_COUNTED_H_ diff --git a/indra/llcrashlogger/llcrashlock.cpp b/indra/llcrashlogger/llcrashlock.cpp index ecd197b2c1..bc34f6798f 100644 --- a/indra/llcrashlogger/llcrashlock.cpp +++ b/indra/llcrashlogger/llcrashlock.cpp @@ -189,7 +189,7 @@ LLSD LLCrashLock::getProcessList()  bool LLCrashLock::fileExists(std::string filename)  {  #ifdef LL_WINDOWS // or BOOST_WINDOWS_API -    boost::filesystem::path file_path(utf8str_to_utf16str(filename)); +    boost::filesystem::path file_path(ll_convert<std::wstring>(filename));  #else      boost::filesystem::path file_path(filename);  #endif @@ -199,7 +199,7 @@ bool LLCrashLock::fileExists(std::string filename)  void LLCrashLock::cleanupProcess(std::string proc_dir)  {  #ifdef LL_WINDOWS // or BOOST_WINDOWS_API -    boost::filesystem::path dir_path(utf8str_to_utf16str(proc_dir)); +    boost::filesystem::path dir_path(ll_convert<std::wstring>(proc_dir));  #else      boost::filesystem::path dir_path(proc_dir);  #endif diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index 918bb0d117..33760d28ae 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -103,7 +103,7 @@ std::vector<std::string> LLDir::getFilesInDir(const std::string &dirname)      //Returns a vector of fullpath filenames.  #ifdef LL_WINDOWS // or BOOST_WINDOWS_API -    boost::filesystem::path p(utf8str_to_utf16str(dirname)); +    boost::filesystem::path p(ll_convert<std::wstring>(dirname));  #else      boost::filesystem::path p(dirname);  #endif @@ -201,7 +201,7 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name)      try      {  #ifdef LL_WINDOWS // or BOOST_WINDOWS_API -        boost::filesystem::path dir_path(utf8str_to_utf16str(dir_name)); +        boost::filesystem::path dir_path(ll_convert<std::wstring>(dir_name));  #else          boost::filesystem::path dir_path(dir_name);  #endif diff --git a/indra/llfilesystem/lldir_mac.cpp b/indra/llfilesystem/lldir_mac.cpp index b25c654e31..785bd034e8 100644 --- a/indra/llfilesystem/lldir_mac.cpp +++ b/indra/llfilesystem/lldir_mac.cpp @@ -149,6 +149,9 @@ LLDir_Mac::LLDir_Mac()          mWorkingDir = getCurPath(); +/* +        mLLPluginDir = mAppRODataDir + mDirDelimiter + "SLPlugin.app" + mDirDelimiter + "Contents" + mDirDelimiter + "Frameworks"; +*/          mLLPluginDir = mAppRODataDir + mDirDelimiter + "llplugin";      }  } diff --git a/indra/llfilesystem/lldir_win32.cpp b/indra/llfilesystem/lldir_win32.cpp index a607c70b44..58c080c982 100644 --- a/indra/llfilesystem/lldir_win32.cpp +++ b/indra/llfilesystem/lldir_win32.cpp @@ -172,7 +172,7 @@ LLDir_Win32::LLDir_Win32()          {              w_str[wcslen(w_str)-1] = '\0'; /* Flawfinder: ignore */ // remove trailing slash          } -        mTempDir = utf16str_to_utf8str(llutf16string(w_str)); +        mTempDir = ll_convert<std::string>(std::wstring(w_str));          if (mOSUserDir.empty())          { @@ -225,14 +225,14 @@ LLDir_Win32::LLDir_Win32()      // Set working directory, for LLDir::getWorkingDir()      GetCurrentDirectory(MAX_PATH, w_str); -    mWorkingDir = utf16str_to_utf8str(llutf16string(w_str)); +    mWorkingDir = ll_convert<std::string>(std::wstring(w_str));      // Set the executable directory      S32 size = GetModuleFileName(NULL, w_str, MAX_PATH);      if (size)      {          w_str[size] = '\0'; -        mExecutablePathAndName = utf16str_to_utf8str(llutf16string(w_str)); +        mExecutablePathAndName = ll_convert<std::string>(std::wstring(w_str));          auto path_end = mExecutablePathAndName.find_last_of('\\');          if (path_end != std::string::npos)          { @@ -347,8 +347,8 @@ U32 LLDir_Win32::countFilesInDir(const std::string &dirname, const std::string &      WIN32_FIND_DATA FileData; -    llutf16string pathname = utf8str_to_utf16str(dirname); -    pathname += utf8str_to_utf16str(mask); +    std::wstring pathname = ll_convert<std::wstring>(dirname); +    pathname += ll_convert<std::wstring>(mask);      if ((count_search_h = FindFirstFile(pathname.c_str(), &FileData)) != INVALID_HANDLE_VALUE)      { @@ -370,7 +370,7 @@ std::string LLDir_Win32::getCurPath()      WCHAR w_str[MAX_PATH];      GetCurrentDirectory(MAX_PATH, w_str); -    return utf16str_to_utf8str(llutf16string(w_str)); +    return ll_convert<std::string>(std::wstring(w_str));  } diff --git a/indra/llfilesystem/lldir_win32.h b/indra/llfilesystem/lldir_win32.h index ab2726f1a0..21a3f1213b 100644 --- a/indra/llfilesystem/lldir_win32.h +++ b/indra/llfilesystem/lldir_win32.h @@ -51,7 +51,7 @@ public:  private:      void* mDirSearch_h{ nullptr }; -    llutf16string mCurrentDir; +    std::wstring mCurrentDir;  };  #endif // LL_LLDIR_WIN32_H diff --git a/indra/llfilesystem/lldirguard.h b/indra/llfilesystem/lldirguard.h index fcb179bbc8..c6ce13efb4 100644 --- a/indra/llfilesystem/lldirguard.h +++ b/indra/llfilesystem/lldirguard.h @@ -31,6 +31,9 @@  #include "llerror.h"  #if LL_WINDOWS + +#include "llwin32headers.h" +  class LLDirectoryGuard  {  public: @@ -46,8 +49,8 @@ public:              (wcsncmp(mOrigDir,mFinalDir,mOrigDirLen)!=0))          {              // Dir has changed -            std::string mOrigDirUtf8 = utf16str_to_utf8str(llutf16string(mOrigDir)); -            std::string mFinalDirUtf8 = utf16str_to_utf8str(llutf16string(mFinalDir)); +            std::string mOrigDirUtf8 = ll_convert<std::string>(std::wstring(mOrigDir)); +            std::string mFinalDirUtf8 = ll_convert<std::string>(std::wstring(mFinalDir));              LL_INFOS() << "Resetting working dir from " << mFinalDirUtf8 << " to " << mOrigDirUtf8 << LL_ENDL;              SetCurrentDirectory(mOrigDir);          } diff --git a/indra/llfilesystem/lldiriterator.cpp b/indra/llfilesystem/lldiriterator.cpp index cd99c79357..a6eb4adf7f 100644 --- a/indra/llfilesystem/lldiriterator.cpp +++ b/indra/llfilesystem/lldiriterator.cpp @@ -52,7 +52,7 @@ LLDirIterator::Impl::Impl(const std::string &dirname, const std::string &mask)      : mIsValid(false)  {  #ifdef LL_WINDOWS // or BOOST_WINDOWS_API -    fs::path dir_path(utf8str_to_utf16str(dirname)); +    fs::path dir_path(ll_convert<std::wstring>(dirname));  #else      fs::path dir_path(dirname);  #endif diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index d9b223fb49..82e9e18918 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -103,7 +103,7 @@ void LLDiskCache::purge()      std::vector<file_info_t> file_info;  #if LL_WINDOWS -    std::wstring cache_path(utf8str_to_utf16str(sCacheDir)); +    std::wstring cache_path(ll_convert<std::wstring>(sCacheDir));  #else      std::string cache_path(sCacheDir);  #endif @@ -240,7 +240,7 @@ void LLDiskCache::clearCache()       */      boost::system::error_code ec;  #if LL_WINDOWS -    std::wstring cache_path(utf8str_to_utf16str(sCacheDir)); +    std::wstring cache_path(ll_convert<std::wstring>(sCacheDir));  #else      std::string cache_path(sCacheDir);  #endif @@ -279,7 +279,7 @@ void LLDiskCache::removeOldVFSFiles()      boost::system::error_code ec;  #if LL_WINDOWS -    std::wstring cache_path(utf8str_to_utf16str(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""))); +    std::wstring cache_path(ll_convert<std::wstring>(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "")));  #else      std::string cache_path(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""));  #endif @@ -327,7 +327,7 @@ uintmax_t LLDiskCache::dirFileSize(const std::string& dir)       */      boost::system::error_code ec;  #if LL_WINDOWS -    std::wstring dir_path(utf8str_to_utf16str(dir)); +    std::wstring dir_path(ll_convert<std::wstring>(dir));  #else      std::string dir_path(dir);  #endif diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index c8ce9531c2..5ce5244107 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -316,7 +316,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path)      boost::system::error_code ec;  #if LL_WINDOWS      // file last write time -    const std::time_t last_write_time = boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), ec); +    const std::time_t last_write_time = boost::filesystem::last_write_time(ll_convert<std::wstring>(file_path), ec);      if (ec.failed())      {          LL_WARNS() << "Failed to read last write time for cache file " << file_path << ": " << ec.message() << LL_ENDL; @@ -330,7 +330,7 @@ void LLFileSystem::updateFileAccessTime(const std::string& file_path)      // before the last one      if (delta_time > time_threshold)      { -        boost::filesystem::last_write_time(utf8str_to_utf16str(file_path), cur_time, ec); +        boost::filesystem::last_write_time(ll_convert<std::wstring>(file_path), cur_time, ec);      }  #else      // file last write time diff --git a/indra/llfilesystem/tests/lldir_test.cpp b/indra/llfilesystem/tests/lldir_test.cpp index 6e191ad096..d7d57fa86f 100644 --- a/indra/llfilesystem/tests/lldir_test.cpp +++ b/indra/llfilesystem/tests/lldir_test.cpp @@ -435,7 +435,7 @@ namespace tut        for (counter=0, foundUnused=false; !foundUnused; counter++ )        {           char counterStr[3]; -         sprintf(counterStr, "%02d", counter); +         snprintf(counterStr, sizeof(counterStr), "%02d", counter);           uniqueDir = dirbase + counterStr;           foundUnused = ! ( LLFile::isdir(uniqueDir) || LLFile::isfile(uniqueDir) );        } diff --git a/indra/llimage/llimagejpeg.cpp b/indra/llimage/llimagejpeg.cpp index 71b139bc82..803d8f17fc 100644 --- a/indra/llimage/llimagejpeg.cpp +++ b/indra/llimage/llimagejpeg.cpp @@ -31,7 +31,9 @@  #include "llerror.h"  #include "llexception.h" +#if !(LL_DARWIN && defined(__arm64__))  jmp_buf LLImageJPEG::sSetjmpBuffer ; +#endif  LLImageJPEG::LLImageJPEG(S32 quality)  :   LLImageFormatted(IMG_CODEC_JPEG),      mOutputBuffer( NULL ), @@ -435,7 +437,6 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo )      // Let the memory manager delete any temp files      jpeg_destroy(cinfo); -      // Return control to the setjmp point  #if !(LL_DARWIN && defined(__arm64__))      longjmp(sSetjmpBuffer, 1) ; @@ -569,7 +570,6 @@ bool LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time )          return false;      }  #endif -      try      { diff --git a/indra/llimage/llimagejpeg.h b/indra/llimage/llimagejpeg.h index f6d9f19ba5..7a0883797c 100644 --- a/indra/llimage/llimagejpeg.h +++ b/indra/llimage/llimagejpeg.h @@ -78,7 +78,9 @@ protected:      S32             mEncodeQuality;     // on a scale from 1 to 100  private: +#if !LL_ARM64      static jmp_buf  sSetjmpBuffer;      // To allow the library to abort. +#endif  };  #endif  // LL_LLIMAGEJPEG_H diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index 6ebbe359b9..5b672bf171 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -29,8 +29,6 @@  // this is defined so that we get static linking.  #include <openjpeg-2.5/openjpeg.h> -#include <openjpeg-2.5/event.h> -#include <openjpeg-2.5/cio.h>  // Factory function: see declaration in llimagej2c.cpp  LLImageJ2CImpl* fallbackCreateLLImageJ2CImpl() @@ -48,6 +46,7 @@ std::string LLImageJ2COJ::getEngineInfo() const  #endif  } +#if WANT_VERBOSE_OPJ_SPAM  // Return string from message, eliminating final \n if present  static std::string chomp(const char* msg)  { @@ -63,27 +62,34 @@ static std::string chomp(const char* msg)  }      return message;  } +#endif  /**  sample error callback expecting a LLFILE* client object  */  void error_callback(const char* msg, void*)  { -    LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL; +#if WANT_VERBOSE_OPJ_SPAM +    LL_WARNS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL; +#endif  }  /**  sample warning callback expecting a LLFILE* client object  */  void warning_callback(const char* msg, void*)  { -    LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL; +#if WANT_VERBOSE_OPJ_SPAM +    LL_WARNS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL; +#endif  }  /**  sample debug callback expecting no client object  */  void info_callback(const char* msg, void*)  { -    LL_DEBUGS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL; +#if WANT_VERBOSE_OPJ_SPAM +    LL_INFOS() << "LLImageJ2COJ: " << chomp(msg) << LL_ENDL; +#endif  }  // Divide a by 2 to the power of b and round upwards @@ -95,39 +101,13 @@ int ceildivpow2(int a, int b)  class JPEG2KBase  {  public: -    JPEG2KBase() {} +    JPEG2KBase() = default;      U8*        buffer = nullptr;      OPJ_SIZE_T size = 0;      OPJ_OFF_T  offset = 0;  }; -#define WANT_VERBOSE_OPJ_SPAM LL_DEBUG - -static void opj_info(const char* msg, void* user_data) -{ -    llassert(user_data); -#if WANT_VERBOSE_OPJ_SPAM -    LL_INFOS("OpenJPEG") << msg << LL_ENDL; -#endif -} - -static void opj_warn(const char* msg, void* user_data) -{ -    llassert(user_data); -#if WANT_VERBOSE_OPJ_SPAM -    LL_WARNS("OpenJPEG") << msg << LL_ENDL; -#endif -} - -static void opj_error(const char* msg, void* user_data) -{ -    llassert(user_data); -#if WANT_VERBOSE_OPJ_SPAM -    LL_WARNS("OpenJPEG") << msg << LL_ENDL; -#endif -} -  static OPJ_SIZE_T opj_read(void * buffer, OPJ_SIZE_T bytes, void* user_data)  {      llassert(user_data && buffer); @@ -283,11 +263,7 @@ public:      JPEG2KDecode(S8 discardLevel)      { -        memset(&event_mgr, 0, sizeof(opj_event_mgr_t));          memset(¶meters, 0, sizeof(opj_dparameters_t)); -        event_mgr.error_handler = error_callback; -        event_mgr.warning_handler = warning_callback; -        event_mgr.info_handler = info_callback;          opj_set_default_decoder_parameters(¶meters);          parameters.cp_reduce = discardLevel;      } @@ -331,6 +307,11 @@ public:          decoder = opj_create_decompress(OPJ_CODEC_J2K); +        /* catch events using our callbacks and give a local context */ +        opj_set_error_handler(decoder, error_callback, nullptr); +        opj_set_warning_handler(decoder, warning_callback, nullptr); +        opj_set_info_handler(decoder, info_callback, nullptr); +          if (!opj_setup_decoder(decoder, ¶meters))          {              return false; @@ -401,9 +382,9 @@ public:          decoder = opj_create_decompress(OPJ_CODEC_J2K);          opj_setup_decoder(decoder, ¶meters); -        opj_set_info_handler(decoder, opj_info, this); -        opj_set_warning_handler(decoder, opj_warn, this); -        opj_set_error_handler(decoder, opj_error, this); +        opj_set_info_handler(decoder, info_callback, this); +        opj_set_warning_handler(decoder, warning_callback, this); +        opj_set_error_handler(decoder, error_callback, this);          if (stream)          { @@ -469,7 +450,6 @@ public:  private:      opj_dparameters_t         parameters; -    opj_event_mgr_t           event_mgr;      opj_image_t*              image = nullptr;      opj_codec_t*              decoder = nullptr;      opj_stream_t*             stream = nullptr; @@ -484,10 +464,6 @@ public:      JPEG2KEncode(const char* comment_text_in, bool reversible)      {          memset(¶meters, 0, sizeof(opj_cparameters_t)); -        memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); -        event_mgr.error_handler = error_callback; -        event_mgr.warning_handler = warning_callback; -        event_mgr.info_handler = info_callback;          opj_set_default_encoder_parameters(¶meters);          parameters.cod_format = OPJ_CODEC_J2K; @@ -555,6 +531,11 @@ public:          encoder = opj_create_compress(OPJ_CODEC_J2K); +        /* catch events using our callbacks and give a local context */ +        opj_set_error_handler(encoder, error_callback, nullptr); +        opj_set_warning_handler(encoder, warning_callback, nullptr); +        opj_set_info_handler(encoder, info_callback, nullptr); +          parameters.tcp_mct = (image->numcomps >= 3) ? 1 : 0; // no color transform for RGBA images @@ -578,10 +559,6 @@ public:              return false;          } -        opj_set_info_handler(encoder, opj_info, this); -        opj_set_warning_handler(encoder, opj_warn, this); -        opj_set_error_handler(encoder, opj_error, this); -          U32 width_tiles = (rawImageIn.getWidth() >> 6);          U32 height_tiles = (rawImageIn.getHeight() >> 6); @@ -786,7 +763,6 @@ public:  private:      opj_cparameters_t   parameters; -    opj_event_mgr_t     event_mgr;      opj_image_t*        image = nullptr;      opj_codec_t*        encoder = nullptr;      opj_stream_t*       stream = nullptr; diff --git a/indra/llkdu/CMakeLists.txt b/indra/llkdu/CMakeLists.txt index 7cd9f5eb24..411fff34ae 100644 --- a/indra/llkdu/CMakeLists.txt +++ b/indra/llkdu/CMakeLists.txt @@ -27,14 +27,6 @@ set(llkdu_HEADER_FILES  list(APPEND llkdu_SOURCE_FILES ${llkdu_HEADER_FILES}) -# Our KDU package is built with KDU_X86_INTRINSICS in its .vcxproj file. -# Unless that macro is also set for every consumer build, KDU freaks out, -# spamming the viewer log with alignment FUD. -set_source_files_properties(${llkdu_SOURCE_FILES} -                            PROPERTIES -                            COMPILE_DEFINITIONS -                            "KDU_X86_INTRINSICS") -  if (USE_KDU)    add_library (llkdu ${llkdu_SOURCE_FILES}) @@ -42,10 +34,7 @@ if (USE_KDU)    target_include_directories( llkdu  INTERFACE   ${CMAKE_CURRENT_SOURCE_DIR})    # Add tests -  # ND: llkdu tests are very strange as they include stubs for KDU classes/methods -  # if not having access to the right KDU version this test will fail to compile, incidentally I do not -  # have access to a matching version of KDU and thus cannot get this tests to compile -  if (LL_TESTS_KDU) +  if (LL_TESTS)      include(LLAddBuildTest)      include(Tut)      SET(llkdu_TEST_SOURCE_FILES @@ -62,6 +51,6 @@ if (USE_KDU)      set_property( SOURCE ${llkdu_TEST_SOURCE_FILES} PROPERTY LL_TEST_ADDITIONAL_INCLUDE_DIRS ${llimage_include_dir})      LL_ADD_PROJECT_UNIT_TESTS(llkdu "${llkdu_TEST_SOURCE_FILES}") -  endif (LL_TESTS_KDU) +  endif (LL_TESTS)  endif (USE_KDU) diff --git a/indra/llkdu/llimagej2ckdu.cpp b/indra/llkdu/llimagej2ckdu.cpp index b824fd8385..7eba9494a6 100644 --- a/indra/llkdu/llimagej2ckdu.cpp +++ b/indra/llkdu/llimagej2ckdu.cpp @@ -163,6 +163,7 @@ private:      S32 mNumComponents;      bool mUseYCC;      kdu_dims mDims; +    kdu_push_pull_params mParams;      kdu_sample_allocator mAllocator;      kdu_tile_comp mComps[4];      kdu_line_buf mLines[4]; @@ -255,7 +256,7 @@ LLImageJ2CKDU::LLImageJ2CKDU() : LLImageJ2CImpl(),      mCodeStreamp(),      mTPosp(),      mTileIndicesp(), -    mRawImagep(NULL), +    mRawImagep(nullptr),      mDecodeState(),      mBlocksSize(-1),      mPrecinctsSize(-1), @@ -295,17 +296,17 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod          // two U32s and a pointer, so it's not as if it would be a huge overhead          // to allocate a new one every time.          // Also -- why is base.getData() tested specifically here? If that returns -        // NULL, shouldn't we bail out of the whole method? +        // nullptr, shouldn't we bail out of the whole method?          if (!mInputp && base.getData())          {              // The compressed data has been loaded              // Setup the source for the codestream -            mInputp.reset(new LLKDUMemSource(base.getData(), data_size)); +            mInputp = std::make_unique<LLKDUMemSource>(base.getData(), data_size);          }          if (mInputp)          { -            // This is LLKDUMemSource::reset(), not boost::scoped_ptr::reset(). +            // This is LLKDUMemSource::reset(), not std::unique_ptr::reset().              mInputp->reset();          } @@ -315,7 +316,7 @@ void LLImageJ2CKDU::setupCodeStream(LLImageJ2C &base, bool keep_codestream, ECod          // *TODO: This seems to be wrong. The base class should have no idea of          // how j2c compression works so no good way of computing what's the byte          // range to be used. -        mCodeStreamp->set_max_bytes(max_bytes, true); +        mCodeStreamp->set_max_bytes(max_bytes);          //  If you want to flip or rotate the image for some reason, change          // the resolution, or identify a restricted region of interest, this is @@ -461,8 +462,8 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco          mCodeStreamp->change_appearance(false, true, false);          // Apply loading discard level and cropping if required -        kdu_dims* region_kdu = NULL; -        if (region != NULL) +        kdu_dims* region_kdu = nullptr; +        if (region != nullptr)          {              region_kdu = new kdu_dims;              region_kdu->pos.x  = region[0]; @@ -479,7 +480,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco          if (region_kdu)          {              delete region_kdu; -            region_kdu = NULL; +            region_kdu = nullptr;          }          // Resize raw_image according to the image to be decoded @@ -490,12 +491,12 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco          if (!mTileIndicesp)          { -            mTileIndicesp.reset(new kdu_dims); +            mTileIndicesp = std::make_unique<kdu_dims>();          }          mCodeStreamp->get_valid_tiles(*mTileIndicesp);          if (!mTPosp)          { -            mTPosp.reset(new kdu_coords); +            mTPosp = std::make_unique<kdu_coords>();              mTPosp->y = 0;              mTPosp->x = 0;          } @@ -505,7 +506,7 @@ bool LLImageJ2CKDU::initDecode(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco          base.setLastError(msg.what());          return false;      } -    catch (kdu_exception kdu_value) +    catch (const kdu_exception& kdu_value)      {          // KDU internally throws kdu_exception. It's possible that such an          // exception might leak out into our code. Catch kdu_exception @@ -596,8 +597,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco                      kdu_coords offset = tile_dims.pos - dims.pos;                      int row_gap = channels*dims.size.x; // inter-row separation                      kdu_byte *buf = buffer + offset.y*row_gap + offset.x*channels; -                    mDecodeState.reset(new LLKDUDecodeState(tile, buf, row_gap, -                                                            mCodeStreamp.get())); +                    mDecodeState = std::make_unique<LLKDUDecodeState>(tile, buf, row_gap, mCodeStreamp.get());                  }                  // Do the actual processing                  F32 remaining_time = limit_time ? decode_time - decode_timer.getElapsedTimeF32().value() : 0.0f; @@ -622,7 +622,7 @@ bool LLImageJ2CKDU::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 deco                  cleanupCodeStream();                  return true; // done              } -            catch (kdu_exception kdu_value) +            catch (const kdu_exception& kdu_value)              {                  // KDU internally throws kdu_exception. It's possible that such an                  // exception might leak out into our code. Catch kdu_exception @@ -831,7 +831,7 @@ bool LLImageJ2CKDU::encodeImpl(LLImageJ2C &base, const LLImageRaw &raw_image, co          base.setLastError(msg.what());          return false;      } -    catch (kdu_exception kdu_value) +    catch (const kdu_exception& kdu_value)      {          // KDU internally throws kdu_exception. It's possible that such an          // exception might leak out into our code. Catch kdu_exception @@ -865,7 +865,7 @@ bool LLImageJ2CKDU::getMetadata(LLImageJ2C &base)          base.setLastError(msg.what());          return false;      } -    catch (kdu_exception kdu_value) +    catch (const kdu_exception& kdu_value)      {          // KDU internally throws kdu_exception. It's possible that such an          // exception might leak out into our code. Catch kdu_exception @@ -997,8 +997,8 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)          //std::cout << "Parsing discard level = " << discard_level << std::endl;          // Create the input codestream object.          setupCodeStream(base, true, MODE_FAST); -        mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, NULL); -        mCodeStreamp->set_max_bytes(KDU_LONG_MAX,true); +        mCodeStreamp->apply_input_restrictions(0, 4, discard_level, 0, nullptr); +        mCodeStreamp->set_max_bytes(KDU_LONG_MAX,false);          siz_params *siz_in = mCodeStreamp->access_siz();          // Create the output codestream object. @@ -1094,8 +1094,10 @@ void LLImageJ2CKDU::findDiscardLevelsBoundaries(LLImageJ2C &base)  void set_default_colour_weights(kdu_params *siz)  { +    kdu_params *enc = siz->access_cluster(ENC_params); +    assert(enc != nullptr);      kdu_params *cod = siz->access_cluster(COD_params); -    assert(cod != NULL); +    assert(cod != nullptr);      bool can_use_ycc = true;      bool rev0 = false; @@ -1132,7 +1134,7 @@ void set_default_colour_weights(kdu_params *siz)          return;      }      float weight; -    if (cod->get(Clev_weights,0,0,weight) || cod->get(Cband_weights,0,0,weight)) +    if (enc->get(Clev_weights,0,0,weight) || enc->get(Cband_weights,0,0,weight))      {          // Weights already specified explicitly -> nothing to do          return; @@ -1141,17 +1143,16 @@ void set_default_colour_weights(kdu_params *siz)      // These example weights are adapted from numbers generated by Marcus Nadenau      // at EPFL, for a viewing distance of 15 cm and a display resolution of      // 300 DPI. - -    cod->parse_string("Cband_weights:C0=" +    enc->parse_string("Cband_weights:C0="          "{0.0901},{0.2758},{0.2758},"          "{0.7018},{0.8378},{0.8378},{1}"); -    cod->parse_string("Cband_weights:C1=" +    enc->parse_string("Cband_weights:C1="          "{0.0263},{0.0863},{0.0863},"          "{0.1362},{0.2564},{0.2564},"          "{0.3346},{0.4691},{0.4691},"          "{0.5444},{0.6523},{0.6523},"          "{0.7078},{0.7797},{0.7797},{1}"); -    cod->parse_string("Cband_weights:C2=" +    enc->parse_string("Cband_weights:C2="          "{0.0773},{0.1835},{0.1835},"          "{0.2598},{0.4130},{0.4130},"          "{0.5040},{0.6464},{0.6464}," @@ -1170,7 +1171,7 @@ byte buffer, spacing successive output samples apart by `gap' bytes  all necessary level shifting, type conversion, rounding and truncation. */  {      int width = src.get_width(); -    if (src.get_buf32() != NULL) +    if (src.get_buf32() != nullptr)      { // Decompressed samples have a 32-bit representation (integer or float)          assert(precision >= 8); // Else would have used 16 bit representation          kdu_sample32 *sp = src.get_buf32(); @@ -1333,11 +1334,11 @@ LLKDUDecodeState::LLKDUDecodeState(kdu_tile tile, kdu_byte *buf, S32 row_gap,          mLines[c].pre_create(&mAllocator,mDims.size.x,mReversible[c],use_shorts,0,0);          if (res.which() == 0) // No DWT levels used          { -            mEngines[c] = kdu_decoder(res.access_subband(LL_BAND),&mAllocator,use_shorts); +            mEngines[c] = kdu_decoder(res.access_subband(LL_BAND), &mAllocator, mParams, use_shorts);          }          else          { -            mEngines[c] = kdu_synthesis(res,&mAllocator,use_shorts); +            mEngines[c] = kdu_synthesis(res, &mAllocator, mParams, use_shorts);          }      }      mAllocator.finalize(*codestreamp); // Actually creates buffering resources @@ -1415,7 +1416,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod      this->codestream = codestream;      codestream.get_valid_tiles(valid_tile_indices);      tile_idx = valid_tile_indices.pos; -    tile = codestream.open_tile(tile_idx,NULL); +    tile = codestream.open_tile(tile_idx, nullptr);      // Set up the individual components      num_components = codestream.get_num_components(true); @@ -1424,7 +1425,7 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod      kdc_component_flow_control *comp = components;      for (n = 0; n < num_components; n++, comp++)      { -        comp->line = NULL; +        comp->line = nullptr;          comp->reader = img_in;          kdu_coords subsampling;          codestream.get_subsampling(n,subsampling,true); @@ -1441,12 +1442,12 @@ kdc_flow_control::kdc_flow_control (kdu_supp::kdu_image_in_base *img_in, kdu_cod      assert(num_components >= 0);      tile.set_components_of_interest(num_components); -    max_buffer_memory = engine.create(codestream,tile,false,NULL,false,1,NULL,NULL,false); +    max_buffer_memory = engine.create(codestream, tile, false, nullptr, false, 1, nullptr, nullptr,false);  }  kdc_flow_control::~kdc_flow_control()  { -    if (components != NULL) +    if (components != nullptr)      {          delete[] components;      } @@ -1473,8 +1474,8 @@ bool kdc_flow_control::advance_components()                  if (comp->ratio_counter < 0)                  {                      found_line = true; -                    comp->line = engine.exchange_line(n,NULL,NULL); -                    assert(comp->line != NULL); +                    comp->line = engine.exchange_line(n,nullptr,nullptr); +                    assert(comp->line != nullptr);                      if (comp->line->get_width())                      {                          comp->reader->get(n,*(comp->line),0); @@ -1501,9 +1502,9 @@ void kdc_flow_control::process_components()              assert(comp->ratio_counter >= 0);              assert(comp->remaining_lines > 0);              comp->remaining_lines--; -            assert(comp->line != NULL); -            engine.exchange_line(n,comp->line,NULL); -            comp->line = NULL; +            assert(comp->line != nullptr); +            engine.exchange_line(n,comp->line,nullptr); +            comp->line = nullptr;          }      }  } diff --git a/indra/llkdu/llimagej2ckdu.h b/indra/llkdu/llimagej2ckdu.h index 8037c81868..c9aa0c5250 100644 --- a/indra/llkdu/llimagej2ckdu.h +++ b/indra/llkdu/llimagej2ckdu.h @@ -27,12 +27,13 @@  #ifndef LL_LLIMAGEJ2CKDU_H  #define LL_LLIMAGEJ2CKDU_H +#include "llpreprocessor.h" +  #include "llimagej2c.h"  //  // KDU core header files  // -#define KDU_NO_THREADS  #include "kdu_elementary.h"  #include "kdu_messaging.h"  #include "kdu_params.h" @@ -41,7 +42,6 @@  #include "include_kdu_xxxx.h"  #include "kdu_sample_processing.h" -#include <boost/scoped_ptr.hpp>  #include <boost/noncopyable.hpp>  class LLKDUDecodeState; diff --git a/indra/llkdu/llkdumem.h b/indra/llkdu/llkdumem.h index 177a8ea976..56aff13c76 100644 --- a/indra/llkdu/llkdumem.h +++ b/indra/llkdu/llkdumem.h @@ -27,9 +27,9 @@  #ifndef LL_LLKDUMEM_H  #define LL_LLKDUMEM_H -// Support classes for reading and writing from memory buffers in KDU -#define KDU_NO_THREADS +#include "llpreprocessor.h" +// Support classes for reading and writing from memory buffers in KDU  #define kdu_xxxx "kdu_image.h"  #include "include_kdu_xxxx.h" @@ -54,9 +54,7 @@ public:          mCurPos = 0;      } -    ~LLKDUMemSource() -    { -    } +    ~LLKDUMemSource() = default;      int read(kdu_core::kdu_byte *buf, int num_bytes)      { @@ -94,9 +92,7 @@ public:          mOutputSize = &output_size;      } -    ~LLKDUMemTarget() -    { -    } +    ~LLKDUMemTarget() = default;      bool write(const kdu_core::kdu_byte *buf, int num_bytes)      { diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index db81d60d9e..bc52a15c4a 100644 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -80,6 +80,7 @@ U8* LLImageBase::getData() { return NULL; }  U8* LLImageBase::reallocateData(S32 ) { return NULL; }  void LLImageBase::sanityCheck() { }  void LLImageBase::setSize(S32 , S32 , S32 ) { } +bool LLImageBase::isBufferInvalid() const { return false; }  LLImageJ2CImpl::~LLImageJ2CImpl() { } @@ -139,18 +140,19 @@ int kdu_tile_comp::get_bit_depth(bool ) { return 8; }  bool kdu_tile_comp::get_reversible() { return false; }  int kdu_tile_comp::get_num_resolutions() { return 1; }  kdu_subband kdu_resolution::access_subband(int ) { kdu_subband a; return a; } -void kdu_resolution::get_dims(kdu_dims& ) { } -int kdu_resolution::which() { return 0; } -int kdu_resolution::get_valid_band_indices(int &) { return 1; } -kdu_synthesis::kdu_synthesis(kdu_resolution, kdu_sample_allocator*, bool, float, kdu_thread_env*, kdu_thread_queue*) { } +void kdu_resolution::get_dims(kdu_dims& ) const { } +int kdu_resolution::which() const { return 0; } +int kdu_resolution::get_valid_band_indices(int &) const { return 1; } +kdu_synthesis::kdu_synthesis(kdu_resolution, kdu_sample_allocator*, kdu_push_pull_params&, bool, float, kdu_thread_env*, kdu_thread_queue*) { }  //kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool) { } -kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool, kd_core_local::kd_coremem*) {} +kdu_params::kdu_params(const char*, bool, bool, bool, bool, bool) {}  kdu_params::~kdu_params() { } +void kdu_params::destroy() { }  void kdu_params::set(const char* , int , int , bool ) { }  void kdu_params::set(const char* , int , int , int ) { }  void kdu_params::finalize_all(bool ) { }  void kdu_params::finalize_all(int, bool ) { } -void kdu_params::copy_from(kdu_params*, int, int, int, int, int, bool, bool, bool) { } +void kdu_params::copy_from(kdu_params*, int, int, int, int, int, bool, bool, bool, bool) { }  bool kdu_params::parse_string(const char*) { return false; }  bool kdu_params::get(const char*, int, int, bool&, bool, bool, bool) { return false; }  bool kdu_params::get(const char*, int, int, float&, bool, bool, bool) { return false; } @@ -159,13 +161,13 @@ kdu_params* kdu_params::access_relation(int, int, int, bool) { return NULL; }  kdu_params* kdu_params::access_cluster(const char*) { return NULL; }  void kdu_codestream::set_fast() { }  void kdu_codestream::set_fussy() { } -void kdu_codestream::get_dims(int, kdu_dims&, bool ) { } +void kdu_codestream::get_dims(int, kdu_dims&, bool ) const { }  int kdu_codestream::get_min_dwt_levels() { return 5; }  int kdu_codestream::get_max_tile_layers() { return 1; }  void kdu_codestream::change_appearance(bool, bool, bool, kdu_thread_env *) {}  void kdu_codestream::get_tile_dims(kdu_coords, int, kdu_dims&, bool ) { }  void kdu_codestream::destroy() { } -void kdu_codestream::collect_timing_stats(int ) { } +void kdu_codestream::collect_timing_stats(int ) const { }  void kdu_codestream::set_max_bytes(kdu_long, bool, bool ) { }  void kdu_codestream::get_valid_tiles(kdu_dims& ) { }  void kdu_codestream::create( @@ -182,19 +184,21 @@ void kdu_codestream::get_subsampling(int , kdu_coords&, bool ) { }  void kdu_codestream::flush(kdu_long *, int, kdu_uint16 *, bool, bool, double, kdu_thread_env*, int) { }  void kdu_codestream::set_resilient(bool ) { }  int kdu_codestream::get_num_components(bool ) { return 0; } -kdu_long kdu_codestream::get_total_bytes(bool ) { return 0; } +kdu_long kdu_codestream::get_total_bytes(bool ) const { return 0; }  kdu_long kdu_codestream::get_compressed_data_memory(bool ) const {return 0; }  void kdu_codestream::share_buffering(kdu_codestream ) { } -int kdu_codestream::get_num_tparts() { return 0; } +int kdu_codestream::get_num_tparts() const { return 0; }  int kdu_codestream::trans_out(kdu_long, kdu_long*, int, bool, kdu_thread_env* ) { return 0; }  bool kdu_codestream::ready_for_flush(kdu_thread_env*) { return false; }  siz_params* kdu_codestream::access_siz() { return NULL; }  kdu_tile kdu_codestream::open_tile(kdu_coords , kdu_thread_env* ) { kdu_tile a; return a; }  kdu_codestream_comment kdu_codestream::add_comment(kdu_thread_env*) { kdu_codestream_comment a; return a; } +kdu_codestream_comment  kdu_codestream::get_comment(kdu_codestream_comment) { kdu_codestream_comment a; return a; };  void kdu_subband::close_block(kdu_block*, kdu_thread_env*) { }  void kdu_subband::get_valid_blocks(kdu_dims &indices) const { }  kdu_block * kdu_subband::open_block(kdu_coords, int *, kdu_thread_env *, int, bool) { return NULL; }  bool kdu_codestream_comment::put_text(const char*) { return false; } +const char *kdu_codestream_comment::get_text() { return nullptr; };  void kdu_customize_warnings(kdu_message*) { }  void kdu_customize_errors(kdu_message*) { }  kdu_long kdu_multi_analysis::create( @@ -209,16 +213,18 @@ kdu_long kdu_multi_analysis::create(      const kdu_push_pull_params*,      kdu_membroker*) { return kdu_long(0); }  void kdu_multi_analysis::destroy(kdu_thread_env *) {} +siz_params::siz_params() : kdu_params(NULL, false, false, false, false, false) { }  siz_params::siz_params(kd_core_local::kd_coremem*) : kdu_params(NULL, false, false, false, false, false) { }  siz_params::~siz_params() {}  void siz_params::finalize(bool ) { }  void siz_params::copy_with_xforms(kdu_params*, int, int, bool, bool, bool) { } -int siz_params::write_marker_segment(kdu_output*, kdu_params*, int) { return 0; } +int siz_params::write_marker_segment(kdu_output*, kdu_params*, int, int&) { return 0; }  bool siz_params::check_marker_segment(kdu_uint16, int, kdu_byte a[], int&) { return false; } -bool siz_params::read_marker_segment(kdu_uint16, int, kdu_byte a[], int) { return false; } +int siz_params::read_marker_segment(kdu_uint16 code, int num_bytes, kdu_byte bytes[], int tpart_idx) { return false; }  kdu_decoder::kdu_decoder(      kdu_subband subband,      kdu_sample_allocator*, +    kdu_push_pull_params&,      bool, float, int,      kdu_thread_env*,      kdu_thread_queue*, diff --git a/indra/llmath/llbbox.h b/indra/llmath/llbbox.h index 5617eaebde..3a4e09a598 100644 --- a/indra/llmath/llbbox.h +++ b/indra/llmath/llbbox.h @@ -95,6 +95,10 @@ private:      bool                mEmpty;     // Nothing has been added to this bbox yet  }; +static_assert(std::is_trivially_copyable<LLBBox>::value, "LLBBox must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLBBox>::value, "LLBBox must be trivial move"); +static_assert(std::is_standard_layout<LLBBox>::value, "LLBBox must be a standard layout type"); +  //LLBBox operator*(const LLBBox &a, const LLMatrix4 &b); diff --git a/indra/llmath/llbboxlocal.h b/indra/llmath/llbboxlocal.h index e215e55460..f743bc0ee4 100644 --- a/indra/llmath/llbboxlocal.h +++ b/indra/llmath/llbboxlocal.h @@ -61,5 +61,8 @@ private:  LLBBoxLocal operator*(const LLBBoxLocal &a, const LLMatrix4 &b); +static_assert(std::is_trivially_copyable<LLBBoxLocal>::value, "LLBBoxLocal must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLBBoxLocal>::value, "LLBBoxLocal must be trivial move"); +static_assert(std::is_standard_layout<LLBBoxLocal>::value, "LLBBoxLocal must be a standard layout type");  #endif  // LL_BBOXLOCAL_H diff --git a/indra/llmath/llline.h b/indra/llmath/llline.h index e98e173d1f..fa151f8b20 100644 --- a/indra/llmath/llline.h +++ b/indra/llmath/llline.h @@ -40,7 +40,7 @@ class LLLine  public:      LLLine();      LLLine( const LLVector3& first_point, const LLVector3& second_point ); -    virtual ~LLLine() {}; +    ~LLLine() = default;      void setPointDirection( const LLVector3& first_point, const LLVector3& second_point );      void setPoints( const LLVector3& first_point, const LLVector3& second_point ); @@ -76,5 +76,8 @@ protected:      LLVector3 mDirection;  }; +static_assert(std::is_trivially_copyable<LLLine>::value, "LLLine must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLLine>::value, "LLLine must be trivial move"); +static_assert(std::is_standard_layout<LLLine>::value, "LLLine must be a standard layout type");  #endif diff --git a/indra/llmath/llmatrix3a.h b/indra/llmath/llmatrix3a.h index dff6604ae5..9b173c22ed 100644 --- a/indra/llmath/llmatrix3a.h +++ b/indra/llmath/llmatrix3a.h @@ -56,7 +56,7 @@ public:      //////////////////////////      // Ctor -    LLMatrix3a() {} +    LLMatrix3a() = default;      // Ctor for setting by columns      inline LLMatrix3a( const LLVector4a& c0, const LLVector4a& c1, const LLVector4a& c2 ); @@ -115,14 +115,18 @@ protected:  }; +static_assert(std::is_trivial<LLMatrix3a>::value, "LLMatrix3a must be a trivial type"); +  class LLRotation : public LLMatrix3a  {  public: -    LLRotation() {} +    LLRotation() = default;      // Returns true if this rotation is orthonormal with det ~= 1      inline bool isOkRotation() const;  }; +static_assert(std::is_trivial<LLRotation>::value, "LLRotation must be a trivial type"); +  #endif diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h index 3b423f783a..377203098e 100644 --- a/indra/llmath/llmatrix4a.h +++ b/indra/llmath/llmatrix4a.h @@ -36,10 +36,7 @@ class LLMatrix4a  public:      LL_ALIGN_16(LLVector4a mMatrix[4]); -    LLMatrix4a() -    { - -    } +    LLMatrix4a() = default;      explicit LLMatrix4a(const LLMatrix4& val)      { @@ -228,6 +225,8 @@ public:      const LLVector4a& getTranslation() const { return mMatrix[3]; }  }; +static_assert(std::is_trivial<LLMatrix4a>::value, "LLMatrix4a must be a trivial type"); +  inline LLVector4a rowMul(const LLVector4a &row, const LLMatrix4a &mat)  {      LLVector4a result; diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h index 4e8546e32b..832004bb64 100644 --- a/indra/llmath/llplane.h +++ b/indra/llmath/llplane.h @@ -43,7 +43,7 @@ class LLPlane  public:      // Constructors -    LLPlane() {}; // no default constructor +    LLPlane() = default;      LLPlane(const LLVector3 &p0, F32 d) { setVec(p0, d); }      LLPlane(const LLVector3 &p0, const LLVector3 &n) { setVec(p0, n); }      inline void setVec(const LLVector3 &p0, F32 d) { mV.set(p0[0], p0[1], p0[2], d); } @@ -104,6 +104,7 @@ private:      LLVector4a mV;  } LL_ALIGN_POSTFIX(16); +static_assert(std::is_trivial<LLPlane>::value, "LLPlane must be a trivial type");  #endif // LL_LLPLANE_H diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h index 762d13eded..472d7ca62d 100644 --- a/indra/llmath/llquaternion.h +++ b/indra/llmath/llquaternion.h @@ -174,6 +174,10 @@ public:      //static U32 mMultCount;  }; +static_assert(std::is_trivially_copyable<LLQuaternion>::value, "LLQuaternion must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLQuaternion>::value, "LLQuaternion must be trivial move"); +static_assert(std::is_standard_layout<LLQuaternion>::value, "LLQuaternion must be a standard layout type"); +  inline LLSD LLQuaternion::getValue() const  {      LLSD ret; diff --git a/indra/llmath/llquaternion2.h b/indra/llmath/llquaternion2.h index 902bfb7134..c9dcc4573f 100644 --- a/indra/llmath/llquaternion2.h +++ b/indra/llmath/llquaternion2.h @@ -49,7 +49,7 @@ public:      //////////////////////////      // Ctor -    LLQuaternion2() {} +    LLQuaternion2() = default;      // Ctor from LLQuaternion      explicit LLQuaternion2( const class LLQuaternion& quat ); @@ -102,4 +102,6 @@ protected:  }; +static_assert(std::is_trivial<LLQuaternion2>::value, "LLQuaternion2 must be a trivial type"); +  #endif diff --git a/indra/llmath/llrect.h b/indra/llmath/llrect.h index 317578da06..0a3da2fee0 100644 --- a/indra/llmath/llrect.h +++ b/indra/llmath/llrect.h @@ -51,10 +51,6 @@ public:      LLRectBase():   mLeft(0), mTop(0), mRight(0), mBottom(0)      {} -    LLRectBase(const LLRectBase &r): -    mLeft(r.mLeft), mTop(r.mTop), mRight(r.mRight), mBottom(r.mBottom) -    {} -      LLRectBase(Type left, Type top, Type right, Type bottom):      mLeft(left), mTop(top), mRight(right), mBottom(bottom)      {} @@ -295,4 +291,8 @@ template <class Type> LLRectBase<Type> LLRectBase<Type>::null(0,0,0,0);  typedef LLRectBase<S32> LLRect;  typedef LLRectBase<F32> LLRectf; +static_assert(std::is_trivially_copyable<LLRect>::value, "LLRect must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLRect>::value, "LLRect must be trivial move"); +static_assert(std::is_standard_layout<LLRect>::value, "LLRect must be a standard layout type"); +  #endif diff --git a/indra/llmath/llsimdmath.h b/indra/llmath/llsimdmath.h index 6242095456..440561e589 100644 --- a/indra/llmath/llsimdmath.h +++ b/indra/llmath/llsimdmath.h @@ -31,8 +31,12 @@  #error "Please include llmath.h before this file."  #endif -#if ( ( LL_DARWIN || LL_LINUX ) && !(__SSE2__ || __ARM_NEON) ) || ( LL_WINDOWS && ( _M_IX86_FP < 2 && ADDRESS_SIZE == 32 ) ) -#error SSE2 not enabled. LLVector4a and related class will not compile. +#if ( ( LL_DARWIN || LL_LINUX ) ) +    #if !(__SSE2__ || __ARM_NEON) +        #error SSE2 not enabled. LLVector4a and related class will not compile. +    #endif +#elif ( LL_WINDOWS && ( _M_IX86_FP < 2 && ADDRESS_SIZE == 32 ) ) +    #error SSE2 not enabled. LLVector4a and related class will not compile.  #endif  #if !LL_WINDOWS diff --git a/indra/llmath/llsimdtypes.h b/indra/llmath/llsimdtypes.h index a407f51029..6c4f55b0c0 100644 --- a/indra/llmath/llsimdtypes.h +++ b/indra/llmath/llsimdtypes.h @@ -36,7 +36,7 @@ typedef __m128  LLQuad;  class LLBool32  {  public: -    inline LLBool32() {} +    inline LLBool32() = default;      inline LLBool32(int rhs) : m_bool(rhs) {}      inline LLBool32(unsigned int rhs) : m_bool(rhs) {}      inline LLBool32(bool rhs) { m_bool = static_cast<const int>(rhs); } @@ -46,13 +46,15 @@ public:      inline operator bool() const { return static_cast<const bool&>(m_bool); }  private: -    int m_bool{ 0 }; +    int m_bool;  }; +static_assert(std::is_trivial<LLBool32>::value, "LLBool32 must be a standard layout type"); +  class LLSimdScalar  {  public: -    inline LLSimdScalar() {} +    inline LLSimdScalar() = default;      inline LLSimdScalar(LLQuad q)      {          mQ = q; @@ -100,7 +102,9 @@ public:      }  private: -    LLQuad mQ{}; +    LLQuad mQ;  }; +static_assert(std::is_trivial<LLSimdScalar>::value, "LLSimdScalar must be a standard layout type"); +  #endif //LL_SIMD_TYPES_H diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h index 4004852e06..764a3b94e6 100644 --- a/indra/llmath/llvector4a.h +++ b/indra/llmath/llvector4a.h @@ -95,10 +95,7 @@ public:      ////////////////////////////////////      //LLVector4a is plain data which should never have a default constructor or destructor(malloc&free won't trigger it) -    LLVector4a() -    { //DO NOT INITIALIZE -- The overhead is completely unnecessary -        ll_assert_aligned(this,16); -    } +    LLVector4a() = default;      LLVector4a(F32 x, F32 y, F32 z, F32 w = 0.f)      { @@ -361,8 +358,6 @@ public:      ////////////////////////////////////      // Do NOT add aditional operators without consulting someone with SSE experience -    inline const LLVector4a& operator= ( const LLVector4a& rhs ); -      inline const LLVector4a& operator= ( const LLQuad& rhs );      inline operator LLQuad() const; @@ -378,9 +373,11 @@ public:      };  private: -    LLQuad mQ{}; +    LLQuad mQ;  }; +static_assert(std::is_trivial<LLVector4a>::value, "LLVector4a must be a trivial type"); +  inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p)  {      min.setMin(min, p); diff --git a/indra/llmath/llvector4a.inl b/indra/llmath/llvector4a.inl index 17e7de6eeb..0f7c4123ac 100644 --- a/indra/llmath/llvector4a.inl +++ b/indra/llmath/llvector4a.inl @@ -115,7 +115,7 @@ inline void LLVector4a::set(F32 x, F32 y, F32 z, F32 w)  // Set to all zeros  inline void LLVector4a::clear()  { -    mQ = LLVector4a::getZero().mQ; +    mQ = _mm_setzero_ps();  }  inline void LLVector4a::splat(const F32 x) @@ -272,6 +272,9 @@ inline void LLVector4a::setCross3(const LLVector4a& a, const LLVector4a& b)  // Set all elements to the dot product of the x, y, and z elements in a and b  inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)  { +#if (defined(__arm64__) || defined(__aarch64__)) +    mQ = _mm_dp_ps(a.mQ, b.mQ, 0x7f); +#else      // ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }      const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );      // yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] } @@ -284,11 +287,15 @@ inline void LLVector4a::setAllDot3(const LLVector4a& a, const LLVector4a& b)      const __m128i zSplat = _mm_shuffle_epi32(_mm_castps_si128(ab), _MM_SHUFFLE( 2, 2, 2, 2 ));      // mQ = { a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }      mQ = _mm_add_ps(_mm_castsi128_ps(zSplat), xPlusYSplat); +#endif  }  // Set all elements to the dot product of the x, y, z, and w elements in a and b  inline void LLVector4a::setAllDot4(const LLVector4a& a, const LLVector4a& b)  { +#if (defined(__arm64__) || defined(__aarch64__)) +    mQ = _mm_dp_ps(a.mQ, b.mQ, 0xff); +#else      // ab = { a[W]*b[W], a[Z]*b[Z], a[Y]*b[Y], a[X]*b[X] }      const LLQuad ab = _mm_mul_ps( a.mQ, b.mQ );      // yzxw = { a[W]*b[W], a[Z]*b[Z], a[X]*b[X], a[Y]*b[Y] } @@ -301,21 +308,29 @@ inline void LLVector4a::setAllDot4(const LLVector4a& a, const LLVector4a& b)      // mQ = { a[W]*b[W] + a[Z] * b[Z] + a[Y] * b[Y] + a[X] * b[X], same, same, same }      mQ = _mm_add_ps(xPlusYSplat, zPlusWSplat); +#endif  }  // Return the 3D dot product of this vector and b  inline LLSimdScalar LLVector4a::dot3(const LLVector4a& b) const  { +#if (defined(__arm64__) || defined(__aarch64__)) +    return _mm_dp_ps(mQ, b.mQ, 0x7f); +#else      const LLQuad ab = _mm_mul_ps( mQ, b.mQ );      const LLQuad splatY = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(1, 1, 1, 1) ) );      const LLQuad splatZ = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128(ab), _MM_SHUFFLE(2, 2, 2, 2) ) );      const LLQuad xPlusY = _mm_add_ps( ab, splatY );      return _mm_add_ps( xPlusY, splatZ ); +#endif  }  // Return the 4D dot product of this vector and b  inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const  { +#if (defined(__arm64__) || defined(__aarch64__)) +    return _mm_dp_ps(mQ, b.mQ, 0xff); +#else      // ab = { w, z, y, x }      const LLQuad ab = _mm_mul_ps( mQ, b.mQ );      // upperProdsInLowerElems = { y, x, y, x } @@ -325,6 +340,7 @@ inline LLSimdScalar LLVector4a::dot4(const LLVector4a& b) const      // shuffled = { z+x, z+x, z+x, z+x }      const LLQuad shuffled = _mm_castsi128_ps( _mm_shuffle_epi32( _mm_castps_si128( sumOfPairs ), _MM_SHUFFLE(1, 1, 1, 1) ) );      return _mm_add_ss( sumOfPairs, shuffled ); +#endif  }  // Normalize this vector with respect to the x, y, and z components only. Accurate to 22 bites of precision. W component is destroyed @@ -608,12 +624,6 @@ inline bool LLVector4a::equals3(const LLVector4a& rhs, F32 tolerance ) const  ////////////////////////////////////  // Do NOT add aditional operators without consulting someone with SSE experience -inline const LLVector4a& LLVector4a::operator= ( const LLVector4a& rhs ) -{ -    mQ = rhs.mQ; -    return *this; -} -  inline const LLVector4a& LLVector4a::operator= ( const LLQuad& rhs )  {      mQ = rhs; diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h index 70759eef5c..77cb5862e5 100644 --- a/indra/llmath/llvector4logical.h +++ b/indra/llmath/llvector4logical.h @@ -61,7 +61,7 @@ public:      };      // Empty default ctor -    LLVector4Logical() {} +    LLVector4Logical() = default;      LLVector4Logical( const LLQuad& quad )      { @@ -120,7 +120,9 @@ public:  private: -    LLQuad mQ{}; +    LLQuad mQ;  }; +static_assert(std::is_trivial<LLVector4Logical>::value, "LLVector4Logical must be a standard layout type"); +  #endif //LL_VECTOR4ALOGICAL_H diff --git a/indra/llmath/m3math.h b/indra/llmath/m3math.h index cd14290246..36661d2cb0 100644 --- a/indra/llmath/m3math.h +++ b/indra/llmath/m3math.h @@ -142,6 +142,10 @@ class LLMatrix3          friend std::ostream&     operator<<(std::ostream& s, const LLMatrix3 &a);   // Stream a  }; +static_assert(std::is_trivially_copyable<LLMatrix3>::value, "LLMatrix3 must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLMatrix3>::value, "LLMatrix3 must be trivial move"); +static_assert(std::is_standard_layout<LLMatrix3>::value, "LLMatrix3 must be a standard layout type"); +  inline LLMatrix3::LLMatrix3(void)  {      mMatrix[0][0] = 1.f; diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp index a9853fe7e9..1724a50601 100644 --- a/indra/llmath/m4math.cpp +++ b/indra/llmath/m4math.cpp @@ -156,10 +156,6 @@ LLMatrix4::LLMatrix4(const F32 roll, const F32 pitch, const F32 yaw)      mMatrix[3][3] = 1.f;  } -LLMatrix4::~LLMatrix4(void) -{ -} -  // Clear and Assignment Functions  const LLMatrix4& LLMatrix4::setZero() diff --git a/indra/llmath/m4math.h b/indra/llmath/m4math.h index b0f8c90cdf..f164779283 100644 --- a/indra/llmath/m4math.h +++ b/indra/llmath/m4math.h @@ -119,8 +119,6 @@ public:                const LLVector4 &pos);                        // Initializes Matrix with Euler angles      LLMatrix4(const F32 roll, const F32 pitch, const F32 yaw);              // Initializes Matrix with Euler angles -    ~LLMatrix4(void);                                       // Destructor -      LLSD getValue() const;      void setValue(const LLSD&); @@ -242,6 +240,10 @@ public:      friend std::ostream&     operator<<(std::ostream& s, const LLMatrix4 &a);   // Stream a  }; +static_assert(std::is_trivially_copyable<LLMatrix4>::value, "LLMatrix4 must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLMatrix4>::value, "LLMatrix4 must be trivial move"); +static_assert(std::is_standard_layout<LLMatrix4>::value, "LLMatrix4 must be a standard layout type"); +  inline const LLMatrix4& LLMatrix4::setIdentity()  {      mMatrix[0][0] = 1.f; diff --git a/indra/llmath/tests/llquaternion_test.cpp b/indra/llmath/tests/llquaternion_test.cpp index aa3c0ad843..ba18d54d55 100644 --- a/indra/llmath/tests/llquaternion_test.cpp +++ b/indra/llmath/tests/llquaternion_test.cpp @@ -349,9 +349,9 @@ namespace tut          ensure(              "2. LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot) failed",              is_approx_equal(-58153.5390f, result.mV[0]) && -            (183787.8125f == result.mV[1]) && -            (116864.164063f == result.mV[2]) && -            (78.099998f == result.mV[3])); +            is_approx_equal(183787.8125f, result.mV[1]) && +            is_approx_equal(116864.164063f, result.mV[2]) && +            is_approx_equal(78.099998f, result.mV[3]));      }      //test case for LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot) fn. diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index 6b9d37535b..b31e4056a3 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -110,6 +110,9 @@ class LLVector2          friend std::ostream& operator<<(std::ostream& s, const LLVector2 &a);       // Stream a  }; +static_assert(std::is_trivially_copyable<LLVector2>::value, "LLVector2 must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLVector2>::value, "LLVector2 must be trivial move"); +static_assert(std::is_standard_layout<LLVector2>::value, "LLVector2 must be a standard layout type");  // Non-member functions diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index 48b36e7c8a..7357d93599 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -144,8 +144,11 @@ public:      inline void exp(); // Do an exponential on the color  }; -LLColor3 lerp(const LLColor3& a, const LLColor3& b, F32 u); +static_assert(std::is_trivially_copyable<LLColor3>::value, "LLColor3 must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLColor3>::value, "LLColor3 must be trivial move"); +static_assert(std::is_standard_layout<LLColor3>::value, "LLColor3 must be a standard layout type"); +LLColor3 lerp(const LLColor3& a, const LLColor3& b, F32 u);  void LLColor3::clamp()  {      // Clamp the color... diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h index fcce2c30eb..7c56cf138d 100644 --- a/indra/llmath/v3dmath.h +++ b/indra/llmath/v3dmath.h @@ -129,6 +129,10 @@ public:      static bool parseVector3d(const std::string& buf, LLVector3d* value);  }; +static_assert(std::is_trivially_copyable<LLVector3d>::value, "LLVector3d must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLVector3d>::value, "LLVector3d must be trivial move"); +static_assert(std::is_standard_layout<LLVector3d>::value, "LLVector3d must be a standard layout type"); +  typedef LLVector3d LLGlobalVec;  inline const LLVector3d &LLVector3d::set(const LLVector3 &vec) diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index 098ca5218c..196ecdcf7d 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -164,6 +164,10 @@ class LLVector3          static bool parseVector3(const std::string& buf, LLVector3* value);  }; +static_assert(std::is_trivially_copyable<LLVector3>::value, "LLVector3 must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLVector3>::value, "LLVector3 must be trivial move"); +static_assert(std::is_standard_layout<LLVector3>::value, "LLVector3 must be a standard layout type"); +  typedef LLVector3 LLSimLocalVec;  // Non-member functions diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 2f1cb21113..d48020c223 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -231,6 +231,10 @@ public:      inline void clamp();  }; +static_assert(std::is_trivially_copyable<LLColor4>::value, "LLColor4 must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLColor4>::value, "LLColor4 must be trivial move"); +static_assert(std::is_standard_layout<LLColor4>::value, "LLColor4 must be a standard layout type"); +  // Non-member functions  F32      distVec(const LLColor4& a, const LLColor4& b);         // Returns distance between a and b  F32      distVec_squared(const LLColor4& a, const LLColor4& b); // Returns distance squared between a and b diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h index bfa998bc58..e495fd3eea 100644 --- a/indra/llmath/v4coloru.h +++ b/indra/llmath/v4coloru.h @@ -123,6 +123,10 @@ public:      static LLColor4U blue;  }; +static_assert(std::is_trivially_copyable<LLColor4U>::value, "LLColor4U must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLColor4U>::value, "LLColor4U must be trivial move"); +static_assert(std::is_standard_layout<LLColor4U>::value, "LLColor4U must be a standard layout type"); +  // Non-member functions  F32 distVec(const LLColor4U& a, const LLColor4U& b);         // Returns distance between a and b  F32 distVec_squared(const LLColor4U& a, const LLColor4U& b); // Returns distance squared between a and b diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h index 1cbd0d9a78..edfc2f8592 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -146,6 +146,10 @@ public:      friend LLVector4 operator-(const LLVector4 &a);                 // Return vector -a  }; +static_assert(std::is_trivially_copyable<LLVector4>::value, "LLVector4 must be trivial copy"); +static_assert(std::is_trivially_move_assignable<LLVector4>::value, "LLVector4 must be trivial move"); +static_assert(std::is_standard_layout<LLVector4>::value, "LLVector4 must be a standard layout type"); +  // Non-member functions  F32 angle_between(const LLVector4 &a, const LLVector4 &b);      // Returns angle (radians) between a and b  bool are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon = F_APPROXIMATELY_ZERO);      // Returns true if a and b are very close to parallel diff --git a/indra/llmessage/llxfermanager.cpp b/indra/llmessage/llxfermanager.cpp index f6ed43a4e4..a2d09f4f36 100644 --- a/indra/llmessage/llxfermanager.cpp +++ b/indra/llmessage/llxfermanager.cpp @@ -1051,7 +1051,7 @@ void LLXferManager::retransmitUnackedPackets()      // Re-build mOutgoingHosts data      updateHostStatus(); -    F32 et; +    F32 et = 0.f;      iter = mSendList.begin();      while (iter != mSendList.end())      { diff --git a/indra/llplugin/CMakeLists.txt b/indra/llplugin/CMakeLists.txt index 7fa5c957b6..0525e3d9ea 100644 --- a/indra/llplugin/CMakeLists.txt +++ b/indra/llplugin/CMakeLists.txt @@ -35,7 +35,7 @@ list(APPEND llplugin_SOURCE_FILES ${llplugin_HEADER_FILES})  add_library (llplugin ${llplugin_SOURCE_FILES})  target_include_directories( llplugin  INTERFACE   ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries( llplugin llcommon llmath llrender llmessage ) +target_link_libraries( llplugin llcommon llmath llmessage llxml )  add_subdirectory(slplugin)  include(LibraryInstall) diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index 5eb22332d4..53a338b3d6 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -132,9 +132,13 @@ void LLPluginClassMedia::reset()      mLastMouseY = 0;      mStatus = LLPluginClassMediaOwner::MEDIA_NONE;      mSleepTime = 1.0f / 100.0f; +    mCanUndo = false; +    mCanRedo = false;      mCanCut = false;      mCanCopy = false;      mCanPaste = false; +    mCanDoDelete = false; +    mCanSelectAll = false;      mMediaName.clear();      mMediaDescription.clear();      mBackgroundColor = LLColor4(1.0f, 1.0f, 1.0f, 1.0f); @@ -907,6 +911,18 @@ void LLPluginClassMedia::sendAuthResponse(bool ok, const std::string &username,      sendMessage(message);  } +void LLPluginClassMedia::undo() +{ +    LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_undo"); +    sendMessage(message); +} + +void LLPluginClassMedia::redo() +{ +    LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_redo"); +    sendMessage(message); +} +  void LLPluginClassMedia::cut()  {      LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_cut"); @@ -925,6 +941,24 @@ void LLPluginClassMedia::paste()      sendMessage(message);  } +void LLPluginClassMedia::doDelete() +{ +    LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_delete"); +    sendMessage(message); +} + +void LLPluginClassMedia::selectAll() +{ +    LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_select_all"); +    sendMessage(message); +} + +void LLPluginClassMedia::showPageSource() +{ +    LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_show_source"); +    sendMessage(message); +} +  void LLPluginClassMedia::setUserDataPath(const std::string &user_data_path_cache,                                           const std::string &username,                                           const std::string &user_data_path_cef_log) @@ -1187,6 +1221,14 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)          }          else if(message_name == "edit_state")          { +            if(message.hasValue("undo")) +            { +                mCanUndo = message.getValueBoolean("undo"); +            } +            if(message.hasValue("redo")) +            { +                mCanRedo = message.getValueBoolean("redo"); +            }              if(message.hasValue("cut"))              {                  mCanCut = message.getValueBoolean("cut"); @@ -1199,6 +1241,14 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)              {                  mCanPaste = message.getValueBoolean("paste");              } +            if (message.hasValue("delete")) +            { +                mCanDoDelete = message.getValueBoolean("delete"); +            } +            if (message.hasValue("select_all")) +            { +                mCanSelectAll = message.getValueBoolean("select_all"); +            }          }          else if(message_name == "name_text")          { diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index 80862284ff..6c512003cc 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -29,7 +29,6 @@  #ifndef LL_LLPLUGINCLASSMEDIA_H  #define LL_LLPLUGINCLASSMEDIA_H -#include "llgltypes.h"  #include "llpluginprocessparent.h"  #include "llrect.h"  #include "llpluginclassmediaowner.h" @@ -205,6 +204,12 @@ public:      LLPluginClassMediaOwner::EMediaStatus getStatus() const { return mStatus; } +    void    undo(); +    bool    canUndo() const { return mCanUndo; }; + +    void    redo(); +    bool    canRedo() const { return mCanRedo; }; +      void    cut();      bool    canCut() const { return mCanCut; }; @@ -214,6 +219,14 @@ public:      void    paste();      bool    canPaste() const { return mCanPaste; }; +    void    doDelete(); +    bool    canDoDelete() const { return mCanDoDelete; }; + +    void    selectAll(); +    bool    canSelectAll() const { return mCanSelectAll; }; + +    void    showPageSource(); +      // These can be called before init(), and they will be queued and sent before the media init message.      void    setUserDataPath(const std::string &user_data_path_cache, const std::string &username, const std::string &user_data_path_cef_log);      void    setLanguageCode(const std::string &language_code); @@ -357,9 +370,9 @@ protected:      bool        mTextureParamsReceived;     // the mRequestedTexture* fields are only valid when this is true      S32         mRequestedTextureDepth; -    LLGLenum    mRequestedTextureInternalFormat; -    LLGLenum    mRequestedTextureFormat; -    LLGLenum    mRequestedTextureType; +    U32         mRequestedTextureInternalFormat; +    U32         mRequestedTextureFormat; +    U32         mRequestedTextureType;      bool        mRequestedTextureSwapBytes;      bool        mRequestedTextureCoordsOpenGL; @@ -425,9 +438,13 @@ protected:      F64             mSleepTime; +    bool            mCanUndo; +    bool            mCanRedo;      bool            mCanCut;      bool            mCanCopy;      bool            mCanPaste; +    bool            mCanDoDelete; +    bool            mCanSelectAll;      std::string     mMediaName;      std::string     mMediaTitle; diff --git a/indra/llplugin/slplugin/CMakeLists.txt b/indra/llplugin/slplugin/CMakeLists.txt index 2100e6f556..38f4c92b09 100644 --- a/indra/llplugin/slplugin/CMakeLists.txt +++ b/indra/llplugin/slplugin/CMakeLists.txt @@ -30,18 +30,6 @@ add_executable(SLPlugin      ${SLPlugin_SOURCE_FILES}      ) -if (WINDOWS) -set_target_properties(SLPlugin -  PROPERTIES -  LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMTD\"" -  ) -else () -set_target_properties(SLPlugin -  PROPERTIES -  MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/slplugin_info.plist -  ) -endif () -  target_link_libraries(SLPlugin          llplugin          llmessage @@ -49,7 +37,20 @@ target_link_libraries(SLPlugin          ll::pluginlibraries          ) -if (DARWIN) +if (WINDOWS) +  set_target_properties(SLPlugin +    PROPERTIES +    LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMTD\"" +    ) +elseif (DARWIN) +  set_target_properties(SLPlugin +    PROPERTIES +    BUILD_WITH_INSTALL_RPATH 1 +    INSTALL_RPATH "@executable_path/../../../../Frameworks;@executable_path/../Frameworks;@executable_path/../Frameworks/plugins" +    MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/slplugin_info.plist +    XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym" +  ) +    # Make sure the app bundle has a Resources directory (it will get populated by viewer-manifest.py later)    add_custom_command(      TARGET SLPlugin POST_BUILD @@ -58,7 +59,7 @@ if (DARWIN)        -p        ${CMAKE_CURRENT_BINARY_DIR}/$<IF:$<BOOL:${LL_GENERATOR_IS_MULTI_CONFIG}>,$<CONFIG>,>/SLPlugin.app/Contents/Frameworks    ) -endif (DARWIN) +endif ()  if (BUILD_SHARED_LIBS)    set_target_properties(SLPlugin PROPERTIES LINK_FLAGS_RELEASE diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index bfcd84a43d..81ebe631c5 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -1319,7 +1319,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do                      {                          //Build a joint for the resolver to work with                          char str[64]={0}; -                        sprintf(str,"./%s",(*jointIt).first.c_str() ); +                        snprintf(str, sizeof(str), "./%s",(*jointIt).first.c_str() );                          //LL_WARNS()<<"Joint "<< str <<LL_ENDL;                          //Setup the resolver diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index e93c98970b..9d6773ac5b 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -58,9 +58,9 @@  FT_Render_Mode gFontRenderMode = FT_RENDER_MODE_NORMAL; -LLFontManager *gFontManagerp = NULL; +LLFontManager *gFontManagerp = nullptr; -FT_Library gFTLibrary = NULL; +FT_Library gFTLibrary = nullptr;  //static  void LLFontManager::initClass() @@ -75,7 +75,7 @@ void LLFontManager::initClass()  void LLFontManager::cleanupClass()  {      delete gFontManagerp; -    gFontManagerp = NULL; +    gFontManagerp = nullptr;  }  LLFontManager::LLFontManager() @@ -103,6 +103,7 @@ LLFontManager::LLFontManager()  LLFontManager::~LLFontManager()  {      FT_Done_FreeType(gFTLibrary); +    unloadAllFonts();  } @@ -141,12 +142,8 @@ LLFontFreetype::LLFontFreetype()      mAscender(0.f),      mDescender(0.f),      mLineHeight(0.f), -#ifdef LL_WINDOWS -    pFileStream(NULL), -    pFtStream(NULL), -#endif      mIsFallback(false), -    mFTFace(NULL), +    mFTFace(nullptr),      mRenderGlyphCount(0),      mStyle(0),      mPointSize(0) @@ -159,35 +156,16 @@ LLFontFreetype::~LLFontFreetype()      // Clean up freetype libs.      if (mFTFace)          FT_Done_Face(mFTFace); -    mFTFace = NULL; +    mFTFace = nullptr;      // Delete glyph info      std::for_each(mCharGlyphInfoMap.begin(), mCharGlyphInfoMap.end(), DeletePairedPointer());      mCharGlyphInfoMap.clear(); -#ifdef LL_WINDOWS -    delete pFileStream; // closed by FT_Done_Face -    delete pFtStream; -#endif      delete mFontBitmapCachep;      // mFallbackFonts cleaned up by LLPointer destructor  } -#ifdef LL_WINDOWS -unsigned long ft_read_cb(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) { -    if (count <= 0) return count; -    llifstream *file_stream = static_cast<llifstream *>(stream->descriptor.pointer); -    file_stream->seekg(offset, std::ios::beg); -    file_stream->read((char*)buffer, count); -    return (unsigned long)file_stream->gcount(); -} - -void ft_close_cb(FT_Stream stream) { -    llifstream *file_stream = static_cast<llifstream *>(stream->descriptor.pointer); -    file_stream->close(); -} -#endif -  bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 vert_dpi, F32 horz_dpi, bool is_fallback, S32 face_n)  {      // Don't leak face objects.  This is also needed to deal with @@ -195,26 +173,21 @@ bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v      if (mFTFace)      {          FT_Done_Face(mFTFace); -        mFTFace = NULL; +        mFTFace = nullptr;      } -    int error; -#ifdef LL_WINDOWS -    error = ftOpenFace(filename, face_n); -#else -    error = FT_New_Face( gFTLibrary, -                         filename.c_str(), -                         0, -                         &mFTFace); -#endif +    FT_Open_Args openArgs; +    memset( &openArgs, 0, sizeof( openArgs ) ); +    openArgs.memory_base = gFontManagerp->loadFont( filename, openArgs.memory_size ); + +    if( !openArgs.memory_base ) +        return false; + +    openArgs.flags = FT_OPEN_MEMORY; +    int error = FT_Open_Face( gFTLibrary, &openArgs, 0, &mFTFace );      if (error) -    { -#ifdef LL_WINDOWS -        clearFontStreams(); -#endif          return false; -    }      mIsFallback = is_fallback;      F32 pixels_per_em = (point_size / 72.f)*vert_dpi; // Size in inches * dpi @@ -229,10 +202,8 @@ bool LLFontFreetype::loadFace(const std::string& filename, F32 point_size, F32 v      {          // Clean up freetype libs.          FT_Done_Face(mFTFace); -#ifdef LL_WINDOWS -        clearFontStreams(); -#endif -        mFTFace = NULL; + +        mFTFace = nullptr;          return false;      } @@ -288,73 +259,30 @@ S32 LLFontFreetype::getNumFaces(const std::string& filename)      if (mFTFace)      {          FT_Done_Face(mFTFace); -        mFTFace = NULL; +        mFTFace = nullptr;      }      S32 num_faces = 1; -#ifdef LL_WINDOWS -    int error = ftOpenFace(filename, 0); +    FT_Open_Args openArgs; +    memset( &openArgs, 0, sizeof( openArgs ) ); +    openArgs.memory_base = gFontManagerp->loadFont( filename, openArgs.memory_size ); +    if( !openArgs.memory_base ) +        return 0; +    openArgs.flags = FT_OPEN_MEMORY; +    int error = FT_Open_Face( gFTLibrary, &openArgs, 0, &mFTFace );      if (error) -    {          return 0; -    }      else -    {          num_faces = mFTFace->num_faces; -    }      FT_Done_Face(mFTFace); -    clearFontStreams(); -    mFTFace = NULL; -#endif +    mFTFace = nullptr;      return num_faces;  } -#ifdef LL_WINDOWS -S32 LLFontFreetype::ftOpenFace(const std::string& filename, S32 face_n) -{ -    S32 error = -1; -    pFileStream = new llifstream(filename, std::ios::binary); -    if (pFileStream->is_open()) -    { -        std::streampos beg = pFileStream->tellg(); -        pFileStream->seekg(0, std::ios::end); -        std::streampos end = pFileStream->tellg(); -        std::size_t file_size = end - beg; -        pFileStream->seekg(0, std::ios::beg); - -        pFtStream = new LLFT_Stream(); -        pFtStream->base = 0; -        pFtStream->pos = 0; -        pFtStream->size = static_cast<unsigned long>(file_size); -        pFtStream->descriptor.pointer = pFileStream; -        pFtStream->read = ft_read_cb; -        pFtStream->close = ft_close_cb; - -        FT_Open_Args args; -        args.flags = FT_OPEN_STREAM; -        args.stream = (FT_StreamRec*)pFtStream; -        error = FT_Open_Face(gFTLibrary, &args, face_n, &mFTFace); -    } -    return error; -} - -void LLFontFreetype::clearFontStreams() -{ -    if (pFileStream) -    { -        pFileStream->close(); -    } -    delete pFileStream; -    delete pFtStream; -    pFileStream = NULL; -    pFtStream = NULL; -} -#endif -  void LLFontFreetype::addFallbackFont(const LLPointer<LLFontFreetype>& fallback_font,                                       const char_functor_t& functor)  { @@ -378,7 +306,7 @@ F32 LLFontFreetype::getDescenderHeight() const  F32 LLFontFreetype::getXAdvance(llwchar wch) const  { -    if (mFTFace == NULL) +    if (mFTFace == nullptr)          return 0.0;      // Return existing info only if it is current @@ -402,7 +330,7 @@ F32 LLFontFreetype::getXAdvance(llwchar wch) const  F32 LLFontFreetype::getXAdvance(const LLFontGlyphInfo* glyph) const  { -    if (mFTFace == NULL) +    if (mFTFace == nullptr)          return 0.0;      return glyph->mXAdvance; @@ -410,7 +338,7 @@ F32 LLFontFreetype::getXAdvance(const LLFontGlyphInfo* glyph) const  F32 LLFontFreetype::getXKerning(llwchar char_left, llwchar char_right) const  { -    if (mFTFace == NULL) +    if (mFTFace == nullptr)          return 0.0;      //llassert(!mIsFallback); @@ -429,7 +357,7 @@ F32 LLFontFreetype::getXKerning(llwchar char_left, llwchar char_right) const  F32 LLFontFreetype::getXKerning(const LLFontGlyphInfo* left_glyph_info, const LLFontGlyphInfo* right_glyph_info) const  { -    if (mFTFace == NULL) +    if (mFTFace == nullptr)          return 0.0;      U32 left_glyph = left_glyph_info ? left_glyph_info->mGlyphIndex : 0; @@ -452,7 +380,7 @@ LLFontGlyphInfo* LLFontFreetype::addGlyph(llwchar wch, EFontGlyphType glyph_type  {      if (!mFTFace)      { -        return NULL; +        return nullptr;      }      llassert(!mIsFallback); @@ -543,14 +471,14 @@ LLFontGlyphInfo* LLFontFreetype::addGlyph(llwchar wch, EFontGlyphType glyph_type      {          return addGlyphFromFont(this, wch, glyph_index, glyph_type);      } -    return NULL; +    return nullptr;  }  LLFontGlyphInfo* LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, llwchar wch, U32 glyph_index, EFontGlyphType requested_glyph_type) const  {      LL_PROFILE_ZONE_SCOPED; -    if (mFTFace == NULL) -        return NULL; +    if (mFTFace == nullptr) +        return nullptr;      llassert(!mIsFallback);      fontp->renderGlyph(requested_glyph_type, glyph_index, wch); @@ -602,7 +530,7 @@ LLFontGlyphInfo* LLFontFreetype::addGlyphFromFont(const LLFontFreetype *fontp, l      {          U8 *buffer_data = fontp->mFTFace->glyph->bitmap.buffer;          S32 buffer_row_stride = fontp->mFTFace->glyph->bitmap.pitch; -        U8 *tmp_graydata = NULL; +        U8 *tmp_graydata = nullptr;          if (fontp->mFTFace->glyph->bitmap.pixel_mode              == FT_PIXEL_MODE_MONO) @@ -706,7 +634,7 @@ void LLFontFreetype::insertGlyphInfo(llwchar wch, LLFontGlyphInfo* gi) const  void LLFontFreetype::renderGlyph(EFontGlyphType bitmap_type, U32 glyph_index, llwchar wch) const  { -    if (mFTFace == NULL) +    if (mFTFace == nullptr)          return;      FT_Int32 load_flags = FT_LOAD_FORCE_AUTOHINT; @@ -920,3 +848,58 @@ void LLFontFreetype::setSubImageLuminanceAlpha(U32 x, U32 y, U32 bitmap_num, U32      }  } + +namespace ll +{ +    namespace fonts +    { +        class LoadedFont +        { +            public: +            LoadedFont( std::string aName , std::string const &aAddress, std::size_t aSize ) +            : mAddress( aAddress ) +            { +                mName = aName; +                mSize = aSize; +                mRefs = 1; +            } +            std::string mName; +            std::string mAddress; +            std::size_t mSize; +            U32  mRefs; +        }; +    } +} + +U8 const* LLFontManager::loadFont( std::string const &aFilename, long &a_Size) +{ +    a_Size = 0; +    std::map< std::string, std::shared_ptr<ll::fonts::LoadedFont> >::iterator itr = m_LoadedFonts.find( aFilename ); +    if( itr != m_LoadedFonts.end() ) +    { +        ++itr->second->mRefs; +        // A possible overflow cannot happen here, as it is asserted that the size is less than std::numeric_limits<long>::max() a few lines below. +        a_Size = static_cast<long>(itr->second->mSize); +        return reinterpret_cast<U8 const*>(itr->second->mAddress.c_str()); +    } + +    auto strContent = LLFile::getContents(aFilename); + +    if( strContent.empty() ) +        return nullptr; + +    // For fontconfig a type of long is required, std::string::size() returns size_t. I think it is safe to limit this to 2GiB and not support fonts that huge (can that even be a thing?) +    llassert_always( strContent.size() < std::numeric_limits<long>::max() ); + +    a_Size = static_cast<long>(strContent.size()); + +    auto pCache = std::make_shared<ll::fonts::LoadedFont>( aFilename,  strContent, a_Size ); +    itr = m_LoadedFonts.insert( std::make_pair( aFilename, pCache ) ).first; + +    return reinterpret_cast<U8 const*>(itr->second->mAddress.c_str()); +} + +void LLFontManager::unloadAllFonts() +{ +    m_LoadedFonts.clear(); +} diff --git a/indra/llrender/llfontfreetype.h b/indra/llrender/llfontfreetype.h index 783bf4a4b3..a9b3a944ee 100644 --- a/indra/llrender/llfontfreetype.h +++ b/indra/llrender/llfontfreetype.h @@ -43,15 +43,28 @@ typedef struct FT_FaceRec_* LLFT_Face;  struct FT_StreamRec_;  typedef struct FT_StreamRec_ LLFT_Stream; +namespace ll +{ +    namespace fonts +    { +        class LoadedFont; +    } +} +  class LLFontManager  {  public:      static void initClass();      static void cleanupClass(); +    U8 const *loadFont( std::string const &aFilename, long &a_Size ); +  private:      LLFontManager();      ~LLFontManager(); + +    void unloadAllFonts(); +    std::map< std::string, std::shared_ptr<ll::fonts::LoadedFont> > m_LoadedFonts;  };  struct LLFontGlyphInfo @@ -90,11 +103,6 @@ public:      S32 getNumFaces(const std::string& filename); -#ifdef LL_WINDOWS -    S32 ftOpenFace(const std::string& filename, S32 face_n); -    void clearFontStreams(); -#endif -      typedef std::function<bool(llwchar)> char_functor_t;      void addFallbackFont(const LLPointer<LLFontFreetype>& fallback_font, const char_functor_t& functor = nullptr); @@ -170,11 +178,6 @@ private:      LLFT_Face mFTFace; -#ifdef LL_WINDOWS -    llifstream *pFileStream; -    LLFT_Stream *pFtStream; -#endif -      bool mIsFallback;      typedef std::pair<LLPointer<LLFontFreetype>, char_functor_t> fallback_font_t;      typedef std::vector<fallback_font_t> fallback_font_vector_t; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index cc619e2086..b002d183ef 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -1123,17 +1123,6 @@ bool LLGLManager::initGL()      if (mGLVersion >= 2.f)      {          parse_glsl_version(mGLSLVersionMajor, mGLSLVersionMinor); - -#if 0 && LL_DARWIN -        // TODO maybe switch to using a core profile for GL 3.2? -        // https://stackoverflow.com/a/19868861 -        //never use GLSL greater than 1.20 on OSX -        if (mGLSLVersionMajor > 1 || mGLSLVersionMinor > 30) -        { -            mGLSLVersionMajor = 1; -            mGLSLVersionMinor = 30; -        } -#endif      }  #if GL_VERSION_1_3 @@ -2748,7 +2737,7 @@ void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d)      if(cplane[2] < 0)          cplane *= -1; -    glm::mat4 suffix; +    glm::mat4 suffix = glm::identity<glm::mat4>();      suffix = glm::row(suffix, 2, cplane);      glm::mat4 newP = suffix * P;      gGL.matrixMode(LLRender::MM_PROJECTION); diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index a1392e6288..5a0281eeb5 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -450,8 +450,11 @@ bool LLGLSLShader::createShader()      llassert_always(!mShaderFiles.empty());  #if LL_DARWIN -    // work-around missing mix(vec3,vec3,bvec3) -    mDefines["OLD_SELECT"] = "1"; +    if(!gGLManager.mIsApple) +    { +        // work-around missing mix(vec3,vec3,bvec3) +        mDefines["OLD_SELECT"] = "1"; +    }  #endif      mShaderHash = hash(); @@ -572,7 +575,7 @@ bool LLGLSLShader::createShader()          }      } -#ifdef LL_PROFILER_ENABLE_RENDER_DOC +#if LL_PROFILER_ENABLE_RENDER_DOC      setLabel(mName.c_str());  #endif @@ -2116,7 +2119,7 @@ LLUUID LLGLSLShader::hash()      return hash_obj.digest();  } -#ifdef LL_PROFILER_ENABLE_RENDER_DOC +#if LL_PROFILER_ENABLE_RENDER_DOC  void LLGLSLShader::setLabel(const char* label) {      LL_LABEL_OBJECT_GL(GL_PROGRAM, mProgramObject, strlen(label), label);  } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 873ab0cff5..4702a27cc5 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -361,7 +361,7 @@ public:      // hacky flag used for optimization in LLDrawPoolAlpha      bool mCanBindFast = false; -#ifdef LL_PROFILER_ENABLE_RENDER_DOC +#if LL_PROFILER_ENABLE_RENDER_DOC      void setLabel(const char* label);  #endif @@ -381,7 +381,7 @@ extern LLGLSLShader         gSolidColorProgram;  //Alpha mask shader (declared here so llappearance can access properly)  extern LLGLSLShader         gAlphaMaskProgram; -#ifdef LL_PROFILER_ENABLE_RENDER_DOC +#if LL_PROFILER_ENABLE_RENDER_DOC  #define LL_SET_SHADER_LABEL(shader) shader.setLabel(#shader)  #else  #define LL_SET_SHADER_LABEL(shader, label) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 332d15f76c..8ba8ab21f4 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -124,7 +124,7 @@ static const GLenum sGLBlendFactor[] =  LLTexUnit::LLTexUnit(S32 index)      : mCurrTexType(TT_NONE), -    mCurrColorScale(1), mCurrAlphaScale(1), mCurrTexture(0), +    mCurrTexture(0),      mHasMipMaps(false),      mIndex(index)  { @@ -214,6 +214,14 @@ void LLTexUnit::bindFast(LLTexture* texture)      }      glBindTexture(sGLTextureType[gl_tex->getTarget()], mCurrTexture);      mHasMipMaps = gl_tex->mHasMipMaps; +/* +    if (gl_tex->mTexOptionsDirty) +    { +        gl_tex->mTexOptionsDirty = false; +        setTextureAddressModeFast(gl_tex->mAddressMode); +        setTextureFilteringOptionFast(gl_tex->mFilterOption); +    } +*/  }  bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind) @@ -468,11 +476,18 @@ void LLTexUnit::setTextureAddressMode(eTextureAddressMode mode)      activate(); -    glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); -    glTexParameteri (sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]); +/* +    setTextureAddressModeFast(mode); +} + +void LLTexUnit::setTextureAddressModeFast(eTextureAddressMode mode) +{ +*/ +    glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_S, sGLAddressMode[mode]); +    glTexParameteri(sGLTextureType[mCurrTexType], GL_TEXTURE_WRAP_T, sGLAddressMode[mode]);      if (mCurrTexType == TT_CUBE_MAP)      { -        glTexParameteri (GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]); +        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, sGLAddressMode[mode]);      }  } @@ -490,6 +505,13 @@ void LLTexUnit::setTextureFilteringOption(LLTexUnit::eTextureFilterOptions optio      gGL.flush(); +/* +    setTextureFilteringOptionFast(option); +} + +void LLTexUnit::setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions option) +{ +*/      if (option == TFO_POINT)      {          glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -621,30 +643,6 @@ GLint LLTexUnit::getTextureSourceType(eTextureBlendSrc src, bool isAlpha)      }  } -void LLTexUnit::setColorScale(S32 scale) -{ -    if (mCurrColorScale != scale || gGL.mDirty) -    { -        mCurrColorScale = scale; -        gGL.flush(); -#if GL_VERSION_1_1 -        glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE, scale ); -#endif -    } -} - -void LLTexUnit::setAlphaScale(S32 scale) -{ -    if (mCurrAlphaScale != scale || gGL.mDirty) -    { -        mCurrAlphaScale = scale; -        gGL.flush(); -#if GL_VERSION_1_1 -        glTexEnvi( GL_TEXTURE_ENV, GL_ALPHA_SCALE, scale ); -#endif -    } -} -  // Useful for debugging that you've manually assigned a texture operation to the correct  // texture unit based on the currently set active texture in opengl.  void LLTexUnit::debugTextureUnit(void) @@ -1308,9 +1306,7 @@ void LLRender::translateUI(F32 x, F32 y, F32 z)          LL_ERRS() << "Need to push a UI translation frame before offsetting" << LL_ENDL;      } -    mUIOffset.back().mV[0] += x; -    mUIOffset.back().mV[1] += y; -    mUIOffset.back().mV[2] += z; +    mUIOffset.back().add(LLVector4a(x, y, z));  }  void LLRender::scaleUI(F32 x, F32 y, F32 z) @@ -1320,14 +1316,14 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z)          LL_ERRS() << "Need to push a UI transformation frame before scaling." << LL_ENDL;      } -    mUIScale.back().scaleVec(LLVector3(x,y,z)); +    mUIScale.back().mul(LLVector4a(x, y, z));  }  void LLRender::pushUIMatrix()  {      if (mUIOffset.empty())      { -        mUIOffset.emplace_back(0.f,0.f,0.f); +        mUIOffset.emplace_back(0.f);      }      else      { @@ -1336,7 +1332,7 @@ void LLRender::pushUIMatrix()      if (mUIScale.empty())      { -        mUIScale.emplace_back(1.f,1.f,1.f); +        mUIScale.emplace_back(1.f);      }      else      { @@ -1358,18 +1354,20 @@ LLVector3 LLRender::getUITranslation()  {      if (mUIOffset.empty())      { -        return LLVector3(0,0,0); +        return LLVector3::zero;      } -    return mUIOffset.back(); + +    return LLVector3(mUIOffset.back().getF32ptr());  }  LLVector3 LLRender::getUIScale()  {      if (mUIScale.empty())      { -        return LLVector3(1,1,1); +        return LLVector3::all_one;      } -    return mUIScale.back(); + +    return LLVector3(mUIScale.back().getF32ptr());  } @@ -1379,8 +1377,9 @@ void LLRender::loadUIIdentity()      {          LL_ERRS() << "Need to push UI translation frame before clearing offset." << LL_ENDL;      } -    mUIOffset.back().setVec(0,0,0); -    mUIScale.back().setVec(1,1,1); + +    mUIOffset.back().clear(); +    mUIScale.back().splat(1);  }  void LLRender::setColorMask(bool writeColor, bool writeAlpha) @@ -1816,8 +1815,10 @@ void LLRender::vertex3f(const GLfloat& x, const GLfloat& y, const GLfloat& z)      }      else      { -        LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back()); -        mVerticesp[mCount].set(vert.mV[VX], vert.mV[VY], vert.mV[VZ]); +        LLVector4a vert(x, y, z); +        vert.add(mUIOffset.back()); +        vert.mul(mUIScale.back()); +        mVerticesp[mCount] = vert;      }      mCount++; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index a755ddd2b1..15a6249c5a 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -44,6 +44,7 @@  #include "llglheaders.h"  #include "llmatrix4a.h"  #include "glm/mat4x4.hpp" +#include <boost/align/aligned_allocator.hpp>  #include <array>  #include <list> @@ -214,11 +215,19 @@ public:      // Warning: this stays set for the bound texture forever,      // make sure you want to permanently change the address mode  for the bound texture.      void setTextureAddressMode(eTextureAddressMode mode); +/* +    // MUST already be active and bound +    void setTextureAddressModeFast(eTextureAddressMode mode); +*/      // Sets the filtering options used to sample the texture      // Warning: this stays set for the bound texture forever,      // make sure you want to permanently change the filtering for the bound texture.      void setTextureFilteringOption(LLTexUnit::eTextureFilterOptions option); +/* +    // MUST already be active and bound +    void setTextureFilteringOptionFast(LLTexUnit::eTextureFilterOptions option); +*/      static U32 getInternalType(eTextureType type); @@ -234,13 +243,9 @@ protected:      S32                 mIndex;      U32                 mCurrTexture;      eTextureType        mCurrTexType; -    S32                 mCurrColorScale; -    S32                 mCurrAlphaScale;      bool                mHasMipMaps;      void debugTextureUnit(void); -    void setColorScale(S32 scale); -    void setAlphaScale(S32 scale);      GLint getTextureSource(eTextureBlendSrc src);      GLint getTextureSourceType(eTextureBlendSrc src, bool isAlpha = false);  }; @@ -534,8 +539,8 @@ private:      eBlendFactor mCurrBlendAlphaSFactor;      eBlendFactor mCurrBlendAlphaDFactor; -    std::vector<LLVector3> mUIOffset; -    std::vector<LLVector3> mUIScale; +    std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 16> > mUIOffset; +    std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 16> > mUIScale;  };  extern F32 gGLModelView[16]; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 7bd8abc592..9b55998886 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -458,7 +458,7 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev  // endsure work-around for missing GLSL funcs gets propogated to feature shader files (e.g. srgbF.glsl)  #if LL_DARWIN -    if (defines) +    if (!gGLManager.mIsApple && defines)      {          (*defines)["OLD_SELECT"] = "1";      } diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 1bd7a57cd9..4b62c3476f 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -794,12 +794,6 @@ void LLVertexBuffer::drawElements(U32 mode, const LLVector4a* pos, const LLVecto      gGL.syncMatrices(); -    U32 mask = LLVertexBuffer::MAP_VERTEX; -    if (tc) -    { -        mask = mask | LLVertexBuffer::MAP_TEXCOORD0; -    } -      unbind();      gGL.begin(mode); @@ -892,7 +886,7 @@ bool LLVertexBuffer::validateRange(U32 start, U32 end, U32 count, U32 indices_of      return true;  } -#ifdef LL_PROFILER_ENABLE_RENDER_DOC +#if LL_PROFILER_ENABLE_RENDER_DOC  void LLVertexBuffer::setLabel(const char* label) {      LL_LABEL_OBJECT_GL(GL_BUFFER, mGLBuffer, strlen(label), label);  } diff --git a/indra/llrender/llvertexbuffer.h b/indra/llrender/llvertexbuffer.h index bf5f2b5ab6..b0f6ae7d8d 100644 --- a/indra/llrender/llvertexbuffer.h +++ b/indra/llrender/llvertexbuffer.h @@ -281,7 +281,7 @@ public:      //for debugging, validate data in given range is valid      bool validateRange(U32 start, U32 end, U32 count, U32 offset) const; -    #ifdef LL_PROFILER_ENABLE_RENDER_DOC +    #if LL_PROFILER_ENABLE_RENDER_DOC      void setLabel(const char* label);      #endif @@ -342,7 +342,7 @@ public:      static U32 sVertexCount;  }; -#ifdef LL_PROFILER_ENABLE_RENDER_DOC +#if LL_PROFILER_ENABLE_RENDER_DOC  #define LL_LABEL_VERTEX_BUFFER(buf, name) buf->setLabel(name)  #else  #define LL_LABEL_VERTEX_BUFFER(buf, name) diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index e7dea79eaa..179d1dcaff 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -213,13 +213,8 @@ void LLUI::setPopupFuncs(const add_popup_t& add_popup, const remove_popup_t& rem  void LLUI::setMousePositionScreen(S32 x, S32 y)  { -#if defined(LL_DARWIN) -    S32 screen_x = ll_round(((F32)x * getScaleFactor().mV[VX]) / LLView::getWindow()->getSystemUISize()); -    S32 screen_y = ll_round(((F32)y * getScaleFactor().mV[VY]) / LLView::getWindow()->getSystemUISize()); -#else      S32 screen_x = ll_round((F32)x * getScaleFactor().mV[VX]);      S32 screen_y = ll_round((F32)y * getScaleFactor().mV[VY]); -#endif      LLView::getWindow()->setCursorPosition(LLCoordGL(screen_x, screen_y).convert());  } diff --git a/indra/llwebrtc/CMakeLists.txt b/indra/llwebrtc/CMakeLists.txt index a64a3e4dac..a01d9fc632 100644 --- a/indra/llwebrtc/CMakeLists.txt +++ b/indra/llwebrtc/CMakeLists.txt @@ -10,10 +10,6 @@ include(WebRTC)  project(llwebrtc) -if (LINUX) -    add_compile_options(-Wno-deprecated-declarations) # webrtc::CreateAudioDeviceWithDataObserver is deprecated -endif (LINUX) -  set(llwebrtc_SOURCE_FILES      llwebrtc.cpp      ) @@ -46,7 +42,7 @@ if (WINDOWS)                                         iphlpapi                                         libcmt)      # as the webrtc libraries are release, build this binary as release as well. -    target_compile_options(llwebrtc PRIVATE "/MT") +    target_compile_options(llwebrtc PRIVATE "/MT" "/Zc:wchar_t")      if (USE_BUGSPLAT)          set_target_properties(llwebrtc PROPERTIES PDB_OUTPUT_DIRECTORY "${SYMBOLS_STAGING_DIR}")      endif (USE_BUGSPLAT) @@ -65,6 +61,8 @@ target_include_directories( llwebrtc INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})  if (WINDOWS)      set_property(TARGET llwebrtc PROPERTY          MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") +else() +    target_compile_options(llwebrtc PRIVATE -Wno-deprecated-declarations) # webrtc::CreateAudioDeviceWithDataObserver is deprecated  endif (WINDOWS)  ADD_CUSTOM_COMMAND(TARGET llwebrtc POST_BUILD diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index 12d02bbcc1..edba2bee9a 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -9,7 +9,7 @@   * This library is free software; you can redistribute it and/or   * modify it under the terms of the GNU Lesser General Public   * License as published by the Free Software Foundation; - * version 2.1 of the License only. + * version 2.1 of the License only   *   * This library is distributed in the hope that it will be useful,   * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -32,41 +32,79 @@  #include "api/audio_codecs/audio_encoder_factory.h"  #include "api/audio_codecs/builtin_audio_decoder_factory.h"  #include "api/audio_codecs/builtin_audio_encoder_factory.h" +#include "api/audio/builtin_audio_processing_builder.h"  #include "api/media_stream_interface.h"  #include "api/media_stream_track.h"  #include "modules/audio_processing/audio_buffer.h"  #include "modules/audio_mixer/audio_mixer_impl.h" +#include "api/environment/environment_factory.h"  namespace llwebrtc  { +#if WEBRTC_WIN +static int16_t PLAYOUT_DEVICE_DEFAULT = webrtc::AudioDeviceModule::kDefaultDevice; +static int16_t RECORD_DEVICE_DEFAULT  = webrtc::AudioDeviceModule::kDefaultDevice; +#else +static int16_t PLAYOUT_DEVICE_DEFAULT = 0; +static int16_t RECORD_DEVICE_DEFAULT  = 0; +#endif -static int16_t PLAYOUT_DEVICE_DEFAULT = -1; -static int16_t PLAYOUT_DEVICE_BAD     = -2; -static int16_t RECORD_DEVICE_DEFAULT  = -1; -static int16_t RECORD_DEVICE_BAD      = -2; -LLAudioDeviceObserver::LLAudioDeviceObserver() : mSumVector {0}, mMicrophoneEnergy(0.0) {} +// +// LLWebRTCAudioTransport implementation +// -float LLAudioDeviceObserver::getMicrophoneEnergy() { return mMicrophoneEnergy; } +LLWebRTCAudioTransport::LLWebRTCAudioTransport() : mMicrophoneEnergy(0.0) +{ +    memset(mSumVector, 0, sizeof(mSumVector)); +} -// TODO: Pull smoothing/filtering code into a common helper function -// for LLAudioDeviceObserver and LLCustomProcessor +void LLWebRTCAudioTransport::SetEngineTransport(webrtc::AudioTransport* t) +{ +    engine_.store(t, std::memory_order_release); +} -void LLAudioDeviceObserver::OnCaptureData(const void    *audio_samples, -                                          const size_t   num_samples, -                                          const size_t   bytes_per_sample, -                                          const size_t   num_channels, -                                          const uint32_t samples_per_sec) +int32_t LLWebRTCAudioTransport::RecordedDataIsAvailable(const void* audio_data, +                                                        size_t      number_of_frames, +                                                        size_t      bytes_per_frame, +                                                        size_t      number_of_channels, +                                                        uint32_t    samples_per_sec, +                                                        uint32_t    total_delay_ms, +                                                        int32_t     clock_drift, +                                                        uint32_t    current_mic_level, +                                                        bool        key_pressed, +                                                        uint32_t&   new_mic_level)  { +    auto* engine = engine_.load(std::memory_order_acquire); + +    // 1) Deliver to engine (authoritative). +    int32_t ret = 0; +    if (engine) +    { +        ret = engine->RecordedDataIsAvailable(audio_data, +                                              number_of_frames, +                                              bytes_per_frame, +                                              number_of_channels, +                                              samples_per_sec, +                                              total_delay_ms, +                                              clock_drift, +                                              current_mic_level, +                                              key_pressed, +                                              new_mic_level); +    } + +    // 2) Calculate energy for microphone level monitoring      // calculate the energy      float        energy  = 0; -    const short *samples = (const short *) audio_samples; -    for (size_t index = 0; index < num_samples * num_channels; index++) +    const short *samples = (const short *) audio_data; + +    for (size_t index = 0; index < number_of_frames * number_of_channels; index++)      {          float sample = (static_cast<float>(samples[index]) / (float) 32767);          energy += sample * sample;      } - +    float gain = mGain.load(std::memory_order_relaxed); +    energy     = energy * gain * gain;      // smooth it.      size_t buffer_size = sizeof(mSumVector) / sizeof(mSumVector[0]);      float  totalSum    = 0; @@ -78,18 +116,59 @@ void LLAudioDeviceObserver::OnCaptureData(const void    *audio_samples,      }      mSumVector[i] = energy;      totalSum += energy; -    mMicrophoneEnergy = std::sqrt(totalSum / (num_samples * buffer_size)); +    mMicrophoneEnergy = std::sqrt(totalSum / (number_of_frames * number_of_channels * buffer_size)); + +    return ret;  } -void LLAudioDeviceObserver::OnRenderData(const void    *audio_samples, -                                         const size_t   num_samples, -                                         const size_t   bytes_per_sample, -                                         const size_t   num_channels, -                                         const uint32_t samples_per_sec) +int32_t LLWebRTCAudioTransport::NeedMorePlayData(size_t   number_of_frames, +                                                 size_t   bytes_per_frame, +                                                 size_t   number_of_channels, +                                                 uint32_t samples_per_sec, +                                                 void*    audio_data, +                                                 size_t&  number_of_samples_out, +                                                 int64_t* elapsed_time_ms, +                                                 int64_t* ntp_time_ms)  { +    auto* engine = engine_.load(std::memory_order_acquire); +    if (!engine) +    { +        // No engine sink; output silence to be safe. +        const size_t bytes = number_of_frames * bytes_per_frame * number_of_channels; +        memset(audio_data, 0, bytes); +        number_of_samples_out = bytes_per_frame; +        return 0; +    } + +    // Only the engine should fill the buffer. +    return engine->NeedMorePlayData(number_of_frames, +                                    bytes_per_frame, +                                    number_of_channels, +                                    samples_per_sec, +                                    audio_data, +                                    number_of_samples_out, +                                    elapsed_time_ms, +                                    ntp_time_ms);  } -LLCustomProcessor::LLCustomProcessor() : mSampleRateHz(0), mNumChannels(0), mMicrophoneEnergy(0.0), mGain(1.0) +void LLWebRTCAudioTransport::PullRenderData(int      bits_per_sample, +                                            int      sample_rate, +                                            size_t   number_of_channels, +                                            size_t   number_of_frames, +                                            void*    audio_data, +                                            int64_t* elapsed_time_ms, +                                            int64_t* ntp_time_ms) +{ +    auto* engine = engine_.load(std::memory_order_acquire); + +    if (engine) +    { +        engine +            ->PullRenderData(bits_per_sample, sample_rate, number_of_channels, number_of_frames, audio_data, elapsed_time_ms, ntp_time_ms); +    } +} + +LLCustomProcessor::LLCustomProcessor(LLCustomProcessorStatePtr state) : mSampleRateHz(0), mNumChannels(0), mState(state)  {      memset(mSumVector, 0, sizeof(mSumVector));  } @@ -101,40 +180,61 @@ void LLCustomProcessor::Initialize(int sample_rate_hz, int num_channels)      memset(mSumVector, 0, sizeof(mSumVector));  } -void LLCustomProcessor::Process(webrtc::AudioBuffer *audio_in) +void LLCustomProcessor::Process(webrtc::AudioBuffer *audio)  { -    webrtc::StreamConfig stream_config; -    stream_config.set_sample_rate_hz(mSampleRateHz); -    stream_config.set_num_channels(mNumChannels); -    std::vector<float *> frame; -    std::vector<float>   frame_samples; - -    if (audio_in->num_channels() < 1 || audio_in->num_frames() < 480) +    if (audio->num_channels() < 1 || audio->num_frames() < 480)      {          return;      } -    // grab the input audio -    frame_samples.resize(stream_config.num_samples()); -    frame.resize(stream_config.num_channels()); -    for (size_t ch = 0; ch < stream_config.num_channels(); ++ch) +    // calculate the energy + +    float desired_gain = mState->getGain(); +    if (mState->getDirty())      { -        frame[ch] = &(frame_samples)[ch * stream_config.num_frames()]; +        // We'll delay ramping by 30ms in order to clear out buffers that may +        // have had content before muting.  And for the last 20ms, we'll ramp +        // down or up smoothly. +        mRampFrames = 5; + +        // we've changed our desired gain, so set the incremental +        // gain change so that we smoothly step over 20ms +        mGainStep = (desired_gain - mCurrentGain) / (mSampleRateHz / 50);      } -    audio_in->CopyTo(stream_config, &frame[0]); - -    // calculate the energy -    float energy = 0; -    for (size_t index = 0; index < stream_config.num_samples(); index++) +    if (mRampFrames)      { -        float sample = frame_samples[index]; -        sample       = sample * mGain; // apply gain -        frame_samples[index] = sample; // write processed sample back to buffer. -        energy += sample * sample; +        if (mRampFrames-- > 2) +        { +            // don't change the gain if we're still in the 'don't move' phase +            mGainStep = 0.0f; +        } +    } +    else +    { +        // We've ramped all the way down, so don't step the gain any more and +        // just maintaint he current gain. +        mGainStep = 0.0f; +        mCurrentGain = desired_gain;      } -    audio_in->CopyFrom(&frame[0], stream_config); +    float energy       = 0; + +    auto chans = audio->channels(); +    for (size_t ch = 0; ch < audio->num_channels(); ch++) +    { +        float* frame_samples = chans[ch]; +        float  gain          = mCurrentGain; +        for (size_t index = 0; index < audio->num_frames(); index++) +        { +            float sample         = frame_samples[index]; +            sample               = sample * gain;    // apply gain +            frame_samples[index] = sample;        // write processed sample back to buffer. +            energy += sample * sample; +            gain += mGainStep; +        } +    } +    mCurrentGain += audio->num_frames() * mGainStep;      // smooth it.      size_t buffer_size = sizeof(mSumVector) / sizeof(mSumVector[0]); @@ -147,7 +247,7 @@ void LLCustomProcessor::Process(webrtc::AudioBuffer *audio_in)      }      mSumVector[i] = energy;      totalSum += energy; -    mMicrophoneEnergy = std::sqrt(totalSum / (stream_config.num_samples() * buffer_size)); +    mState->setMicrophoneEnergy(std::sqrt(totalSum / (audio->num_channels() * audio->num_frames() * buffer_size)));  }  // @@ -159,91 +259,54 @@ LLWebRTCImpl::LLWebRTCImpl(LLWebRTCLogCallback* logCallback) :      mPeerCustomProcessor(nullptr),      mMute(true),      mTuningMode(false), -    mPlayoutDevice(0), -    mRecordingDevice(0), -    mTuningAudioDeviceObserver(nullptr) +    mDevicesDeploying(0), +    mGain(0.0f)  {  }  void LLWebRTCImpl::init()  { -    mPlayoutDevice   = 0; -    mRecordingDevice = 0; -    rtc::InitializeSSL(); +    webrtc::InitializeSSL();      // Normal logging is rather spammy, so turn it off. -    rtc::LogMessage::LogToDebug(rtc::LS_NONE); -    rtc::LogMessage::SetLogToStderr(true); -    rtc::LogMessage::AddLogToStream(mLogSink, rtc::LS_VERBOSE); +    webrtc::LogMessage::LogToDebug(webrtc::LS_NONE); +    webrtc::LogMessage::SetLogToStderr(true); +    webrtc::LogMessage::AddLogToStream(mLogSink, webrtc::LS_VERBOSE);      mTaskQueueFactory = webrtc::CreateDefaultTaskQueueFactory();      // Create the native threads. -    mNetworkThread = rtc::Thread::CreateWithSocketServer(); +    mNetworkThread = webrtc::Thread::CreateWithSocketServer();      mNetworkThread->SetName("WebRTCNetworkThread", nullptr);      mNetworkThread->Start(); -    mWorkerThread = rtc::Thread::Create(); +    mWorkerThread = webrtc::Thread::Create();      mWorkerThread->SetName("WebRTCWorkerThread", nullptr);      mWorkerThread->Start(); -    mSignalingThread = rtc::Thread::Create(); +    mSignalingThread = webrtc::Thread::Create();      mSignalingThread->SetName("WebRTCSignalingThread", nullptr);      mSignalingThread->Start(); -    mTuningAudioDeviceObserver = new LLAudioDeviceObserver; -    mWorkerThread->PostTask( -        [this]() -        { -            // Initialize the audio devices on the Worker Thread -            mTuningDeviceModule = -                webrtc::CreateAudioDeviceWithDataObserver(webrtc::AudioDeviceModule::AudioLayer::kPlatformDefaultAudio, -                                                          mTaskQueueFactory.get(), -                                                          std::unique_ptr<webrtc::AudioDeviceDataObserver>(mTuningAudioDeviceObserver)); - -            mTuningDeviceModule->Init(); -            mTuningDeviceModule->SetPlayoutDevice(mPlayoutDevice); -            mTuningDeviceModule->SetRecordingDevice(mRecordingDevice); -            mTuningDeviceModule->EnableBuiltInAEC(false); -#if !CM_WEBRTC -            mTuningDeviceModule->SetAudioDeviceSink(this); -#endif -            mTuningDeviceModule->InitMicrophone(); -            mTuningDeviceModule->InitSpeaker(); -            mTuningDeviceModule->SetStereoRecording(false); -            mTuningDeviceModule->SetStereoPlayout(true); -            mTuningDeviceModule->InitRecording(); -            mTuningDeviceModule->InitPlayout(); -            updateDevices(); -        }); -      mWorkerThread->BlockingCall(          [this]()          { -            // the peer device module doesn't need an observer -            // as we pull peer data after audio processing. -            mPeerDeviceModule = webrtc::CreateAudioDeviceWithDataObserver(webrtc::AudioDeviceModule::AudioLayer::kPlatformDefaultAudio, -                                                                          mTaskQueueFactory.get(), -                                                                          nullptr); -            mPeerDeviceModule->Init(); -            mPeerDeviceModule->SetPlayoutDevice(mPlayoutDevice); -            mPeerDeviceModule->SetRecordingDevice(mRecordingDevice); -            mPeerDeviceModule->EnableBuiltInAEC(false); -            mPeerDeviceModule->InitMicrophone(); -            mPeerDeviceModule->InitSpeaker(); +            webrtc::scoped_refptr<webrtc::AudioDeviceModule> realADM = +                webrtc::AudioDeviceModule::Create(webrtc::AudioDeviceModule::AudioLayer::kPlatformDefaultAudio, mTaskQueueFactory.get()); +            mDeviceModule = webrtc::make_ref_counted<LLWebRTCAudioDeviceModule>(realADM); +            mDeviceModule->SetObserver(this);          });      // The custom processor allows us to retrieve audio data (and levels)      // from after other audio processing such as AEC, AGC, etc. -    mPeerCustomProcessor = new LLCustomProcessor; -    webrtc::AudioProcessingBuilder apb; -    apb.SetCapturePostProcessing(std::unique_ptr<webrtc::CustomProcessing>(mPeerCustomProcessor)); -    mAudioProcessingModule = apb.Create(); +    mPeerCustomProcessor = std::make_shared<LLCustomProcessorState>(); +    webrtc::BuiltinAudioProcessingBuilder apb; +    apb.SetCapturePostProcessing(std::make_unique<LLCustomProcessor>(mPeerCustomProcessor)); +    mAudioProcessingModule = apb.Build(webrtc::CreateEnvironment());      webrtc::AudioProcessing::Config apm_config;      apm_config.echo_canceller.enabled         = false;      apm_config.echo_canceller.mobile_mode     = false;      apm_config.gain_controller1.enabled       = false; -    apm_config.gain_controller1.mode          = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog; -    apm_config.gain_controller2.enabled       = false; +    apm_config.gain_controller2.enabled       = true;      apm_config.high_pass_filter.enabled       = true;      apm_config.noise_suppression.enabled      = true;      apm_config.noise_suppression.level        = webrtc::AudioProcessing::Config::NoiseSuppression::kVeryHigh; @@ -254,6 +317,7 @@ void LLWebRTCImpl::init()      mAudioProcessingModule->ApplyConfig(apm_config);      webrtc::ProcessingConfig processing_config; +      processing_config.input_stream().set_num_channels(2);      processing_config.input_stream().set_sample_rate_hz(48000);      processing_config.output_stream().set_num_channels(2); @@ -268,13 +332,19 @@ void LLWebRTCImpl::init()      mPeerConnectionFactory = webrtc::CreatePeerConnectionFactory(mNetworkThread.get(),                                                                   mWorkerThread.get(),                                                                   mSignalingThread.get(), -                                                                 mPeerDeviceModule, +                                                                 mDeviceModule,                                                                   webrtc::CreateBuiltinAudioEncoderFactory(),                                                                   webrtc::CreateBuiltinAudioDecoderFactory(),                                                                   nullptr /* video_encoder_factory */,                                                                   nullptr /* video_decoder_factory */,                                                                   nullptr /* audio_mixer */,                                                                   mAudioProcessingModule); +    mWorkerThread->PostTask( +        [this]() +        { +            mDeviceModule->EnableBuiltInAEC(false); +            updateDevices(); +        });  } @@ -296,64 +366,16 @@ void LLWebRTCImpl::terminate()      mWorkerThread->BlockingCall(          [this]()          { -            if (mTuningDeviceModule) -            { -                mTuningDeviceModule->StopRecording(); -                mTuningDeviceModule->Terminate(); -            } -            if (mPeerDeviceModule) +            if (mDeviceModule)              { -                mPeerDeviceModule->StopRecording(); -                mPeerDeviceModule->Terminate(); -            } -            mTuningDeviceModule = nullptr; -            mPeerDeviceModule   = nullptr; -            mTaskQueueFactory   = nullptr; -        }); -    rtc::LogMessage::RemoveLogToStream(mLogSink); -} - -// -// Devices functions -// -// Most device-related functionality needs to happen -// on the worker thread (the audio thread,) so those calls will be -// proxied over to that thread. -// -void LLWebRTCImpl::setRecording(bool recording) -{ -    mWorkerThread->PostTask( -        [this, recording]() -        { -            if (recording) -            { -                mPeerDeviceModule->SetStereoRecording(false); -                mPeerDeviceModule->InitRecording(); -                mPeerDeviceModule->StartRecording(); -            } -            else -            { -                mPeerDeviceModule->StopRecording(); -            } -        }); -} - -void LLWebRTCImpl::setPlayout(bool playing) -{ -    mWorkerThread->PostTask( -        [this, playing]() -        { -            if (playing) -            { -                mPeerDeviceModule->SetStereoPlayout(true); -                mPeerDeviceModule->InitPlayout(); -                mPeerDeviceModule->StartPlayout(); -            } -            else -            { -                mPeerDeviceModule->StopPlayout(); +                mDeviceModule->StopRecording(); +                mDeviceModule->StopPlayout(); +                mDeviceModule->Terminate();              } +            mDeviceModule     = nullptr; +            mTaskQueueFactory = nullptr;          }); +    webrtc::LogMessage::RemoveLogToStream(mLogSink);  }  void LLWebRTCImpl::setAudioConfig(LLWebRTCDeviceInterface::AudioConfig config) @@ -361,9 +383,9 @@ void LLWebRTCImpl::setAudioConfig(LLWebRTCDeviceInterface::AudioConfig config)      webrtc::AudioProcessing::Config apm_config;      apm_config.echo_canceller.enabled         = config.mEchoCancellation;      apm_config.echo_canceller.mobile_mode     = false; -    apm_config.gain_controller1.enabled       = config.mAGC; -    apm_config.gain_controller1.mode          = webrtc::AudioProcessing::Config::GainController1::kAdaptiveAnalog; -    apm_config.gain_controller2.enabled       = false; +    apm_config.gain_controller1.enabled       = false; +    apm_config.gain_controller2.enabled       = config.mAGC; +    apm_config.gain_controller2.adaptive_digital.enabled = true; // auto-level speech      apm_config.high_pass_filter.enabled       = true;      apm_config.transient_suppression.enabled  = true;      apm_config.pipeline.multi_channel_render  = true; @@ -416,142 +438,134 @@ void LLWebRTCImpl::unsetDevicesObserver(LLWebRTCDevicesObserver *observer)      }  } -void ll_set_device_module_capture_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device) +// must be run in the worker thread. +void LLWebRTCImpl::workerDeployDevices()  { +    int16_t recordingDevice = RECORD_DEVICE_DEFAULT;  #if WEBRTC_WIN -    if (device < 0) -    { -        device_module->SetRecordingDevice(webrtc::AudioDeviceModule::kDefaultDevice); -    } -    else -    { -        device_module->SetRecordingDevice(device); -    } +    int16_t recording_device_start = 0;  #else -    // passed in default is -1, but the device list -    // has it at 0 -    device_module->SetRecordingDevice(device + 1); +    int16_t recording_device_start = 1;  #endif -    device_module->InitMicrophone(); -} -void LLWebRTCImpl::setCaptureDevice(const std::string &id) -{ -    int16_t recordingDevice = RECORD_DEVICE_DEFAULT; -    if (id != "Default") +    if (mRecordingDevice != "Default")      { -        for (int16_t i = 0; i < mRecordingDeviceList.size(); i++) +        for (int16_t i = recording_device_start; i < mRecordingDeviceList.size(); i++)          { -            if (mRecordingDeviceList[i].mID == id) +            if (mRecordingDeviceList[i].mID == mRecordingDevice)              {                  recordingDevice = i;                  break;              }          }      } -    if (recordingDevice == mRecordingDevice) -    { -        return; -    } -    mRecordingDevice = recordingDevice; -    if (mTuningMode) -    { -        mWorkerThread->PostTask([this, recordingDevice]() -            { -                ll_set_device_module_capture_device(mTuningDeviceModule, recordingDevice); -            }); -    } -    else -    { -        mWorkerThread->PostTask([this, recordingDevice]() -            { -                bool recording = mPeerDeviceModule->Recording(); -                if (recording) -                { -                    mPeerDeviceModule->StopRecording(); -                } -                ll_set_device_module_capture_device(mPeerDeviceModule, recordingDevice); -                if (recording) -                { -                    mPeerDeviceModule->SetStereoRecording(false); -                    mPeerDeviceModule->InitRecording(); -                    mPeerDeviceModule->StartRecording(); -                } -            }); -    } -} - -void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceModule> device_module, int16_t device) -{ +    mDeviceModule->StopPlayout(); +    mDeviceModule->ForceStopRecording();  #if WEBRTC_WIN -    if (device < 0) +    if (recordingDevice < 0)      { -        device_module->SetPlayoutDevice(webrtc::AudioDeviceModule::kDefaultDevice); +        mDeviceModule->SetRecordingDevice((webrtc::AudioDeviceModule::WindowsDeviceType)recordingDevice);      }      else      { -        device_module->SetPlayoutDevice(device); +        mDeviceModule->SetRecordingDevice(recordingDevice);      }  #else -    device_module->SetPlayoutDevice(device + 1); +    mDeviceModule->SetRecordingDevice(recordingDevice);  #endif -    device_module->InitSpeaker(); -} +    mDeviceModule->InitMicrophone(); +    mDeviceModule->SetStereoRecording(false); +    mDeviceModule->InitRecording(); -void LLWebRTCImpl::setRenderDevice(const std::string &id) -{      int16_t playoutDevice = PLAYOUT_DEVICE_DEFAULT; -    if (id != "Default") +#if WEBRTC_WIN +    int16_t playout_device_start = 0; +#else +    int16_t playout_device_start = 1; +#endif +    if (mPlayoutDevice != "Default")      { -        for (int16_t i = 0; i < mPlayoutDeviceList.size(); i++) +        for (int16_t i = playout_device_start; i < mPlayoutDeviceList.size(); i++)          { -            if (mPlayoutDeviceList[i].mID == id) +            if (mPlayoutDeviceList[i].mID == mPlayoutDevice)              {                  playoutDevice = i;                  break;              }          }      } -    if (playoutDevice == mPlayoutDevice) + +#if WEBRTC_WIN +    if (playoutDevice < 0) +    { +        mDeviceModule->SetPlayoutDevice((webrtc::AudioDeviceModule::WindowsDeviceType)playoutDevice); +    } +    else      { -        return; +        mDeviceModule->SetPlayoutDevice(playoutDevice);      } -    mPlayoutDevice = playoutDevice; +#else +    mDeviceModule->SetPlayoutDevice(playoutDevice); +#endif +    mDeviceModule->InitSpeaker(); +    mDeviceModule->SetStereoPlayout(true); +    mDeviceModule->InitPlayout(); -    if (mTuningMode) +    if ((!mMute && mPeerConnections.size()) || mTuningMode)      { -        mWorkerThread->PostTask( -            [this, playoutDevice]() -            { -                ll_set_device_module_render_device(mTuningDeviceModule, playoutDevice); -            }); +        mDeviceModule->ForceStartRecording();      } -    else + +    if (!mTuningMode)      { -        mWorkerThread->PostTask( -            [this, playoutDevice]() +        mDeviceModule->StartPlayout(); +    } +    mSignalingThread->PostTask( +        [this] +        { +            for (auto& connection : mPeerConnections)              { -                bool playing = mPeerDeviceModule->Playing(); -                if (playing) +                if (mTuningMode)                  { -                    mPeerDeviceModule->StopPlayout(); +                    connection->enableSenderTracks(false);                  } -                ll_set_device_module_render_device(mPeerDeviceModule, playoutDevice); -                if (playing) +                else                  { -                    mPeerDeviceModule->SetStereoPlayout(true); -                    mPeerDeviceModule->InitPlayout(); -                    mPeerDeviceModule->StartPlayout(); +                    connection->resetMute();                  } -            }); +                connection->enableReceiverTracks(!mTuningMode); +            } +            if (1 < mDevicesDeploying.fetch_sub(1, std::memory_order_relaxed)) +            { +                mWorkerThread->PostTask([this] { workerDeployDevices(); }); +            } +        }); +} + +void LLWebRTCImpl::setCaptureDevice(const std::string &id) +{ + +    if (mRecordingDevice != id) +    { +        mRecordingDevice = id; +        deployDevices(); +    } +} + +void LLWebRTCImpl::setRenderDevice(const std::string &id) +{ +    if (mPlayoutDevice != id) +    { +        mPlayoutDevice = id; +        deployDevices();      }  }  // updateDevices needs to happen on the worker thread.  void LLWebRTCImpl::updateDevices()  { -    int16_t renderDeviceCount  = mTuningDeviceModule->PlayoutDevices(); +    int16_t renderDeviceCount  = mDeviceModule->PlayoutDevices();      mPlayoutDeviceList.clear();  #if WEBRTC_WIN @@ -565,11 +579,11 @@ void LLWebRTCImpl::updateDevices()      {          char name[webrtc::kAdmMaxDeviceNameSize];          char guid[webrtc::kAdmMaxGuidSize]; -        mTuningDeviceModule->PlayoutDeviceName(index, name, guid); +        mDeviceModule->PlayoutDeviceName(index, name, guid);          mPlayoutDeviceList.emplace_back(name, guid);      } -    int16_t captureDeviceCount        = mTuningDeviceModule->RecordingDevices(); +    int16_t captureDeviceCount        = mDeviceModule->RecordingDevices();      mRecordingDeviceList.clear();  #if WEBRTC_WIN @@ -583,7 +597,7 @@ void LLWebRTCImpl::updateDevices()      {          char name[webrtc::kAdmMaxDeviceNameSize];          char guid[webrtc::kAdmMaxGuidSize]; -        mTuningDeviceModule->RecordingDeviceName(index, name, guid); +        mDeviceModule->RecordingDeviceName(index, name, guid);          mRecordingDeviceList.emplace_back(name, guid);      } @@ -595,11 +609,7 @@ void LLWebRTCImpl::updateDevices()  void LLWebRTCImpl::OnDevicesUpdated()  { -    // reset these to a bad value so an update is forced -    mRecordingDevice = RECORD_DEVICE_BAD; -    mPlayoutDevice   = PLAYOUT_DEVICE_BAD; - -    updateDevices(); +    deployDevices();  } @@ -607,60 +617,109 @@ void LLWebRTCImpl::setTuningMode(bool enable)  {      mTuningMode = enable;      mWorkerThread->PostTask( -        [this, enable] { -            if (enable) -            { -                mPeerDeviceModule->StopRecording(); -                mPeerDeviceModule->StopPlayout(); -                ll_set_device_module_render_device(mTuningDeviceModule, mPlayoutDevice); -                ll_set_device_module_capture_device(mTuningDeviceModule, mRecordingDevice); -                mTuningDeviceModule->InitPlayout(); -                mTuningDeviceModule->InitRecording(); -                mTuningDeviceModule->StartRecording(); -                // TODO:  Starting Playout on the TDM appears to create an audio artifact (click) -                // in this case, so disabling it for now.  We may have to do something different -                // if we enable 'echo playback' via the TDM when tuning. -                //mTuningDeviceModule->StartPlayout(); -            } -            else -            { -                mTuningDeviceModule->StopRecording(); -                //mTuningDeviceModule->StopPlayout(); -                ll_set_device_module_render_device(mPeerDeviceModule, mPlayoutDevice); -                ll_set_device_module_capture_device(mPeerDeviceModule, mRecordingDevice); -                mPeerDeviceModule->SetStereoPlayout(true); -                mPeerDeviceModule->SetStereoRecording(false); -                mPeerDeviceModule->InitPlayout(); -                mPeerDeviceModule->InitRecording(); -                mPeerDeviceModule->StartPlayout(); -                mPeerDeviceModule->StartRecording(); -            } -        } -    ); -    mSignalingThread->PostTask( -        [this, enable] +        [this]          { -            for (auto &connection : mPeerConnections) -            { -                if (enable) +            mDeviceModule->SetTuning(mTuningMode, mMute); +            mSignalingThread->PostTask( +                [this]                  { -                    connection->enableSenderTracks(false); -                } -                else -                { -                    connection->resetMute(); -                } -                connection->enableReceiverTracks(!enable); -            } +                    for (auto& connection : mPeerConnections) +                    { +                        if (mTuningMode) +                        { +                            connection->enableSenderTracks(false); +                        } +                        else +                        { +                            connection->resetMute(); +                        } +                        connection->enableReceiverTracks(!mTuningMode); +                    } +                });          });  } -float LLWebRTCImpl::getTuningAudioLevel() { return -20 * log10f(mTuningAudioDeviceObserver->getMicrophoneEnergy()); } +void LLWebRTCImpl::deployDevices() +{ +    if (0 < mDevicesDeploying.fetch_add(1, std::memory_order_relaxed)) +    { +        return; +    } +    mWorkerThread->PostTask( +        [this] { +            workerDeployDevices(); +        }); +} + +float LLWebRTCImpl::getTuningAudioLevel() +{ +    return mDeviceModule ? -20 * log10f(mDeviceModule->GetMicrophoneEnergy()) : std::numeric_limits<float>::infinity(); +} -float LLWebRTCImpl::getPeerConnectionAudioLevel() { return -20 * log10f(mPeerCustomProcessor->getMicrophoneEnergy()); } +void LLWebRTCImpl::setTuningMicGain(float gain) +{ +    if (mTuningMode && mDeviceModule) +    { +        mDeviceModule->SetTuningMicGain(gain); +    } +} + +float LLWebRTCImpl::getPeerConnectionAudioLevel() +{ +    return mTuningMode ? std::numeric_limits<float>::infinity() +                       : (mPeerCustomProcessor ? -20 * log10f(mPeerCustomProcessor->getMicrophoneEnergy()) +                                               : std::numeric_limits<float>::infinity()); +} -void LLWebRTCImpl::setPeerConnectionGain(float gain) { mPeerCustomProcessor->setGain(gain); } +void LLWebRTCImpl::setMicGain(float gain) +{ +    mGain = gain; +    if (!mTuningMode && mPeerCustomProcessor) +    { +        mPeerCustomProcessor->setGain(gain); +    } +} +void LLWebRTCImpl::setMute(bool mute, int delay_ms) +{ +    if (mMute != mute) +    { +        mMute = mute; +        intSetMute(mute, delay_ms); +    } +} + +void LLWebRTCImpl::intSetMute(bool mute, int delay_ms) +{ +    if (mPeerCustomProcessor) +    { +        mPeerCustomProcessor->setGain(mMute ? 0.0f : mGain); +    } +    if (mMute) +    { +        mWorkerThread->PostDelayedTask( +            [this] +            { +                if (mDeviceModule) +                { +                    mDeviceModule->ForceStopRecording(); +                } +            }, +            webrtc::TimeDelta::Millis(delay_ms)); +    } +    else +    { +        mWorkerThread->PostTask( +            [this] +            { +                if (mDeviceModule) +                { +                    mDeviceModule->InitRecording(); +                    mDeviceModule->ForceStartRecording(); +                } +            }); +    } +}  //  // Peer Connection Helpers @@ -668,34 +727,31 @@ void LLWebRTCImpl::setPeerConnectionGain(float gain) { mPeerCustomProcessor->set  LLWebRTCPeerConnectionInterface *LLWebRTCImpl::newPeerConnection()  { -    rtc::scoped_refptr<LLWebRTCPeerConnectionImpl> peerConnection = rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>(new rtc::RefCountedObject<LLWebRTCPeerConnectionImpl>()); +    bool empty = mPeerConnections.empty(); +    webrtc::scoped_refptr<LLWebRTCPeerConnectionImpl> peerConnection = webrtc::scoped_refptr<LLWebRTCPeerConnectionImpl>(new webrtc::RefCountedObject<LLWebRTCPeerConnectionImpl>());      peerConnection->init(this); - -    mPeerConnections.emplace_back(peerConnection); -    // Should it really start disabled? -    // Seems like something doesn't get the memo and senders need to be reset later -    // to remove the voice indicator from taskbar -    peerConnection->enableSenderTracks(false);      if (mPeerConnections.empty())      { -        setRecording(true); -        setPlayout(true); +        intSetMute(mMute);      } +    mPeerConnections.emplace_back(peerConnection); + +    peerConnection->enableSenderTracks(false); +    peerConnection->resetMute();      return peerConnection.get();  }  void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_connection)  { -    std::vector<rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>>::iterator it = +    std::vector<webrtc::scoped_refptr<LLWebRTCPeerConnectionImpl>>::iterator it =      std::find(mPeerConnections.begin(), mPeerConnections.end(), peer_connection);      if (it != mPeerConnections.end())      {          mPeerConnections.erase(it); -    } -    if (mPeerConnections.empty()) -    { -        setRecording(false); -        setPlayout(false); +        if (mPeerConnections.empty()) +        { +            intSetMute(true); +        }      }  } @@ -731,7 +787,7 @@ void LLWebRTCPeerConnectionImpl::init(LLWebRTCImpl * webrtc_impl)  }  void LLWebRTCPeerConnectionImpl::terminate()  { -    mWebRTCImpl->SignalingBlockingCall( +    mWebRTCImpl->PostSignalingTask(          [this]()          {              if (mPeerConnection) @@ -755,7 +811,6 @@ void LLWebRTCPeerConnectionImpl::terminate()                          track->set_enabled(false);                      }                  } -                mPeerConnection->SetAudioRecording(false);                  mPeerConnection->Close();                  if (mLocalStream) @@ -842,7 +897,7 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti                  mDataChannel->RegisterObserver(this);              } -            cricket::AudioOptions audioOptions; +            webrtc::AudioOptions audioOptions;              audioOptions.auto_gain_control = true;              audioOptions.echo_cancellation = true;              audioOptions.noise_suppression = true; @@ -850,7 +905,7 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti              mLocalStream = mPeerConnectionFactory->CreateLocalMediaStream("SLStream"); -            rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track( +            webrtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(                  mPeerConnectionFactory->CreateAudioTrack("SLAudio", mPeerConnectionFactory->CreateAudioSource(audioOptions).get()));              audio_track->set_enabled(false);              mLocalStream->AddTrack(audio_track); @@ -864,7 +919,7 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti                  webrtc::RtpParameters      params;                  webrtc::RtpCodecParameters codecparam;                  codecparam.name                       = "opus"; -                codecparam.kind                       = cricket::MEDIA_TYPE_AUDIO; +                codecparam.kind                       = webrtc::MediaType::AUDIO;                  codecparam.clock_rate                 = 48000;                  codecparam.num_channels               = 2;                  codecparam.parameters["stereo"]       = "1"; @@ -879,7 +934,7 @@ bool LLWebRTCPeerConnectionImpl::initializeConnection(const LLWebRTCPeerConnecti                  webrtc::RtpParameters      params;                  webrtc::RtpCodecParameters codecparam;                  codecparam.name                       = "opus"; -                codecparam.kind                       = cricket::MEDIA_TYPE_AUDIO; +                codecparam.kind                       = webrtc::MediaType::AUDIO;                  codecparam.clock_rate                 = 48000;                  codecparam.num_channels               = 2;                  codecparam.parameters["stereo"]       = "1"; @@ -906,7 +961,6 @@ void LLWebRTCPeerConnectionImpl::enableSenderTracks(bool enable)      // set_enabled shouldn't be done on the worker thread.      if (mPeerConnection)      { -        mPeerConnection->SetAudioRecording(enable);          auto senders = mPeerConnection->GetSenders();          for (auto &sender : senders)          { @@ -940,7 +994,7 @@ void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp)                                     {                                         RTC_LOG(LS_INFO) << __FUNCTION__ << " " << mPeerConnection->peer_connection_state();                                         mPeerConnection->SetRemoteDescription(webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, sdp), -                                                                             rtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface>(this)); +                                                                             webrtc::scoped_refptr<webrtc::SetRemoteDescriptionObserverInterface>(this));                                     }                                 });  } @@ -953,22 +1007,22 @@ void LLWebRTCPeerConnectionImpl::AnswerAvailable(const std::string &sdp)  void LLWebRTCPeerConnectionImpl::setMute(bool mute)  {      EMicMuteState new_state = mute ? MUTE_MUTED : MUTE_UNMUTED; -    if (new_state == mMute) -    { -        return; // no change -    } + +    // even if mute hasn't changed, we still need to update the mute +    // state on the connections to handle cases where the 'Default' device +    // has changed in the OS (unplugged headset, etc.) which messes +    // with the mute state. +      bool force_reset = mMute == MUTE_INITIAL && mute;      bool enable = !mute;      mMute = new_state; +      mWebRTCImpl->PostSignalingTask(          [this, force_reset, enable]()          {          if (mPeerConnection)          { -            // SetAudioRecording must be called before enabling/disabling tracks. -            mPeerConnection->SetAudioRecording(enable); -              auto senders = mPeerConnection->GetSenders();              RTC_LOG(LS_INFO) << __FUNCTION__ << (mMute ? "disabling" : "enabling") << " streams count " << senders.size(); @@ -1048,14 +1102,14 @@ void LLWebRTCPeerConnectionImpl::setSendVolume(float volume)  // PeerConnectionObserver implementation.  // -void LLWebRTCPeerConnectionImpl::OnAddTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface>                     receiver, -                                            const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>> &streams) +void LLWebRTCPeerConnectionImpl::OnAddTrack(webrtc::scoped_refptr<webrtc::RtpReceiverInterface>                     receiver, +                                            const std::vector<webrtc::scoped_refptr<webrtc::MediaStreamInterface>> &streams)  {      RTC_LOG(LS_INFO) << __FUNCTION__ << " " << receiver->id();      webrtc::RtpParameters      params;      webrtc::RtpCodecParameters codecparam;      codecparam.name                       = "opus"; -    codecparam.kind                       = cricket::MEDIA_TYPE_AUDIO; +    codecparam.kind                       = webrtc::MediaType::AUDIO;      codecparam.clock_rate                 = 48000;      codecparam.num_channels               = 2;      codecparam.parameters["stereo"]       = "1"; @@ -1064,12 +1118,12 @@ void LLWebRTCPeerConnectionImpl::OnAddTrack(rtc::scoped_refptr<webrtc::RtpReceiv      receiver->SetParameters(params);  } -void LLWebRTCPeerConnectionImpl::OnRemoveTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) +void LLWebRTCPeerConnectionImpl::OnRemoveTrack(webrtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver)  {      RTC_LOG(LS_INFO) << __FUNCTION__ << " " << receiver->id();  } -void LLWebRTCPeerConnectionImpl::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> channel) +void LLWebRTCPeerConnectionImpl::OnDataChannel(webrtc::scoped_refptr<webrtc::DataChannelInterface> channel)  {      if (mDataChannel)      { @@ -1156,23 +1210,23 @@ static std::string iceCandidateToTrickleString(const webrtc::IceCandidateInterfa      candidate->candidate().address().ipaddr().ToString() << " " <<      candidate->candidate().address().PortAsString() << " typ "; -    if (candidate->candidate().type() == cricket::LOCAL_PORT_TYPE) +    if (candidate->candidate().type() == webrtc::IceCandidateType::kHost)      {          candidate_stream << "host";      } -    else if (candidate->candidate().type() == cricket::STUN_PORT_TYPE) +    else if (candidate->candidate().type() == webrtc::IceCandidateType::kSrflx)      {          candidate_stream << "srflx " <<          "raddr " << candidate->candidate().related_address().ipaddr().ToString() << " " <<          "rport " << candidate->candidate().related_address().PortAsString();      } -    else if (candidate->candidate().type() == cricket::RELAY_PORT_TYPE) +    else if (candidate->candidate().type() == webrtc::IceCandidateType::kRelay)      {          candidate_stream << "relay " <<          "raddr " << candidate->candidate().related_address().ipaddr().ToString() << " " <<          "rport " << candidate->candidate().related_address().PortAsString();      } -    else if (candidate->candidate().type() == cricket::PRFLX_PORT_TYPE) +    else if (candidate->candidate().type() == webrtc::IceCandidateType::kPrflx)      {          candidate_stream << "prflx " <<          "raddr " << candidate->candidate().related_address().ipaddr().ToString() << " " << @@ -1267,7 +1321,7 @@ void LLWebRTCPeerConnectionImpl::OnSuccess(webrtc::SessionDescriptionInterface *     mPeerConnection->SetLocalDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>(                                                       webrtc::CreateSessionDescription(webrtc::SdpType::kOffer, mangled_sdp)), -                                                 rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface>(this)); +                                                 webrtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface>(this));  } @@ -1377,7 +1431,7 @@ void LLWebRTCPeerConnectionImpl::sendData(const std::string& data, bool binary)  {      if (mDataChannel)      { -        rtc::CopyOnWriteBuffer cowBuffer(data.data(), data.length()); +        webrtc::CopyOnWriteBuffer cowBuffer(data.data(), data.length());          webrtc::DataBuffer     buffer(cowBuffer, binary);          mWebRTCImpl->PostNetworkTask([this, buffer]() {                  if (mDataChannel) diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h index c6fdb909dd..7d06b7d2b4 100644 --- a/indra/llwebrtc/llwebrtc.h +++ b/indra/llwebrtc/llwebrtc.h @@ -159,7 +159,10 @@ class LLWebRTCDeviceInterface      virtual void setTuningMode(bool enable) = 0;      virtual float getTuningAudioLevel() = 0; // for use during tuning      virtual float getPeerConnectionAudioLevel() = 0; // for use when not tuning -    virtual void setPeerConnectionGain(float gain) = 0; +    virtual void setMicGain(float gain) = 0; +    virtual void setTuningMicGain(float gain)        = 0; + +    virtual void setMute(bool mute, int delay_ms = 0) = 0;  };  // LLWebRTCAudioInterface provides the viewer with a way diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index dfdb19e9be..7b23b11208 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -54,12 +54,12 @@  #include "rtc_base/ref_counted_object.h"  #include "rtc_base/ssl_adapter.h"  #include "rtc_base/thread.h" +#include "rtc_base/logging.h"  #include "api/peer_connection_interface.h"  #include "api/media_stream_interface.h"  #include "api/create_peerconnection_factory.h"  #include "modules/audio_device/include/audio_device.h"  #include "modules/audio_device/include/audio_device_data_observer.h" -#include "rtc_base/task_queue.h"  #include "api/task_queue/task_queue_factory.h"  #include "api/task_queue/default_task_queue_factory.h"  #include "modules/audio_device/include/audio_device_defines.h" @@ -69,35 +69,30 @@ namespace llwebrtc  class LLWebRTCPeerConnectionImpl; -class LLWebRTCLogSink : public rtc::LogSink { +class LLWebRTCLogSink : public webrtc::LogSink +{  public: -    LLWebRTCLogSink(LLWebRTCLogCallback* callback) : -    mCallback(callback) -    { -    } +    LLWebRTCLogSink(LLWebRTCLogCallback* callback) : mCallback(callback) {}      // Destructor: close the log file -    ~LLWebRTCLogSink() override -    { -    } +    ~LLWebRTCLogSink() override {} -    void OnLogMessage(const std::string& msg, -                      rtc::LoggingSeverity severity) override +    void OnLogMessage(const std::string& msg, webrtc::LoggingSeverity severity) override      {          if (mCallback)          { -            switch(severity) +            switch (severity)              { -                case rtc::LS_VERBOSE: +                case webrtc::LS_VERBOSE:                      mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);                      break; -                case rtc::LS_INFO: +                case webrtc::LS_INFO:                      mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);                      break; -                case rtc::LS_WARNING: +                case webrtc::LS_WARNING:                      mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);                      break; -                case rtc::LS_ERROR: +                case webrtc::LS_ERROR:                      mCallback->LogMessage(LLWebRTCLogCallback::LOG_LEVEL_VERBOSE, msg);                      break;                  default: @@ -118,67 +113,301 @@ private:      LLWebRTCLogCallback* mCallback;  }; -// Implements a class allowing capture of audio data -// to determine audio level of the microphone. -class LLAudioDeviceObserver : public webrtc::AudioDeviceDataObserver +// ----------------------------------------------------------------------------- +// A proxy transport that forwards capture data to two AudioTransport sinks: +//  - the "engine" (libwebrtc's VoiceEngine) +//  - the "user" (your app's listener) +// +// Playout (NeedMorePlayData) goes only to the engine by default to avoid +// double-writing into the output buffer. See notes below if you want a tap. +// ----------------------------------------------------------------------------- +class LLWebRTCAudioTransport : public webrtc::AudioTransport  { -  public: -    LLAudioDeviceObserver(); - -    // Retrieve the RMS audio loudness -    float getMicrophoneEnergy(); - -    // Data retrieved from the caputure device is -    // passed in here for processing. -    void OnCaptureData(const void    *audio_samples, -                       const size_t   num_samples, -                       const size_t   bytes_per_sample, -                       const size_t   num_channels, -                       const uint32_t samples_per_sec) override; - -    // This is for data destined for the render device. -    // not currently used. -    void OnRenderData(const void    *audio_samples, -                      const size_t   num_samples, -                      const size_t   bytes_per_sample, -                      const size_t   num_channels, -                      const uint32_t samples_per_sec) override; +public: +    LLWebRTCAudioTransport(); + +    void SetEngineTransport(webrtc::AudioTransport* t); + +    // -------- Capture path: fan out to both sinks -------- +    int32_t RecordedDataIsAvailable(const void* audio_data, +                                    size_t      number_of_samples, +                                    size_t      bytes_per_sample, +                                    size_t      number_of_channels, +                                    uint32_t    samples_per_sec, +                                    uint32_t    total_delay_ms, +                                    int32_t     clock_drift, +                                    uint32_t    current_mic_level, +                                    bool        key_pressed, +                                    uint32_t&   new_mic_level) override; + +    // -------- Playout path: delegate to engine only -------- +    int32_t NeedMorePlayData(size_t   number_of_samples, +                             size_t   bytes_per_sample, +                             size_t   number_of_channels, +                             uint32_t samples_per_sec, +                             void*    audio_data, +                             size_t&  number_of_samples_out, +                             int64_t* elapsed_time_ms, +                             int64_t* ntp_time_ms) override; + +    // Method to pull mixed render audio data from all active VoE channels. +    // The data will not be passed as reference for audio processing internally. +    void PullRenderData(int      bits_per_sample, +                        int      sample_rate, +                        size_t   number_of_channels, +                        size_t   number_of_frames, +                        void*    audio_data, +                        int64_t* elapsed_time_ms, +                        int64_t* ntp_time_ms) override; + +    float GetMicrophoneEnergy() { return mMicrophoneEnergy.load(std::memory_order_relaxed); } +    void  SetGain(float gain) { mGain.store(gain, std::memory_order_relaxed); } + +private: +    std::atomic<webrtc::AudioTransport*> engine_{ nullptr }; +    static const int                     NUM_PACKETS_TO_FILTER = 30; // 300 ms of smoothing (30 frames) +    float                                mSumVector[NUM_PACKETS_TO_FILTER]; +    std::atomic<float>                   mMicrophoneEnergy; +    std::atomic<float>                   mGain{ 0.0f }; -  protected: -    static const int NUM_PACKETS_TO_FILTER = 30;  // 300 ms of smoothing (30 frames) -    float mSumVector[NUM_PACKETS_TO_FILTER]; -    float mMicrophoneEnergy;  }; + +// ----------------------------------------------------------------------------- +// LLWebRTCAudioDeviceModule +// - Wraps a real ADM to provide microphone energy for tuning +// ----------------------------------------------------------------------------- +class LLWebRTCAudioDeviceModule : public webrtc::AudioDeviceModule +{ +public: +    explicit LLWebRTCAudioDeviceModule(webrtc::scoped_refptr<webrtc::AudioDeviceModule> inner) : inner_(std::move(inner)), tuning_(false) +    { +        RTC_CHECK(inner_); +    } + +    // ----- AudioDeviceModule interface: we mostly forward to |inner_| ----- +    int32_t ActiveAudioLayer(AudioLayer* audioLayer) const override { return inner_->ActiveAudioLayer(audioLayer); } + +    int32_t RegisterAudioCallback(webrtc::AudioTransport* engine_transport) override +    { +        // The engine registers its transport here. We put our audio transport between engine and ADM. +        audio_transport_.SetEngineTransport(engine_transport); +        // Register our proxy with the real ADM. +        return inner_->RegisterAudioCallback(&audio_transport_); +    } + +    int32_t Init() override { return inner_->Init(); } +    int32_t Terminate() override { return inner_->Terminate(); } +    bool    Initialized() const override { return inner_->Initialized(); } + +    // --- Device enumeration/selection (forward) --- +    int16_t PlayoutDevices() override { return inner_->PlayoutDevices(); } +    int16_t RecordingDevices() override { return inner_->RecordingDevices(); } +    int32_t PlayoutDeviceName(uint16_t index, char name[webrtc::kAdmMaxDeviceNameSize], char guid[webrtc::kAdmMaxGuidSize]) override +    { +        return inner_->PlayoutDeviceName(index, name, guid); +    } +    int32_t RecordingDeviceName(uint16_t index, char name[webrtc::kAdmMaxDeviceNameSize], char guid[webrtc::kAdmMaxGuidSize]) override +    { +        return inner_->RecordingDeviceName(index, name, guid); +    } +    int32_t SetPlayoutDevice(uint16_t index) override { return inner_->SetPlayoutDevice(index); } +    int32_t SetRecordingDevice(uint16_t index) override { return inner_->SetRecordingDevice(index); } + +    // Windows default/communications selectors, if your branch exposes them: +    int32_t SetPlayoutDevice(WindowsDeviceType type) override { return inner_->SetPlayoutDevice(type); } +    int32_t SetRecordingDevice(WindowsDeviceType type) override { return inner_->SetRecordingDevice(type); } + +    // --- Init/start/stop (forward) --- +    int32_t InitPlayout() override { return inner_->InitPlayout(); } +    bool    PlayoutIsInitialized() const override { return inner_->PlayoutIsInitialized(); } +    int32_t StartPlayout() override { +        if (tuning_) return 0;  // For tuning, don't allow playout +        return inner_->StartPlayout(); +    } +    int32_t StopPlayout() override { return inner_->StopPlayout(); } +    bool    Playing() const override { return inner_->Playing(); } + +    int32_t InitRecording() override { return inner_->InitRecording(); } +    bool    RecordingIsInitialized() const override { return inner_->RecordingIsInitialized(); } +    int32_t StartRecording() override { +        // ignore start recording as webrtc.lib will +        // send one when streams first connect, resulting +        // in an inadvertant 'recording' when mute is on. +        // We take full control of StartRecording via +        // ForceStartRecording below. +        return 0; +    } +    int32_t StopRecording() override { +        if (tuning_) return 0;  // if we're tuning, disregard the StopRecording we get from disabling the streams +        return inner_->StopRecording(); +    } +    int32_t ForceStartRecording() { return inner_->StartRecording(); } +    int32_t ForceStopRecording() { return inner_->StopRecording(); } +    bool    Recording() const override { return inner_->Recording(); } + +    // --- Stereo opts (forward if available on your branch) --- +    int32_t SetStereoPlayout(bool enable) override { return inner_->SetStereoPlayout(enable); } +    int32_t SetStereoRecording(bool enable) override { return inner_->SetStereoRecording(enable); } +    int32_t PlayoutIsAvailable(bool* available) override { return inner_->PlayoutIsAvailable(available); } +    int32_t RecordingIsAvailable(bool* available) override { return inner_->RecordingIsAvailable(available); } + +    // --- AGC/Volume/Mute/etc. (forward) --- +    int32_t SetMicrophoneVolume(uint32_t volume) override { return inner_->SetMicrophoneVolume(volume); } +    int32_t MicrophoneVolume(uint32_t* volume) const override { return inner_->MicrophoneVolume(volume); } + +    // --- Speaker/Microphone init (forward) --- +    int32_t InitSpeaker() override { return inner_->InitSpeaker(); } +    bool    SpeakerIsInitialized() const override { return inner_->SpeakerIsInitialized(); } +    int32_t InitMicrophone() override { return inner_->InitMicrophone(); } +    bool    MicrophoneIsInitialized() const override { return inner_->MicrophoneIsInitialized(); } + +    // --- Speaker Volume (forward) --- +    int32_t SpeakerVolumeIsAvailable(bool* available) override { return inner_->SpeakerVolumeIsAvailable(available); } +    int32_t SetSpeakerVolume(uint32_t volume) override { return inner_->SetSpeakerVolume(volume); } +    int32_t SpeakerVolume(uint32_t* volume) const override { return inner_->SpeakerVolume(volume); } +    int32_t MaxSpeakerVolume(uint32_t* maxVolume) const override { return inner_->MaxSpeakerVolume(maxVolume); } +    int32_t MinSpeakerVolume(uint32_t* minVolume) const override { return inner_->MinSpeakerVolume(minVolume); } + +    // --- Microphone Volume (forward) --- +    int32_t MicrophoneVolumeIsAvailable(bool* available) override { return inner_->MicrophoneVolumeIsAvailable(available); } +    int32_t MaxMicrophoneVolume(uint32_t* maxVolume) const override { return inner_->MaxMicrophoneVolume(maxVolume); } +    int32_t MinMicrophoneVolume(uint32_t* minVolume) const override { return inner_->MinMicrophoneVolume(minVolume); } + +    // --- Speaker Mute (forward) --- +    int32_t SpeakerMuteIsAvailable(bool* available) override { return inner_->SpeakerMuteIsAvailable(available); } +    int32_t SetSpeakerMute(bool enable) override { return inner_->SetSpeakerMute(enable); } +    int32_t SpeakerMute(bool* enabled) const override { return inner_->SpeakerMute(enabled); } + +    // --- Microphone Mute (forward) --- +    int32_t MicrophoneMuteIsAvailable(bool* available) override { return inner_->MicrophoneMuteIsAvailable(available); } +    int32_t SetMicrophoneMute(bool enable) override { return inner_->SetMicrophoneMute(enable); } +    int32_t MicrophoneMute(bool* enabled) const override { return inner_->MicrophoneMute(enabled); } + +    // --- Stereo Support (forward) --- +    int32_t StereoPlayoutIsAvailable(bool* available) const override { return inner_->StereoPlayoutIsAvailable(available); } +    int32_t StereoPlayout(bool* enabled) const override { return inner_->StereoPlayout(enabled); } +    int32_t StereoRecordingIsAvailable(bool* available) const override { return inner_->StereoRecordingIsAvailable(available); } +    int32_t StereoRecording(bool* enabled) const override { return inner_->StereoRecording(enabled); } + +    // --- Delay/Timing (forward) --- +    int32_t PlayoutDelay(uint16_t* delayMS) const override { return inner_->PlayoutDelay(delayMS); } + +    // --- Built-in Audio Processing (forward) --- +    bool    BuiltInAECIsAvailable() const override { return inner_->BuiltInAECIsAvailable(); } +    bool    BuiltInAGCIsAvailable() const override { return inner_->BuiltInAGCIsAvailable(); } +    bool    BuiltInNSIsAvailable() const override { return inner_->BuiltInNSIsAvailable(); } +    int32_t EnableBuiltInAEC(bool enable) override { return inner_->EnableBuiltInAEC(enable); } +    int32_t EnableBuiltInAGC(bool enable) override { return inner_->EnableBuiltInAGC(enable); } +    int32_t EnableBuiltInNS(bool enable) override { return inner_->EnableBuiltInNS(enable); } + +    // --- Additional AudioDeviceModule methods (forward) --- +    int32_t GetPlayoutUnderrunCount() const override { return inner_->GetPlayoutUnderrunCount(); } + +    // Used to generate RTC stats. If not implemented, RTCAudioPlayoutStats will +    // not be present in the stats. +    std::optional<Stats> GetStats() const override { return inner_->GetStats(); } + +// Only supported on iOS. +#if defined(WEBRTC_IOS) +    virtual int GetPlayoutAudioParameters(AudioParameters* params) const override { return inner_->GetPlayoutAudioParameters(params); } +    virtual int GetRecordAudioParameters(AudioParameters* params) override { return inner_->GetRecordAudioParameters(params); } +#endif // WEBRTC_IOS + +    virtual int32_t GetPlayoutDevice() const override { return inner_->GetPlayoutDevice(); } +    virtual int32_t GetRecordingDevice() const override { return inner_->GetRecordingDevice(); } +    virtual int32_t SetObserver(webrtc::AudioDeviceObserver* observer) override { return inner_->SetObserver(observer); } + +    // tuning microphone energy calculations +    float GetMicrophoneEnergy() { return audio_transport_.GetMicrophoneEnergy(); } +    void SetTuningMicGain(float gain) { audio_transport_.SetGain(gain); } +    void  SetTuning(bool tuning, bool mute) +    { +        tuning_ = tuning; +        if (tuning) +        { +            inner_->InitRecording(); +            inner_->StartRecording(); +            inner_->StopPlayout(); +        } +        else +        { +            if (mute) +            { +                inner_->StopRecording(); +            } +            else +            { +                inner_->InitRecording(); +                inner_->StartRecording(); +            } +            inner_->StartPlayout(); +        } +    } + +protected: +    ~LLWebRTCAudioDeviceModule() override = default; + +private: +    webrtc::scoped_refptr<webrtc::AudioDeviceModule> inner_; +    LLWebRTCAudioTransport                        audio_transport_; + +    bool tuning_; +}; + +class LLCustomProcessorState +{ + +public: +    float getMicrophoneEnergy() { return mMicrophoneEnergy.load(std::memory_order_relaxed); } +    void setMicrophoneEnergy(float energy) { mMicrophoneEnergy.store(energy, std::memory_order_relaxed); } + +    void setGain(float gain) +    { +        mGain.store(gain, std::memory_order_relaxed); +        mDirty.store(true, std::memory_order_relaxed); +    } + +    float getGain() { return mGain.load(std::memory_order_relaxed); } + +    bool getDirty() { return mDirty.exchange(false, std::memory_order_relaxed); } + + protected: +    std::atomic<bool>  mDirty{ true }; +    std::atomic<float> mMicrophoneEnergy{ 0.0f }; +    std::atomic<float> mGain{ 0.0f }; +}; + +using LLCustomProcessorStatePtr = std::shared_ptr<LLCustomProcessorState>; +  // Used to process/retrieve audio levels after  // all of the processing (AGC, AEC, etc.) for display in-world to the user.  class LLCustomProcessor : public webrtc::CustomProcessing  { -  public: -    LLCustomProcessor(); +public: +    LLCustomProcessor(LLCustomProcessorStatePtr state);      ~LLCustomProcessor() override {}      // (Re-) Initializes the submodule.      void Initialize(int sample_rate_hz, int num_channels) override;      // Analyzes the given capture or render signal. -    void Process(webrtc::AudioBuffer *audio) override; +    void Process(webrtc::AudioBuffer* audio) override;      // Returns a string representation of the module state.      std::string ToString() const override { return ""; } -    float getMicrophoneEnergy() { return mMicrophoneEnergy; } - -    void setGain(float gain) { mGain = gain; } - -  protected: -    static const int NUM_PACKETS_TO_FILTER = 30;  // 300 ms of smoothing -    int              mSampleRateHz; -    int              mNumChannels; +protected: +    static const int NUM_PACKETS_TO_FILTER = 30; // 300 ms of smoothing +    int              mSampleRateHz{ 48000 }; +    int              mNumChannels{ 2 }; +    int              mRampFrames{ 2 }; +    float            mCurrentGain{ 0.0f }; +    float            mGainStep{ 0.0f };      float mSumVector[NUM_PACKETS_TO_FILTER]; -    float mMicrophoneEnergy; -    float mGain; +    friend LLCustomProcessorState; +    LLCustomProcessorStatePtr mState;  }; @@ -187,7 +416,7 @@ class LLCustomProcessor : public webrtc::CustomProcessing  #if CM_WEBRTC  class LLWebRTCImpl : public LLWebRTCDeviceInterface  #else -class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceSink +class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceObserver  #endif  {    public: @@ -218,10 +447,15 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS      float getTuningAudioLevel() override;      float getPeerConnectionAudioLevel() override; -    void setPeerConnectionGain(float gain) override; +    void setMicGain(float gain) override; +    void setTuningMicGain(float gain) override; + +    void setMute(bool mute, int delay_ms = 20) override; + +    void intSetMute(bool mute, int delay_ms = 20);      // -    // AudioDeviceSink +    // AudioDeviceObserver      //  #if CM_WEBRTC      void OnDevicesUpdated(); @@ -254,19 +488,19 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS          mNetworkThread->PostTask(std::move(task), location);      } -    void WorkerBlockingCall(rtc::FunctionView<void()> functor, +    void WorkerBlockingCall(webrtc::FunctionView<void()> functor,                    const webrtc::Location& location = webrtc::Location::Current())      {          mWorkerThread->BlockingCall(std::move(functor), location);      } -    void SignalingBlockingCall(rtc::FunctionView<void()> functor, +    void SignalingBlockingCall(webrtc::FunctionView<void()> functor,                    const webrtc::Location& location = webrtc::Location::Current())      {          mSignalingThread->BlockingCall(std::move(functor), location);      } -    void NetworkBlockingCall(rtc::FunctionView<void()> functor, +    void NetworkBlockingCall(webrtc::FunctionView<void()> functor,                    const webrtc::Location& location = webrtc::Location::Current())      {          mNetworkThread->BlockingCall(std::move(functor), location); @@ -274,7 +508,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS      // Allows the LLWebRTCPeerConnectionImpl class to retrieve the      // native webrtc PeerConnectionFactory. -    rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> getPeerConnectionFactory() +    webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> getPeerConnectionFactory()      {          return mPeerConnectionFactory;      } @@ -283,49 +517,47 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS      LLWebRTCPeerConnectionInterface* newPeerConnection();      void freePeerConnection(LLWebRTCPeerConnectionInterface* peer_connection); -    // enables/disables capture via the capture device -    void setRecording(bool recording); - -    void setPlayout(bool playing); -    protected: + +    void workerDeployDevices();      LLWebRTCLogSink*                                           mLogSink;      // The native webrtc threads -    std::unique_ptr<rtc::Thread>                               mNetworkThread; -    std::unique_ptr<rtc::Thread>                               mWorkerThread; -    std::unique_ptr<rtc::Thread>                               mSignalingThread; +    std::unique_ptr<webrtc::Thread>                            mNetworkThread; +    std::unique_ptr<webrtc::Thread>                            mWorkerThread; +    std::unique_ptr<webrtc::Thread>                            mSignalingThread;      // The factory that allows creation of native webrtc PeerConnections. -    rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory; +    webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory; -    rtc::scoped_refptr<webrtc::AudioProcessing>                mAudioProcessingModule; +    webrtc::scoped_refptr<webrtc::AudioProcessing>                mAudioProcessingModule;      // more native webrtc stuff -    std::unique_ptr<webrtc::TaskQueueFactory>                  mTaskQueueFactory; +    std::unique_ptr<webrtc::TaskQueueFactory>                     mTaskQueueFactory;      // Devices      void updateDevices(); -    rtc::scoped_refptr<webrtc::AudioDeviceModule>              mTuningDeviceModule; -    rtc::scoped_refptr<webrtc::AudioDeviceModule>              mPeerDeviceModule; +    void deployDevices(); +    std::atomic<int>                                           mDevicesDeploying; +    webrtc::scoped_refptr<LLWebRTCAudioDeviceModule>           mDeviceModule;      std::vector<LLWebRTCDevicesObserver *>                     mVoiceDevicesObserverList;      // accessors in native webrtc for devices aren't apparently implemented yet.      bool                                                       mTuningMode; -    int32_t                                                    mRecordingDevice; +    std::string                                                mRecordingDevice;      LLWebRTCVoiceDeviceList                                    mRecordingDeviceList; -    int32_t                                                    mPlayoutDevice; +    std::string                                                mPlayoutDevice;      LLWebRTCVoiceDeviceList                                    mPlayoutDeviceList;      bool                                                       mMute; +    float                                                      mGain; -    LLAudioDeviceObserver *                                    mTuningAudioDeviceObserver; -    LLCustomProcessor *                                        mPeerCustomProcessor; +    LLCustomProcessorStatePtr                                  mPeerCustomProcessor;      // peer connections -    std::vector<rtc::scoped_refptr<LLWebRTCPeerConnectionImpl>>     mPeerConnections; +    std::vector<webrtc::scoped_refptr<LLWebRTCPeerConnectionImpl>> mPeerConnections;  }; @@ -350,7 +582,7 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,      void terminate();      virtual void AddRef() const override = 0; -    virtual rtc::RefCountReleaseStatus Release() const override = 0; +    virtual webrtc::RefCountReleaseStatus Release() const override = 0;      //      // LLWebRTCPeerConnection @@ -381,10 +613,10 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,      //      void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override {} -    void OnAddTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver, -                    const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>> &streams) override; -    void OnRemoveTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) override; -    void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> channel) override; +    void OnAddTrack(webrtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver, +                    const std::vector<webrtc::scoped_refptr<webrtc::MediaStreamInterface>> &streams) override; +    void OnRemoveTrack(webrtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) override; +    void OnDataChannel(webrtc::scoped_refptr<webrtc::DataChannelInterface> channel) override;      void OnRenegotiationNeeded() override {}      void OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) override {};      void OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) override; @@ -423,7 +655,7 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,      LLWebRTCImpl * mWebRTCImpl; -    rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory; +    webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory;      typedef enum {          MUTE_INITIAL, @@ -437,12 +669,12 @@ class LLWebRTCPeerConnectionImpl : public LLWebRTCPeerConnectionInterface,      std::vector<std::unique_ptr<webrtc::IceCandidateInterface>>  mCachedIceCandidates;      bool mAnswerReceived; -    rtc::scoped_refptr<webrtc::PeerConnectionInterface> mPeerConnection; -    rtc::scoped_refptr<webrtc::MediaStreamInterface> mLocalStream; +    webrtc::scoped_refptr<webrtc::PeerConnectionInterface> mPeerConnection; +    webrtc::scoped_refptr<webrtc::MediaStreamInterface> mLocalStream;      // data      std::vector<LLWebRTCDataObserver *> mDataObserverList; -    rtc::scoped_refptr<webrtc::DataChannelInterface> mDataChannel; +    webrtc::scoped_refptr<webrtc::DataChannelInterface> mDataChannel;  };  } diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 6debd54665..69f11991ea 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -108,7 +108,7 @@ if (DARWIN)        llkeyboardmacosx.cpp        llwindowmacosx.cpp        PROPERTIES -      COMPILE_FLAGS "-Wno-deprecated-declarations -fpascal-strings" +      COMPILE_FLAGS "-fpascal-strings"        )  endif (DARWIN) @@ -183,7 +183,6 @@ endif (SDL_FOUND)    target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})  if (DARWIN) -  find_library(CARBON_LIBRARY Carbon)    target_link_libraries(llwindow ${CARBON_LIBRARY})  endif (DARWIN) diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp index 387982dfc2..ff85b2cb14 100644 --- a/indra/llwindow/lldxhardware.cpp +++ b/indra/llwindow/lldxhardware.cpp @@ -312,7 +312,7 @@ std::string get_string(IDxDiagContainer *containerp, const WCHAR *wszPropName)      WCHAR wszPropValue[256];      get_wstring(containerp, wszPropName, wszPropValue, 256); -    return utf16str_to_utf8str(wszPropValue); +    return ll_convert<std::string>(std::wstring(wszPropValue));  }  LLDXHardware::LLDXHardware() @@ -440,7 +440,7 @@ LLSD LLDXHardware::getDisplayInfo()                      // print the value                      // windows doesn't guarantee to be null terminated                      release_version[RV_SIZE - 1] = NULL; -                    ret["DriverVersion"] = utf16str_to_utf8str(release_version); +                    ret["DriverVersion"] = ll_convert<std::string>(std::wstring(release_version));                  }                  RegCloseKey(hKey); diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h index 249c997340..a2c55a2dd9 100644 --- a/indra/llwindow/llopenglview-objc.h +++ b/indra/llwindow/llopenglview-objc.h @@ -42,7 +42,6 @@      unsigned int mMarkedTextLength;      bool mMarkedTextAllowed;      bool mSimulatedRightClick; -    bool mOldResize;      NSOpenGLPixelFormat *pixelFormat;      NSOpenGLContext *glContext; @@ -55,8 +54,6 @@  - (void)commitCurrentPreedit; -- (void) setOldResize:(bool)oldresize; -  // rebuildContext  // Destroys and recreates a context with the view's internal format set via setPixelFormat;  // Use this in event of needing to rebuild a context for whatever reason, without needing to assign a new pixel format. @@ -73,7 +70,6 @@  - (unsigned long) getVramSize;  - (void) allowMarkedTextInput:(bool)allowed; -- (void) viewDidEndLiveResize;  @end @@ -93,9 +89,6 @@  @interface LLNSWindow : NSWindow -- (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point relativeToView:(NSView *)view; -- (NSPoint)flipPoint:(NSPoint)aPoint; -  @end  @interface NSScreen (PointConversion) @@ -105,16 +98,6 @@   */  + (NSScreen *)currentScreenForMouseLocation; -/* - Allows you to convert a point from global coordinates to the current screen coordinates. - */ -- (NSPoint)convertPointToScreenCoordinates:(NSPoint)aPoint; - -/* - Allows to flip the point coordinates, so y is 0 at the top instead of the bottom. x remains the same - */ -- (NSPoint)flipPoint:(NSPoint)aPoint; -  @end  #endif diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm index 109c1d9b15..57b1252cf1 100644 --- a/indra/llwindow/llopenglview-objc.mm +++ b/indra/llwindow/llopenglview-objc.mm @@ -28,6 +28,8 @@  #import "llwindowmacosx-objc.h"  #import "llappdelegate-objc.h" +#import <Carbon/Carbon.h> +  extern BOOL gHiDPISupport;  extern BOOL gHDRDisplaySupport; @@ -65,16 +67,16 @@ attributedStringInfo getSegments(NSAttributedString *str)      segment_standouts seg_standouts;      NSRange effectiveRange;      NSRange limitRange = NSMakeRange(0, [str length]); -     +      while (limitRange.length > 0) {          NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];          limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange)); -         +          if (effectiveRange.length <= 0)          {              effectiveRange.length = 1;          } -         +          if ([attr integerValue] == 2)          {              seg_lengths.push_back(effectiveRange.length); @@ -97,27 +99,13 @@ attributedStringInfo getSegments(NSAttributedString *str)  + (NSScreen *)currentScreenForMouseLocation  {      NSPoint mouseLocation = [NSEvent mouseLocation]; -     +      NSEnumerator *screenEnumerator = [[NSScreen screens] objectEnumerator];      NSScreen *screen;      while ((screen = [screenEnumerator nextObject]) && !NSMouseInRect(mouseLocation, screen.frame, NO))          ; -     -    return screen; -} - - -- (NSPoint)convertPointToScreenCoordinates:(NSPoint)aPoint -{ -    float normalizedX = fabs(fabs(self.frame.origin.x) - fabs(aPoint.x)); -    float normalizedY = aPoint.y - self.frame.origin.y; -     -    return NSMakePoint(normalizedX, normalizedY); -} -- (NSPoint)flipPoint:(NSPoint)aPoint -{ -    return NSMakePoint(aPoint.x, self.frame.size.height - aPoint.y); +    return screen;  }  @end @@ -134,16 +122,6 @@ attributedStringInfo getSegments(NSAttributedString *str)      return pixelFormat;  } -// Force a high quality update after live resizing -- (void) viewDidEndLiveResize -{ -    if (mOldResize)  //Maint-3135 -    { -        NSSize size = [self frame].size; -        callResize(size.width, size.height); -    } -} -  - (unsigned long)getVramSize  {      CGLRendererInfoObj info = 0; @@ -164,7 +142,7 @@ attributedStringInfo getSegments(NSAttributedString *str)      {          vram_megabytes = 256;      } -     +  	return (unsigned long)vram_megabytes; // return value is in megabytes.  } @@ -189,15 +167,15 @@ attributedStringInfo getSegments(NSAttributedString *str)  	[[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowResized:) name:NSWindowDidResizeNotification  											   object:[self window]]; -     +      [[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowWillMiniaturize:) name:NSWindowWillMiniaturizeNotification  											   object:[self window]]; -     +      [[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification  											   object:[self window]]; -     +      [[NSNotificationCenter defaultCenter] addObserver:self  											 selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification  											   object:[self window]]; @@ -214,18 +192,10 @@ attributedStringInfo getSegments(NSAttributedString *str)      }  } -- (void)setOldResize:(bool)oldresize -{ -    mOldResize = oldresize; -} -  - (void)windowResized:(NSNotification *)notification;  { -    if (!mOldResize)  //Maint-3288 -    { -        NSSize dev_sz = gHiDPISupport ? [self convertSizeToBacking:[self frame].size] : [self frame].size; -        callResize(dev_sz.width, dev_sz.height); -    } +    NSSize dev_sz = [self convertSizeToBacking:[self frame].size]; +    callResize(dev_sz.width, dev_sz.height);  }  - (void)windowWillMiniaturize:(NSNotification *)notification; @@ -269,11 +239,17 @@ attributedStringInfo getSegments(NSAttributedString *str)  	return [self initWithFrame:[self bounds] withSamples:samples andVsync:vsync];  } +#if LL_DARWIN +// For setView and opengl deprecation +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  - (id) initWithFrame:(NSRect)frame withSamples:(NSUInteger)samples andVsync:(BOOL)vsync  { -	[self registerForDraggedTypes:[NSArray arrayWithObject:NSURLPboardType]]; +    [self registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypeURL]];  	[self initWithFrame:frame]; -	 +  	// Initialize with a default "safe" pixel format that will work with versions dating back to OS X 10.6.  	// Any specialized pixel formats, i.e. a core profile pixel format, should be initialized through rebuildContextWithFormat.  	// 10.7 and 10.8 don't really care if we're defining a profile or not.  If we don't explicitly request a core or legacy profile, it'll always assume a legacy profile (for compatibility reasons). @@ -291,8 +267,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  		NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,  		0      }; -	 -	 +      NSOpenGLPixelFormatAttribute HDRAttrs[] = {          NSOpenGLPFANoRecovery,          NSOpenGLPFADoubleBuffer, @@ -335,15 +310,15 @@ attributedStringInfo getSegments(NSAttributedString *str)  		NSLog(@"Failed to create pixel format!", nil);  		return nil;  	} -	 -	 +  	glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; +  	if (glContext == nil)  	{  		NSLog(@"Failed to create OpenGL context!", nil);  		return nil;  	} -	 +  	[self setPixelFormat:pixelFormat];      if(mHDRDisplay) @@ -363,28 +338,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  	[self setWantsBestResolutionOpenGLSurface:gHiDPISupport];  	[self setOpenGLContext:glContext]; -	 +  	[glContext setView:self]; -	 +  	[glContext makeCurrentContext]; -	 +  	if (vsync)  	{  		GLint value = 1; -		[glContext setValues:&value forParameter:NSOpenGLCPSwapInterval]; +        [glContext setValues:&value forParameter:NSOpenGLContextParameterSwapInterval];  	} else {  		// supress this error after move to Xcode 7:  		// error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]  		// Tried using ObjC 'nonnull' keyword as per SO article but didn't build  		GLint swapInterval=0; -		[glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; +        [glContext setValues:&swapInterval forParameter:NSOpenGLContextParameterSwapInterval];  	} -	 +      GLint opacity = 1;      [glContext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity]; -    mOldResize = false; -      	return self;  } @@ -396,22 +369,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (BOOL) rebuildContextWithFormat:(NSOpenGLPixelFormat *)format  {  	NSOpenGLContext *ctx = [self openGLContext]; -	 +  	[ctx clearDrawable];  	[ctx initWithFormat:format shareContext:nil]; -	 +  	if (ctx == nil)  	{  		NSLog(@"Failed to create OpenGL context!", nil);  		return false;  	} -	 +  	[self setOpenGLContext:ctx];  	[ctx setView:self];  	[ctx makeCurrentContext];  	return true;  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  - (CGLContextObj)getCGLContextObj  {  	NSOpenGLContext *ctx = [self openGLContext]; @@ -429,18 +406,14 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) mouseDown:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y; -      // Apparently people still use this? -    if ([theEvent modifierFlags] & NSCommandKeyMask && -        !([theEvent modifierFlags] & NSControlKeyMask) && -        !([theEvent modifierFlags] & NSShiftKeyMask) && -        !([theEvent modifierFlags] & NSAlternateKeyMask) && -        !([theEvent modifierFlags] & NSAlphaShiftKeyMask) && -        !([theEvent modifierFlags] & NSFunctionKeyMask) && -        !([theEvent modifierFlags] & NSHelpKeyMask)) +    if ([theEvent modifierFlags] & NSEventModifierFlagCommand && +        !([theEvent modifierFlags] & NSEventModifierFlagControl) && +        !([theEvent modifierFlags] & NSEventModifierFlagShift) && +        !([theEvent modifierFlags] & NSEventModifierFlagOption) && +        !([theEvent modifierFlags] & NSEventModifierFlagCapsLock) && +        !([theEvent modifierFlags] & NSEventModifierFlagFunction) && +        !([theEvent modifierFlags] & NSEventModifierFlagHelp))      {          callRightMouseDown(mMousePos, [theEvent modifierFlags]);          mSimulatedRightClick = true; @@ -461,7 +434,7 @@ attributedStringInfo getSegments(NSAttributedString *str)          callRightMouseUp(mMousePos, [theEvent modifierFlags]);          mSimulatedRightClick = false;      } else { -        NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; +        NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];          mMousePos[0] = mPoint.x;          mMousePos[1] = mPoint.y;          callLeftMouseUp(mMousePos, [theEvent modifierFlags]); @@ -470,32 +443,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) rightMouseDown:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;  	callRightMouseDown(mMousePos, [theEvent modifierFlags]);  }  - (void) rightMouseUp:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;  	callRightMouseUp(mMousePos, [theEvent modifierFlags]);  }  - (void)mouseMoved:(NSEvent *)theEvent  { -    NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]); +    NSPoint dev_delta = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])];  	float mouseDeltas[] = {  		float(dev_delta.x),  		float(dev_delta.y)  	}; -	 +  	callDeltaUpdate(mouseDeltas, 0); -	 -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; + +    NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];  	mMousePos[0] = mPoint.x;  	mMousePos[1] = mPoint.y;  	callMouseMoved(mMousePos, 0); @@ -510,16 +477,16 @@ attributedStringInfo getSegments(NSAttributedString *str)  	// The old CoreGraphics APIs we previously relied on are now flagged as obsolete.  	// NSEvent isn't obsolete, and provides us with the correct deltas. -    NSPoint dev_delta = gHiDPISupport ? [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])] : NSMakePoint([theEvent deltaX], [theEvent deltaY]); +    NSPoint dev_delta = [self convertPointToBacking:NSMakePoint([theEvent deltaX], [theEvent deltaY])];  	float mouseDeltas[] = {  		float(dev_delta.x),  		float(dev_delta.y)  	}; -	 +  	callDeltaUpdate(mouseDeltas, 0); -	 -	NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; + +	NSPoint mPoint = [self convertPointToBacking:[theEvent locationInWindow]];  	mMousePos[0] = mPoint.x;  	mMousePos[1] = mPoint.y;  	callMouseDragged(mMousePos, 0); @@ -527,17 +494,11 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) otherMouseDown:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;      callOtherMouseDown(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);  }  - (void) otherMouseUp:(NSEvent *)theEvent  { -    NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow]; -    mMousePos[0] = mPoint.x; -    mMousePos[1] = mPoint.y;      callOtherMouseUp(mMousePos, [theEvent modifierFlags], [theEvent buttonNumber]);  } @@ -548,7 +509,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) otherMouseDragged:(NSEvent *)theEvent  { -	[self mouseDragged:theEvent];         +	[self mouseDragged:theEvent];  }  - (void) scrollWheel:(NSEvent *)theEvent @@ -572,7 +533,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  {      NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);      eventData.mKeyEvent = NativeKeyEventData::KEYDOWN; -    +      uint keycode = [theEvent keyCode];      // We must not depend on flagsChange event to detect modifier flags changed,      // must depend on the modifire flags in the event parameter. @@ -590,7 +551,7 @@ attributedStringInfo getSegments(NSAttributedString *str)      if (acceptsText &&          !mMarkedTextAllowed && -        !(mModifiers & (NSControlKeyMask | NSCommandKeyMask)) &&  // commands don't invoke InputWindow +        !(mModifiers & (NSEventModifierFlagControl | NSEventModifierFlagCommand)) &&  // commands don't invoke InputWindow          ![(LLAppDelegate*)[NSApp delegate] romanScript] &&          ch > ' ' &&          ch != NSDeleteCharacter && @@ -606,26 +567,26 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void)flagsChanged:(NSEvent *)theEvent  {      NativeKeyEventData eventData = extractKeyDataFromModifierEvent(theEvent); -  +  	mModifiers = [theEvent modifierFlags];  	callModifier([theEvent modifierFlags]); -      +      NSInteger mask = 0;      switch([theEvent keyCode]) -    {         -        case 56: -            mask = NSShiftKeyMask; +    { +        case kVK_Shift: +            mask = NSEventModifierFlagShift;              break; -        case 58: -            mask = NSAlternateKeyMask; +        case kVK_Option: +            mask = NSEventModifierFlagOption;              break; -        case 59: -            mask = NSControlKeyMask; +        case kVK_Control: +            mask = NSEventModifierFlagControl;              break;          default: -            return;             +            return;      } -     +      if (mModifiers & mask)      {          eventData.mKeyEvent = NativeKeyEventData::KEYDOWN; @@ -644,7 +605,7 @@ attributedStringInfo getSegments(NSAttributedString *str)      {          eventData.mKeyEvent = NativeKeyEventData::KEYUP;          callKeyUp(&eventData, [theEvent keyCode], 0); -    }   +    }  }  - (BOOL) acceptsFirstResponder @@ -656,12 +617,12 @@ attributedStringInfo getSegments(NSAttributedString *str)  {  	NSPasteboard *pboard;      NSDragOperation sourceDragMask; -	 +  	sourceDragMask = [sender draggingSourceOperationMask]; -	 +  	pboard = [sender draggingPasteboard]; -	 -	if ([[pboard types] containsObject:NSURLPboardType]) + +    if ([[pboard types] containsObject:NSPasteboardTypeURL])  	{  		if (sourceDragMask & NSDragOperationLink) {  			NSURL *fileUrl = [[pboard readObjectsForClasses:[NSArray arrayWithObject:[NSURL class]] options:[NSDictionary dictionary]] objectAtIndex:0]; @@ -675,7 +636,7 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender  {  	callHandleDragUpdated(mLastDraggedUrl); -	 +  	return NSDragOperationLink;  } @@ -729,12 +690,12 @@ attributedStringInfo getSegments(NSAttributedString *str)              unsigned(selectedRange.location),              unsigned(selectedRange.length)          }; -         +          unsigned int replacement[2] = {              unsigned(replacementRange.location),              unsigned(replacementRange.length)          }; -         +          int string_length = [aString length];          unichar *text = new unichar[string_length];          attributedStringInfo segments; @@ -774,6 +735,12 @@ attributedStringInfo getSegments(NSAttributedString *str)      }  } +#if LL_DARWIN +// For commitEditing deprecation +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  - (void)commitCurrentPreedit  {      if (mHasMarkedText) @@ -785,6 +752,10 @@ attributedStringInfo getSegments(NSAttributedString *str)      }  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  - (void)unmarkText  {  	[[self inputContext] discardMarkedText]; @@ -835,7 +806,7 @@ attributedStringInfo getSegments(NSAttributedString *str)              return;          }  	} -     +      @try      {          if (!mHasMarkedText) @@ -848,7 +819,7 @@ attributedStringInfo getSegments(NSAttributedString *str)              resetPreedit();              // We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text.              // But just in case... -             +              for (NSInteger i = 0; i < [aString length]; i++)              {                  handleUnicodeCharacter([aString characterAtIndex:i]); @@ -864,9 +835,9 @@ attributedStringInfo getSegments(NSAttributedString *str)  - (void) insertNewline:(id)sender  { -	if (!(mModifiers & NSCommandKeyMask) && -		!(mModifiers & NSShiftKeyMask) && -		!(mModifiers & NSAlternateKeyMask)) +    if (!(mModifiers & NSEventModifierFlagCommand) && +        !(mModifiers & NSEventModifierFlagShift) && +        !(mModifiers & NSEventModifierFlagOption))  	{  		callUnicodeCallback(13, 0);  	} else { @@ -985,27 +956,6 @@ attributedStringInfo getSegments(NSAttributedString *str)  	return self;  } -- (NSPoint)convertToScreenFromLocalPoint:(NSPoint)point relativeToView:(NSView *)view -{ -	NSScreen *currentScreen = [NSScreen currentScreenForMouseLocation]; -	if(currentScreen) -	{ -		NSPoint windowPoint = [view convertPoint:point toView:nil]; -		NSPoint screenPoint = [[view window] convertBaseToScreen:windowPoint]; -		NSPoint flippedScreenPoint = [currentScreen flipPoint:screenPoint]; -		flippedScreenPoint.y += [currentScreen frame].origin.y; -		 -		return flippedScreenPoint; -	} -	 -	return NSZeroPoint; -} - -- (NSPoint)flipPoint:(NSPoint)aPoint -{ -    return NSMakePoint(aPoint.x, self.frame.size.height - aPoint.y); -} -  - (BOOL) becomeFirstResponder  {  	callFocus(); diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 0514f63830..8f8ea7fdb6 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -147,7 +147,6 @@ public:      virtual void swapBuffers() = 0;      virtual void bringToFront() = 0;      virtual void focusClient() { };     // this may not have meaning or be required on other platforms, therefore, it's not abstract -    virtual void setOldResize(bool oldresize) { };      // handy coordinate space conversion routines      // NB: screen to window and vice verse won't work on width/height coordinate pairs,      // as the conversion must take into account left AND right border widths, etc. diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h index d9d8bfce1f..b302a705da 100644 --- a/indra/llwindow/llwindowmacosx-objc.h +++ b/indra/llwindow/llwindowmacosx-objc.h @@ -100,7 +100,6 @@ bool isCGCursorVisible();  void hideNSCursorTillMove(bool hide);  void requestUserAttention();  long showAlert(std::string title, std::string text, int type); -void setResizeMode(bool oldresize, void* glview);  NSWindowRef createNSWindow(int x, int y, int width, int height); @@ -111,16 +110,14 @@ void glSwapBuffers(void* context);  CGLContextObj getCGLContextObj(GLViewRef view);  unsigned long getVramSize(GLViewRef view);  float getDeviceUnitSize(GLViewRef view); -CGPoint getContentViewBoundsPosition(NSWindowRef window); -CGSize getContentViewBoundsSize(NSWindowRef window); -CGSize getDeviceContentViewSize(NSWindowRef window, GLViewRef view); +CGRect getContentViewRect(NSWindowRef window); +CGRect getBackingViewRect(NSWindowRef window, GLViewRef view);  void getWindowSize(NSWindowRef window, float* size);  void setWindowSize(NSWindowRef window, int width, int height);  void getCursorPos(NSWindowRef window, float* pos);  void makeWindowOrderFront(NSWindowRef window);  void convertScreenToWindow(NSWindowRef window, float *coord);  void convertWindowToScreen(NSWindowRef window, float *coord); -void convertScreenToView(NSWindowRef window, float *coord);  void convertRectToScreen(NSWindowRef window, float *coord);  void convertRectFromScreen(NSWindowRef window, float *coord);  void setWindowPos(NSWindowRef window, float* pos); diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm index 2e75d309ea..42cd95be5d 100644 --- a/indra/llwindow/llwindowmacosx-objc.mm +++ b/indra/llwindow/llwindowmacosx-objc.mm @@ -162,11 +162,21 @@ void showNSCursor()  	[NSCursor unhide];  } +#if LL_DARWIN +// For CGCursorIsVisible no replacement in modern API +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  bool isCGCursorVisible()  {      return CGCursorIsVisible();  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  void hideNSCursorTillMove(bool hide)  {  	[NSCursor setHiddenUntilMouseMoves:hide]; @@ -213,7 +223,8 @@ OSErr setImageCursor(CursorRef ref)  NSWindowRef createNSWindow(int x, int y, int width, int height)  {  	LLNSWindow *window = [[LLNSWindow alloc]initWithContentRect:NSMakeRect(x, y, width, height) -													  styleMask:NSTitledWindowMask | NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTexturedBackgroundWindowMask backing:NSBackingStoreBuffered defer:NO]; +                                                      styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskResizable | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable +                                                        backing:NSBackingStoreBuffered defer:NO];  	[window makeKeyAndOrderFront:nil];  	[window setAcceptsMouseMovedEvents:TRUE];      [window setRestorable:FALSE]; // Viewer manages state from own settings @@ -227,11 +238,6 @@ GLViewRef createOpenGLView(NSWindowRef window, unsigned int samples, bool vsync)  	return glview;  } -void setResizeMode(bool oldresize, void* glview) -{ -    [(LLOpenGLView *)glview setOldResize:oldresize]; -} -  void glSwapBuffers(void* context)  {  	[(NSOpenGLContext*)context flushBuffer]; @@ -258,19 +264,14 @@ float getDeviceUnitSize(GLViewRef view)  	return [(LLOpenGLView*)view convertSizeToBacking:NSMakeSize(1, 1)].width;  } -CGPoint getContentViewBoundsPosition(NSWindowRef window) +CGRect getContentViewRect(NSWindowRef window)  { -	return [[(LLNSWindow*)window contentView] bounds].origin; +    return [[(LLNSWindow*)window contentView] bounds];  } -CGSize getContentViewBoundsSize(NSWindowRef window) +CGRect getBackingViewRect(NSWindowRef window, GLViewRef view)  { -	return [[(LLNSWindow*)window contentView] bounds].size; -} - -CGSize getDeviceContentViewSize(NSWindowRef window, GLViewRef view) -{ -    return [(NSOpenGLView*)view convertRectToBacking:[[(LLNSWindow*)window contentView] bounds]].size; +    return [(NSOpenGLView*)view convertRectToBacking:[[(LLNSWindow*)window contentView] bounds]];  }  void getWindowSize(NSWindowRef window, float* size) @@ -313,9 +314,7 @@ void makeWindowOrderFront(NSWindowRef window)  void convertScreenToWindow(NSWindowRef window, float *coord)  { -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; +    NSRect point = NSMakeRect(coord[0], coord[1], 0,0);  	point = [(LLNSWindow*)window convertRectFromScreen:point];  	coord[0] = point.origin.x;  	coord[1] = point.origin.y; @@ -323,28 +322,18 @@ void convertScreenToWindow(NSWindowRef window, float *coord)  void convertRectToScreen(NSWindowRef window, float *coord)  { -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; -	point.size.width = coord[2]; -	point.size.height = coord[3]; -	 -	point = [(LLNSWindow*)window convertRectToScreen:point]; -	 -	coord[0] = point.origin.x; -	coord[1] = point.origin.y; -	coord[2] = point.size.width; -	coord[3] = point.size.height; +    NSRect rect = NSMakeRect(coord[0], coord[1], coord[2], coord[3]);; +    rect = [(LLNSWindow*)window convertRectToScreen:rect]; + +	coord[0] = rect.origin.x; +	coord[1] = rect.origin.y; +	coord[2] = rect.size.width; +	coord[3] = rect.size.height;  }  void convertRectFromScreen(NSWindowRef window, float *coord)  { -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; -	point.size.width = coord[2]; -	point.size.height = coord[3]; -	 +	NSRect point = NSMakeRect(coord[0], coord[1], coord[2], coord[3]);  	point = [(LLNSWindow*)window convertRectFromScreen:point];  	coord[0] = point.origin.x; @@ -353,23 +342,13 @@ void convertRectFromScreen(NSWindowRef window, float *coord)  	coord[3] = point.size.height;  } -void convertScreenToView(NSWindowRef window, float *coord) -{ -	NSRect point; -	point.origin.x = coord[0]; -	point.origin.y = coord[1]; -	point.origin = [(LLNSWindow*)window convertScreenToBase:point.origin]; -	point.origin = [[(LLNSWindow*)window contentView] convertPoint:point.origin fromView:nil]; -} -  void convertWindowToScreen(NSWindowRef window, float *coord)  { -	NSPoint point; -	point.x = coord[0]; -	point.y = coord[1]; -	point = [(LLNSWindow*)window convertToScreenFromLocalPoint:point relativeToView:[(LLNSWindow*)window contentView]]; -	coord[0] = point.x; -	coord[1] = point.y; +    NSRect rect = NSMakeRect(coord[0], coord[1], 0, 0); +    rect = [(LLNSWindow*)window convertRectToScreen:rect]; + +      coord[0] = rect.origin.x; +    coord[1] = [[NSScreen screens][0] frame].size.height - rect.origin.y;  }  void closeWindow(NSWindowRef window) diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp index 3aca4660f3..3ed935c0f2 100644 --- a/indra/llwindow/llwindowmacosx.cpp +++ b/indra/llwindow/llwindowmacosx.cpp @@ -986,7 +986,7 @@ bool LLWindowMacOSX::getPosition(LLCoordScreen *position)      }      else if(mWindow)      { -        const CGPoint & pos = getContentViewBoundsPosition(mWindow); +        CGPoint pos = getContentViewRect(mWindow).origin;          position->mX = pos.x;          position->mY = pos.y; @@ -1013,7 +1013,7 @@ bool LLWindowMacOSX::getSize(LLCoordScreen *size)      }      else if(mWindow)      { -        const CGSize & sz = gHiDPISupport ? getDeviceContentViewSize(mWindow, mGLView) : getContentViewBoundsSize(mWindow); +        CGSize sz = getBackingViewRect(mWindow, mGLView).size;          size->mX = sz.width;          size->mY = sz.height; @@ -1039,7 +1039,7 @@ bool LLWindowMacOSX::getSize(LLCoordWindow *size)      }      else if(mWindow)      { -        const CGSize & sz = gHiDPISupport ? getDeviceContentViewSize(mWindow, mGLView) : getContentViewBoundsSize(mWindow); +        CGSize sz = getBackingViewRect(mWindow, mGLView).size;          size->mX = sz.width;          size->mY = sz.height; @@ -1225,6 +1225,12 @@ void LLWindowMacOSX::setMouseClipping( bool b )      adjustCursorDecouple();  } +#if LL_DARWIN +// For CGSetLocalEventsSuppressionInterval there is no replacement in modern API +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif +  bool LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)  {      bool result = false; @@ -1262,6 +1268,10 @@ bool LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)      return result;  } +#if LL_DARWIN +#pragma clang diagnostic pop +#endif +  bool LLWindowMacOSX::getCursorPosition(LLCoordWindow *position)  {      float cursor_point[2]; @@ -1486,8 +1496,9 @@ bool LLWindowMacOSX::convertCoords(LLCoordScreen from, LLCoordWindow* to)          convertScreenToWindow(mWindow, mouse_point); -        to->mX = mouse_point[0]; -        to->mY = mouse_point[1]; +        float scale_factor = getSystemUISize(); +        to->mX = mouse_point[0] * scale_factor; +        to->mY = mouse_point[1] * scale_factor;          return true;      } @@ -1499,9 +1510,9 @@ bool LLWindowMacOSX::convertCoords(LLCoordWindow from, LLCoordScreen *to)      if(mWindow)      {          float mouse_point[2]; - -        mouse_point[0] = from.mX; -        mouse_point[1] = from.mY; +        float scale_factor = getSystemUISize(); +        mouse_point[0] = from.mX / scale_factor; +        mouse_point[1] = from.mY / scale_factor;          convertWindowToScreen(mWindow, mouse_point); @@ -2638,7 +2649,7 @@ MASK LLWindowMacOSX::modifiersToMask(S16 modifiers)  F32 LLWindowMacOSX::getSystemUISize()  { -    return gHiDPISupport ? ::getDeviceUnitSize(mGLView) : LLWindow::getSystemUISize(); +    return ::getDeviceUnitSize(mGLView);  }  #if LL_OS_DRAGDROP_ENABLED diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h index 7de1a40d93..110c5756d0 100644 --- a/indra/llwindow/llwindowmacosx.h +++ b/indra/llwindow/llwindowmacosx.h @@ -174,9 +174,6 @@ protected:      bool    shouldPostQuit() { return mPostQuit; } -    //Satisfy MAINT-3135 and MAINT-3288 with a flag. -    /*virtual */ void setOldResize(bool oldresize) override {setResizeMode(oldresize, mGLView); } -  private:      void restoreGLContext(); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 03cc10e5d6..cfc2038be9 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -812,7 +812,7 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,      //  }      // SL-12971 dual GPU display -    DISPLAY_DEVICEA display_device; +    DISPLAY_DEVICE display_device;      int             display_index = -1;      DWORD           display_flags = 0; // EDD_GET_DEVICE_INTERFACE_NAME ?      const size_t    display_bytes = sizeof(display_device); @@ -823,23 +823,23 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,          {              // CHAR DeviceName  [ 32] Adapter name              // CHAR DeviceString[128] -            CHAR text[256]; +            WCHAR text[256]; -            size_t name_len = strlen(display_device.DeviceName  ); -            size_t desc_len = strlen(display_device.DeviceString); +            size_t name_len = lstrlen(display_device.DeviceName  ); +            size_t desc_len = lstrlen(display_device.DeviceString); -            const CHAR *name = name_len ? display_device.DeviceName   : "???"; -            const CHAR *desc = desc_len ? display_device.DeviceString : "???"; +            const WCHAR *name = name_len ? display_device.DeviceName   : TEXT("???"); +            const WCHAR *desc = desc_len ? display_device.DeviceString : TEXT("???"); -            sprintf(text, "Display Device %d: %s, %s", display_index, name, desc); -            LL_INFOS("Window") << text << LL_ENDL; +            wsprintf(text, TEXT("Display Device %d: %s, %s"), display_index, name, desc); +            LL_INFOS("Window") << ll_convert<std::string>(std::wstring(text)) << LL_ENDL;          }          ::ZeroMemory(&display_device,display_bytes);          display_device.cb = display_bytes;          display_index++; -    }  while( EnumDisplayDevicesA(NULL, display_index, &display_device, display_flags )); +    }  while( EnumDisplayDevices(NULL, display_index, &display_device, display_flags ));      LL_INFOS("Window") << "Total Display Devices: " << display_index << LL_ENDL; @@ -1698,6 +1698,11 @@ const   S32   max_format  = (S32)num_formats - 1;          return false;      } +    // Setup Tracy gpu context +    { +        LL_PROFILER_GPU_CONTEXT; +    } +      // Disable vertical sync for swap      toggleVSync(enable_vsync); @@ -1729,8 +1734,6 @@ const   S32   max_format  = (S32)num_formats - 1;          swapBuffers();      } -    LL_PROFILER_GPU_CONTEXT; -      return true;  } @@ -1963,7 +1966,7 @@ void LLWindowWin32::setTitle(const std::string title)      // to support non-ascii usernames (and region names?)      mWindowThread->post([=]()          { -            SetWindowTextA(mWindowHandle, title.c_str()); +            SetWindowText(mWindowHandle, ll_convert<std::wstring>(title).c_str());          });  } @@ -3288,7 +3291,7 @@ bool LLWindowWin32::pasteTextFromClipboard(LLWString &dst)                  WCHAR *utf16str = (WCHAR*) GlobalLock(h_data);                  if (utf16str)                  { -                    dst = utf16str_to_wstring(utf16str); +                    dst = ll_convert<LLWString>(std::wstring(utf16str));                      LLWStringUtil::removeWindowsCR(dst);                      GlobalUnlock(h_data);                      success = true; @@ -3313,8 +3316,8 @@ bool LLWindowWin32::copyTextToClipboard(const LLWString& wstr)          // Provide a copy of the data in Unicode format.          LLWString sanitized_string(wstr);          LLWStringUtil::addCRLF(sanitized_string); -        llutf16string out_utf16 = wstring_to_utf16str(sanitized_string); -        const size_t size_utf16 = (out_utf16.length() + 1) * sizeof(WCHAR); +        std::wstring out_utf16 = ll_convert<std::wstring>(sanitized_string); +        const size_t size_utf16 = (out_utf16.length() + 1) * sizeof(wchar_t);          // Memory is allocated and then ownership of it is transfered to the system.          HGLOBAL hglobal_copy_utf16 = GlobalAlloc(GMEM_MOVEABLE, size_utf16); @@ -3674,7 +3677,7 @@ void LLSplashScreenWin32::showImpl()      ShowWindow(mWindow, SW_SHOW);      // Should set taskbar text without creating a header for the window (caption) -    SetWindowTextA(mWindow, "Second Life"); +    SetWindowText(mWindow, TEXT("Second Life"));  } @@ -3811,8 +3814,7 @@ void LLWindowWin32::spawnWebBrowser(const std::string& escaped_url, bool async)      // reliablly on Vista.      // this is madness.. no, this is.. -    LLWString url_wstring = utf8str_to_wstring( escaped_url ); -    llutf16string url_utf16 = wstring_to_utf16str( url_wstring ); +    std::wstring url_utf16 = ll_convert<std::wstring>(escaped_url);      // let the OS decide what to use to open the URL      SHELLEXECUTEINFO sei = { sizeof( sei ) }; @@ -4100,7 +4102,7 @@ void LLWindowWin32::fillCompositionLogfont(LOGFONT *logfont)  U32 LLWindowWin32::fillReconvertString(const LLWString &text,      S32 focus, S32 focus_length, RECONVERTSTRING *reconvert_string)  { -    const llutf16string text_utf16 = wstring_to_utf16str(text); +    const std::wstring text_utf16 = ll_convert<std::wstring>(text);      const DWORD required_size = sizeof(RECONVERTSTRING) + (static_cast<DWORD>(text_utf16.length()) + 1) * sizeof(WCHAR);      if (reconvert_string && reconvert_string->dwSize >= required_size)      { @@ -4200,7 +4202,7 @@ void LLWindowWin32::handleCompositionMessage(const U32 indexes)              size = LLWinImm::getCompositionString(himc, GCS_RESULTSTR, data, size);              if (size > 0)              { -                result_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); +                result_string = ll_convert_wide_to_wstring(std::wstring(data, size / sizeof(WCHAR)));              }              delete[] data;              needs_update = true; @@ -4217,7 +4219,7 @@ void LLWindowWin32::handleCompositionMessage(const U32 indexes)              if (size > 0)              {                  preedit_string_utf16_length = size / sizeof(WCHAR); -                preedit_string = utf16str_to_wstring(llutf16string(data, size / sizeof(WCHAR))); +                preedit_string = ll_convert_wide_to_wstring(std::wstring(data, size / sizeof(WCHAR)));              }              delete[] data;              needs_update = true; diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp index 8a2c36a307..16860ab8b8 100644 --- a/indra/llxml/llxmlnode.cpp +++ b/indra/llxml/llxmlnode.cpp @@ -1285,7 +1285,7 @@ bool LLXMLNode::getAttributeU8(const char* name, U8& value )  bool LLXMLNode::getAttributeS8(const char* name, S8& value )  {      LLXMLNodePtr node; -    S32 val; +    S32 val{};      if (!(getAttribute(name, node) && node->getIntValue(1, &val)))      {          return false; @@ -1297,7 +1297,7 @@ bool LLXMLNode::getAttributeS8(const char* name, S8& value )  bool LLXMLNode::getAttributeU16(const char* name, U16& value )  {      LLXMLNodePtr node; -    U32 val; +    U32 val{};      if (!(getAttribute(name, node) && node->getUnsignedValue(1, &val)))      {          return false; @@ -1309,7 +1309,7 @@ bool LLXMLNode::getAttributeU16(const char* name, U16& value )  bool LLXMLNode::getAttributeS16(const char* name, S16& value )  {      LLXMLNodePtr node; -    S32 val; +    S32 val{};      if (!(getAttribute(name, node) && node->getIntValue(1, &val)))      {          return false; diff --git a/indra/media_plugins/base/CMakeLists.txt b/indra/media_plugins/base/CMakeLists.txt index 57e3782ada..b98617cc4f 100644 --- a/indra/media_plugins/base/CMakeLists.txt +++ b/indra/media_plugins/base/CMakeLists.txt @@ -28,5 +28,5 @@ add_library(media_plugin_base      ${media_plugin_base_SOURCE_FILES}          ) -target_link_libraries( media_plugin_base llplugin ) +target_link_libraries( media_plugin_base llplugin ll::pluginlibraries)  target_include_directories( media_plugin_base  INTERFACE   ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/indra/media_plugins/base/media_plugin_base.cpp b/indra/media_plugins/base/media_plugin_base.cpp index d54e67c532..2d55f99dbe 100644 --- a/indra/media_plugins/base/media_plugin_base.cpp +++ b/indra/media_plugins/base/media_plugin_base.cpp @@ -220,10 +220,8 @@ void SymbolGrabber::ungrabSymbols()  #if LL_WINDOWS  # define LLSYMEXPORT __declspec(dllexport) -#elif LL_LINUX || __FreeBSD__ -# define LLSYMEXPORT __attribute__ ((visibility("default")))  #else -# define LLSYMEXPORT /**/ +# define LLSYMEXPORT __attribute__ ((visibility("default")))  #endif  extern "C" diff --git a/indra/media_plugins/cef/CMakeLists.txt b/indra/media_plugins/cef/CMakeLists.txt index 4803b475c5..539bb4e562 100644 --- a/indra/media_plugins/cef/CMakeLists.txt +++ b/indra/media_plugins/cef/CMakeLists.txt @@ -105,7 +105,7 @@ if (DARWIN)      PROPERTIES      PREFIX ""      BUILD_WITH_INSTALL_RPATH 1 -    INSTALL_NAME_DIR "@executable_path" +    INSTALL_RPATH "@executable_path/../Frameworks"      LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base/media_plugin_base.exp"    ) @@ -147,6 +147,7 @@ if (INSTALL)          install(              DIRECTORY                  "${ARCH_PREBUILT_DIRS_RELEASE}/DullahanHelper.app" +                "${ARCH_PREBUILT_DIRS_RELEASE}/DullahanHelper (Alerts).app"                  "${ARCH_PREBUILT_DIRS_RELEASE}/DullahanHelper (GPU).app"                  "${ARCH_PREBUILT_DIRS_RELEASE}/DullahanHelper (Plugin).app"                  "${ARCH_PREBUILT_DIRS_RELEASE}/DullahanHelper (Renderer).app" diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp index 9c205b558c..5693420bb6 100644 --- a/indra/media_plugins/cef/media_plugin_cef.cpp +++ b/indra/media_plugins/cef/media_plugin_cef.cpp @@ -38,6 +38,13 @@  #include "volume_catcher.h"  #include "media_plugin_base.h" +// _getpid()/getpid() +#if LL_WINDOWS +#include <process.h> +#else +#include <unistd.h> +#endif +  #include "dullahan.h"  //////////////////////////////////////////////////////////////////////////////// @@ -64,7 +71,7 @@ private:      void onLoadStartCallback();      void onRequestExitCallback();      void onLoadEndCallback(int httpStatusCode, std::string url); -    void onLoadError(int status, const std::string error_text); +    void onLoadError(int status, const std::string error_text, const std::string error_url);      void onAddressChangeCallback(std::string url);      void onOpenPopupCallback(std::string url, std::string target);      bool onHTTPAuthCallback(const std::string host, const std::string realm, std::string& username, std::string& password); @@ -99,12 +106,14 @@ private:      std::string mAuthUsername;      std::string mAuthPassword;      bool mAuthOK; +    bool mCanUndo; +    bool mCanRedo;      bool mCanCut;      bool mCanCopy;      bool mCanPaste; +    bool mCanDelete; +    bool mCanSelectAll;      std::string mRootCachePath; -    std::string mCachePath; -    std::string mContextCachePath;      std::string mCefLogFile;      bool mCefLogVerbose;      std::vector<std::string> mPickedFiles; @@ -139,10 +148,13 @@ MediaPluginBase(host_send_func, host_user_data)      mAuthUsername = "";      mAuthPassword = "";      mAuthOK = false; +    mCanUndo = false; +    mCanRedo = false;      mCanCut = false;      mCanCopy = false;      mCanPaste = false; -    mCachePath = ""; +    mCanDelete = false; +    mCanSelectAll = false;      mCefLogFile = "";      mCefLogVerbose = false;      mPickedFiles.clear(); @@ -242,15 +254,17 @@ void MediaPluginCEF::onLoadStartCallback()  /////////////////////////////////////////////////////////////////////////////////  // -void MediaPluginCEF::onLoadError(int status, const std::string error_text) +void MediaPluginCEF::onLoadError(int status, const std::string error_text, const std::string error_url)  {      std::stringstream msg; -    msg << "<b>Loading error!</b>"; +    msg << "<b>Loading error</b>"; +    msg << "<p>"; +    msg << "Error message: " << error_text;      msg << "<p>"; -    msg << "Message: " << error_text; -    msg << "<br>"; -    msg << "Code: " << status; +    msg << "Error URL: <tt>" << error_url << "</tt>"; +    msg << "<p>"; +    msg << "Error code: " << status;      mCEFLib->showBrowserMessage(msg.str());  } @@ -607,7 +621,12 @@ void MediaPluginCEF::receiveMessage(const char* message_string)                  mCEFLib->setOnTooltipCallback(std::bind(&MediaPluginCEF::onTooltipCallback, this, std::placeholders::_1));                  mCEFLib->setOnLoadStartCallback(std::bind(&MediaPluginCEF::onLoadStartCallback, this));                  mCEFLib->setOnLoadEndCallback(std::bind(&MediaPluginCEF::onLoadEndCallback, this, std::placeholders::_1, std::placeholders::_2)); -                mCEFLib->setOnLoadErrorCallback(std::bind(&MediaPluginCEF::onLoadError, this, std::placeholders::_1, std::placeholders::_2)); + +                // CEF 139 seems to have introduced a loading failure at the login page (only?) I haven't seen it on +                // any other page and it only happens about 1 in 8 times. Without this handler for the error page +                // (red box, error message/code/url) the page load recovers after display a brief built in error. +                // Not ideal but better than stopping altgoether. Will restore this once I discover the error. +                //mCEFLib->setOnLoadErrorCallback(std::bind(&MediaPluginCEF::onLoadError, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));                  mCEFLib->setOnAddressChangeCallback(std::bind(&MediaPluginCEF::onAddressChangeCallback, this, std::placeholders::_1));                  mCEFLib->setOnOpenPopupCallback(std::bind(&MediaPluginCEF::onOpenPopupCallback, this, std::placeholders::_1, std::placeholders::_2));                  mCEFLib->setOnHTTPAuthCallback(std::bind(&MediaPluginCEF::onHTTPAuthCallback, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); @@ -635,10 +654,7 @@ void MediaPluginCEF::receiveMessage(const char* message_string)                  // and set it to white                  settings.background_color = 0xffffffff; // white -                settings.cache_enabled = true;                  settings.root_cache_path = mRootCachePath; -                settings.cache_path = mCachePath; -                settings.context_cache_path = mContextCachePath;                  settings.cookies_enabled = mCookiesEnabled;                  // configure proxy argument if enabled and valid @@ -729,23 +745,32 @@ void MediaPluginCEF::receiveMessage(const char* message_string)                  std::string user_data_path_cache = message_in.getValue("cache_path");                  std::string subfolder = message_in.getValue("username"); -                mRootCachePath = user_data_path_cache + "cef_cache"; -                if (!subfolder.empty()) -                { -                    std::string delim; +                // media plugin doesn't have access to gDirUtilp +                std::string path_separator;  #if LL_WINDOWS -                    // media plugin doesn't have access to gDirUtilp -                    delim = "\\"; +                path_separator = "\\";  #else -                    delim = "/"; +                path_separator = "/";  #endif -                    mCachePath = mRootCachePath + delim + subfolder; -                } -                else -                { -                    mCachePath = mRootCachePath; -                } -                mContextCachePath = ""; // disabled by "" + +                mRootCachePath = user_data_path_cache + "cef_cache"; + +                // Issue #4498 Introduce an additional sub-folder underneath the main cache +                // folder so that each CEF media instance gets its own (as per the CEF API +                // official position). These folders will be removed at startup by Viewer code +                // so that their non-trivial size does not exhaust available disk space. This +                // begs the question - why turn on the cache at all? There are 2 reasons - firstly +                // some of the instances will benefit from per Viewer session caching and will +                // use the injected SL cookie and secondly, it's not clear how having no cache +                // interacts with the multiple simultaneous paradigm we use. +                mRootCachePath += path_separator; +# if LL_WINDOWS +                mRootCachePath += std::to_string(_getpid()); +# else +                mRootCachePath += std::to_string(getpid()); +# endif + +                  mCefLogFile = message_in.getValue("cef_log_file");                  mCefLogVerbose = message_in.getValueBoolean("cef_verbose_log");              } @@ -930,6 +955,14 @@ void MediaPluginCEF::receiveMessage(const char* message_string)              {                  authResponse(message_in);              } +            if (message_name == "edit_undo") +            { +                mCEFLib->editUndo(); +            } +            if (message_name == "edit_redo") +            { +                mCEFLib->editRedo(); +            }              if (message_name == "edit_cut")              {                  mCEFLib->editCut(); @@ -942,6 +975,18 @@ void MediaPluginCEF::receiveMessage(const char* message_string)              {                  mCEFLib->editPaste();              } +            if (message_name == "edit_delete") +            { +                mCEFLib->editDelete(); +            } +            if (message_name == "edit_select_all") +            { +                mCEFLib->editSelectAll(); +            } +            if (message_name == "edit_show_source") +            { +                mCEFLib->viewSource(); +            }          }          else if (message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER)          { @@ -1125,14 +1170,31 @@ void MediaPluginCEF::unicodeInput(std::string event, LLSD native_key_data = LLSD  //  void MediaPluginCEF::checkEditState()  { +    bool can_undo = mCEFLib->editCanUndo(); +    bool can_redo = mCEFLib->editCanRedo();      bool can_cut = mCEFLib->editCanCut();      bool can_copy = mCEFLib->editCanCopy();      bool can_paste = mCEFLib->editCanPaste(); +    bool can_delete = mCEFLib->editCanDelete(); +    bool can_select_all = mCEFLib->editCanSelectAll(); -    if ((can_cut != mCanCut) || (can_copy != mCanCopy) || (can_paste != mCanPaste)) +    if ((can_undo != mCanUndo) || (can_redo != mCanRedo) || (can_cut != mCanCut) || (can_copy != mCanCopy) +        || (can_paste != mCanPaste) || (can_delete != mCanDelete) || (can_select_all != mCanSelectAll))      {          LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "edit_state"); +        if (can_undo != mCanUndo) +        { +            mCanUndo = can_undo; +            message.setValueBoolean("undo", can_undo); +        } + +        if (can_redo != mCanRedo) +        { +            mCanRedo = can_redo; +            message.setValueBoolean("redo", can_redo); +        } +          if (can_cut != mCanCut)          {              mCanCut = can_cut; @@ -1151,6 +1213,18 @@ void MediaPluginCEF::checkEditState()              message.setValueBoolean("paste", can_paste);          } +        if (can_delete != mCanDelete) +        { +            mCanDelete = can_delete; +            message.setValueBoolean("delete", can_delete); +        } + +        if (can_select_all != mCanSelectAll) +        { +            mCanSelectAll = can_select_all; +            message.setValueBoolean("select_all", can_select_all); +        } +          sendMessage(message);      }  } diff --git a/indra/media_plugins/example/CMakeLists.txt b/indra/media_plugins/example/CMakeLists.txt index 71343d5f85..be8ffe5a40 100644 --- a/indra/media_plugins/example/CMakeLists.txt +++ b/indra/media_plugins/example/CMakeLists.txt @@ -39,7 +39,7 @@ if (DARWIN)      PROPERTIES      PREFIX ""      BUILD_WITH_INSTALL_RPATH 1 -    INSTALL_NAME_DIR "@executable_path" +    INSTALL_RPATH "@executable_path/../Frameworks"      LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base/media_plugin_base.exp"    ) diff --git a/indra/media_plugins/libvlc/CMakeLists.txt b/indra/media_plugins/libvlc/CMakeLists.txt index 1919f54a82..7c69a3ea58 100644 --- a/indra/media_plugins/libvlc/CMakeLists.txt +++ b/indra/media_plugins/libvlc/CMakeLists.txt @@ -43,7 +43,7 @@ if (DARWIN)      PROPERTIES      PREFIX ""      BUILD_WITH_INSTALL_RPATH 1 -    INSTALL_NAME_DIR "@executable_path" +    INSTALL_RPATH "@executable_path/../Frameworks"      LINK_FLAGS "-exported_symbols_list ${CMAKE_CURRENT_SOURCE_DIR}/../base/media_plugin_base.exp"    ) diff --git a/indra/media_plugins/libvlc/media_plugin_libvlc.cpp b/indra/media_plugins/libvlc/media_plugin_libvlc.cpp index e79d474325..3fe2c2b193 100644 --- a/indra/media_plugins/libvlc/media_plugin_libvlc.cpp +++ b/indra/media_plugins/libvlc/media_plugin_libvlc.cpp @@ -174,7 +174,7 @@ void MediaPluginLibVLC::initVLC()      };  #if LL_DARWIN -    setenv("VLC_PLUGIN_PATH", ".", 1); +    setenv("VLC_PLUGIN_PATH", "./plugins", 1);  #endif      int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index dabad38f99..a52107ffa5 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1493,7 +1493,7 @@ if (DARWIN)    set(viewer_RESOURCE_FILES      secondlife.icns      Info-SecondLife.plist -    SecondLife.xib/ +    SecondLife.xib      # CMake doesn't seem to support Xcode language variants well just yet      English.lproj/InfoPlist.strings      English.lproj/language.txt @@ -1886,7 +1886,7 @@ if (WINDOWS)      # And of course it's straightforward to read a text file in Python.      set(COPY_INPUT_DEPENDENCIES -      # The following commented dependencies are determined at variably at build time. Can't do this here. +      # The following commented dependencies are determined variably at build time. Can't do this here.        app_settings/message.xml        ${CMAKE_SOURCE_DIR}/../scripts/messages/message_template.msg        ${SHARED_LIB_STAGING_DIR}/openjp2.dll @@ -2086,7 +2086,9 @@ if (WINDOWS)  elseif (DARWIN)      set_target_properties(${VIEWER_BINARY_NAME}          PROPERTIES -        LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} -Xlinker -dead_strip -Xlinker -map -Xlinker ${CMAKE_CURRENT_BINARY_DIR}/${VIEWER_BINARY_NAME}.MAP" +        RESOURCE SecondLife.xib +        #LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} -Xlinker -dead_strip -Xlinker -map -Xlinker ${CMAKE_CURRENT_BINARY_DIR}/${VIEWER_BINARY_NAME}.MAP" +        LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} -Xlinker -dead_strip"          )  else (WINDOWS)          # Linux @@ -2147,6 +2149,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}          llappearance          ${LLPHYSICSEXTENSIONS_LIBRARIES}          ll::bugsplat +        ll::ndof          ll::tracy          ll::openxr          ) @@ -2435,10 +2438,6 @@ if (DARWIN)      PROPERTIES      OUTPUT_NAME "${product}"      # From Contents/MacOS/SecondLife, look in Contents/Frameworks -    INSTALL_RPATH "@loader_path/../Frameworks" -    # SIGH, as of 2018-05-24 (cmake 3.11.1) the INSTALL_RPATH property simply -    # does not work. Try this: -    LINK_FLAGS "-rpath @loader_path/../Frameworks"      MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info-SecondLife.plist"      XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${MACOSX_BUNDLE_GUI_IDENTIFIER}"      MACOSX_BUNDLE TRUE diff --git a/indra/newview/FixBundle.cmake.in b/indra/newview/FixBundle.cmake.in index 7a2d9d2510..e47c70aee6 100644 --- a/indra/newview/FixBundle.cmake.in +++ b/indra/newview/FixBundle.cmake.in @@ -139,6 +139,7 @@ fixup_bundle(${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents/MacOS/${VIEWER_  file(CHMOD      "${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper.app/Contents/MacOS/DullahanHelper" +    "${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (Alerts).app/Contents/MacOS/DullahanHelper (Alerts)"      "${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (GPU).app/Contents/MacOS/DullahanHelper (GPU)"      "${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (Plugin).app/Contents/MacOS/DullahanHelper (Plugin)"      "${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (Renderer).app/Contents/MacOS/DullahanHelper (Renderer)" @@ -276,6 +277,7 @@ execute_process(      COMMAND sudo codesign -f -s ${SIGNING_IDENTITY} --timestamp -o runtime --runtime-version ${CMAKE_OSX_DEPLOYMENT_TARGET}          Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libEGL.dylib          Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libGLESv2.dylib +        Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libcef_sandbox.dylib          Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libvk_swiftshader.dylib          Frameworks/Chromium\ Embedded\ Framework.framework          Frameworks/libalut.0.dylib @@ -671,6 +673,7 @@ execute_process(          Resources/llplugin/plugins/libyuy2_i420_plugin.dylib          Resources/llplugin/plugins/libyuy2_i422_plugin.dylib          Resources/llplugin/plugins/libzvbi_plugin.dylib +        Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper\ \(GPU\).app/Contents/MacOS/DullahanHelper\ \(Alerts\)          Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper\ \(GPU\).app/Contents/MacOS/DullahanHelper\ \(GPU\)          Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper\ \(Plugin\).app/Contents/MacOS/DullahanHelper\ \(Plugin\)          WORKING_DIRECTORY ${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents @@ -683,6 +686,7 @@ execute_process(          DullahanHelper\ \(Renderer\).app/Contents/MacOS/DullahanHelper\ \(Renderer\)      COMMAND sudo codesign -f -s ${SIGNING_IDENTITY} --timestamp -o runtime --runtime-version ${CMAKE_OSX_DEPLOYMENT_TARGET}          --deep +        DullahanHelper\ \(Alerts\).app          DullahanHelper\ \(GPU\).app          DullahanHelper\ \(Plugin\).app      WORKING_DIRECTORY ${viewer_BINARY_DIR}/${VIEWER_CHANNEL}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks diff --git a/indra/newview/FixPackage.cmake.in b/indra/newview/FixPackage.cmake.in index 01ec38de57..5b0e38c9cd 100644 --- a/indra/newview/FixPackage.cmake.in +++ b/indra/newview/FixPackage.cmake.in @@ -139,6 +139,7 @@ fixup_bundle(${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/  file(CHMOD      "${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/${CPACK_BUNDLE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}/${CPACK_BUNDLE_NAME}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper.app/Contents/MacOS/DullahanHelper" +    "${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/${CPACK_BUNDLE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}/${CPACK_BUNDLE_NAME}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (Alerts).app/Contents/MacOS/DullahanHelper (Alerts)"      "${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/${CPACK_BUNDLE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}/${CPACK_BUNDLE_NAME}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (GPU).app/Contents/MacOS/DullahanHelper (GPU)"      "${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/${CPACK_BUNDLE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}/${CPACK_BUNDLE_NAME}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (Plugin).app/Contents/MacOS/DullahanHelper (Plugin)"      "${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/${CPACK_BUNDLE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}/${CPACK_BUNDLE_NAME}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper (Renderer).app/Contents/MacOS/DullahanHelper (Renderer)" @@ -276,6 +277,7 @@ execute_process(      COMMAND sudo codesign -f -s ${SIGNING_IDENTITY} --timestamp -o runtime --runtime-version ${CMAKE_OSX_DEPLOYMENT_TARGET}          Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libEGL.dylib          Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libGLESv2.dylib +        Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libcef_sandbox.dylib          Frameworks/Chromium\ Embedded\ Framework.framework/Libraries/libvk_swiftshader.dylib          Frameworks/Chromium\ Embedded\ Framework.framework          Frameworks/libalut.0.dylib @@ -672,6 +674,7 @@ execute_process(          Resources/llplugin/plugins/libyuy2_i422_plugin.dylib          Resources/llplugin/plugins/libzvbi_plugin.dylib          Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper.app +        Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper\ \(Alerts\).app/Contents/MacOS/DullahanHelper\ \(Alerts\)          Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper\ \(GPU\).app/Contents/MacOS/DullahanHelper\ \(GPU\)          Resources/SLPlugin.app/Contents/Frameworks/DullahanHelper\ \(Plugin\).app/Contents/MacOS/DullahanHelper\ \(Plugin\)          WORKING_DIRECTORY ${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/${CPACK_BUNDLE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}/${CPACK_BUNDLE_NAME}.app/Contents @@ -682,6 +685,7 @@ execute_process(          DullahanHelper\ \(Renderer\).app/Contents/MacOS/DullahanHelper\ \(Renderer\)      COMMAND sudo codesign -f -s ${SIGNING_IDENTITY} --timestamp -o runtime --runtime-version ${CMAKE_OSX_DEPLOYMENT_TARGET}          --deep +        DullahanHelper\ \(Alerts\).app          DullahanHelper\ \(GPU\).app          DullahanHelper\ \(Plugin\).app      WORKING_DIRECTORY ${CMAKE_CACHEFILE_DIR}/_CPack_Packages/${CMAKE_SYSTEM_NAME}/Bundle/${CPACK_BUNDLE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}/${CPACK_BUNDLE_NAME}.app/Contents/Resources/SLPlugin.app/Contents/Frameworks diff --git a/indra/newview/SecondLife.xib b/indra/newview/SecondLife.xib index 8302392f5d..d123eee79e 100644 --- a/indra/newview/SecondLife.xib +++ b/indra/newview/SecondLife.xib @@ -1,1136 +1,193 @@  <?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00"> -	<data> -		<int key="IBDocument.SystemTarget">1060</int> -		<string key="IBDocument.SystemVersion">12E55</string> -		<string key="IBDocument.InterfaceBuilderVersion">4457.6</string> -		<string key="IBDocument.AppKitVersion">1187.39</string> -		<string key="IBDocument.HIToolboxVersion">626.00</string> -		<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> -			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> -			<string key="NS.object.0">4457.6</string> -		</object> -		<array key="IBDocument.IntegratedClassDependencies"> -			<string>NSCustomObject</string> -			<string>NSMenu</string> -			<string>NSMenuItem</string> -			<string>NSScrollView</string> -			<string>NSScroller</string> -			<string>NSTextView</string> -			<string>NSView</string> -			<string>NSWindowTemplate</string> -		</array> -		<array key="IBDocument.PluginDependencies"> -			<string>com.apple.InterfaceBuilder.CocoaPlugin</string> -		</array> -		<object class="NSMutableDictionary" key="IBDocument.Metadata"> -			<string key="NS.key.0">PluginDependencyRecalculationVersion</string> -			<integer value="1" key="NS.object.0"/> -		</object> -		<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048"> -			<object class="NSCustomObject" id="1021"> -				<string key="NSClassName">NSApplication</string> -			</object> -			<object class="NSCustomObject" id="1014"> -				<string key="NSClassName">FirstResponder</string> -			</object> -			<object class="NSCustomObject" id="1050"> -				<string key="NSClassName">NSApplication</string> -			</object> -			<object class="NSMenu" id="649796088"> -				<string key="NSTitle">Main Menu</string> -				<array class="NSMutableArray" key="NSMenuItems"> -					<object class="NSMenuItem" id="694149608"> -						<reference key="NSMenu" ref="649796088"/> -						<string key="NSTitle">Megapahit</string> -						<string key="NSKeyEquiv"/> -						<int key="NSMnemonicLoc">2147483647</int> -						<object class="NSCustomResource" key="NSOnImage" id="353210768"> -							<string key="NSClassName">NSImage</string> -							<string key="NSResourceName">NSMenuCheckmark</string> -						</object> -						<object class="NSCustomResource" key="NSMixedImage" id="549394948"> -							<string key="NSClassName">NSImage</string> -							<string key="NSResourceName">NSMenuMixedState</string> -						</object> -						<string key="NSAction">submenuAction:</string> -						<object class="NSMenu" key="NSSubmenu" id="110575045"> -							<string key="NSTitle">Megapahit</string> -							<array class="NSMutableArray" key="NSMenuItems"> -								<object class="NSMenuItem" id="238522557"> -									<reference key="NSMenu" ref="110575045"/> -									<string key="NSTitle">About Megapahit</string> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="304266470"> -									<reference key="NSMenu" ref="110575045"/> -									<bool key="NSIsDisabled">YES</bool> -									<bool key="NSIsSeparator">YES</bool> -									<string key="NSTitle"/> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="609285721"> -									<reference key="NSMenu" ref="110575045"/> -									<string key="NSTitle">Preferences…</string> -									<string key="NSKeyEquiv">,</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="481834944"> -									<reference key="NSMenu" ref="110575045"/> -									<bool key="NSIsDisabled">YES</bool> -									<bool key="NSIsSeparator">YES</bool> -									<string key="NSTitle"/> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="1046388886"> -									<reference key="NSMenu" ref="110575045"/> -									<string key="NSTitle">Services</string> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -									<string key="NSAction">submenuAction:</string> -									<object class="NSMenu" key="NSSubmenu" id="752062318"> -										<string key="NSTitle">Services</string> -										<array class="NSMutableArray" key="NSMenuItems"/> -										<string key="NSName">_NSServicesMenu</string> -									</object> -								</object> -								<object class="NSMenuItem" id="646227648"> -									<reference key="NSMenu" ref="110575045"/> -									<bool key="NSIsDisabled">YES</bool> -									<bool key="NSIsSeparator">YES</bool> -									<string key="NSTitle"/> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="755159360"> -									<reference key="NSMenu" ref="110575045"/> -									<string key="NSTitle">Hide Megapahit</string> -									<string key="NSKeyEquiv">h</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="342932134"> -									<reference key="NSMenu" ref="110575045"/> -									<string key="NSTitle">Hide Others</string> -									<string key="NSKeyEquiv">h</string> -									<int key="NSKeyEquivModMask">1572864</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="908899353"> -									<reference key="NSMenu" ref="110575045"/> -									<string key="NSTitle">Show All</string> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="1056857174"> -									<reference key="NSMenu" ref="110575045"/> -									<bool key="NSIsDisabled">YES</bool> -									<bool key="NSIsSeparator">YES</bool> -									<string key="NSTitle"/> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="632727374"> -									<reference key="NSMenu" ref="110575045"/> -									<string key="NSTitle">Quit Megapahit</string> -									<string key="NSKeyEquiv">q</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -							</array> -							<string key="NSName">_NSAppleMenu</string> -						</object> -					</object> -					<object class="NSMenuItem" id="725688984"> -						<reference key="NSMenu" ref="649796088"/> -						<string key="NSTitle">Edit</string> -						<string key="NSKeyEquiv"/> -						<int key="NSMnemonicLoc">2147483647</int> -						<reference key="NSOnImage" ref="353210768"/> -						<reference key="NSMixedImage" ref="549394948"/> -						<string key="NSAction">submenuAction:</string> -						<object class="NSMenu" key="NSSubmenu" id="701759256"> -							<string key="NSTitle">Edit</string> -							<array class="NSMutableArray" key="NSMenuItems"> -								<object class="NSMenuItem" id="521487141"> -									<reference key="NSMenu" ref="701759256"/> -									<string key="NSTitle">Undo</string> -									<string key="NSKeyEquiv">z</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="668936019"> -									<reference key="NSMenu" ref="701759256"/> -									<string key="NSTitle">Redo</string> -									<string key="NSKeyEquiv">Z</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="383018193"> -									<reference key="NSMenu" ref="701759256"/> -									<bool key="NSIsDisabled">YES</bool> -									<bool key="NSIsSeparator">YES</bool> -									<string key="NSTitle"/> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="984623395"> -									<reference key="NSMenu" ref="701759256"/> -									<string key="NSTitle">Cut</string> -									<string key="NSKeyEquiv">x</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="656529582"> -									<reference key="NSMenu" ref="701759256"/> -									<string key="NSTitle">Copy</string> -									<string key="NSKeyEquiv">c</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="1032676691"> -									<reference key="NSMenu" ref="701759256"/> -									<string key="NSTitle">Paste</string> -									<string key="NSKeyEquiv">v</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="538907583"> -									<reference key="NSMenu" ref="701759256"/> -									<string key="NSTitle">Select All</string> -									<string key="NSKeyEquiv">a</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -							</array> -						</object> -					</object> -					<object class="NSMenuItem" id="713487014"> -						<reference key="NSMenu" ref="649796088"/> -						<string key="NSTitle">Window</string> -						<string key="NSKeyEquiv"/> -						<int key="NSMnemonicLoc">2147483647</int> -						<reference key="NSOnImage" ref="353210768"/> -						<reference key="NSMixedImage" ref="549394948"/> -						<string key="NSAction">submenuAction:</string> -						<object class="NSMenu" key="NSSubmenu" id="835318025"> -							<string key="NSTitle">Window</string> -							<array class="NSMutableArray" key="NSMenuItems"> -								<object class="NSMenuItem" id="1011231497"> -									<reference key="NSMenu" ref="835318025"/> -									<string key="NSTitle">Minimize</string> -									<string key="NSKeyEquiv">m</string> -									<int key="NSKeyEquivModMask">1048576</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="575023229"> -									<reference key="NSMenu" ref="835318025"/> -									<string key="NSTitle">Zoom</string> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="86356408"> -									<reference key="NSMenu" ref="835318025"/> -									<string key="NSTitle">Enter Full Screen</string> -									<string key="NSKeyEquiv">f</string> -									<int key="NSKeyEquivModMask">1310720</int> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="299356726"> -									<reference key="NSMenu" ref="835318025"/> -									<bool key="NSIsDisabled">YES</bool> -									<bool key="NSIsSeparator">YES</bool> -									<string key="NSTitle"/> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -								<object class="NSMenuItem" id="625202149"> -									<reference key="NSMenu" ref="835318025"/> -									<string key="NSTitle">Bring All to Front</string> -									<string key="NSKeyEquiv"/> -									<int key="NSMnemonicLoc">2147483647</int> -									<reference key="NSOnImage" ref="353210768"/> -									<reference key="NSMixedImage" ref="549394948"/> -								</object> -							</array> -							<string key="NSName">_NSWindowsMenu</string> -						</object> -					</object> -					<object class="NSMenuItem" id="391199113"> -						<reference key="NSMenu" ref="649796088"/> -						<string key="NSTitle">Help</string> -						<string key="NSKeyEquiv"/> -						<int key="NSMnemonicLoc">2147483647</int> -						<reference key="NSOnImage" ref="353210768"/> -						<reference key="NSMixedImage" ref="549394948"/> -					</object> -				</array> -				<string key="NSName">_NSMainMenu</string> -			</object> -			<object class="NSCustomObject" id="756173070"> -				<string key="NSClassName">LLAppDelegate</string> -			</object> -			<object class="NSWindowTemplate" id="110292814"> -				<int key="NSWindowStyleMask">15</int> -				<int key="NSWindowBacking">2</int> -				<string key="NSWindowRect">{{196, 240}, {1024, 600}}</string> -				<int key="NSWTFlags">74974208</int> -				<string key="NSWindowTitle">Megapahit</string> -				<string key="NSWindowClass">LLNSWindow</string> -				<nil key="NSViewClass"/> -				<nil key="NSUserInterfaceItemIdentifier"/> -				<object class="NSView" key="NSWindowView" id="305280978"> -					<reference key="NSNextResponder"/> -					<int key="NSvFlags">256</int> -					<array class="NSMutableArray" key="NSSubviews"/> -					<string key="NSFrameSize">{1024, 600}</string> -					<reference key="NSSuperview"/> -					<reference key="NSWindow"/> -					<string key="NSReuseIdentifierKey">_NS:20</string> -				</object> -				<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string> -				<string key="NSMaxSize">{10000000000000, 10000000000000}</string> -				<string key="NSFrameAutosaveName">Megapahit</string> -				<int key="NSWindowCollectionBehavior">128</int> -				<bool key="NSWindowIsRestorable">NO</bool> -			</object> -			<object class="NSWindowTemplate" id="979091056"> -				<int key="NSWindowStyleMask">31</int> -				<int key="NSWindowBacking">2</int> -				<string key="NSWindowRect">{{272, 176}, {938, 42}}</string> -				<int key="NSWTFlags">-1535638528</int> -				<string key="NSWindowTitle">Input Window</string> -				<string key="NSWindowClass">LLUserInputWindow</string> -				<nil key="NSViewClass"/> -				<nil key="NSUserInterfaceItemIdentifier"/> -				<object class="NSView" key="NSWindowView" id="1044753903"> -					<reference key="NSNextResponder"/> -					<int key="NSvFlags">256</int> -					<array class="NSMutableArray" key="NSSubviews"> -						<object class="NSScrollView" id="238626476"> -							<reference key="NSNextResponder" ref="1044753903"/> -							<int key="NSvFlags">256</int> -							<array class="NSMutableArray" key="NSSubviews"> -								<object class="NSClipView" id="871543330"> -									<reference key="NSNextResponder" ref="238626476"/> -									<int key="NSvFlags">2322</int> -									<array class="NSMutableArray" key="NSSubviews"> -										<object class="NSTextView" id="395788163"> -											<reference key="NSNextResponder" ref="871543330"/> -											<int key="NSvFlags">2322</int> -											<set class="NSMutableSet" key="NSDragTypes"> -												<string>Apple HTML pasteboard type</string> -												<string>Apple PDF pasteboard type</string> -												<string>Apple PICT pasteboard type</string> -												<string>Apple PNG pasteboard type</string> -												<string>Apple URL pasteboard type</string> -												<string>CorePasteboardFlavorType 0x6D6F6F76</string> -												<string>NSColor pasteboard type</string> -												<string>NSFilenamesPboardType</string> -												<string>NSStringPboardType</string> -												<string>NeXT Encapsulated PostScript v1.2 pasteboard type</string> -												<string>NeXT RTFD pasteboard type</string> -												<string>NeXT Rich Text Format v1.0 pasteboard type</string> -												<string>NeXT TIFF v4.0 pasteboard type</string> -												<string>NeXT font pasteboard type</string> -												<string>NeXT ruler pasteboard type</string> -												<string>WebURLsWithTitlesPboardType</string> -												<string>public.url</string> -											</set> -											<string key="NSFrameSize">{938, 42}</string> -											<reference key="NSSuperview" ref="871543330"/> -											<reference key="NSWindow"/> -											<reference key="NSNextKeyView" ref="339833963"/> -											<string key="NSReuseIdentifierKey">_NS:13</string> -											<object class="NSTextContainer" key="NSTextContainer" id="648552009"> -												<object class="NSLayoutManager" key="NSLayoutManager"> -													<object class="NSTextStorage" key="NSTextStorage"> -														<object class="NSMutableString" key="NSString"> -															<characters key="NS.bytes"/> -														</object> -														<nil key="NSDelegate"/> -													</object> -													<array class="NSMutableArray" key="NSTextContainers"> -														<reference ref="648552009"/> -													</array> -													<int key="NSLMFlags">166</int> -													<nil key="NSDelegate"/> -												</object> -												<reference key="NSTextView" ref="395788163"/> -												<double key="NSWidth">938</double> -												<int key="NSTCFlags">1</int> -											</object> -											<object class="NSTextViewSharedData" key="NSSharedData"> -												<int key="NSFlags">67121127</int> -												<int key="NSTextCheckingTypes">0</int> -												<nil key="NSMarkedAttributes"/> -												<object class="NSColor" key="NSBackgroundColor" id="535647664"> -													<int key="NSColorSpace">3</int> -													<bytes key="NSWhite">MQA</bytes> -												</object> -												<dictionary key="NSSelectedAttributes"> -													<object class="NSColor" key="NSBackgroundColor"> -														<int key="NSColorSpace">6</int> -														<string key="NSCatalogName">System</string> -														<string key="NSColorName">selectedTextBackgroundColor</string> -														<object class="NSColor" key="NSColor"> -															<int key="NSColorSpace">3</int> -															<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> -														</object> -													</object> -													<object class="NSColor" key="NSColor"> -														<int key="NSColorSpace">6</int> -														<string key="NSCatalogName">System</string> -														<string key="NSColorName">selectedTextColor</string> -														<object class="NSColor" key="NSColor" id="835883401"> -															<int key="NSColorSpace">3</int> -															<bytes key="NSWhite">MAA</bytes> -														</object> -													</object> -												</dictionary> -												<reference key="NSInsertionColor" ref="835883401"/> -												<dictionary key="NSLinkAttributes"> -													<object class="NSColor" key="NSColor"> -														<int key="NSColorSpace">1</int> -														<bytes key="NSRGB">MCAwIDEAA</bytes> -													</object> -													<object class="NSCursor" key="NSCursor"> -														<string key="NSHotSpot">{8, -8}</string> -														<int key="NSCursorType">13</int> -													</object> -													<integer value="1" key="NSUnderline"/> -												</dictionary> -												<nil key="NSDefaultParagraphStyle"/> -												<nil key="NSTextFinder"/> -												<int key="NSPreferredTextFinderStyle">1</int> -											</object> -											<int key="NSTVFlags">6</int> -											<string key="NSMaxSize">{939, 10000000}</string> -											<nil key="NSDelegate"/> -										</object> -									</array> -									<string key="NSFrame">{{1, 1}, {938, 42}}</string> -									<reference key="NSSuperview" ref="238626476"/> -									<reference key="NSWindow"/> -									<reference key="NSNextKeyView" ref="395788163"/> -									<string key="NSReuseIdentifierKey">_NS:11</string> -									<reference key="NSDocView" ref="395788163"/> -									<reference key="NSBGColor" ref="535647664"/> -									<object class="NSCursor" key="NSCursor"> -										<string key="NSHotSpot">{4, 5}</string> -										<object class="NSImage" key="NSImage"> -											<int key="NSImageFlags">79691776</int> -											<array key="NSReps"> -												<array> -													<integer value="5"/> -													<object class="NSURL"> -														<nil key="NS.base"/> -														<string key="NS.relative">file://localhost/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Resources/DVTIbeamCursor.tiff</string> -													</object> -												</array> -											</array> -											<object class="NSColor" key="NSColor"> -												<int key="NSColorSpace">3</int> -												<bytes key="NSWhite">MCAwAA</bytes> -											</object> -										</object> -									</object> -									<int key="NScvFlags">4</int> -								</object> -								<object class="NSScroller" id="339833963"> -									<reference key="NSNextResponder" ref="238626476"/> -									<int key="NSvFlags">256</int> -									<string key="NSFrame">{{923, 1}, {16, 42}}</string> -									<reference key="NSSuperview" ref="238626476"/> -									<reference key="NSWindow"/> -									<reference key="NSNextKeyView"/> -									<string key="NSReuseIdentifierKey">_NS:83</string> -									<bool key="NSAllowsLogicalLayoutDirection">NO</bool> -									<reference key="NSTarget" ref="238626476"/> -									<string key="NSAction">_doScroller:</string> -									<double key="NSPercent">0.96666666666666667</double> -								</object> -								<object class="NSScroller" id="1067057765"> -									<reference key="NSNextResponder" ref="238626476"/> -									<int key="NSvFlags">-2147483392</int> -									<string key="NSFrame">{{-100, -100}, {87, 18}}</string> -									<reference key="NSSuperview" ref="238626476"/> -									<reference key="NSWindow"/> -									<reference key="NSNextKeyView" ref="871543330"/> -									<string key="NSReuseIdentifierKey">_NS:33</string> -									<bool key="NSAllowsLogicalLayoutDirection">NO</bool> -									<int key="NSsFlags">1</int> -									<reference key="NSTarget" ref="238626476"/> -									<string key="NSAction">_doScroller:</string> -									<double key="NSCurValue">1</double> -									<double key="NSPercent">0.94565218687057495</double> -								</object> -							</array> -							<string key="NSFrame">{{-1, -1}, {940, 44}}</string> -							<reference key="NSSuperview" ref="1044753903"/> -							<reference key="NSWindow"/> -							<reference key="NSNextKeyView" ref="1067057765"/> -							<string key="NSReuseIdentifierKey">_NS:9</string> -							<int key="NSsFlags">133138</int> -							<reference key="NSVScroller" ref="339833963"/> -							<reference key="NSHScroller" ref="1067057765"/> -							<reference key="NSContentView" ref="871543330"/> -							<double key="NSMinMagnification">0.25</double> -							<double key="NSMaxMagnification">4</double> -							<double key="NSMagnification">1</double> -						</object> -					</array> -					<string key="NSFrameSize">{938, 42}</string> -					<reference key="NSSuperview"/> -					<reference key="NSWindow"/> -					<reference key="NSNextKeyView" ref="238626476"/> -					<string key="NSReuseIdentifierKey">_NS:21</string> -				</object> -				<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string> -				<string key="NSMaxSize">{10000000000000, 10000000000000}</string> -				<bool key="NSWindowIsRestorable">YES</bool> -			</object> -		</array> -		<object class="IBObjectContainer" key="IBDocument.Objects"> -			<array class="NSMutableArray" key="connectionRecords"> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">terminate:</string> -						<reference key="source" ref="1050"/> -						<reference key="destination" ref="632727374"/> -					</object> -					<int key="connectionID">823</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">orderFrontStandardAboutPanel:</string> -						<reference key="source" ref="1021"/> -						<reference key="destination" ref="238522557"/> -					</object> -					<int key="connectionID">142</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBOutletConnection" key="connection"> -						<string key="label">delegate</string> -						<reference key="source" ref="1021"/> -						<reference key="destination" ref="756173070"/> -					</object> -					<int key="connectionID">845</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">performMiniaturize:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="1011231497"/> -					</object> -					<int key="connectionID">37</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">arrangeInFront:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="625202149"/> -					</object> -					<int key="connectionID">39</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">performZoom:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="575023229"/> -					</object> -					<int key="connectionID">240</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">hide:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="755159360"/> -					</object> -					<int key="connectionID">369</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">hideOtherApplications:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="342932134"/> -					</object> -					<int key="connectionID">370</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">unhideAllApplications:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="908899353"/> -					</object> -					<int key="connectionID">372</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">cut:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="984623395"/> -					</object> -					<int key="connectionID">768</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">paste:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="1032676691"/> -					</object> -					<int key="connectionID">769</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">undo:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="521487141"/> -					</object> -					<int key="connectionID">776</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">copy:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="656529582"/> -					</object> -					<int key="connectionID">782</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">selectAll:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="538907583"/> -					</object> -					<int key="connectionID">785</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBActionConnection" key="connection"> -						<string key="label">toggleFullScreen:</string> -						<reference key="source" ref="1014"/> -						<reference key="destination" ref="86356408"/> -					</object> -					<int key="connectionID">842</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBOutletConnection" key="connection"> -						<string key="label">window</string> -						<reference key="source" ref="756173070"/> -						<reference key="destination" ref="110292814"/> -					</object> -					<int key="connectionID">850</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBOutletConnection" key="connection"> -						<string key="label">inputWindow</string> -						<reference key="source" ref="756173070"/> -						<reference key="destination" ref="979091056"/> -					</object> -					<int key="connectionID">953</int> -				</object> -				<object class="IBConnectionRecord"> -					<object class="IBOutletConnection" key="connection"> -						<string key="label">inputView</string> -						<reference key="source" ref="756173070"/> -						<reference key="destination" ref="395788163"/> -					</object> -					<int key="connectionID">954</int> -				</object> -			</array> -			<object class="IBMutableOrderedSet" key="objectRecords"> -				<array key="orderedObjects"> -					<object class="IBObjectRecord"> -						<int key="objectID">0</int> -						<array key="object" id="0"/> -						<reference key="children" ref="1048"/> -						<nil key="parent"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">-2</int> -						<reference key="object" ref="1021"/> -						<reference key="parent" ref="0"/> -						<string key="objectName">File's Owner</string> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">-1</int> -						<reference key="object" ref="1014"/> -						<reference key="parent" ref="0"/> -						<string key="objectName">First Responder</string> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">-3</int> -						<reference key="object" ref="1050"/> -						<reference key="parent" ref="0"/> -						<string key="objectName">Application</string> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">29</int> -						<reference key="object" ref="649796088"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="713487014"/> -							<reference ref="694149608"/> -							<reference ref="391199113"/> -							<reference ref="725688984"/> -						</array> -						<reference key="parent" ref="0"/> -						<string key="objectName">Main Menu</string> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">19</int> -						<reference key="object" ref="713487014"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="835318025"/> -						</array> -						<reference key="parent" ref="649796088"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">56</int> -						<reference key="object" ref="694149608"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="110575045"/> -						</array> -						<reference key="parent" ref="649796088"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">103</int> -						<reference key="object" ref="391199113"/> -						<array class="NSMutableArray" key="children"/> -						<reference key="parent" ref="649796088"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">57</int> -						<reference key="object" ref="110575045"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="238522557"/> -							<reference ref="755159360"/> -							<reference ref="908899353"/> -							<reference ref="632727374"/> -							<reference ref="646227648"/> -							<reference ref="609285721"/> -							<reference ref="481834944"/> -							<reference ref="304266470"/> -							<reference ref="1046388886"/> -							<reference ref="1056857174"/> -							<reference ref="342932134"/> -						</array> -						<reference key="parent" ref="694149608"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">58</int> -						<reference key="object" ref="238522557"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">134</int> -						<reference key="object" ref="755159360"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">150</int> -						<reference key="object" ref="908899353"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">136</int> -						<reference key="object" ref="632727374"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">144</int> -						<reference key="object" ref="646227648"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">129</int> -						<reference key="object" ref="609285721"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">143</int> -						<reference key="object" ref="481834944"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">236</int> -						<reference key="object" ref="304266470"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">131</int> -						<reference key="object" ref="1046388886"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="752062318"/> -						</array> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">149</int> -						<reference key="object" ref="1056857174"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">145</int> -						<reference key="object" ref="342932134"/> -						<reference key="parent" ref="110575045"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">130</int> -						<reference key="object" ref="752062318"/> -						<reference key="parent" ref="1046388886"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">24</int> -						<reference key="object" ref="835318025"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="299356726"/> -							<reference ref="625202149"/> -							<reference ref="575023229"/> -							<reference ref="1011231497"/> -							<reference ref="86356408"/> -						</array> -						<reference key="parent" ref="713487014"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">92</int> -						<reference key="object" ref="299356726"/> -						<reference key="parent" ref="835318025"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">5</int> -						<reference key="object" ref="625202149"/> -						<reference key="parent" ref="835318025"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">239</int> -						<reference key="object" ref="575023229"/> -						<reference key="parent" ref="835318025"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">23</int> -						<reference key="object" ref="1011231497"/> -						<reference key="parent" ref="835318025"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">711</int> -						<reference key="object" ref="725688984"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="701759256"/> -						</array> -						<reference key="parent" ref="649796088"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">712</int> -						<reference key="object" ref="701759256"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="521487141"/> -							<reference ref="668936019"/> -							<reference ref="383018193"/> -							<reference ref="984623395"/> -							<reference ref="656529582"/> -							<reference ref="1032676691"/> -							<reference ref="538907583"/> -						</array> -						<reference key="parent" ref="725688984"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">716</int> -						<reference key="object" ref="984623395"/> -						<reference key="parent" ref="701759256"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">717</int> -						<reference key="object" ref="656529582"/> -						<reference key="parent" ref="701759256"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">718</int> -						<reference key="object" ref="1032676691"/> -						<reference key="parent" ref="701759256"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">721</int> -						<reference key="object" ref="538907583"/> -						<reference key="parent" ref="701759256"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">824</int> -						<reference key="object" ref="756173070"/> -						<reference key="parent" ref="0"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">841</int> -						<reference key="object" ref="86356408"/> -						<reference key="parent" ref="835318025"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">828</int> -						<reference key="object" ref="110292814"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="305280978"/> -						</array> -						<reference key="parent" ref="0"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">829</int> -						<reference key="object" ref="305280978"/> -						<array class="NSMutableArray" key="children"/> -						<reference key="parent" ref="110292814"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">713</int> -						<reference key="object" ref="521487141"/> -						<reference key="parent" ref="701759256"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">714</int> -						<reference key="object" ref="668936019"/> -						<reference key="parent" ref="701759256"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">715</int> -						<reference key="object" ref="383018193"/> -						<reference key="parent" ref="701759256"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">941</int> -						<reference key="object" ref="979091056"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="1044753903"/> -						</array> -						<reference key="parent" ref="0"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">942</int> -						<reference key="object" ref="1044753903"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="238626476"/> -						</array> -						<reference key="parent" ref="979091056"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">943</int> -						<reference key="object" ref="238626476"/> -						<array class="NSMutableArray" key="children"> -							<reference ref="395788163"/> -							<reference ref="1067057765"/> -							<reference ref="339833963"/> -						</array> -						<reference key="parent" ref="1044753903"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">944</int> -						<reference key="object" ref="395788163"/> -						<reference key="parent" ref="238626476"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">945</int> -						<reference key="object" ref="1067057765"/> -						<reference key="parent" ref="238626476"/> -					</object> -					<object class="IBObjectRecord"> -						<int key="objectID">946</int> -						<reference key="object" ref="339833963"/> -						<reference key="parent" ref="238626476"/> -					</object> -				</array> -			</object> -			<dictionary class="NSMutableDictionary" key="flattenedProperties"> -				<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="103.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="129.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="130.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="131.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="134.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="136.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="143.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="144.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="145.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="149.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="150.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="19.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="23.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="236.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="239.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="24.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="29.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="56.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="57.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="711.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="712.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="713.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="714.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="715.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="716.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="717.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="718.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="721.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="824.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<boolean value="YES" key="828.IBNSWindowAutoPositionCentersHorizontal"/> -				<boolean value="YES" key="828.IBNSWindowAutoPositionCentersVertical"/> -				<string key="828.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<boolean value="YES" key="828.NSWindowTemplate.visibleAtLaunch"/> -				<string key="829.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="841.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="941.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<boolean value="NO" key="941.NSWindowTemplate.visibleAtLaunch"/> -				<string key="942.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="943.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="944.CustomClassName">LLNonInlineTextView</string> -				<string key="944.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="945.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -				<string key="946.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string> -			</dictionary> -			<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/> -			<nil key="activeLocalization"/> -			<dictionary class="NSMutableDictionary" key="localizations"/> -			<nil key="sourceID"/> -			<int key="maxID">954</int> -		</object> -		<object class="IBClassDescriber" key="IBDocument.Classes"> -			<array class="NSMutableArray" key="referencedPartialClassDescriptions"> -				<object class="IBPartialClassDescription"> -					<string key="className">LLAppDelegate</string> -					<string key="superclassName">NSObject</string> -					<dictionary class="NSMutableDictionary" key="outlets"> -						<string key="inputView">LLNonInlineTextView</string> -						<string key="inputWindow">NSWindow</string> -						<string key="window">LLNSWindow</string> -					</dictionary> -					<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName"> -						<object class="IBToOneOutletInfo" key="inputView"> -							<string key="name">inputView</string> -							<string key="candidateClassName">LLNonInlineTextView</string> -						</object> -						<object class="IBToOneOutletInfo" key="inputWindow"> -							<string key="name">inputWindow</string> -							<string key="candidateClassName">NSWindow</string> -						</object> -						<object class="IBToOneOutletInfo" key="window"> -							<string key="name">window</string> -							<string key="candidateClassName">LLNSWindow</string> -						</object> -					</dictionary> -					<object class="IBClassDescriptionSource" key="sourceIdentifier"> -						<string key="majorKey">IBProjectSource</string> -						<string key="minorKey">./Classes/LLAppDelegate.h</string> -					</object> -				</object> -				<object class="IBPartialClassDescription"> -					<string key="className">LLNSWindow</string> -					<string key="superclassName">NSWindow</string> -					<object class="IBClassDescriptionSource" key="sourceIdentifier"> -						<string key="majorKey">IBProjectSource</string> -						<string key="minorKey">./Classes/LLNSWindow.h</string> -					</object> -				</object> -				<object class="IBPartialClassDescription"> -					<string key="className">LLNonInlineTextView</string> -					<string key="superclassName">NSTextView</string> -					<object class="IBClassDescriptionSource" key="sourceIdentifier"> -						<string key="majorKey">IBProjectSource</string> -						<string key="minorKey">./Classes/LLNonInlineTextView.h</string> -					</object> -				</object> -				<object class="IBPartialClassDescription"> -					<string key="className">LLUserInputWindow</string> -					<string key="superclassName">NSPanel</string> -					<object class="IBClassDescriptionSource" key="sourceIdentifier"> -						<string key="majorKey">IBProjectSource</string> -						<string key="minorKey">./Classes/LLUserInputWindow.h</string> -					</object> -				</object> -				<object class="IBPartialClassDescription"> -					<string key="className">NSTextView</string> -					<dictionary class="NSMutableDictionary" key="actions"> -						<string key="orderFrontSharingServicePicker:">id</string> -						<string key="toggleQuickLookPreviewPanel:">id</string> -					</dictionary> -					<dictionary class="NSMutableDictionary" key="actionInfosByName"> -						<object class="IBActionInfo" key="orderFrontSharingServicePicker:"> -							<string key="name">orderFrontSharingServicePicker:</string> -							<string key="candidateClassName">id</string> -						</object> -						<object class="IBActionInfo" key="toggleQuickLookPreviewPanel:"> -							<string key="name">toggleQuickLookPreviewPanel:</string> -							<string key="candidateClassName">id</string> -						</object> -					</dictionary> -					<object class="IBClassDescriptionSource" key="sourceIdentifier"> -						<string key="majorKey">IBProjectSource</string> -						<string key="minorKey">./Classes/NSTextView.h</string> -					</object> -				</object> -			</array> -		</object> -		<int key="IBDocument.localizationMode">0</int> -		<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string> -		<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies"> -			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> -			<real value="1060" key="NS.object.0"/> -		</object> -		<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> -			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> -			<integer value="4600" key="NS.object.0"/> -		</object> -		<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> -		<int key="IBDocument.defaultPropertyAccessControl">3</int> -		<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes"> -			<string key="NSMenuCheckmark">{11, 11}</string> -			<string key="NSMenuMixedState">{10, 3}</string> -		</dictionary> -	</data> -</archive> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="23727" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> +    <dependencies> +        <deployment version="110000" identifier="macosx"/> +        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="23727"/> +        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> +    </dependencies> +    <objects> +        <customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> +            <connections> +                <outlet property="delegate" destination="824" id="845"/> +            </connections> +        </customObject> +        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> +        <customObject id="-3" userLabel="Application" customClass="NSObject"/> +        <menu title="Main Menu" systemMenu="main" id="29" userLabel="Main Menu"> +            <items> +                <menuItem title="Megapahit" id="56"> +                    <modifierMask key="keyEquivalentModifierMask"/> +                    <menu key="submenu" title="Megapahit" systemMenu="apple" id="57"> +                        <items> +                            <menuItem title="About Megapahit" id="58"> +                                <modifierMask key="keyEquivalentModifierMask"/> +                                <connections> +                                    <action selector="orderFrontStandardAboutPanel:" target="-2" id="142"/> +                                </connections> +                            </menuItem> +                            <menuItem isSeparatorItem="YES" id="236"/> +                            <menuItem title="Preferences…" keyEquivalent="," id="129"/> +                            <menuItem isSeparatorItem="YES" id="143"/> +                            <menuItem title="Services" id="131"> +                                <modifierMask key="keyEquivalentModifierMask"/> +                                <menu key="submenu" title="Services" systemMenu="services" id="130"/> +                            </menuItem> +                            <menuItem isSeparatorItem="YES" id="144"/> +                            <menuItem title="Hide Megapahit" keyEquivalent="h" id="134"> +                                <connections> +                                    <action selector="hide:" target="-1" id="369"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Hide Others" keyEquivalent="h" id="145"> +                                <modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/> +                                <connections> +                                    <action selector="hideOtherApplications:" target="-1" id="370"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Show All" id="150"> +                                <modifierMask key="keyEquivalentModifierMask"/> +                                <connections> +                                    <action selector="unhideAllApplications:" target="-1" id="372"/> +                                </connections> +                            </menuItem> +                            <menuItem isSeparatorItem="YES" id="149"/> +                            <menuItem title="Quit Megapahit" keyEquivalent="q" id="136"> +                                <connections> +                                    <action selector="terminate:" target="-3" id="823"/> +                                </connections> +                            </menuItem> +                        </items> +                    </menu> +                </menuItem> +                <menuItem title="Edit" id="711"> +                    <modifierMask key="keyEquivalentModifierMask"/> +                    <menu key="submenu" title="Edit" id="712"> +                        <items> +                            <menuItem title="Undo" keyEquivalent="z" id="713"> +                                <connections> +                                    <action selector="undo:" target="-1" id="776"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Redo" keyEquivalent="Z" id="714"/> +                            <menuItem isSeparatorItem="YES" id="715"/> +                            <menuItem title="Cut" keyEquivalent="x" id="716"> +                                <connections> +                                    <action selector="cut:" target="-1" id="768"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Copy" keyEquivalent="c" id="717"> +                                <connections> +                                    <action selector="copy:" target="-1" id="782"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Paste" keyEquivalent="v" id="718"> +                                <connections> +                                    <action selector="paste:" target="-1" id="769"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Select All" keyEquivalent="a" id="721"> +                                <connections> +                                    <action selector="selectAll:" target="-1" id="785"/> +                                </connections> +                            </menuItem> +                        </items> +                    </menu> +                </menuItem> +                <menuItem title="Window" id="19"> +                    <modifierMask key="keyEquivalentModifierMask"/> +                    <menu key="submenu" title="Window" systemMenu="window" id="24"> +                        <items> +                            <menuItem title="Minimize" keyEquivalent="m" id="23"> +                                <connections> +                                    <action selector="performMiniaturize:" target="-1" id="37"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Zoom" id="239"> +                                <modifierMask key="keyEquivalentModifierMask"/> +                                <connections> +                                    <action selector="performZoom:" target="-1" id="240"/> +                                </connections> +                            </menuItem> +                            <menuItem title="Enter Full Screen" keyEquivalent="f" id="841"> +                                <modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/> +                                <connections> +                                    <action selector="toggleFullScreen:" target="-1" id="842"/> +                                </connections> +                            </menuItem> +                            <menuItem isSeparatorItem="YES" id="92"/> +                            <menuItem title="Bring All to Front" id="5"> +                                <modifierMask key="keyEquivalentModifierMask"/> +                                <connections> +                                    <action selector="arrangeInFront:" target="-1" id="39"/> +                                </connections> +                            </menuItem> +                        </items> +                    </menu> +                </menuItem> +                <menuItem title="Help" id="103"> +                    <modifierMask key="keyEquivalentModifierMask"/> +                </menuItem> +            </items> +            <point key="canvasLocation" x="87" y="149"/> +        </menu> +        <customObject id="824" customClass="LLAppDelegate"> +            <connections> +                <outlet property="inputView" destination="944" id="954"/> +                <outlet property="inputWindow" destination="941" id="953"/> +                <outlet property="window" destination="828" id="850"/> +            </connections> +        </customObject> +        <window title="Megapahit" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" deferred="NO" frameAutosaveName="Megapahit" animationBehavior="default" id="828" customClass="LLNSWindow"> +            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> +            <windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/> +            <rect key="contentRect" x="196" y="240" width="1024" height="600"/> +            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/> +            <view key="contentView" id="829"> +                <rect key="frame" x="0.0" y="0.0" width="1024" height="600"/> +                <autoresizingMask key="autoresizingMask"/> +            </view> +            <point key="canvasLocation" x="-48" y="-285"/> +        </window> +        <window title="Input Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" visibleAtLaunch="NO" animationBehavior="default" id="941" customClass="LLUserInputWindow"> +            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" utility="YES"/> +            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> +            <rect key="contentRect" x="272" y="176" width="938" height="42"/> +            <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/> +            <view key="contentView" id="942"> +                <rect key="frame" x="0.0" y="0.0" width="938" height="42"/> +                <autoresizingMask key="autoresizingMask"/> +                <subviews> +                    <scrollView fixedFrame="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="943"> +                        <rect key="frame" x="-1" y="-1" width="940" height="44"/> +                        <autoresizingMask key="autoresizingMask"/> +                        <clipView key="contentView" id="Mvi-Vb-2zK"> +                            <rect key="frame" x="1" y="1" width="938" height="42"/> +                            <autoresizingMask key="autoresizingMask"/> +                            <subviews> +                                <textView importsGraphics="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" spellingCorrection="YES" smartInsertDelete="YES" id="944" customClass="LLNonInlineTextView"> +                                    <rect key="frame" x="0.0" y="0.0" width="938" height="42"/> +                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> +                                    <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> +                                    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> +                                    <size key="minSize" width="938" height="42"/> +                                    <size key="maxSize" width="940" height="10000000"/> +                                    <color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/> +                                </textView> +                            </subviews> +                            <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> +                        </clipView> +                        <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="945"> +                            <rect key="frame" x="-100" y="-100" width="87" height="18"/> +                            <autoresizingMask key="autoresizingMask"/> +                        </scroller> +                        <scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="946"> +                            <rect key="frame" x="924" y="1" width="15" height="42"/> +                            <autoresizingMask key="autoresizingMask"/> +                        </scroller> +                    </scrollView> +                </subviews> +            </view> +            <point key="canvasLocation" x="87" y="144"/> +        </window> +    </objects> +</document> diff --git a/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl b/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl index 017855325c..8e12d09443 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/CASF.glsl @@ -2545,12 +2545,31 @@ A_STATIC void CasSetup(  #endif  #ifdef A_GPU + +#ifdef LEGACY_GAMMA +uniform float gamma; + +vec3 legacyGamma(vec3 color) +{ +    vec3 c = 1. - clamp(color, vec3(0.), vec3(1.)); +    c = 1. - pow(c, vec3(gamma)); // s/b inverted already CPU-side + +    return c; +} +#endif +  void main()  {      vec4 diff = vec4(0.f);      uvec2 point = uvec2(vary_fragcoord * out_screen_res.xy);      CasFilter(diff.r, diff.g, diff.b, point, cas_param_0, cas_param_1, true);      diff.a = texture(diffuseRect, vary_fragcoord).a; +    diff.rgb = linear_to_srgb(diff.rgb); + +#ifdef LEGACY_GAMMA +    diff.rgb = legacyGamma(diff.rgb); +#endif +      frag_color = diff;  }  #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl b/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl index fdb77cce6e..5837308965 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/SMAA.glsl @@ -1351,6 +1351,10 @@ float4 SMAABlendingWeightCalculationPS(float2 texcoord,  //-----------------------------------------------------------------------------  // Neighborhood Blending Pixel Shader (Third Pass) +vec3 srgb_to_linear(vec3 cs); +vec4 srgb_to_linear4(vec4 cs); +vec3 linear_to_srgb(vec3 cl); +  float4 SMAANeighborhoodBlendingPS(float2 texcoord,                                    float4 offset,                                    SMAATexture2D(colorTex), @@ -1369,6 +1373,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,      SMAA_BRANCH      if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {          float4 color = SMAASampleLevelZero(colorTex, texcoord); +        color.rgb = srgb_to_linear(color.rgb);          #if SMAA_REPROJECTION          float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord)); @@ -1377,6 +1382,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,          color.a = sqrt(5.0 * length(velocity));          #endif +        color.rgb = linear_to_srgb(color.rgb);          return color;      } else {          bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical) @@ -1393,8 +1399,13 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,          // We exploit bilinear filtering to mix current pixel with the chosen          // neighbor: -        float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy); -        color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw); +        float4 color = SMAASampleLevelZero(colorTex, blendingCoord.xy); +        color.rgb = srgb_to_linear(color.rgb); +        color = blendingWeight.x * color; + +        float4 color2 = SMAASampleLevelZero(colorTex, blendingCoord.zw); +        color2.rgb = srgb_to_linear(color2.rgb); +        color += blendingWeight.y * color2;          #if SMAA_REPROJECTION          // Antialias velocity for proper reprojection in a later stage: @@ -1405,6 +1416,7 @@ float4 SMAANeighborhoodBlendingPS(float2 texcoord,          color.a = sqrt(5.0 * length(velocity));          #endif +        color.rgb = linear_to_srgb(color.rgb);          return color;      }  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 197ce48a45..a24e7c0b90 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -43,8 +43,6 @@ vec3 legacyGamma(vec3 color)      return c;  } -vec3 clampHDRRange(vec3 color); -  void main()  {      //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB) @@ -55,7 +53,7 @@ void main()      diff.rgb = legacyGamma(diff.rgb);  #endif -    diff.rgb = clampHDRRange(diff.rgb); +    diff.rgb = clamp(diff.rgb, vec3(0.0), vec3(1.0));      frag_color = diff;  } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl index 1f01c7f16a..b1218d61af 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredTonemap.glsl @@ -31,11 +31,25 @@ uniform sampler2D diffuseRect;  in vec2 vary_fragcoord; +#ifdef GAMMA_CORRECT +uniform float gamma; +#endif +  vec3 linear_to_srgb(vec3 cl);  vec3 toneMap(vec3 color);  vec3 clampHDRRange(vec3 color); +#ifdef GAMMA_CORRECT +vec3 legacyGamma(vec3 color) +{ +    vec3 c = 1. - clamp(color, vec3(0.), vec3(1.)); +    c = 1. - pow(c, vec3(gamma)); // s/b inverted already CPU-side + +    return c; +} +#endif +  void main()  {      //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB) @@ -47,8 +61,18 @@ void main()      diff.rgb = clamp(diff.rgb, vec3(0.0), vec3(1.0));  #endif -    diff.rgb = clampHDRRange(diff.rgb); +#ifdef GAMMA_CORRECT +    diff.rgb = linear_to_srgb(diff.rgb); + +#ifdef LEGACY_GAMMA +    diff.rgb = legacyGamma(diff.rgb); +#endif + +#endif + +    diff.rgb = clamp(diff.rgb, vec3(0.0), vec3(1.0)); // We should always be 0-1 past this point +      //debugExposure(diff.rgb); -    frag_color = max(diff, vec4(0)); +    frag_color = diff;  } diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index d4b05dde72..b8fd3dc189 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -372,7 +372,7 @@ struct AttachmentInfo  - (void)sendEvent:(NSEvent *)event  {      [super sendEvent:event]; -    if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask)) +    if ([event type] == NSEventTypeKeyUp && ([event modifierFlags] & NSEventModifierFlagCommand))      {             [[self keyWindow] sendEvent:event];      } diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 98a1fd740b..6422d1befa 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1388,6 +1388,7 @@ bool LLAppViewer::doFrame()  #endif      LL_RECORD_BLOCK_TIME(FTM_FRAME); +    LL_PROFILE_GPU_ZONE("Frame");      {      // and now adjust the visuals from previous frame.      if(LLPerfStats::tunables.userAutoTuneEnabled && LLPerfStats::tunables.tuningFlag != LLPerfStats::Tunables::Nothing) @@ -1477,24 +1478,26 @@ bool LLAppViewer::doFrame()          if (!LLApp::isExiting())          { -            LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df JoystickKeyboard"); -            pingMainloopTimeout("Main:JoystickKeyboard"); - -            // Scan keyboard for movement keys.  Command keys and typing -            // are handled by windows callbacks.  Don't do this until we're -            // done initializing.  JC -            if (gViewerWindow -                && (gHeadlessClient || gViewerWindow->getWindow()->getVisible()) -                && gViewerWindow->getActive() -                && !gViewerWindow->getWindow()->getMinimized() -                && LLStartUp::getStartupState() == STATE_STARTED -                && (gHeadlessClient || !gViewerWindow->getShowProgress()) -                && !gFocusMgr.focusLocked())              { -                LLPerfStats::RecordSceneTime T (LLPerfStats::StatType_t::RENDER_IDLE); -                joystick->scanJoystick(); -                gKeyboard->scanKeyboard(); -                gViewerInput.scanMouse(); +                LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df JoystickKeyboard"); +                pingMainloopTimeout("Main:JoystickKeyboard"); + +                // Scan keyboard for movement keys.  Command keys and typing +                // are handled by windows callbacks.  Don't do this until we're +                // done initializing.  JC +                if (gViewerWindow +                    && (gHeadlessClient || gViewerWindow->getWindow()->getVisible()) +                    && gViewerWindow->getActive() +                    && !gViewerWindow->getWindow()->getMinimized() +                    && LLStartUp::getStartupState() == STATE_STARTED +                    && (gHeadlessClient || !gViewerWindow->getShowProgress()) +                    && !gFocusMgr.focusLocked()) +                { +                    LLPerfStats::RecordSceneTime T(LLPerfStats::StatType_t::RENDER_IDLE); +                    joystick->scanJoystick(); +                    gKeyboard->scanKeyboard(); +                    gViewerInput.scanMouse(); +                }              }              // Update state based on messages, user input, object idle. @@ -3230,17 +3233,6 @@ bool LLAppViewer::initWindow()      LLNotificationsUI::LLNotificationManager::getInstance(); - -#ifdef LL_DARWIN -    //Satisfy both MAINT-3135 (OSX 10.6 and earlier) MAINT-3288 (OSX 10.7 and later) -    LLOSInfo& os_info = LLOSInfo::instance(); -    if (os_info.mMajorVer == 10 && os_info.mMinorVer < 7) -    { -        if ( os_info.mMinorVer == 6 && os_info.mBuild < 8 ) -            gViewerWindow->getWindow()->setOldResize(true); -    } -#endif -      if (gSavedSettings.getBOOL("WindowMaximized"))      {          gViewerWindow->getWindow()->maximize(); @@ -3355,6 +3347,11 @@ LLSD LLAppViewer::getViewerInfo() const      info["VIEWER_VERSION_STR"] = versionInfo.getVersion();      info["CHANNEL"] = versionInfo.getChannel();      info["ADDRESS_SIZE"] = ADDRESS_SIZE; +#if LL_ARM64 +    info["ARCHITECTURE"] = "ARM"; +#else +    info["ARCHITECTURE"] = "x86"; +#endif      std::string build_config = versionInfo.getBuildConfig();      if (build_config != "Release")      { @@ -4490,6 +4487,9 @@ bool LLAppViewer::initCache()      const U32 CACHE_NUMBER_OF_REGIONS_FOR_OBJECTS = 128;      LLVOCache::getInstance()->initCache(LL_PATH_CACHE, CACHE_NUMBER_OF_REGIONS_FOR_OBJECTS, getObjectCacheVersion()); +    // Remove old, stale CEF cache folders +    purgeCefStaleCaches(); +      return true;  } @@ -4514,18 +4514,27 @@ void LLAppViewer::loadKeyBindings()      LLUrlRegistry::instance().setKeybindingHandler(&gViewerInput);  } +// As per GHI #4498, remove old, stale CEF cache folders from previous sessions +void LLAppViewer::purgeCefStaleCaches() +{ +    // TODO: we really shouldn't use a hard coded name for the cache folder here... +    const std::string browser_parent_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "cef_cache"); +    if (LLFile::isdir(browser_parent_cache)) +    { +        // This is a sledgehammer approach - nukes the cef_cache dir entirely +        // which is then recreated the first time a CEF instance creates an +        // individual cache folder. If we ever decide to retain some folders +        // e.g. Search UI cache - then we will need a more granular approach. +        gDirUtilp->deleteDirAndContents(browser_parent_cache); +    } +} +  void LLAppViewer::purgeCache()  {      LL_INFOS("AppCache") << "Purging Cache and Texture Cache..." << LL_ENDL;      LLAppViewer::getTextureCache()->purgeCache(LL_PATH_CACHE);      LLVOCache::getInstance()->removeCache(LL_PATH_CACHE);      LLViewerShaderMgr::instance()->clearShaderCache(); -    std::string browser_cache = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "cef_cache"); -    if (LLFile::isdir(browser_cache)) -    { -        // cef does not support clear_cache and clear_cookies, so clear what we can manually. -        gDirUtilp->deleteDirAndContents(browser_cache); -    }      gDirUtilp->deleteFilesInDir(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, ""), "*");  } @@ -5712,6 +5721,8 @@ void LLAppViewer::forceErrorBreakpoint()      DebugBreak();  #elif __i386__ || __x86_64__      asm ("int $3"); +#else +    __builtin_trap();  #endif      return;  } diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index e7de2d9b28..3afde6b9f5 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -220,6 +220,7 @@ public:      void initGeneralThread();      void purgeUserDataOnExit() { mPurgeUserDataOnExit = true; } +    void purgeCefStaleCaches();  // Remove old, stale CEF cache folders      void purgeCache(); // Clear the local cache.      void purgeCacheImmediate(); //clear local cache immediately.      S32  updateTextureThreads(F32 max_time); diff --git a/indra/newview/llappviewerlinux.cpp b/indra/newview/llappviewerlinux.cpp index 18ac523e0c..ae7ed17359 100644 --- a/indra/newview/llappviewerlinux.cpp +++ b/indra/newview/llappviewerlinux.cpp @@ -118,6 +118,11 @@ static void exceptionTerminateHandler()  int main( int argc, char **argv )  { +    // Call Tracy first thing to have it allocate memory +    // https://github.com/wolfpld/tracy/issues/196 +    LL_PROFILER_FRAME_END; +    LL_PROFILER_SET_THREAD_NAME("App"); +      gArgC = argc;      gArgV = argv; diff --git a/indra/newview/llappviewermacosx-objc.h b/indra/newview/llappviewermacosx-objc.h index d0ae0a7fc2..3fbf4202f1 100644 --- a/indra/newview/llappviewermacosx-objc.h +++ b/indra/newview/llappviewermacosx-objc.h @@ -30,9 +30,6 @@  #include <string>  #include <vector> -//Why?  Because BOOL -void launchApplication(const std::string* app_name, const std::vector<std::string>* args); -  void force_ns_sxeption();  #endif // LL_LLAPPVIEWERMACOSX_OBJC_H diff --git a/indra/newview/llappviewermacosx-objc.mm b/indra/newview/llappviewermacosx-objc.mm index 9b6bfe621b..2ea3f2f171 100644 --- a/indra/newview/llappviewermacosx-objc.mm +++ b/indra/newview/llappviewermacosx-objc.mm @@ -33,45 +33,6 @@  #include "llappviewermacosx-objc.h" -void launchApplication(const std::string* app_name, const std::vector<std::string>* args) -{ - -    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; -     -	if (app_name->empty()) return; - -	NSMutableString* app_name_ns = [NSMutableString stringWithString:[[NSBundle mainBundle] resourcePath]];	//Path to resource dir -	[app_name_ns appendFormat:@"/%@", [NSString stringWithCString:app_name->c_str()  -								encoding:[NSString defaultCStringEncoding]]]; - -	NSMutableArray *args_ns = nil; -	args_ns = [[NSMutableArray alloc] init]; - -	for (int i=0; i < args->size(); ++i) -	{ -        NSLog(@"Adding string %s", (*args)[i].c_str()); -		[args_ns addObject: -			[NSString stringWithCString:(*args)[i].c_str() -						encoding:[NSString defaultCStringEncoding]]]; -	} - -    NSTask *task = [[NSTask alloc] init]; -    NSBundle *bundle = [NSBundle bundleWithPath:[[NSWorkspace sharedWorkspace] fullPathForApplication:app_name_ns]]; -    [task setLaunchPath:[bundle executablePath]]; -    [task setArguments:args_ns]; -    [task launch]; -     -//	NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; -//	NSURL *url = [NSURL fileURLWithPath:[workspace fullPathForApplication:app_name_ns]]; -// -//	NSError *error = nil; -//	[workspace launchApplicationAtURL:url options:0 configuration:[NSDictionary dictionaryWithObject:args_ns forKey:NSWorkspaceLaunchConfigurationArguments] error:&error]; -	//TODO Handle error -     -    [pool release]; -	return; -} -  void force_ns_sxeption()  {      NSException *exception = [NSException exceptionWithName:@"Forced NSException" reason:nullptr userInfo:nullptr]; diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index aab6d00573..b074c40c17 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -258,6 +258,11 @@ void infos(const std::string& message)  int main( int argc, char **argv )  { +    // Call Tracy first thing to have it allocate memory +    // https://github.com/wolfpld/tracy/issues/196 +    LL_PROFILER_FRAME_END; +    LL_PROFILER_SET_THREAD_NAME("App"); +      // Store off the command line args for use later.      gArgC = argc;      gArgV = argv; diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index d5cce28a3d..f612495953 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -260,8 +260,8 @@ void ll_nvapi_init(NvDRSSessionHandle hSession)      NvAPI_UnicodeString profile_name;      std::string app_name = LLTrans::getString("APP_NAME"); -    llutf16string w_app_name = utf8str_to_utf16str(app_name); -    wsprintf(profile_name, L"%s", w_app_name.c_str()); +    std::wstring w_app_name = ll_convert<std::wstring>(app_name); +    wsprintf(reinterpret_cast<wchar_t*>(profile_name), L"%s", w_app_name.c_str());      NvDRSProfileHandle hProfile = 0;      // (3) Check if we already have an application profile for the viewer      status = NvAPI_DRS_FindProfileByName(hSession, profile_name, &hProfile); @@ -278,7 +278,7 @@ void ll_nvapi_init(NvDRSSessionHandle hSession)          NVDRS_PROFILE profileInfo;          profileInfo.version = NVDRS_PROFILE_VER;          profileInfo.isPredefined = 0; -        wsprintf(profileInfo.profileName, L"%s", w_app_name.c_str()); +        wsprintf(reinterpret_cast<wchar_t*>(profileInfo.profileName), L"%s", w_app_name.c_str());          status = NvAPI_DRS_CreateProfile(hSession, &profileInfo, &hProfile);          if (status != NVAPI_OK) @@ -293,9 +293,9 @@ void ll_nvapi_init(NvDRSSessionHandle hSession)      NVDRS_APPLICATION profile_application;      profile_application.version = NVDRS_APPLICATION_VER; -    llutf16string w_exe_name = utf8str_to_utf16str(exe_name); +    std::wstring w_exe_name = ll_convert<std::wstring>(exe_name);      NvAPI_UnicodeString profile_app_name; -    wsprintf(profile_app_name, L"%s", w_exe_name.c_str()); +    wsprintf(reinterpret_cast<wchar_t*>(profile_app_name), L"%s", w_exe_name.c_str());      status = NvAPI_DRS_GetApplicationInfo(hSession, hProfile, profile_app_name, &profile_application);      if (status != NVAPI_OK && status != NVAPI_EXECUTABLE_NOT_FOUND) @@ -311,10 +311,10 @@ void ll_nvapi_init(NvDRSSessionHandle hSession)          NVDRS_APPLICATION application;          application.version = NVDRS_APPLICATION_VER;          application.isPredefined = 0; -        wsprintf(application.appName, L"%s", w_exe_name.c_str()); -        wsprintf(application.userFriendlyName, L"%s", w_exe_name.c_str()); -        wsprintf(application.launcher, L"%s", w_exe_name.c_str()); -        wsprintf(application.fileInFolder, L"%s", ""); +        wsprintf(reinterpret_cast<wchar_t*>(application.appName), L"%s", w_exe_name.c_str()); +        wsprintf(reinterpret_cast<wchar_t*>(application.userFriendlyName), L"%s", w_exe_name.c_str()); +        wsprintf(reinterpret_cast<wchar_t*>(application.launcher), L"%s", w_exe_name.c_str()); +        wsprintf(reinterpret_cast<wchar_t*>(application.fileInFolder), L"%s", "");          status = NvAPI_DRS_CreateApplication(hSession, hProfile, &application);          if (status != NVAPI_OK) @@ -597,7 +597,7 @@ void LLAppViewerWin32::disableWinErrorReporting()  {      std::string executable_name = gDirUtilp->getExecutableFilename(); -    if( S_OK == WerAddExcludedApplication( utf8str_to_utf16str(executable_name).c_str(), FALSE ) ) +    if( S_OK == WerAddExcludedApplication(ll_convert<std::wstring>(executable_name).c_str(), FALSE ) )      {          LL_INFOS() << "WerAddExcludedApplication() succeeded for " << executable_name << LL_ENDL;      } diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 1c8864a9df..46696fc4a4 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -204,7 +204,7 @@ public:          NUM_RENDER_TYPES,      }; -    #ifdef LL_PROFILER_ENABLE_RENDER_DOC +    #if LL_PROFILER_ENABLE_RENDER_DOC      static inline const char* lookupPassName(U32 pass)      {          switch (pass) @@ -340,7 +340,7 @@ public:          }      }      #else -    static inline const char* lookupPass(U32 pass) { return ""; } +    static inline const char* lookupPassName(U32 pass) { return ""; }      #endif      LLRenderPass(const U32 type); diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index e4b81ba00a..d2b862eb58 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -771,9 +771,6 @@ static void xform4a(LLVector4a &tex_coord, const LLVector4a& trans, const LLVect      // Texture transforms are done about the center of the face.      st.setAdd(tex_coord, trans); -    // Handle rotation -    LLVector4a rot_st; -      // <s0 * cosAng, s0*-sinAng, s1*cosAng, s1*-sinAng>      LLVector4a s0;      s0.splat(st, 0); @@ -2258,8 +2255,6 @@ bool LLFace::calcPixelArea(F32& cos_angle_to_view_dir, F32& radius)                          if (joint)                          { -                            LLVector4a jointPos; -                              LLMatrix4a worldMat;                              worldMat.loadu((F32*)&joint->getWorldMatrix().mMatrix[0][0]); diff --git a/indra/newview/llfilepicker.cpp b/indra/newview/llfilepicker.cpp index 9e19d16957..d26a3784a2 100644 --- a/indra/newview/llfilepicker.cpp +++ b/indra/newview/llfilepicker.cpp @@ -292,7 +292,7 @@ bool LLFilePicker::getOpenFile(ELoadFilter filter, bool blocking)      success = GetOpenFileName(&mOFN);      if (success)      { -        std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); +        std::string filename = ll_convert<std::string>(std::wstring(mFilesW));          mFiles.push_back(filename);      } @@ -358,7 +358,7 @@ bool LLFilePicker::getMultipleOpenFiles(ELoadFilter filter, bool blocking)          // lengths.          if( wcslen(mOFN.lpstrFile) > mOFN.nFileOffset ) /*Flawfinder: ignore*/          { -            std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); +            std::string filename = ll_convert<std::string>(std::wstring(mFilesW));              mFiles.push_back(filename);          }          else @@ -372,7 +372,7 @@ bool LLFilePicker::getMultipleOpenFiles(ELoadFilter filter, bool blocking)                      break;                  if (*tptrw == 0)                      tptrw++; // shouldn't happen? -                std::string filename = utf16str_to_utf8str(llutf16string(tptrw)); +                std::string filename = ll_convert<std::string>(std::wstring(tptrw));                  if (dirname.empty())                      dirname = filename + "\\";                  else @@ -418,7 +418,7 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,      mOFN.lpstrFile = mFilesW;      if (!filename.empty())      { -        llutf16string tstring = utf8str_to_utf16str(filename); +        std::wstring tstring = ll_convert<std::wstring>(filename);          wcsncpy(mFilesW, tstring.c_str(), FILENAME_BUFFER_SIZE);    }   /*Flawfinder: ignore*/      else      { @@ -600,7 +600,7 @@ bool LLFilePicker::getSaveFile(ESaveFilter filter, const std::string& filename,              success = GetSaveFileName(&mOFN);              if (success)              { -                std::string filename = utf16str_to_utf8str(llutf16string(mFilesW)); +                std::string filename = ll_convert<std::string>(std::wstring(mFilesW));                  mFiles.push_back(filename);              }          } diff --git a/indra/newview/llfilepicker_mac.mm b/indra/newview/llfilepicker_mac.mm index b21bc724fb..978069457c 100644 --- a/indra/newview/llfilepicker_mac.mm +++ b/indra/newview/llfilepicker_mac.mm @@ -86,7 +86,7 @@ std::unique_ptr<std::vector<std::string>> doLoadDialog(const std::vector<std::st          result = [panel runModal]; -        if (result == NSOKButton) +        if (result == NSModalResponseOK)          {              NSArray *filesToOpen = [panel URLs];              int i, count = [filesToOpen count]; @@ -173,7 +173,7 @@ std::unique_ptr<std::string> doSaveDialog(const std::string* file,          [panel setNameFieldStringValue: fileName];          [panel setDirectoryURL: url];          if([panel runModal] == -           NSFileHandlingPanelOKButton) +           NSModalResponseOK)          {              NSURL* url = [panel URL];              NSString* p = [url path]; @@ -211,7 +211,7 @@ void doSaveDialogModeless(const std::string* file,  		[panel beginWithCompletionHandler:^(NSModalResponse result)  		{ -			if (result == NSOKButton) +            if (result == NSModalResponseOK)  			{  				NSURL* url = [panel URL];  				NSString* p = [url path]; diff --git a/indra/newview/llfloateremojipicker.cpp b/indra/newview/llfloateremojipicker.cpp index ffbda0265d..af0ef7223d 100644 --- a/indra/newview/llfloateremojipicker.cpp +++ b/indra/newview/llfloateremojipicker.cpp @@ -1285,7 +1285,7 @@ void LLFloaterEmojiPicker::saveState()              if (!recentlyUsed.empty())                  recentlyUsed += ",";              char buffer[32]; -            sprintf(buffer, "%u", (U32)emoji); +            snprintf(buffer, sizeof(buffer), "%u", (U32)emoji);              recentlyUsed += buffer;              if (!--maxCount)                  break; @@ -1302,7 +1302,7 @@ void LLFloaterEmojiPicker::saveState()              if (!frequentlyUsed.empty())                  frequentlyUsed += ",";              char buffer[32]; -            sprintf(buffer, "%u:%u", (U32)it.first, (U32)it.second); +            snprintf(buffer, sizeof(buffer), "%u:%u", (U32)it.first, (U32)it.second);              frequentlyUsed += buffer;              if (!--maxCount)                  break; diff --git a/indra/newview/llfloaterjoystick.cpp b/indra/newview/llfloaterjoystick.cpp index 68b11ec92b..871f924316 100644 --- a/indra/newview/llfloaterjoystick.cpp +++ b/indra/newview/llfloaterjoystick.cpp @@ -78,7 +78,7 @@ BOOL CALLBACK di8_list_devices_callback(LPCDIDEVICEINSTANCE device_instance_ptr,      // Capable of detecting devices like Oculus Rift      if (device_instance_ptr && pvRef)      { -        std::string product_name = utf16str_to_utf8str(llutf16string(device_instance_ptr->tszProductName)); +        std::string product_name = ll_convert<std::string>(std::wstring(device_instance_ptr->tszProductName));          S32 size = sizeof(GUID);          LLSD::Binary data; //just an std::vector          data.resize(size); diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index c2d7d34287..c93b837e82 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -238,7 +238,7 @@ private:      std::unique_ptr< ll::prefs::SearchData > mSearchData;      bool mSearchDataDirty; -    boost::signals2::connection	mImpostorsChangedSignal; +    boost::signals2::connection mImpostorsChangedSignal;      boost::signals2::connection mComplexityChangedSignal;      void onUpdateFilterTerm( bool force = false ); diff --git a/indra/newview/llfloaterpreferencesgraphicsadvanced.h b/indra/newview/llfloaterpreferencesgraphicsadvanced.h index a1a54f238d..6f793c1379 100644 --- a/indra/newview/llfloaterpreferencesgraphicsadvanced.h +++ b/indra/newview/llfloaterpreferencesgraphicsadvanced.h @@ -61,7 +61,7 @@ protected:      void        onBtnOK(const LLSD& userdata);      void        onBtnCancel(const LLSD& userdata); -    boost::signals2::connection	mImpostorsChangedSignal; +    boost::signals2::connection mImpostorsChangedSignal;      boost::signals2::connection mComplexityChangedSignal;      boost::signals2::connection mComplexityModeChangedSignal;      boost::signals2::connection mLODFactorChangedSignal; diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index d8b3f996aa..8da835ed7d 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -45,7 +45,9 @@  #include "llworld.h"  #include "tinygltf/tiny_gltf.h" -#include <strstream> + +#include <boost/iostreams/device/array.hpp> +#include <boost/iostreams/stream.hpp>  #include <unordered_set> @@ -555,8 +557,7 @@ void LLGLTFMaterialList::onAssetLoadComplete(const LLUUID& id, LLAssetType::ETyp                  LLSD asset;                  // read file into buffer -                std::istrstream str(&buffer[0], static_cast<S32>(buffer.size())); - +                boost::iostreams::stream<boost::iostreams::array_source> str(buffer.data(), buffer.size());                  if (LLSDSerialize::deserialize(asset, str, buffer.size()))                  {                      if (asset.has("version") && LLGLTFMaterial::isAcceptedVersion(asset["version"].asString())) diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp index 0b792efa1f..02b6751307 100644 --- a/indra/newview/llgltfmaterialpreviewmgr.cpp +++ b/indra/newview/llgltfmaterialpreviewmgr.cpp @@ -530,12 +530,21 @@ bool LLGLTFPreviewTexture::render()      gPipeline.copyScreenSpaceReflections(&screen, &gPipeline.mSceneMap);      gPipeline.generateLuminance(&screen, &gPipeline.mLuminanceMap);      gPipeline.generateExposure(&gPipeline.mLuminanceMap, &gPipeline.mExposureMap, /*use_history = */ false); +/* +    gPipeline.gammaCorrect(&screen, &gPipeline.mPostPingMap); +*/      }      U16 activeRT = 0;      gPipeline.gammaCorrect(&screen, &gPipeline.mPostMaps[activeRT]);      LLVertexBuffer::unbind(); +/* +    gPipeline.generateGlow(&gPipeline.mPostPingMap); +    gPipeline.combineGlow(&gPipeline.mPostPingMap, &screen); +    gPipeline.renderDoF(&screen, &gPipeline.mPostPingMap); +    gPipeline.applyFXAA(&gPipeline.mPostPingMap, &screen); +*/      gPipeline.generateGlow(&gPipeline.mPostMaps[activeRT]);      gPipeline.combineGlow(&gPipeline.mPostMaps[activeRT], &gPipeline.mPostMaps[1-activeRT]); diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 343bb01072..9efe70786d 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -92,6 +92,7 @@ void LLHeroProbeManager::update()      }      LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; +    LL_PROFILE_GPU_ZONE("hero manager update");      llassert(!gCubeSnapshot); // assert a snapshot is not in progress      if (LLAppViewer::instance()->logoutRequestSent())      { @@ -293,6 +294,9 @@ void LLHeroProbeManager::renderProbes()  // In effect this simulates single-bounce lighting.  void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face, bool is_dynamic, F32 near_clip)  { +    LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; +    LL_PROFILE_GPU_ZONE("hero probe update"); +      // hacky hot-swap of camera specific render targets      gPipeline.mRT = &gPipeline.mHeroProbeRT; @@ -363,7 +367,7 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face, bool          for (int i = 0; i < mMipChain.size(); ++i)          { -            LL_PROFILE_GPU_ZONE("probe mip"); +            LL_PROFILE_GPU_ZONE("hero probe mip");              mMipChain[i].bindTarget();              if (i == 0)              { @@ -390,7 +394,7 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face, bool              if (mip >= 0)              { -                LL_PROFILE_GPU_ZONE("probe mip copy"); +                LL_PROFILE_GPU_ZONE("hero probe mip copy");                  mTexture->bind(0);                  glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, sourceIdx * 6 + face, 0, 0, res, res); @@ -440,7 +444,7 @@ void LLHeroProbeManager::generateRadiance(LLReflectionMap* probe)              for (int i = 0; i < mMipChain.size() / 4; ++i)              { -                LL_PROFILE_GPU_ZONE("probe radiance gen"); +                LL_PROFILE_GPU_ZONE("hero probe radiance gen");                  static LLStaticHashedString sMipLevel("mipLevel");                  static LLStaticHashedString sRoughness("roughness");                  static LLStaticHashedString sWidth("u_width"); @@ -487,6 +491,7 @@ void LLHeroProbeManager::updateUniforms()      }      LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; +    LL_PROFILE_GPU_ZONE("hpmu - uniforms")      LLMatrix4a modelview;      modelview.loadu(gGLModelView); diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index d1fd82a7f1..e6b33453d5 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -3890,6 +3890,31 @@ void LLInventoryAction::fileUploadLocation(const LLUUID& dest_id, const std::str      }  } +bool LLInventoryAction::isFileUploadLocation(const LLUUID& dest_id, const std::string& action) +{ +    if (action == "def_model") +    { +        return gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_OBJECT) == dest_id; +    } +    else if (action == "def_texture") +    { +        return gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_TEXTURE) == dest_id; +    } +    else if (action == "def_sound") +    { +        return gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_SOUND) == dest_id; +    } +    else if (action == "def_animation") +    { +        return gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_ANIMATION) == dest_id; +    } +    else if (action == "def_pbr_material") +    { +        return gInventory.findUserDefinedCategoryUUIDForType(LLFolderType::FT_MATERIAL) == dest_id; +    } +    return false; +} +  void LLInventoryAction::onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response, LLHandle<LLFolderView> root)  {      S32 option = LLNotificationsUtil::getSelectedOption(notification, response); diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index ae7bb8770d..77a2a18877 100644 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -653,6 +653,7 @@ struct LLInventoryAction      static void onItemsRemovalConfirmation(const LLSD& notification, const LLSD& response, LLHandle<LLFolderView> root);      static void removeItemFromDND(LLFolderView* root);      static void fileUploadLocation(const LLUUID& dest_id, const std::string& action); +    static bool isFileUploadLocation(const LLUUID& dest_id, const std::string& action);      static void saveMultipleTextures(const std::vector<std::string>& filenames, std::set<LLFolderViewItem*> selected_items, LLInventoryModel* model); diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp index 388e1604ea..b9d4f4471a 100644 --- a/indra/newview/llinventorygallerymenu.cpp +++ b/indra/newview/llinventorygallerymenu.cpp @@ -112,6 +112,7 @@ LLContextMenu* LLInventoryGalleryContextMenu::createMenu()      enable_registrar.add("Inventory.CanSetUploadLocation", boost::bind(&LLInventoryGalleryContextMenu::canSetUploadLocation, this, _2));      enable_registrar.add("Inventory.CanSetFavoriteFolder", boost::bind(&LLInventoryGalleryContextMenu::canSetFavoriteFolder, this)); +    enable_registrar.add("Inventory.FileUploadLocation.Check", boost::bind(&LLInventoryGalleryContextMenu::isUploadLocationSelected, this, _2));      enable_registrar.add("Inventory.EnvironmentEnabled", [](LLUICtrl*, const LLSD&)                           { @@ -491,6 +492,12 @@ void LLInventoryGalleryContextMenu::fileUploadLocation(const LLSD& userdata)      LLInventoryAction::fileUploadLocation(mUUIDs.front(), param);  } +bool LLInventoryGalleryContextMenu::isUploadLocationSelected(const LLSD& userdata) +{ +    const std::string param = userdata.asString(); +    return LLInventoryAction::isFileUploadLocation(mUUIDs.front(), param); +} +  bool LLInventoryGalleryContextMenu::canSetUploadLocation(const LLSD& userdata)  {      if (mUUIDs.size() != 1) diff --git a/indra/newview/llinventorygallerymenu.h b/indra/newview/llinventorygallerymenu.h index 7f6598e171..d91c752544 100644 --- a/indra/newview/llinventorygallerymenu.h +++ b/indra/newview/llinventorygallerymenu.h @@ -47,6 +47,7 @@ protected:      void updateMenuItemsVisibility(LLContextMenu* menu);      void fileUploadLocation(const LLSD& userdata); +    bool isUploadLocationSelected(const LLSD& userdata);      bool canSetUploadLocation(const LLSD& userdata);      void setFavoriteFolder(); diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 0da7e35c38..4b436e894a 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -188,6 +188,7 @@ LLInventoryPanel::LLInventoryPanel(const LLInventoryPanel::Params& p) :      mCommitCallbackRegistrar.add("Inventory.Share",  boost::bind(&LLAvatarActions::shareWithAvatars, this));      mCommitCallbackRegistrar.add("Inventory.FileUploadLocation", boost::bind(&LLInventoryPanel::fileUploadLocation, this, _2));      mCommitCallbackRegistrar.add("Inventory.SetFavoriteFolder", boost::bind(&LLInventoryPanel::setFavoriteFolder, this)); +    mEnableCallbackRegistrar.add("Inventory.FileUploadLocation.Check", boost::bind(&LLInventoryPanel::isUploadLocationSelected, this, _2));      mCommitCallbackRegistrar.add("Inventory.OpenNewFolderWindow", boost::bind(&LLInventoryPanel::openSingleViewInventory, this, LLUUID()));  } @@ -1838,6 +1839,13 @@ void LLInventoryPanel::setFavoriteFolder()      gSavedPerAccountSettings.setString("FavoriteFolder", LLFolderBridge::sSelf.get()->getUUID().asString());  } +bool LLInventoryPanel::isUploadLocationSelected(const LLSD& userdata) +{ +    const std::string param = userdata.asString(); +    const LLUUID dest = LLFolderBridge::sSelf.get()->getUUID(); +    return LLInventoryAction::isFileUploadLocation(dest, param); +} +  void LLInventoryPanel::openSingleViewInventory(LLUUID folder_id)  {      LLPanelMainInventory::newFolderWindow(folder_id.isNull() ? LLFolderBridge::sSelf.get()->getUUID() : folder_id); @@ -2103,7 +2111,7 @@ void LLInventoryPanel::removeItemID(const LLUUID& id)          ++it)      {          mItemMap.erase((*it)->getUUID()); -    } +}      for (LLInventoryModel::item_array_t::iterator it = items.begin(),   end_it  = items.end();          it != end_it; diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index b7fef98413..5a73df54b0 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -226,6 +226,7 @@ public:      bool beginIMSession();      void fileUploadLocation(const LLSD& userdata);      void setFavoriteFolder(); +    bool isUploadLocationSelected(const LLSD& userdata);      void openSingleViewInventory(LLUUID folder_id = LLUUID());      void purgeSelectedItems();      bool attachObject(const LLSD& userdata); diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp index e31fbb188a..a99c9df0ff 100644 --- a/indra/newview/lllocalbitmaps.cpp +++ b/indra/newview/lllocalbitmaps.cpp @@ -196,7 +196,7 @@ bool LLLocalBitmap::updateSelf(EUpdateType optional_firstupdate)  #ifndef LL_WINDOWS              const std::time_t temp_time = boost::filesystem::last_write_time(boost::filesystem::path(mFilename));  #else -            const std::time_t temp_time = boost::filesystem::last_write_time(boost::filesystem::path(utf8str_to_utf16str(mFilename))); +            const std::time_t temp_time = boost::filesystem::last_write_time(boost::filesystem::path(ll_convert<std::wstring>(mFilename)));  #endif              LLSD new_last_modified = asctime(localtime(&temp_time)); diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp index fab18f2d26..d6facad23d 100644 --- a/indra/newview/lllocalgltfmaterials.cpp +++ b/indra/newview/lllocalgltfmaterials.cpp @@ -134,7 +134,7 @@ bool LLLocalGLTFMaterial::updateSelf()  #ifndef LL_WINDOWS              const std::time_t temp_time = boost::filesystem::last_write_time(boost::filesystem::path(mFilename));  #else -            const std::time_t temp_time = boost::filesystem::last_write_time(boost::filesystem::path(utf8str_to_utf16str(mFilename))); +            const std::time_t temp_time = boost::filesystem::last_write_time(boost::filesystem::path(ll_convert<std::wstring>(mFilename)));  #endif              LLSD new_last_modified = asctime(localtime(&temp_time)); diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp index aa03001389..51c38aba3a 100644 --- a/indra/newview/llmachineid.cpp +++ b/indra/newview/llmachineid.cpp @@ -293,7 +293,7 @@ bool LLWMIMethods::getGenericSerialNumber(const BSTR &select, const LPCWSTR &var          if (validate_as_uuid)          {              std::wstring ws(serialNumber, serial_size); -            std::string str = ll_convert_wide_to_string(ws); +            std::string str = ll_convert<std::string>(ws);              if (!LLUUID::validate(str))              { @@ -315,7 +315,7 @@ bool LLWMIMethods::getGenericSerialNumber(const BSTR &select, const LPCWSTR &var                  continue;              }          } -        LL_INFOS("AppInit") << " Serial Number : " << vtProp.bstrVal << LL_ENDL; +        LL_INFOS("AppInit") << " Serial Number : " << ll_convert_wide_to_string(std::wstring(vtProp.bstrVal, SysStringLen(vtProp.bstrVal))) << LL_ENDL;          unsigned int j = 0; diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 3e5d6d1171..cac72bb085 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -63,8 +63,9 @@  #include "tinygltf/tiny_gltf.h"  #include "lltinygltfhelper.h" -#include <strstream> +#include <boost/iostreams/device/array.hpp> +#include <boost/iostreams/stream.hpp>  const std::string MATERIAL_BASE_COLOR_DEFAULT_NAME = "Base Color";  const std::string MATERIAL_NORMAL_DEFAULT_NAME = "Normal"; @@ -1246,7 +1247,7 @@ bool LLMaterialEditor::decodeAsset(const std::vector<char>& buffer)  {      LLSD asset; -    std::istrstream str(&buffer[0], buffer.size()); +    boost::iostreams::stream<boost::iostreams::array_source> str(buffer.data(), buffer.size());      if (LLSDSerialize::deserialize(asset, str, buffer.size()))      {          if (asset.has("version") && LLGLTFMaterial::isAcceptedVersion(asset["version"].asString())) diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp index 202008f7f9..c7b60b2fd5 100644 --- a/indra/newview/llmediactrl.cpp +++ b/indra/newview/llmediactrl.cpp @@ -347,6 +347,7 @@ bool LLMediaCtrl::handleRightMouseDown( S32 x, S32 y, MASK mask )      {          LLUICtrl::CommitCallbackRegistry::ScopedRegistrar registar;          registar.add("Open.WebInspector", boost::bind(&LLMediaCtrl::onOpenWebInspector, this)); +        registar.add("Open.ShowSource", boost::bind(&LLMediaCtrl::onShowSource, this));          // stinson 05/05/2014 : use this as the parent of the context menu if the static menu          // container has yet to be created @@ -364,8 +365,9 @@ bool LLMediaCtrl::handleRightMouseDown( S32 x, S32 y, MASK mask )      {          // hide/show debugging options          bool media_plugin_debugging_enabled = gSavedSettings.getBOOL("MediaPluginDebugging"); +        menu->setItemVisible("debug_separator", media_plugin_debugging_enabled);          menu->setItemVisible("open_webinspector", media_plugin_debugging_enabled ); -        menu->setItemVisible("debug_separator", media_plugin_debugging_enabled ); +        menu->setItemVisible("show_page_source", media_plugin_debugging_enabled);          menu->show(x, y);          LLMenuGL::showPopup(this, menu, x, y); @@ -444,6 +446,12 @@ void LLMediaCtrl::onOpenWebInspector()          mMediaSource->getMediaPlugin()->showWebInspector( true );  } +void LLMediaCtrl::onShowSource() +{ +    if (mMediaSource && mMediaSource->hasMedia()) +        mMediaSource->getMediaPlugin()->showPageSource(); +} +  ////////////////////////////////////////////////////////////////////////////////  //  bool LLMediaCtrl::handleKeyHere( KEY key, MASK mask ) diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h index 9f9564af46..a644ef3071 100644 --- a/indra/newview/llmediactrl.h +++ b/indra/newview/llmediactrl.h @@ -171,6 +171,7 @@ public:          // right click debugging item          void onOpenWebInspector(); +        void onShowSource();          LLUUID getTextureID() {return mMediaTextureID;} diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index b1c8b5f36a..86071e38e1 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -645,7 +645,7 @@ void LLPanelPrimMediaControls::updateShape()          vert_it = vect_face.begin();          vert_end = vect_face.end(); -        glm::mat4 mat; +        glm::mat4 mat = glm::identity<glm::mat4>();          if (!is_hud)          {              mat = get_current_projection() * get_current_modelview(); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index fa4a725fda..eb3d2eb715 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -212,6 +212,7 @@ void LLReflectionMapManager::update()      }      LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; +    LL_PROFILE_GPU_ZONE("reflection manager update");      llassert(!gCubeSnapshot); // assert a snapshot is not in progress      if (LLAppViewer::instance()->logoutRequestSent())      { @@ -841,6 +842,8 @@ void LLReflectionMapManager::doProbeUpdate()  // In effect this simulates single-bounce lighting.  void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)  { +    LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; +    LL_PROFILE_GPU_ZONE("probe update");      // hacky hot-swap of camera specific render targets      gPipeline.mRT = &gPipeline.mAuxillaryRT; @@ -1217,6 +1220,7 @@ void LLReflectionMapManager::updateUniforms()      }      LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; +    LL_PROFILE_GPU_ZONE("rmmu - uniforms")      mReflectionMaps.resize(mReflectionProbeCount); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 8f5585b6b1..f6ad29d085 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -410,6 +410,7 @@ static void update_tp_display(bool minimized)  void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)  {      LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Render"); +    LL_PROFILE_GPU_ZONE("Render");      LLPerfStats::RecordSceneTime T (LLPerfStats::StatType_t::RENDER_DISPLAY); // render time capture - This is the main stat for overall rendering. @@ -716,6 +717,7 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot)          if (gPipeline.RenderMirrors && !gSnapshot)          {              LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("Update hero probes"); +            LL_PROFILE_GPU_ZONE("hero manager")              gPipeline.mHeroProbeManager.update();              gPipeline.mHeroProbeManager.renderProbes();          } diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index 9d45ea24b9..8edb21956f 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -144,7 +144,7 @@ BOOL CALLBACK di8_devices_callback(LPCDIDEVICEINSTANCE device_instance_ptr, LPVO      // Capable of detecting devices like Oculus Rift      if (device_instance_ptr)      { -        std::string product_name = utf16str_to_utf8str(llutf16string(device_instance_ptr->tszProductName)); +        std::string product_name = ll_convert<std::string>(std::wstring(device_instance_ptr->tszProductName));          LLSD guid = LLViewerJoystick::getInstance()->getDeviceUUID(); @@ -211,7 +211,7 @@ BOOL CALLBACK di8_devices_callback(LPCDIDEVICEINSTANCE device_instance_ptr, LPVO  // This is GUID2 so teoretically it can be memcpy copied into LLUUID  void guid_from_string(GUID &guid, const std::string &input)  { -    CLSIDFromString(utf8str_to_utf16str(input).c_str(), &guid); +    CLSIDFromString(ll_convert<std::wstring>(input).c_str(), &guid);  }  std::string string_from_guid(const GUID &guid) @@ -221,7 +221,7 @@ std::string string_from_guid(const GUID &guid)      // use guidString... -    std::string res = utf16str_to_utf8str(llutf16string(guidString)); +    std::string res = ll_convert<std::string>(std::wstring(guidString));      // ensure memory is freed      ::CoTaskMemFree(guidString); diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 09bb4a35ad..10a29f3fb2 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -3528,6 +3528,46 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla  ////////////////////////////////////////////////////////////////////////////////  // virtual  void +LLViewerMediaImpl::undo() +{ +    if (mMediaSource) +        mMediaSource->undo(); +} + +//////////////////////////////////////////////////////////////////////////////// +// virtual +bool +LLViewerMediaImpl::canUndo() const +{ +    if (mMediaSource) +        return mMediaSource->canUndo(); +    else +        return FALSE; +} + +//////////////////////////////////////////////////////////////////////////////// +// virtual +void +LLViewerMediaImpl::redo() +{ +    if (mMediaSource) +        mMediaSource->redo(); +} + +//////////////////////////////////////////////////////////////////////////////// +// virtual +bool +LLViewerMediaImpl::canRedo() const +{ +    if (mMediaSource) +        return mMediaSource->canRedo(); +    else +        return FALSE; +} + +//////////////////////////////////////////////////////////////////////////////// +// virtual +void  LLViewerMediaImpl::cut()  {      if (mMediaSource) @@ -3585,6 +3625,46 @@ LLViewerMediaImpl::canPaste() const          return false;  } +//////////////////////////////////////////////////////////////////////////////// +// virtual +void +LLViewerMediaImpl::doDelete() +{ +    if (mMediaSource) +        mMediaSource->doDelete(); +} + +//////////////////////////////////////////////////////////////////////////////// +// virtual +bool +LLViewerMediaImpl::canDoDelete() const +{ +    if (mMediaSource) +        return mMediaSource->canDoDelete(); +    else +        return FALSE; +} + +//////////////////////////////////////////////////////////////////////////////// +// virtual +void +LLViewerMediaImpl::selectAll() +{ +    if (mMediaSource) +        mMediaSource->selectAll(); +} + +//////////////////////////////////////////////////////////////////////////////// +// virtual +bool +LLViewerMediaImpl::canSelectAll() const +{ +    if (mMediaSource) +        return mMediaSource->canSelectAll(); +    else +        return FALSE; +} +  void LLViewerMediaImpl::setUpdated(bool updated)  {      mIsUpdated = updated ; diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 5753615a43..c17cf59815 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -341,6 +341,12 @@ public:      /*virtual*/ void handleMediaEvent(LLPluginClassMedia* plugin, LLPluginClassMediaOwner::EMediaEvent);      // LLEditMenuHandler overrides +    /*virtual*/ void    undo(); +    /*virtual*/ bool    canUndo() const; + +    /*virtual*/ void    redo(); +    /*virtual*/ bool    canRedo() const; +      /*virtual*/ void    cut();      /*virtual*/ bool    canCut() const; @@ -350,6 +356,12 @@ public:      /*virtual*/ void    paste();      /*virtual*/ bool    canPaste() const; +    /*virtual*/ void    doDelete(); +    /*virtual*/ bool    canDoDelete() const; + +    /*virtual*/ void    selectAll(); +    /*virtual*/ bool    canSelectAll() const; +      void addObject(LLVOVolume* obj) ;      void removeObject(LLVOVolume* obj) ;      const std::list< LLVOVolume* >* getObjectList() const ; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 3e9f67bf29..f32d0aebda 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -200,6 +200,10 @@ LLGLSLShader            gDeferredCoFProgram;  LLGLSLShader            gDeferredDoFCombineProgram;  LLGLSLShader            gDeferredPostTonemapProgram;  LLGLSLShader            gNoPostTonemapProgram; +LLGLSLShader            gDeferredPostTonemapGammaCorrectProgram; +LLGLSLShader            gNoPostTonemapGammaCorrectProgram; +LLGLSLShader            gDeferredPostTonemapLegacyGammaCorrectProgram; +LLGLSLShader            gNoPostTonemapLegacyGammaCorrectProgram;  LLGLSLShader            gDeferredPostGammaCorrectProgram;  LLGLSLShader            gLegacyPostGammaCorrectProgram;  LLGLSLShader            gHDRGammaCorrectProgram; @@ -211,6 +215,7 @@ LLGLSLShader            gSMAAEdgeDetectProgram[4];  LLGLSLShader            gSMAABlendWeightsProgram[4];  LLGLSLShader            gSMAANeighborhoodBlendProgram[4];  LLGLSLShader            gCASProgram; +LLGLSLShader            gCASLegacyGammaProgram;  LLGLSLShader            gDeferredPostNoDoFProgram;  LLGLSLShader            gDeferredPostNoDoFNoiseProgram;  LLGLSLShader            gDeferredWLSkyProgram; @@ -448,6 +453,11 @@ void LLViewerShaderMgr::finalizeShaderList()      mShaderList.push_back(&gHUDPBRAlphaProgram);      mShaderList.push_back(&gDeferredPostTonemapProgram);      mShaderList.push_back(&gNoPostTonemapProgram); +    mShaderList.push_back(&gDeferredPostTonemapGammaCorrectProgram); +    mShaderList.push_back(&gNoPostTonemapGammaCorrectProgram); +    mShaderList.push_back(&gDeferredPostTonemapLegacyGammaCorrectProgram); +    mShaderList.push_back(&gNoPostTonemapLegacyGammaCorrectProgram); +    mShaderList.push_back(&gCASLegacyGammaProgram);      mShaderList.push_back(&gDeferredPostGammaCorrectProgram); // for gamma      mShaderList.push_back(&gLegacyPostGammaCorrectProgram);      mShaderList.push_back(&gHDRGammaCorrectProgram); @@ -1173,6 +1183,11 @@ bool LLViewerShaderMgr::loadShadersDeferred()          gHDRGammaCorrectProgram.unload();          gDeferredPostTonemapProgram.unload();          gNoPostTonemapProgram.unload(); +        gDeferredPostTonemapGammaCorrectProgram.unload(); +        gNoPostTonemapGammaCorrectProgram.unload(); +        gDeferredPostTonemapLegacyGammaCorrectProgram.unload(); +        gNoPostTonemapLegacyGammaCorrectProgram.unload(); +          for (auto i = 0; i < 4; ++i)          {              gFXAAProgram[i].unload(); @@ -1181,6 +1196,7 @@ bool LLViewerShaderMgr::loadShadersDeferred()              gSMAANeighborhoodBlendProgram[i].unload();          }          gCASProgram.unload(); +        gCASLegacyGammaProgram.unload();          gEnvironmentMapProgram.unload();          gDeferredWLSkyProgram.unload();          gDeferredWLCloudProgram.unload(); @@ -2558,6 +2574,74 @@ bool LLViewerShaderMgr::loadShadersDeferred()          llassert(success);      } +    if (success) +    { +        gDeferredPostTonemapGammaCorrectProgram.mName = "Deferred Tonemap Gamma Post Process"; +        gDeferredPostTonemapGammaCorrectProgram.mFeatures.hasSrgb = true; +        gDeferredPostTonemapGammaCorrectProgram.mFeatures.isDeferred = true; +        gDeferredPostTonemapGammaCorrectProgram.mFeatures.hasTonemap = true; +        gDeferredPostTonemapGammaCorrectProgram.mShaderFiles.clear(); +        gDeferredPostTonemapGammaCorrectProgram.clearPermutations(); +        gDeferredPostTonemapGammaCorrectProgram.addPermutation("GAMMA_CORRECT", "1"); +        gDeferredPostTonemapGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); +        gDeferredPostTonemapGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER)); +        gDeferredPostTonemapGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; +        success = gDeferredPostTonemapGammaCorrectProgram.createShader(); +        llassert(success); +    } + +    if (success) +    { +        gNoPostTonemapGammaCorrectProgram.mName = "No Post Tonemap Gamma Post Process"; +        gNoPostTonemapGammaCorrectProgram.mFeatures.hasSrgb = true; +        gNoPostTonemapGammaCorrectProgram.mFeatures.isDeferred = true; +        gNoPostTonemapGammaCorrectProgram.mFeatures.hasTonemap = true; +        gNoPostTonemapGammaCorrectProgram.mShaderFiles.clear(); +        gNoPostTonemapGammaCorrectProgram.clearPermutations(); +        gNoPostTonemapGammaCorrectProgram.addPermutation("GAMMA_CORRECT", "1"); +        gNoPostTonemapGammaCorrectProgram.addPermutation("NO_POST", "1"); +        gNoPostTonemapGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); +        gNoPostTonemapGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER)); +        gNoPostTonemapGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; +        success = gNoPostTonemapGammaCorrectProgram.createShader(); +        llassert(success); +    } + +    if (success) +    { +        gDeferredPostTonemapLegacyGammaCorrectProgram.mName = "Deferred Tonemap Legacy Gamma Post Process"; +        gDeferredPostTonemapLegacyGammaCorrectProgram.mFeatures.hasSrgb = true; +        gDeferredPostTonemapProgram.mFeatures.isDeferred = true; +        gDeferredPostTonemapLegacyGammaCorrectProgram.mFeatures.hasTonemap = true; +        gDeferredPostTonemapLegacyGammaCorrectProgram.mShaderFiles.clear(); +        gDeferredPostTonemapLegacyGammaCorrectProgram.clearPermutations(); +        gDeferredPostTonemapLegacyGammaCorrectProgram.addPermutation("GAMMA_CORRECT", "1"); +        gDeferredPostTonemapLegacyGammaCorrectProgram.addPermutation("LEGACY_GAMMA", "1"); +        gDeferredPostTonemapLegacyGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); +        gDeferredPostTonemapLegacyGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER)); +        gDeferredPostTonemapLegacyGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; +        success = gDeferredPostTonemapLegacyGammaCorrectProgram.createShader(); +        llassert(success); +    } + +    if (success) +    { +        gNoPostTonemapLegacyGammaCorrectProgram.mName = "No Post Tonemap Legacy Gamma Post Process"; +        gNoPostTonemapLegacyGammaCorrectProgram.mFeatures.hasSrgb = true; +        gNoPostTonemapLegacyGammaCorrectProgram.mFeatures.isDeferred = true; +        gNoPostTonemapLegacyGammaCorrectProgram.mFeatures.hasTonemap = true; +        gNoPostTonemapLegacyGammaCorrectProgram.mShaderFiles.clear(); +        gNoPostTonemapLegacyGammaCorrectProgram.clearPermutations(); +        gNoPostTonemapLegacyGammaCorrectProgram.addPermutation("NO_POST", "1"); +        gNoPostTonemapLegacyGammaCorrectProgram.addPermutation("GAMMA_CORRECT", "1"); +        gNoPostTonemapLegacyGammaCorrectProgram.addPermutation("LEGACY_GAMMA", "1"); +        gNoPostTonemapLegacyGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); +        gNoPostTonemapLegacyGammaCorrectProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredTonemap.glsl", GL_FRAGMENT_SHADER)); +        gNoPostTonemapLegacyGammaCorrectProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; +        success = gNoPostTonemapLegacyGammaCorrectProgram.createShader(); +        llassert(success); +    } +      if (success && gGLManager.mGLVersion > 3.9f)      {          std::vector<std::pair<std::string, std::string>> quality_levels = { {"12", "Low"}, @@ -2741,6 +2825,27 @@ bool LLViewerShaderMgr::loadShadersDeferred()          }      } +    if (success && gGLManager.mGLVersion > 4.05f) +    { +        gCASLegacyGammaProgram.mName = "Contrast Adaptive Sharpening Legacy Gamma Shader"; +        gCASLegacyGammaProgram.mFeatures.hasSrgb = true; +        gCASLegacyGammaProgram.mShaderFiles.clear(); +        gCASLegacyGammaProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); +        gCASLegacyGammaProgram.mShaderFiles.push_back(make_pair("deferred/CASF.glsl", GL_FRAGMENT_SHADER)); +        gCASLegacyGammaProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; +        gCASLegacyGammaProgram.clearPermutations(); +        gCASLegacyGammaProgram.addPermutation("GAMMA_CORRECT", "1"); +        gCASLegacyGammaProgram.addPermutation("LEGACY_GAMMA", "1"); +        success = gCASLegacyGammaProgram.createShader(); +        // llassert(success); +        if (!success) +        { +            LL_WARNS() << "Failed to create shader '" << gCASProgram.mName << "', disabling!" << LL_ENDL; +            // continue as if this shader never happened +            success = true; +        } +    } +      if (success)      {          gDeferredPostProgram.mName = "Deferred Post Shader"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 7f989f281e..f503401510 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -250,6 +250,7 @@ extern LLGLSLShader         gSMAAEdgeDetectProgram[4];  extern LLGLSLShader         gSMAABlendWeightsProgram[4];  extern LLGLSLShader         gSMAANeighborhoodBlendProgram[4];  extern LLGLSLShader         gCASProgram; +extern LLGLSLShader         gCASLegacyGammaProgram;  extern LLGLSLShader         gDeferredPostNoDoFProgram;  extern LLGLSLShader         gDeferredPostNoDoFNoiseProgram;  extern LLGLSLShader         gDeferredPostGammaCorrectProgram; @@ -257,6 +258,10 @@ extern LLGLSLShader         gLegacyPostGammaCorrectProgram;  extern LLGLSLShader         gHDRGammaCorrectProgram;  extern LLGLSLShader         gDeferredPostTonemapProgram;  extern LLGLSLShader         gNoPostTonemapProgram; +extern LLGLSLShader         gDeferredPostTonemapGammaCorrectProgram; +extern LLGLSLShader         gNoPostTonemapGammaCorrectProgram; +extern LLGLSLShader         gDeferredPostTonemapLegacyGammaCorrectProgram; +extern LLGLSLShader         gNoPostTonemapLegacyGammaCorrectProgram;  extern LLGLSLShader         gExposureProgram;  extern LLGLSLShader         gExposureProgramNoFade;  extern LLGLSLShader         gLuminanceProgram; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 47fb658d15..9942ea3de8 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -261,9 +261,6 @@ static const F32 MIN_DISPLAY_SCALE = 0.75f;  static const char KEY_MOUSELOOK = 'M'; -static LLCachedControl<std::string> sSnapshotBaseName(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseName", "Snapshot")); -static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", "")); -  LLTrace::SampleStatHandle<> LLViewerWindow::sMouseVelocityStat("Mouse Velocity"); @@ -784,8 +781,16 @@ public:              addText(xpos, ypos, "Projection Matrix");              ypos += y_inc; +#if LL_DARWIN +// For sprintf deprecation +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif              // View last column is always <0,0,0,1>              MATRIX_ROW_F32_TO_STR(gGLModelView, 12,camera_lines[3]); addText(xpos, ypos, std::string(camera_lines[3])); ypos += y_inc; +#if LL_DARWIN +#pragma clang diagnostic pop +#endif              MATRIX_ROW_N32_TO_STR(gGLModelView,  8,camera_lines[2]); addText(xpos, ypos, std::string(camera_lines[2])); ypos += y_inc;              MATRIX_ROW_N32_TO_STR(gGLModelView,  4,camera_lines[1]); addText(xpos, ypos, std::string(camera_lines[1])); ypos += y_inc; mBackRectCamera2.mTop = ypos + 2;              MATRIX_ROW_N32_TO_STR(gGLModelView,  0,camera_lines[0]); addText(xpos, ypos, std::string(camera_lines[0])); ypos += y_inc; @@ -2036,6 +2041,7 @@ LLViewerWindow::LLViewerWindow(const Params& p)  std::string LLViewerWindow::getLastSnapshotDir()  { +    static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", ""));      return sSnapshotDir;  } @@ -4746,6 +4752,7 @@ void LLViewerWindow::saveImageNumbered(LLImageFormatted *image, bool force_picke      // Get a base file location if needed.      if (force_picker || !isSnapshotLocSet())      { +        static LLCachedControl<std::string> sSnapshotBaseName(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseName", "Snapshot"));          std::string proposed_name(sSnapshotBaseName);          // getSaveFile will append an appropriate extension to the proposed name, based on the ESaveFilter constant passed in. @@ -4800,7 +4807,7 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save  // Check if there is enough free space to save snapshot  #ifdef LL_WINDOWS -    boost::filesystem::path b_path(utf8str_to_utf16str(lastSnapshotDir)); +    boost::filesystem::path b_path(ll_convert<std::wstring>(lastSnapshotDir));  #else      boost::filesystem::path b_path(lastSnapshotDir);  #endif @@ -4844,6 +4851,9 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save          // Shouldn't there be a return here?      } +    static LLCachedControl<std::string> sSnapshotBaseName(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseName", "Snapshot")); +    static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", "")); +      // Look for an unused file name      auto is_snapshot_name_loc_set = isSnapshotLocSet();      std::string filepath; @@ -4959,8 +4969,8 @@ void LLViewerWindow::playSnapshotAnimAndSound()  bool LLViewerWindow::isSnapshotLocSet() const  { -    std::string snapshot_dir = sSnapshotDir; -    return !snapshot_dir.empty(); +    static LLCachedControl<std::string> sSnapshotDir(LLCachedControl<std::string>(gSavedPerAccountSettings, "SnapshotBaseDir", "")); +    return !sSnapshotDir().empty();  }  void LLViewerWindow::resetSnapshotLoc() const diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index 30f899877a..f13d4caa19 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -82,9 +82,15 @@ const std::string WEBRTC_VOICE_SERVER_TYPE = "webrtc";  namespace { -    const F32 MAX_AUDIO_DIST      = 50.0f; -    const F32 VOLUME_SCALE_WEBRTC = 0.01f; -    const F32 LEVEL_SCALE_WEBRTC  = 0.008f; +    const F32      MAX_AUDIO_DIST           = 50.0f; +    const F32      VOLUME_SCALE_WEBRTC      = 0.01f; +    const F32      TUNING_LEVEL_SCALE       = 0.01f; +    const F32      TUNING_LEVEL_START_POINT = 0.8f; +    const F32      LEVEL_SCALE              = 0.005f; +    const F32      LEVEL_START_POINT        = 0.18f; +    const uint32_t SET_HIDDEN_RESTORE_DELAY_MS = 200;  // 200 ms to unmute again after hiding during teleport +    const uint32_t MUTE_FADE_DELAY_MS       = 500;   // 20ms fade followed by 480ms silence gets rid of the click just after unmuting. +                                                     // This is because the buffers and processing is cleared by the silence.      const F32 SPEAKING_AUDIO_LEVEL = 0.30; @@ -201,7 +207,6 @@ bool LLWebRTCVoiceClient::sShuttingDown = false;  LLWebRTCVoiceClient::LLWebRTCVoiceClient() :      mHidden(false), -    mTuningMode(false),      mTuningMicGain(0.0),      mTuningSpeakerVolume(50),  // Set to 50 so the user can hear themselves when he sets his mic volume      mDevicesListUpdated(false), @@ -348,25 +353,45 @@ void LLWebRTCVoiceClient::updateSettings()          static LLCachedControl<std::string> sOutputDevice(gSavedSettings, "VoiceOutputAudioDevice");          setRenderDevice(sOutputDevice); -        LL_INFOS("Voice") << "Input device: " << std::quoted(sInputDevice()) << ", output device: " << std::quoted(sOutputDevice()) << LL_ENDL; +        LL_INFOS("Voice") << "Input device: " << std::quoted(sInputDevice()) << ", output device: " << std::quoted(sOutputDevice()) +                            << LL_ENDL;          static LLCachedControl<F32> sMicLevel(gSavedSettings, "AudioLevelMic");          setMicGain(sMicLevel);          llwebrtc::LLWebRTCDeviceInterface::AudioConfig config; +        bool audioConfigChanged = false; +          static LLCachedControl<bool> sEchoCancellation(gSavedSettings, "VoiceEchoCancellation", true); -        config.mEchoCancellation = sEchoCancellation; +        if (sEchoCancellation != config.mEchoCancellation) +        { +            config.mEchoCancellation = sEchoCancellation; +            audioConfigChanged       = true; +        }          static LLCachedControl<bool> sAGC(gSavedSettings, "VoiceAutomaticGainControl", true); -        config.mAGC = sAGC; +        if (sAGC != config.mAGC) +        { +            config.mAGC        = sAGC; +            audioConfigChanged = true; +        } -        static LLCachedControl<U32> sNoiseSuppressionLevel(gSavedSettings, +        static LLCachedControl<U32> sNoiseSuppressionLevel( +            gSavedSettings,              "VoiceNoiseSuppressionLevel",              llwebrtc::LLWebRTCDeviceInterface::AudioConfig::ENoiseSuppressionLevel::NOISE_SUPPRESSION_LEVEL_VERY_HIGH); -        config.mNoiseSuppressionLevel = (llwebrtc::LLWebRTCDeviceInterface::AudioConfig::ENoiseSuppressionLevel)(U32)sNoiseSuppressionLevel; - -        mWebRTCDeviceInterface->setAudioConfig(config); +        auto noiseSuppressionLevel = +            (llwebrtc::LLWebRTCDeviceInterface::AudioConfig::ENoiseSuppressionLevel)(U32)sNoiseSuppressionLevel; +        if (noiseSuppressionLevel != config.mNoiseSuppressionLevel) +        { +            config.mNoiseSuppressionLevel = noiseSuppressionLevel; +            audioConfigChanged            = true; +        } +        if (audioConfigChanged) +        { +            mWebRTCDeviceInterface->setAudioConfig(config); +        }      }  } @@ -695,21 +720,38 @@ void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDevi      std::string outputDevice = gSavedSettings.getString("VoiceOutputAudioDevice");      LL_DEBUGS("Voice") << "Setting devices to-input: '" << inputDevice << "' output: '" << outputDevice << "'" << LL_ENDL; -    clearRenderDevices(); -    for (auto &device : render_devices) + +    // only set the render device if the device list has changed. +    if (mRenderDevices.size() != render_devices.size() || !std::equal(mRenderDevices.begin(), +                    mRenderDevices.end(), +                    render_devices.begin(), +                    [](const LLVoiceDevice& a, const llwebrtc::LLWebRTCVoiceDevice& b) { +            return a.display_name == b.mDisplayName && a.full_name == b.mID; }))      { -        addRenderDevice(LLVoiceDevice(device.mDisplayName, device.mID)); +        clearRenderDevices(); +        for (auto& device : render_devices) +        { +            addRenderDevice(LLVoiceDevice(device.mDisplayName, device.mID)); +        } +        setRenderDevice(outputDevice);      } -    setRenderDevice(outputDevice); -    clearCaptureDevices(); -    for (auto &device : capture_devices) +    // only set the capture device if the device list has changed. +    if (mCaptureDevices.size() != capture_devices.size() ||!std::equal(mCaptureDevices.begin(), +                    mCaptureDevices.end(), +                    capture_devices.begin(), +                    [](const LLVoiceDevice& a, const llwebrtc::LLWebRTCVoiceDevice& b) +                    { return a.display_name == b.mDisplayName && a.full_name == b.mID; }))      { -        LL_DEBUGS("Voice") << "Checking capture device:'" << device.mID << "'" << LL_ENDL; +        clearCaptureDevices(); +        for (auto& device : capture_devices) +        { +            LL_DEBUGS("Voice") << "Checking capture device:'" << device.mID << "'" << LL_ENDL; -        addCaptureDevice(LLVoiceDevice(device.mDisplayName, device.mID)); +            addCaptureDevice(LLVoiceDevice(device.mDisplayName, device.mID)); +        } +        setCaptureDevice(inputDevice);      } -    setCaptureDevice(inputDevice);      setDevicesListUpdated(true);  } @@ -762,7 +804,14 @@ bool LLWebRTCVoiceClient::inTuningMode()  void LLWebRTCVoiceClient::tuningSetMicVolume(float volume)  { -    mTuningMicGain      = volume; +    if (volume != mTuningMicGain) +    { +        mTuningMicGain = volume; +        if (mWebRTCDeviceInterface) +        { +            mWebRTCDeviceInterface->setTuningMicGain(volume); +        } +    }  }  void LLWebRTCVoiceClient::tuningSetSpeakerVolume(float volume) @@ -774,21 +823,10 @@ void LLWebRTCVoiceClient::tuningSetSpeakerVolume(float volume)      }  } -float LLWebRTCVoiceClient::getAudioLevel() -{ -    if (mIsInTuningMode) -    { -        return (1.0f - mWebRTCDeviceInterface->getTuningAudioLevel() * LEVEL_SCALE_WEBRTC) * mTuningMicGain / 2.1f; -    } -    else -    { -        return (1.0f - mWebRTCDeviceInterface->getPeerConnectionAudioLevel() * LEVEL_SCALE_WEBRTC) * mMicGain / 2.1f; -    } -} -  float LLWebRTCVoiceClient::tuningGetEnergy(void)  { -    return getAudioLevel(); +    float rms = mWebRTCDeviceInterface->getTuningAudioLevel(); +    return TUNING_LEVEL_START_POINT - TUNING_LEVEL_SCALE * rms;  }  bool LLWebRTCVoiceClient::deviceSettingsAvailable() @@ -824,6 +862,11 @@ void LLWebRTCVoiceClient::setHidden(bool hidden)      if (inSpatialChannel())      { +        if (mWebRTCDeviceInterface) +        { +            mWebRTCDeviceInterface->setMute(mHidden || mMuteMic, +                                            mHidden ? 0 : SET_HIDDEN_RESTORE_DELAY_MS); // delay 200ms so as to not pile up mutes/unmutes. +        }          if (mHidden)          {              // get out of the channel entirely @@ -990,7 +1033,6 @@ void LLWebRTCVoiceClient::updatePosition(void)          {              if (participant->mRegion != region->getRegionID()) {                  participant->mRegion = region->getRegionID(); -                setMuteMic(mMuteMic);              }          }      } @@ -1115,13 +1157,14 @@ void LLWebRTCVoiceClient::sendPositionUpdate(bool force)  // Update our own volume on our participant, so it'll show up  // in the UI.  This is done on all sessions, so switching  // sessions retains consistent volume levels. -void LLWebRTCVoiceClient::updateOwnVolume() { -    F32 audio_level = 0.0; -    if (!mMuteMic && !mTuningMode) +void LLWebRTCVoiceClient::updateOwnVolume() +{ +    F32 audio_level = 0.0f; +    if (!mMuteMic)      { -        audio_level = getAudioLevel(); +        float rms = mWebRTCDeviceInterface->getPeerConnectionAudioLevel(); +        audio_level = LEVEL_START_POINT - LEVEL_SCALE * rms;      } -      sessionState::for_each(boost::bind(predUpdateOwnVolume, _1, audio_level));  } @@ -1518,6 +1561,17 @@ void LLWebRTCVoiceClient::setMuteMic(bool muted)      }      mMuteMic = muted; + +    if (mIsInTuningMode) +    { +        return; +    } + +    if (mWebRTCDeviceInterface) +    { +        mWebRTCDeviceInterface->setMute(muted, muted ? MUTE_FADE_DELAY_MS : 0);  // delay for 40ms on mute to allow buffers to empty +    } +      // when you're hidden, your mic is always muted.      if (!mHidden)      { @@ -1556,7 +1610,10 @@ void LLWebRTCVoiceClient::setMicGain(F32 gain)      if (gain != mMicGain)      {          mMicGain = gain; -        mWebRTCDeviceInterface->setPeerConnectionGain(gain); +        if (mWebRTCDeviceInterface) +        { +            mWebRTCDeviceInterface->setMicGain(gain); +        }      }  } @@ -2900,9 +2957,13 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()              }              // else was already posted by llwebrtc::terminate().              break; +        } +          case VOICE_STATE_WAIT_FOR_CLOSE:              break; +          case VOICE_STATE_CLOSED: +        {              if (!mShutDown)              {                  mVoiceConnectionState = VOICE_STATE_START_SESSION; diff --git a/indra/newview/llvoicewebrtc.h b/indra/newview/llvoicewebrtc.h index f93086cea7..4c40ebcffb 100644 --- a/indra/newview/llvoicewebrtc.h +++ b/indra/newview/llvoicewebrtc.h @@ -444,10 +444,6 @@ public:  private: -    // helper function to retrieve the audio level -    // Used in multiple places. -    float getAudioLevel(); -      // Coroutine support methods      //---      void voiceConnectionCoro(); @@ -458,7 +454,6 @@ private:      LL::WorkQueue::weak_t mMainQueue; -    bool mTuningMode;      F32 mTuningMicGain;      int mTuningSpeakerVolume;      bool mDevicesListUpdated;            // set to true when the device list has been updated diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1a6056fddb..0c369d6926 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -350,6 +350,9 @@ void validate_framebuffer_object();  bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false)  {      U32 orm = GL_RGBA8; +/* +    U32 norm = GL_RGBA16; +*/      U32 norm = GL_RGBA16F;      U32 emissive = GL_RGB16F; @@ -950,6 +953,10 @@ bool LLPipeline::allocateScreenBufferInternal(U32 resX, U32 resY, U32 type_)              mSceneMap.release();          } +/* +        mPostPingMap.allocate(resX, resY, GL_RGBA); +        mPostPongMap.allocate(resX, resY, GL_RGBA); +*/          if((hdr && MPColorPrecision == 2) || mHDRDisplay)          {              mPostMaps[0].allocate(resX, resY, screenFormat); @@ -1243,6 +1250,10 @@ void LLPipeline::releaseGLBuffers()      mWaterExclusionMask.release(); +/* +    mPostPingMap.release(); +    mPostPongMap.release(); +*/      mPostMaps[0].release();      mPostMaps[1].release(); @@ -7373,13 +7384,15 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool  extern LLPointer<LLImageGL> gEXRImage; -void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst) +void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst, bool gamma_correct)  { +/* +    LL_PROFILE_GPU_ZONE("tonemap"); +*/ +      dst->bindTarget("tonemap", 1);      // gamma correct lighting      { -        LL_PROFILE_GPU_ZONE("tonemap"); -          static LLCachedControl<bool> buildNoPost(gSavedSettings, "RenderDisablePostProcessing", false);          LLGLDepthTest depth(GL_FALSE, GL_FALSE); @@ -7391,17 +7404,33 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst)          LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();          bool no_post = gSnapshotNoPost || psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f || (buildNoPost && gFloaterTools && gFloaterTools->isAvailable()); -        LLGLSLShader& shader = no_post ? gNoPostTonemapProgram : gDeferredPostTonemapProgram; +        LLGLSLShader* shader = nullptr; +        if(gamma_correct) +        { +            bool legacy_gamma = psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f; +            if(legacy_gamma) +            { +                shader = no_post ? &gNoPostTonemapLegacyGammaCorrectProgram : &gDeferredPostTonemapLegacyGammaCorrectProgram; +            } +            else +            { +                shader = no_post ? &gNoPostTonemapGammaCorrectProgram : &gDeferredPostTonemapGammaCorrectProgram; +            } +        } +        else +        { +            shader = no_post ? &gNoPostTonemapProgram : &gDeferredPostTonemapProgram; +        } -        shader.bind(); +        shader->bind();          //S32 channel = 0; -        shader.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT); +        shader->bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, false, LLTexUnit::TFO_POINT); -        shader.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); +        shader->bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); -        shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight()); +        shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight());          static LLCachedControl<F32> exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7411,17 +7440,18 @@ void LLPipeline::tonemap(LLRenderTarget* src, LLRenderTarget* dst)          static LLStaticHashedString tonemap_mix("tonemap_mix");          static LLStaticHashedString tonemap_type("tonemap_type"); -        shader.uniform1f(s_exposure, e); +        shader->uniform1f(s_exposure, e);          static LLCachedControl<U32> tonemap_type_setting(gSavedSettings, "RenderTonemapType", 0U); -        shader.uniform1i(tonemap_type, tonemap_type_setting); -        shader.uniform1f(tonemap_mix, psky->getTonemapMix(should_auto_adjust())); +        shader->uniform1i(tonemap_type, tonemap_type_setting); +        shader->uniform1f(tonemap_mix, psky->getTonemapMix(should_auto_adjust()));          renderTriangle(); -        //shader.unbindTexture(LLShaderMgr::DEFERRED_DIFFUSE); -        //shader.unbindTexture(LLShaderMgr::EXPOSURE_MAP); -        shader.unbind(); +/* +        gGL.getTexUnit(channel)->unbind(src->getUsage()); +*/ +        shader->unbind();      }      dst->flush();      LOG_GLERROR("LLPipeline::tonemap()"); @@ -7431,8 +7461,17 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst)  {      LLGLDepthTest depth(GL_FALSE, GL_FALSE); +/* +    LL_PROFILE_GPU_ZONE("gamma correct"); + +    dst->bindTarget(); +*/      // gamma correct lighting      { +/* +        LLGLDepthTest depth(GL_FALSE, GL_FALSE); +*/ +          LL_PROFILE_GPU_ZONE("gamma correct");          dst->bindTarget("gammaCorrect", 1); @@ -7500,11 +7539,15 @@ void LLPipeline::copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget*  void LLPipeline::generateGlow(LLRenderTarget* src)  { +    LL_PROFILE_GPU_ZONE("glow generate");      if (sRenderGlow)      {          LL_PROFILE_GPU_ZONE("glow");          LL_RECORD_BLOCK_TIME(FTM_RENDER_GLOW); +/* +        mGlow[2].bindTarget(); +*/          mGlow[2].bindTarget("mGlow[2]", 1);          mGlow[2].clear(); @@ -7612,12 +7655,21 @@ void LLPipeline::generateGlow(LLRenderTarget* src)  bool LLPipeline::applyCAS(LLRenderTarget* src, LLRenderTarget* dst)  {      static LLCachedControl<F32> cas_sharpness(gSavedSettings, "RenderCASSharpness", 0.4f); -    if (cas_sharpness == 0.0f || !gCASProgram.isComplete()) +    LL_PROFILE_GPU_ZONE("cas"); +    if (cas_sharpness == 0.0f || !gCASProgram.isComplete() || !gCASLegacyGammaProgram.isComplete())      {          return false;      }      LLGLSLShader* sharpen_shader = &gCASProgram; +    static LLCachedControl<bool> should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", false); + +    LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); +    bool legacy_gamma = psky->getReflectionProbeAmbiance(should_auto_adjust) == 0.f; +    if(legacy_gamma) +    { +        sharpen_shader = &gCASLegacyGammaProgram; +    }      // Bind setup:      dst->bindTarget("applyCAS", 1); @@ -7690,6 +7742,7 @@ bool LLPipeline::generateFXAABuffer(LLRenderTarget* src)  bool LLPipeline::applyFXAA(LLRenderTarget* src, LLRenderTarget* dst)  { +    LL_PROFILE_GPU_ZONE("FXAA");      {          llassert(!gCubeSnapshot);          bool multisample = RenderFSAAType == 1 && gFXAAProgram[0].isComplete() && mFXAAMap.isComplete(); @@ -7789,7 +7842,7 @@ bool LLPipeline::generateSMAABuffers(LLRenderTarget* src)      // Present everything.      if (multisample)      { -        LL_PROFILE_GPU_ZONE("aa"); +        LL_PROFILE_GPU_ZONE("SMAA Edge");          static LLCachedControl<U32> aa_quality(gSavedSettings, "RenderFSAASamples", 0U);          U32 fsaa_quality = std::clamp(aa_quality(), 0U, 3U); @@ -7830,6 +7883,7 @@ bool LLPipeline::generateSMAABuffers(LLRenderTarget* src)                      gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);                      gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);                  } +                gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);              }              renderTriangle(); @@ -7889,6 +7943,7 @@ bool LLPipeline::generateSMAABuffers(LLRenderTarget* src)  bool LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst)  { +    LL_PROFILE_GPU_ZONE("SMAA");      llassert(!gCubeSnapshot);      bool multisample = false; @@ -7901,7 +7956,6 @@ bool LLPipeline::applySMAA(LLRenderTarget* src, LLRenderTarget* dst)      if(!multisample) return false;      { -        LL_PROFILE_GPU_ZONE("aa");          static LLCachedControl<U32> aa_quality(gSavedSettings, "RenderFSAASamples", 0U);          U32 fsaa_quality = std::clamp(aa_quality(), 0U, 3U); @@ -7970,8 +8024,12 @@ void LLPipeline::copyRenderTarget(LLRenderTarget* src, LLRenderTarget* dst)  void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst)  { -    // Go ahead and do our glow combine here in our destination.  We blit this later into the front buffer. +    LL_PROFILE_GPU_ZONE("glow combine"); +/* +    // Go ahead and do our glow combine here in our destination.  We blit this later into the front buffer. +    dst->bindTarget(); +*/      dst->bindTarget("combineGlow", 1);      { @@ -7990,6 +8048,7 @@ void LLPipeline::combineGlow(LLRenderTarget* src, LLRenderTarget* dst)  bool LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)  { +    LL_PROFILE_GPU_ZONE("dof");      {          bool dof_enabled =              (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && @@ -8002,7 +8061,6 @@ bool LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst)          if (dof_enabled)          { -            LL_PROFILE_GPU_ZONE("dof");              LLGLDisable blend(GL_BLEND);              // depth of field focal plane calculations @@ -8334,10 +8392,29 @@ void LLPipeline::renderFinalize()          generateExposure(&mLuminanceMap, &mExposureMap); -            tonemap(&mRT->screen, &mRT->deferredLight); +/* +        static LLCachedControl<F32> cas_sharpness(gSavedSettings, "RenderCASSharpness", 0.4f); +        bool apply_cas = cas_sharpness != 0.0f && gCASProgram.isComplete() && gCASLegacyGammaProgram.isComplete(); + +        tonemap(&mRT->screen, apply_cas ? &mRT->deferredLight : &mPostPingMap, !apply_cas); + +        if (apply_cas) +        { +            // Gamma Corrects +            applyCAS(&mRT->deferredLight, &mPostPingMap); +        } +*/ + +            tonemap(&mRT->screen, &mRT->deferredLight, false);              postHDRTarget = &mRT->deferredLight;          }      } +/* +    else +    { +        gammaCorrect(&mRT->screen, &mPostPingMap); +    } +*/      gammaCorrect(postHDRTarget, &mPostMaps[1 - activeRT]);      activeRT = 1 - activeRT; @@ -8352,6 +8429,44 @@ void LLPipeline::renderFinalize()          }      } +/* +    LLVertexBuffer::unbind(); + +    generateGlow(&mPostPingMap); + +    LLRenderTarget* sourceBuffer = &mPostPingMap; +    LLRenderTarget* targetBuffer = &mPostPongMap; + +    combineGlow(sourceBuffer, targetBuffer); +    std::swap(sourceBuffer, targetBuffer); + +    gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; +    gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom; +    gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth(); +    gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); +    glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); + +    if((RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && +        RenderDepthOfField && +        !gCubeSnapshot) +    { +        renderDoF(sourceBuffer, targetBuffer); +        std::swap(sourceBuffer, targetBuffer); +    } + +     if (RenderFSAAType == 1) +    { +        applyFXAA(sourceBuffer, targetBuffer); +        std::swap(sourceBuffer, targetBuffer); +    } +    else if (RenderFSAAType == 2) +    { +        generateSMAABuffers(sourceBuffer); +        applySMAA(sourceBuffer, targetBuffer); +        std::swap(sourceBuffer, targetBuffer); +    } +*/ +      combineGlow(&mPostMaps[activeRT], &mPostMaps[1 - activeRT]);      activeRT = 1 - activeRT; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 8e18fb419f..41e428fce9 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -158,7 +158,7 @@ public:      void copyScreenSpaceReflections(LLRenderTarget* src, LLRenderTarget* dst);      void generateLuminance(LLRenderTarget* src, LLRenderTarget* dst);      void generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool use_history = true); -    void tonemap(LLRenderTarget* src, LLRenderTarget* dst); +    void tonemap(LLRenderTarget* src, LLRenderTarget* dst, bool gamma_correct);      void gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst);      void generateGlow(LLRenderTarget* src);      bool applyCAS(LLRenderTarget* src, LLRenderTarget* dst); @@ -740,7 +740,10 @@ public:      LLRenderTarget          mBloomBlur[2];      // tonemapped and gamma corrected render ready for post -    //LLRenderTarget          mPostMap; +/* +    LLRenderTarget          mPostPingMap; +    LLRenderTarget          mPostPongMap; +*/      LLRenderTarget          mPostMaps[2];      // FXAA helper target diff --git a/indra/newview/skins/default/xui/en/floater_web_content.xml b/indra/newview/skins/default/xui/en/floater_web_content.xml index 2e1dfa00c7..53796f0959 100644 --- a/indra/newview/skins/default/xui/en/floater_web_content.xml +++ b/indra/newview/skins/default/xui/en/floater_web_content.xml @@ -178,7 +178,7 @@          width="22">          <button.commit_callback            function="WebContent.TestURL" -          parameter="https://sl-viewer-media-system.s3.amazonaws.com/index.html"/> +          parameter="https://sl-viewer-media-system.s3.amazonaws.com/bookmarks/index.html"/>        </button>      </layout_panel>      <layout_panel diff --git a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml index d8ef139d37..f01dee36ce 100644 --- a/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_gallery_inventory.xml @@ -687,61 +687,6 @@       parameter="remove_from_favorites" />    </menu_item_call>    <menu -   label="Use as default for" -   layout="topleft" -   name="upload_def"> -    <menu_item_call -     label="Image uploads" -     layout="topleft" -     name="Image uploads"> -      <menu_item_call.on_click -       function="Inventory.FileUploadLocation" -        parameter="texture" /> -      <menu_item_call.on_visible -       function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -    <menu_item_call -     label="Sound uploads" -     layout="topleft" -     name="Sound uploads"> -      <menu_item_call.on_click -       function="Inventory.FileUploadLocation" -       parameter="sound" /> -      <menu_item_call.on_visible -       function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -    <menu_item_call -     label="Animation uploads" -     layout="topleft" -     name="Animation uploads"> -      <menu_item_call.on_click -       function="Inventory.FileUploadLocation" -       parameter="animation" /> -      <menu_item_call.on_visible -       function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -    <menu_item_call -     label="Model uploads" -     layout="topleft" -     name="Model uploads"> -      <menu_item_call.on_click -       function="Inventory.FileUploadLocation" -       parameter="model" /> -      <menu_item_call.on_visible -       function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -  </menu> -  <menu_item_call -   label="Use as favorite folder" -   layout="topleft" -   name="Set favorite folder"> -    <menu_item_call.on_click -     function="Inventory.SetFavoriteFolder" -     parameter="favorite" /> -    <menu_item_call.on_visible -     function="Inventory.CanSetFavoriteFolder" /> -  </menu_item_call> -  <menu     label="Upload to folder"     layout="topleft"     name="upload_options"> @@ -822,54 +767,79 @@     label="Use as default for"     layout="topleft"     name="upload_def"> -    <menu_item_call +    <menu_item_check       label="Image uploads"       layout="topleft"       name="Image uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"          parameter="def_texture" /> -      <menu_item_call.on_visible +      <on_visible         function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_texture" /> +    </menu_item_check> +    <menu_item_check       label="Sound uploads"       layout="topleft"       name="Sound uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_sound" /> -      <menu_item_call.on_visible +      <on_visible         function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_sound" /> +    </menu_item_check> +    <menu_item_check       label="Animation uploads"       layout="topleft"       name="Animation uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_animation" /> -      <menu_item_call.on_visible +      <on_visible         function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_animation" /> +    </menu_item_check> +    <menu_item_check       label="Model uploads"       layout="topleft"       name="Model uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_model" /> -      <menu_item_call.on_visible +      <on_visible         function="Inventory.CanSetUploadLocation" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_model" /> +    </menu_item_check> +    <menu_item_check       label="PBR material uploads"       layout="topleft"       name="PBR uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_pbr_material" /> -    </menu_item_call> +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_pbr_material" /> +    </menu_item_check> +    <menu_item_check +     label="Use as favorite folder" +     layout="topleft" +     name="Set favorite folder"> +      <on_click +       function="Inventory.SetFavoriteFolder" +       parameter="favorite" /> +      <on_visible +       function="Inventory.CanSetFavoriteFolder" /> +    </menu_item_check>    </menu>  	<menu_item_separator  	 layout="topleft" diff --git a/indra/newview/skins/default/xui/en/menu_inventory.xml b/indra/newview/skins/default/xui/en/menu_inventory.xml index 28569c1557..087424b469 100644 --- a/indra/newview/skins/default/xui/en/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en/menu_inventory.xml @@ -1064,46 +1064,61 @@     label="Use as default for"     layout="topleft"     name="upload_def"> -    <menu_item_call +    <menu_item_check       label="Image uploads"       layout="topleft"       name="Image uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_texture" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_texture" /> +    </menu_item_check> +    <menu_item_check       label="Sound uploads"       layout="topleft"       name="Sound uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_sound" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_sound" /> +    </menu_item_check> +    <menu_item_check       label="Animation uploads"       layout="topleft"       name="Animation uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_animation" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_animation" /> +    </menu_item_check> +    <menu_item_check       label="Model uploads"       layout="topleft"       name="Model uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_model" /> -    </menu_item_call> -    <menu_item_call +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_model" /> +    </menu_item_check> +    <menu_item_check       label="PBR material uploads"       layout="topleft"       name="PBR uploads"> -      <menu_item_call.on_click +      <on_click         function="Inventory.FileUploadLocation"         parameter="def_pbr_material" /> -    </menu_item_call> +      <on_check +       function="Inventory.FileUploadLocation.Check" +       parameter="def_pbr_material" /> +    </menu_item_check>    </menu>    <menu_item_call     label="Use as favorite folder" diff --git a/indra/newview/skins/default/xui/en/menu_media_ctrl.xml b/indra/newview/skins/default/xui/en/menu_media_ctrl.xml index f9864637a0..e687ae93e8 100644 --- a/indra/newview/skins/default/xui/en/menu_media_ctrl.xml +++ b/indra/newview/skins/default/xui/en/menu_media_ctrl.xml @@ -40,4 +40,12 @@      <menu_item_call.on_click       function="Open.WebInspector" />    </menu_item_call> +  <menu_item_call +   label="Show Source" +   layout="topleft" +   name="show_page_source" +   visible="false"> +    <menu_item_call.on_click +     function="Open.ShowSource" /> +  </menu_item_call>  </context_menu> diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 741db1139e..d16f427530 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -626,12 +626,16 @@ class Windows_x86_64_Manifest(ViewerManifest):              with self.prefix(src=os.path.join(pkgdir, 'bin', config)):                  self.path("chrome_elf.dll")                  self.path("d3dcompiler_47.dll") +                self.path("dxcompiler.dll") +                self.path("dxil.dll")                  self.path("libcef.dll")                  self.path("libEGL.dll")                  self.path("libGLESv2.dll") -                self.path("dullahan_host.exe") -                self.path("snapshot_blob.bin")                  self.path("v8_context_snapshot.bin") +                self.path("vk_swiftshader.dll") +                self.path("vk_swiftshader_icd.json") +                self.path("vulkan-1.dll") +                self.path("dullahan_host.exe")              # MSVC DLLs needed for CEF and have to be in same directory as plugin              with self.prefix(src=os.path.join(self.args['build'], os.pardir, @@ -863,14 +867,29 @@ class Darwin_x86_64_Manifest(ViewerManifest):              # CEF framework goes inside Contents/Frameworks.              # Remember where we parked this car. -            with self.prefix(src="", dst="Frameworks"): -                CEF_framework = "Chromium Embedded Framework.framework" -                self.path2basename(relpkgdir, CEF_framework) -                CEF_framework = self.dst_path_of(CEF_framework) +            with self.prefix(src=relpkgdir, dst="Frameworks"): +                self.path("libndofdev.dylib") +                  if self.args.get('bugsplat'):                      self.path2basename(relpkgdir, "BugsplatMac.framework") +                # OpenAL dylibs +                if self.args['openal'] == 'ON': +                    for libfile in ( +                                "libopenal.dylib", +                                "libalut.dylib", +                                ): +                        self.path(libfile) + +                # WebRTC libraries +                with self.prefix(src=os.path.join(self.args['build'], os.pardir, +                                          'sharedlibs', self.args['buildtype'], 'Resources')): +                    for libfile in ( +                            'libllwebrtc.dylib', +                    ): +                        self.path(libfile) +              with self.prefix(dst="MacOS"):                  executable = self.dst_path_of(self.channel())                  if self.args.get('bugsplat'): @@ -930,16 +949,12 @@ class Darwin_x86_64_Manifest(ViewerManifest):                          self.path("*.png")                          self.path("*.gif") -                with self.prefix(src=relpkgdir, dst=""): -                    self.path("libndofdev.dylib") -                  with self.prefix(src_dst="cursors_mac"):                      self.path("*.tif")                  self.path("licenses-mac.txt", dst="licenses.txt")                  self.path("featuretable_mac.txt")                  self.path("cube.dae") -                self.path("SecondLife.nib")                  with self.prefix(src=pkgdir,dst=""):                      self.path("ca-bundle.crt") @@ -992,20 +1007,6 @@ class Darwin_x86_64_Manifest(ViewerManifest):                          print("Skipping %s" % dst)                      return added -                # WebRTC libraries -                with self.prefix(src=os.path.join(self.args['build'], os.pardir, -                                          'sharedlibs', self.args['buildtype'], 'Resources')): -                    for libfile in ( -                            'libllwebrtc.dylib', -                    ): -                        self.path(libfile) - -                        oldpath = os.path.join("@rpath", libfile) -                        self.run_command( -                            ['install_name_tool', '-change', oldpath, -                             '@executable_path/../Resources/%s' % libfile, -                             executable]) -                  # dylibs is a list of all the .dylib files we expect to need                  # in our bundled sub-apps. For each of these we'll create a                  # symlink from sub-app/Contents/Resources to the real .dylib. @@ -1030,20 +1031,6 @@ class Darwin_x86_64_Manifest(ViewerManifest):                                  ):                          self.path2basename(relpkgdir, libfile) -                # OpenAL dylibs -                if self.args['openal'] == 'ON': -                    for libfile in ( -                                "libopenal.dylib", -                                "libalut.dylib", -                                ): -                        dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile) - -                        oldpath = os.path.join("@rpath", libfile) -                        self.run_command( -                            ['install_name_tool', '-change', oldpath, -                             '@executable_path/../Resources/%s' % libfile, -                             executable]) -                  # our apps                  executable_path = {}                  embedded_apps = [ (os.path.join("llplugin", "slplugin"), "SLPlugin.app") ] @@ -1054,123 +1041,34 @@ class Darwin_x86_64_Manifest(ViewerManifest):                      executable_path[app] = \                          self.dst_path_of(os.path.join(app, "Contents", "MacOS")) -                    # our apps dependencies on shared libs -                    # for each app, for each dylib we collected in dylibs, -                    # create a symlink to the real copy of the dylib. -                    with self.prefix(dst=os.path.join(app, "Contents", "Resources")): -                        for libfile in dylibs: -                            self.relsymlinkf(os.path.join(libfile_parent, libfile)) -                  # Dullahan helper apps go inside SLPlugin.app                  with self.prefix(dst=os.path.join(                      "SLPlugin.app", "Contents", "Frameworks")): - -                    frameworkname = 'Chromium Embedded Framework' - -                    # This code constructs a relative symlink from the -                    # target framework folder back to the real CEF framework. -                    # It needs to be relative so that the symlink still works when -                    # (as is normal) the user moves the app bundle out of the DMG -                    # and into the /Applications folder. Note we pass catch=False, -                    # letting the uncaught exception terminate the process, since -                    # without this symlink, Second Life web media can't possibly work. - -                    # It might seem simpler just to symlink Frameworks back to -                    # the parent of Chromimum Embedded Framework.framework. But -                    # that would create a symlink cycle, which breaks our -                    # packaging step. So make a symlink from Chromium Embedded -                    # Framework.framework to the directory of the same name, which -                    # is NOT an ancestor of the symlink. - -                    # from SLPlugin.app/Contents/Frameworks/Chromium Embedded -                    # Framework.framework back to -                    # $viewer_app/Contents/Frameworks/Chromium Embedded Framework.framework -                    SLPlugin_framework = self.relsymlinkf(CEF_framework, catch=False) - -                    # for all the multiple CEF/Dullahan (as of CEF 76) helper app bundles we need: -                    for helper in ( -                        "DullahanHelper", -                        "DullahanHelper (GPU)", -                        "DullahanHelper (Renderer)", -                        "DullahanHelper (Plugin)", -                    ): -                        # app is the directory name of the app bundle, with app/Contents/MacOS/helper as the executable -                        app = helper + ".app" - -                        # copy DullahanHelper.app -                        self.path2basename(relpkgdir, app) - -                        # and fix that up with a Frameworks/CEF symlink too -                        with self.prefix(dst=os.path.join( -                                app, 'Contents', 'Frameworks')): -                            # from Dullahan Helper *.app/Contents/Frameworks/Chromium Embedded -                            # Framework.framework back to -                            # SLPlugin.app/Contents/Frameworks/Chromium Embedded Framework.framework -                            # Since SLPlugin_framework is itself a -                            # symlink, don't let relsymlinkf() resolve -- -                            # explicitly call relpath(symlink=True) and -                            # create that symlink here. -                            helper_framework = \ -                            self.symlinkf(self.relpath(SLPlugin_framework, symlink=True), catch=False) - -                        # change_command includes install_name_tool, the -                        # -change subcommand and the old framework rpath -                        # stamped into the executable. To use it with -                        # run_command(), we must still append the new -                        # framework path and the pathname of the -                        # executable to change. -                        change_command = [ -                            'install_name_tool', '-change', -                            '@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework'] - -                        with self.prefix(dst=os.path.join( -                                app, 'Contents', 'MacOS')): -                            # Now self.get_dst_prefix() is, at runtime, -                            # @executable_path. Locate the helper app -                            # framework (which is a symlink) from here. -                            newpath = os.path.join( -                                '@executable_path', -                                    self.relpath(helper_framework, symlink=True), -                                frameworkname) -                                # and restamp the Dullahan Helper executable itself -                            self.run_command( -                                change_command + -                                    [newpath, self.dst_path_of(helper)]) - -                # SLPlugin plugins -                with self.prefix(dst="llplugin"): -                    dylibexecutable = 'media_plugin_cef.dylib' +                    # copy CEF plugin                      self.path2basename("../media_plugins/cef/" + self.args['configuration'], -                                       dylibexecutable) - -                    # Do this install_name_tool *after* media plugin is copied over. -                    # Locate the framework lib executable -- relative to -                    # SLPlugin.app/Contents/MacOS, which will be our -                    # @executable_path at runtime! -                    newpath = os.path.join( -                        '@executable_path', -                        self.relpath(SLPlugin_framework, executable_path["SLPlugin.app"], -                                     symlink=True), -                        frameworkname) -                    # restamp media_plugin_cef.dylib -                    self.run_command( -                        change_command + -                        [newpath, self.dst_path_of(dylibexecutable)]) - -                    # copy LibVLC plugin itself -                    dylibexecutable = 'media_plugin_libvlc.dylib' -                    self.path2basename("../media_plugins/libvlc/" + self.args['configuration'], dylibexecutable) -                    # add @rpath for the correct LibVLC subfolder -                    self.run_command(['install_name_tool', '-add_rpath', '@loader_path/lib', self.dst_path_of(dylibexecutable)]) - -                    # copy LibVLC dynamic libraries -                    with self.prefix(src=relpkgdir, dst="lib"): +                                       "media_plugin_cef.dylib") + +                    # copy LibVLC plugin +                    self.path2basename("../media_plugins/libvlc/" + self.args['configuration'], +                                       "media_plugin_libvlc.dylib") + +                    # CEF framework and vlc libraries goes inside Contents/Frameworks. +                    with self.prefix(src=os.path.join(pkgdir, 'lib', 'release')): +                        self.path("Chromium Embedded Framework.framework") +                        self.path("DullahanHelper.app") +                        self.path("DullahanHelper (Alerts).app") +                        self.path("DullahanHelper (GPU).app") +                        self.path("DullahanHelper (Renderer).app") +                        self.path("DullahanHelper (Plugin).app") + +                        # Copy libvlc                          self.path( "libvlc*.dylib*" )                          # copy LibVLC plugins folder -                        with self.prefix(src='plugins', dst=""): +                        with self.prefix(src='plugins', dst="plugins"):                              self.path( "*.dylib" )                              self.path( "plugins.dat" ) +      def package_finish(self):          imagename = self.installer_base_name()          self.set_github_output('imagename', imagename) diff --git a/indra/test/CMakeLists.txt b/indra/test/CMakeLists.txt index 745c0eedf8..f80286a630 100644 --- a/indra/test/CMakeLists.txt +++ b/indra/test/CMakeLists.txt @@ -114,7 +114,7 @@ if (LL_TESTS)        # but the CMake $<TARGET_FILE_DIR> generator expression isn't evaluated by        # CREATE_LINK, so fudge it.        add_custom_command( TARGET lltest POST_BUILD -              COMMAND cmake -E create_symlink ${SHARED_LIB_STAGING_DIR} ${CMAKE_BINARY_DIR}/test/Resources +              COMMAND ${CMAKE_COMMAND} -E create_symlink ${SHARED_LIB_STAGING_DIR} ${CMAKE_BINARY_DIR}/test/Resources                )      endif()  endif (LL_TESTS) | 
