blob: 99b34dd1ce6e7936dd8bef30b3ac2a24d32d70f4 [file] [log] [blame]
Romain Guybd0e6aa2010-07-22 18:50:12 -07001/*
2 * Copyright (C) 2010 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
17#define LOG_TAG "OpenGLRenderer"
18
19#ifndef ANDROID_UI_EXTENSIONS_H
20#define ANDROID_UI_EXTENSIONS_H
21
22#include <utils/SortedVector.h>
23#include <utils/String8.h>
24
25#include <GLES2/gl2.h>
26#include <GLES2/gl2ext.h>
27
28namespace android {
29namespace uirenderer {
30
31class Extensions {
32public:
33 Extensions() {
34 const char* buffer = (const char*) glGetString(GL_EXTENSIONS);
35 const char* current = buffer;
36 const char* head = current;
37 do {
38 head = strchr(current, ' ');
39 String8 s(current, head ? head - current : strlen(current));
40 if (s.length()) {
41 mExtensionList.add(s);
42 }
43 current = head + 1;
44 } while (head);
45
46 mHasNPot = hasExtension("GL_OES_texture_npot");
Romain Guy51769a62010-07-23 00:28:00 -070047 mHasDrawPath = hasExtension("GL_NV_draw_path");
48 mHasCoverageSample = hasExtension("GL_NV_coverage_sample");
49
50 mExtensions = buffer;
Romain Guybd0e6aa2010-07-22 18:50:12 -070051 }
52
53 inline bool hasNPot() const { return mHasNPot; }
Romain Guy51769a62010-07-23 00:28:00 -070054 inline bool hasDrawPath() const { return mHasDrawPath; }
55 inline bool hasCoverageSample() const { return mHasCoverageSample; }
Romain Guybd0e6aa2010-07-22 18:50:12 -070056
57 bool hasExtension(const char* extension) const {
58 const String8 s(extension);
59 return mExtensionList.indexOf(s) >= 0;
60 }
61
Romain Guy51769a62010-07-23 00:28:00 -070062 void dump() {
63 LOGD("Supported extensions:\n%s", mExtensions);
64 }
65
Romain Guybd0e6aa2010-07-22 18:50:12 -070066private:
67 SortedVector<String8> mExtensionList;
68
Romain Guy51769a62010-07-23 00:28:00 -070069 const char* mExtensions;
70
Romain Guybd0e6aa2010-07-22 18:50:12 -070071 bool mHasNPot;
Romain Guy51769a62010-07-23 00:28:00 -070072 bool mHasDrawPath;
73 bool mHasCoverageSample;
Romain Guybd0e6aa2010-07-22 18:50:12 -070074}; // class Extensions
75
76}; // namespace uirenderer
77}; // namespace android
78
79#endif // ANDROID_UI_EXTENSIONS_H