add modify human
This commit is contained in:
parent
348d9343f0
commit
847866847e
@ -1,7 +1,7 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.21)
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.21)
|
||||||
|
|
||||||
PROJECT(HunanRender)
|
PROJECT(HunanRender)
|
||||||
SET(CMAKE_CXX_STANDARD 17)
|
SET(CMAKE_CXX_STANDARD 14)
|
||||||
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
SET(CMAKE_CXX_EXTENSIONS OFF)
|
SET(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
@ -1,134 +0,0 @@
|
|||||||
// Copyright (c) 2013 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.
|
|
||||||
|
|
||||||
#include "CEF/CefApp.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "include/cef_browser.h"
|
|
||||||
#include "include/cef_command_line.h"
|
|
||||||
#include "include/views/cef_browser_view.h"
|
|
||||||
#include "include/views/cef_window.h"
|
|
||||||
#include "include/wrapper/cef_helpers.h"
|
|
||||||
#include "CEF/simple_handler.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// When using the Views framework this object provides the delegate
|
|
||||||
// implementation for the CefWindow that hosts the Views-based browser.
|
|
||||||
class SimpleWindowDelegate : public CefWindowDelegate {
|
|
||||||
public:
|
|
||||||
explicit SimpleWindowDelegate(CefRefPtr<CefBrowserView> browser_view)
|
|
||||||
: browser_view_(browser_view) {}
|
|
||||||
|
|
||||||
void OnWindowCreated(CefRefPtr<CefWindow> window) override {
|
|
||||||
// Add the browser view and show the window.
|
|
||||||
window->AddChildView(browser_view_);
|
|
||||||
window->Show();
|
|
||||||
|
|
||||||
// Give keyboard focus to the browser view.
|
|
||||||
browser_view_->RequestFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnWindowDestroyed(CefRefPtr<CefWindow> window) override {
|
|
||||||
browser_view_ = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CanClose(CefRefPtr<CefWindow> window) override {
|
|
||||||
// Allow the window to close if the browser says it's OK.
|
|
||||||
CefRefPtr<CefBrowser> browser = browser_view_->GetBrowser();
|
|
||||||
if (browser)
|
|
||||||
return browser->GetHost()->TryCloseBrowser();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefSize GetPreferredSize(CefRefPtr<CefView> view) override {
|
|
||||||
return CefSize(800, 600);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
CefRefPtr<CefBrowserView> browser_view_;
|
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(SimpleWindowDelegate);
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(SimpleWindowDelegate);
|
|
||||||
};
|
|
||||||
|
|
||||||
class SimpleBrowserViewDelegate : public CefBrowserViewDelegate {
|
|
||||||
public:
|
|
||||||
SimpleBrowserViewDelegate() {}
|
|
||||||
|
|
||||||
bool OnPopupBrowserViewCreated(CefRefPtr<CefBrowserView> browser_view,
|
|
||||||
CefRefPtr<CefBrowserView> popup_browser_view,
|
|
||||||
bool is_devtools) override {
|
|
||||||
// Create a new top-level Window for the popup. It will show itself after
|
|
||||||
// creation.
|
|
||||||
CefWindow::CreateTopLevelWindow(
|
|
||||||
new SimpleWindowDelegate(popup_browser_view));
|
|
||||||
|
|
||||||
// We created the Window.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
IMPLEMENT_REFCOUNTING(SimpleBrowserViewDelegate);
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(SimpleBrowserViewDelegate);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
SimpleApp::SimpleApp() {}
|
|
||||||
|
|
||||||
void SimpleApp::OnContextInitialized() {
|
|
||||||
CEF_REQUIRE_UI_THREAD();
|
|
||||||
|
|
||||||
CefRefPtr<CefCommandLine> command_line =
|
|
||||||
CefCommandLine::GetGlobalCommandLine();
|
|
||||||
|
|
||||||
// Create the browser using the Views framework if "--use-views" is specified
|
|
||||||
// via the command-line. Otherwise, create the browser using the native
|
|
||||||
// platform framework.
|
|
||||||
const bool use_views = command_line->HasSwitch("use-views");
|
|
||||||
|
|
||||||
// SimpleHandler implements browser-level callbacks.
|
|
||||||
CefRefPtr<SimpleHandler> handler(new SimpleHandler(use_views));
|
|
||||||
|
|
||||||
// Specify CEF browser settings here.
|
|
||||||
CefBrowserSettings browser_settings;
|
|
||||||
|
|
||||||
std::string url;
|
|
||||||
|
|
||||||
// Check if a "--url=" value was provided via the command-line. If so, use
|
|
||||||
// that instead of the default URL.
|
|
||||||
url = command_line->GetSwitchValue("url");
|
|
||||||
if (url.empty())
|
|
||||||
url = "http://www.google.com";
|
|
||||||
|
|
||||||
if (use_views) {
|
|
||||||
// Create the BrowserView.
|
|
||||||
CefRefPtr<CefBrowserView> browser_view = CefBrowserView::CreateBrowserView(
|
|
||||||
handler, url, browser_settings, nullptr, nullptr,
|
|
||||||
new SimpleBrowserViewDelegate());
|
|
||||||
|
|
||||||
// Create the Window. It will show itself after creation.
|
|
||||||
CefWindow::CreateTopLevelWindow(new SimpleWindowDelegate(browser_view));
|
|
||||||
} else {
|
|
||||||
// Information used when creating the native window.
|
|
||||||
CefWindowInfo window_info;
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
// On Windows we need to specify certain flags that will be passed to
|
|
||||||
// CreateWindowEx().
|
|
||||||
window_info.SetAsPopup(nullptr, "cefsimple");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Create the first browser window.
|
|
||||||
CefBrowserHost::CreateBrowser(window_info, handler, url, browser_settings,
|
|
||||||
nullptr, nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CefRefPtr<CefClient> SimpleApp::GetDefaultClient() {
|
|
||||||
// Called when a new browser window is created via the Chrome runtime UI.
|
|
||||||
return SimpleHandler::GetInstance();
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
// Copyright (c) 2013 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.
|
|
||||||
|
|
||||||
#ifndef CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
|
||||||
#define CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
|
||||||
|
|
||||||
#include "include/cef_app.h"
|
|
||||||
|
|
||||||
// Implement application-level callbacks for the browser process.
|
|
||||||
class SimpleApp : public CefApp, public CefBrowserProcessHandler {
|
|
||||||
public:
|
|
||||||
SimpleApp();
|
|
||||||
|
|
||||||
// CefApp methods:
|
|
||||||
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// CefBrowserProcessHandler methods:
|
|
||||||
void OnContextInitialized() override;
|
|
||||||
CefRefPtr<CefClient> GetDefaultClient() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Include the default reference counting implementation.
|
|
||||||
IMPLEMENT_REFCOUNTING(SimpleApp);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
|
377
src/CEF/HuamAppRendererDelegate.cpp
Normal file
377
src/CEF/HuamAppRendererDelegate.cpp
Normal file
@ -0,0 +1,377 @@
|
|||||||
|
#include "CEF/HumanAppRenderer.h"
|
||||||
|
|
||||||
|
#include "CEF/RenderContent.h"
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8NullCreate) {
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateNull();
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8BoolCreate) {
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateBool(true);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8IntCreate) {
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateInt(-5);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8UIntCreate) {
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateUInt(10);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8DoubleCreate) {
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateDouble(12.432);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8DateCreate) {
|
||||||
|
static cef_time_t time = { 2012, 1, 0, 1 };
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateDate(time);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8StringCreate) {
|
||||||
|
CefString str = "test string";
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateString(str);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ArrayCreate) {
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateArray(1);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ArraySetValue) {
|
||||||
|
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||||
|
CefRefPtr<CefV8Value> array = CefV8Value::CreateArray(1);
|
||||||
|
array->SetValue(0, val);
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
array->SetValue(0, val);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ArrayGetValue) {
|
||||||
|
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||||
|
CefRefPtr<CefV8Value> array = CefV8Value::CreateArray(1);
|
||||||
|
array->SetValue(0, val);
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> ret = array->GetValue(0);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8FunctionCreate) {
|
||||||
|
class Handler : public CefV8Handler {
|
||||||
|
public:
|
||||||
|
Handler() {}
|
||||||
|
virtual bool Execute(const CefString& name,
|
||||||
|
CefRefPtr<CefV8Value> object,
|
||||||
|
const CefV8ValueList& arguments,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
IMPLEMENT_REFCOUNTING(Handler);
|
||||||
|
};
|
||||||
|
|
||||||
|
CefString name = "name";
|
||||||
|
CefRefPtr<CefV8Handler> handler = new Handler();
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateFunction(name, handler);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8FunctionExecute) {
|
||||||
|
class Handler : public CefV8Handler {
|
||||||
|
public:
|
||||||
|
Handler() {}
|
||||||
|
virtual bool Execute(const CefString& name,
|
||||||
|
CefRefPtr<CefV8Value> object,
|
||||||
|
const CefV8ValueList& arguments,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
IMPLEMENT_REFCOUNTING(Handler);
|
||||||
|
};
|
||||||
|
|
||||||
|
CefString name = "name";
|
||||||
|
CefRefPtr<CefV8Handler> handler = new Handler();
|
||||||
|
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction(name, handler);
|
||||||
|
CefRefPtr<CefV8Value> obj = CefV8Context::GetCurrentContext()->GetGlobal();
|
||||||
|
CefV8ValueList args;
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
func->ExecuteFunction(obj, args);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8FunctionExecuteWithContext) {
|
||||||
|
class Handler : public CefV8Handler {
|
||||||
|
public:
|
||||||
|
Handler() {}
|
||||||
|
virtual bool Execute(const CefString& name,
|
||||||
|
CefRefPtr<CefV8Value> object,
|
||||||
|
const CefV8ValueList& arguments,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
IMPLEMENT_REFCOUNTING(Handler);
|
||||||
|
};
|
||||||
|
|
||||||
|
CefString name = "name";
|
||||||
|
CefRefPtr<CefV8Handler> handler = new Handler();
|
||||||
|
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction(name, handler);
|
||||||
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||||
|
CefRefPtr<CefV8Value> obj = context->GetGlobal();
|
||||||
|
CefV8ValueList args;
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
func->ExecuteFunctionWithContext(context, obj, args);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ObjectCreate) {
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateObject(nullptr, nullptr);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ObjectCreateWithAccessor) {
|
||||||
|
class Accessor : public CefV8Accessor {
|
||||||
|
public:
|
||||||
|
Accessor() {}
|
||||||
|
virtual bool Get(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool Set(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
const CefRefPtr<CefV8Value> value,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
IMPLEMENT_REFCOUNTING(Accessor);
|
||||||
|
};
|
||||||
|
|
||||||
|
CefRefPtr<CefV8Accessor> accessor = new Accessor();
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateObject(accessor, nullptr);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ObjectCreateWithInterceptor) {
|
||||||
|
class Interceptor : public CefV8Interceptor {
|
||||||
|
public:
|
||||||
|
Interceptor() {}
|
||||||
|
virtual bool Get(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool Get(int index,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool Set(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
const CefRefPtr<CefV8Value> value,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool Set(int index,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
const CefRefPtr<CefV8Value> value,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
IMPLEMENT_REFCOUNTING(Interceptor);
|
||||||
|
};
|
||||||
|
|
||||||
|
CefRefPtr<CefV8Interceptor> interceptor = new Interceptor();
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> value = CefV8Value::CreateObject(nullptr, interceptor);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ObjectSetValue) {
|
||||||
|
CefString name = "name";
|
||||||
|
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||||
|
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(nullptr, nullptr);
|
||||||
|
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ObjectGetValue) {
|
||||||
|
CefString name = "name";
|
||||||
|
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||||
|
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(nullptr, nullptr);
|
||||||
|
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> ret = obj->GetValue(name);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ObjectSetValueWithAccessor) {
|
||||||
|
class Accessor : public CefV8Accessor {
|
||||||
|
public:
|
||||||
|
Accessor() {}
|
||||||
|
virtual bool Get(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool Set(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
const CefRefPtr<CefV8Value> value,
|
||||||
|
CefString& exception) override {
|
||||||
|
val_ = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CefRefPtr<CefV8Value> val_;
|
||||||
|
IMPLEMENT_REFCOUNTING(Accessor);
|
||||||
|
};
|
||||||
|
|
||||||
|
CefRefPtr<CefV8Accessor> accessor = new Accessor();
|
||||||
|
|
||||||
|
CefString name = "name";
|
||||||
|
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||||
|
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(accessor, nullptr);
|
||||||
|
obj->SetValue(name, V8_ACCESS_CONTROL_DEFAULT, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ObjectGetValueWithAccessor) {
|
||||||
|
class Accessor : public CefV8Accessor {
|
||||||
|
public:
|
||||||
|
Accessor() : val_(CefV8Value::CreateBool(true)) {}
|
||||||
|
virtual bool Get(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
retval = val_;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool Set(const CefString& name,
|
||||||
|
const CefRefPtr<CefV8Value> object,
|
||||||
|
const CefRefPtr<CefV8Value> value,
|
||||||
|
CefString& exception) override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CefRefPtr<CefV8Value> val_;
|
||||||
|
IMPLEMENT_REFCOUNTING(Accessor);
|
||||||
|
};
|
||||||
|
|
||||||
|
CefRefPtr<CefV8Accessor> accessor = new Accessor();
|
||||||
|
|
||||||
|
CefString name = "name";
|
||||||
|
CefRefPtr<CefV8Value> val = CefV8Value::CreateBool(true);
|
||||||
|
CefRefPtr<CefV8Value> obj = CefV8Value::CreateObject(accessor, nullptr);
|
||||||
|
obj->SetValue(name, V8_ACCESS_CONTROL_DEFAULT, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
obj->SetValue(name, val, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
CefRefPtr<CefV8Value> ret = obj->GetValue(name);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ArrayBufferCreate) {
|
||||||
|
class ReleaseCallback : public CefV8ArrayBufferReleaseCallback {
|
||||||
|
public:
|
||||||
|
void ReleaseBuffer(void* buffer) override {
|
||||||
|
std::free(buffer);
|
||||||
|
}
|
||||||
|
IMPLEMENT_REFCOUNTING(ReleaseCallback);
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t len = 1;
|
||||||
|
size_t byte_len = len * sizeof(float);
|
||||||
|
CefRefPtr<CefV8ArrayBufferReleaseCallback> callback = new ReleaseCallback();
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
float* buffer = (float*)std::malloc(byte_len);
|
||||||
|
CefRefPtr<CefV8Value> ret =
|
||||||
|
CefV8Value::CreateArrayBuffer(buffer, byte_len, callback);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ContextEnterExit) {
|
||||||
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
context->Enter();
|
||||||
|
context->Exit();
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
PERF_TEST_FUNC(V8ContextEval) {
|
||||||
|
CefRefPtr<CefV8Context> context = CefV8Context::GetCurrentContext();
|
||||||
|
CefString jsCode = "var i = 0;";
|
||||||
|
CefRefPtr<CefV8Value> retval;
|
||||||
|
CefRefPtr<CefV8Exception> exception;
|
||||||
|
|
||||||
|
PERF_ITERATIONS_START()
|
||||||
|
context->Eval(jsCode, CefString(), 0, retval, exception);
|
||||||
|
PERF_ITERATIONS_END()
|
||||||
|
}
|
||||||
|
|
||||||
|
const PerfTestEntry kPerfTests[] = {
|
||||||
|
PERF_TEST_ENTRY(V8NullCreate),
|
||||||
|
PERF_TEST_ENTRY(V8BoolCreate),
|
||||||
|
PERF_TEST_ENTRY(V8IntCreate),
|
||||||
|
PERF_TEST_ENTRY(V8UIntCreate),
|
||||||
|
PERF_TEST_ENTRY(V8DoubleCreate),
|
||||||
|
PERF_TEST_ENTRY(V8DateCreate),
|
||||||
|
PERF_TEST_ENTRY(V8StringCreate),
|
||||||
|
PERF_TEST_ENTRY(V8ArrayCreate),
|
||||||
|
PERF_TEST_ENTRY(V8ArraySetValue),
|
||||||
|
PERF_TEST_ENTRY(V8ArrayGetValue),
|
||||||
|
PERF_TEST_ENTRY(V8FunctionCreate),
|
||||||
|
PERF_TEST_ENTRY(V8FunctionExecute),
|
||||||
|
PERF_TEST_ENTRY(V8FunctionExecuteWithContext),
|
||||||
|
PERF_TEST_ENTRY(V8ObjectCreate),
|
||||||
|
PERF_TEST_ENTRY(V8ObjectCreateWithAccessor),
|
||||||
|
PERF_TEST_ENTRY(V8ObjectCreateWithInterceptor),
|
||||||
|
PERF_TEST_ENTRY(V8ObjectSetValue),
|
||||||
|
PERF_TEST_ENTRY(V8ObjectGetValue),
|
||||||
|
PERF_TEST_ENTRY(V8ObjectSetValueWithAccessor),
|
||||||
|
PERF_TEST_ENTRY(V8ObjectGetValueWithAccessor),
|
||||||
|
PERF_TEST_ENTRY(V8ArrayBufferCreate),
|
||||||
|
PERF_TEST_ENTRY(V8ContextEnterExit),
|
||||||
|
PERF_TEST_ENTRY(V8ContextEval),
|
||||||
|
};
|
||||||
|
|
||||||
|
const int kPerfTestsCount = (sizeof(kPerfTests) / sizeof(kPerfTests[0]));
|
||||||
|
|
47
src/CEF/HumanApp.cpp
Normal file
47
src/CEF/HumanApp.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright (c) 2013 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.
|
||||||
|
|
||||||
|
#include "CEF/HumanApp.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "include/base/cef_callback.h"
|
||||||
|
#include "include/cef_app.h"
|
||||||
|
#include "include/cef_parser.h"
|
||||||
|
#include "include/views/cef_browser_view.h"
|
||||||
|
#include "include/views/cef_window.h"
|
||||||
|
#include "include/wrapper/cef_closure_task.h"
|
||||||
|
#include "include/wrapper/cef_helpers.h"
|
||||||
|
|
||||||
|
const char kProcessType[] = "type";
|
||||||
|
const char kRendererProcess[] = "renderer";
|
||||||
|
|
||||||
|
|
||||||
|
HumanApp::HumanApp() {}
|
||||||
|
|
||||||
|
// static
|
||||||
|
HumanApp::ProcessType HumanApp::GetProcessType(
|
||||||
|
CefRefPtr<CefCommandLine> command_line) {
|
||||||
|
// The command-line flag won't be specified for the browser process.
|
||||||
|
if (!command_line->HasSwitch(kProcessType))
|
||||||
|
return BrowserProcess;
|
||||||
|
|
||||||
|
const std::string& process_type = command_line->GetSwitchValue(kProcessType);
|
||||||
|
if (process_type == kRendererProcess)
|
||||||
|
return RendererProcess;
|
||||||
|
|
||||||
|
return OtherProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HumanApp::RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanApp::OnRegisterCustomSchemes(
|
||||||
|
CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||||
|
RegisterCustomSchemes(registrar);
|
||||||
|
}
|
||||||
|
|
32
src/CEF/HumanApp.h
Normal file
32
src/CEF/HumanApp.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/cef_app.h"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
class HumanApp : public CefApp {
|
||||||
|
public:
|
||||||
|
HumanApp();
|
||||||
|
|
||||||
|
enum ProcessType {
|
||||||
|
BrowserProcess,
|
||||||
|
RendererProcess,
|
||||||
|
ZygoteProcess,
|
||||||
|
OtherProcess,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determine the process type based on command-line arguments.
|
||||||
|
static ProcessType GetProcessType(CefRefPtr<CefCommandLine> command_line);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Registers custom schemes. Implemented by cefclient in
|
||||||
|
// client_app_delegates_common.cc
|
||||||
|
static void RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar);
|
||||||
|
|
||||||
|
// CefApp methods.
|
||||||
|
void OnRegisterCustomSchemes(
|
||||||
|
CefRawPtr<CefSchemeRegistrar> registrar) override;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(HumanApp);
|
||||||
|
};
|
||||||
|
|
111
src/CEF/HumanAppBrowser.cpp
Normal file
111
src/CEF/HumanAppBrowser.cpp
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// Copyright (c) 2013 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.
|
||||||
|
|
||||||
|
#include "CEF/HumanApp.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "include/cef_browser.h"
|
||||||
|
#include "include/cef_command_line.h"
|
||||||
|
#include "include/views/cef_browser_view.h"
|
||||||
|
#include "include/views/cef_window.h"
|
||||||
|
#include "include/wrapper/cef_helpers.h"
|
||||||
|
|
||||||
|
|
||||||
|
HumanAppBrowser::HumanAppBrowser() {
|
||||||
|
CreateDelegates(delegates_);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
void HumanAppBrowser::PopulateSettings(CefRefPtr<CefCommandLine> command_line,
|
||||||
|
CefSettings& settings) {
|
||||||
|
#if (defined(OS_WIN) || defined(OS_LINUX))
|
||||||
|
settings.multi_threaded_message_loop =
|
||||||
|
command_line->HasSwitch(client::switches::kMultiThreadedMessageLoop);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!settings.multi_threaded_message_loop) {
|
||||||
|
settings.external_message_pump =
|
||||||
|
command_line->HasSwitch(client::switches::kExternalMessagePump);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> cookieable_schemes;
|
||||||
|
RegisterCookieableSchemes(cookieable_schemes);
|
||||||
|
if (!cookieable_schemes.empty()) {
|
||||||
|
std::string list_str;
|
||||||
|
for (const auto& scheme : cookieable_schemes) {
|
||||||
|
if (!list_str.empty())
|
||||||
|
list_str += ",";
|
||||||
|
list_str += scheme;
|
||||||
|
}
|
||||||
|
CefString(&settings.cookieable_schemes_list) = list_str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppBrowser::OnBeforeCommandLineProcessing(
|
||||||
|
const CefString& process_type,
|
||||||
|
CefRefPtr<CefCommandLine> command_line) {
|
||||||
|
// Pass additional command-line flags to the browser process.
|
||||||
|
if (process_type.empty()) {
|
||||||
|
// Pass additional command-line flags when off-screen rendering is enabled.
|
||||||
|
if (command_line->HasSwitch(switches::kOffScreenRenderingEnabled) &&
|
||||||
|
!command_line->HasSwitch(switches::kSharedTextureEnabled)) {
|
||||||
|
// Use software rendering and compositing (disable GPU) for increased FPS
|
||||||
|
// and decreased CPU usage. This will also disable WebGL so remove these
|
||||||
|
// switches if you need that capability.
|
||||||
|
// See https://bitbucket.org/chromiumembedded/cef/issues/1257 for details.
|
||||||
|
if (!command_line->HasSwitch(switches::kEnableGPU)) {
|
||||||
|
command_line->AppendSwitch("disable-gpu");
|
||||||
|
command_line->AppendSwitch("disable-gpu-compositing");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (command_line->HasSwitch(switches::kUseViews) &&
|
||||||
|
!command_line->HasSwitch("top-chrome-md")) {
|
||||||
|
// Use non-material mode on all platforms by default. Among other things
|
||||||
|
// this causes menu buttons to show hover state. See usage of
|
||||||
|
// MaterialDesignController::IsModeMaterial() in Chromium code.
|
||||||
|
command_line->AppendSwitchWithValue("top-chrome-md", "non-material");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!command_line->HasSwitch(switches::kCachePath) &&
|
||||||
|
!command_line->HasSwitch("disable-gpu-shader-disk-cache")) {
|
||||||
|
// Don't create a "GPUCache" directory when cache-path is unspecified.
|
||||||
|
command_line->AppendSwitch("disable-gpu-shader-disk-cache");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable popup blocking for the chrome runtime.
|
||||||
|
command_line->AppendSwitch("disable-popup-blocking");
|
||||||
|
|
||||||
|
#if defined(OS_MAC)
|
||||||
|
// Disable the toolchain prompt on macOS.
|
||||||
|
command_line->AppendSwitch("use-mock-keychain");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnBeforeCommandLineProcessing(this, command_line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppBrowser::OnContextInitialized() {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnContextInitialized(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppBrowser::OnBeforeChildProcessLaunch(
|
||||||
|
CefRefPtr<CefCommandLine> command_line) {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnBeforeChildProcessLaunch(this, command_line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppBrowser::OnScheduleMessagePumpWork(int64 delay) {
|
||||||
|
// Only used when `--external-message-pump` is passed via the command-line.
|
||||||
|
MainMessageLoopExternalPump* message_pump =
|
||||||
|
MainMessageLoopExternalPump::Get();
|
||||||
|
if (message_pump)
|
||||||
|
message_pump->OnScheduleMessagePumpWork(delay);
|
||||||
|
}
|
55
src/CEF/HumanAppBrowser.h
Normal file
55
src/CEF/HumanAppBrowser.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "CEF/HumanApp.h"
|
||||||
|
|
||||||
|
// Implement application-level callbacks for the browser process.
|
||||||
|
class HumanAppBrowser : public HumanApp, public CefBrowserProcessHandler {
|
||||||
|
public:
|
||||||
|
class Delegate : public virtual CefBaseRefCounted {
|
||||||
|
public:
|
||||||
|
virtual void OnBeforeCommandLineProcessing(
|
||||||
|
CefRefPtr<HumanAppBrowser> app,
|
||||||
|
CefRefPtr<CefCommandLine> command_line) {}
|
||||||
|
|
||||||
|
virtual void OnContextInitialized(CefRefPtr<HumanAppBrowser> app) {}
|
||||||
|
|
||||||
|
virtual void OnBeforeChildProcessLaunch(
|
||||||
|
CefRefPtr<HumanAppBrowser> app,
|
||||||
|
CefRefPtr<CefCommandLine> command_line) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
using DelegateSet = std::set<CefRefPtr<Delegate>>;
|
||||||
|
|
||||||
|
HumanAppBrowser();
|
||||||
|
|
||||||
|
static void PopulateSettings(CefRefPtr<CefCommandLine> command_line,
|
||||||
|
CefSettings& settings);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void RegisterCookieableSchemes(
|
||||||
|
std::vector<std::string>& cookieable_schemes);
|
||||||
|
|
||||||
|
static void CreateDelegates(DelegateSet& delegates);
|
||||||
|
|
||||||
|
void OnBeforeCommandLineProcessing(
|
||||||
|
const CefString& process_type,
|
||||||
|
CefRefPtr<CefCommandLine> command_line) override;
|
||||||
|
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CefBrowserProcessHandler methods.
|
||||||
|
void OnContextInitialized() override;
|
||||||
|
void OnBeforeChildProcessLaunch(
|
||||||
|
CefRefPtr<CefCommandLine> command_line) override;
|
||||||
|
void OnScheduleMessagePumpWork(int64 delay) override;
|
||||||
|
|
||||||
|
|
||||||
|
DelegateSet delegates_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(HumanAppBrowser);
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(HumanAppBrowser);
|
||||||
|
};
|
||||||
|
|
7
src/CEF/HumanAppOther.cpp
Normal file
7
src/CEF/HumanAppOther.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Copyright (c) 2012 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.
|
||||||
|
|
||||||
|
#include "CEF/HumanAppOther.h"
|
||||||
|
|
||||||
|
HumanAppOther::HumanAppOther() {}
|
15
src/CEF/HumanAppOther.h
Normal file
15
src/CEF/HumanAppOther.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "CEF/HumanApp.h"
|
||||||
|
|
||||||
|
class HumanAppOther
|
||||||
|
: public HumanApp{
|
||||||
|
public:
|
||||||
|
HumanAppOther();
|
||||||
|
private:
|
||||||
|
IMPLEMENT_REFCOUNTING(HumanAppOther);
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(HumanAppOther);
|
||||||
|
};
|
||||||
|
|
314
src/CEF/HumanAppRenderer.cpp
Normal file
314
src/CEF/HumanAppRenderer.cpp
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
// Copyright (c) 2012 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.
|
||||||
|
|
||||||
|
#include "CEF/HumanAppRenderer.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "include/cef_crash_util.h"
|
||||||
|
#include "include/cef_dom.h"
|
||||||
|
#include "include/wrapper/cef_helpers.h"
|
||||||
|
#include "include/wrapper/cef_message_router.h"
|
||||||
|
|
||||||
|
#include "CEF/RenderContent.h"
|
||||||
|
|
||||||
|
const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged";
|
||||||
|
|
||||||
|
class ClientRenderDelegate : public HumanAppRenderer::Delegate {
|
||||||
|
public:
|
||||||
|
ClientRenderDelegate() : last_node_is_editable_(false) {}
|
||||||
|
|
||||||
|
void OnWebKitInitialized(CefRefPtr<HumanAppRenderer> app) override {
|
||||||
|
if (CefCrashReportingEnabled()) {
|
||||||
|
// Set some crash keys for testing purposes. Keys must be defined in the
|
||||||
|
// "crash_reporter.cfg" file. See cef_crash_util.h for details.
|
||||||
|
CefSetCrashKeyValue("testkey_small1", "value1_small_renderer");
|
||||||
|
CefSetCrashKeyValue("testkey_small2", "value2_small_renderer");
|
||||||
|
CefSetCrashKeyValue("testkey_medium1", "value1_medium_renderer");
|
||||||
|
CefSetCrashKeyValue("testkey_medium2", "value2_medium_renderer");
|
||||||
|
CefSetCrashKeyValue("testkey_large1", "value1_large_renderer");
|
||||||
|
CefSetCrashKeyValue("testkey_large2", "value2_large_renderer");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the renderer-side router for query handling.
|
||||||
|
CefMessageRouterConfig config;
|
||||||
|
message_router_ = CefMessageRouterRendererSide::Create(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnContextCreated(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) override {
|
||||||
|
message_router_->OnContextCreated(browser, frame, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnContextReleased(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) override {
|
||||||
|
message_router_->OnContextReleased(browser, frame, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnFocusedNodeChanged(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefDOMNode> node) override {
|
||||||
|
bool is_editable = (node.get() && node->IsEditable());
|
||||||
|
if (is_editable != last_node_is_editable_) {
|
||||||
|
// Notify the browser of the change in focused element type.
|
||||||
|
last_node_is_editable_ = is_editable;
|
||||||
|
CefRefPtr<CefProcessMessage> message =
|
||||||
|
CefProcessMessage::Create(kFocusedNodeChangedMessage);
|
||||||
|
message->GetArgumentList()->SetBool(0, is_editable);
|
||||||
|
frame->SendProcessMessage(PID_BROWSER, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnProcessMessageReceived(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message) override {
|
||||||
|
return message_router_->OnProcessMessageReceived(browser, frame,
|
||||||
|
source_process, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool last_node_is_editable_;
|
||||||
|
|
||||||
|
// Handles the renderer side of query routing.
|
||||||
|
CefRefPtr<CefMessageRouterRendererSide> message_router_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ClientRenderDelegate);
|
||||||
|
IMPLEMENT_REFCOUNTING(ClientRenderDelegate);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const char kGetPerfTests[] = "GetPerfTests";
|
||||||
|
const char kRunPerfTest[] = "RunPerfTest";
|
||||||
|
const char kPerfTestReturnValue[] = "PerfTestReturnValue";
|
||||||
|
|
||||||
|
class V8Handler : public CefV8Handler {
|
||||||
|
public:
|
||||||
|
V8Handler() {}
|
||||||
|
|
||||||
|
virtual bool Execute(const CefString& name,
|
||||||
|
CefRefPtr<CefV8Value> object,
|
||||||
|
const CefV8ValueList& arguments,
|
||||||
|
CefRefPtr<CefV8Value>& retval,
|
||||||
|
CefString& exception) override {
|
||||||
|
if (name == kRunPerfTest) {
|
||||||
|
if (arguments.size() == 1 && arguments[0]->IsString()) {
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
|
std::string test = arguments[0]->GetStringValue();
|
||||||
|
for (int i = 0; i < kPerfTestsCount; ++i) {
|
||||||
|
if (test == kPerfTests[i].name) {
|
||||||
|
// Execute the test.
|
||||||
|
int64 delta = kPerfTests[i].test(kPerfTests[i].iterations);
|
||||||
|
|
||||||
|
retval = CefV8Value::CreateInt(delta);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
std::string msg = "Unknown test: ";
|
||||||
|
msg.append(test);
|
||||||
|
exception = msg;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
exception = "Invalid function parameters";
|
||||||
|
}
|
||||||
|
} else if (name == kGetPerfTests) {
|
||||||
|
// Retrieve the list of perf tests.
|
||||||
|
retval = CefV8Value::CreateArray(kPerfTestsCount);
|
||||||
|
for (int i = 0; i < kPerfTestsCount; ++i) {
|
||||||
|
CefRefPtr<CefV8Value> val = CefV8Value::CreateArray(2);
|
||||||
|
val->SetValue(0, CefV8Value::CreateString(kPerfTests[i].name));
|
||||||
|
val->SetValue(1, CefV8Value::CreateUInt(kPerfTests[i].iterations));
|
||||||
|
retval->SetValue(i, val);
|
||||||
|
}
|
||||||
|
} else if (name == kPerfTestReturnValue) {
|
||||||
|
if (arguments.size() == 0) {
|
||||||
|
retval = CefV8Value::CreateInt(1);
|
||||||
|
} else if (arguments.size() == 1 && arguments[0]->IsInt()) {
|
||||||
|
int32 type = arguments[0]->GetIntValue();
|
||||||
|
CefTime date;
|
||||||
|
switch (type) {
|
||||||
|
case 0:
|
||||||
|
retval = CefV8Value::CreateUndefined();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
retval = CefV8Value::CreateNull();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
retval = CefV8Value::CreateBool(true);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
retval = CefV8Value::CreateInt(1);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
retval = CefV8Value::CreateUInt(1);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
retval = CefV8Value::CreateDouble(1.234);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
date.Now();
|
||||||
|
retval = CefV8Value::CreateDate(date);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
retval = CefV8Value::CreateString("Hello, world!");
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
retval = CefV8Value::CreateObject(nullptr, nullptr);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
retval = CefV8Value::CreateArray(8);
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
// retval = CefV8Value::CreateFunction(...);
|
||||||
|
exception = "Not implemented";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
exception = "Not supported";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
IMPLEMENT_REFCOUNTING(V8Handler);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Handle bindings in the render process.
|
||||||
|
class RenderDelegate : public HumanAppRenderer::Delegate {
|
||||||
|
public:
|
||||||
|
RenderDelegate() {}
|
||||||
|
|
||||||
|
virtual void OnContextCreated(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) override {
|
||||||
|
CefRefPtr<CefV8Value> object = context->GetGlobal();
|
||||||
|
|
||||||
|
CefRefPtr<CefV8Handler> handler = new V8Handler();
|
||||||
|
|
||||||
|
// Bind test functions.
|
||||||
|
object->SetValue(kGetPerfTests,
|
||||||
|
CefV8Value::CreateFunction(kGetPerfTests, handler),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_READONLY);
|
||||||
|
object->SetValue(kRunPerfTest,
|
||||||
|
CefV8Value::CreateFunction(kRunPerfTest, handler),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_READONLY);
|
||||||
|
object->SetValue(kPerfTestReturnValue,
|
||||||
|
CefV8Value::CreateFunction(kPerfTestReturnValue, handler),
|
||||||
|
V8_PROPERTY_ATTRIBUTE_READONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
IMPLEMENT_REFCOUNTING(RenderDelegate);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HumanAppRenderer::HumanAppRenderer() {
|
||||||
|
CreateDelegates(delegates_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void HumanAppRenderer::CreateDelegates(DelegateSet& delegates) {
|
||||||
|
delegates.insert(new ClientRenderDelegate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppRenderer::OnWebKitInitialized() {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnWebKitInitialized(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppRenderer::OnBrowserCreated(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDictionaryValue> extra_info) {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnBrowserCreated(this, browser, extra_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppRenderer::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnBrowserDestroyed(this, browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefLoadHandler> HumanAppRenderer::GetLoadHandler() {
|
||||||
|
CefRefPtr<CefLoadHandler> load_handler;
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end() && !load_handler.get(); ++it)
|
||||||
|
load_handler = (*it)->GetLoadHandler(this);
|
||||||
|
|
||||||
|
return load_handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppRenderer::OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnContextCreated(this, browser, frame, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppRenderer::OnContextReleased(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnContextReleased(this, browser, frame, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppRenderer::OnUncaughtException(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context,
|
||||||
|
CefRefPtr<CefV8Exception> exception,
|
||||||
|
CefRefPtr<CefV8StackTrace> stackTrace) {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it) {
|
||||||
|
(*it)->OnUncaughtException(this, browser, frame, context, exception,
|
||||||
|
stackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HumanAppRenderer::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefDOMNode> node) {
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end(); ++it)
|
||||||
|
(*it)->OnFocusedNodeChanged(this, browser, frame, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HumanAppRenderer::OnProcessMessageReceived(
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message) {
|
||||||
|
DCHECK_EQ(source_process, PID_BROWSER);
|
||||||
|
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
|
DelegateSet::iterator it = delegates_.begin();
|
||||||
|
for (; it != delegates_.end() && !handled; ++it) {
|
||||||
|
handled = (*it)->OnProcessMessageReceived(this, browser, frame,
|
||||||
|
source_process, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
103
src/CEF/HumanAppRenderer.h
Normal file
103
src/CEF/HumanAppRenderer.h
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "CEF/HumanApp.h"
|
||||||
|
|
||||||
|
class HumanAppRenderer
|
||||||
|
: public HumanApp
|
||||||
|
, public CefRenderProcessHandler {
|
||||||
|
public:
|
||||||
|
class Delegate : public virtual CefBaseRefCounted {
|
||||||
|
public:
|
||||||
|
virtual void OnWebKitInitialized(CefRefPtr<HumanAppRenderer> app) {}
|
||||||
|
|
||||||
|
virtual void OnBrowserCreated(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDictionaryValue> extra_info) {}
|
||||||
|
|
||||||
|
virtual void OnBrowserDestroyed(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser) {}
|
||||||
|
|
||||||
|
virtual CefRefPtr<CefLoadHandler> GetLoadHandler(
|
||||||
|
CefRefPtr<HumanAppRenderer> app) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnContextCreated(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) {}
|
||||||
|
|
||||||
|
virtual void OnContextReleased(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) {}
|
||||||
|
|
||||||
|
virtual void OnUncaughtException(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context,
|
||||||
|
CefRefPtr<CefV8Exception> exception,
|
||||||
|
CefRefPtr<CefV8StackTrace> stackTrace) {}
|
||||||
|
|
||||||
|
virtual void OnFocusedNodeChanged(CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefDOMNode> node) {}
|
||||||
|
|
||||||
|
virtual bool OnProcessMessageReceived(
|
||||||
|
CefRefPtr<HumanAppRenderer> app,
|
||||||
|
CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using DelegateSet = std::set<CefRefPtr<Delegate>>;
|
||||||
|
|
||||||
|
|
||||||
|
HumanAppRenderer();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void CreateDelegates(DelegateSet& delegates);
|
||||||
|
|
||||||
|
// CefApp methods.
|
||||||
|
CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() override {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CefRenderProcessHandler methods.
|
||||||
|
void OnWebKitInitialized() override;
|
||||||
|
void OnBrowserCreated(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefDictionaryValue> extra_info) override;
|
||||||
|
void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) override;
|
||||||
|
CefRefPtr<CefLoadHandler> GetLoadHandler() override;
|
||||||
|
void OnContextCreated(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) override;
|
||||||
|
void OnContextReleased(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context) override;
|
||||||
|
void OnUncaughtException(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefV8Context> context,
|
||||||
|
CefRefPtr<CefV8Exception> exception,
|
||||||
|
CefRefPtr<CefV8StackTrace> stackTrace) override;
|
||||||
|
void OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefRefPtr<CefDOMNode> node) override;
|
||||||
|
bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||||
|
CefRefPtr<CefFrame> frame,
|
||||||
|
CefProcessId source_process,
|
||||||
|
CefRefPtr<CefProcessMessage> message) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DelegateSet delegates_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(HumanAppRenderer);
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(HumanAppRenderer);
|
||||||
|
};
|
||||||
|
|
83
src/CEF/Main.cpp
Normal file
83
src/CEF/Main.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
#if 1
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
#include "Core/Core.h"
|
||||||
|
|
||||||
|
#include "include/cef_command_line.h"
|
||||||
|
#include "include/cef_sandbox_win.h"
|
||||||
|
#include "CEF/HumanAppBrowser.h"
|
||||||
|
#include "CEF/HumanAppRenderer.h"
|
||||||
|
#include "CEF/HumanAppOther.h"
|
||||||
|
|
||||||
|
|
||||||
|
static int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||||
|
_In_ LPWSTR lpCmdLine, _In_ int nCmdShow) {
|
||||||
|
Logger::Init();
|
||||||
|
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||||
|
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||||
|
|
||||||
|
// Enable High-DPI support on Windows 7 or newer.
|
||||||
|
CefEnableHighDPISupport();
|
||||||
|
|
||||||
|
void* sandbox_info = nullptr;
|
||||||
|
|
||||||
|
#if defined(CEF_USE_SANDBOX)
|
||||||
|
// Manage the life span of the sandbox information object. This is necessary
|
||||||
|
// for sandbox support on Windows. See cef_sandbox_win.h for complete details.
|
||||||
|
CefScopedSandboxInfo scoped_sandbox;
|
||||||
|
sandbox_info = scoped_sandbox.sandbox_info();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Provide CEF with command-line arguments.
|
||||||
|
CefMainArgs main_args(hInstance);
|
||||||
|
|
||||||
|
// CEF applications have multiple sub-processes (render, 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, nullptr, sandbox_info);
|
||||||
|
if (exit_code >= 0) {
|
||||||
|
// The sub-process has completed so return here.
|
||||||
|
return exit_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse command-line arguments for use in this method.
|
||||||
|
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
|
||||||
|
command_line->InitFromString(::GetCommandLineW());
|
||||||
|
|
||||||
|
// Specify CEF global settings here.
|
||||||
|
CefSettings settings;
|
||||||
|
|
||||||
|
if (command_line->HasSwitch("enable-chrome-runtime")) {
|
||||||
|
// Enable experimental Chrome runtime. See issue #2969 for details.
|
||||||
|
settings.chrome_runtime = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(CEF_USE_SANDBOX)
|
||||||
|
settings.no_sandbox = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SimpleApp implements application-level callbacks for the browser process.
|
||||||
|
// It will create the first browser instance in OnContextInitialized() after
|
||||||
|
// CEF has initialized.
|
||||||
|
CefRefPtr<CefApp> app;
|
||||||
|
HumanApp::ProcessType process_type = HumanApp::GetProcessType(command_line);
|
||||||
|
if (process_type == HumanApp::BrowserProcess)
|
||||||
|
app = new HumanAppBrowser();
|
||||||
|
else if (process_type == HumanApp::RendererProcess)
|
||||||
|
app = new HumanAppRenderer();
|
||||||
|
else if (process_type == HumanApp::OtherProcess)
|
||||||
|
app = new HumanAppOther();
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
90
src/CEF/RenderContent.h
Normal file
90
src/CEF/RenderContent.h
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/base/cef_logging.h"
|
||||||
|
#include "include/base/cef_macros.h"
|
||||||
|
|
||||||
|
// Default number of iterations.
|
||||||
|
extern const int kDefaultIterations;
|
||||||
|
|
||||||
|
// Test name.
|
||||||
|
#define PERF_TEST_NAME(name) PerfTest##name
|
||||||
|
|
||||||
|
// Entry in test array.
|
||||||
|
#define PERF_TEST_ENTRY_EX(name, iterations) \
|
||||||
|
{ #name, PERF_TEST_NAME(name), iterations }
|
||||||
|
#define PERF_TEST_ENTRY(name) PERF_TEST_ENTRY_EX(name, kDefaultIterations)
|
||||||
|
|
||||||
|
// Test function declaration.
|
||||||
|
#define PERF_TEST_RESULT int64
|
||||||
|
#define PERF_TEST_PARAM_ITERATIONS iterations
|
||||||
|
#define PERF_TEST_PARAMS int PERF_TEST_PARAM_ITERATIONS
|
||||||
|
#define PERF_TEST_FUNC(name) \
|
||||||
|
PERF_TEST_RESULT PERF_TEST_NAME(name)(PERF_TEST_PARAMS)
|
||||||
|
|
||||||
|
// Typedef for test pointers.
|
||||||
|
typedef PERF_TEST_RESULT(PerfTest(PERF_TEST_PARAMS));
|
||||||
|
|
||||||
|
class CefTimer {
|
||||||
|
public:
|
||||||
|
CefTimer() : running_(false) {}
|
||||||
|
|
||||||
|
bool IsRunning() {
|
||||||
|
return running_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
DCHECK(!running_);
|
||||||
|
running_ = true;
|
||||||
|
start_.Now();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stop() {
|
||||||
|
stop_.Now();
|
||||||
|
DCHECK(running_);
|
||||||
|
running_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64 Delta() {
|
||||||
|
DCHECK(!running_);
|
||||||
|
return start_.Delta(stop_);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool running_;
|
||||||
|
CefTime start_;
|
||||||
|
CefTime stop_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefTimer);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Peform test iterations using a user-provided timing result variable.
|
||||||
|
#define PERF_ITERATIONS_START_EX() \
|
||||||
|
{ \
|
||||||
|
CefTimer _timer; \
|
||||||
|
_timer.Start(); \
|
||||||
|
for (int _i = 0; _i < PERF_TEST_PARAM_ITERATIONS; ++_i) {
|
||||||
|
#define PERF_ITERATIONS_END_EX(result) \
|
||||||
|
} \
|
||||||
|
_timer.Stop(); \
|
||||||
|
result = _timer.Delta(); \
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform test iterations and return the timing result.
|
||||||
|
#define PERF_ITERATIONS_START() \
|
||||||
|
int64 _result = 0; \
|
||||||
|
PERF_ITERATIONS_START_EX()
|
||||||
|
|
||||||
|
#define PERF_ITERATIONS_END() \
|
||||||
|
PERF_ITERATIONS_END_EX(_result) \
|
||||||
|
return _result;
|
||||||
|
|
||||||
|
// Perf test entry structure.
|
||||||
|
struct PerfTestEntry {
|
||||||
|
const char* name;
|
||||||
|
PerfTest* test;
|
||||||
|
int iterations;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Array of perf tests.
|
||||||
|
extern const PerfTestEntry kPerfTests[];
|
||||||
|
extern const int kPerfTestsCount;
|
@ -9,11 +9,17 @@ FILE(GLOB_RECURSE CPP_FILES ./*.cpp)
|
|||||||
FILE(GLOB_RECURSE CC_FILES ./*.cc)
|
FILE(GLOB_RECURSE CC_FILES ./*.cc)
|
||||||
FILE(GLOB_RECURSE CC_FILES ./*.c)
|
FILE(GLOB_RECURSE CC_FILES ./*.c)
|
||||||
|
|
||||||
|
SET(
|
||||||
|
RC_FILE
|
||||||
|
cefsimple.rc
|
||||||
|
)
|
||||||
|
|
||||||
SET(
|
SET(
|
||||||
ALL_FILES
|
ALL_FILES
|
||||||
${HEADER_FILES}
|
${HEADER_FILES}
|
||||||
${CPP_FILES}
|
${CPP_FILES}
|
||||||
${CC_FILES}
|
${CC_FILES}
|
||||||
|
${RC_FILE}
|
||||||
)
|
)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
@ -87,13 +93,13 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${Proj
|
|||||||
TARGET_LINK_LIBRARIES(
|
TARGET_LINK_LIBRARIES(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
)
|
)
|
||||||
#
|
|
||||||
#add_custom_command(TARGET ${PROJECT_NAME}
|
add_custom_command(TARGET ${PROJECT_NAME}
|
||||||
# POST_BUILD
|
POST_BUILD
|
||||||
#
|
|
||||||
# COMMAND mt.exe
|
COMMAND mt.exe -nologo
|
||||||
# -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\${PROJECT_NAME}.manifest\"
|
-manifest \"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.exe.manifest\"
|
||||||
# -inputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"
|
\"${CMAKE_CURRENT_SOURCE_DIR}/compatibility.manifest\"
|
||||||
# -outputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"
|
-inputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"
|
||||||
#)
|
-outputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"
|
||||||
#
|
)
|
||||||
|
20
src/HumanRender.exe.manifest
Normal file
20
src/HumanRender.exe.manifest
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
|
||||||
|
<!--The compatibility section will be merged from build/win/compatibility.manifest -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||||
|
</dependentAssembly>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
|
<security>
|
||||||
|
<requestedPrivileges>
|
||||||
|
<requestedExecutionLevel level="asInvoker" />
|
||||||
|
</requestedPrivileges>
|
||||||
|
</security>
|
||||||
|
</trustInfo>
|
||||||
|
|
||||||
|
</assembly>
|
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|
||||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
|
||||||
<application>
|
|
||||||
<!--The ID below indicates application support for Windows 8.1 -->
|
|
||||||
<supportedOS Id="{886480BC-BF0D-4441-9749-6455CB4A8E47}"/>
|
|
||||||
<!-- 10.0 -->
|
|
||||||
<supportedOS Id="{886480BC-BF0D-4441-9749-6455CB4A8E47"/>
|
|
||||||
</application>
|
|
||||||
</compatibility>
|
|
||||||
</assembly>
|
|
@ -1,3 +1,4 @@
|
|||||||
|
#if 0
|
||||||
#if 1
|
#if 1
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
@ -188,3 +189,5 @@ static int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevI
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
79
src/cefsimple.rc
Normal file
79
src/cefsimple.rc
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
// Microsoft Visual C++ generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||||
|
#include "windows.h"
|
||||||
|
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (U.S.) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
#ifdef _WIN32
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
#pragma code_page(1252)
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Icon
|
||||||
|
//
|
||||||
|
|
||||||
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
|
// remains consistent on all systems.
|
||||||
|
IDI_CEFSIMPLE ICON "res\cefsimple.ico"
|
||||||
|
IDI_SMALL ICON "res\small.ico"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||||
|
"#include ""windows.h""\r\n"
|
||||||
|
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
#endif // English (U.S.) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
20
src/compatibility.manifest
Normal file
20
src/compatibility.manifest
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
|
<application>
|
||||||
|
<!--The ID below indicates application support for Windows Vista -->
|
||||||
|
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||||
|
<!--The ID below indicates application support for Windows 7 -->
|
||||||
|
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||||
|
<!--The ID below indicates application support for Windows 8 -->
|
||||||
|
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||||
|
<!--The ID below indicates application support for Windows 8.1 -->
|
||||||
|
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||||
|
<!--The ID below indicates application support for Windows 10 -->
|
||||||
|
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||||
|
<!-- This tag is required for XAML islands usage in the process for media scenarios. -->
|
||||||
|
<!-- This version corresponds to the Windows 10 May 2019 Update. -->
|
||||||
|
<maxversiontested Id="10.0.18362.0"/>
|
||||||
|
</application>
|
||||||
|
</compatibility>
|
||||||
|
</assembly>
|
BIN
src/res/cefsimple.ico
Normal file
BIN
src/res/cefsimple.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
src/res/small.ico
Normal file
BIN
src/res/small.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
26
src/resource.h
Normal file
26
src/resource.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) 2013 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.
|
||||||
|
|
||||||
|
//{{NO_DEPENDENCIES}}
|
||||||
|
// Microsoft Visual C++ generated include file.
|
||||||
|
// Used by cefsimple.rc
|
||||||
|
//
|
||||||
|
|
||||||
|
#define IDI_CEFSIMPLE 100
|
||||||
|
#define IDI_SMALL 101
|
||||||
|
|
||||||
|
// Avoid files associated with MacOS
|
||||||
|
#define _X86_
|
||||||
|
|
||||||
|
// Next default values for new objects
|
||||||
|
//
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
#define _APS_NO_MFC 1
|
||||||
|
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||||
|
#define _APS_NEXT_COMMAND_VALUE 32700
|
||||||
|
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||||
|
#define _APS_NEXT_SYMED_VALUE 102
|
||||||
|
#endif
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user