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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.detach()); | 113 SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.detach()); |
114 fStrings.reset(SkNEW(SkTArray<SkString>(oldStrings->count() - 1))); | 114 fStrings.reset(SkNEW(SkTArray<SkString>(oldStrings->count() - 1))); |
115 fStrings->push_back_n(idx, &oldStrings->front()); | 115 fStrings->push_back_n(idx, &oldStrings->front()); |
116 fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx]
+ 1); | 116 fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx]
+ 1); |
117 return true; | 117 return true; |
118 } else { | 118 } else { |
119 return false; | 119 return false; |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
| 123 void GrGLExtensions::add(const char ext[]) { |
| 124 int idx = find_string(*fStrings, ext); |
| 125 if (idx < 0) { |
| 126 // This is not the most effecient approach since we end up doing a full
sort of the |
| 127 // extensions after the add |
| 128 fStrings->push_back().set(ext); |
| 129 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; |
| 130 SkTQSort(&fStrings->front(), &fStrings->back(), cmp); |
| 131 } |
| 132 } |
| 133 |
123 void GrGLExtensions::print(const char* sep) const { | 134 void GrGLExtensions::print(const char* sep) const { |
124 if (NULL == sep) { | 135 if (NULL == sep) { |
125 sep = " "; | 136 sep = " "; |
126 } | 137 } |
127 int cnt = fStrings->count(); | 138 int cnt = fStrings->count(); |
128 for (int i = 0; i < cnt; ++i) { | 139 for (int i = 0; i < cnt; ++i) { |
129 GrPrintf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : ""); | 140 GrPrintf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : ""); |
130 } | 141 } |
131 } | 142 } |
OLD | NEW |