コード例 #1
0
ファイル: egl_display_impl.cpp プロジェクト: epowers/arc
EGLBoolean EglDisplayImpl::ChooseConfigs(const EGLint* attribs,
                                         EGLConfig* configs,
                                         EGLint configs_size,
                                         EGLint* num_config) {
  int count = 0;
  EglConfigImpl dummy(attribs);
  const EGLConfig egl_config = dummy.GetKey();
  if (egl_config != reinterpret_cast<EGLConfig>(EGL_DONT_CARE)) {
    const EglConfigImpl* cfg = GetConfig(egl_config);
    if (cfg && configs_size > 0) {
      configs[0] = cfg->GetKey();
      count = 1;
    } else {
      count = 0;
    }
  } else {
    for (ConfigSet::iterator i = configs_.begin(); i != configs_.end(); ++i) {
      if (i->Matches(dummy)) {
        if (configs) {
          if (count >= configs_size) {
            break;
          }
          configs[count] = i->GetKey();
        }
        ++count;
      }
    }
  }

  if (num_config) {
    *num_config = count;
  }

  return EGL_TRUE;
}
コード例 #2
0
ファイル: egl_display_impl.cpp プロジェクト: epowers/arc
EGLBoolean EglDisplayImpl::GetConfigs(EGLConfig* configs, EGLint config_size,
                                      EGLint* num_config) {
  const EGLint total_configs = GetNumConfigs();
  if (!configs) {
    *num_config = total_configs;
    return EGL_TRUE;
  }

  int count = 0;
  const EGLint max_configs = std::min(total_configs, config_size);
  for (ConfigSet::iterator i = configs_.begin(); i != configs_.end(); ++i) {
    if (count >= max_configs) {
      break;
    }
    configs[count] = i->GetKey();
    ++count;
  }
  LOG_ALWAYS_FATAL_IF(!num_config, "num_config must be non-NULL");
  *num_config = count;
  return EGL_TRUE;
}
コード例 #3
0
ファイル: egl_display_impl.cpp プロジェクト: epowers/arc
void EglDisplayImpl::Initialize() {
  Mutex::Autolock mutex(&lock_);
  if (initialized_) {
    return;
  }

  window_ = Native::CreateNativeWindow();
  LOG_ALWAYS_FATAL_IF(!window_, "Could not create native window.");

  EGLConfig cfg = NULL;
  for (ConfigSet::iterator it = configs_.begin(); it != configs_.end(); ++it) {
    const EGLint r = it->GetValue(EGL_RED_SIZE);
    const EGLint g = it->GetValue(EGL_GREEN_SIZE);
    const EGLint b = it->GetValue(EGL_BLUE_SIZE);
    if (r > 0 && g > 0 && b > 0) {
      cfg = it->GetKey();
      break;
    }
  }

  EGLint err = 0;
  global_context_ = EglContextImpl::Create(kDefaultDisplay, cfg, NULL, 2, &err);

  // Bind the window surface here in order for the compositor to be associated
  // with the correct context.  (The compositor associates itself to the first
  // surface that is bound.)
  ContextPtr ctx = contexts_.Get(global_context_);
  Native::BindNativeWindow(window_, ctx->GetNativeContext());

  // Force the GlesContext owned by the global context to be initialized at
  // least once.
  EglThreadInfo& info = EglThreadInfo::GetInstance();
  info.SetCurrentContext(ctx);
  ctx->GetGlesContext()->OnMakeCurrent();
  info.SetCurrentContext(ContextPtr());

  initialized_ = true;
}