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

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

Issue 23359002: Use indexed extensions on ES3. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 | src/gpu/gl/GrGLInterface.cpp » ('j') | 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"
11 11
12 #include "SkTSearch.h" 12 #include "SkTSearch.h"
13 #include "SkTSort.h" 13 #include "SkTSort.h"
14 14
15 namespace { 15 namespace {
16 inline bool extension_compare(const SkString& a, const SkString& b) { 16 inline bool extension_compare(const SkString& a, const SkString& b) {
17 return strcmp(a.c_str(), b.c_str()) < 0; 17 return strcmp(a.c_str(), b.c_str()) < 0;
18 } 18 }
19 } 19 }
20 20
21 bool GrGLExtensions::init(GrGLBinding binding, 21 bool GrGLExtensions::init(GrGLBinding binding,
22 GrGLGetStringProc getString, 22 GrGLGetStringProc getString,
23 GrGLGetStringiProc getStringi, 23 GrGLGetStringiProc getStringi,
24 GrGLGetIntegervProc getIntegerv) { 24 GrGLGetIntegervProc getIntegerv) {
25 fStrings.reset(); 25 fStrings.reset();
26 if (NULL == getString) { 26 if (NULL == getString) {
27 return false; 27 return false;
28 } 28 }
29 bool indexed = false; 29
30 if (kDesktop_GrGLBinding == binding) { 30 // glGetStringi and indexed extensions were added in version 3.0 of desktop GL and ES.
31 const GrGLubyte* verString = getString(GR_GL_VERSION); 31 const GrGLubyte* verString = getString(GR_GL_VERSION);
32 if (NULL == verString) { 32 if (NULL == verString) {
33 return false; 33 return false;
34 }
35 GrGLVersion version = GrGLGetVersionFromString((const char*) verString);
36 indexed = version >= GR_GL_VER(3, 0);
37 } 34 }
35 GrGLVersion version = GrGLGetVersionFromString((const char*) verString);
36 bool indexed = version >= GR_GL_VER(3, 0);
37
38 if (indexed) { 38 if (indexed) {
39 if (NULL == getStringi || NULL == getIntegerv) { 39 if (NULL == getStringi || NULL == getIntegerv) {
40 return false; 40 return false;
41 } 41 }
42 GrGLint extensionCnt = 0; 42 GrGLint extensionCnt = 0;
43 getIntegerv(GR_GL_NUM_EXTENSIONS, &extensionCnt); 43 getIntegerv(GR_GL_NUM_EXTENSIONS, &extensionCnt);
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;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 void GrGLExtensions::print(const char* sep) const { 88 void GrGLExtensions::print(const char* sep) const {
89 if (NULL == sep) { 89 if (NULL == sep) {
90 sep = " "; 90 sep = " ";
91 } 91 }
92 int cnt = fStrings.count(); 92 int cnt = fStrings.count();
93 for (int i = 0; i < cnt; ++i) { 93 for (int i = 0; i < cnt; ++i) {
94 GrPrintf("%s%s", fStrings[i].c_str(), (i < cnt - 1) ? sep : ""); 94 GrPrintf("%s%s", fStrings[i].c_str(), (i < cnt - 1) ? sep : "");
95 } 95 }
96 } 96 }
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698