aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGLExtensions.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-24 20:49:44 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-24 20:49:44 +0000
commitd8ed85101ee77ad2cb0c186a79d197698a75d246 (patch)
tree0de059817c9954a768b85c15a972a5b09b33cb8b /src/gpu/gl/GrGLExtensions.cpp
parent8f2201144945be6693dd4954c2cc89e085f14ef8 (diff)
Turn NVPR on by default (but off in tools).
BUG=skia:2042 Committed: http://code.google.com/p/skia/source/detail?r=13164 R=robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/144003006 git-svn-id: http://skia.googlecode.com/svn/trunk@13176 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGLExtensions.cpp')
-rw-r--r--src/gpu/gl/GrGLExtensions.cpp50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/gpu/gl/GrGLExtensions.cpp b/src/gpu/gl/GrGLExtensions.cpp
index 4e75d3e08c..33273e5f65 100644
--- a/src/gpu/gl/GrGLExtensions.cpp
+++ b/src/gpu/gl/GrGLExtensions.cpp
@@ -12,12 +12,35 @@
#include "SkTSearch.h"
#include "SkTSort.h"
-namespace {
+namespace { // This cannot be static because it is used as a template parameter.
inline bool extension_compare(const SkString& a, const SkString& b) {
return strcmp(a.c_str(), b.c_str()) < 0;
}
}
+// finds the index of ext in strings or a negative result if ext is not found.
+static int find_string(const SkTArray<SkString>& strings, const char ext[]) {
+ if (strings.empty()) {
+ return -1;
+ }
+ SkString extensionStr(ext);
+ int idx = SkTSearch<SkString, extension_compare>(&strings.front(),
+ strings.count(),
+ extensionStr,
+ sizeof(SkString));
+ return idx;
+}
+
+GrGLExtensions::GrGLExtensions(const GrGLExtensions& that) : fStrings(SkNEW(SkTArray<SkString>)) {
+ *this = that;
+}
+
+GrGLExtensions& GrGLExtensions::operator=(const GrGLExtensions& that) {
+ *fStrings = *that.fStrings;
+ fInitialized = that.fInitialized;
+ return *this;
+}
+
bool GrGLExtensions::init(GrGLStandard standard,
GrGLGetStringProc getString,
GrGLGetStringiProc getStringi,
@@ -76,16 +99,25 @@ bool GrGLExtensions::init(GrGLStandard standard,
return true;
}
-bool GrGLExtensions::has(const char* ext) const {
- if (fStrings->empty()) {
+bool GrGLExtensions::has(const char ext[]) const {
+ SkASSERT(fInitialized);
+ return find_string(*fStrings, ext) >= 0;
+}
+
+bool GrGLExtensions::remove(const char ext[]) {
+ SkASSERT(fInitialized);
+ int idx = find_string(*fStrings, ext);
+ if (idx >= 0) {
+ // This is not terribly effecient but we really only expect this function to be called at
+ // most a handful of times when our test programs start.
+ SkAutoTDelete< SkTArray<SkString> > oldStrings(fStrings.detach());
+ fStrings.reset(SkNEW(SkTArray<SkString>(oldStrings->count() - 1)));
+ fStrings->push_back_n(idx, &oldStrings->front());
+ fStrings->push_back_n(oldStrings->count() - idx - 1, &(*oldStrings)[idx] + 1);
+ return true;
+ } else {
return false;
}
- SkString extensionStr(ext);
- int idx = SkTSearch<SkString, extension_compare>(&fStrings->front(),
- fStrings->count(),
- extensionStr,
- sizeof(SkString));
- return idx >= 0;
}
void GrGLExtensions::print(const char* sep) const {