OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gl/GrGLExtensions.h" | 8 #include "gl/GrGLExtensions.h" |
9 #include "gl/GrGLDefines.h" | 9 #include "gl/GrGLDefines.h" |
10 #include "gl/GrGLUtil.h" | 10 #include "gl/GrGLUtil.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 return *this; | 41 return *this; |
42 } | 42 } |
43 | 43 |
44 bool GrGLExtensions::init(GrGLStandard standard, | 44 bool GrGLExtensions::init(GrGLStandard standard, |
45 GrGLGetStringProc getString, | 45 GrGLGetStringProc getString, |
46 GrGLGetStringiProc getStringi, | 46 GrGLGetStringiProc getStringi, |
47 GrGLGetIntegervProc getIntegerv) { | 47 GrGLGetIntegervProc getIntegerv) { |
48 fInitialized = false; | 48 fInitialized = false; |
49 fStrings->reset(); | 49 fStrings->reset(); |
50 | 50 |
51 if (NULL == getString) { | 51 if (nullptr == getString) { |
52 return false; | 52 return false; |
53 } | 53 } |
54 | 54 |
55 // glGetStringi and indexed extensions were added in version 3.0 of desktop
GL and ES. | 55 // glGetStringi and indexed extensions were added in version 3.0 of desktop
GL and ES. |
56 const GrGLubyte* verString = getString(GR_GL_VERSION); | 56 const GrGLubyte* verString = getString(GR_GL_VERSION); |
57 GrGLVersion version = GrGLGetVersionFromString((const char*) verString); | 57 GrGLVersion version = GrGLGetVersionFromString((const char*) verString); |
58 if (GR_GL_INVALID_VER == version) { | 58 if (GR_GL_INVALID_VER == version) { |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 bool indexed = version >= GR_GL_VER(3, 0); | 62 bool indexed = version >= GR_GL_VER(3, 0); |
63 | 63 |
64 if (indexed) { | 64 if (indexed) { |
65 if (NULL == getStringi || NULL == getIntegerv) { | 65 if (nullptr == getStringi || nullptr == getIntegerv) { |
66 return false; | 66 return false; |
67 } | 67 } |
68 GrGLint extensionCnt = 0; | 68 GrGLint extensionCnt = 0; |
69 getIntegerv(GR_GL_NUM_EXTENSIONS, &extensionCnt); | 69 getIntegerv(GR_GL_NUM_EXTENSIONS, &extensionCnt); |
70 fStrings->push_back_n(extensionCnt); | 70 fStrings->push_back_n(extensionCnt); |
71 for (int i = 0; i < extensionCnt; ++i) { | 71 for (int i = 0; i < extensionCnt; ++i) { |
72 const char* ext = (const char*) getStringi(GR_GL_EXTENSIONS, i); | 72 const char* ext = (const char*) getStringi(GR_GL_EXTENSIONS, i); |
73 (*fStrings)[i] = ext; | 73 (*fStrings)[i] = ext; |
74 } | 74 } |
75 } else { | 75 } else { |
76 const char* extensions = (const char*) getString(GR_GL_EXTENSIONS); | 76 const char* extensions = (const char*) getString(GR_GL_EXTENSIONS); |
77 if (NULL == extensions) { | 77 if (nullptr == extensions) { |
78 return false; | 78 return false; |
79 } | 79 } |
80 while (true) { | 80 while (true) { |
81 // skip over multiple spaces between extensions | 81 // skip over multiple spaces between extensions |
82 while (' ' == *extensions) { | 82 while (' ' == *extensions) { |
83 ++extensions; | 83 ++extensions; |
84 } | 84 } |
85 // quit once we reach the end of the string. | 85 // quit once we reach the end of the string. |
86 if ('\0' == *extensions) { | 86 if ('\0' == *extensions) { |
87 break; | 87 break; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if (idx < 0) { | 126 if (idx < 0) { |
127 // This is not the most effecient approach since we end up doing a full
sort of the | 127 // This is not the most effecient approach since we end up doing a full
sort of the |
128 // extensions after the add | 128 // extensions after the add |
129 fStrings->push_back().set(ext); | 129 fStrings->push_back().set(ext); |
130 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | 130 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; |
131 SkTQSort(&fStrings->front(), &fStrings->back(), cmp); | 131 SkTQSort(&fStrings->front(), &fStrings->back(), cmp); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 void GrGLExtensions::print(const char* sep) const { | 135 void GrGLExtensions::print(const char* sep) const { |
136 if (NULL == sep) { | 136 if (nullptr == sep) { |
137 sep = " "; | 137 sep = " "; |
138 } | 138 } |
139 int cnt = fStrings->count(); | 139 int cnt = fStrings->count(); |
140 for (int i = 0; i < cnt; ++i) { | 140 for (int i = 0; i < cnt; ++i) { |
141 SkDebugf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : ""); | 141 SkDebugf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : ""); |
142 } | 142 } |
143 } | 143 } |
OLD | NEW |