Extensions.h revision 51769a68a5cb34e9564740c6a854fcb93018789d
1/* 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 mHasDrawPath = hasExtension("GL_NV_draw_path"); 48 mHasCoverageSample = hasExtension("GL_NV_coverage_sample"); 49 50 mExtensions = buffer; 51 } 52 53 inline bool hasNPot() const { return mHasNPot; } 54 inline bool hasDrawPath() const { return mHasDrawPath; } 55 inline bool hasCoverageSample() const { return mHasCoverageSample; } 56 57 bool hasExtension(const char* extension) const { 58 const String8 s(extension); 59 return mExtensionList.indexOf(s) >= 0; 60 } 61 62 void dump() { 63 LOGD("Supported extensions:\n%s", mExtensions); 64 } 65 66private: 67 SortedVector<String8> mExtensionList; 68 69 const char* mExtensions; 70 71 bool mHasNPot; 72 bool mHasDrawPath; 73 bool mHasCoverageSample; 74}; // class Extensions 75 76}; // namespace uirenderer 77}; // namespace android 78 79#endif // ANDROID_UI_EXTENSIONS_H 80