summaryrefslogtreecommitdiffstats
path: root/gpu/config/gpu_util.cc
blob: bed1f0c7110d04157229a0b11d888e0979e6b96e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gpu/config/gpu_util.h"

#include <vector>

#include "base/logging.h"
#include "ui/gl/gl_switches.h"

namespace gpu {

GpuSwitchingOption StringToGpuSwitchingOption(
    const std::string& switching_string) {
  if (switching_string == switches::kGpuSwitchingOptionNameAutomatic)
    return GPU_SWITCHING_OPTION_AUTOMATIC;
  if (switching_string == switches::kGpuSwitchingOptionNameForceIntegrated)
    return GPU_SWITCHING_OPTION_FORCE_INTEGRATED;
  if (switching_string == switches::kGpuSwitchingOptionNameForceDiscrete)
    return GPU_SWITCHING_OPTION_FORCE_DISCRETE;
  return GPU_SWITCHING_OPTION_UNKNOWN;
}

std::string GpuSwitchingOptionToString(GpuSwitchingOption option) {
  switch (option) {
    case GPU_SWITCHING_OPTION_AUTOMATIC:
      return switches::kGpuSwitchingOptionNameAutomatic;
    case GPU_SWITCHING_OPTION_FORCE_INTEGRATED:
      return switches::kGpuSwitchingOptionNameForceIntegrated;
    case GPU_SWITCHING_OPTION_FORCE_DISCRETE:
      return switches::kGpuSwitchingOptionNameForceDiscrete;
    default:
      return "unknown";
  }
}

void MergeFeatureSets(std::set<int>* dst, const std::set<int>& src) {
  DCHECK(dst);
  if (src.empty())
    return;
  dst->insert(src.begin(), src.end());
}

}  // namespace gpu