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

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

Issue 12328111: Use glGetStringi to get extensions when available. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gl/GrGLExtensions.h"
9 #include "gl/GrGLDefines.h"
10 #include "gl/GrGLUtil.h"
11
12 bool GrGLExtensions::init(GrGLBinding binding,
13 GrGLGetStringProc getString,
14 GrGLGetStringiProc getStringi,
robertphillips 2013/02/26 21:06:07 getIntegerv?
bsalomon 2013/02/26 21:32:51 Done.
15 GrGLGetIntegervProc getIntegeriv) {
16 fStrings.reset();
17 if (NULL == getString) {
18 return false;
19 }
20 bool indexed = false;
21 if (kDesktop_GrGLBinding == binding) {
22 const GrGLubyte* verString = getString(GR_GL_VERSION);
23 if (NULL == verString) {
24 return false;
25 }
26 GrGLVersion version = GrGLGetVersionFromString((const char*) verString);
27 indexed = version >= GR_GL_VER(3, 0);
28 }
29 if (indexed) {
30 if (NULL == getStringi || NULL == getIntegeriv) {
31 return false;
32 }
33 GrGLint extensionCnt = 0;
34 getIntegeriv(GR_GL_NUM_EXTENSIONS, &extensionCnt);
35 fStrings.push_back_n(extensionCnt);
36 for (int i = 0; i < extensionCnt; ++i) {
37 const char* ext = (const char*) getStringi(GR_GL_EXTENSIONS, i);
38 fStrings[i] = ext;
39 }
40 } else {
41 const char* extensions = (const char*) getString(GR_GL_EXTENSIONS);
Jvsquare 2013/02/26 21:33:39 Not a huge deal since it's in an init function, bu
bsalomon 2013/02/26 21:38:46 True... I was thinking that the initial scan to ge
42 if (NULL == extensions) {
43 return false;
44 }
45 int extensionCnt = 1;
46 const char* e = (const char*) extensions;
47 while (NULL != (e = strchr(e+1, ' '))) {
48 e += 1;
49 ++extensionCnt;
50 }
51 fStrings.push_back_n(extensionCnt);
52 int i = 0;
53 while (true) {
54 size_t length = strcspn(extensions, " ");
55 GrAssert(i < extensionCnt);
56 fStrings[i].set(extensions, length);
57 ++i;
58 if ('\0' == extensions[length]) {
59 break;
60 }
61 extensions += length + 1;
62 }
63 GrAssert(i == extensionCnt);
64 }
65 return true;
66 }
67
68 bool GrGLExtensions::has(const char* ext) const {
69 // TODO: Sort the extensions and binary search.
70 int count = fStrings.count();
71 for (int i = 0; i < count; ++i) {
72 if (fStrings[i].equals(ext)) {
73 return true;
74 }
75 }
76 return false;
77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698