Merge pull request #202 from atom/fix-acclerated-composition

Enable accelerated composition in normal window
This commit is contained in:
Cheng Zhao 2014-03-06 04:25:43 +00:00
commit f9c5d0796c
4 changed files with 48 additions and 14 deletions

View file

@ -70,10 +70,6 @@ void AtomMainDelegate::PreSandboxStartup() {
// Disable renderer sandbox for most of node's functions.
command_line->AppendSwitch(switches::kNoSandbox);
// Disable accelerated compositing since it caused a lot of troubles (black
// devtools, screen flashes) and needed lots of effort to make it right.
command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
// Add a flag to mark the end of switches added by atom-shell.
command_line->AppendSwitch("atom-shell-switches-end");
}

View file

@ -4,14 +4,13 @@
#include "browser/atom_browser_client.h"
#include "base/command_line.h"
#include "browser/atom_browser_context.h"
#include "browser/atom_browser_main_parts.h"
#include "browser/native_window.h"
#include "browser/net/atom_url_request_context_getter.h"
#include "browser/window_list.h"
#include "common/options_switches.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "webkit/common/webpreferences.h"
@ -69,6 +68,12 @@ void AtomBrowserClient::OverrideWebkitPrefs(
prefs->experimental_webgl_enabled = false;
prefs->allow_displaying_insecure_content = true;
prefs->allow_running_insecure_content = true;
NativeWindow* window = NativeWindow::FromRenderView(
render_view_host->GetProcess()->GetID(),
render_view_host->GetRoutingID());
if (window)
window->OverrideWebkitPrefs(url, prefs);
}
bool AtomBrowserClient::ShouldSwapProcessesForNavigation(
@ -105,10 +110,8 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
window = *iter;
}
// Append --node-integration to renderer process.
if (window != NULL)
command_line->AppendSwitchASCII(switches::kNodeIntegration,
window->node_integration());
window->AppendExtraCommandLineSwitches(command_line, child_process_id);
dying_render_process_ = NULL;
}

View file

@ -6,14 +6,13 @@
#include <string>
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/prefs/pref_service.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "browser/api/atom_browser_bindings.h"
#include "browser/atom_browser_context.h"
#include "browser/atom_browser_main_parts.h"
@ -30,6 +29,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/renderer_preferences.h"
#include "common/api/api_messages.h"
#include "common/atom_version.h"
@ -39,7 +39,10 @@
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "vendor/brightray/browser/inspectable_web_contents.h"
#include "vendor/brightray/browser/inspectable_web_contents_view.h"
#include "webkit/common/user_agent/user_agent_util.h"
#include "webkit/common/webpreferences.h"
using content::NavigationEntry;
@ -63,6 +66,12 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
brightray::InspectableWebContents::Create(web_contents)) {
options->GetBoolean(switches::kFrame, &has_frame_);
#if defined(OS_MACOSX)
// Temporary fix for flashing devtools, try removing this after upgraded to
// Chrome 32.
web_contents->GetView()->SetAllowOverlappingViews(false);
#endif
// Read icon before window is created.
std::string icon;
if (options->GetString(switches::kIcon, &icon) && !SetIcon(icon))
@ -181,10 +190,16 @@ bool NativeWindow::HasModalDialog() {
}
void NativeWindow::OpenDevTools() {
if (devtools_window_)
if (devtools_window_) {
devtools_window_->Focus(true);
else
} else {
inspectable_web_contents()->ShowDevTools();
#if defined(OS_MACOSX)
// Temporary fix for flashing devtools, try removing this after upgraded to
// Chrome 32.
GetDevToolsWebContents()->GetView()->SetAllowOverlappingViews(false);
#endif
}
}
void NativeWindow::CloseDevTools() {
@ -298,6 +313,19 @@ content::WebContents* NativeWindow::GetDevToolsWebContents() const {
return inspectable_web_contents()->devtools_web_contents();
}
void NativeWindow::AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id) {
// Append --node-integration to renderer process.
command_line->AppendSwitchASCII(switches::kNodeIntegration,
node_integration_);
}
void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) {
// FIXME Disable accelerated composition in frameless window.
if (!has_frame_)
prefs->accelerated_compositing_enabled = false;
}
void NativeWindow::NotifyWindowClosed() {
if (is_closed_)
return;

View file

@ -19,6 +19,9 @@
#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
class CommandLine;
struct WebPreferences;
namespace base {
class DictionaryValue;
class ListValue;
@ -160,6 +163,11 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
content::WebContents* GetWebContents() const;
content::WebContents* GetDevToolsWebContents() const;
// Called when renderer process is going to be started.
void AppendExtraCommandLineSwitches(CommandLine* command_line,
int child_process_id);
void OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs);
void AddObserver(NativeWindowObserver* obs) {
observers_.AddObserver(obs);
}
@ -169,7 +177,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
}
bool has_frame() const { return has_frame_; }
std::string node_integration() const { return node_integration_; }
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;