a32940a3f3
Enable hardware-accelerated rendering and persist GPU/cache data. Added a BrowserSettings() helper that enables WebGL and use it when creating Chrome/Content/MenuPopup browsers (src/app/nebula_controller.cpp). Configure CefSettings to use a persistent user data and cache directory (src/app/run.cpp) by calling nebula::ui::GetUserDataDirectory() and GetCacheDirectory(). Add command-line switches to initialize the GPU process and avoid sandbox/blocklist fallbacks (disable GPU sandbox, in-process-gpu, ignore-gpu-blocklist, enable-accelerated-video-decode, use ANGLE D3D11) to prevent GPU crashes and Chromium falling back to software rendering (src/cef/nebula_app.cpp). Implement GetUserDataDirectory() and GetCacheDirectory() (preferring %LOCALAPPDATA% with an executable-directory fallback) and expose them in the header (src/ui/paths.cpp, src/ui/paths.h). These changes ensure GPU shader caching, WebGL support, and smoother video/graphics behavior.
68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
#include "app/run.h"
|
|
|
|
#include "app/nebula_controller.h"
|
|
#include "cef/nebula_app.h"
|
|
#include "include/cef_app.h"
|
|
#include "include/cef_command_line.h"
|
|
#include "ui/paths.h"
|
|
|
|
namespace nebula::app {
|
|
namespace {
|
|
|
|
void EnableDpiAwareness() {
|
|
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int RunNebula(HINSTANCE instance, int show_command) {
|
|
EnableDpiAwareness();
|
|
|
|
CefMainArgs main_args(instance);
|
|
CefRefPtr<nebula::cef::NebulaApp> app(new nebula::cef::NebulaApp);
|
|
|
|
const int subprocess_exit_code = CefExecuteProcess(main_args, app, nullptr);
|
|
if (subprocess_exit_code >= 0) {
|
|
return subprocess_exit_code;
|
|
}
|
|
|
|
CefSettings settings;
|
|
settings.no_sandbox = true;
|
|
|
|
// A persistent profile is required for the GPU shader cache and several
|
|
// hardware acceleration features. Without these Chromium silently falls
|
|
// back to software rendering, which causes choppy video and disables
|
|
// WebGL/WebGL2 in the GPU diagnostics page.
|
|
const std::wstring user_data_dir = nebula::ui::GetUserDataDirectory().wstring();
|
|
const std::wstring cache_dir = nebula::ui::GetCacheDirectory().wstring();
|
|
if (!user_data_dir.empty()) {
|
|
CefString(&settings.root_cache_path).FromWString(user_data_dir);
|
|
}
|
|
if (!cache_dir.empty()) {
|
|
CefString(&settings.cache_path).FromWString(cache_dir);
|
|
}
|
|
|
|
if (!CefInitialize(main_args, settings, app, nullptr)) {
|
|
return CefGetExitCode();
|
|
}
|
|
|
|
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
|
command_line->InitFromString(GetCommandLineW());
|
|
|
|
std::string initial_url = command_line->GetSwitchValue("url");
|
|
if (nebula::ui::IsEmptyOrChromiumNewTabUrl(initial_url)) {
|
|
initial_url = nebula::ui::GetHomeUrl();
|
|
}
|
|
|
|
NebulaController controller(instance, initial_url, show_command);
|
|
const bool created = controller.Create();
|
|
if (created) {
|
|
CefRunMessageLoop();
|
|
}
|
|
|
|
CefShutdown();
|
|
return created ? 0 : 1;
|
|
}
|
|
|
|
} // namespace nebula::app
|