blob: 06c8a21b019bceeeca58162f7b3cee1727daebca [file] [log] [blame]
Romain Guy3bbacf22013-02-06 16:51:04 -08001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Chris Craik117bdbc2015-02-05 10:12:38 -080017#include "Extensions.h"
18
19#include "Debug.h"
20#include "Properties.h"
Chris Craik6e6646c2015-09-14 15:54:12 -070021#include "utils/StringUtils.h"
Romain Guye9bc11f2013-05-23 12:47:26 -070022
Chris Craik117bdbc2015-02-05 10:12:38 -080023#include <GLES2/gl2ext.h>
Romain Guye9bc11f2013-05-23 12:47:26 -070024#include <utils/Log.h>
25
Romain Guy3bbacf22013-02-06 16:51:04 -080026namespace android {
Romain Guy3bbacf22013-02-06 16:51:04 -080027namespace uirenderer {
28
Romain Guy3bbacf22013-02-06 16:51:04 -080029// Debug
30#if DEBUG_EXTENSIONS
31 #define EXT_LOGD(...) ALOGD(__VA_ARGS__)
32#else
33 #define EXT_LOGD(...)
34#endif
35
Romain Guy3bbacf22013-02-06 16:51:04 -080036
Chris Craik117bdbc2015-02-05 10:12:38 -080037Extensions::Extensions() {
Chris Craik6e6646c2015-09-14 15:54:12 -070038 StringCollection extensions((const char*) glGetString(GL_EXTENSIONS));
39 mHasNPot = extensions.has("GL_OES_texture_npot");
40 mHasFramebufferFetch = extensions.has("GL_NV_shader_framebuffer_fetch");
41 mHasDiscardFramebuffer = extensions.has("GL_EXT_discard_framebuffer");
42 mHasDebugMarker = extensions.has("GL_EXT_debug_marker");
43 mHas1BitStencil = extensions.has("GL_OES_stencil1");
44 mHas4BitStencil = extensions.has("GL_OES_stencil4");
45 mHasUnpackSubImage = extensions.has("GL_EXT_unpack_subimage");
Romain Guy3bbacf22013-02-06 16:51:04 -080046
Romain Guydf1dc282013-03-29 18:32:29 -070047 const char* version = (const char*) glGetString(GL_VERSION);
Romain Guydf1dc282013-03-29 18:32:29 -070048
49 // Section 6.1.5 of the OpenGL ES specification indicates the GL version
50 // string strictly follows this format:
51 //
52 // OpenGL<space>ES<space><version number><space><vendor-specific information>
53 //
54 // In addition section 6.1.5 describes the version number thusly:
55 //
56 // "The version number is either of the form major number.minor number or
57 // major number.minor number.release number, where the numbers all have one
58 // or more digits. The release number and vendor specific information are
59 // optional."
60
Romain Guy6cad7572013-07-24 11:49:33 -070061 if (sscanf(version, "OpenGL ES %d.%d", &mVersionMajor, &mVersionMinor) != 2) {
Romain Guydf1dc282013-03-29 18:32:29 -070062 // If we cannot parse the version number, assume OpenGL ES 2.0
63 mVersionMajor = 2;
64 mVersionMinor = 0;
65 }
Romain Guy3bbacf22013-02-06 16:51:04 -080066}
67
Romain Guy3bbacf22013-02-06 16:51:04 -080068}; // namespace uirenderer
69}; // namespace android