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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 SkASSERT(fInitialized); | 118 SkASSERT(fInitialized); |
119 return find_string(*fStrings, ext) >= 0; | 119 return find_string(*fStrings, ext) >= 0; |
120 } | 120 } |
121 | 121 |
122 bool GrGLExtensions::remove(const char ext[]) { | 122 bool GrGLExtensions::remove(const char ext[]) { |
123 SkASSERT(fInitialized); | 123 SkASSERT(fInitialized); |
124 int idx = find_string(*fStrings, ext); | 124 int idx = find_string(*fStrings, ext); |
125 if (idx >= 0) { | 125 if (idx >= 0) { |
126 // This is not terribly effecient but we really only expect this functio
n to be called at | 126 // This is not terribly effecient but we really only expect this functio
n to be called at |
127 // most a handful of times when our test programs start. | 127 // most a handful of times when our test programs start. |
128 SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.detach()); | 128 SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.release()); |
129 fStrings.reset(new SkTArray<SkString>(oldStrings->count() - 1)); | 129 fStrings.reset(new SkTArray<SkString>(oldStrings->count() - 1)); |
130 fStrings->push_back_n(idx, &oldStrings->front()); | 130 fStrings->push_back_n(idx, &oldStrings->front()); |
131 fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx]
+ 1); | 131 fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx]
+ 1); |
132 return true; | 132 return true; |
133 } else { | 133 } else { |
134 return false; | 134 return false; |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 void GrGLExtensions::add(const char ext[]) { | 138 void GrGLExtensions::add(const char ext[]) { |
139 int idx = find_string(*fStrings, ext); | 139 int idx = find_string(*fStrings, ext); |
140 if (idx < 0) { | 140 if (idx < 0) { |
141 // This is not the most effecient approach since we end up doing a full
sort of the | 141 // This is not the most effecient approach since we end up doing a full
sort of the |
142 // extensions after the add | 142 // extensions after the add |
143 fStrings->push_back().set(ext); | 143 fStrings->push_back().set(ext); |
144 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; | 144 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; |
145 SkTQSort(&fStrings->front(), &fStrings->back(), cmp); | 145 SkTQSort(&fStrings->front(), &fStrings->back(), cmp); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 void GrGLExtensions::print(const char* sep) const { | 149 void GrGLExtensions::print(const char* sep) const { |
150 if (nullptr == sep) { | 150 if (nullptr == sep) { |
151 sep = " "; | 151 sep = " "; |
152 } | 152 } |
153 int cnt = fStrings->count(); | 153 int cnt = fStrings->count(); |
154 for (int i = 0; i < cnt; ++i) { | 154 for (int i = 0; i < cnt; ++i) { |
155 SkDebugf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : ""); | 155 SkDebugf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : ""); |
156 } | 156 } |
157 } | 157 } |
OLD | NEW |