blob: c3d244871ce453cd46d09db23ff9ed4b6618338d [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");
47 }
48
49 inline bool hasNPot() const { return mHasNPot; }
50
51 bool hasExtension(const char* extension) const {
52 const String8 s(extension);
53 return mExtensionList.indexOf(s) >= 0;
54 }
55
56private:
57 SortedVector<String8> mExtensionList;
58
59 bool mHasNPot;
60}; // class Extensions
61
62}; // namespace uirenderer
63}; // namespace android
64
65#endif // ANDROID_UI_EXTENSIONS_H