blob: 7778290cf95278f946c8367dcb7af620330667a6 [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
Romain Guybd0e6aa2010-07-22 18:50:12 -070017#ifndef ANDROID_UI_EXTENSIONS_H
18#define ANDROID_UI_EXTENSIONS_H
19
20#include <utils/SortedVector.h>
21#include <utils/String8.h>
22
23#include <GLES2/gl2.h>
24#include <GLES2/gl2ext.h>
25
26namespace android {
27namespace uirenderer {
28
29class Extensions {
30public:
31 Extensions() {
32 const char* buffer = (const char*) glGetString(GL_EXTENSIONS);
33 const char* current = buffer;
34 const char* head = current;
35 do {
36 head = strchr(current, ' ');
37 String8 s(current, head ? head - current : strlen(current));
38 if (s.length()) {
39 mExtensionList.add(s);
40 }
41 current = head + 1;
42 } while (head);
43
44 mHasNPot = hasExtension("GL_OES_texture_npot");
Romain Guy51769a62010-07-23 00:28:00 -070045 mHasDrawPath = hasExtension("GL_NV_draw_path");
46 mHasCoverageSample = hasExtension("GL_NV_coverage_sample");
47
48 mExtensions = buffer;
Romain Guybd0e6aa2010-07-22 18:50:12 -070049 }
50
51 inline bool hasNPot() const { return mHasNPot; }
Romain Guy51769a62010-07-23 00:28:00 -070052 inline bool hasDrawPath() const { return mHasDrawPath; }
53 inline bool hasCoverageSample() const { return mHasCoverageSample; }
Romain Guybd0e6aa2010-07-22 18:50:12 -070054
55 bool hasExtension(const char* extension) const {
56 const String8 s(extension);
57 return mExtensionList.indexOf(s) >= 0;
58 }
59
Romain Guy51769a62010-07-23 00:28:00 -070060 void dump() {
61 LOGD("Supported extensions:\n%s", mExtensions);
62 }
63
Romain Guybd0e6aa2010-07-22 18:50:12 -070064private:
65 SortedVector<String8> mExtensionList;
66
Romain Guy51769a62010-07-23 00:28:00 -070067 const char* mExtensions;
68
Romain Guybd0e6aa2010-07-22 18:50:12 -070069 bool mHasNPot;
Romain Guy51769a62010-07-23 00:28:00 -070070 bool mHasDrawPath;
71 bool mHasCoverageSample;
Romain Guybd0e6aa2010-07-22 18:50:12 -070072}; // class Extensions
73
74}; // namespace uirenderer
75}; // namespace android
76
77#endif // ANDROID_UI_EXTENSIONS_H