Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 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 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_HWUI_EXTENSIONS_H |
| 18 | #define ANDROID_HWUI_EXTENSIONS_H |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 19 | |
| 20 | #include <utils/SortedVector.h> |
| 21 | #include <utils/String8.h> |
| 22 | |
| 23 | #include <GLES2/gl2.h> |
| 24 | #include <GLES2/gl2ext.h> |
| 25 | |
Romain Guy | a60c388 | 2011-08-01 15:28:16 -0700 | [diff] [blame] | 26 | #include "Debug.h" |
| 27 | |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 28 | namespace android { |
| 29 | namespace uirenderer { |
| 30 | |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 31 | /////////////////////////////////////////////////////////////////////////////// |
| 32 | // Defines |
| 33 | /////////////////////////////////////////////////////////////////////////////// |
| 34 | |
| 35 | // Debug |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 36 | #if DEBUG_EXTENSIONS |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 37 | #define EXT_LOGD(...) ALOGD(__VA_ARGS__) |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 38 | #else |
| 39 | #define EXT_LOGD(...) |
| 40 | #endif |
| 41 | |
Romain Guy | a60c388 | 2011-08-01 15:28:16 -0700 | [diff] [blame] | 42 | /////////////////////////////////////////////////////////////////////////////// |
| 43 | // Classes |
| 44 | /////////////////////////////////////////////////////////////////////////////// |
| 45 | |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 46 | class Extensions { |
| 47 | public: |
| 48 | Extensions() { |
| 49 | const char* buffer = (const char*) glGetString(GL_EXTENSIONS); |
| 50 | const char* current = buffer; |
| 51 | const char* head = current; |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 52 | EXT_LOGD("Available GL extensions:"); |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 53 | do { |
| 54 | head = strchr(current, ' '); |
| 55 | String8 s(current, head ? head - current : strlen(current)); |
| 56 | if (s.length()) { |
| 57 | mExtensionList.add(s); |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 58 | EXT_LOGD(" %s", s.string()); |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 59 | } |
| 60 | current = head + 1; |
| 61 | } while (head); |
| 62 | |
| 63 | mHasNPot = hasExtension("GL_OES_texture_npot"); |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 64 | mHasFramebufferFetch = hasExtension("GL_NV_shader_framebuffer_fetch"); |
Romain Guy | 9c4b79a | 2011-11-10 19:23:58 -0800 | [diff] [blame] | 65 | mHasDiscardFramebuffer = hasExtension("GL_EXT_discard_framebuffer"); |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 66 | mHasDebugMarker = hasExtension("GL_EXT_debug_marker"); |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 67 | mHasDebugLabel = hasExtension("GL_EXT_debug_label"); |
Romain Guy | 85ef80d | 2012-09-13 20:26:50 -0700 | [diff] [blame] | 68 | mHasTiledRendering = hasExtension("GL_QCOM_tiled_rendering"); |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 69 | |
Romain Guy | 85ef80d | 2012-09-13 20:26:50 -0700 | [diff] [blame] | 70 | mExtensions = strdup(buffer); |
| 71 | } |
| 72 | |
| 73 | ~Extensions() { |
| 74 | free(mExtensions); |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | inline bool hasNPot() const { return mHasNPot; } |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 78 | inline bool hasFramebufferFetch() const { return mHasFramebufferFetch; } |
Romain Guy | 9c4b79a | 2011-11-10 19:23:58 -0800 | [diff] [blame] | 79 | inline bool hasDiscardFramebuffer() const { return mHasDiscardFramebuffer; } |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 80 | inline bool hasDebugMarker() const { return mHasDebugMarker; } |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 81 | inline bool hasDebugLabel() const { return mHasDebugLabel; } |
Romain Guy | 85ef80d | 2012-09-13 20:26:50 -0700 | [diff] [blame] | 82 | inline bool hasTiledRendering() const { return mHasTiledRendering; } |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 83 | |
| 84 | bool hasExtension(const char* extension) const { |
| 85 | const String8 s(extension); |
| 86 | return mExtensionList.indexOf(s) >= 0; |
| 87 | } |
| 88 | |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 89 | void dump() { |
Steve Block | 5baa3a6 | 2011-12-20 16:23:08 +0000 | [diff] [blame] | 90 | ALOGD("Supported extensions:\n%s", mExtensions); |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 93 | private: |
| 94 | SortedVector<String8> mExtensionList; |
| 95 | |
Romain Guy | 85ef80d | 2012-09-13 20:26:50 -0700 | [diff] [blame] | 96 | char* mExtensions; |
Romain Guy | 51769a6 | 2010-07-23 00:28:00 -0700 | [diff] [blame] | 97 | |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 98 | bool mHasNPot; |
Romain Guy | a5aed0d | 2010-09-09 14:42:43 -0700 | [diff] [blame] | 99 | bool mHasFramebufferFetch; |
Romain Guy | 9c4b79a | 2011-11-10 19:23:58 -0800 | [diff] [blame] | 100 | bool mHasDiscardFramebuffer; |
Romain Guy | 13631f3 | 2012-01-30 17:41:55 -0800 | [diff] [blame] | 101 | bool mHasDebugMarker; |
Romain Guy | dfa1046 | 2012-05-12 16:18:58 -0700 | [diff] [blame] | 102 | bool mHasDebugLabel; |
Romain Guy | 85ef80d | 2012-09-13 20:26:50 -0700 | [diff] [blame] | 103 | bool mHasTiledRendering; |
Romain Guy | bd0e6aa | 2010-07-22 18:50:12 -0700 | [diff] [blame] | 104 | }; // class Extensions |
| 105 | |
| 106 | }; // namespace uirenderer |
| 107 | }; // namespace android |
| 108 | |
Romain Guy | 5b3b352 | 2010-10-27 18:57:51 -0700 | [diff] [blame] | 109 | #endif // ANDROID_HWUI_EXTENSIONS_H |