本文整理汇总了C++中ContextPtr::SetCurrent方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextPtr::SetCurrent方法的具体用法?C++ ContextPtr::SetCurrent怎么用?C++ ContextPtr::SetCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextPtr
的用法示例。
在下文中一共展示了ContextPtr::SetCurrent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeCurrent
EGLint EglDisplayImpl::MakeCurrent(EGLContext egl_ctx, EGLSurface egl_draw,
EGLSurface egl_read) {
if (egl_read != egl_draw) {
LOG_ALWAYS_FATAL("Read and draw surfaces must be the same.");
return EGL_BAD_MATCH;
}
ContextPtr ctx = contexts_.Get(egl_ctx);
SurfacePtr sfc = surfaces_.Get(egl_draw);
bool release = ctx == NULL && sfc == NULL;
// If a context is being set, then a surface must be set. Similarly, if a
// context is being cleared, the surface must be cleared. Any other
// combination is an error.
const bool invalid_surface = ctx != NULL ? sfc == NULL : sfc != NULL;
if (!release && invalid_surface) {
return EGL_BAD_MATCH;
}
EglThreadInfo& info = EglThreadInfo::GetInstance();
ContextPtr prev_ctx = info.GetCurrentContext();
SurfacePtr prev_sfc =
prev_ctx != NULL ? prev_ctx->GetSurface() : SurfacePtr();
if (release) {
if (prev_ctx != NULL) {
prev_ctx->Flush();
info.SetCurrentContext(ContextPtr());
}
} else {
if (ctx == NULL) {
return EGL_BAD_CONTEXT;
}
if (ctx->config != sfc->config) {
return EGL_BAD_MATCH;
}
if (ctx != NULL && prev_ctx != NULL) {
if (ctx == prev_ctx) {
if (sfc == prev_sfc) {
// Reassigning the same context and surface.
return EGL_SUCCESS;
}
} else {
// Make sure to clear the previous context.
release = true;
}
}
if (prev_ctx != NULL) {
prev_ctx->Flush();
}
if (!ctx->SetCurrent()) {
return EGL_BAD_ACCESS;
}
info.SetCurrentContext(ctx);
ctx->SetSurface(sfc);
}
if (prev_ctx != NULL && release) {
prev_ctx->ClearCurrent();
prev_ctx->ClearSurface();
}
return EGL_SUCCESS;
}