Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1125)

Unified Diff: content/browser/browser_main_loop.cc

Issue 2347383002: X11: Use better visuals for OpenGL (Closed)
Patch Set: auto* Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/gpu/gpu_internals_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_main_loop.cc
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index bbd8dd6992878c1d82fce50e13a7ebe5b62b03ad..df9c13aff6bd321822d5a47dffe0c22112fcdd06 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -71,6 +71,7 @@
#include "content/common/mojo/mojo_shell_connection_impl.h"
#include "content/public/browser/browser_main_parts.h"
#include "content/public/browser/content_browser_client.h"
+#include "content/public/browser/gpu_data_manager_observer.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/tracing_controller.h"
#include "content/public/common/content_client.h"
@@ -184,7 +185,6 @@
#include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "ui/base/x/x11_util_internal.h" // nogncheck
#include "ui/gfx/x/x11_connection.h" // nogncheck
-#include "ui/gfx/x/x11_switches.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck
#endif
@@ -365,6 +365,44 @@ base::win::MemoryPressureMonitor* CreateWinMemoryPressureMonitor(
} // namespace
+#if defined(USE_X11) && !defined(OS_CHROMEOS)
+namespace internal {
+
+// Forwards GPUInfo updates to ui::XVisualManager
+class GpuDataManagerVisualProxy : public GpuDataManagerObserver {
+ public:
+ explicit GpuDataManagerVisualProxy(GpuDataManagerImpl* gpu_data_manager)
+ : gpu_data_manager_(gpu_data_manager) {
+ gpu_data_manager_->AddObserver(this);
+ }
+
+ ~GpuDataManagerVisualProxy() override {
+ gpu_data_manager_->RemoveObserver(this);
+ }
+
+ void OnGpuInfoUpdate() override {
+ gpu::GPUInfo gpu_info = gpu_data_manager_->GetGPUInfo();
+ if (!ui::XVisualManager::GetInstance()->OnGPUInfoChanged(
+ gpu_info.software_rendering ||
+ !gpu_data_manager_->GpuAccessAllowed(nullptr),
+ gpu_info.system_visual, gpu_info.rgba_visual)) {
+ // The GPU process sent back bad visuals, which should never happen.
+ auto* gpu_process_host = GpuProcessHost::Get(
+ GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, false);
+ if (gpu_process_host)
+ gpu_process_host->ForceShutdown();
+ }
+ }
+
+ private:
+ GpuDataManagerImpl* gpu_data_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuDataManagerVisualProxy);
+};
+
+} // namespace internal
+#endif
+
// The currently-running BrowserMainLoop. There can be one or zero.
BrowserMainLoop* g_current_browser_main_loop = NULL;
@@ -746,30 +784,12 @@ int BrowserMainLoop::PreCreateThreads() {
// It's unsafe to append the gpu command line switches to the global
// CommandLine::ForCurrentProcess object after threads are created.
// 2) Must be after parts_->PreCreateThreads to pick up chrome://flags.
- GpuDataManagerImpl::GetInstance()->Initialize();
+ GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance();
+ gpu_data_manager->Initialize();
#if defined(USE_X11) && !defined(OS_CHROMEOS)
- // PreCreateThreads is called before CreateStartupTasks which starts the gpu
- // process.
- bool enable_transparent_visuals =
- !GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive(
- gpu::DISABLE_TRANSPARENT_VISUALS);
-
- // Prevent this flag to be turned off later since it is only used here.
- if (!enable_transparent_visuals &&
- !GpuDataManagerImpl::GetInstance()->IsCompleteGpuInfoAvailable()) {
- base::CommandLine::ForCurrentProcess()->AppendSwitch(
- "disable_transparent_visuals");
- }
-
- Visual* visual = NULL;
- int depth = 0;
- ui::ChooseVisualForWindow(enable_transparent_visuals, &visual, &depth);
- DCHECK(depth > 0);
- base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kWindowDepth, base::IntToString(depth));
- base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kX11VisualID, base::UintToString(visual->visualid));
+ gpu_data_manager_visual_proxy_.reset(
+ new internal::GpuDataManagerVisualProxy(gpu_data_manager));
#endif
#if !defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID)
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/gpu/gpu_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698