// Enable High-DPI support on Windows 7 or newer.
CefEnableHighDPISupport();
void* sandbox_info = NULL;
// Provide CEF with command-line arguments.
CefMainArgs main_args(hInstance);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, NULL, sandbox_info);
if ( exit_code >= 0 )
{
// The sub-process has completed so return here.
return exit_code;
}
// Specify CEF global settings here.
CefSettings settings;
//settings.single_process = true;
// SimpleApp implements application-level callbacks for the browser process.
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
CefRefPtr<SimpleApp> app(new SimpleApp);
// Initialize CEF.
CefInitialize(main_args, settings, app.get(), sandbox_info);
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
CefRunMessageLoop();
// Shut down CEF.
CefShutdown();
__declspec( dllexport ) void __stdcall PluginDLLRunner_InitCEF(HINSTANCE hInstance)
{
// Enable High-DPI support on Windows 7 or newer.
CefEnableHighDPISupport();
void* sandbox_info = NULL;
// Provide CEF with command-line arguments.
CefMainArgs main_args(hInstance);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, NULL, sandbox_info);
if ( exit_code >= 0 )
{
// The sub-process has completed so return here.
return;
}
// Specify CEF global settings here.
CefSettings settings;
settings.log_severity = LOGSEVERITY_VERBOSE;
// SimpleApp implements application-level callbacks for the browser process.
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
CefRefPtr<SimpleApp> app(new SimpleApp);
// Initialize CEF.
CefInitialize(main_args, settings, app.get(), sandbox_info);
}
__declspec( dllexport ) void __stdcall PluginDLLRunner_ShutdownCEF()
{
// Shut down CEF.
CefShutdown();
}
__declspec( dllexport ) void __stdcall PluginDLLRunner_CreateCEFWindow()
{
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
CefRunMessageLoop();
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch ( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
{
PluginDLLRunner_InitCEF(static_cast<HINSTANCE>( hModule ));
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
{
PluginDLLRunner_ShutdownCEF();
}
break;
}
return TRUE;
}
The implementation of DoCefInitialize calls CefInitialize with CefSettings.multi_threaded_message_loop = true and browser_subprocess_path pointing to a separate exe for subprocesses.
abizeau wrote:Do I really need multi thread message loop ? Do I really need to create a sub process ?
abizeau wrote:the program is stuck on the CefInitialize() when the dll start
abizeau wrote:Im not sure to understand why I need to use a sub-process
abizeau wrote:Photoshop will provide an image to my Plugin as Input, can I send it to the sub-process ?
abizeau wrote:
Photoshop will provide an image to my Plugin as Input, can I send it to the sub-process ?
You can use asynchronous JavaScript bindings or the network layer.
bool PluginCEFHelper::CreateCEFWindows(const std::string url)
{
OutputDebugString(L"PluginCEFHelper - Shows the window.\n");
m_app->GenerateWindows(url);
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
CefRunMessageLoop();
return false;
}
Users browsing this forum: Google [Bot] and 91 guests