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

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

Issue 1434813002: Add support for EGLImage to GrGLInterface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 5 years, 1 month 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 | « src/gpu/gl/GrGLDefines.h ('k') | 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"
(...skipping 23 matching lines...) Expand all
34 GrGLExtensions::GrGLExtensions(const GrGLExtensions& that) : fStrings(new SkTArr ay<SkString>) { 34 GrGLExtensions::GrGLExtensions(const GrGLExtensions& that) : fStrings(new SkTArr ay<SkString>) {
35 *this = that; 35 *this = that;
36 } 36 }
37 37
38 GrGLExtensions& GrGLExtensions::operator=(const GrGLExtensions& that) { 38 GrGLExtensions& GrGLExtensions::operator=(const GrGLExtensions& that) {
39 *fStrings = *that.fStrings; 39 *fStrings = *that.fStrings;
40 fInitialized = that.fInitialized; 40 fInitialized = that.fInitialized;
41 return *this; 41 return *this;
42 } 42 }
43 43
44 static void eat_space_sep_strings(SkTArray<SkString>* out, const char in[]) {
45 if (!in) {
46 return;
47 }
48 while (true) {
49 // skip over multiple spaces between extensions
50 while (' ' == *in) {
51 ++in;
52 }
53 // quit once we reach the end of the string.
54 if ('\0' == *in) {
55 break;
56 }
57 // we found an extension
58 size_t length = strcspn(in, " ");
59 out->push_back().set(in, length);
60 in += length;
61 }
62 }
63
44 bool GrGLExtensions::init(GrGLStandard standard, 64 bool GrGLExtensions::init(GrGLStandard standard,
45 GrGLGetStringProc getString, 65 GrGLGetStringProc getString,
46 GrGLGetStringiProc getStringi, 66 GrGLGetStringiProc getStringi,
47 GrGLGetIntegervProc getIntegerv) { 67 GrGLGetIntegervProc getIntegerv,
68 GrEGLQueryStringProc queryString,
69 GrEGLDisplay eglDisplay) {
48 fInitialized = false; 70 fInitialized = false;
49 fStrings->reset(); 71 fStrings->reset();
50 72
51 if (nullptr == getString) { 73 if (!getString) {
52 return false; 74 return false;
53 } 75 }
54 76
55 // glGetStringi and indexed extensions were added in version 3.0 of desktop GL and ES. 77 // glGetStringi and indexed extensions were added in version 3.0 of desktop GL and ES.
56 const GrGLubyte* verString = getString(GR_GL_VERSION); 78 const GrGLubyte* verString = getString(GR_GL_VERSION);
57 GrGLVersion version = GrGLGetVersionFromString((const char*) verString); 79 GrGLVersion version = GrGLGetVersionFromString((const char*) verString);
58 if (GR_GL_INVALID_VER == version) { 80 if (GR_GL_INVALID_VER == version) {
59 return false; 81 return false;
60 } 82 }
61 83
62 bool indexed = version >= GR_GL_VER(3, 0); 84 bool indexed = version >= GR_GL_VER(3, 0);
63 85
64 if (indexed) { 86 if (indexed) {
65 if (nullptr == getStringi || nullptr == getIntegerv) { 87 if (!getStringi || !getIntegerv) {
66 return false; 88 return false;
67 } 89 }
68 GrGLint extensionCnt = 0; 90 GrGLint extensionCnt = 0;
69 getIntegerv(GR_GL_NUM_EXTENSIONS, &extensionCnt); 91 getIntegerv(GR_GL_NUM_EXTENSIONS, &extensionCnt);
70 fStrings->push_back_n(extensionCnt); 92 fStrings->push_back_n(extensionCnt);
71 for (int i = 0; i < extensionCnt; ++i) { 93 for (int i = 0; i < extensionCnt; ++i) {
72 const char* ext = (const char*) getStringi(GR_GL_EXTENSIONS, i); 94 const char* ext = (const char*) getStringi(GR_GL_EXTENSIONS, i);
73 (*fStrings)[i] = ext; 95 (*fStrings)[i] = ext;
74 } 96 }
75 } else { 97 } else {
76 const char* extensions = (const char*) getString(GR_GL_EXTENSIONS); 98 const char* extensions = (const char*) getString(GR_GL_EXTENSIONS);
77 if (nullptr == extensions) { 99 if (!extensions) {
78 return false; 100 return false;
79 } 101 }
80 while (true) { 102 eat_space_sep_strings(fStrings, extensions);
81 // skip over multiple spaces between extensions 103 }
82 while (' ' == *extensions) { 104 if (queryString) {
83 ++extensions; 105 const char* extensions = queryString(eglDisplay, GR_EGL_EXTENSIONS);
84 } 106
85 // quit once we reach the end of the string. 107 eat_space_sep_strings(fStrings, extensions);
86 if ('\0' == *extensions) {
87 break;
88 }
89 // we found an extension
90 size_t length = strcspn(extensions, " ");
91 fStrings->push_back().set(extensions, length);
92 extensions += length;
93 }
94 } 108 }
95 if (!fStrings->empty()) { 109 if (!fStrings->empty()) {
96 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp; 110 SkTLessFunctionToFunctorAdaptor<SkString, extension_compare> cmp;
97 SkTQSort(&fStrings->front(), &fStrings->back(), cmp); 111 SkTQSort(&fStrings->front(), &fStrings->back(), cmp);
98 } 112 }
99 fInitialized = true; 113 fInitialized = true;
100 return true; 114 return true;
101 } 115 }
102 116
103 bool GrGLExtensions::has(const char ext[]) const { 117 bool GrGLExtensions::has(const char ext[]) const {
(...skipping 30 matching lines...) Expand all
134 148
135 void GrGLExtensions::print(const char* sep) const { 149 void GrGLExtensions::print(const char* sep) const {
136 if (nullptr == sep) { 150 if (nullptr == sep) {
137 sep = " "; 151 sep = " ";
138 } 152 }
139 int cnt = fStrings->count(); 153 int cnt = fStrings->count();
140 for (int i = 0; i < cnt; ++i) { 154 for (int i = 0; i < cnt; ++i) {
141 SkDebugf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : ""); 155 SkDebugf("%s%s", (*fStrings)[i].c_str(), (i < cnt - 1) ? sep : "");
142 } 156 }
143 } 157 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLDefines.h ('k') | src/gpu/gl/GrGLInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698