diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-24 20:49:44 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-24 20:49:44 +0000 |
commit | d8ed85101ee77ad2cb0c186a79d197698a75d246 (patch) | |
tree | 0de059817c9954a768b85c15a972a5b09b33cb8b /src/gpu | |
parent | 8f2201144945be6693dd4954c2cc89e085f14ef8 (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')
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLExtensions.cpp | 50 | ||||
-rw-r--r-- | src/gpu/gl/GrGLInterface.cpp | 77 | ||||
-rw-r--r-- | src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp | 5 | ||||
-rw-r--r-- | src/gpu/gl/win/SkNativeGLContext_win.cpp | 6 |
5 files changed, 123 insertions, 18 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 153be6a4be..bdb19e2e3a 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -309,8 +309,7 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { // attachment, hence this min: fMaxRenderTargetSize = GrMin(fMaxTextureSize, fMaxRenderTargetSize); - fPathRenderingSupport = GR_GL_USE_NV_PATH_RENDERING && - ctxInfo.hasExtension("GL_NV_path_rendering"); + fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering"); SkASSERT(!fPathRenderingSupport || fFixedFunctionSupport); fDstReadInShaderSupport = kNone_FBFetchType != fFBFetchType; 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 { diff --git a/src/gpu/gl/GrGLInterface.cpp b/src/gpu/gl/GrGLInterface.cpp index 0a0ff59408..f7b0a53c20 100644 --- a/src/gpu/gl/GrGLInterface.cpp +++ b/src/gpu/gl/GrGLInterface.cpp @@ -18,6 +18,64 @@ void GrGLDefaultInterfaceCallback(const GrGLInterface*) {} } #endif +const GrGLInterface* GrGLInterfaceRemoveNVPR(const GrGLInterface* interface) { + GrGLInterface* newInterface = GrGLInterface::NewClone(interface); + + newInterface->fExtensions.remove("GL_NV_path_rendering"); + + newInterface->fPathCommands = NULL; + newInterface->fPathCoords = NULL; + newInterface->fPathSubCommands = NULL; + newInterface->fPathSubCoords = NULL; + newInterface->fPathString = NULL; + newInterface->fPathGlyphs = NULL; + newInterface->fPathGlyphRange = NULL; + newInterface->fWeightPaths = NULL; + newInterface->fCopyPath = NULL; + newInterface->fInterpolatePaths = NULL; + newInterface->fTransformPath = NULL; + newInterface->fPathParameteriv = NULL; + newInterface->fPathParameteri = NULL; + newInterface->fPathParameterfv = NULL; + newInterface->fPathParameterf = NULL; + newInterface->fPathDashArray = NULL; + newInterface->fGenPaths = NULL; + newInterface->fDeletePaths = NULL; + newInterface->fIsPath = NULL; + newInterface->fPathStencilFunc = NULL; + newInterface->fPathStencilDepthOffset = NULL; + newInterface->fStencilFillPath = NULL; + newInterface->fStencilStrokePath = NULL; + newInterface->fStencilFillPathInstanced = NULL; + newInterface->fStencilStrokePathInstanced = NULL; + newInterface->fPathCoverDepthFunc = NULL; + newInterface->fPathColorGen = NULL; + newInterface->fPathTexGen = NULL; + newInterface->fPathFogGen = NULL; + newInterface->fCoverFillPath = NULL; + newInterface->fCoverStrokePath = NULL; + newInterface->fCoverFillPathInstanced = NULL; + newInterface->fCoverStrokePathInstanced = NULL; + newInterface->fGetPathParameteriv = NULL; + newInterface->fGetPathParameterfv = NULL; + newInterface->fGetPathCommands = NULL; + newInterface->fGetPathCoords = NULL; + newInterface->fGetPathDashArray = NULL; + newInterface->fGetPathMetrics = NULL; + newInterface->fGetPathMetricRange = NULL; + newInterface->fGetPathSpacing = NULL; + newInterface->fGetPathColorGeniv = NULL; + newInterface->fGetPathColorGenfv = NULL; + newInterface->fGetPathTexGeniv = NULL; + newInterface->fGetPathTexGenfv = NULL; + newInterface->fIsPointInFillPath = NULL; + newInterface->fIsPointInStrokePath = NULL; + newInterface->fGetPathLength = NULL; + newInterface->fPointAlongPath = NULL; + + return newInterface; +} + GrGLInterface::GrGLInterface() // TODO: Remove this madness ASAP. : fActiveTexture(&fFunctions.fActiveTexture) @@ -205,8 +263,7 @@ GrGLInterface::GrGLInterface() , fIsPointInFillPath(&fFunctions.fIsPointInFillPath) , fIsPointInStrokePath(&fFunctions.fIsPointInStrokePath) , fGetPathLength(&fFunctions.fGetPathLength) - , fPointAlongPath(&fFunctions.fPointAlongPath) -{ + , fPointAlongPath(&fFunctions.fPointAlongPath) { fStandard = kNone_GrGLStandard; #if GR_GL_PER_GL_FUNC_CALLBACK @@ -215,6 +272,20 @@ GrGLInterface::GrGLInterface() #endif } +GrGLInterface* GrGLInterface::NewClone(const GrGLInterface* interface) { + SkASSERT(NULL != interface); + + GrGLInterface* clone = SkNEW(GrGLInterface); + clone->fStandard = interface->fStandard; + clone->fExtensions = interface->fExtensions; + clone->fFunctions = interface->fFunctions; +#if GR_GL_PER_GL_FUNC_CALLBACK + clone->fCallback = interface->fCallback; + clone->fCallbackData = interface->fCallbackData; +#endif + return clone; +} + bool GrGLInterface::validate() const { if (kNone_GrGLStandard == fStandard) { @@ -405,7 +476,7 @@ bool GrGLInterface::validate() const { return false; } } - if (false && fExtensions.has("GL_NV_path_rendering")) { + if (fExtensions.has("GL_NV_path_rendering")) { if (NULL == fFunctions.fPathCommands || NULL == fFunctions.fPathCoords || NULL == fFunctions.fPathSubCommands || diff --git a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp index 2858541ed9..1695c3c36f 100644 --- a/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp +++ b/src/gpu/gl/angle/GrGLCreateANGLEInterface.cpp @@ -152,5 +152,10 @@ const GrGLInterface* GrGLCreateANGLEInterface() { functions->fMapBuffer = (GrGLMapBufferProc) eglGetProcAddress("glMapBufferOES"); functions->fUnmapBuffer = (GrGLUnmapBufferProc) eglGetProcAddress("glUnmapBufferOES"); + + interface->fExtensions.init(kGLES_GrGLStandard, + interface->fFunctions.fGetString, + interface->fFunctions.fGetStringi, + interface->fFunctions.fGetIntegerv); return interface; } diff --git a/src/gpu/gl/win/SkNativeGLContext_win.cpp b/src/gpu/gl/win/SkNativeGLContext_win.cpp index 17b4e4ad9b..bae97a780c 100644 --- a/src/gpu/gl/win/SkNativeGLContext_win.cpp +++ b/src/gpu/gl/win/SkNativeGLContext_win.cpp @@ -86,10 +86,8 @@ const GrGLInterface* SkNativeGLContext::createGLContext() { return NULL; } - // We don't want the core profile when using NV path rendering (since - // NV path rendering relies on fixed function calls) - if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, - !GR_GL_USE_NV_PATH_RENDERING))) { + // Requesting a Core profile would bar us from using NVPR. So we pass false. + if (!(fGlRenderContext = SkCreateWGLContext(fDeviceContext, 0, false))) { SkDebugf("Could not create rendering context.\n"); this->destroyGLContext(); return NULL; |