/** * Method is used to initialize and configure engine context. */ void ContextManager::initializeContextManager() { initializeContext(); resizeWindow(resolutionWidth, resolutionHeight); initializeOpenGL(); contextWindow->setActive(); sf::Mouse::setPosition(sf::Vector2i(resolutionWidth/2,resolutionHeight/2),*contextWindow); contextWindow->setMouseCursorVisible(false); }
void AsyncIO::submit(Op* op) { CHECK_EQ(op->state(), Op::State::INITIALIZED); CHECK_LT(pending_, capacity_) << "too many pending requests"; initializeContext(); // on demand iocb* cb = &op->iocb_; cb->data = nullptr; // unused if (pollFd_ != -1) { io_set_eventfd(cb, pollFd_); } int rc = io_submit(ctx_, 1, &cb); checkKernelError(rc, "AsyncIO: io_submit failed"); DCHECK_EQ(rc, 1); op->start(); ++pending_; }
void Browser::quickstart_p(bool updateHistory) { // generate the quickstart page QVariantHash mapping; initializeContext(mapping); QVariantList exampleCategories; foreach (const QString& cat, Toolkit::findExampleCategories()) { QVariantHash catDescription; catDescription.insert("name", cat); QVariantList examples; foreach (const QString &example, Toolkit::findExamples(cat)) examples.append(example); catDescription.insert("examples", examples); exampleCategories << catDescription; }
bool FECustomFilter::applyShader() { Uint8ClampedArray* dstPixelArray = createUnmultipliedImageResult(); if (!dstPixelArray) return false; FilterEffect* in = inputEffect(0); IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); RefPtr<Uint8ClampedArray> srcPixelArray = in->asUnmultipliedImage(effectDrawingRect); IntSize newContextSize(effectDrawingRect.size()); bool hadContext = m_context; if (!m_context && !initializeContext()) return false; m_context->makeContextCurrent(); if (!hadContext || m_contextSize != newContextSize) resizeContext(newContextSize); #if !PLATFORM(BLACKBERRY) // BlackBerry defines its own Texture class. // Do not draw the filter if the input image cannot fit inside a single GPU texture. if (m_inputTexture->tiles().numTilesX() != 1 || m_inputTexture->tiles().numTilesY() != 1) return false; #endif // The shader had compiler errors. We cannot draw anything. if (!m_compiledProgram->isInitialized()) return false; m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_frameBuffer); m_context->viewport(0, 0, newContextSize.width(), newContextSize.height()); m_context->clearColor(0, 0, 0, 0); m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT); bindProgramAndBuffers(srcPixelArray.get()); m_context->drawElements(GraphicsContext3D::TRIANGLES, m_mesh->indicesCount(), GraphicsContext3D::UNSIGNED_SHORT, 0); unbindVertexAttributes(); ASSERT(static_cast<size_t>(newContextSize.width() * newContextSize.height() * 4) == dstPixelArray->length()); m_context->readPixels(0, 0, newContextSize.width(), newContextSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, dstPixelArray->data()); return true; }
bool FECustomFilter::prepareForDrawing(CustomFilterDrawType filterDrawType) { if (!m_context && !initializeContext()) return false; m_context->makeContextCurrent(); // If the shader had compiler errors we cannot draw anything. if (!m_compiledProgram->isInitialized()) return false; // Only allocate a texture if the program needs one and the caller doesn't allocate one by itself. if ((programNeedsInputTexture() && (filterDrawType == NEEDS_INPUT_TEXTURE) && !ensureInputTexture()) || !ensureFrameBuffer()) return false; return true; }
GLShaderDev::GLShaderDev(const QStringList& args) : _editor(new CodeEditor(this)), _output(new BuildOutput(this)), _glInfoDialog(nullptr), _newFileDialog(new NewFileDialog(this)) { resize(1000, 800); // FIXME set sizeHint instead of hardcoding it setWindowIcon(QIcon(":/glsd-icon.png")); setCentralWidget(_editor); initializeContext(); initializeActions(); initializeDockWidgets(); loadSettings(); updateTitleBar(); for (int i = 0; i < args.size(); ++i) openFile(args.at(i)); }
void FECustomFilter::platformApplySoftware() { ByteArray* dstPixelArray = createPremultipliedImageResult(); if (!dstPixelArray) return; FilterEffect* in = inputEffect(0); IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); RefPtr<ByteArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect); IntSize newContextSize(effectDrawingRect.size()); bool hadContext = m_context; if (!m_context) initializeContext(newContextSize); if (!hadContext || m_contextSize != newContextSize) resizeContext(newContextSize); // Do not draw the filter if the input image cannot fit inside a single GPU texture. if (m_inputTexture->tiles().numTilesX() != 1 || m_inputTexture->tiles().numTilesY() != 1) return; // The shader had compiler errors. We cannot draw anything. if (!m_shader->isInitialized()) return; m_context->clearColor(0, 0, 0, 0); m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT); bindProgramAndBuffers(srcPixelArray.get()); m_context->drawElements(GraphicsContext3D::TRIANGLES, m_mesh->indicesCount(), GraphicsContext3D::UNSIGNED_SHORT, 0); m_drawingBuffer->commit(); RefPtr<ImageData> imageData = m_context->paintRenderingResultsToImageData(m_drawingBuffer.get()); ByteArray* gpuResult = imageData->data()->data(); ASSERT(gpuResult->length() == dstPixelArray->length()); memcpy(dstPixelArray->data(), gpuResult->data(), gpuResult->length()); }
void FECustomFilter::platformApplySoftware() { Uint8ClampedArray* dstPixelArray = createPremultipliedImageResult(); if (!dstPixelArray) return; FilterEffect* in = inputEffect(0); IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect()); RefPtr<Uint8ClampedArray> srcPixelArray = in->asPremultipliedImage(effectDrawingRect); IntSize newContextSize(effectDrawingRect.size()); bool hadContext = m_context; if (!m_context) initializeContext(); if (!hadContext || m_contextSize != newContextSize) resizeContext(newContextSize); // Do not draw the filter if the input image cannot fit inside a single GPU texture. if (m_inputTexture->tiles().numTilesX() != 1 || m_inputTexture->tiles().numTilesY() != 1) return; // The shader had compiler errors. We cannot draw anything. if (!m_shader->isInitialized()) return; m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_frameBuffer); m_context->viewport(0, 0, newContextSize.width(), newContextSize.height()); m_context->clearColor(0, 0, 0, 0); m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT); bindProgramAndBuffers(srcPixelArray.get()); m_context->drawElements(GraphicsContext3D::TRIANGLES, m_mesh->indicesCount(), GraphicsContext3D::UNSIGNED_SHORT, 0); ASSERT(static_cast<size_t>(newContextSize.width() * newContextSize.height() * 4) == dstPixelArray->length()); m_context->readPixels(0, 0, newContextSize.width(), newContextSize.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, dstPixelArray->data()); }
void CACFLayerTreeHost::initialize() { // Point the CACFContext to this initializeContext(this, m_rootLayer.get()); // Under the root layer, we have a clipping layer to clip the content, // that contains a scroll layer that we use for scrolling the content. // The root layer is the size of the client area of the window. // The clipping layer is the size of the WebView client area (window less the scrollbars). // The scroll layer is the size of the root child layer. // Resizing the window will change the bounds of the rootLayer and the clip layer and will not // cause any repositioning. // Scrolling will affect only the position of the scroll layer without affecting the bounds. m_rootLayer->setName("CACFLayerTreeHost rootLayer"); m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0)); m_rootLayer->setGeometryFlipped(true); #ifndef NDEBUG CGColorRef debugColor = CGColorCreateGenericRGB(1, 0, 0, 0.8); m_rootLayer->setBackgroundColor(debugColor); CGColorRelease(debugColor); #endif }
void AsyncIO::submit(Op* op) { CHECK_EQ(op->state(), Op::State::INITIALIZED); initializeContext(); // on demand // We can increment past capacity, but we'll clean up after ourselves. auto p = pending_.fetch_add(1, std::memory_order_acq_rel); if (p >= capacity_) { decrementPending(); throw std::range_error("AsyncIO: too many pending requests"); } iocb* cb = &op->iocb_; cb->data = nullptr; // unused if (pollFd_ != -1) { io_set_eventfd(cb, pollFd_); } int rc = io_submit(ctx_, 1, &cb); if (rc < 0) { decrementPending(); throwSystemErrorExplicit(-rc, "AsyncIO: io_submit failed"); } submitted_++; DCHECK_EQ(rc, 1); op->start(); }
egl::Error DisplayGLX::initialize(egl::Display *display) { mEGLDisplay = display; Display *xDisplay = display->getNativeDisplayId(); const auto &attribMap = display->getAttributeMap(); // ANGLE_platform_angle allows the creation of a default display // using EGL_DEFAULT_DISPLAY (= nullptr). In this case just open // the display specified by the DISPLAY environment variable. if (xDisplay == EGL_DEFAULT_DISPLAY) { mUsesNewXDisplay = true; xDisplay = XOpenDisplay(NULL); if (!xDisplay) { return egl::Error(EGL_NOT_INITIALIZED, "Could not open the default X display."); } } std::string glxInitError; if (!mGLX.initialize(xDisplay, DefaultScreen(xDisplay), &glxInitError)) { return egl::Error(EGL_NOT_INITIALIZED, glxInitError.c_str()); } mHasMultisample = mGLX.minorVersion > 3 || mGLX.hasExtension("GLX_ARB_multisample"); mHasARBCreateContext = mGLX.hasExtension("GLX_ARB_create_context"); mHasARBCreateContextProfile = mGLX.hasExtension("GLX_ARB_create_context_profile"); mHasEXTCreateContextES2Profile = mGLX.hasExtension("GLX_EXT_create_context_es2_profile"); // Choose the swap_control extension to use, if any. // The EXT version is better as it allows glXSwapInterval to be called per // window, while we'll potentially need to change the swap interval on each // swap buffers when using the SGI or MESA versions. if (mGLX.hasExtension("GLX_EXT_swap_control")) { mSwapControl = SwapControl::EXT; // In GLX_EXT_swap_control querying these is done on a GLXWindow so we just // set default values. mMinSwapInterval = 0; mMaxSwapInterval = 4; } else if (mGLX.hasExtension("GLX_MESA_swap_control")) { // If we have the Mesa or SGI extension, assume that you can at least set // a swap interval of 0 or 1. mSwapControl = SwapControl::Mesa; mMinSwapInterval = 0; mMinSwapInterval = 1; } else if (mGLX.hasExtension("GLX_SGI_swap_control")) { mSwapControl = SwapControl::SGI; mMinSwapInterval = 0; mMinSwapInterval = 1; } else { mSwapControl = SwapControl::Absent; mMinSwapInterval = 1; mMinSwapInterval = 1; } if (attribMap.contains(EGL_X11_VISUAL_ID_ANGLE)) { mRequestedVisual = attribMap.get(EGL_X11_VISUAL_ID_ANGLE, -1); // There is no direct way to get the GLXFBConfig matching an X11 visual ID // so we have to iterate over all the GLXFBConfigs to find the right one. int nConfigs; int attribList[] = { None, }; glx::FBConfig *allConfigs = mGLX.chooseFBConfig(attribList, &nConfigs); for (int i = 0; i < nConfigs; ++i) { if (getGLXFBConfigAttrib(allConfigs[i], GLX_VISUAL_ID) == mRequestedVisual) { mContextConfig = allConfigs[i]; break; } } XFree(allConfigs); if (mContextConfig == nullptr) { return egl::Error(EGL_NOT_INITIALIZED, "Invalid visual ID requested."); } } else { // When glXMakeCurrent is called, the context and the surface must be // compatible which in glX-speak means that their config have the same // color buffer type, are both RGBA or ColorIndex, and their buffers have // the same depth, if they exist. // Since our whole EGL implementation is backed by only one GL context, this // context must be compatible with all the GLXFBConfig corresponding to the // EGLconfigs that we will be exposing. int nConfigs; int attribList[] = { // We want RGBA8 and DEPTH24_STENCIL8 GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, // We want RGBA rendering (vs COLOR_INDEX) and doublebuffer GLX_RENDER_TYPE, GLX_RGBA_BIT, // Double buffer is not strictly required as a non-doublebuffer // context can work with a doublebuffered surface, but it still // flickers and all applications want doublebuffer anyway. GLX_DOUBLEBUFFER, True, // All of these must be supported for full EGL support GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PBUFFER_BIT | GLX_PIXMAP_BIT, // This makes sure the config have an associated visual Id GLX_X_RENDERABLE, True, GLX_CONFIG_CAVEAT, GLX_NONE, None }; glx::FBConfig *candidates = mGLX.chooseFBConfig(attribList, &nConfigs); if (nConfigs == 0) { XFree(candidates); return egl::Error(EGL_NOT_INITIALIZED, "Could not find a decent GLX FBConfig to create the context."); } mContextConfig = candidates[0]; XFree(candidates); } const auto &eglAttributes = display->getAttributeMap(); if (mHasARBCreateContext) { egl::Error error = initializeContext(mContextConfig, eglAttributes, &mContext); if (error.isError()) { return error; } } else { if (eglAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE) == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE) { return egl::Error(EGL_NOT_INITIALIZED, "Cannot create an OpenGL ES platform on GLX without the " "GLX_ARB_create_context extension."); } XVisualInfo visualTemplate; visualTemplate.visualid = getGLXFBConfigAttrib(mContextConfig, GLX_VISUAL_ID); int numVisuals = 0; XVisualInfo *visuals = XGetVisualInfo(xDisplay, VisualIDMask, &visualTemplate, &numVisuals); if (numVisuals <= 0) { return egl::Error(EGL_NOT_INITIALIZED, "Could not get the visual info from the fb config"); } ASSERT(numVisuals == 1); mContext = mGLX.createContext(&visuals[0], nullptr, true); XFree(visuals); if (!mContext) { return egl::Error(EGL_NOT_INITIALIZED, "Could not create GL context."); } } ASSERT(mContext); // FunctionsGL and DisplayGL need to make a few GL calls, for example to // query the version of the context so we need to make the context current. // glXMakeCurrent requires a GLXDrawable so we create a temporary Pbuffer // (of size 1, 1) for the duration of these calls. // Ideally we would want to unset the current context and destroy the pbuffer // before going back to the application but this is TODO // We could use a pbuffer of size (0, 0) but it fails on the Intel Mesa driver // as commented on https://bugs.freedesktop.org/show_bug.cgi?id=38869 so we // use (1, 1) instead. int dummyPbufferAttribs[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, None, }; mDummyPbuffer = mGLX.createPbuffer(mContextConfig, dummyPbufferAttribs); if (!mDummyPbuffer) { return egl::Error(EGL_NOT_INITIALIZED, "Could not create the dummy pbuffer."); } if (!mGLX.makeCurrent(mDummyPbuffer, mContext)) { return egl::Error(EGL_NOT_INITIALIZED, "Could not make the dummy pbuffer current."); } mFunctionsGL = new FunctionsGLGLX(mGLX.getProc); mFunctionsGL->initialize(); // TODO(cwallez, angleproject:1303) Disable the OpenGL ES backend on Linux NVIDIA and Intel as // it has problems on our automated testing. An OpenGL ES backend might not trigger this test if // there is no Desktop OpenGL support, but that's not the case in our automated testing. VendorID vendor = GetVendorID(mFunctionsGL); bool isOpenGLES = eglAttributes.get(EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE) == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE; if (isOpenGLES && (vendor == VENDOR_ID_INTEL || vendor == VENDOR_ID_NVIDIA)) { return egl::Error(EGL_NOT_INITIALIZED, "Intel or NVIDIA OpenGL ES drivers are not supported."); } syncXCommands(); std::string rendererString = reinterpret_cast<const char*>(mFunctionsGL->getString(GL_RENDERER)); mIsMesa = rendererString.find("Mesa") != std::string::npos; return DisplayGL::initialize(display); }
egl::Error DisplayOzone::initialize(egl::Display *display) { int fd; char deviceName[30]; drmModeResPtr resources = nullptr; for (int i = 0; i < 9; ++i) { snprintf(deviceName, sizeof(deviceName), "/dev/dri/card%d", i); fd = open(deviceName, O_RDWR | O_CLOEXEC); if (fd >= 0) { resources = drmModeGetResources(fd); if (resources) { if (resources->count_connectors > 0) { break; } drmModeFreeResources(resources); resources = nullptr; } close(fd); } } if (!resources) { return egl::Error(EGL_NOT_INITIALIZED, "Could not open drm device."); } mGBM = gbm_create_device(fd); if (!mGBM) { close(fd); drmModeFreeResources(resources); return egl::Error(EGL_NOT_INITIALIZED, "Could not create gbm device."); } mConnector = nullptr; bool monitorConnected = false; for (int i = 0; !mCRTC && i < resources->count_connectors; ++i) { drmModeFreeConnector(mConnector); mConnector = drmModeGetConnector(fd, resources->connectors[i]); if (!mConnector || mConnector->connection != DRM_MODE_CONNECTED) { continue; } monitorConnected = true; mMode = ChooseMode(mConnector); if (!mMode) { continue; } int n = ChooseCRTC(fd, mConnector); if (n < 0) { continue; } mCRTC = drmModeGetCrtc(fd, resources->crtcs[n]); } drmModeFreeResources(resources); if (mCRTC) { mWidth = mMode->hdisplay; mHeight = mMode->vdisplay; } else if (!monitorConnected) { // Even though there is no monitor to show it, we still do // everything the same as if there were one, so we need an // arbitrary size for our buffers. mWidth = 1280; mHeight = 1024; } else { return egl::Error(EGL_NOT_INITIALIZED, "Failed to choose mode/crtc."); } // ANGLE builds its executables with an RPATH so they pull in ANGLE's libGL and libEGL. // Here we need to open the native libEGL. An absolute path would work, but then we // couldn't use LD_LIBRARY_PATH which is often useful during development. Instead we take // advantage of the fact that the system lib is available under multiple names (for example // with a .1 suffix) while Angle only installs libEGL.so. FunctionsEGLDL *egl = new FunctionsEGLDL(); mEGL = egl; ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), "libEGL.so.1")); const char *necessaryExtensions[] = { "EGL_KHR_image_base", "EGL_EXT_image_dma_buf_import", "EGL_KHR_surfaceless_context", }; for (auto &ext : necessaryExtensions) { if (!mEGL->hasExtension(ext)) { return egl::Error(EGL_NOT_INITIALIZED, "need %s", ext); } } if (mEGL->hasExtension("EGL_MESA_configless_context")) { mConfig = EGL_NO_CONFIG_MESA; } else { // clang-format off const EGLint attrib[] = { // We want RGBA8 and DEPTH24_STENCIL8 EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_NONE, }; // clang-format on EGLint numConfig; EGLConfig config[1]; if (!mEGL->chooseConfig(attrib, config, 1, &numConfig) || numConfig < 1) { return egl::Error(EGL_NOT_INITIALIZED, "Could not get EGL config."); } mConfig = config[0]; } ANGLE_TRY(initializeContext(display->getAttributeMap())); if (!mEGL->makeCurrent(EGL_NO_SURFACE, mContext)) { return egl::Error(EGL_NOT_INITIALIZED, "Could not make context current."); } mFunctionsGL = mEGL->makeFunctionsGL(); mFunctionsGL->initialize(); return DisplayGL::initialize(display); }
egl::Error DisplayGLX::initialize(egl::Display *display) { mEGLDisplay = display; Display *xDisplay = display->getNativeDisplayId(); // ANGLE_platform_angle allows the creation of a default display // using EGL_DEFAULT_DISPLAY (= nullptr). In this case just open // the display specified by the DISPLAY environment variable. if (xDisplay == EGL_DEFAULT_DISPLAY) { mUsesNewXDisplay = true; xDisplay = XOpenDisplay(NULL); if (!xDisplay) { return egl::Error(EGL_NOT_INITIALIZED, "Could not open the default X display."); } } std::string glxInitError; if (!mGLX.initialize(xDisplay, DefaultScreen(xDisplay), &glxInitError)) { return egl::Error(EGL_NOT_INITIALIZED, glxInitError.c_str()); } // Check we have the needed extensions { if (mGLX.minorVersion == 3 && !mGLX.hasExtension("GLX_ARB_multisample")) { return egl::Error(EGL_NOT_INITIALIZED, "GLX doesn't support ARB_multisample."); } // Require ARB_create_context which has been supported since Mesa 9 unconditionnaly // and is present in Mesa 8 in an almost always on compile flag. Also assume proprietary // drivers have it. if (!mGLX.hasExtension("GLX_ARB_create_context")) { return egl::Error(EGL_NOT_INITIALIZED, "GLX doesn't support ARB_create_context."); } } // When glXMakeCurrent is called, the context and the surface must be // compatible which in glX-speak means that their config have the same // color buffer type, are both RGBA or ColorIndex, and their buffers have // the same depth, if they exist. // Since our whole EGL implementation is backed by only one GL context, this // context must be compatible with all the GLXFBConfig corresponding to the // EGLconfigs that we will be exposing. { int nConfigs; int attribList[] = { // We want RGBA8 and DEPTH24_STENCIL8 GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, // We want RGBA rendering (vs COLOR_INDEX) and doublebuffer GLX_RENDER_TYPE, GLX_RGBA_BIT, // Double buffer is not strictly required as a non-doublebuffer // context can work with a doublebuffered surface, but it still // flickers and all applications want doublebuffer anyway. GLX_DOUBLEBUFFER, True, // All of these must be supported for full EGL support GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PBUFFER_BIT | GLX_PIXMAP_BIT, // This makes sure the config have an associated visual Id GLX_X_RENDERABLE, True, GLX_CONFIG_CAVEAT, GLX_NONE, None }; glx::FBConfig* candidates = mGLX.chooseFBConfig(attribList, &nConfigs); if (nConfigs == 0) { XFree(candidates); return egl::Error(EGL_NOT_INITIALIZED, "Could not find a decent GLX FBConfig to create the context."); } mContextConfig = candidates[0]; XFree(candidates); } mContext = initializeContext(mContextConfig, display->getAttributeMap()); if (!mContext) { return egl::Error(EGL_NOT_INITIALIZED, "Could not create GL context."); } // FunctionsGL and DisplayGL need to make a few GL calls, for example to // query the version of the context so we need to make the context current. // glXMakeCurrent requires a GLXDrawable so we create a temporary Pbuffer // (of size 1, 1) for the duration of these calls. // Ideally we would want to unset the current context and destroy the pbuffer // before going back to the application but this is TODO // We could use a pbuffer of size (0, 0) but it fails on the Intel Mesa driver // as commented on https://bugs.freedesktop.org/show_bug.cgi?id=38869 so we // use (1, 1) instead. int dummyPbufferAttribs[] = { GLX_PBUFFER_WIDTH, 1, GLX_PBUFFER_HEIGHT, 1, None, }; mDummyPbuffer = mGLX.createPbuffer(mContextConfig, dummyPbufferAttribs); if (!mDummyPbuffer) { return egl::Error(EGL_NOT_INITIALIZED, "Could not create the dummy pbuffer."); } if (!mGLX.makeCurrent(mDummyPbuffer, mContext)) { return egl::Error(EGL_NOT_INITIALIZED, "Could not make the dummy pbuffer current."); } mFunctionsGL = new FunctionsGLGLX(mGLX.getProc); mFunctionsGL->initialize(); syncXCommands(); std::string rendererString = reinterpret_cast<const char*>(mFunctionsGL->getString(GL_RENDERER)); mIsMesa = rendererString.find("Mesa") != std::string::npos; return DisplayGL::initialize(display); }
egl::Error DisplayAndroid::initialize(egl::Display *display) { FunctionsEGLDL *egl = new FunctionsEGLDL(); mEGL = egl; ANGLE_TRY(egl->initialize(display->getNativeDisplayId(), GetEGLPath())); gl::Version eglVersion(mEGL->majorVersion, mEGL->minorVersion); ASSERT(eglVersion >= gl::Version(1, 4)); static_assert(EGL_OPENGL_ES3_BIT == EGL_OPENGL_ES3_BIT_KHR, "Extension define must match core"); EGLint esBit = (eglVersion >= gl::Version(1, 5) || mEGL->hasExtension("EGL_KHR_create_context")) ? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT; // clang-format off mConfigAttribList = { // Choose RGBA8888 EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, // EGL1.5 spec Section 2.2 says that depth, multisample and stencil buffer depths // must match for contexts to be compatible. EGL_DEPTH_SIZE, 24, EGL_STENCIL_SIZE, 8, EGL_SAMPLE_BUFFERS, 0, // Android doesn't support pixmaps EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, EGL_CONFIG_CAVEAT, EGL_NONE, EGL_CONFORMANT, esBit, EGL_RENDERABLE_TYPE, esBit, EGL_NONE }; // clang-format on EGLint numConfig; EGLBoolean success = mEGL->chooseConfig(mConfigAttribList.data(), &mConfig, 1, &numConfig); if (success == EGL_FALSE) { return egl::Error(mEGL->getError(), "eglChooseConfig failed"); } ANGLE_TRY(initializeContext(display->getAttributeMap())); int dummyPbufferAttribs[] = { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE, }; mDummyPbuffer = mEGL->createPbufferSurface(mConfig, dummyPbufferAttribs); if (mDummyPbuffer == EGL_NO_SURFACE) { return egl::Error(mEGL->getError(), "eglCreatePbufferSurface failed"); } success = mEGL->makeCurrent(mDummyPbuffer, mContext); if (success == EGL_FALSE) { return egl::Error(mEGL->getError(), "eglMakeCurrent failed"); } mFunctionsGL = mEGL->makeFunctionsGL(); mFunctionsGL->initialize(); return DisplayGL::initialize(display); }
netease_encrypt::netease_encrypt() { initializeContext(); }