summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chromium/ui/gl/gl_context_cgl.cc14
-rw-r--r--chromium/ui/gl/gl_context_cgl.h4
-rw-r--r--chromium/ui/gl/init/gl_factory_mac.cc20
3 files changed, 29 insertions, 9 deletions
diff --git a/chromium/ui/gl/gl_context_cgl.cc b/chromium/ui/gl/gl_context_cgl.cc
index 7d4fc5d5279..02c0e34efc0 100644
--- a/chromium/ui/gl/gl_context_cgl.cc
+++ b/chromium/ui/gl/gl_context_cgl.cc
@@ -33,9 +33,9 @@ bool g_support_renderer_switching;
} // namespace
-static CGLPixelFormatObj GetPixelFormat() {
+static CGLPixelFormatObj GetPixelFormat(const int core_profile = 0) {
static CGLPixelFormatObj format;
- if (format)
+ if (format && core_profile == 0)
return format;
std::vector<CGLPixelFormatAttribute> attribs;
// If the system supports dual gpus then allow offline renderers for every
@@ -53,9 +53,8 @@ static CGLPixelFormatObj GetPixelFormat() {
// These constants don't exist in the 10.6 SDK against which
// Chromium currently compiles.
const int kOpenGLProfile = 99;
- const int kOpenGL3_2Core = 0x3200;
attribs.push_back(static_cast<CGLPixelFormatAttribute>(kOpenGLProfile));
- attribs.push_back(static_cast<CGLPixelFormatAttribute>(kOpenGL3_2Core));
+ attribs.push_back(static_cast<CGLPixelFormatAttribute>(core_profile));
}
attribs.push_back((CGLPixelFormatAttribute) 0);
@@ -75,8 +74,9 @@ static CGLPixelFormatObj GetPixelFormat() {
return format;
}
-GLContextCGL::GLContextCGL(GLShareGroup* share_group)
- : GLContextReal(share_group) {}
+GLContextCGL::GLContextCGL(GLShareGroup* share_group, int core_profile_number)
+ : GLContextReal(share_group)
+ , core_profile_number_(core_profile_number) {}
bool GLContextCGL::Initialize(GLSurface* compatible_surface,
const GLContextAttribs& attribs) {
@@ -93,7 +93,7 @@ bool GLContextCGL::Initialize(GLSurface* compatible_surface,
GLContextCGL* share_context = share_group() ?
static_cast<GLContextCGL*>(share_group()->GetContext()) : nullptr;
- CGLPixelFormatObj format = GetPixelFormat();
+ CGLPixelFormatObj format = GetPixelFormat(core_profile_number_);
if (!format)
return false;
diff --git a/chromium/ui/gl/gl_context_cgl.h b/chromium/ui/gl/gl_context_cgl.h
index c0aa656a306..966cc291d04 100644
--- a/chromium/ui/gl/gl_context_cgl.h
+++ b/chromium/ui/gl/gl_context_cgl.h
@@ -23,7 +23,7 @@ class GLSurface;
// Encapsulates a CGL OpenGL context.
class GL_EXPORT GLContextCGL : public GLContextReal {
public:
- explicit GLContextCGL(GLShareGroup* share_group);
+ explicit GLContextCGL(GLShareGroup* share_group, int core_profile_number = 0);
// Implement GLContext.
bool Initialize(GLSurface* compatible_surface,
@@ -64,6 +64,8 @@ class GL_EXPORT GLContextCGL : public GLContextReal {
// Debugging for https://crbug.com/863817
bool has_switched_gpus_ = false;
+ int core_profile_number_ = 0;
+
DISALLOW_COPY_AND_ASSIGN(GLContextCGL);
};
diff --git a/chromium/ui/gl/init/gl_factory_mac.cc b/chromium/ui/gl/init/gl_factory_mac.cc
index a084ec60985..c142ff75dfa 100644
--- a/chromium/ui/gl/init/gl_factory_mac.cc
+++ b/chromium/ui/gl/init/gl_factory_mac.cc
@@ -58,6 +58,8 @@ class NoOpGLSurface : public GLSurface {
DISALLOW_COPY_AND_ASSIGN(NoOpGLSurface);
};
+const int kOpenGL3_2Core = 0x3200;
+const int kOpenGL4_1Core = 0x4100;
} // namespace
std::vector<GLImplementation> GetAllowedGLImplementations() {
@@ -76,16 +78,32 @@ bool GetGLWindowSystemBindingInfo(GLWindowSystemBindingInfo* info) {
return false;
}
+scoped_refptr<GLContext> tryCreateCoreProfileContext(GLShareGroup* share_group,
+ GLSurface* compatible_surface,
+ const GLContextAttribs& attribs) {
+ scoped_refptr<GLContext> context = InitializeGLContext(new GLContextCGL(share_group,
+ kOpenGL4_1Core),
+ compatible_surface, attribs);
+ if (context != nullptr)
+ return context;
+
+ return InitializeGLContext(new GLContextCGL(share_group, kOpenGL3_2Core),
+ compatible_surface, attribs);
+}
+
scoped_refptr<GLContext> CreateGLContext(GLShareGroup* share_group,
GLSurface* compatible_surface,
const GLContextAttribs& attribs) {
TRACE_EVENT0("gpu", "gl::init::CreateGLContext");
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL:
- case kGLImplementationDesktopGLCoreProfile:
case kGLImplementationAppleGL:
return InitializeGLContext(new GLContextCGL(share_group),
compatible_surface, attribs);
+ case kGLImplementationDesktopGLCoreProfile:
+ return tryCreateCoreProfileContext(share_group,
+ compatible_surface, attribs);
+
#if BUILDFLAG(USE_EGL_ON_MAC)
case kGLImplementationEGLGLES2:
case kGLImplementationSwiftShaderGL: