EGLSurface EGLAPIENTRY CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list) { EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLNativePixmapType pixmap = " "0x%0.8p, " "const EGLint *attrib_list = 0x%0.8p)", dpy, config, pixmap, attrib_list); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Config *configuration = static_cast<Config *>(config); Error error = ValidateConfig(display, configuration); if (error.isError()) { thread->setError(error); return EGL_NO_SURFACE; } UNIMPLEMENTED(); // FIXME thread->setError(NoError()); return EGL_NO_SURFACE; }
void every(const double delay, SharedPtr<Reactor> reactor, Callback<Error> &&callback, std::function<bool()> &&stop_predicate, Callback<> &&callable) { reactor->call_soon([ =, callback = std::move(callback), stop_predicate = std::move(stop_predicate), callable = std::move(callable) ]() mutable { if (delay <= 0.0) { callback(ValueError()); return; } if (stop_predicate()) { callback(NoError()); return; } callable(); reactor->call_later(delay, [ =, callback = std::move(callback), stop_predicate = std::move(stop_predicate), callable = std::move(callable) ]() mutable { every(delay, reactor, std::move(callback), std::move(stop_predicate), std::move(callable)); }); }); }
Error Surface::destroyImpl(const Display *display) { if (mState.defaultFramebuffer) { mState.defaultFramebuffer->destroyDefault(display); } if (mImplementation) { mImplementation->destroy(display); } if (mTexture.get()) { if (mImplementation) { ANGLE_TRY(mImplementation->releaseTexImage(EGL_BACK_BUFFER)); } auto glErr = mTexture->releaseTexImageFromSurface(display->getProxyContext()); if (glErr.isError()) { return Error(EGL_BAD_SURFACE); } mTexture.set(nullptr, nullptr); } if (mState.defaultFramebuffer) { mState.defaultFramebuffer->onDestroy(display->getProxyContext()); } SafeDelete(mState.defaultFramebuffer); SafeDelete(mImplementation); delete this; return NoError(); }
Error FramebufferAttachment::initializeContents(const Context *context) { ASSERT(mResource); ANGLE_TRY(mResource->initializeContents(context, mTarget.textureIndex())); setInitState(InitState::Initialized); return NoError(); }
EGLBoolean EGLAPIENTRY GetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config) { EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLConfig *configs = 0x%0.8p, " "EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", dpy, configs, config_size, num_config); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Error error = ValidateGetConfigs(display, config_size, num_config); if (error.isError()) { thread->setError(error); return EGL_FALSE; } ClipConfigs(display->getConfigs(AttributeMap()), configs, config_size, num_config); thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target) { EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLNativePixmapType target = " "0x%0.8p)", dpy, surface, target); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = static_cast<Surface *>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (display->testDeviceLost()) { thread->setError(EglContextLost()); return EGL_FALSE; } UNIMPLEMENTED(); // FIXME thread->setError(NoError()); return 0; }
EGLBoolean EGLAPIENTRY DestroySurface(EGLDisplay dpy, EGLSurface surface) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p)", dpy, surface); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = static_cast<Surface *>(surface); Error error = ValidateSurface(display, eglSurface); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (surface == EGL_NO_SURFACE) { thread->setError(EglBadSurface()); return EGL_FALSE; } error = display->destroySurface(reinterpret_cast<Surface *>(surface)); if (error.isError()) { thread->setError(error); return EGL_FALSE; } thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY WaitGL(void) { EVENT("()"); Thread *thread = GetCurrentThread(); Display *display = thread->getCurrentDisplay(); Error error = ValidateDisplay(display); if (error.isError()) { thread->setError(error); return EGL_FALSE; } // eglWaitGL like calling eglWaitClient with the OpenGL ES API bound. Since we only implement // OpenGL ES we can do the call directly. error = display->waitClient(thread->getContext()); if (error.isError()) { thread->setError(error); return EGL_FALSE; } thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY WaitNative(EGLint engine) { EVENT("(EGLint engine = %d)", engine); Thread *thread = GetCurrentThread(); Display *display = thread->getCurrentDisplay(); Error error = ValidateDisplay(display); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (engine != EGL_CORE_NATIVE_ENGINE) { thread->setError(EglBadParameter() << "the 'engine' parameter has an unrecognized value"); } error = display->waitNative(thread->getContext(), engine); if (error.isError()) { thread->setError(error); return EGL_FALSE; } thread->setError(NoError()); return EGL_TRUE; }
EGLContext EGLAPIENTRY CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list) { EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLContext share_context = " "0x%0.8p, " "const EGLint *attrib_list = 0x%0.8p)", dpy, config, share_context, attrib_list); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Config *configuration = static_cast<Config *>(config); gl::Context *sharedGLContext = static_cast<gl::Context *>(share_context); AttributeMap attributes = AttributeMap::CreateFromIntArray(attrib_list); Error error = ValidateCreateContext(display, configuration, sharedGLContext, attributes); if (error.isError()) { thread->setError(error); return EGL_NO_CONTEXT; } gl::Context *context = nullptr; error = display->createContext(configuration, sharedGLContext, attributes, &context); if (error.isError()) { thread->setError(error); return EGL_NO_CONTEXT; } thread->setError(NoError()); return static_cast<EGLContext>(context); }
EGLBoolean EGLAPIENTRY SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value) { EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLSurface surface = 0x%0.8p, EGLint attribute = %d, EGLint " "value = %d)", dpy, surface, attribute, value); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Surface *eglSurface = static_cast<Surface *>(surface); Error error = ValidateSurfaceAttrib(display, eglSurface, attribute, value); if (error.isError()) { thread->setError(error); return EGL_FALSE; } SetSurfaceAttrib(eglSurface, attribute, value); thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY ChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config) { EVENT( "(EGLDisplay dpy = 0x%0.8p, const EGLint *attrib_list = 0x%0.8p, " "EGLConfig *configs = 0x%0.8p, EGLint config_size = %d, EGLint *num_config = 0x%0.8p)", dpy, attrib_list, configs, config_size, num_config); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); AttributeMap attribMap = AttributeMap::CreateFromIntArray(attrib_list); Error error = ValidateChooseConfig(display, attribMap, config_size, num_config); if (error.isError()) { thread->setError(error); return EGL_FALSE; } ClipConfigs(display->getConfigs(attribMap), configs, config_size, num_config); thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value) { EVENT( "(EGLDisplay dpy = 0x%0.8p, EGLConfig config = 0x%0.8p, EGLint attribute = %d, EGLint " "*value = 0x%0.8p)", dpy, config, attribute, value); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Config *configuration = static_cast<Config *>(config); Error error = ValidateGetConfigAttrib(display, configuration, attribute); if (error.isError()) { thread->setError(error); return EGL_FALSE; } QueryConfigAttrib(configuration, attribute, value); thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY Terminate(EGLDisplay dpy) { EVENT("(EGLDisplay dpy = 0x%0.8p)", dpy); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display)) { thread->setError(EglBadDisplay()); return EGL_FALSE; } if (display->isValidContext(thread->getContext())) { thread->setCurrent(nullptr); } Error error = display->terminate(); if (error.isError()) { thread->setError(error); return EGL_FALSE; } thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY Initialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint *major = 0x%0.8p, EGLint *minor = 0x%0.8p)", dpy, major, minor); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); if (dpy == EGL_NO_DISPLAY || !Display::isValidDisplay(display)) { thread->setError(EglBadDisplay()); return EGL_FALSE; } Error error = display->initialize(); if (error.isError()) { thread->setError(error); return EGL_FALSE; } if (major) *major = 1; if (minor) *minor = 4; thread->setError(NoError()); return EGL_TRUE; }
EGLBoolean EGLAPIENTRY SwapInterval(EGLDisplay dpy, EGLint interval) { EVENT("(EGLDisplay dpy = 0x%0.8p, EGLint interval = %d)", dpy, interval); Thread *thread = GetCurrentThread(); Display *display = static_cast<Display *>(dpy); Error error = ValidateDisplay(display); if (error.isError()) { thread->setError(error); return EGL_FALSE; } Surface *draw_surface = static_cast<Surface *>(thread->getCurrentDrawSurface()); if (draw_surface == nullptr) { thread->setError(EglBadSurface()); return EGL_FALSE; } const egl::Config *surfaceConfig = draw_surface->getConfig(); EGLint clampedInterval = std::min(std::max(interval, surfaceConfig->minSwapInterval), surfaceConfig->maxSwapInterval); draw_surface->setSwapInterval(clampedInterval); thread->setError(NoError()); return EGL_TRUE; }
Error Surface::initialize(const Display *display) { ANGLE_TRY(mImplementation->initialize(display)); // Initialized here since impl is nullptr in the constructor. // Must happen after implementation initialize for Android. mSwapBehavior = mImplementation->getSwapBehavior(); if (mBuftype == EGL_IOSURFACE_ANGLE) { GLenum internalFormat = static_cast<GLenum>(mState.attributes.get(EGL_TEXTURE_INTERNAL_FORMAT_ANGLE)); GLenum type = static_cast<GLenum>(mState.attributes.get(EGL_TEXTURE_TYPE_ANGLE)); mColorFormat = gl::Format(internalFormat, type); } if (mBuftype == EGL_D3D_TEXTURE_ANGLE) { const angle::Format *colorFormat = mImplementation->getD3DTextureColorFormat(); ASSERT(colorFormat != nullptr); GLenum internalFormat = colorFormat->fboImplementationInternalFormat; mColorFormat = gl::Format(internalFormat, colorFormat->componentType); mGLColorspace = EGL_GL_COLORSPACE_LINEAR; if (mColorFormat.info->colorEncoding == GL_SRGB) { mGLColorspace = EGL_GL_COLORSPACE_SRGB; } } return NoError(); }
void DryadSubGraphVertex::VertexCompleted(DrError status, DryadMetaData* errorData) { bool finished = false; { AutoCriticalSection acs(&m_baseCS); LogAssert(GetErrorCode() != DryadError_VertexCompleted); if (status == DryadError_VertexCompleted) { status = DrError_OK; } if (NoError()) { ReportError(status, errorData); } LogAssert(m_outstandingVertices > 0); --m_outstandingVertices; if (m_outstandingVertices == 0) { finished = true; } } if (finished) { /* the real status will be returned in AsyncPostCompletion after we have exited all handlers. */ m_handler->ProgramCompleted(); } }
void DryadSubGraphVertex::Initialize(UInt32 numberOfInputChannels, UInt32 numberOfOutputChannels) { DrError err; DryadMetaData* metaData = GetMetaData(); if (metaData == NULL) { ReportError(DryadError_VertexInitialization, "No MetaData In Start Command"); return; } DryadMetaDataRef graphData; err = metaData->LookUpMetaData(DryadTag_GraphDescription, &graphData); if (err != DrError_OK) { ReportError(DryadError_VertexInitialization, "No GraphDescription Tag"); return; } ReadVertices(graphData); if (NoError() == false) { return; } ReadEdges(graphData); }
ErrorOr<std::string> slurp(std::string path) { ErrorOr<std::vector<char>> v = slurpv<char>(path); if (!v) { return {v.as_error(), std::string{}}; } std::string s{v->begin(), v->end()}; /* Note that here we make a copy */ return {NoError(), std::move(s)}; }
Error Buffer::bufferSubData(GLenum target, const void *data, GLsizeiptr size, GLintptr offset) { ANGLE_TRY(mBuffer->setSubData(target, data, size, offset)); mIndexRangeCache.invalidateRange(static_cast<unsigned int>(offset), static_cast<unsigned int>(size)); return NoError(); }
Error Surface::setIsCurrent(const gl::Context *context, bool isCurrent) { if (isCurrent) { mCurrentCount++; return NoError(); } ASSERT(mCurrentCount > 0); mCurrentCount--; if (mCurrentCount == 0 && mDestroyed) { ASSERT(context); return destroyImpl(context->getCurrentDisplay()); } return NoError(); }
Error Buffer::getIndexRange(GLenum type, size_t offset, size_t count, bool primitiveRestartEnabled, IndexRange *outRange) const { if (mIndexRangeCache.findRange(type, offset, count, primitiveRestartEnabled, outRange)) { return NoError(); } ANGLE_TRY(mBuffer->getIndexRange(type, offset, count, primitiveRestartEnabled, outRange)); mIndexRangeCache.addRange(type, offset, count, primitiveRestartEnabled, *outRange); return NoError(); }
nlohmann::json represent_string(const std::string &s) { Error error = utf8_parse(s); if (error != NoError()) { return nlohmann::json{{"format", "base64"}, {"data", base64_encode(s)}}; } return s; }
Error Buffer::copyBufferSubData(Buffer* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) { ANGLE_TRY(mBuffer->copySubData(source->getImplementation(), sourceOffset, destOffset, size)); mIndexRangeCache.invalidateRange(static_cast<unsigned int>(destOffset), static_cast<unsigned int>(size)); return NoError(); }
Error parse_iso8601_utc(std::string ts, std::tm *tmb) { *tmb = {}; // "portable programs should initialize the structure" std::istringstream ss(ts); ss >> std::get_time(tmb, "%Y-%m-%dT%H:%M:%SZ"); if (ss.fail()) { return ValueError(); } return NoError(); }
Error Surface::onDestroy(const Display *display) { mDestroyed = true; if (mRefCount == 0) { return destroyImpl(display); } return NoError(); }
// EGL 1.0 EGLint EGLAPIENTRY GetError(void) { EVENT("()"); Thread *thread = GetCurrentThread(); EGLint error = thread->getError(); thread->setError(NoError()); return error; }
EGLBoolean EGLAPIENTRY ReleaseThread(void) { EVENT("()"); Thread *thread = GetCurrentThread(); MakeCurrent(EGL_NO_DISPLAY, EGL_NO_CONTEXT, EGL_NO_SURFACE, EGL_NO_SURFACE); thread->setError(NoError()); return EGL_TRUE; }
EGLenum EGLAPIENTRY QueryAPI(void) { EVENT("()"); Thread *thread = GetCurrentThread(); EGLenum API = thread->getAPI(); thread->setError(NoError()); return API; }