mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-16 06:12:23 +08:00
chore: re-organized web wallpaper support to use custom scheme and better handle multiprocessing
This commit is contained in:
parent
b931b317fb
commit
47b52fd6df
@ -113,6 +113,7 @@ add_subdirectory(src/External/SPIRV-Cross-WallpaperEngine spirv-cross)
|
||||
include_directories(
|
||||
src/External/glslang-WallpaperEngine
|
||||
src/External/SPIRV-Cross-WallpaperEngine
|
||||
src/External/MimeTypes
|
||||
${MPV_INCLUDE_DIR}
|
||||
${GLEW_INCLUDE_DIR}
|
||||
${LZ4_INCLUDE_DIR}
|
||||
@ -214,6 +215,9 @@ add_executable(
|
||||
src/External/Android/fft.cpp
|
||||
src/External/Android/fft.h
|
||||
|
||||
src/External/MimeTypes/MimeTypes.cpp
|
||||
src/External/MimeTypes/MimeTypes.h
|
||||
|
||||
src/Steam/FileSystem/FileSystem.h
|
||||
src/Steam/FileSystem/FileSystem.cpp
|
||||
|
||||
@ -345,6 +349,18 @@ add_executable(
|
||||
src/WallpaperEngine/Render/Objects/Effects/CMaterial.h
|
||||
src/WallpaperEngine/Render/Objects/Effects/CMaterial.cpp
|
||||
|
||||
src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp
|
||||
src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h
|
||||
src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.cpp
|
||||
src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.h
|
||||
src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.cpp
|
||||
src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.h
|
||||
src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.cpp
|
||||
src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h
|
||||
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.cpp
|
||||
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h
|
||||
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.cpp
|
||||
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.h
|
||||
src/WallpaperEngine/WebBrowser/CWebBrowserContext.cpp
|
||||
src/WallpaperEngine/WebBrowser/CWebBrowserContext.h
|
||||
|
||||
|
@ -1,387 +0,0 @@
|
||||
# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
# Must be loaded via FindCEF.cmake.
|
||||
if(NOT DEFINED _CEF_ROOT_EXPLICIT)
|
||||
message(FATAL_ERROR "Use find_package(CEF) to load this file.")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Shared macros.
|
||||
#
|
||||
|
||||
# Print the current CEF configuration.
|
||||
macro(PRINT_CEF_CONFIG)
|
||||
message(STATUS "*** CEF CONFIGURATION SETTINGS ***")
|
||||
message(STATUS "Generator: ${CMAKE_GENERATOR}")
|
||||
message(STATUS "Platform: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "Project architecture: ${PROJECT_ARCH}")
|
||||
|
||||
if(GEN_NINJA OR GEN_MAKEFILES)
|
||||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Binary distribution root: ${_CEF_ROOT}")
|
||||
|
||||
if(OS_MAC)
|
||||
message(STATUS "Base SDK: ${CMAKE_OSX_SYSROOT}")
|
||||
message(STATUS "Target SDK: ${CEF_TARGET_SDK}")
|
||||
endif()
|
||||
|
||||
if(OS_WINDOWS)
|
||||
message(STATUS "Visual Studio ATL support: ${USE_ATL}")
|
||||
endif()
|
||||
|
||||
message(STATUS "CEF sandbox: ${USE_SANDBOX}")
|
||||
|
||||
set(_libraries ${CEF_STANDARD_LIBS})
|
||||
if(OS_WINDOWS AND USE_SANDBOX)
|
||||
list(APPEND _libraries ${CEF_SANDBOX_STANDARD_LIBS})
|
||||
endif()
|
||||
message(STATUS "Standard libraries: ${_libraries}")
|
||||
|
||||
message(STATUS "Compile defines: ${CEF_COMPILER_DEFINES}")
|
||||
message(STATUS "Compile defines (Debug): ${CEF_COMPILER_DEFINES_DEBUG}")
|
||||
message(STATUS "Compile defines (Release): ${CEF_COMPILER_DEFINES_RELEASE}")
|
||||
message(STATUS "C compile flags: ${CEF_COMPILER_FLAGS} ${CEF_C_COMPILER_FLAGS}")
|
||||
message(STATUS "C compile flags (Debug): ${CEF_COMPILER_FLAGS_DEBUG} ${CEF_C_COMPILER_FLAGS_DEBUG}")
|
||||
message(STATUS "C compile flags (Release): ${CEF_COMPILER_FLAGS_RELEASE} ${CEF_C_COMPILER_FLAGS_RELEASE}")
|
||||
message(STATUS "C++ compile flags: ${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS}")
|
||||
message(STATUS "C++ compile flags (Debug): ${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}")
|
||||
message(STATUS "C++ compile flags (Release): ${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}")
|
||||
message(STATUS "Exe link flags: ${CEF_LINKER_FLAGS} ${CEF_EXE_LINKER_FLAGS}")
|
||||
message(STATUS "Exe link flags (Debug): ${CEF_LINKER_FLAGS_DEBUG} ${CEF_EXE_LINKER_FLAGS_DEBUG}")
|
||||
message(STATUS "Exe link flags (Release): ${CEF_LINKER_FLAGS_RELEASE} ${CEF_EXE_LINKER_FLAGS_RELEASE}")
|
||||
message(STATUS "Shared link flags: ${CEF_LINKER_FLAGS} ${CEF_SHARED_LINKER_FLAGS}")
|
||||
message(STATUS "Shared link flags (Debug): ${CEF_LINKER_FLAGS_DEBUG} ${CEF_SHARED_LINKER_FLAGS_DEBUG}")
|
||||
message(STATUS "Shared link flags (Release): ${CEF_LINKER_FLAGS_RELEASE} ${CEF_SHARED_LINKER_FLAGS_RELEASE}")
|
||||
|
||||
if(OS_LINUX OR OS_WINDOWS)
|
||||
message(STATUS "CEF Binary files: ${CEF_BINARY_FILES}")
|
||||
message(STATUS "CEF Resource files: ${CEF_RESOURCE_FILES}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Append platform specific sources to a list of sources.
|
||||
macro(APPEND_PLATFORM_SOURCES name_of_list)
|
||||
if(OS_LINUX AND ${name_of_list}_LINUX)
|
||||
list(APPEND ${name_of_list} ${${name_of_list}_LINUX})
|
||||
endif()
|
||||
if(OS_POSIX AND ${name_of_list}_POSIX)
|
||||
list(APPEND ${name_of_list} ${${name_of_list}_POSIX})
|
||||
endif()
|
||||
if(OS_WINDOWS AND ${name_of_list}_WINDOWS)
|
||||
list(APPEND ${name_of_list} ${${name_of_list}_WINDOWS})
|
||||
endif()
|
||||
if(OS_MAC AND ${name_of_list}_MAC)
|
||||
list(APPEND ${name_of_list} ${${name_of_list}_MAC})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Determine the target output directory based on platform and generator.
|
||||
macro(SET_CEF_TARGET_OUT_DIR)
|
||||
if(GEN_NINJA OR GEN_MAKEFILES)
|
||||
# By default Ninja and Make builds don't create a subdirectory named after
|
||||
# the configuration.
|
||||
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
|
||||
|
||||
# Output binaries (executables, libraries) to the correct directory.
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})
|
||||
else()
|
||||
set(CEF_TARGET_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Copy a list of files from one directory to another. Relative file paths are maintained.
|
||||
macro(COPY_FILES target file_list source_dir target_dir)
|
||||
foreach(FILENAME ${file_list})
|
||||
set(source_file ${source_dir}/${FILENAME})
|
||||
|
||||
# Remove the target file path component.
|
||||
get_filename_component(target_name ${FILENAME} NAME)
|
||||
set(target_file ${target_dir}/${target_name})
|
||||
|
||||
COPY_SINGLE_FILE(${target} ${source_file} ${target_file})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# Copy a list of files from one directory to another. Relative file paths are maintained.
|
||||
macro(COPY_RESOURCES target file_list prefix_list source_dir target_dir)
|
||||
foreach(FILENAME ${file_list})
|
||||
set(source_file ${source_dir}/${FILENAME})
|
||||
|
||||
# Remove one or more prefixes from the source paths.
|
||||
set(TARGET_FILENAME "${FILENAME}")
|
||||
foreach(PREFIX ${prefix_list})
|
||||
string(REGEX REPLACE "^.*${PREFIX}" "" TARGET_FILENAME ${TARGET_FILENAME})
|
||||
endforeach()
|
||||
set(target_file ${target_dir}/${TARGET_FILENAME})
|
||||
|
||||
COPY_SINGLE_FILE(${target} ${source_file} ${target_file})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
macro(COPY_SINGLE_FILE target source_file target_file)
|
||||
string(FIND ${source_file} "$<CONFIGURATION>" _pos)
|
||||
if(NOT ${_pos} EQUAL -1)
|
||||
# Must test with an actual configuration directory.
|
||||
string(REPLACE "$<CONFIGURATION>" "Release" existing_source_file ${source_file})
|
||||
if(NOT EXISTS ${existing_source_file})
|
||||
string(REPLACE "$<CONFIGURATION>" "Debug" existing_source_file ${source_file})
|
||||
endif()
|
||||
else()
|
||||
set(existing_source_file ${source_file})
|
||||
endif()
|
||||
|
||||
if(IS_DIRECTORY ${existing_source_file})
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${source_file}" "${target_file}"
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${source_file}" "${target_file}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
#
|
||||
# Linux macros.
|
||||
#
|
||||
|
||||
if(OS_LINUX)
|
||||
|
||||
# Use pkg-config to find Linux libraries and update compiler/linker variables.
|
||||
macro(FIND_LINUX_LIBRARIES libraries)
|
||||
# Read pkg-config info into variables.
|
||||
execute_process(COMMAND pkg-config --cflags ${libraries} OUTPUT_VARIABLE FLL_CFLAGS)
|
||||
execute_process(COMMAND pkg-config --libs-only-L --libs-only-other ${libraries} OUTPUT_VARIABLE FLL_LDFLAGS)
|
||||
execute_process(COMMAND pkg-config --libs-only-l ${libraries} OUTPUT_VARIABLE FLL_LIBS)
|
||||
|
||||
# Strip leading and trailing whitepspace.
|
||||
STRING(STRIP "${FLL_CFLAGS}" FLL_CFLAGS)
|
||||
STRING(STRIP "${FLL_LDFLAGS}" FLL_LDFLAGS)
|
||||
STRING(STRIP "${FLL_LIBS}" FLL_LIBS)
|
||||
|
||||
# Convert to a list.
|
||||
separate_arguments(FLL_CFLAGS)
|
||||
separate_arguments(FLL_LDFLAGS)
|
||||
separate_arguments(FLL_LIBS)
|
||||
|
||||
# Update build variables.
|
||||
list(APPEND CEF_C_COMPILER_FLAGS ${FLL_CFLAGS})
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS ${FLL_CFLAGS})
|
||||
list(APPEND CEF_EXE_LINKER_FLAGS ${FLL_LDFLAGS})
|
||||
list(APPEND CEF_SHARED_LINKER_FLAGS ${FLL_LDFLAGS})
|
||||
list(APPEND CEF_STANDARD_LIBS ${FLL_LIBS})
|
||||
endmacro()
|
||||
|
||||
# Set SUID permissions on the specified executable.
|
||||
macro(SET_LINUX_SUID_PERMISSIONS target executable)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo ""
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "*** Run the following command manually to set SUID permissions ***"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "EXE=\"${executable}\" && sudo -- chown root:root $EXE && sudo -- chmod 4755 $EXE"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo ""
|
||||
VERBATIM
|
||||
)
|
||||
endmacro()
|
||||
|
||||
endif(OS_LINUX)
|
||||
|
||||
|
||||
#
|
||||
# Mac OS X macros.
|
||||
#
|
||||
|
||||
if(OS_MAC)
|
||||
|
||||
# Manually process and copy over resource files.
|
||||
macro(COPY_MAC_RESOURCES resource_list prefix_list target source_dir app_path)
|
||||
foreach(FILENAME ${resource_list})
|
||||
# Remove one or more prefixes from the source paths.
|
||||
set(TARGET_FILENAME "${FILENAME}")
|
||||
foreach(PREFIX ${prefix_list})
|
||||
string(REGEX REPLACE "^.*${PREFIX}" "" TARGET_FILENAME ${TARGET_FILENAME})
|
||||
endforeach()
|
||||
|
||||
# Determine the absolute source and target paths.
|
||||
set(TARGET_PATH "${app_path}/Contents/Resources/${TARGET_FILENAME}")
|
||||
if(IS_ABSOLUTE ${FILENAME})
|
||||
set(SOURCE_PATH ${FILENAME})
|
||||
else()
|
||||
set(SOURCE_PATH "${source_dir}/${FILENAME}")
|
||||
endif()
|
||||
|
||||
if(${FILENAME} MATCHES ".xib$")
|
||||
# Change the target file extension.
|
||||
string(REGEX REPLACE ".xib$" ".nib" TARGET_PATH ${TARGET_PATH})
|
||||
|
||||
get_filename_component(TARGET_DIRECTORY ${TARGET_PATH} PATH)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
# Create the target directory.
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${TARGET_DIRECTORY}"
|
||||
# Compile the XIB file to a NIB.
|
||||
COMMAND /usr/bin/ibtool --output-format binary1 --compile "${TARGET_PATH}" "${SOURCE_PATH}"
|
||||
VERBATIM
|
||||
)
|
||||
elseif(NOT ${TARGET_FILENAME} STREQUAL "Info.plist")
|
||||
# Copy the file as-is.
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${SOURCE_PATH}" "${TARGET_PATH}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
endif(OS_MAC)
|
||||
|
||||
|
||||
#
|
||||
# Windows macros.
|
||||
#
|
||||
|
||||
if(OS_WINDOWS)
|
||||
|
||||
# Add custom manifest files to an executable target.
|
||||
macro(ADD_WINDOWS_MANIFEST manifest_path target extension)
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND "mt.exe" -nologo
|
||||
-manifest \"${manifest_path}/${target}.${extension}.manifest\" \"${manifest_path}/compatibility.manifest\"
|
||||
-outputresource:"${CEF_TARGET_OUT_DIR}/${target}.${extension}"\;\#1
|
||||
COMMENT "Adding manifest..."
|
||||
)
|
||||
endmacro()
|
||||
|
||||
endif(OS_WINDOWS)
|
||||
|
||||
|
||||
#
|
||||
# Target configuration macros.
|
||||
#
|
||||
|
||||
# Add a logical target that can be used to link the specified libraries into an
|
||||
# executable target.
|
||||
macro(ADD_LOGICAL_TARGET target debug_lib release_lib)
|
||||
add_library(${target} ${CEF_LIBTYPE} IMPORTED)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
IMPORTED_LOCATION "${release_lib}"
|
||||
IMPORTED_LOCATION_DEBUG "${debug_lib}"
|
||||
IMPORTED_LOCATION_RELEASE "${release_lib}"
|
||||
)
|
||||
endmacro()
|
||||
|
||||
# Set common target properties. Use SET_LIBRARY_TARGET_PROPERTIES() or
|
||||
# SET_EXECUTABLE_TARGET_PROPERTIES() instead of calling this macro directly.
|
||||
macro(SET_COMMON_TARGET_PROPERTIES target)
|
||||
# Compile flags.
|
||||
target_compile_options(${target} PRIVATE ${CEF_COMPILER_FLAGS} ${CEF_CXX_COMPILER_FLAGS})
|
||||
target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_FLAGS_DEBUG} ${CEF_CXX_COMPILER_FLAGS_DEBUG}>)
|
||||
target_compile_options(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_FLAGS_RELEASE} ${CEF_CXX_COMPILER_FLAGS_RELEASE}>)
|
||||
|
||||
# Compile definitions.
|
||||
target_compile_definitions(${target} PRIVATE ${CEF_COMPILER_DEFINES})
|
||||
target_compile_definitions(${target} PRIVATE $<$<CONFIG:Debug>:${CEF_COMPILER_DEFINES_DEBUG}>)
|
||||
target_compile_definitions(${target} PRIVATE $<$<CONFIG:Release>:${CEF_COMPILER_DEFINES_RELEASE}>)
|
||||
|
||||
# Include directories.
|
||||
target_include_directories(${target} PRIVATE ${CEF_INCLUDE_PATH})
|
||||
|
||||
# Linker flags.
|
||||
if(CEF_LINKER_FLAGS)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
|
||||
endif()
|
||||
if(CEF_LINKER_FLAGS_DEBUG)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_DEBUG}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
|
||||
endif()
|
||||
if(CEF_LINKER_FLAGS_RELEASE)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_LINKER_FLAGS_RELEASE}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
|
||||
endif()
|
||||
|
||||
if(OS_MAC)
|
||||
# Set Xcode target properties.
|
||||
set_target_properties(${target} PROPERTIES
|
||||
XCODE_ATTRIBUTE_ALWAYS_SEARCH_USER_PATHS NO
|
||||
XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++11" # -std=gnu++11
|
||||
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME NO # -fno-objc-link-runtime
|
||||
XCODE_ATTRIBUTE_CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS YES # -Wobjc-missing-property-synthesis
|
||||
XCODE_ATTRIBUTE_COPY_PHASE_STRIP NO
|
||||
XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING[variant=Release] YES # -Wl,-dead_strip
|
||||
XCODE_ATTRIBUTE_GCC_C_LANGUAGE_STANDARD "c99" # -std=c99
|
||||
XCODE_ATTRIBUTE_GCC_CW_ASM_SYNTAX NO # No -fasm-blocks
|
||||
XCODE_ATTRIBUTE_GCC_DYNAMIC_NO_PIC NO
|
||||
XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS NO # -fno-exceptions
|
||||
XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI NO # -fno-rtti
|
||||
XCODE_ATTRIBUTE_GCC_ENABLE_PASCAL_STRINGS NO # No -mpascal-strings
|
||||
XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN YES # -fvisibility-inlines-hidden
|
||||
XCODE_ATTRIBUTE_GCC_OBJC_CALL_CXX_CDTORS YES # -fobjc-call-cxx-cdtors
|
||||
XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES # -fvisibility=hidden
|
||||
XCODE_ATTRIBUTE_GCC_THREADSAFE_STATICS NO # -fno-threadsafe-statics
|
||||
XCODE_ATTRIBUTE_GCC_TREAT_WARNINGS_AS_ERRORS YES # -Werror
|
||||
XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0"
|
||||
XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE YES # -Wnewline-eof
|
||||
XCODE_ATTRIBUTE_USE_HEADERMAP NO
|
||||
OSX_ARCHITECTURES_DEBUG "${CMAKE_OSX_ARCHITECTURES}"
|
||||
OSX_ARCHITECTURES_RELEASE "${CMAKE_OSX_ARCHITECTURES}"
|
||||
)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Set library-specific properties.
|
||||
macro(SET_LIBRARY_TARGET_PROPERTIES target)
|
||||
SET_COMMON_TARGET_PROPERTIES(${target})
|
||||
|
||||
# Shared library linker flags.
|
||||
if(CEF_SHARED_LINKER_FLAGS)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_SHARED_LINKER_FLAGS}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
|
||||
endif()
|
||||
if(CEF_SHARED_LINKER_FLAGS_DEBUG)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_SHARED_LINKER_FLAGS_DEBUG}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
|
||||
endif()
|
||||
if(CEF_SHARED_LINKER_FLAGS_RELEASE)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_SHARED_LINKER_FLAGS_RELEASE}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Set executable-specific properties.
|
||||
macro(SET_EXECUTABLE_TARGET_PROPERTIES target)
|
||||
SET_COMMON_TARGET_PROPERTIES(${target})
|
||||
|
||||
# Executable linker flags.
|
||||
if(CEF_EXE_LINKER_FLAGS)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS ${_flags_str})
|
||||
endif()
|
||||
if(CEF_EXE_LINKER_FLAGS_DEBUG)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_DEBUG}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_DEBUG ${_flags_str})
|
||||
endif()
|
||||
if(CEF_EXE_LINKER_FLAGS_RELEASE)
|
||||
string(REPLACE ";" " " _flags_str "${CEF_EXE_LINKER_FLAGS_RELEASE}")
|
||||
set_property(TARGET ${target} PROPERTY LINK_FLAGS_RELEASE ${_flags_str})
|
||||
endif()
|
||||
endmacro()
|
@ -1,582 +0,0 @@
|
||||
# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
# Must be loaded via FindCEF.cmake.
|
||||
if(NOT DEFINED _CEF_ROOT_EXPLICIT)
|
||||
message(FATAL_ERROR "Use find_package(CEF) to load this file.")
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Shared configuration.
|
||||
#
|
||||
|
||||
# Determine the platform.
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
set(OS_MAC 1)
|
||||
set(OS_MACOSX 1) # For backwards compatibility.
|
||||
set(OS_POSIX 1)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
set(OS_LINUX 1)
|
||||
set(OS_POSIX 1)
|
||||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
||||
set(OS_WINDOWS 1)
|
||||
endif()
|
||||
|
||||
# Determine the project architecture.
|
||||
if(NOT DEFINED PROJECT_ARCH)
|
||||
if(("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64") OR
|
||||
("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM64"))
|
||||
set(PROJECT_ARCH "arm64")
|
||||
elseif(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||
set(PROJECT_ARCH "x86_64")
|
||||
else()
|
||||
set(PROJECT_ARCH "x86")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
set(GEN_NINJA 1)
|
||||
elseif(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
|
||||
set(GEN_MAKEFILES 1)
|
||||
endif()
|
||||
|
||||
# Determine the build type.
|
||||
if(NOT CMAKE_BUILD_TYPE AND (GEN_NINJA OR GEN_MAKEFILES))
|
||||
# CMAKE_BUILD_TYPE should be specified when using Ninja or Unix Makefiles.
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
message(WARNING "No CMAKE_BUILD_TYPE value selected, using ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
|
||||
|
||||
# Path to the include directory.
|
||||
set(CEF_INCLUDE_PATH "${_CEF_ROOT}")
|
||||
|
||||
# Path to the libcef_dll_wrapper target.
|
||||
set(CEF_LIBCEF_DLL_WRAPPER_PATH "${_CEF_ROOT}/libcef_dll")
|
||||
|
||||
|
||||
# Shared compiler/linker flags.
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
# Allow C++ programs to use stdint.h macros specified in the C99 standard that aren't
|
||||
# in the C++ standard (e.g. UINT8_MAX, INT64_MIN, etc)
|
||||
__STDC_CONSTANT_MACROS __STDC_FORMAT_MACROS
|
||||
)
|
||||
|
||||
|
||||
# Configure use of the sandbox.
|
||||
option(USE_SANDBOX "Enable or disable use of the sandbox." ON)
|
||||
|
||||
|
||||
#
|
||||
# Linux configuration.
|
||||
#
|
||||
|
||||
if(OS_LINUX)
|
||||
# Platform-specific compiler/linker flags.
|
||||
set(CEF_LIBTYPE SHARED)
|
||||
list(APPEND CEF_COMPILER_FLAGS
|
||||
-fno-strict-aliasing # Avoid assumptions regarding non-aliasing of objects of different types
|
||||
-fPIC # Generate position-independent code for shared libraries
|
||||
-fstack-protector # Protect some vulnerable functions from stack-smashing (security feature)
|
||||
-funwind-tables # Support stack unwinding for backtrace()
|
||||
-fvisibility=hidden # Give hidden visibility to declarations that are not explicitly marked as visible
|
||||
--param=ssp-buffer-size=4 # Set the minimum buffer size protected by SSP (security feature, related to stack-protector)
|
||||
-pipe # Use pipes rather than temporary files for communication between build stages
|
||||
-pthread # Use the pthread library
|
||||
# -Wall # Enable all warnings
|
||||
# -Werror # Treat warnings as errors
|
||||
# -Wno-missing-field-initializers # Don't warn about missing field initializers
|
||||
# -Wno-unused-parameter # Don't warn about unused parameters
|
||||
# -Wno-error=comment # Don't warn about code in comments
|
||||
# -Wno-comment # Don't warn about code in comments
|
||||
# -Wno-deprecated-declarations # Don't warn about using deprecated methods
|
||||
)
|
||||
list(APPEND CEF_C_COMPILER_FLAGS
|
||||
-std=c99 # Use the C99 language standard
|
||||
)
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
# -fno-exceptions # Disable exceptions
|
||||
# -fno-rtti # Disable real-time type information
|
||||
-fno-threadsafe-statics # Don't generate thread-safe statics
|
||||
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
||||
-std=c++17 # Use the C++17 language standard
|
||||
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||
-O0 # Disable optimizations
|
||||
-g # Generate debug information
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE
|
||||
-O2 # Optimize for maximum speed
|
||||
-fdata-sections # Enable linker optimizations to improve locality of reference for data sections
|
||||
-ffunction-sections # Enable linker optimizations to improve locality of reference for function sections
|
||||
-fno-ident # Ignore the #ident directive
|
||||
-U_FORTIFY_SOURCE # Undefine _FORTIFY_SOURCE in case it was previously defined
|
||||
-D_FORTIFY_SOURCE=2 # Add memory and string function protection (security feature, related to stack-protector)
|
||||
)
|
||||
list(APPEND CEF_LINKER_FLAGS
|
||||
-fPIC # Generate position-independent code for shared libraries
|
||||
-pthread # Use the pthread library
|
||||
-Wl,--disable-new-dtags # Don't generate new-style dynamic tags in ELF
|
||||
-Wl,--fatal-warnings # Treat warnings as errors
|
||||
-Wl,-rpath,. # Set rpath so that libraries can be placed next to the executable
|
||||
-Wl,-z,noexecstack # Mark the stack as non-executable (security feature)
|
||||
-Wl,-z,now # Resolve symbols on program start instead of on first use (security feature)
|
||||
-Wl,-z,relro # Mark relocation sections as read-only (security feature)
|
||||
)
|
||||
list(APPEND CEF_LINKER_FLAGS_RELEASE
|
||||
-Wl,-O1 # Enable linker optimizations
|
||||
-Wl,--as-needed # Only link libraries that export symbols used by the binary
|
||||
-Wl,--gc-sections # Remove unused code resulting from -fdata-sections and -function-sections
|
||||
)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
_FILE_OFFSET_BITS=64 # Allow the Large File Support (LFS) interface to replace the old interface
|
||||
)
|
||||
list(APPEND CEF_COMPILER_DEFINES_RELEASE
|
||||
NDEBUG # Not a debug build
|
||||
)
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
CHECK_CXX_COMPILER_FLAG(-Wno-undefined-var-template COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
||||
if(COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
-Wno-undefined-var-template # Don't warn about potentially uninstantiated static members
|
||||
)
|
||||
endif()
|
||||
|
||||
CHECK_C_COMPILER_FLAG(-Wno-unused-local-typedefs COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
||||
if(COMPILER_SUPPORTS_NO_UNUSED_LOCAL_TYPEDEFS)
|
||||
list(APPEND CEF_C_COMPILER_FLAGS
|
||||
-Wno-unused-local-typedefs # Don't warn about unused local typedefs
|
||||
)
|
||||
endif()
|
||||
|
||||
CHECK_CXX_COMPILER_FLAG(-Wno-literal-suffix COMPILER_SUPPORTS_NO_LITERAL_SUFFIX)
|
||||
if(COMPILER_SUPPORTS_NO_LITERAL_SUFFIX)
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
-Wno-literal-suffix # Don't warn about invalid suffixes on literals
|
||||
)
|
||||
endif()
|
||||
|
||||
CHECK_CXX_COMPILER_FLAG(-Wno-narrowing COMPILER_SUPPORTS_NO_NARROWING)
|
||||
if(COMPILER_SUPPORTS_NO_NARROWING)
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
-Wno-narrowing # Don't warn about type narrowing
|
||||
)
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
-Wno-attributes # The cfi-icall attribute is not supported by the GNU C++ compiler
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PROJECT_ARCH STREQUAL "x86_64")
|
||||
# 64-bit architecture.
|
||||
list(APPEND CEF_COMPILER_FLAGS
|
||||
-m64
|
||||
-march=x86-64
|
||||
)
|
||||
list(APPEND CEF_LINKER_FLAGS
|
||||
-m64
|
||||
)
|
||||
elseif(PROJECT_ARCH STREQUAL "x86")
|
||||
# 32-bit architecture.
|
||||
list(APPEND CEF_COMPILER_FLAGS
|
||||
-msse2
|
||||
-mfpmath=sse
|
||||
-mmmx
|
||||
-m32
|
||||
)
|
||||
list(APPEND CEF_LINKER_FLAGS
|
||||
-m32
|
||||
)
|
||||
endif()
|
||||
|
||||
# Standard libraries.
|
||||
set(CEF_STANDARD_LIBS
|
||||
X11
|
||||
)
|
||||
|
||||
# CEF directory paths.
|
||||
set(CEF_RESOURCE_DIR "${_CEF_ROOT}/Resources")
|
||||
set(CEF_BINARY_DIR "${_CEF_ROOT}/${CMAKE_BUILD_TYPE}")
|
||||
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
|
||||
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/Release")
|
||||
|
||||
# CEF library paths.
|
||||
set(CEF_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/libcef.so")
|
||||
set(CEF_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/libcef.so")
|
||||
|
||||
# List of CEF binary files.
|
||||
set(CEF_BINARY_FILES
|
||||
chrome-sandbox
|
||||
libcef.so
|
||||
libEGL.so
|
||||
libGLESv2.so
|
||||
libvk_swiftshader.so
|
||||
# libvulkan.so.1
|
||||
snapshot_blob.bin
|
||||
v8_context_snapshot.bin
|
||||
vk_swiftshader_icd.json
|
||||
)
|
||||
|
||||
# List of CEF resource files.
|
||||
set(CEF_RESOURCE_FILES
|
||||
chrome_100_percent.pak
|
||||
chrome_200_percent.pak
|
||||
resources.pak
|
||||
icudtl.dat
|
||||
locales
|
||||
)
|
||||
|
||||
if(USE_SANDBOX)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Mac OS X configuration.
|
||||
#
|
||||
|
||||
if(OS_MAC)
|
||||
# Platform-specific compiler/linker flags.
|
||||
# See also Xcode target properties in cef_macros.cmake.
|
||||
set(CEF_LIBTYPE SHARED)
|
||||
list(APPEND CEF_COMPILER_FLAGS
|
||||
-fno-strict-aliasing # Avoid assumptions regarding non-aliasing of objects of different types
|
||||
-fstack-protector # Protect some vulnerable functions from stack-smashing (security feature)
|
||||
-funwind-tables # Support stack unwinding for backtrace()
|
||||
-fvisibility=hidden # Give hidden visibility to declarations that are not explicitly marked as visible
|
||||
-Wall # Enable all warnings
|
||||
-Werror # Treat warnings as errors
|
||||
-Wextra # Enable additional warnings
|
||||
-Wendif-labels # Warn whenever an #else or an #endif is followed by text
|
||||
-Wnewline-eof # Warn about no newline at end of file
|
||||
-Wno-missing-field-initializers # Don't warn about missing field initializers
|
||||
-Wno-unused-parameter # Don't warn about unused parameters
|
||||
)
|
||||
list(APPEND CEF_C_COMPILER_FLAGS
|
||||
-std=c99 # Use the C99 language standard
|
||||
)
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
# -fno-exceptions # Disable exceptions
|
||||
# -fno-rtti # Disable real-time type information
|
||||
-fno-threadsafe-statics # Don't generate thread-safe statics
|
||||
-fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects
|
||||
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
|
||||
-std=c++17 # Use the C++17 language standard
|
||||
-Wno-narrowing # Don't warn about type narrowing
|
||||
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||
-O0 # Disable optimizations
|
||||
-g # Generate debug information
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE
|
||||
-O3 # Optimize for maximum speed plus a few extras
|
||||
)
|
||||
list(APPEND CEF_LINKER_FLAGS
|
||||
-Wl,-search_paths_first # Search for static or shared library versions in the same pass
|
||||
-Wl,-ObjC # Support creation of ObjC static libraries
|
||||
-Wl,-pie # Generate position-independent code suitable for executables only
|
||||
)
|
||||
list(APPEND CEF_LINKER_FLAGS_RELEASE
|
||||
-Wl,-dead_strip # Strip dead code
|
||||
)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
CHECK_CXX_COMPILER_FLAG(-Wno-undefined-var-template COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
||||
if(COMPILER_SUPPORTS_NO_UNDEFINED_VAR_TEMPLATE)
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
-Wno-undefined-var-template # Don't warn about potentially uninstantiated static members
|
||||
)
|
||||
endif()
|
||||
|
||||
# Standard libraries.
|
||||
set(CEF_STANDARD_LIBS
|
||||
-lpthread
|
||||
"-framework Cocoa"
|
||||
"-framework AppKit"
|
||||
)
|
||||
|
||||
# Find the newest available base SDK.
|
||||
execute_process(COMMAND xcode-select --print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
foreach(OS_VERSION 10.15 10.14 10.13)
|
||||
set(SDK "${XCODE_PATH}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${OS_VERSION}.sdk")
|
||||
if(NOT "${CMAKE_OSX_SYSROOT}" AND EXISTS "${SDK}" AND IS_DIRECTORY "${SDK}")
|
||||
set(CMAKE_OSX_SYSROOT ${SDK})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Target SDK.
|
||||
set(CEF_TARGET_SDK "10.13")
|
||||
list(APPEND CEF_COMPILER_FLAGS
|
||||
-mmacosx-version-min=${CEF_TARGET_SDK}
|
||||
)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET ${CEF_TARGET_SDK})
|
||||
|
||||
# Target architecture.
|
||||
if(PROJECT_ARCH STREQUAL "x86_64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
elseif(PROJECT_ARCH STREQUAL "arm64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64")
|
||||
else()
|
||||
set(CMAKE_OSX_ARCHITECTURES "i386")
|
||||
endif()
|
||||
|
||||
# Prevent Xcode 11 from doing automatic codesigning.
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
|
||||
|
||||
# CEF directory paths.
|
||||
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
|
||||
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
|
||||
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/Release")
|
||||
|
||||
if(USE_SANDBOX)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
||||
)
|
||||
|
||||
list(APPEND CEF_STANDARD_LIBS
|
||||
-lsandbox
|
||||
)
|
||||
|
||||
# CEF sandbox library paths.
|
||||
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.a")
|
||||
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.a")
|
||||
endif()
|
||||
|
||||
# CEF Helper app suffixes.
|
||||
# Format is "<name suffix>:<target suffix>:<plist suffix>".
|
||||
set(CEF_HELPER_APP_SUFFIXES
|
||||
"::"
|
||||
" (Alerts):_alerts:.alerts"
|
||||
" (GPU):_gpu:.gpu"
|
||||
" (Plugin):_plugin:.plugin"
|
||||
" (Renderer):_renderer:.renderer"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# Windows configuration.
|
||||
#
|
||||
|
||||
if(OS_WINDOWS)
|
||||
if (GEN_NINJA)
|
||||
# When using the Ninja generator clear the CMake defaults to avoid excessive
|
||||
# console warnings (see issue #2120).
|
||||
set(CMAKE_CXX_FLAGS "")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
endif()
|
||||
|
||||
if(USE_SANDBOX)
|
||||
# Check if the current MSVC version is compatible with the cef_sandbox.lib
|
||||
# static library. We require VS2015 or newer.
|
||||
if(MSVC_VERSION LESS 1900)
|
||||
message(WARNING "CEF sandbox is not compatible with the current MSVC version (${MSVC_VERSION})")
|
||||
set(USE_SANDBOX OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Consumers who run into LNK4099 warnings can pass /Z7 instead (see issue #385).
|
||||
set(CEF_DEBUG_INFO_FLAG "/Zi" CACHE STRING "Optional flag specifying specific /Z flag to use")
|
||||
|
||||
# Consumers using different runtime types may want to pass different flags
|
||||
set(CEF_RUNTIME_LIBRARY_FLAG "/MT" CACHE STRING "Optional flag specifying which runtime to use")
|
||||
if (CEF_RUNTIME_LIBRARY_FLAG)
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG ${CEF_RUNTIME_LIBRARY_FLAG}d)
|
||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE ${CEF_RUNTIME_LIBRARY_FLAG})
|
||||
endif()
|
||||
|
||||
# Platform-specific compiler/linker flags.
|
||||
set(CEF_LIBTYPE STATIC)
|
||||
list(APPEND CEF_COMPILER_FLAGS
|
||||
/MP # Multiprocess compilation
|
||||
/Gy # Enable function-level linking
|
||||
/GR- # Disable run-time type information
|
||||
/W4 # Warning level 4
|
||||
/WX # Treat warnings as errors
|
||||
/wd4100 # Ignore "unreferenced formal parameter" warning
|
||||
/wd4127 # Ignore "conditional expression is constant" warning
|
||||
/wd4244 # Ignore "conversion possible loss of data" warning
|
||||
/wd4324 # Ignore "structure was padded due to alignment specifier" warning
|
||||
/wd4481 # Ignore "nonstandard extension used: override" warning
|
||||
/wd4512 # Ignore "assignment operator could not be generated" warning
|
||||
/wd4701 # Ignore "potentially uninitialized local variable" warning
|
||||
/wd4702 # Ignore "unreachable code" warning
|
||||
/wd4996 # Ignore "function or variable may be unsafe" warning
|
||||
${CEF_DEBUG_INFO_FLAG}
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_DEBUG
|
||||
/RTC1 # Disable optimizations
|
||||
/Od # Enable basic run-time checks
|
||||
)
|
||||
list(APPEND CEF_COMPILER_FLAGS_RELEASE
|
||||
/O2 # Optimize for maximum speed
|
||||
/Ob2 # Inline any suitable function
|
||||
/GF # Enable string pooling
|
||||
)
|
||||
list(APPEND CEF_CXX_COMPILER_FLAGS
|
||||
/std:c++17 # Use the C++17 language standard
|
||||
)
|
||||
list(APPEND CEF_LINKER_FLAGS_DEBUG
|
||||
/DEBUG # Generate debug information
|
||||
)
|
||||
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||
/MANIFEST:NO # No default manifest (see ADD_WINDOWS_MANIFEST macro usage)
|
||||
/LARGEADDRESSAWARE # Allow 32-bit processes to access 3GB of RAM
|
||||
)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
WIN32 _WIN32 _WINDOWS # Windows platform
|
||||
UNICODE _UNICODE # Unicode build
|
||||
# Targeting Windows 10. We can't say `=_WIN32_WINNT_WIN10` here because
|
||||
# some files do `#if WINVER < 0x0600` without including windows.h before,
|
||||
# and then _WIN32_WINNT_WIN10 isn't yet known to be 0x0A00.
|
||||
WINVER=0x0A00
|
||||
_WIN32_WINNT=0x0A00
|
||||
NTDDI_VERSION=NTDDI_WIN10_FE
|
||||
NOMINMAX # Use the standard's templated min/max
|
||||
WIN32_LEAN_AND_MEAN # Exclude less common API declarations
|
||||
_HAS_EXCEPTIONS=0 # Disable exceptions
|
||||
)
|
||||
list(APPEND CEF_COMPILER_DEFINES_RELEASE
|
||||
NDEBUG _NDEBUG # Not a debug build
|
||||
)
|
||||
|
||||
if(PROJECT_ARCH STREQUAL "x86")
|
||||
# Set the initial stack size to 0.5MiB, instead of the 1.5MiB minimum
|
||||
# needed by CEF's main thread. This saves significant memory on threads
|
||||
# (like those in the Windows thread pool, and others) whose stack size we
|
||||
# can only control through this setting. The main thread (in 32-bit builds
|
||||
# only) uses fibers to switch to a 4MiB stack at runtime via
|
||||
# CefRunWinMainWithPreferredStackSize().
|
||||
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||
/STACK:0x80000
|
||||
)
|
||||
else()
|
||||
# Increase the initial stack size to 8MiB from the default 1MiB.
|
||||
list(APPEND CEF_EXE_LINKER_FLAGS
|
||||
/STACK:0x800000
|
||||
)
|
||||
endif()
|
||||
|
||||
# Standard libraries.
|
||||
set(CEF_STANDARD_LIBS
|
||||
comctl32.lib
|
||||
gdi32.lib
|
||||
rpcrt4.lib
|
||||
shlwapi.lib
|
||||
ws2_32.lib
|
||||
)
|
||||
|
||||
# CEF directory paths.
|
||||
set(CEF_RESOURCE_DIR "${_CEF_ROOT}/Resources")
|
||||
set(CEF_BINARY_DIR "${_CEF_ROOT}/$<CONFIGURATION>")
|
||||
set(CEF_BINARY_DIR_DEBUG "${_CEF_ROOT}/Debug")
|
||||
set(CEF_BINARY_DIR_RELEASE "${_CEF_ROOT}/Release")
|
||||
|
||||
# CEF library paths.
|
||||
set(CEF_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/libcef.lib")
|
||||
set(CEF_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/libcef.lib")
|
||||
|
||||
# List of CEF binary files.
|
||||
set(CEF_BINARY_FILES
|
||||
chrome_elf.dll
|
||||
d3dcompiler_47.dll
|
||||
libcef.dll
|
||||
libEGL.dll
|
||||
libGLESv2.dll
|
||||
snapshot_blob.bin
|
||||
v8_context_snapshot.bin
|
||||
vk_swiftshader.dll
|
||||
vk_swiftshader_icd.json
|
||||
vulkan-1.dll
|
||||
)
|
||||
|
||||
# List of CEF resource files.
|
||||
set(CEF_RESOURCE_FILES
|
||||
chrome_100_percent.pak
|
||||
chrome_200_percent.pak
|
||||
resources.pak
|
||||
icudtl.dat
|
||||
locales
|
||||
)
|
||||
|
||||
if(USE_SANDBOX)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
PSAPI_VERSION=1 # Required by cef_sandbox.lib
|
||||
CEF_USE_SANDBOX # Used by apps to test if the sandbox is enabled
|
||||
)
|
||||
list(APPEND CEF_COMPILER_DEFINES_DEBUG
|
||||
_HAS_ITERATOR_DEBUGGING=0 # Disable iterator debugging
|
||||
)
|
||||
|
||||
# Libraries required by cef_sandbox.lib.
|
||||
set(CEF_SANDBOX_STANDARD_LIBS
|
||||
Advapi32.lib
|
||||
dbghelp.lib
|
||||
Delayimp.lib
|
||||
ntdll.lib
|
||||
OleAut32.lib
|
||||
PowrProf.lib
|
||||
Propsys.lib
|
||||
psapi.lib
|
||||
SetupAPI.lib
|
||||
Shell32.lib
|
||||
Shcore.lib
|
||||
Userenv.lib
|
||||
version.lib
|
||||
wbemuuid.lib
|
||||
WindowsApp.lib
|
||||
winmm.lib
|
||||
)
|
||||
|
||||
# CEF sandbox library paths.
|
||||
set(CEF_SANDBOX_LIB_DEBUG "${CEF_BINARY_DIR_DEBUG}/cef_sandbox.lib")
|
||||
set(CEF_SANDBOX_LIB_RELEASE "${CEF_BINARY_DIR_RELEASE}/cef_sandbox.lib")
|
||||
endif()
|
||||
|
||||
# Configure use of ATL.
|
||||
option(USE_ATL "Enable or disable use of ATL." ON)
|
||||
if(USE_ATL)
|
||||
# Locate the atlmfc directory if it exists. It may be at any depth inside
|
||||
# the VC directory. The cl.exe path returned by CMAKE_CXX_COMPILER may also
|
||||
# be at different depths depending on the toolchain version
|
||||
# (e.g. "VC/bin/cl.exe", "VC/bin/amd64_x86/cl.exe",
|
||||
# "VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe", etc).
|
||||
set(HAS_ATLMFC 0)
|
||||
get_filename_component(VC_DIR ${CMAKE_CXX_COMPILER} DIRECTORY)
|
||||
get_filename_component(VC_DIR_NAME ${VC_DIR} NAME)
|
||||
while(NOT ${VC_DIR_NAME} STREQUAL "VC")
|
||||
get_filename_component(VC_DIR ${VC_DIR} DIRECTORY)
|
||||
if(IS_DIRECTORY "${VC_DIR}/atlmfc")
|
||||
set(HAS_ATLMFC 1)
|
||||
break()
|
||||
endif()
|
||||
get_filename_component(VC_DIR_NAME ${VC_DIR} NAME)
|
||||
endwhile()
|
||||
|
||||
# Determine if the Visual Studio install supports ATL.
|
||||
if(NOT HAS_ATLMFC)
|
||||
message(WARNING "ATL is not supported by your VC installation.")
|
||||
set(USE_ATL OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_ATL)
|
||||
list(APPEND CEF_COMPILER_DEFINES
|
||||
CEF_USE_ATL # Used by apps to test if ATL support is enabled
|
||||
)
|
||||
endif()
|
||||
endif()
|
29
main.cpp
29
main.cpp
@ -8,30 +8,45 @@
|
||||
|
||||
WallpaperEngine::Application::CWallpaperApplication* app;
|
||||
|
||||
void signalhandler(int sig)
|
||||
{
|
||||
void signalhandler(int sig) {
|
||||
if (app == nullptr)
|
||||
return;
|
||||
|
||||
app->signal (sig);
|
||||
}
|
||||
|
||||
void initLogging ()
|
||||
{
|
||||
void initLogging () {
|
||||
sLog.addOutput (new std::ostream (std::cout.rdbuf ()));
|
||||
sLog.addError (new std::ostream (std::cerr.rdbuf ()));
|
||||
}
|
||||
|
||||
int main (int argc, char* argv[]) {
|
||||
initLogging ();
|
||||
WallpaperEngine::WebBrowser::CWebBrowserContext webBrowserContext(argc, argv);
|
||||
// if type parameter is specified, this is a subprocess, so no logging should be enabled from our side
|
||||
bool enableLogging = true;
|
||||
std::string typeZygote = "--type=zygote";
|
||||
std::string typeUtility = "--type=utility";
|
||||
|
||||
for (int i = 1; i < argc; i ++) {
|
||||
if (strncmp (typeZygote.c_str(), argv[i], typeZygote.size()) == 0) {
|
||||
enableLogging = false;
|
||||
break;
|
||||
} else if (strncmp (typeUtility.c_str(), argv[i], typeUtility.size()) == 0) {
|
||||
enableLogging = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (enableLogging) {
|
||||
initLogging ();
|
||||
}
|
||||
|
||||
WallpaperEngine::Application::CApplicationContext appContext (argc, argv);
|
||||
|
||||
// halt if the list-properties option was specified
|
||||
if (appContext.settings.general.onlyListProperties)
|
||||
return 0;
|
||||
|
||||
app = new WallpaperEngine::Application::CWallpaperApplication (appContext, webBrowserContext);
|
||||
app = new WallpaperEngine::Application::CWallpaperApplication (appContext);
|
||||
|
||||
// attach signals to gracefully stop
|
||||
std::signal (SIGINT, signalhandler);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <getopt.h>
|
||||
#include <iostream>
|
||||
|
||||
#define WORKSHOP_APP_ID 431960
|
||||
#define APP_DIRECTORY "wallpaper_engine"
|
||||
@ -55,7 +56,9 @@ std::string stringPathFixes (const std::string& s) {
|
||||
return std::move (str);
|
||||
}
|
||||
|
||||
CApplicationContext::CApplicationContext (int argc, char* argv []) {
|
||||
CApplicationContext::CApplicationContext (int argc, char* argv []) :
|
||||
m_argc (argc),
|
||||
m_argv (argv) {
|
||||
// setup structs with sane default values for now
|
||||
this->settings = {
|
||||
.general =
|
||||
@ -90,6 +93,19 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) {
|
||||
},
|
||||
};
|
||||
|
||||
// use std::out on this in case logging is disabled, this way it's easy to look at what is running
|
||||
std::stringbuf buffer;
|
||||
std::ostream bufferStream (&buffer);
|
||||
|
||||
bufferStream << "Running with: ";
|
||||
|
||||
for (int i = 0; i < argc; i ++) {
|
||||
bufferStream << argv [i];
|
||||
bufferStream << " ";
|
||||
}
|
||||
|
||||
std::cout << buffer.str() << std::endl;
|
||||
|
||||
int c;
|
||||
|
||||
std::string lastScreen;
|
||||
@ -248,6 +264,14 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) {
|
||||
this->state.audio.volume = this->settings.audio.volume;
|
||||
}
|
||||
|
||||
int CApplicationContext::getArgc () const {
|
||||
return this->m_argc;
|
||||
}
|
||||
|
||||
char** CApplicationContext::getArgv () const {
|
||||
return this->m_argv;
|
||||
}
|
||||
|
||||
std::filesystem::path CApplicationContext::translateBackground (const std::string& bgIdOrPath) {
|
||||
if (bgIdOrPath.find ('/') == std::string::npos)
|
||||
return Steam::FileSystem::workshopDirectory (WORKSHOP_APP_ID, bgIdOrPath);
|
||||
|
@ -104,7 +104,15 @@ class CApplicationContext {
|
||||
|
||||
CApplicationState state;
|
||||
|
||||
[[nodiscard]] int getArgc() const;
|
||||
[[nodiscard]] char** getArgv() const;
|
||||
|
||||
private:
|
||||
/** Program argument count on startup */
|
||||
int m_argc;
|
||||
/** Program arguments on startup */
|
||||
char** m_argv;
|
||||
|
||||
/**
|
||||
* Validates the assets folder and ensures a valid one is present
|
||||
*/
|
||||
|
@ -16,6 +16,7 @@
|
||||
#endif /* ENABLE_WAYLAND */
|
||||
|
||||
#ifdef ENABLE_X11
|
||||
#include "WallpaperEngine/Core/Wallpapers/CWeb.h"
|
||||
#include "WallpaperEngine/Render/Drivers/Detectors/CX11FullScreenDetector.h"
|
||||
#endif /* ENABLE_X11 */
|
||||
|
||||
@ -30,10 +31,9 @@ float g_TimeLast;
|
||||
float g_Daytime;
|
||||
|
||||
namespace WallpaperEngine::Application {
|
||||
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context,
|
||||
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) :
|
||||
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context) :
|
||||
m_context (context),
|
||||
m_browserContext (browserContext),
|
||||
m_browserContext (nullptr),
|
||||
m_audioContext (nullptr),
|
||||
m_audioDriver (nullptr),
|
||||
m_audioRecorder (nullptr),
|
||||
@ -43,6 +43,7 @@ CWallpaperApplication::CWallpaperApplication (CApplicationContext& context,
|
||||
m_fullScreenDetector (nullptr) {
|
||||
this->loadBackgrounds ();
|
||||
this->setupProperties ();
|
||||
this->setupBrowser();
|
||||
}
|
||||
|
||||
CWallpaperApplication::~CWallpaperApplication () {
|
||||
@ -51,6 +52,7 @@ CWallpaperApplication::~CWallpaperApplication () {
|
||||
delete m_audioContext;
|
||||
delete m_audioDriver;
|
||||
delete m_inputContext;
|
||||
delete m_browserContext;
|
||||
}
|
||||
|
||||
void CWallpaperApplication::setupContainer (CCombinedContainer& container, const std::string& bg) const {
|
||||
@ -201,10 +203,23 @@ void CWallpaperApplication::setupPropertiesForProject (const Core::CProject* pro
|
||||
}
|
||||
|
||||
void CWallpaperApplication::setupProperties () {
|
||||
for (const auto& [backgrounc, info] : this->m_backgrounds)
|
||||
for (const auto& [background, info] : this->m_backgrounds)
|
||||
this->setupPropertiesForProject (info);
|
||||
}
|
||||
|
||||
void CWallpaperApplication::setupBrowser () {
|
||||
bool anyWebProject = std::any_of (this->m_backgrounds.begin (), this->m_backgrounds.end (), [](std::pair<const std::string, const Core::CProject*> pair) -> bool {
|
||||
return pair.second->getWallpaper()->is<Core::Wallpapers::CWeb> ();
|
||||
});
|
||||
|
||||
// do not perform any initialization if no web background is present
|
||||
if (!anyWebProject) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->m_browserContext = new WebBrowser::CWebBrowserContext (*this);
|
||||
}
|
||||
|
||||
void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filename) const {
|
||||
// this should be getting called at the end of the frame, so the right thing should be bound already
|
||||
const int width = this->m_renderContext->getOutput ().getFullWidth ();
|
||||
@ -384,7 +399,7 @@ void CWallpaperApplication::show () {
|
||||
for (const auto& [background, info] : this->m_backgrounds) {
|
||||
m_renderContext->setWallpaper (background,
|
||||
WallpaperEngine::Render::CWallpaper::fromWallpaper (
|
||||
info->getWallpaper (), *m_renderContext, *m_audioContext, m_browserContext,
|
||||
info->getWallpaper (), *m_renderContext, *m_audioContext, *m_browserContext,
|
||||
this->m_context.settings.general.screenScalings [background]));
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace WallpaperEngine::Application {
|
||||
*/
|
||||
class CWallpaperApplication {
|
||||
public:
|
||||
explicit CWallpaperApplication (CApplicationContext& context, WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext);
|
||||
explicit CWallpaperApplication (CApplicationContext& context);
|
||||
~CWallpaperApplication ();
|
||||
|
||||
/**
|
||||
@ -101,6 +101,10 @@ class CWallpaperApplication {
|
||||
* @param project
|
||||
*/
|
||||
void setupPropertiesForProject (const Core::CProject* project);
|
||||
/**
|
||||
* Prepares CEF browser to be used
|
||||
*/
|
||||
void setupBrowser ();
|
||||
/**
|
||||
* Takes an screenshot of the background and saves it to the specified path
|
||||
*
|
||||
@ -120,6 +124,6 @@ class CWallpaperApplication {
|
||||
WallpaperEngine::Render::CRenderContext* m_renderContext;
|
||||
WallpaperEngine::Render::Drivers::CVideoDriver* m_videoDriver;
|
||||
WallpaperEngine::Render::Drivers::Detectors::CFullScreenDetector* m_fullScreenDetector;
|
||||
WallpaperEngine::WebBrowser::CWebBrowserContext& m_browserContext;
|
||||
WallpaperEngine::WebBrowser::CWebBrowserContext* m_browserContext;
|
||||
};
|
||||
} // namespace WallpaperEngine::Application
|
||||
|
@ -36,6 +36,8 @@ const uint8_t* CDirectory::readFile (const std::string& filename, uint32_t* leng
|
||||
return it->second.address;
|
||||
}
|
||||
|
||||
// TODO: PREVENT ESCAPING THE BASE PATH ON INITIALIZATION
|
||||
|
||||
FILE* fp = fopen (final.c_str (), "rb");
|
||||
|
||||
if (fp == nullptr)
|
||||
|
@ -15,7 +15,7 @@ using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Core::UserSettings;
|
||||
|
||||
CObject::CObject (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
||||
CObject::CObject (Wallpapers::CScene* scene, CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
||||
CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles) :
|
||||
m_scene (scene),
|
||||
m_visible (visible),
|
||||
@ -26,7 +26,7 @@ CObject::CObject (CScene* scene, CUserSettingBoolean* visible, int id, std::stri
|
||||
m_scale (scale),
|
||||
m_angles (angles) {}
|
||||
|
||||
CObject* CObject::fromJSON (json data, CScene* scene, CContainer* container) {
|
||||
CObject* CObject::fromJSON (json data, Wallpapers::CScene* scene, CContainer* container) {
|
||||
std::string json = data.dump ();
|
||||
|
||||
auto id_it = jsonFindRequired (data, "id", "Objects must have id");
|
||||
@ -117,7 +117,7 @@ bool CObject::isVisible () const {
|
||||
return this->m_visible->processValue (this->getScene ()->getProject ().getProperties ());
|
||||
}
|
||||
|
||||
CScene* CObject::getScene () const {
|
||||
Wallpapers::CScene* CObject::getScene () const {
|
||||
return this->m_scene;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h"
|
||||
|
||||
namespace WallpaperEngine::Core {
|
||||
namespace WallpaperEngine::Core::Wallpapers {
|
||||
class CScene;
|
||||
}
|
||||
|
||||
@ -26,10 +26,10 @@ using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Core::UserSettings;
|
||||
|
||||
class CObject {
|
||||
friend class CScene;
|
||||
friend class Wallpapers::CScene;
|
||||
|
||||
public:
|
||||
static CObject* fromJSON (json data, CScene* scene, CContainer* container);
|
||||
static CObject* fromJSON (json data, Wallpapers::CScene* scene, CContainer* container);
|
||||
|
||||
template <class T> const T* as () const {
|
||||
assert (is<T> ());
|
||||
@ -55,10 +55,10 @@ class CObject {
|
||||
[[nodiscard]] const std::string& getName () const;
|
||||
|
||||
[[nodiscard]] bool isVisible () const;
|
||||
[[nodiscard]] CScene* getScene () const;
|
||||
[[nodiscard]] Wallpapers::CScene* getScene () const;
|
||||
|
||||
protected:
|
||||
CObject (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
||||
CObject (Wallpapers::CScene* scene, CUserSettingBoolean* visible, int id, std::string name, std::string type,
|
||||
CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles);
|
||||
|
||||
void insertEffect (Objects::CEffect* effect);
|
||||
@ -77,6 +77,6 @@ class CObject {
|
||||
std::vector<Objects::CEffect*> m_effects;
|
||||
std::vector<int> m_dependencies;
|
||||
|
||||
CScene* m_scene;
|
||||
Wallpapers::CScene* m_scene;
|
||||
};
|
||||
} // namespace WallpaperEngine::Core
|
||||
|
@ -1,25 +1,35 @@
|
||||
#include "common.h"
|
||||
#include <WallpaperEngine/Assets/CContainer.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "CProject.h"
|
||||
#include "WallpaperEngine/Core/Wallpapers/CScene.h"
|
||||
#include "WallpaperEngine/Core/Wallpapers/CVideo.h"
|
||||
#include "WallpaperEngine/Core/Wallpapers/CWeb.h"
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Core::Wallpapers;
|
||||
using namespace WallpaperEngine::Assets;
|
||||
|
||||
CProject::CProject (std::string title, std::string type, CContainer* container) :
|
||||
static int backgroundId = -1;
|
||||
|
||||
CProject::CProject (std::string title, std::string type, std::string workshopid, CContainer* container) :
|
||||
m_title (std::move (title)),
|
||||
m_type (std::move (type)),
|
||||
m_wallpaper (nullptr),
|
||||
m_container (container) {}
|
||||
m_container (container),
|
||||
m_workshopid(std::move(workshopid))
|
||||
{}
|
||||
|
||||
CProject* CProject::fromFile (const std::string& filename, CContainer* container) {
|
||||
json content = json::parse (container->readFileAsString (filename));
|
||||
|
||||
std::string dependency = jsonFindDefault<std::string> (content, "dependency", "No dependency");
|
||||
if (dependency == "No dependency") {
|
||||
// workshopid is not required, but we have to use it for some identification stuff,
|
||||
// so using a static, decreasing number should be enough
|
||||
std::string workshopid = jsonFindDefault <std::string> (content, "workshopid", std::to_string (backgroundId--));
|
||||
std::string title = *jsonFindRequired (content, "title", "Project title missing");
|
||||
std::string type = *jsonFindRequired (content, "type", "Project type missing");
|
||||
std::string file = *jsonFindRequired (content, "file", "Project's main file missing");
|
||||
@ -28,7 +38,7 @@ CProject* CProject::fromFile (const std::string& filename, CContainer* container
|
||||
|
||||
std::transform (type.begin (), type.end (), type.begin (), tolower);
|
||||
|
||||
CProject* project = new CProject (title, type, container);
|
||||
CProject* project = new CProject (title, type, workshopid, container);
|
||||
|
||||
if (type == "scene")
|
||||
wallpaper = CScene::fromFile (file, *project, container);
|
||||
@ -78,6 +88,10 @@ const std::vector<Projects::CProperty*>& CProject::getProperties () const {
|
||||
return this->m_properties;
|
||||
}
|
||||
|
||||
const std::string& CProject::getWorkshopId () const {
|
||||
return this->m_workshopid;
|
||||
}
|
||||
|
||||
CContainer* CProject::getContainer () {
|
||||
return this->m_container;
|
||||
}
|
||||
|
@ -16,16 +16,17 @@ class CProject {
|
||||
public:
|
||||
static CProject* fromFile (const std::string& filename, CContainer* container);
|
||||
|
||||
CWallpaper* getWallpaper () const;
|
||||
[[nodiscard]] CWallpaper* getWallpaper () const;
|
||||
|
||||
const std::string& getTitle () const;
|
||||
const std::string& getType () const;
|
||||
const std::vector<Projects::CProperty*>& getProperties () const;
|
||||
[[nodiscard]] const std::string& getTitle () const;
|
||||
[[nodiscard]] const std::string& getType () const;
|
||||
[[nodiscard]] const std::vector<Projects::CProperty*>& getProperties () const;
|
||||
[[nodiscard]] const std::string& getWorkshopId () const;
|
||||
|
||||
CContainer* getContainer ();
|
||||
|
||||
protected:
|
||||
CProject (std::string title, std::string type, CContainer* container);
|
||||
CProject (std::string title, std::string type, std::string workshopid, CContainer* container);
|
||||
|
||||
void setWallpaper (CWallpaper* wallpaper);
|
||||
void insertProperty (Projects::CProperty* property);
|
||||
@ -33,6 +34,7 @@ class CProject {
|
||||
private:
|
||||
std::vector<Projects::CProperty*> m_properties;
|
||||
|
||||
std::string m_workshopid;
|
||||
std::string m_title;
|
||||
std::string m_type;
|
||||
CWallpaper* m_wallpaper;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include "CProject.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
using namespace WallpaperEngine::Core::Objects;
|
||||
using namespace WallpaperEngine::Core::UserSettings;
|
||||
|
||||
CImage::CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, int id, std::string name,
|
||||
CImage::CImage (Wallpapers::CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, int id, std::string name,
|
||||
CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles, const glm::vec2& size,
|
||||
std::string alignment, CUserSettingVector3* color, CUserSettingFloat* alpha, float brightness,
|
||||
uint32_t colorBlendMode, const glm::vec2& parallaxDepth, bool fullscreen, bool passthrough,
|
||||
@ -28,7 +28,7 @@ CImage::CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean*
|
||||
m_passthrough (passthrough),
|
||||
m_autosize (autosize) {}
|
||||
|
||||
WallpaperEngine::Core::CObject* CImage::fromJSON (CScene* scene, json data, CContainer* container,
|
||||
WallpaperEngine::Core::CObject* CImage::fromJSON (Wallpapers::CScene* scene, json data, CContainer* container,
|
||||
CUserSettingBoolean* visible, int id, std::string name,
|
||||
CUserSettingVector3* origin, CUserSettingVector3* scale,
|
||||
const glm::vec3& angles) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingFloat.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h"
|
||||
|
||||
namespace WallpaperEngine::Core {
|
||||
namespace WallpaperEngine::Core::Wallpapers {
|
||||
class CScene;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ class CImage : public CObject {
|
||||
friend class CObject;
|
||||
|
||||
public:
|
||||
static CObject* fromJSON (CScene* scene, json data, CContainer* container, CUserSettingBoolean* visible,
|
||||
static CObject* fromJSON (Wallpapers::CScene* scene, json data, CContainer* container, CUserSettingBoolean* visible,
|
||||
int id, std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale,
|
||||
const glm::vec3& angles);
|
||||
|
||||
@ -77,7 +77,7 @@ class CImage : public CObject {
|
||||
[[nodiscard]] bool isAutosize () const;
|
||||
|
||||
protected:
|
||||
CImage (CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, int id, std::string name,
|
||||
CImage (Wallpapers::CScene* scene, Images::CMaterial* material, CUserSettingBoolean* visible, int id, std::string name,
|
||||
CUserSettingVector3* origin, CUserSettingVector3* scale, const glm::vec3& angles, const glm::vec2& size,
|
||||
std::string alignment, CUserSettingVector3* color, CUserSettingFloat* alpha, float brightness,
|
||||
uint32_t colorBlendMode, const glm::vec2& parallaxDepth, bool fullscreen, bool passthrough, bool autosize);
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects;
|
||||
|
||||
CParticle* CParticle::fromFile (CScene* scene, const std::string& filename, CContainer* container,
|
||||
CParticle* CParticle::fromFile (Wallpapers::CScene* scene, const std::string& filename, CContainer* container,
|
||||
CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin,
|
||||
CUserSettingVector3* scale) {
|
||||
json data = json::parse (container->readFileAsString (filename));
|
||||
@ -28,7 +28,7 @@ CParticle* CParticle::fromFile (CScene* scene, const std::string& filename, CCon
|
||||
return particle;
|
||||
}
|
||||
|
||||
CParticle::CParticle (CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, int id,
|
||||
CParticle::CParticle (Wallpapers::CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, int id,
|
||||
std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale) :
|
||||
CObject (scene, visible, id, std::move (name), Type, origin, scale, glm::vec3 ()),
|
||||
m_starttime (starttime),
|
||||
|
@ -17,7 +17,7 @@ class CParticle : public CObject {
|
||||
friend class CObject;
|
||||
|
||||
public:
|
||||
static CParticle* fromFile (CScene* scene, const std::string& filename, CContainer* container,
|
||||
static CParticle* fromFile (Wallpapers::CScene* scene, const std::string& filename, CContainer* container,
|
||||
CUserSettingBoolean* visible, int id, std::string name,
|
||||
CUserSettingVector3* origin, CUserSettingVector3* scale);
|
||||
|
||||
@ -35,7 +35,7 @@ class CParticle : public CObject {
|
||||
[[nodiscard]] const std::vector<Particles::CInitializer*>& getInitializers () const;
|
||||
|
||||
protected:
|
||||
CParticle (CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, int id,
|
||||
CParticle (Wallpapers::CScene* scene, uint32_t starttime, uint32_t maxcount, CUserSettingBoolean* visible, int id,
|
||||
std::string name, CUserSettingVector3* origin, CUserSettingVector3* scale);
|
||||
|
||||
/**
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
using namespace WallpaperEngine::Core::Objects;
|
||||
|
||||
CSound::CSound (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin,
|
||||
CSound::CSound (Wallpapers::CScene* scene, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin,
|
||||
CUserSettingVector3* scale, const glm::vec3& angles, bool repeat) :
|
||||
CObject (scene, visible, id, std::move (name), Type, origin, scale, angles),
|
||||
m_repeat (repeat) {}
|
||||
|
||||
WallpaperEngine::Core::CObject* CSound::fromJSON (CScene* scene, json data, CUserSettingBoolean* visible, int id,
|
||||
WallpaperEngine::Core::CObject* CSound::fromJSON (Wallpapers::CScene* scene, json data, CUserSettingBoolean* visible, int id,
|
||||
const std::string& name, CUserSettingVector3* origin,
|
||||
CUserSettingVector3* scale, const glm::vec3& angles) {
|
||||
bool repeat = false;
|
||||
|
@ -4,6 +4,10 @@
|
||||
#include "WallpaperEngine/Core/Core.h"
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingBoolean.h"
|
||||
|
||||
namespace WallpaperEngine::Core::Wallpapers {
|
||||
class CScene;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Core::Objects {
|
||||
using json = nlohmann::json;
|
||||
using namespace WallpaperEngine::Core::UserSettings;
|
||||
@ -15,7 +19,7 @@ class CSound : public CObject {
|
||||
friend class CObject;
|
||||
|
||||
public:
|
||||
static CObject* fromJSON (CScene* scene, json data, CUserSettingBoolean* visible, int id,
|
||||
static CObject* fromJSON (Wallpapers::CScene* scene, json data, CUserSettingBoolean* visible, int id,
|
||||
const std::string& name, CUserSettingVector3* origin, CUserSettingVector3* scale,
|
||||
const glm::vec3& angles);
|
||||
|
||||
@ -29,7 +33,7 @@ class CSound : public CObject {
|
||||
[[nodiscard]] bool isRepeat () const;
|
||||
|
||||
protected:
|
||||
CSound (CScene* scene, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin,
|
||||
CSound (Wallpapers::CScene* scene, CUserSettingBoolean* visible, int id, std::string name, CUserSettingVector3* origin,
|
||||
CUserSettingVector3* scale, const glm::vec3& angles, bool repeat);
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "WallpaperEngine/Core/UserSettings/CUserSettingVector3.h"
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Core::Wallpapers;
|
||||
|
||||
CScene::CScene (CProject& project, CContainer* container, Scenes::CCamera* camera, glm::vec3 ambientColor,
|
||||
CUserSettingBoolean* bloom, CUserSettingFloat* bloomStrength, CUserSettingFloat* bloomThreshold,
|
||||
|
@ -9,9 +9,11 @@
|
||||
#include "WallpaperEngine/Core/Scenes/CProjection.h"
|
||||
|
||||
namespace WallpaperEngine::Core {
|
||||
using json = nlohmann::json;
|
||||
|
||||
class CObject;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Core::Wallpapers {
|
||||
using json = nlohmann::json;
|
||||
|
||||
class CScene : public CWallpaper {
|
||||
public:
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Core::Wallpapers;
|
||||
|
||||
CVideo::CVideo (std::string filename, CProject& project) :
|
||||
CWallpaper (Type, project),
|
||||
|
@ -10,7 +10,7 @@ extern "C" {
|
||||
#include <libswscale/swscale.h>
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Core {
|
||||
namespace WallpaperEngine::Core::Wallpapers {
|
||||
class CVideo : public CWallpaper {
|
||||
public:
|
||||
explicit CVideo (std::string filename, CProject& project);
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <utility>
|
||||
|
||||
using namespace WallpaperEngine::Core;
|
||||
using namespace WallpaperEngine::Core::Wallpapers;
|
||||
|
||||
const std::string& CWeb::getFilename () {
|
||||
return this->m_filename;
|
||||
|
@ -16,7 +16,7 @@ extern "C"
|
||||
#include <libswscale/swscale.h>
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Core
|
||||
namespace WallpaperEngine::Core::Wallpapers
|
||||
{
|
||||
class CWeb : public CWallpaper
|
||||
{
|
||||
@ -24,7 +24,7 @@ namespace WallpaperEngine::Core
|
||||
explicit CWeb (std::string filename, CProject& project);
|
||||
|
||||
const std::string& getFilename ();
|
||||
|
||||
|
||||
protected:
|
||||
friend class CWallpaper;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render;
|
||||
|
||||
CCamera::CCamera (CScene* scene, const Core::Scenes::CCamera* camera) :
|
||||
CCamera::CCamera (Wallpapers::CScene* scene, const Core::Scenes::CCamera* camera) :
|
||||
m_camera (camera),
|
||||
m_scene (scene),
|
||||
m_isOrthogonal (false),
|
||||
@ -43,7 +43,7 @@ bool CCamera::isOrthogonal () const {
|
||||
return this->m_isOrthogonal;
|
||||
}
|
||||
|
||||
CScene* CCamera::getScene () const {
|
||||
Wallpapers::CScene* CCamera::getScene () const {
|
||||
return this->m_scene;
|
||||
}
|
||||
|
||||
|
@ -7,12 +7,14 @@
|
||||
|
||||
#include "WallpaperEngine/Core/Scenes/CCamera.h"
|
||||
|
||||
namespace WallpaperEngine::Render {
|
||||
namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CScene;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Render {
|
||||
class CCamera {
|
||||
public:
|
||||
CCamera (CScene* scene, const Core::Scenes::CCamera* camera);
|
||||
CCamera (Wallpapers::CScene* scene, const Core::Scenes::CCamera* camera);
|
||||
~CCamera ();
|
||||
|
||||
void setOrthogonalProjection (float width, float height);
|
||||
@ -22,7 +24,7 @@ class CCamera {
|
||||
const glm::vec3& getUp () const;
|
||||
const glm::mat4& getProjection () const;
|
||||
const glm::mat4& getLookAt () const;
|
||||
CScene* getScene () const;
|
||||
Wallpapers::CScene* getScene () const;
|
||||
bool isOrthogonal () const;
|
||||
|
||||
private:
|
||||
@ -30,6 +32,6 @@ class CCamera {
|
||||
glm::mat4 m_projection;
|
||||
glm::mat4 m_lookat;
|
||||
const Core::Scenes::CCamera* m_camera;
|
||||
CScene* m_scene;
|
||||
Wallpapers::CScene* m_scene;
|
||||
};
|
||||
} // namespace WallpaperEngine::Render
|
||||
|
@ -4,14 +4,15 @@
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::Render::Wallpapers;
|
||||
|
||||
CObject::CObject (CScene* scene, std::string type, Core::CObject* object) :
|
||||
CObject::CObject (Wallpapers::CScene* scene, std::string type, Core::CObject* object) :
|
||||
Helpers::CContextAware (scene),
|
||||
m_scene (scene),
|
||||
m_object (object),
|
||||
m_type (std::move (type)) {}
|
||||
|
||||
CScene* CObject::getScene () const {
|
||||
Wallpapers::CScene* CObject::getScene () const {
|
||||
return this->m_scene;
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,11 @@
|
||||
|
||||
#include "WallpaperEngine/Render/Wallpapers/CScene.h"
|
||||
|
||||
namespace WallpaperEngine::Render {
|
||||
namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CScene;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Render {
|
||||
class CObject : public Helpers::CContextAware {
|
||||
public:
|
||||
template <class T> const T* as () const {
|
||||
@ -28,18 +30,18 @@ class CObject : public Helpers::CContextAware {
|
||||
|
||||
virtual void render () = 0;
|
||||
|
||||
[[nodiscard]] CScene* getScene () const;
|
||||
[[nodiscard]] Wallpapers::CScene* getScene () const;
|
||||
[[nodiscard]] CContainer* getContainer () const;
|
||||
[[nodiscard]] int getId () const;
|
||||
|
||||
protected:
|
||||
CObject (CScene* scene, std::string type, Core::CObject* object);
|
||||
CObject (Wallpapers::CScene* scene, std::string type, Core::CObject* object);
|
||||
~CObject () override = default;
|
||||
|
||||
private:
|
||||
std::string m_type;
|
||||
|
||||
CScene* m_scene;
|
||||
Wallpapers::CScene* m_scene;
|
||||
Core::CObject* m_object;
|
||||
};
|
||||
} // namespace WallpaperEngine::Render
|
@ -282,14 +282,14 @@ CFBO* CWallpaper::getFBO () const {
|
||||
}
|
||||
|
||||
CWallpaper* CWallpaper::fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext& context,
|
||||
CAudioContext& audioContext, CWebBrowserContext& browserContext,
|
||||
CAudioContext& audioContext, WebBrowser::CWebBrowserContext& browserContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode) {
|
||||
if (wallpaper->is<Core::CScene> ())
|
||||
return new WallpaperEngine::Render::CScene (wallpaper->as<Core::CScene> (), context, audioContext, scalingMode);
|
||||
if (wallpaper->is<Core::CVideo> ())
|
||||
return new WallpaperEngine::Render::CVideo (wallpaper->as<Core::CVideo> (), context, audioContext, scalingMode);
|
||||
else if (wallpaper->is<Core::CWeb> ())
|
||||
return new WallpaperEngine::Render::CWeb (wallpaper->as<Core::CWeb> (), context, audioContext, browserContext,
|
||||
if (wallpaper->is<Core::Wallpapers::CScene> ())
|
||||
return new WallpaperEngine::Render::Wallpapers::CScene (wallpaper->as<Core::Wallpapers::CScene> (), context, audioContext, scalingMode);
|
||||
if (wallpaper->is<Core::Wallpapers::CVideo> ())
|
||||
return new WallpaperEngine::Render::Wallpapers::CVideo (wallpaper->as<Core::Wallpapers::CVideo> (), context, audioContext, scalingMode);
|
||||
else if (wallpaper->is<Core::Wallpapers::CWeb> ())
|
||||
return new WallpaperEngine::Render::Wallpapers::CWeb (wallpaper->as<Core::Wallpapers::CWeb> (), context, audioContext, browserContext,
|
||||
scalingMode);
|
||||
else
|
||||
sLog.exception ("Unsupported wallpaper type");
|
||||
|
@ -14,13 +14,14 @@
|
||||
#include "WallpaperEngine/Render/CRenderContext.h"
|
||||
#include "WallpaperEngine/Render/Helpers/CContextAware.h"
|
||||
|
||||
#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h"
|
||||
|
||||
#include "CWallpaperState.h"
|
||||
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::Audio;
|
||||
using namespace WallpaperEngine::WebBrowser;
|
||||
|
||||
namespace WallpaperEngine::WebBrowser {
|
||||
class CWebBrowserContext;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Render {
|
||||
namespace Helpers {
|
||||
@ -146,7 +147,7 @@ class CWallpaper : public Helpers::CContextAware {
|
||||
* @return
|
||||
*/
|
||||
static CWallpaper* fromWallpaper (Core::CWallpaper* wallpaper, CRenderContext& context, CAudioContext& audioContext,
|
||||
CWebBrowserContext& browserContext,
|
||||
WebBrowser::CWebBrowserContext& browserContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode);
|
||||
|
||||
protected:
|
||||
|
@ -4,7 +4,7 @@
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render::Objects;
|
||||
|
||||
CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
|
||||
CImage::CImage (Wallpapers::CScene* scene, Core::Objects::CImage* image) :
|
||||
Render::CObject (scene, Type, image),
|
||||
m_image (image),
|
||||
m_animationTime (0.0),
|
||||
|
@ -29,7 +29,7 @@ class CImage final : public CObject {
|
||||
friend CObject;
|
||||
|
||||
public:
|
||||
CImage (CScene* scene, Core::Objects::CImage* image);
|
||||
CImage (Wallpapers::CScene* scene, Core::Objects::CImage* image);
|
||||
|
||||
void setup ();
|
||||
void render () override;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
using namespace WallpaperEngine::Render::Objects;
|
||||
|
||||
CSound::CSound (CScene* scene, Core::Objects::CSound* sound) : CObject (scene, Type, sound), m_sound (sound) {
|
||||
CSound::CSound (Wallpapers::CScene* scene, Core::Objects::CSound* sound) : CObject (scene, Type, sound), m_sound (sound) {
|
||||
if (this->getContext ().getApp ().getContext ().settings.audio.enabled)
|
||||
this->load ();
|
||||
}
|
||||
|
@ -7,10 +7,14 @@
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
|
||||
namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CScene;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Render::Objects {
|
||||
class CSound final : public CObject {
|
||||
public:
|
||||
CSound (CScene* scene, Core::Objects::CSound* sound);
|
||||
CSound (Wallpapers::CScene* scene, Core::Objects::CSound* sound);
|
||||
~CSound () override;
|
||||
|
||||
void render () override;
|
||||
|
@ -15,8 +15,9 @@ extern float g_TimeLast;
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::Render::Wallpapers;
|
||||
|
||||
CScene::CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& audioContext,
|
||||
CScene::CScene (Core::Wallpapers::CScene* scene, CRenderContext& context, CAudioContext& audioContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode) :
|
||||
CWallpaper (scene, Type, context, audioContext, scalingMode),
|
||||
m_mousePosition (),
|
||||
@ -241,8 +242,8 @@ void CScene::updateMouse (glm::ivec4 viewport) {
|
||||
// screen-space positions have to be transposed to what the screen will actually show
|
||||
}
|
||||
|
||||
Core::CScene* CScene::getScene () const {
|
||||
return this->getWallpaperData ()->as<Core::CScene> ();
|
||||
Core::Wallpapers::CScene* CScene::getScene () const {
|
||||
return this->getWallpaperData ()->as<Core::Wallpapers::CScene> ();
|
||||
}
|
||||
|
||||
int CScene::getWidth () const {
|
||||
|
@ -9,15 +9,17 @@
|
||||
namespace WallpaperEngine::Render {
|
||||
class CCamera;
|
||||
class CObject;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CScene final : public CWallpaper {
|
||||
public:
|
||||
CScene (Core::CScene* scene, CRenderContext& context, CAudioContext& audioContext,
|
||||
CScene (Core::Wallpapers::CScene* scene, CRenderContext& context, CAudioContext& audioContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode);
|
||||
|
||||
CCamera* getCamera () const;
|
||||
|
||||
Core::CScene* getScene () const;
|
||||
Core::Wallpapers::CScene* getScene () const;
|
||||
|
||||
int getWidth () const override;
|
||||
int getHeight () const override;
|
||||
@ -48,4 +50,4 @@ class CScene final : public CWallpaper {
|
||||
CFBO* _rt_8FrameBuffer;
|
||||
CFBO* _rt_Bloom;
|
||||
};
|
||||
} // namespace WallpaperEngine::Render
|
||||
} // namespace WallpaperEngine::Render::Wallpaper
|
||||
|
@ -5,12 +5,13 @@
|
||||
|
||||
using namespace WallpaperEngine;
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::Render::Wallpapers;
|
||||
|
||||
void* get_proc_address (void* ctx, const char* name) {
|
||||
return static_cast<CVideo*> (ctx)->getContext ().getDriver ().getProcAddress (name);
|
||||
}
|
||||
|
||||
CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext,
|
||||
CVideo::CVideo (Core::Wallpapers::CVideo* video, CRenderContext& context, CAudioContext& audioContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode) :
|
||||
CWallpaper (video, Type, context, audioContext, scalingMode),
|
||||
m_width (16),
|
||||
@ -118,8 +119,8 @@ void CVideo::renderFrame (glm::ivec4 viewport) {
|
||||
mpv_render_context_render (this->m_mpvGl, params);
|
||||
}
|
||||
|
||||
Core::CVideo* CVideo::getVideo () {
|
||||
return this->getWallpaperData ()->as<Core::CVideo> ();
|
||||
Core::Wallpapers::CVideo* CVideo::getVideo () {
|
||||
return this->getWallpaperData ()->as<Core::Wallpapers::CVideo> ();
|
||||
}
|
||||
|
||||
void CVideo::setPause (bool newState) {
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include <mpv/client.h>
|
||||
#include <mpv/render_gl.h>
|
||||
|
||||
namespace WallpaperEngine::Render {
|
||||
namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CVideo final : public CWallpaper {
|
||||
public:
|
||||
CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext,
|
||||
CVideo (Core::Wallpapers::CVideo* video, CRenderContext& context, CAudioContext& audioContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode);
|
||||
|
||||
Core::CVideo* getVideo ();
|
||||
Core::Wallpapers::CVideo* getVideo ();
|
||||
|
||||
[[nodiscard]] int getWidth () const override;
|
||||
[[nodiscard]] int getHeight () const override;
|
||||
@ -36,4 +36,4 @@ class CVideo final : public CWallpaper {
|
||||
int64_t m_width;
|
||||
int64_t m_height;
|
||||
};
|
||||
} // namespace WallpaperEngine::Render
|
||||
} // namespace WallpaperEngine::Render::Wallpapers
|
||||
|
@ -2,11 +2,15 @@
|
||||
// https://github.com/if1live/cef-gl-example
|
||||
// https://github.com/andmcgregor/cefgui
|
||||
#include "CWeb.h"
|
||||
#include "WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h"
|
||||
|
||||
using namespace WallpaperEngine::Render;
|
||||
using namespace WallpaperEngine::WebBrowser;
|
||||
using namespace WallpaperEngine::Render::Wallpapers;
|
||||
|
||||
CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContext, CWebBrowserContext& browserContext,
|
||||
using namespace WallpaperEngine::WebBrowser;
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
CWeb::CWeb (Core::Wallpapers::CWeb* web, CRenderContext& context, CAudioContext& audioContext, CWebBrowserContext& browserContext,
|
||||
const CWallpaperState::TextureUVsScaling& scalingMode) :
|
||||
CWallpaper (web, Type, context, audioContext, scalingMode),
|
||||
m_width (16),
|
||||
@ -18,26 +22,26 @@ CWeb::CWeb (Core::CWeb* web, CRenderContext& context, CAudioContext& audioContex
|
||||
m_mousePosition(),
|
||||
m_mousePositionLast(),
|
||||
m_client () {
|
||||
this->m_browserContext.markAsUsed ();
|
||||
// setup framebuffers
|
||||
this->setupFramebuffers ();
|
||||
|
||||
CefWindowInfo window_info;
|
||||
window_info.SetAsWindowless (0);
|
||||
|
||||
this->m_render_handler = new RenderHandler (this);
|
||||
this->m_renderHandler = new WebBrowser::CEF::CRenderHandler (this);
|
||||
|
||||
CefBrowserSettings browserSettings;
|
||||
// Documentaion says that 60 fps is maximum value
|
||||
browserSettings.windowless_frame_rate = std::max (60, context.getApp ().getContext ().settings.render.maximumFPS);
|
||||
|
||||
m_client = new BrowserClient (m_render_handler);
|
||||
std::filesystem::path htmlpath =
|
||||
this->getWeb ()->getProject ().getContainer ()->resolveRealFile (this->getWeb ()->getFilename ());
|
||||
// To open local file in browser URL must be "file:///path/to/file.html"
|
||||
const std::string htmlURL = std::string ("file:///") + htmlpath.c_str ();
|
||||
m_browser =
|
||||
CefBrowserHost::CreateBrowserSync (window_info, m_client.get (), htmlURL, browserSettings, nullptr, nullptr);
|
||||
this->m_client = new WebBrowser::CEF::CBrowserClient (m_renderHandler);
|
||||
// use the custom scheme for the wallpaper's files
|
||||
const std::string htmlURL =
|
||||
CWPSchemeHandlerFactory::generateSchemeName(this->getWeb ()->getProject ().getWorkshopId ()) +
|
||||
"://" +
|
||||
this->getWeb()->getFilename ();
|
||||
this->m_browser =
|
||||
CefBrowserHost::CreateBrowserSync (window_info, this->m_client, htmlURL, browserSettings, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void CWeb::setSize (int width, int height) {
|
||||
@ -54,7 +58,7 @@ void CWeb::setSize (int width, int height) {
|
||||
nullptr);
|
||||
|
||||
// Notify cef that it was resized(maybe it's not even needed)
|
||||
m_browser->GetHost ()->WasResized ();
|
||||
this->m_browser->GetHost ()->WasResized ();
|
||||
}
|
||||
|
||||
void CWeb::renderFrame (glm::ivec4 viewport) {
|
||||
@ -94,15 +98,15 @@ void CWeb::updateMouse (glm::ivec4 viewport) {
|
||||
evt.x = std::clamp (int (position.x - viewport.x), 0, viewport.z);
|
||||
evt.y = std::clamp (int (position.y - viewport.y), 0, viewport.w);
|
||||
// Send mouse position to cef
|
||||
m_browser->GetHost ()->SendMouseMoveEvent (evt, false);
|
||||
this->m_browser->GetHost ()->SendMouseMoveEvent (evt, false);
|
||||
|
||||
// TODO: ANY OTHER MOUSE EVENTS TO SEND?
|
||||
if (leftClick != this->m_leftClick) {
|
||||
m_browser->GetHost ()->SendMouseClickEvent (evt, CefBrowserHost::MouseButtonType::MBT_LEFT, leftClick == WallpaperEngine::Input::MouseClickStatus::Released, 1);
|
||||
this->m_browser->GetHost ()->SendMouseClickEvent (evt, CefBrowserHost::MouseButtonType::MBT_LEFT, leftClick == WallpaperEngine::Input::MouseClickStatus::Released, 1);
|
||||
}
|
||||
|
||||
if (rightClick != this->m_rightClick) {
|
||||
m_browser->GetHost ()->SendMouseClickEvent (evt, CefBrowserHost::MouseButtonType::MBT_RIGHT, rightClick == WallpaperEngine::Input::MouseClickStatus::Released, 1);
|
||||
this->m_browser->GetHost ()->SendMouseClickEvent (evt, CefBrowserHost::MouseButtonType::MBT_RIGHT, rightClick == WallpaperEngine::Input::MouseClickStatus::Released, 1);
|
||||
}
|
||||
|
||||
this->m_leftClick = leftClick;
|
||||
@ -111,24 +115,9 @@ void CWeb::updateMouse (glm::ivec4 viewport) {
|
||||
|
||||
CWeb::~CWeb () {
|
||||
CefDoMessageLoopWork ();
|
||||
m_browser->GetHost ()->CloseBrowser (true);
|
||||
}
|
||||
this->m_browser->GetHost ()->CloseBrowser (true);
|
||||
|
||||
CWeb::RenderHandler::RenderHandler (CWeb* webdata) : m_webdata (webdata) {}
|
||||
|
||||
// Required by CEF
|
||||
void CWeb::RenderHandler::GetViewRect (CefRefPtr<CefBrowser> browser, CefRect& rect) {
|
||||
rect = CefRect (0, 0, this->m_webdata->getWidth (), this->m_webdata->getHeight ());
|
||||
}
|
||||
|
||||
// Will be executed in CEF message loop
|
||||
void CWeb::RenderHandler::OnPaint (CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects,
|
||||
const void* buffer, int width, int height) {
|
||||
// sLog.debug("BrowserView::RenderHandler::OnPaint");
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glBindTexture (GL_TEXTURE_2D, this->texture ());
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (unsigned char*) buffer);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
delete this->m_renderHandler;
|
||||
}
|
||||
|
||||
const std::string CWeb::Type = "web";
|
@ -13,14 +13,19 @@
|
||||
#include "WallpaperEngine/Audio/CAudioStream.h"
|
||||
#include "WallpaperEngine/Core/Wallpapers/CWeb.h"
|
||||
#include "WallpaperEngine/Render/CWallpaper.h"
|
||||
#include "WallpaperEngine/WebBrowser/CEF/CBrowserClient.h"
|
||||
#include "WallpaperEngine/WebBrowser/CEF/CRenderHandler.h"
|
||||
#include "common.h"
|
||||
|
||||
namespace WallpaperEngine::Render
|
||||
{
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
class CRenderHandler;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CWeb : public CWallpaper
|
||||
{
|
||||
public:
|
||||
CWeb (Core::CWeb* scene, CRenderContext& context, CAudioContext& audioContext, WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode);
|
||||
CWeb (Core::Wallpapers::CWeb* scene, CRenderContext& context, CAudioContext& audioContext, WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext, const CWallpaperState::TextureUVsScaling& scalingMode);
|
||||
~CWeb() override;
|
||||
[[nodiscard]] int getWidth () const override { return this->m_width; }
|
||||
|
||||
@ -31,9 +36,9 @@ namespace WallpaperEngine::Render
|
||||
protected:
|
||||
void renderFrame (glm::ivec4 viewport) override;
|
||||
void updateMouse (glm::ivec4 viewport);
|
||||
Core::CWeb* getWeb ()
|
||||
Core::Wallpapers::CWeb* getWeb ()
|
||||
{
|
||||
return this->getWallpaperData ()->as<Core::CWeb> ();
|
||||
return this->getWallpaperData ()->as<Core::Wallpapers::CWeb> ();
|
||||
}
|
||||
|
||||
friend class CWallpaper;
|
||||
@ -41,70 +46,11 @@ namespace WallpaperEngine::Render
|
||||
static const std::string Type;
|
||||
|
||||
private:
|
||||
// *************************************************************************
|
||||
//! \brief Private implementation to handle CEF events to draw the web page.
|
||||
// *************************************************************************
|
||||
class RenderHandler: public CefRenderHandler
|
||||
{
|
||||
public:
|
||||
explicit RenderHandler(CWeb* webdata);
|
||||
|
||||
//! \brief
|
||||
~RenderHandler() override = default;
|
||||
|
||||
//! \brief CefRenderHandler interface
|
||||
void GetViewRect(CefRefPtr<CefBrowser> browser, CefRect &rect) override;
|
||||
|
||||
//! \brief CefRenderHandler interface
|
||||
//! Update the OpenGL texture.
|
||||
void OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type,
|
||||
const RectList &dirtyRects, const void *buffer,
|
||||
int width, int height) override;
|
||||
|
||||
//! \brief CefBase interface
|
||||
IMPLEMENT_REFCOUNTING(RenderHandler);
|
||||
|
||||
private:
|
||||
CWeb* m_webdata;
|
||||
|
||||
int getWidth () const {
|
||||
return this->m_webdata->getWidth();
|
||||
};
|
||||
int getHeight () const {
|
||||
return this->m_webdata->getHeight();
|
||||
};
|
||||
//! \brief Return the OpenGL texture handle
|
||||
GLuint texture() const
|
||||
{
|
||||
return this->m_webdata->getWallpaperFramebuffer();
|
||||
}
|
||||
};
|
||||
|
||||
// *************************************************************************
|
||||
//! \brief Provide access to browser-instance-specific callbacks. A single
|
||||
//! CefClient instance can be shared among any number of browsers.
|
||||
// *************************************************************************
|
||||
class BrowserClient: public CefClient
|
||||
{
|
||||
public:
|
||||
explicit BrowserClient(CefRefPtr<CefRenderHandler> ptr)
|
||||
: m_renderHandler(std::move(ptr))
|
||||
{}
|
||||
|
||||
CefRefPtr<CefRenderHandler> GetRenderHandler() override
|
||||
{
|
||||
return m_renderHandler;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderHandler> m_renderHandler;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(BrowserClient);
|
||||
};
|
||||
|
||||
WallpaperEngine::WebBrowser::CWebBrowserContext& m_browserContext;
|
||||
CefRefPtr<CefBrowser> m_browser;
|
||||
CefRefPtr<BrowserClient> m_client;
|
||||
RenderHandler* m_render_handler = nullptr;
|
||||
CefRefPtr<WallpaperEngine::WebBrowser::CEF::CBrowserClient> m_client;
|
||||
WallpaperEngine::WebBrowser::CEF::CRenderHandler* m_renderHandler = nullptr;
|
||||
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
64
src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.cpp
Normal file
64
src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "CBrowserApp.h"
|
||||
#include "WallpaperEngine/Logging/CLog.h"
|
||||
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
CBrowserApp::CBrowserApp (WallpaperEngine::Application::CWallpaperApplication& application) :
|
||||
CSubprocessApp (application) {
|
||||
}
|
||||
|
||||
CefRefPtr<CefBrowserProcessHandler> CBrowserApp::GetBrowserProcessHandler () {
|
||||
return this;
|
||||
}
|
||||
|
||||
void CBrowserApp::OnContextInitialized () {
|
||||
// register all the needed schemes, "wp" + the background id is going to be our scheme
|
||||
for (const auto& [workshopId, factory] : this->getHandlerFactories ()) {
|
||||
CefRegisterSchemeHandlerFactory (
|
||||
CWPSchemeHandlerFactory::generateSchemeName (workshopId),
|
||||
(const char*) nullptr,
|
||||
factory
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void CBrowserApp::OnBeforeCommandLineProcessing (const CefString& process_type, CefRefPtr<CefCommandLine> command_line) {
|
||||
// TODO: ACTIVATE THIS IF WE EVER SUPPORT MACOS OFFICIALLY
|
||||
/*
|
||||
if (process_type.empty()) {
|
||||
#if defined(OS_MACOSX)
|
||||
// Disable the macOS keychain prompt. Cookies will not be encrypted.
|
||||
command_line->AppendSwitch("use-mock-keychain");
|
||||
#endif
|
||||
}*/
|
||||
// TODO: ADD FLAGS
|
||||
/*"--disable-features",
|
||||
"IsolateOrigins,HardwareMediaKeyHandling,WebContentsOcclusion,RendererCodeIntegrityEnabled,site-per-process",
|
||||
"--disable-gpu-shader-disk-cache",
|
||||
"--disable-site-isolation-trials",
|
||||
"--disable-web-security",
|
||||
"--remote-allow-origins",
|
||||
"*",
|
||||
//"--force-device-scale-factor",
|
||||
//"1", // this can also be 2
|
||||
//"--high-dpi-support",
|
||||
//"1",
|
||||
"--autoplay-policy",
|
||||
"no-user-gesture-required",
|
||||
"--disable-background-timer-throttling",
|
||||
"--disable-backgrounding-occluded-windows",
|
||||
"--disable-background-media-suspend",
|
||||
"--disable-renderer-backgrounding",
|
||||
"--disable-test-root-certs",
|
||||
"--disable-bundled-ppapi-flash",
|
||||
"--disable-breakpad",
|
||||
"--disable-field-trial-config",
|
||||
"--no-experiments"*/
|
||||
}
|
||||
|
||||
void CBrowserApp::OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) {
|
||||
// add back any parameters we had before so the new process can load up everything needed
|
||||
for (int i = 1; i < this->getApplication ().getContext ().getArgc (); i ++) {
|
||||
command_line->AppendArgument (this->getApplication ().getContext ().getArgv () [i]);
|
||||
}
|
||||
}
|
30
src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.h
Normal file
30
src/WallpaperEngine/WebBrowser/CEF/CBrowserApp.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "CSubprocessApp.h"
|
||||
#include "CWPSchemeHandlerFactory.h"
|
||||
#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h"
|
||||
#include "include/cef_app.h"
|
||||
|
||||
namespace WallpaperEngine::Application {
|
||||
class CWallpaperApplication;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
/**
|
||||
* Provides custom protocol to contain everything under it
|
||||
*/
|
||||
class CBrowserApp : public CSubprocessApp, public CefBrowserProcessHandler {
|
||||
public:
|
||||
explicit CBrowserApp (WallpaperEngine::Application::CWallpaperApplication& application);
|
||||
|
||||
[[nodiscard]] CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler () override;
|
||||
|
||||
void OnContextInitialized () override;
|
||||
void OnBeforeCommandLineProcessing (const CefString& process_type, CefRefPtr<CefCommandLine> command_line) override;
|
||||
void OnBeforeChildProcessLaunch(CefRefPtr<CefCommandLine> command_line) override;
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING (CBrowserApp);
|
||||
DISALLOW_COPY_AND_ASSIGN (CBrowserApp);
|
||||
};
|
||||
} // namespace WallpaperEngine::WebBrowser::CEF
|
12
src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.cpp
Normal file
12
src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "CBrowserClient.h"
|
||||
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
CBrowserClient::CBrowserClient(CefRefPtr<CefRenderHandler> ptr)
|
||||
: m_renderHandler(std::move(ptr))
|
||||
{}
|
||||
|
||||
CefRefPtr<CefRenderHandler> CBrowserClient::GetRenderHandler()
|
||||
{
|
||||
return m_renderHandler;
|
||||
}
|
21
src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.h
Normal file
21
src/WallpaperEngine/WebBrowser/CEF/CBrowserClient.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_client.h"
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
// *************************************************************************
|
||||
//! \brief Provide access to browser-instance-specific callbacks. A single
|
||||
//! CefClient instance can be shared among any number of browsers.
|
||||
// *************************************************************************
|
||||
class CBrowserClient: public CefClient
|
||||
{
|
||||
public:
|
||||
explicit CBrowserClient(CefRefPtr<CefRenderHandler> ptr);
|
||||
|
||||
[[nodiscard]] CefRefPtr<CefRenderHandler> GetRenderHandler() override;
|
||||
|
||||
CefRefPtr<CefRenderHandler> m_renderHandler;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CBrowserClient);
|
||||
};
|
||||
} // namespace WallpaperEngine::WebBrowser::CEF
|
31
src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp
Normal file
31
src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "CRenderHandler.h"
|
||||
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
CRenderHandler::CRenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata) : m_webdata (webdata) {}
|
||||
|
||||
// Required by CEF
|
||||
void CRenderHandler::GetViewRect (CefRefPtr<CefBrowser> browser, CefRect& rect) {
|
||||
rect = CefRect (0, 0, this->m_webdata->getWidth (), this->m_webdata->getHeight ());
|
||||
}
|
||||
|
||||
// Will be executed in CEF message loop
|
||||
void CRenderHandler::OnPaint (CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects,
|
||||
const void* buffer, int width, int height) {
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glBindTexture (GL_TEXTURE_2D, this->texture ());
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (unsigned char*) buffer);
|
||||
glBindTexture (GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
int CRenderHandler::getWidth() const {
|
||||
return this->m_webdata->getWidth ();
|
||||
}
|
||||
|
||||
int CRenderHandler::getHeight() const {
|
||||
return this->m_webdata->getHeight ();
|
||||
}
|
||||
|
||||
GLuint CRenderHandler::texture () const {
|
||||
return this->m_webdata->getWallpaperFramebuffer();
|
||||
}
|
42
src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h
Normal file
42
src/WallpaperEngine/WebBrowser/CEF/CRenderHandler.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "WallpaperEngine/Render/Wallpapers/CWeb.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "common.h"
|
||||
|
||||
namespace WallpaperEngine::Render::Wallpapers {
|
||||
class CWeb;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
// *************************************************************************
|
||||
//! \brief Private implementation to handle CEF events to draw the web page.
|
||||
// *************************************************************************
|
||||
class CRenderHandler : public CefRenderHandler {
|
||||
public:
|
||||
explicit CRenderHandler (WallpaperEngine::Render::Wallpapers::CWeb* webdata);
|
||||
|
||||
//! \brief
|
||||
~CRenderHandler () override = default;
|
||||
|
||||
//! \brief CefRenderHandler interface
|
||||
void GetViewRect (CefRefPtr<CefBrowser> browser, CefRect& rect) override;
|
||||
|
||||
//! \brief CefRenderHandler interface
|
||||
//! Update the OpenGL texture.
|
||||
void OnPaint (CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects, const void* buffer,
|
||||
int width, int height) override;
|
||||
|
||||
//! \brief CefBase interface
|
||||
IMPLEMENT_REFCOUNTING (CRenderHandler);
|
||||
|
||||
private:
|
||||
WallpaperEngine::Render::Wallpapers::CWeb* m_webdata;
|
||||
|
||||
[[nodiscard]] int getWidth () const;
|
||||
[[nodiscard]] int getHeight () const;
|
||||
|
||||
//! \brief Return the OpenGL texture handle
|
||||
[[nodiscard]] GLuint texture () const;
|
||||
};
|
||||
} // namespace WallpaperEngine::WebBrowser::CEF
|
30
src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.cpp
Normal file
30
src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "CSubprocessApp.h"
|
||||
#include "CWPSchemeHandlerFactory.h"
|
||||
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
CSubprocessApp::CSubprocessApp (WallpaperEngine::Application::CWallpaperApplication& application) :
|
||||
m_application (application),
|
||||
m_handlerFactories () {
|
||||
for (const auto& [_, info] : this->m_application.getBackgrounds()) {
|
||||
this->m_handlerFactories [info->getWorkshopId ()] = new CWPSchemeHandlerFactory (info);
|
||||
}
|
||||
}
|
||||
|
||||
void CSubprocessApp::OnRegisterCustomSchemes (CefRawPtr <CefSchemeRegistrar> registrar) {
|
||||
// register all the needed schemes, "wp" + the background id is going to be our scheme
|
||||
for (const auto& [workshopId, _] : this->m_handlerFactories) {
|
||||
registrar->AddCustomScheme (
|
||||
CWPSchemeHandlerFactory::generateSchemeName (workshopId),
|
||||
CEF_SCHEME_OPTION_LOCAL | CEF_SCHEME_OPTION_SECURE | CEF_SCHEME_OPTION_FETCH_ENABLED
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const WallpaperEngine::Application::CWallpaperApplication& CSubprocessApp::getApplication () const {
|
||||
return this->m_application;
|
||||
}
|
||||
|
||||
const std::map<std::string, CWPSchemeHandlerFactory*>& CSubprocessApp::getHandlerFactories () const {
|
||||
return this->m_handlerFactories;
|
||||
}
|
28
src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h
Normal file
28
src/WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "CWPSchemeHandlerFactory.h"
|
||||
#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h"
|
||||
#include "include/cef_app.h"
|
||||
|
||||
namespace WallpaperEngine::Application {
|
||||
class CWallpaperApplication;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
class CSubprocessApp : public CefApp {
|
||||
public:
|
||||
explicit CSubprocessApp (WallpaperEngine::Application::CWallpaperApplication& application);
|
||||
|
||||
void OnRegisterCustomSchemes (CefRawPtr <CefSchemeRegistrar> registrar) override;
|
||||
|
||||
protected:
|
||||
const WallpaperEngine::Application::CWallpaperApplication& getApplication () const;
|
||||
const std::map<std::string, CWPSchemeHandlerFactory*>& getHandlerFactories () const;
|
||||
|
||||
private:
|
||||
std::map<std::string, CWPSchemeHandlerFactory*> m_handlerFactories;
|
||||
WallpaperEngine::Application::CWallpaperApplication& m_application;
|
||||
IMPLEMENT_REFCOUNTING (CSubprocessApp);
|
||||
DISALLOW_COPY_AND_ASSIGN (CSubprocessApp);
|
||||
};
|
||||
}
|
95
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.cpp
Normal file
95
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include "CWPSchemeHandler.h"
|
||||
#include "WallpaperEngine/Assets/CAssetLoadException.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "MimeTypes.h"
|
||||
#include "include/cef_parser.h"
|
||||
|
||||
using namespace WallpaperEngine::Assets;
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
CWPSchemeHandler::CWPSchemeHandler(const Core::CProject* project) :
|
||||
m_project (project),
|
||||
m_contents (nullptr),
|
||||
m_filesize (0),
|
||||
m_mimeType (),
|
||||
m_offset (0) {
|
||||
this->m_container = this->m_project->getWallpaper ()->getProject ().getContainer ();
|
||||
}
|
||||
|
||||
bool CWPSchemeHandler::ProcessRequest(CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefCallback> callback) {
|
||||
CEF_REQUIRE_IO_THREAD();
|
||||
|
||||
// free previous file so we can properly build the right chain of responses
|
||||
delete this->m_contents;
|
||||
|
||||
std::cout << "ProcessRequest for " << request->GetURL ().c_str () << std::endl;
|
||||
// url contains the full path, we need to get rid of the protocol
|
||||
// otherwise files won't be found
|
||||
CefURLParts parts;
|
||||
|
||||
// url parsing is a must
|
||||
if (!CefParseURL (request->GetURL (), parts)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string path = CefString(&parts.path);
|
||||
|
||||
// remove leading slashes from the path
|
||||
path = path.substr (2);
|
||||
|
||||
try {
|
||||
// try to read the file on the current container, if the file doesn't exists
|
||||
// an exception will be thrown
|
||||
this->m_mimeType = MimeTypes::getType (path.c_str ());
|
||||
this->m_contents = this->m_container->readFile (path, &this->m_filesize);
|
||||
callback->Continue ();
|
||||
} catch (CAssetLoadException&) {
|
||||
// not found in this container, next try
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CWPSchemeHandler::GetResponseHeaders(CefRefPtr<CefResponse> response,
|
||||
int64_t& response_length,
|
||||
CefString& redirectUrl) {
|
||||
CEF_REQUIRE_IO_THREAD();
|
||||
|
||||
if (!this->m_contents) {
|
||||
response->SetStatus (404);
|
||||
return;
|
||||
}
|
||||
|
||||
response->SetMimeType (this->m_mimeType);
|
||||
response->SetStatus (200);
|
||||
|
||||
response_length = this->m_filesize;
|
||||
}
|
||||
|
||||
void CWPSchemeHandler::Cancel () {
|
||||
CEF_REQUIRE_IO_THREAD();
|
||||
}
|
||||
|
||||
bool CWPSchemeHandler::ReadResponse(void* data_out,
|
||||
int bytes_to_read,
|
||||
int& bytes_read,
|
||||
CefRefPtr<CefCallback> callback) {
|
||||
CEF_REQUIRE_IO_THREAD();
|
||||
|
||||
bytes_read = 0;
|
||||
|
||||
if (this->m_offset < this->m_filesize) {
|
||||
int bytes_to_transfer = std::min (bytes_to_read, static_cast <int> (this->m_filesize - this->m_offset));
|
||||
|
||||
memcpy (data_out, &this->m_contents [this->m_offset], bytes_to_transfer);
|
||||
|
||||
bytes_read = bytes_to_transfer;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
48
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.h
Normal file
48
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandler.h
Normal file
@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "WallpaperEngine/Core/CProject.h"
|
||||
#include "include/cef_resource_handler.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
|
||||
namespace WallpaperEngine::Assets {
|
||||
class CContainer;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
/**
|
||||
* wp{id}:// actual handler called by cef to access files
|
||||
*/
|
||||
class CWPSchemeHandler : public CefResourceHandler {
|
||||
public:
|
||||
explicit CWPSchemeHandler(const Core::CProject* project);
|
||||
|
||||
bool ProcessRequest(CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefCallback> callback) override;
|
||||
|
||||
void GetResponseHeaders(CefRefPtr<CefResponse> response,
|
||||
int64_t& response_length,
|
||||
CefString& redirectUrl) override;
|
||||
|
||||
void Cancel() override;
|
||||
|
||||
bool ReadResponse(void* data_out,
|
||||
int bytes_to_read,
|
||||
int& bytes_read,
|
||||
CefRefPtr<CefCallback> callback) override;
|
||||
|
||||
private:
|
||||
const Core::CProject* m_project;
|
||||
|
||||
const Assets::CContainer* m_container;
|
||||
const uint8_t* m_contents;
|
||||
uint32_t m_filesize;
|
||||
std::string m_mimeType;
|
||||
uint32_t m_offset;
|
||||
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CWPSchemeHandler);
|
||||
DISALLOW_COPY_AND_ASSIGN(CWPSchemeHandler);
|
||||
};
|
||||
};
|
@ -0,0 +1,19 @@
|
||||
#include "CWPSchemeHandlerFactory.h"
|
||||
#include "CWPSchemeHandler.h"
|
||||
#include "WallpaperEngine/WebBrowser/CWebBrowserContext.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
|
||||
using namespace WallpaperEngine::WebBrowser::CEF;
|
||||
|
||||
CWPSchemeHandlerFactory::CWPSchemeHandlerFactory (const Core::CProject* project) : m_project (project) {}
|
||||
|
||||
CefRefPtr<CefResourceHandler> CWPSchemeHandlerFactory::Create (
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const CefString& scheme_name, CefRefPtr<CefRequest> request) {
|
||||
CEF_REQUIRE_IO_THREAD ();
|
||||
return new CWPSchemeHandler(this->m_project);
|
||||
}
|
||||
|
||||
std::string CWPSchemeHandlerFactory::generateSchemeName (const std::string& workshopId) {
|
||||
return std::string(WPENGINE_SCHEME) + workshopId;
|
||||
}
|
26
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h
Normal file
26
src/WallpaperEngine/WebBrowser/CEF/CWPSchemeHandlerFactory.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "WallpaperEngine/Core/CProject.h"
|
||||
#include "include/cef_scheme.h"
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
/**
|
||||
* Simple factory that creates a scheme handler for wp when requested by Cef
|
||||
*/
|
||||
class CWPSchemeHandlerFactory : public CefSchemeHandlerFactory {
|
||||
public:
|
||||
explicit CWPSchemeHandlerFactory (const Core::CProject* project);
|
||||
|
||||
CefRefPtr<CefResourceHandler> Create (
|
||||
CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
const CefString& scheme_name, CefRefPtr<CefRequest> request) override;
|
||||
|
||||
static std::string generateSchemeName (const std::string& workshopId);
|
||||
private:
|
||||
const Core::CProject* m_project;
|
||||
|
||||
IMPLEMENT_REFCOUNTING (CWPSchemeHandlerFactory);
|
||||
DISALLOW_COPY_AND_ASSIGN (CWPSchemeHandlerFactory);
|
||||
};
|
||||
} // namespace WallpaperEngine::WebBrowser::CEF
|
@ -1,31 +1,76 @@
|
||||
#include "CWebBrowserContext.h"
|
||||
#include "CEF/CBrowserApp.h"
|
||||
#include "WallpaperEngine/Logging/CLog.h"
|
||||
#include "WallpaperEngine/WebBrowser/CEF/CSubprocessApp.h"
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/cef_render_handler.h"
|
||||
#include <filesystem>
|
||||
#include <random>
|
||||
|
||||
using namespace WallpaperEngine::WebBrowser;
|
||||
|
||||
CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (false) {
|
||||
// clone original argc/argv as they'll be modified by cef
|
||||
char** argv2 = new char*[argc];
|
||||
// TODO: THIS IS USED TO GENERATE A RANDOM FOLDER FOR THE CHROME PROFILE, MAYBE A DIFFERENT APPROACH WOULD BE BETTER?
|
||||
namespace uuid {
|
||||
static std::random_device rd;
|
||||
static std::mt19937 gen(rd());
|
||||
static std::uniform_int_distribution<> dis(0, 15);
|
||||
static std::uniform_int_distribution<> dis2(8, 11);
|
||||
|
||||
for (int i = 0; i < argc; i++) {
|
||||
argv2 [i] = new char [strlen (argv [i]) + 1];
|
||||
strcpy (argv2 [i], argv [i]);
|
||||
std::string generate_uuid_v4() {
|
||||
std::stringstream ss;
|
||||
int i;
|
||||
ss << std::hex;
|
||||
for (i = 0; i < 8; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-";
|
||||
for (i = 0; i < 4; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-4";
|
||||
for (i = 0; i < 3; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-";
|
||||
ss << dis2(gen);
|
||||
for (i = 0; i < 3; i++) {
|
||||
ss << dis(gen);
|
||||
}
|
||||
ss << "-";
|
||||
for (i = 0; i < 12; i++) {
|
||||
ss << dis(gen);
|
||||
};
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
|
||||
CWebBrowserContext::CWebBrowserContext (WallpaperEngine::Application::CWallpaperApplication& wallpaperApplication) :
|
||||
m_wallpaperApplication (wallpaperApplication),
|
||||
m_browserApplication (nullptr) {
|
||||
CefMainArgs main_args (this->m_wallpaperApplication.getContext ().getArgc (), this->m_wallpaperApplication.getContext ().getArgv ());
|
||||
|
||||
// only care about app if the process is the main process
|
||||
// we should maybe use a better lib for handling command line arguments instead
|
||||
// or using C's version on some places and CefCommandLine on others
|
||||
// TODO: ANOTHER THING TO TAKE CARE OF BEFORE MERGING
|
||||
CefRefPtr<CefCommandLine> commandLine = CefCommandLine::CreateCommandLine();
|
||||
|
||||
commandLine->InitFromArgv (main_args.argc, main_args.argv);
|
||||
|
||||
if (!commandLine->HasSwitch("type")) {
|
||||
this->m_browserApplication = new CEF::CBrowserApp(wallpaperApplication);
|
||||
} else {
|
||||
this->m_browserApplication = new CEF::CSubprocessApp(wallpaperApplication);
|
||||
}
|
||||
|
||||
CefMainArgs args (argc, argv2);
|
||||
|
||||
// this blocks for anything not-main-thread
|
||||
int exit_code = CefExecuteProcess (
|
||||
args, nullptr, nullptr); // Spawned processes will terminate here(see CefIninitilize below). Maybe implementing
|
||||
// settings.browser_subprocess_path will allow it to work not in main function.
|
||||
main_args, this->m_browserApplication, nullptr);
|
||||
|
||||
// this is needed to kill subprocesses after they're done
|
||||
if (exit_code >= 0) {
|
||||
// Sub proccess has endend, so exit
|
||||
exit (exit_code);
|
||||
} else if (exit_code == -1) {
|
||||
// If called for the browser process (identified by no "type" command-line value)
|
||||
// it will return immediately with a value of -1
|
||||
}
|
||||
|
||||
// Configurate Chromium
|
||||
@ -35,13 +80,14 @@ CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (fals
|
||||
// CefString(&settings.framework_dir_path) = "OffScreenCEF/godot/";
|
||||
// CefString(&settings.cache_path) = "OffScreenCEF/godot/";
|
||||
// CefString(&settings.browser_subprocess_path) = "path/to/client"
|
||||
CefString(&settings.root_cache_path) = std::filesystem::temp_directory_path() / uuid::generate_uuid_v4();
|
||||
settings.windowless_rendering_enabled = true;
|
||||
#if defined(CEF_NO_SANDBOX)
|
||||
settings.no_sandbox = true;
|
||||
#endif
|
||||
|
||||
// spawns two new processess
|
||||
bool result = CefInitialize (args, settings, nullptr, nullptr);
|
||||
bool result = CefInitialize (main_args, settings, this->m_browserApplication, nullptr);
|
||||
|
||||
if (!result) {
|
||||
sLog.exception ("CefInitialize: failed");
|
||||
@ -49,25 +95,6 @@ CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (fals
|
||||
}
|
||||
|
||||
CWebBrowserContext::~CWebBrowserContext () {
|
||||
this->stop ();
|
||||
}
|
||||
|
||||
void CWebBrowserContext::markAsUsed () {
|
||||
this->m_inUse = true;
|
||||
}
|
||||
|
||||
bool CWebBrowserContext::isUsed () {
|
||||
return this->m_inUse;
|
||||
}
|
||||
|
||||
void CWebBrowserContext::stop () {
|
||||
if (this->m_stopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
sLog.out ("Shutting down CEF");
|
||||
|
||||
this->m_stopped = true;
|
||||
|
||||
CefShutdown ();
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "WallpaperEngine/Application/CApplicationContext.h"
|
||||
#include "WallpaperEngine/Application/CWallpaperApplication.h"
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_browser_process_handler.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
|
||||
#define WPENGINE_SCHEME "wp"
|
||||
|
||||
namespace WallpaperEngine::WebBrowser::CEF {
|
||||
class CBrowserApp;
|
||||
}
|
||||
|
||||
namespace WallpaperEngine::WebBrowser {
|
||||
class CWebBrowserContext {
|
||||
public:
|
||||
CWebBrowserContext (int argc, char** argv);
|
||||
explicit CWebBrowserContext (WallpaperEngine::Application::CWallpaperApplication& wallpaperApplication);
|
||||
~CWebBrowserContext();
|
||||
|
||||
void markAsUsed();
|
||||
bool isUsed();
|
||||
void stop();
|
||||
|
||||
private:
|
||||
bool m_stopped;
|
||||
bool m_inUse;
|
||||
CefRefPtr<CefApp> m_browserApplication;
|
||||
CefRefPtr<CefCommandLine> m_commandLine;
|
||||
WallpaperEngine::Application::CWallpaperApplication& m_wallpaperApplication;
|
||||
};
|
||||
} // namespace WallpaperEngine::WebBrowser
|
||||
|
Loading…
Reference in New Issue
Block a user