1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_GL_GL_VERSION_INFO_H_
6 #define UI_GL_GL_VERSION_INFO_H_
10 #include "base/basictypes.h"
11 #include "ui/gl/gl_export.h"
15 struct GL_EXPORT GLVersionInfo
{
16 GLVersionInfo(const char* version_str
, const char* renderer_str
,
17 const char* extensions_str
);
19 GLVersionInfo(const char* version_str
, const char* renderer_str
,
20 const std::set
<std::string
>& exts
);
22 bool IsAtLeastGL(unsigned major
, unsigned minor
) const {
23 return !is_es
&& (major_version
> major
||
24 (major_version
== major
&& minor_version
>= minor
));
27 bool IsLowerThanGL(unsigned major
, unsigned minor
) const {
28 return !is_es
&& (major_version
< major
||
29 (major_version
== major
&& minor_version
< minor
));
32 bool IsAtLeastGLES(unsigned major
, unsigned minor
) const {
33 return is_es
&& (major_version
> major
||
34 (major_version
== major
&& minor_version
>= minor
));
37 bool BehavesLikeGLES() const {
38 return is_es
|| is_desktop_core_profile
;
41 bool IsES3Capable() const {
42 if (IsAtLeastGLES(3, 0) || IsAtLeastGL(4, 2))
44 #if defined(OS_MACOSX)
45 // TODO(zmo): For experimentation purpose on MacOSX with core profile,
46 // allow 3.2 or plus for now.
47 if (IsAtLeastGL(3, 2))
53 static void ParseVersionString(const char* version_str
,
54 unsigned* major_version
,
55 unsigned* minor_version
,
61 unsigned major_version
;
62 unsigned minor_version
;
64 bool is_desktop_core_profile
;
67 GLVersionInfo(const char* version_str
, const char* renderer_str
);
69 DISALLOW_COPY_AND_ASSIGN(GLVersionInfo
);
74 #endif // UI_GL_GL_VERSION_INFO_H_