void SkRTConfRegistry::UnitTest() { SkRTConfRegistry registryWithoutContents(true); sk_setenv("skia_nonexistent_item", "132"); int result = 0; registryWithoutContents.parse("nonexistent.item", &result); SkASSERT(result == 132); }
void SkCommandBufferGLContext::initializeGLContext(void* nativeWindow, const int* configAttribs, const int* surfaceAttribs) { LoadCommandBufferOnce(); if (!gfFunctionsLoadedSuccessfully) { SkDebugf("Command Buffer: Could not load EGL functions.\n"); return; } // Make sure CHROMIUM_path_rendering is enabled for NVPR support. sk_setenv("CHROME_COMMAND_BUFFER_GLES2_ARGS", "--enable-gl-path-rendering"); fDisplay = gfGetDisplay(EGL_DEFAULT_DISPLAY); if (EGL_NO_DISPLAY == fDisplay) { SkDebugf("Command Buffer: Could not create EGL display.\n"); return; } EGLint majorVersion; EGLint minorVersion; if (!gfInitialize(fDisplay, &majorVersion, &minorVersion)) { SkDebugf("Command Buffer: Could not initialize EGL display.\n"); this->destroyGLContext(); return; } EGLint numConfigs; if (!gfChooseConfig(fDisplay, configAttribs, static_cast<EGLConfig*>(&fConfig), 1, &numConfigs) || numConfigs != 1) { SkDebugf("Command Buffer: Could not choose EGL config.\n"); this->destroyGLContext(); return; } if (nativeWindow) { fSurface = gfCreateWindowSurface(fDisplay, static_cast<EGLConfig>(fConfig), (EGLNativeWindowType)nativeWindow, surfaceAttribs); } else { fSurface = gfCreatePbufferSurface(fDisplay, static_cast<EGLConfig>(fConfig), surfaceAttribs); } if (EGL_NO_SURFACE == fSurface) { SkDebugf("Command Buffer: Could not create EGL surface.\n"); this->destroyGLContext(); return; } static const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; fContext = gfCreateContext(fDisplay, static_cast<EGLConfig>(fConfig), nullptr, contextAttribs); if (EGL_NO_CONTEXT == fContext) { SkDebugf("Command Buffer: Could not create EGL context.\n"); this->destroyGLContext(); return; } if (!gfMakeCurrent(fDisplay, fSurface, fSurface, fContext)) { SkDebugf("Command Buffer: Could not make EGL context current.\n"); this->destroyGLContext(); return; } SkAutoTUnref<const GrGLInterface> gl(GrGLCreateCommandBufferInterface()); if (nullptr == gl.get()) { SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n"); this->destroyGLContext(); return; } if (!gl->validate()) { SkDebugf("Command Buffer: Could not validate CommandBuffer GL interface.\n"); this->destroyGLContext(); return; } this->init(gl.release()); }