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

Unified Diff: ui/gl/gl_surface_mac.cc

Issue 2024953002: Move GL one-off initialization code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@split_x11
Patch Set: Delete GLInitializer class. Created 4 years, 6 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 | « ui/gl/gl_surface_android.cc ('k') | ui/gl/gl_surface_ozone.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_surface_mac.cc
diff --git a/ui/gl/gl_surface_mac.cc b/ui/gl/gl_surface_mac.cc
index d4ccaef3371c738d2bd3004a4e1c6a77ccc0bc8c..f38f6dc64538d7e7ec3f84751d1516f778a56e97 100644
--- a/ui/gl/gl_surface_mac.cc
+++ b/ui/gl/gl_surface_mac.cc
@@ -4,8 +4,6 @@
#include "ui/gl/gl_surface.h"
-#include <OpenGL/CGLRenderers.h>
-
#include <memory>
#include "base/logging.h"
@@ -17,7 +15,6 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_osmesa.h"
#include "ui/gl/gl_surface_stub.h"
-#include "ui/gl/gpu_switching_manager.h"
namespace gl {
namespace {
@@ -52,64 +49,8 @@ class GL_EXPORT NoOpGLSurface : public GLSurface {
DISALLOW_COPY_AND_ASSIGN(NoOpGLSurface);
};
-// static
-bool InitializeOneOffForSandbox() {
- static bool initialized = false;
- if (initialized)
- return true;
-
- // This is called from the sandbox warmup code on Mac OS X.
- // GPU-related stuff is very slow without this, probably because
- // the sandbox prevents loading graphics drivers or some such.
- std::vector<CGLPixelFormatAttribute> attribs;
- if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
- // Avoid switching to the discrete GPU just for this pixel
- // format selection.
- attribs.push_back(kCGLPFAAllowOfflineRenderers);
- }
- if (GetGLImplementation() == kGLImplementationAppleGL) {
- attribs.push_back(kCGLPFARendererID);
- attribs.push_back(static_cast<CGLPixelFormatAttribute>(
- kCGLRendererGenericFloatID));
- }
- attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
-
- CGLPixelFormatObj format;
- GLint num_pixel_formats;
- if (CGLChoosePixelFormat(&attribs.front(),
- &format,
- &num_pixel_formats) != kCGLNoError) {
- LOG(ERROR) << "Error choosing pixel format.";
- return false;
- }
- if (!format) {
- LOG(ERROR) << "format == 0.";
- return false;
- }
- CGLReleasePixelFormat(format);
- DCHECK_NE(num_pixel_formats, 0);
- initialized = true;
- return true;
-}
-
} // namespace
-bool GLSurface::InitializeOneOffInternal() {
- switch (GetGLImplementation()) {
- case kGLImplementationDesktopGL:
- case kGLImplementationDesktopGLCoreProfile:
- case kGLImplementationAppleGL:
- if (!InitializeOneOffForSandbox()) {
- LOG(ERROR) << "GLSurfaceCGL::InitializeOneOff failed.";
- return false;
- }
- break;
- default:
- break;
- }
- return true;
-}
-
scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
gfx::AcceleratedWidget window) {
TRACE_EVENT0("gpu", "GLSurface::CreateViewGLSurface");
« no previous file with comments | « ui/gl/gl_surface_android.cc ('k') | ui/gl/gl_surface_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698