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_HWUI_EXTENSIONS_H
18#define ANDROID_HWUI_EXTENSIONS_H
19
20#include <cutils/compiler.h>
21
22#include <utils/Singleton.h>
23#include <utils/SortedVector.h>
24#include <utils/String8.h>
25
26#include <GLES2/gl2.h>
27
28namespace android {
29namespace uirenderer {
30
31///////////////////////////////////////////////////////////////////////////////
32// Classes
33///////////////////////////////////////////////////////////////////////////////
34
35class ANDROID_API Extensions {
36public:
37    Extensions();
38
39    inline bool hasNPot() const { return mHasNPot; }
40    inline bool hasFramebufferFetch() const { return mHasFramebufferFetch; }
41    inline bool hasDiscardFramebuffer() const { return mHasDiscardFramebuffer; }
42    inline bool hasDebugMarker() const { return mHasDebugMarker; }
43    inline bool hasTiledRendering() const { return mHasTiledRendering; }
44    inline bool has1BitStencil() const { return mHas1BitStencil; }
45    inline bool has4BitStencil() const { return mHas4BitStencil; }
46    inline bool hasNvSystemTime() const { return mHasNvSystemTime; }
47    inline bool hasUnpackRowLength() const { return mVersionMajor >= 3; }
48    inline bool hasPixelBufferObjects() const { return mVersionMajor >= 3; }
49    inline bool hasOcclusionQueries() const { return mVersionMajor >= 3; }
50    inline bool hasFloatTextures() const { return mVersionMajor >= 3; }
51
52    inline int getMajorGlVersion() const { return mVersionMajor; }
53    inline int getMinorGlVersion() const { return mVersionMinor; }
54
55    bool hasGlExtension(const char* extension) const;
56    bool hasEglExtension(const char* extension) const;
57
58    void dump() const;
59
60private:
61    void findExtensions(const char* extensions, SortedVector<String8>& list) const;
62
63    SortedVector<String8> mGlExtensionList;
64    SortedVector<String8> mEglExtensionList;
65
66    bool mHasNPot;
67    bool mHasFramebufferFetch;
68    bool mHasDiscardFramebuffer;
69    bool mHasDebugMarker;
70    bool mHasTiledRendering;
71    bool mHas1BitStencil;
72    bool mHas4BitStencil;
73    bool mHasNvSystemTime;
74
75    int mVersionMajor;
76    int mVersionMinor;
77}; // class Extensions
78
79}; // namespace uirenderer
80}; // namespace android
81
82#endif // ANDROID_HWUI_EXTENSIONS_H
83