Commit 029dad3f authored by bajones@chromium.org's avatar bajones@chromium.org

Updated OSX to blacklist multisampling when multiple monitors are connected

BUG=237931
R=joi@chromium.org, kbr@chromium.org, zmo@chromium.org

Review URL: https://codereview.chromium.org/14947002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203827 0039d316-1c4b-4281-b951-d872f2087c98
parent e81a0354
......@@ -233,6 +233,16 @@ size_t GpuDataManagerImpl::GetBlacklistedFeatureCount() const {
return private_->GetBlacklistedFeatureCount();
}
void GpuDataManagerImpl::SetDisplayCount(unsigned int display_count) {
base::AutoLock auto_lock(lock_);
private_->SetDisplayCount(display_count);
}
unsigned int GpuDataManagerImpl::GetDisplayCount() const {
base::AutoLock auto_lock(lock_);
return private_->GetDisplayCount();
}
void GpuDataManagerImpl::Notify3DAPIBlocked(const GURL& url,
int render_process_id,
int render_view_id,
......
......@@ -169,6 +169,9 @@ class CONTENT_EXPORT GpuDataManagerImpl
// Get number of features being blacklisted.
size_t GetBlacklistedFeatureCount() const;
void SetDisplayCount(unsigned int display_count);
unsigned int GetDisplayCount() const;
private:
friend class GpuDataManagerImplPrivate;
friend class GpuDataManagerImplPrivateTest;
......
......@@ -217,12 +217,25 @@ std::string IntSetToString(const std::set<int>& list) {
void DisplayReconfigCallback(CGDirectDisplayID display,
CGDisplayChangeSummaryFlags flags,
void* gpu_data_manager) {
if (flags & kCGDisplayAddFlag) {
GpuDataManagerImpl* manager =
reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager);
DCHECK(manager);
manager->HandleGpuSwitch();
if(flags == kCGDisplayBeginConfigurationFlag)
return; // This call contains no information about the display change
GpuDataManagerImpl* manager =
reinterpret_cast<GpuDataManagerImpl*>(gpu_data_manager);
DCHECK(manager);
uint32_t displayCount;
CGGetActiveDisplayList(0, NULL, &displayCount);
bool fireGpuSwitch = flags & kCGDisplayAddFlag;
if (displayCount != manager->GetDisplayCount()) {
manager->SetDisplayCount(displayCount);
fireGpuSwitch = true;
}
if (fireGpuSwitch)
manager->HandleGpuSwitch();
}
#endif // OS_MACOSX
......@@ -343,6 +356,14 @@ size_t GpuDataManagerImplPrivate::GetBlacklistedFeatureCount() const {
return blacklisted_features_.size();
}
void GpuDataManagerImplPrivate::SetDisplayCount(unsigned int display_count) {
display_count_ = display_count;
}
unsigned int GpuDataManagerImplPrivate::GetDisplayCount() const {
return display_count_;
}
gpu::GPUInfo GpuDataManagerImplPrivate::GetGPUInfo() const {
return gpu_info_;
}
......@@ -751,7 +772,8 @@ void GpuDataManagerImplPrivate::UpdateRendererWebPrefs(
prefs->flash_stage3d_baseline_enabled = false;
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS))
prefs->accelerated_2d_canvas_enabled = false;
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING))
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_MULTISAMPLING)
|| display_count_ > 1)
prefs->gl_multisampling_enabled = false;
if (IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_3D_CSS)) {
prefs->accelerated_compositing_for_3d_transforms_enabled = false;
......@@ -915,7 +937,8 @@ GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(
update_histograms_(true),
window_count_(0),
domain_blocking_enabled_(true),
owner_(owner) {
owner_(owner),
display_count_(0) {
DCHECK(owner_);
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
......@@ -934,6 +957,7 @@ GpuDataManagerImplPrivate::GpuDataManagerImplPrivate(
}
#if defined(OS_MACOSX)
CGGetActiveDisplayList (0, NULL, &display_count_);
CGDisplayRegisterReconfigurationCallback(DisplayReconfigCallback, owner_);
#endif // OS_MACOSX
}
......
......@@ -105,6 +105,9 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
size_t GetBlacklistedFeatureCount() const;
void SetDisplayCount(unsigned int display_count);
unsigned int GetDisplayCount() const;
virtual ~GpuDataManagerImplPrivate();
private:
......@@ -233,6 +236,8 @@ class CONTENT_EXPORT GpuDataManagerImplPrivate {
GpuDataManagerImpl* owner_;
unsigned int display_count_;
DISALLOW_COPY_AND_ASSIGN(GpuDataManagerImplPrivate);
};
......
......@@ -396,7 +396,8 @@ RenderProcessHostImpl::RenderProcessHostImpl(
dummy_shutdown_event_(false, false),
#endif
supports_browser_plugin_(supports_browser_plugin),
is_guest_(is_guest) {
is_guest_(is_guest),
gpu_observer_registered_(false) {
widget_helper_ = new RenderWidgetHelper();
ChildProcessSecurityPolicyImpl::GetInstance()->Add(GetID());
......@@ -425,6 +426,11 @@ RenderProcessHostImpl::~RenderProcessHostImpl() {
DCHECK(!run_renderer_in_process());
ChildProcessSecurityPolicyImpl::GetInstance()->Remove(GetID());
if (gpu_observer_registered_) {
GpuDataManagerImpl::GetInstance()->RemoveObserver(this);
gpu_observer_registered_ = false;
}
// We may have some unsent messages at this point, but that's OK.
channel_.reset();
while (!queued_messages_.empty()) {
......@@ -548,6 +554,11 @@ bool RenderProcessHostImpl::Init() {
fast_shutdown_started_ = false;
}
if (!gpu_observer_registered_) {
gpu_observer_registered_ = true;
GpuDataManagerImpl::GetInstance()->AddObserver(this);
}
is_initialized_ = true;
return true;
}
......@@ -1774,4 +1785,20 @@ void RenderProcessHostImpl::OnCompositorSurfaceBuffersSwappedNoHost(
ack_params);
}
void RenderProcessHostImpl::OnGpuSwitching() {
for (RenderWidgetHostsIterator iter = GetRenderWidgetHostsIterator();
!iter.IsAtEnd();
iter.Advance()) {
const RenderWidgetHost* widget = iter.GetCurrentValue();
DCHECK(widget);
if (!widget || !widget->IsRenderView())
continue;
RenderViewHost* rvh =
RenderViewHost::From(const_cast<RenderWidgetHost*>(widget));
rvh->UpdateWebkitPreferences(rvh->GetWebkitPreferences());
}
}
} // namespace content
......@@ -15,6 +15,7 @@
#include "base/timer.h"
#include "content/browser/child_process_launcher.h"
#include "content/common/content_export.h"
#include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/browser/render_process_host.h"
#include "ipc/ipc_channel_proxy.h"
#include "ui/surface/transport_dib.h"
......@@ -62,7 +63,8 @@ class StoragePartitionImpl;
// to access the partition they are assigned to.
class CONTENT_EXPORT RenderProcessHostImpl
: public RenderProcessHost,
public ChildProcessLauncher::Client {
public ChildProcessLauncher::Client,
public GpuDataManagerObserver {
public:
RenderProcessHostImpl(BrowserContext* browser_context,
StoragePartitionImpl* storage_partition_impl,
......@@ -235,6 +237,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
// Handle termination of our process.
void ProcessDied(bool already_dead);
virtual void OnGpuSwitching() OVERRIDE;
// The count of currently visible widgets. Since the host can be a container
// for multiple widgets, it uses this count to determine when it should be
// backgrounded.
......@@ -327,6 +331,10 @@ class CONTENT_EXPORT RenderProcessHostImpl
// and PeerConnectionTracker in the renderer process.
scoped_refptr<PeerConnectionTrackerHost> peer_connection_tracker_host_;
// Prevents the class from being added as a GpuDataManagerImpl observer more
// than once.
bool gpu_observer_registered_;
DISALLOW_COPY_AND_ASSIGN(RenderProcessHostImpl);
};
......
......@@ -16,7 +16,7 @@ namespace content {
// Observers can register themselves via GpuDataManager::AddObserver, and
// can un-register with GpuDataManager::RemoveObserver.
class GpuDataManagerObserver {
class CONTENT_EXPORT GpuDataManagerObserver {
public:
// Called for any observers whenever there is a GPU info update.
virtual void OnGpuInfoUpdate() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment