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
This commit is contained in:
svaisanen 2016-04-20 00:36:53 -07:00 committed by Commit bot
parent 6d3119c9fc
commit b988ecf639
5 changed files with 45 additions and 36 deletions

View File

@ -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. */

View File

@ -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<const char*> 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); }

View File

@ -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());

View File

@ -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;
}

View File

@ -11,7 +11,7 @@
#include "gl/GLTestContext.h"
namespace sk_gpu_test {
GLTestContext* CreateNullGLTestContext();
GLTestContext* CreateNullGLTestContext(bool enableNVPR);
} // namespace sk_gpu_test
#endif