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