Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -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 | |
| 17 | #ifndef ANDROID_SF_GLEXTENSION_H |
| 18 | #define ANDROID_SF_GLEXTENSION_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 23 | #include <utils/Singleton.h> |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 24 | #include <utils/SortedVector.h> |
| 25 | #include <utils/String8.h> |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 26 | |
| 27 | #include <EGL/egl.h> |
| 28 | #include <EGL/eglext.h> |
| 29 | #include <GLES/gl.h> |
| 30 | #include <GLES/glext.h> |
| 31 | |
| 32 | namespace android { |
| 33 | // --------------------------------------------------------------------------- |
| 34 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 35 | class GLExtensions : public Singleton<GLExtensions> { |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 36 | friend class Singleton<GLExtensions>; |
| 37 | |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 38 | bool mHasNoConfigContext = false; |
Chia-I Wu | 767fcf7 | 2017-11-30 22:07:38 -0800 | [diff] [blame] | 39 | bool mHasNativeFenceSync = false; |
| 40 | bool mHasFenceSync = false; |
| 41 | bool mHasWaitSync = false; |
Chia-I Wu | 401ef83 | 2017-12-01 10:52:22 -0800 | [diff] [blame^] | 42 | bool mHasImageCrop = false; |
| 43 | bool mHasProtectedContent = false; |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 44 | |
| 45 | String8 mVendor; |
| 46 | String8 mRenderer; |
| 47 | String8 mVersion; |
| 48 | String8 mExtensions; |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 49 | SortedVector<String8> mExtensionList; |
| 50 | |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 51 | String8 mEGLVersion; |
| 52 | String8 mEGLExtensions; |
| 53 | SortedVector<String8> mEGLExtensionList; |
| 54 | |
| 55 | static SortedVector<String8> parseExtensionString(char const* extensions); |
| 56 | |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 57 | GLExtensions(const GLExtensions&); |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 58 | GLExtensions& operator=(const GLExtensions&); |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 59 | |
| 60 | protected: |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 61 | GLExtensions() = default; |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 62 | |
| 63 | public: |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 64 | bool hasNoConfigContext() const { return mHasNoConfigContext; } |
Chia-I Wu | 767fcf7 | 2017-11-30 22:07:38 -0800 | [diff] [blame] | 65 | bool hasNativeFenceSync() const { return mHasNativeFenceSync; } |
| 66 | bool hasFenceSync() const { return mHasFenceSync; } |
| 67 | bool hasWaitSync() const { return mHasWaitSync; } |
Chia-I Wu | 401ef83 | 2017-12-01 10:52:22 -0800 | [diff] [blame^] | 68 | bool hasImageCrop() const { return mHasImageCrop; } |
| 69 | bool hasProtectedContent() const { return mHasProtectedContent; } |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 70 | |
Chia-I Wu | b027f80 | 2017-11-29 14:00:52 -0800 | [diff] [blame] | 71 | void initWithGLStrings(GLubyte const* vendor, GLubyte const* renderer, GLubyte const* version, |
| 72 | GLubyte const* extensions); |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 73 | char const* getVendor() const; |
| 74 | char const* getRenderer() const; |
| 75 | char const* getVersion() const; |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 76 | char const* getExtensions() const; |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 77 | bool hasExtension(char const* extension) const; |
Chia-I Wu | 767d7c9 | 2017-11-30 13:22:48 -0800 | [diff] [blame] | 78 | |
| 79 | void initWithEGLStrings(char const* eglVersion, char const* eglExtensions); |
| 80 | char const* getEGLVersion() const; |
| 81 | char const* getEGLExtensions() const; |
| 82 | bool hasEGLExtension(char const* extension) const; |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 85 | // --------------------------------------------------------------------------- |
| 86 | }; // namespace android |
| 87 | |
| 88 | #endif // ANDROID_SF_GLEXTENSION_H |