From b988ecf639f1394ea5e821ac15b989e25e064534 Mon Sep 17 00:00:00 2001 From: svaisanen Date: Wed, 20 Apr 2016 00:36:53 -0700 Subject: [PATCH] Enable NV_path_rendering in the Null GL. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1882563002 Review URL: https://codereview.chromium.org/1882563002 --- include/gpu/gl/GrGLInterface.h | 2 +- src/gpu/gl/GrGLCreateNullInterface.cpp | 67 +++++++++++++++++++-------------- tools/gpu/GrContextFactory.cpp | 2 +- tools/gpu/gl/null/NullGLTestContext.cpp | 8 ++-- tools/gpu/gl/null/NullGLTestContext.h | 2 +- 5 files changed, 45 insertions(+), 36 deletions(-) diff --git a/include/gpu/gl/GrGLInterface.h b/include/gpu/gl/GrGLInterface.h index e17bb0b..47dfbaa 100644 --- a/include/gpu/gl/GrGLInterface.h +++ b/include/gpu/gl/GrGLInterface.h @@ -53,7 +53,7 @@ typedef intptr_t GrGLInterfaceCallbackData; * CPU overhead. TODO: We would like to move this to tools/gpu/gl/null but currently * Chromium is using it in its unit tests. */ -const SK_API GrGLInterface* GrGLCreateNullInterface(); +const SK_API GrGLInterface* GrGLCreateNullInterface(bool enableNVPR = false); /** Function that returns a new interface identical to "interface" but without support for GL_NV_path_rendering. */ diff --git a/src/gpu/gl/GrGLCreateNullInterface.cpp b/src/gpu/gl/GrGLCreateNullInterface.cpp index 80a7cfb..7282667 100644 --- a/src/gpu/gl/GrGLCreateNullInterface.cpp +++ b/src/gpu/gl/GrGLCreateNullInterface.cpp @@ -112,7 +112,7 @@ private: /** Null interface implementation */ class NullInterface : public GrGLTestInterface { public: - NullInterface() + NullInterface(bool enableNVPR) : fCurrArrayBuffer(0) , fCurrElementArrayBuffer(0) , fCurrPixelPackBuffer(0) @@ -120,7 +120,20 @@ public: , fCurrProgramID(0) , fCurrShaderID(0) , fCurrGenericID(0) - , fCurrUniformLocation(0) { + , fCurrUniformLocation(0) + , fCurrPathID(0) { + fExtensions.push_back("GL_ARB_framebuffer_object"); + fExtensions.push_back("GL_ARB_blend_func_extended"); + fExtensions.push_back("GL_ARB_timer_query"); + fExtensions.push_back("GL_ARB_draw_buffers"); + fExtensions.push_back("GL_ARB_occlusion_query"); + fExtensions.push_back("GL_EXT_stencil_wrap"); + if (enableNVPR) { + fExtensions.push_back("GL_NV_path_rendering"); + fExtensions.push_back("GL_ARB_program_interface_query"); + } + fExtensions.push_back(nullptr); + this->init(kGL_GrGLStandard); } @@ -293,7 +306,7 @@ public: break; case GR_GL_NUM_EXTENSIONS: { GrGLint i = 0; - while (kExtensions[i++]); + while (fExtensions[i++]); *params = i; break; } @@ -377,7 +390,7 @@ public: GrGLint count; this->getIntegerv(GR_GL_NUM_EXTENSIONS, &count); if ((GrGLint)i <= count) { - return (const GrGLubyte*) kExtensions[i]; + return (const GrGLubyte*) fExtensions[i]; } else { return nullptr; } @@ -507,16 +520,24 @@ public: } }; + // NV_path_rendering + GrGLuint genPaths(GrGLsizei range) override { + return ++fCurrPathID; + } + + private: - BufferManager fBufferManager; - GrGLuint fCurrArrayBuffer; - GrGLuint fCurrElementArrayBuffer; - GrGLuint fCurrPixelPackBuffer; - GrGLuint fCurrPixelUnpackBuffer; - GrGLuint fCurrProgramID; - GrGLuint fCurrShaderID; - GrGLuint fCurrGenericID; - GrGLuint fCurrUniformLocation; + BufferManager fBufferManager; + GrGLuint fCurrArrayBuffer; + GrGLuint fCurrElementArrayBuffer; + GrGLuint fCurrPixelPackBuffer; + GrGLuint fCurrPixelUnpackBuffer; + GrGLuint fCurrProgramID; + GrGLuint fCurrShaderID; + GrGLuint fCurrGenericID; + GrGLuint fCurrUniformLocation; + GrGLuint fCurrPathID; + SkTArray fExtensions; // the OpenGLES 2.0 spec says this must be >= 128 static const GrGLint kDefaultMaxVertexUniformVectors = 128; @@ -530,19 +551,17 @@ private: // the OpenGLES 2.0 spec says this must be >= 8 static const GrGLint kDefaultMaxVaryingVectors = 8; - static const char* kExtensions[]; - - static const GrGLubyte* CombinedExtensionString() { + const GrGLubyte* CombinedExtensionString() { static SkString gExtString; static SkMutex gMutex; gMutex.acquire(); if (0 == gExtString.size()) { int i = 0; - while (kExtensions[i]) { + while (fExtensions[i]) { if (i > 0) { gExtString.append(" "); } - gExtString.append(kExtensions[i]); + gExtString.append(fExtensions[i]); ++i; } } @@ -600,16 +619,6 @@ private: typedef GrGLTestInterface INHERITED; }; -const char* NullInterface::kExtensions[] = { - "GL_ARB_framebuffer_object", - "GL_ARB_blend_func_extended", - "GL_ARB_timer_query", - "GL_ARB_draw_buffers", - "GL_ARB_occlusion_query", - "GL_EXT_stencil_wrap", - nullptr, // signifies the end of the array. -}; - } // anonymous namespace -const GrGLInterface* GrGLCreateNullInterface() { return new NullInterface; } +const GrGLInterface* GrGLCreateNullInterface(bool enableNVPR) { return new NullInterface(enableNVPR); } diff --git a/tools/gpu/GrContextFactory.cpp b/tools/gpu/GrContextFactory.cpp index 651f3fc..eb0f414 100755 --- a/tools/gpu/GrContextFactory.cpp +++ b/tools/gpu/GrContextFactory.cpp @@ -141,7 +141,7 @@ ContextInfo GrContextFactory::getContextInfo(ContextType type, ContextOptions op break; #endif case kNullGL_ContextType: - glCtx.reset(CreateNullGLTestContext()); + glCtx.reset(CreateNullGLTestContext(kEnableNVPR_ContextOptions & options)); break; case kDebugGL_ContextType: glCtx.reset(CreateDebugGLTestContext()); diff --git a/tools/gpu/gl/null/NullGLTestContext.cpp b/tools/gpu/gl/null/NullGLTestContext.cpp index e029654..56236a4 100644 --- a/tools/gpu/gl/null/NullGLTestContext.cpp +++ b/tools/gpu/gl/null/NullGLTestContext.cpp @@ -17,10 +17,10 @@ namespace { class NullGLContext : public sk_gpu_test::GLTestContext { public: - NullGLContext() { this->init(GrGLCreateNullInterface()); } + NullGLContext(bool enableNVPR) { this->init(GrGLCreateNullInterface(enableNVPR)); } ~NullGLContext() override { this->teardown(); } -private: +private: void onPlatformMakeCurrent() const override {}; void onPlatformSwapBuffers() const override {} GrGLFuncPtr onPlatformGetProcAddress(const char*) const override { return nullptr; } @@ -29,8 +29,8 @@ private: } // anonymous namespace namespace sk_gpu_test { -GLTestContext* CreateNullGLTestContext() { - GLTestContext* ctx = new NullGLContext(); +GLTestContext* CreateNullGLTestContext(bool enableNVPR) { + GLTestContext* ctx = new NullGLContext(enableNVPR); if (ctx->isValid()) { return ctx; } diff --git a/tools/gpu/gl/null/NullGLTestContext.h b/tools/gpu/gl/null/NullGLTestContext.h index ebde61a..909ec2e 100644 --- a/tools/gpu/gl/null/NullGLTestContext.h +++ b/tools/gpu/gl/null/NullGLTestContext.h @@ -11,7 +11,7 @@ #include "gl/GLTestContext.h" namespace sk_gpu_test { -GLTestContext* CreateNullGLTestContext(); +GLTestContext* CreateNullGLTestContext(bool enableNVPR); } // namespace sk_gpu_test #endif -- 2.7.4