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