+void CEFCapture::reload()
+{
+ post_to_cef_ui_thread([this] {
+ loaded = false;
+ browser->Reload();
+ });
+}
+
+void CEFCapture::set_max_fps(int max_fps)
+{
+ post_to_cef_ui_thread([this, max_fps] {
+ browser->GetHost()->SetWindowlessFrameRate(max_fps);
+ this->max_fps = max_fps;
+ });
+}
+
+void CEFCapture::execute_javascript_async(const string &js)
+{
+ post_to_cef_ui_thread([this, js] {
+ if (loaded) {
+ CefString script_url("<theme eval>");
+ int start_line = 1;
+ browser->GetMainFrame()->ExecuteJavaScript(js, script_url, start_line);
+ } else {
+ deferred_javascript.push_back(js);
+ }
+ });
+}
+
+void CEFCapture::resize(unsigned width, unsigned height)
+{
+ lock_guard<mutex> lock(resolution_mutex);
+ this->width = width;
+ this->height = height;
+}
+
+void CEFCapture::request_new_frame()
+{
+ // By adding a delay, we make sure we don't get a new frame
+ // delivered immediately (we probably already are on the UI thread),
+ // where we couldn't really deal with it.
+ post_to_cef_ui_thread([this] {
+ lock_guard<recursive_mutex> lock(browser_mutex);
+ if (browser != nullptr) { // Could happen if we are shutting down.
+ browser->GetHost()->Invalidate(PET_VIEW);
+ }
+ }, 16);
+}
+