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

Side by Side Diff: src/gpu/gl/GrGLExtensions.cpp

Issue 12564003: Fix extensions string (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Upload correct patch Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 /* 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 fStrings.push_back_n(extensionCnt); 44 fStrings.push_back_n(extensionCnt);
45 for (int i = 0; i < extensionCnt; ++i) { 45 for (int i = 0; i < extensionCnt; ++i) {
46 const char* ext = (const char*) getStringi(GR_GL_EXTENSIONS, i); 46 const char* ext = (const char*) getStringi(GR_GL_EXTENSIONS, i);
47 fStrings[i] = ext; 47 fStrings[i] = ext;
48 } 48 }
49 } else { 49 } else {
50 const char* extensions = (const char*) getString(GR_GL_EXTENSIONS); 50 const char* extensions = (const char*) getString(GR_GL_EXTENSIONS);
51 if (NULL == extensions) { 51 if (NULL == extensions) {
52 return false; 52 return false;
53 } 53 }
54 // First count the extensions so that we don't cause the array to malloc multiple times.
55 int extensionCnt = 1;
56 const char* e = (const char*) extensions;
57 while (NULL != (e = strchr(e+1, ' '))) {
58 e += 1;
59 ++extensionCnt;
60 }
61 fStrings.push_back_n(extensionCnt);
62
63 int i = 0;
64 while (true) { 54 while (true) {
65 size_t length = strcspn(extensions, " "); 55 // skip over multiple spaces between extensions
66 GrAssert(i < extensionCnt); 56 while (' ' == *extensions) {
67 fStrings[i].set(extensions, length); 57 ++extensions;
68 ++i; 58 }
69 if ('\0' == extensions[length]) { 59 // quit once we reach the end of the string.
60 if ('\0' == *extensions) {
70 break; 61 break;
71 } 62 }
72 extensions += length + 1; 63 // we found an extension
64 size_t length = strcspn(extensions, " ");
65 fStrings.push_back().set(extensions, length);
66 extensions += length;
73 } 67 }
74 GrAssert(i == extensionCnt);
75 } 68 }
76 SkTSearchCompareLTFunctor<SkString, extension_compare> cmp; 69 SkTSearchCompareLTFunctor<SkString, extension_compare> cmp;
77 SkTQSort(&fStrings.front(), &fStrings.back(), cmp); 70 SkTQSort(&fStrings.front(), &fStrings.back(), cmp);
78 return true; 71 return true;
79 } 72 }
80 73
81 bool GrGLExtensions::has(const char* ext) const { 74 bool GrGLExtensions::has(const char* ext) const {
82 SkString extensionStr(ext); 75 SkString extensionStr(ext);
83 int idx = SkTSearch<SkString, extension_compare>(&fStrings.front(), 76 int idx = SkTSearch<SkString, extension_compare>(&fStrings.front(),
84 fStrings.count(), 77 fStrings.count(),
85 extensionStr, 78 extensionStr,
86 sizeof(SkString)); 79 sizeof(SkString));
87 return idx >= 0; 80 return idx >= 0;
88 } 81 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698