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

Unified Diff: ui/gl/gpu_switching_manager.cc

Issue 786123002: Update from https://crrev.com/307330 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 | « ui/gl/gpu_switching_manager.h ('k') | url/gurl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gpu_switching_manager.cc
diff --git a/ui/gl/gpu_switching_manager.cc b/ui/gl/gpu_switching_manager.cc
index f9046291d3a8dbae46a5edb6a92e58d858528d38..020592f20da4356777f4e6a8410844e5eaa8c17e 100644
--- a/ui/gl/gpu_switching_manager.cc
+++ b/ui/gl/gpu_switching_manager.cc
@@ -9,12 +9,19 @@
#include "ui/gl/gl_switches.h"
#if defined(OS_MACOSX)
+#include <OpenGL/OpenGL.h>
#include "base/mac/mac_util.h"
#include "ui/gl/gl_context_cgl.h"
#endif // OS_MACOSX
namespace ui {
+struct GpuSwitchingManager::PlatformSpecific {
+#if defined(OS_MACOSX)
+ CGLPixelFormatObj discrete_pixel_format;
+#endif // OS_MACOSX
+};
+
// static
GpuSwitchingManager* GpuSwitchingManager::GetInstance() {
return Singleton<GpuSwitchingManager>::get();
@@ -25,16 +32,17 @@ GpuSwitchingManager::GpuSwitchingManager()
gpu_switching_option_set_(false),
supports_dual_gpus_(false),
supports_dual_gpus_set_(false),
- gpu_count_(0) {
+ gpu_count_(0),
+ platform_specific_(new PlatformSpecific) {
#if defined(OS_MACOSX)
- discrete_pixel_format_ = NULL;
+ platform_specific_->discrete_pixel_format = nullptr;
#endif // OS_MACOSX
}
GpuSwitchingManager::~GpuSwitchingManager() {
#if defined(OS_MACOSX)
- if (discrete_pixel_format_)
- CGLReleasePixelFormat(discrete_pixel_format_);
+ if (platform_specific_->discrete_pixel_format)
+ CGLReleasePixelFormat(platform_specific_->discrete_pixel_format);
#endif // OS_MACOSX
}
@@ -123,12 +131,13 @@ gfx::GpuPreference GpuSwitchingManager::AdjustGpuPreference(
#if defined(OS_MACOSX)
void GpuSwitchingManager::SwitchToDiscreteGpuMac() {
- if (discrete_pixel_format_)
+ if (platform_specific_->discrete_pixel_format)
return;
CGLPixelFormatAttribute attribs[1];
attribs[0] = static_cast<CGLPixelFormatAttribute>(0);
GLint num_pixel_formats = 0;
- CGLChoosePixelFormat(attribs, &discrete_pixel_format_, &num_pixel_formats);
+ CGLChoosePixelFormat(attribs, &platform_specific_->discrete_pixel_format,
+ &num_pixel_formats);
}
#endif // OS_MACOSX
« no previous file with comments | « ui/gl/gpu_switching_manager.h ('k') | url/gurl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698