Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: ui/gl/gl_implementation.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/base/capabilities_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_implementation.h" 5 #include "ui/gl/gl_implementation.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
11 11
12 #include "base/at_exit.h" 12 #include "base/at_exit.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/strings/string_piece.h"
17 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "ui/gl/gl_bindings.h" 21 #include "ui/gl/gl_bindings.h"
21 #include "ui/gl/gl_gl_api_implementation.h" 22 #include "ui/gl/gl_gl_api_implementation.h"
22 #include "ui/gl/gl_version_info.h" 23 #include "ui/gl/gl_version_info.h"
23 24
24 namespace gl { 25 namespace gl {
25 26
26 namespace { 27 namespace {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 bool HasInitializedNullDrawGLBindings() { 156 bool HasInitializedNullDrawGLBindings() {
156 return GetNullDrawBindingsEnabled(); 157 return GetNullDrawBindingsEnabled();
157 } 158 }
158 159
159 std::string FilterGLExtensionList( 160 std::string FilterGLExtensionList(
160 const char* extensions, 161 const char* extensions,
161 const std::vector<std::string>& disabled_extensions) { 162 const std::vector<std::string>& disabled_extensions) {
162 if (extensions == NULL) 163 if (extensions == NULL)
163 return ""; 164 return "";
164 165
165 std::vector<std::string> extension_vec = base::SplitString( 166 std::vector<base::StringPiece> extension_vec = base::SplitStringPiece(
166 extensions, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 167 extensions, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
167 168
168 auto is_disabled = [&disabled_extensions](const std::string& ext) { 169 auto is_disabled = [&disabled_extensions](const base::StringPiece& ext) {
169 return std::find(disabled_extensions.begin(), disabled_extensions.end(), 170 return std::find(disabled_extensions.begin(), disabled_extensions.end(),
170 ext) != disabled_extensions.end(); 171 ext) != disabled_extensions.end();
171 }; 172 };
172 extension_vec.erase( 173 extension_vec.erase(
173 std::remove_if(extension_vec.begin(), extension_vec.end(), is_disabled), 174 std::remove_if(extension_vec.begin(), extension_vec.end(), is_disabled),
174 extension_vec.end()); 175 extension_vec.end());
175 176
176 return base::JoinString(extension_vec, " "); 177 return base::JoinString(extension_vec, " ");
177 } 178 }
178 179
(...skipping 15 matching lines...) Expand all
194 std::string GetGLExtensionsFromCurrentContext(GLApi* api) { 195 std::string GetGLExtensionsFromCurrentContext(GLApi* api) {
195 if (WillUseGLGetStringForExtensions(api)) { 196 if (WillUseGLGetStringForExtensions(api)) {
196 const char* extensions = 197 const char* extensions =
197 reinterpret_cast<const char*>(api->glGetStringFn(GL_EXTENSIONS)); 198 reinterpret_cast<const char*>(api->glGetStringFn(GL_EXTENSIONS));
198 return extensions ? std::string(extensions) : std::string(); 199 return extensions ? std::string(extensions) : std::string();
199 } 200 }
200 201
201 GLint num_extensions = 0; 202 GLint num_extensions = 0;
202 api->glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions); 203 api->glGetIntegervFn(GL_NUM_EXTENSIONS, &num_extensions);
203 204
204 std::vector<std::string> exts(num_extensions); 205 std::vector<base::StringPiece> exts(num_extensions);
205 for (GLint i = 0; i < num_extensions; ++i) { 206 for (GLint i = 0; i < num_extensions; ++i) {
206 const char* extension = 207 const char* extension =
207 reinterpret_cast<const char*>(api->glGetStringiFn(GL_EXTENSIONS, i)); 208 reinterpret_cast<const char*>(api->glGetStringiFn(GL_EXTENSIONS, i));
208 DCHECK(extension != NULL); 209 DCHECK(extension != NULL);
209 exts[i] = extension; 210 exts[i] = extension;
210 } 211 }
211 return base::JoinString(exts, " "); 212 return base::JoinString(exts, " ");
212 } 213 }
213 214
214 bool WillUseGLGetStringForExtensions() { 215 bool WillUseGLGetStringForExtensions() {
(...skipping 28 matching lines...) Expand all
243 base::NativeLibrary library = base::LoadNativeLibrary(filename, &error); 244 base::NativeLibrary library = base::LoadNativeLibrary(filename, &error);
244 if (!library) { 245 if (!library) {
245 LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": " 246 LOG(ERROR) << "Failed to load " << filename.MaybeAsASCII() << ": "
246 << error.ToString(); 247 << error.ToString();
247 return NULL; 248 return NULL;
248 } 249 }
249 return library; 250 return library;
250 } 251 }
251 252
252 } // namespace gl 253 } // namespace gl
OLDNEW
« no previous file with comments | « remoting/base/capabilities_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698