OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/gpu_feature_flags.h" | 5 #include "content/common/gpu_feature_flags.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | |
9 #include <vector> | |
jam
2011/04/12 17:55:49
nit: this should go on line 7, and have a blank li
| |
8 | 10 |
9 const char GpuFeatureFlags::kGpuFeatureNameAccelerated2dCanvas[] = | 11 const char GpuFeatureFlags::kGpuFeatureNameAccelerated2dCanvas[] = |
10 "accelerated_2d_canvas"; | 12 "accelerated_2d_canvas"; |
11 const char GpuFeatureFlags::kGpuFeatureNameAcceleratedCompositing[] = | 13 const char GpuFeatureFlags::kGpuFeatureNameAcceleratedCompositing[] = |
12 "accelerated_compositing"; | 14 "accelerated_compositing"; |
13 const char GpuFeatureFlags::kGpuFeatureNameWebgl[] = "webgl"; | 15 const char GpuFeatureFlags::kGpuFeatureNameWebgl[] = "webgl"; |
14 const char GpuFeatureFlags::kGpuFeatureNameMultisampling[] = "multisampling"; | 16 const char GpuFeatureFlags::kGpuFeatureNameMultisampling[] = "multisampling"; |
15 const char GpuFeatureFlags::kGpuFeatureNameAll[] = "all"; | 17 const char GpuFeatureFlags::kGpuFeatureNameAll[] = "all"; |
18 const char GpuFeatureFlags::kGpuFeatureNameUnknown[] = "unknown"; | |
16 | 19 |
17 GpuFeatureFlags::GpuFeatureFlags() | 20 GpuFeatureFlags::GpuFeatureFlags() |
18 : flags_(0) { | 21 : flags_(0) { |
19 } | 22 } |
20 | 23 |
21 void GpuFeatureFlags::set_flags(uint32 flags) { | 24 void GpuFeatureFlags::set_flags(uint32 flags) { |
22 DCHECK_EQ(flags & (~kGpuFeatureAll), 0u); | 25 DCHECK_EQ(flags & (~kGpuFeatureAll), 0u); |
23 flags_ = flags; | 26 flags_ = flags; |
24 } | 27 } |
25 | 28 |
26 uint32 GpuFeatureFlags::flags() const { | 29 uint32 GpuFeatureFlags::flags() const { |
27 return flags_; | 30 return flags_; |
28 } | 31 } |
29 | 32 |
30 void GpuFeatureFlags::Combine(const GpuFeatureFlags& other) { | 33 void GpuFeatureFlags::Combine(const GpuFeatureFlags& other) { |
31 flags_ |= other.flags_; | 34 flags_ |= other.flags_; |
32 } | 35 } |
33 | 36 |
37 // static | |
34 GpuFeatureFlags::GpuFeatureType GpuFeatureFlags::StringToGpuFeatureType( | 38 GpuFeatureFlags::GpuFeatureType GpuFeatureFlags::StringToGpuFeatureType( |
35 const std::string& feature_string) { | 39 const std::string& feature_string) { |
36 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) | 40 if (feature_string == kGpuFeatureNameAccelerated2dCanvas) |
37 return kGpuFeatureAccelerated2dCanvas; | 41 return kGpuFeatureAccelerated2dCanvas; |
38 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) | 42 else if (feature_string == kGpuFeatureNameAcceleratedCompositing) |
39 return kGpuFeatureAcceleratedCompositing; | 43 return kGpuFeatureAcceleratedCompositing; |
40 else if (feature_string == kGpuFeatureNameWebgl) | 44 else if (feature_string == kGpuFeatureNameWebgl) |
41 return kGpuFeatureWebgl; | 45 return kGpuFeatureWebgl; |
42 else if (feature_string == kGpuFeatureNameMultisampling) | 46 else if (feature_string == kGpuFeatureNameMultisampling) |
43 return kGpuFeatureMultisampling; | 47 return kGpuFeatureMultisampling; |
44 else if (feature_string == kGpuFeatureNameAll) | 48 else if (feature_string == kGpuFeatureNameAll) |
45 return kGpuFeatureAll; | 49 return kGpuFeatureAll; |
46 return kGpuFeatureUnknown; | 50 return kGpuFeatureUnknown; |
47 } | 51 } |
48 | 52 |
53 // static | |
54 std::string GpuFeatureFlags::GpuFeatureTypeToString( | |
55 GpuFeatureFlags::GpuFeatureType type) { | |
56 std::vector<std::string> matches; | |
57 if (type == kGpuFeatureAll) { | |
58 matches.push_back(kGpuFeatureNameAll); | |
59 } else { | |
60 if (kGpuFeatureAccelerated2dCanvas & type) | |
61 matches.push_back(kGpuFeatureNameAccelerated2dCanvas); | |
62 if (kGpuFeatureAcceleratedCompositing & type) | |
63 matches.push_back(kGpuFeatureNameAcceleratedCompositing); | |
64 if (kGpuFeatureWebgl & type) | |
65 matches.push_back(kGpuFeatureNameWebgl); | |
66 if (kGpuFeatureMultisampling & type) | |
67 matches.push_back(kGpuFeatureNameMultisampling); | |
68 if (!matches.size()) | |
69 matches.push_back(kGpuFeatureNameUnknown); | |
70 } | |
71 return JoinString(matches, ','); | |
72 } | |
OLD | NEW |