Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: remoting/host/host_attributes.cc

Issue 2941623003: [Chromoting] Use latest API to check whether DX capturer is supported (Closed)
Patch Set: Remove DirectX-Capturer attribute, use Windows version instead Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "remoting/host/host_attributes.h" 5 #include "remoting/host/host_attributes.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <D3DCommon.h> 8 #include <D3DCommon.h>
9 #endif 9 #endif
10 10
11 #include <type_traits> 11 #include <type_traits>
12 12
13 #include "base/atomicops.h" 13 #include "base/atomicops.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/strings/string_piece.h"
17 #include "base/strings/string_util.h"
18 #include "base/win/windows_version.h"
16 #include "build/build_config.h" 19 #include "build/build_config.h"
17 20
18 #if defined(OS_WIN) 21 #if defined(OS_WIN)
19 #include "third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_control ler.h" 22 #include "third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_control ler.h"
20 #include "third_party/webrtc/modules/desktop_capture/win/screen_capturer_win_dir ectx.h" 23 #include "third_party/webrtc/modules/desktop_capture/win/screen_capturer_win_dir ectx.h"
21 #endif 24 #endif
22 25
23 namespace remoting { 26 namespace remoting {
24 27
25 namespace { 28 namespace {
29
26 static constexpr char kSeparator[] = ","; 30 static constexpr char kSeparator[] = ",";
27 31
28 struct Attribute { 32 struct Attribute {
29 const char* name; 33 const char* name;
30 bool(* get_value_func)(); 34 bool(* get_value_func)();
31 }; 35 };
32 36
33 inline constexpr bool IsDebug() { 37 inline constexpr bool IsDebug() {
34 #if defined(NDEBUG) 38 #if defined(NDEBUG)
35 return false; 39 return false;
(...skipping 21 matching lines...) Expand all
57 return true; 61 return true;
58 #else 62 #else
59 return false; 63 return false;
60 #endif 64 #endif
61 } 65 }
62 66
63 inline constexpr bool IsNonOfficialBuild() { 67 inline constexpr bool IsNonOfficialBuild() {
64 return !IsOfficialBuild(); 68 return !IsOfficialBuild();
65 } 69 }
66 70
67 #if defined(OS_WIN)
68 inline bool MinD3DFeatureLevelGreatThan10() {
69 webrtc::DxgiDuplicatorController::D3dInfo info;
70 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) {
71 return info.min_feature_level >= D3D_FEATURE_LEVEL_10_0;
72 }
73 return false;
74 }
75
76 inline bool MinD3DFeatureLevelGreatThan11() {
77 webrtc::DxgiDuplicatorController::D3dInfo info;
78 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) {
79 return info.min_feature_level >= D3D_FEATURE_LEVEL_11_0;
80 }
81 return false;
82 }
83
84 inline bool MinD3DFeatureLevelGreatThan12() {
85 webrtc::DxgiDuplicatorController::D3dInfo info;
86 if (webrtc::DxgiDuplicatorController::Instance()->RetrieveD3dInfo(&info)) {
87 return info.min_feature_level >= D3D_FEATURE_LEVEL_12_0;
88 }
89 return false;
90 }
91 #endif
92
93 // By using arraysize() macro in base/macros.h, it's illegal to have empty 71 // By using arraysize() macro in base/macros.h, it's illegal to have empty
94 // arrays. 72 // arrays.
95 // 73 //
96 // error: no matching function for call to 'ArraySizeHelper' 74 // error: no matching function for call to 'ArraySizeHelper'
97 // note: candidate template ignored: substitution failure 75 // note: candidate template ignored: substitution failure
98 // [with T = const remoting::StaticAttribute, N = 0]: 76 // [with T = const remoting::StaticAttribute, N = 0]:
99 // zero-length arrays are not permitted in C++. 77 // zero-length arrays are not permitted in C++.
100 // 78 //
101 // So we need IsDebug() function, and "Debug-Build" Attribute. 79 // So we need IsDebug() function, and "Debug-Build" Attribute.
102 80
103 static constexpr Attribute kAttributes[] = { 81 static constexpr Attribute kAttributes[] = {
104 { "Debug-Build", &IsDebug }, 82 { "Debug-Build", &IsDebug },
105 { "ChromeBrand", &IsChromeBranded }, 83 { "ChromeBrand", &IsChromeBranded },
106 { "ChromiumBrand", &IsChromiumBranded }, 84 { "ChromiumBrand", &IsChromiumBranded },
107 { "OfficialBuild", &IsOfficialBuild }, 85 { "OfficialBuild", &IsOfficialBuild },
108 { "NonOfficialBuild", &IsNonOfficialBuild }, 86 { "NonOfficialBuild", &IsNonOfficialBuild },
109 #if defined(OS_WIN)
110 { "DirectX-Capturer", &webrtc::ScreenCapturerWinDirectx::IsSupported },
111 { "MinD3DGT10", &MinD3DFeatureLevelGreatThan10 },
112 { "MinD3DGT11", &MinD3DFeatureLevelGreatThan11 },
113 { "MinD3DGT12", &MinD3DFeatureLevelGreatThan12 },
114 #endif
115 }; 87 };
116 88
117 } // namespace 89 } // namespace
118 90
119 static_assert(std::is_pod<Attribute>::value, "Attribute should be POD."); 91 static_assert(std::is_pod<Attribute>::value, "Attribute should be POD.");
120 92
121 std::string GetHostAttributes() { 93 std::string GetHostAttributes() {
122 std::string result; 94 std::vector<base::StringPiece> result;
123 // By using ranged for-loop, MSVC throws error C3316: 95 // By using ranged for-loop, MSVC throws error C3316:
124 // 'const remoting::StaticAttribute [0]': 96 // 'const remoting::StaticAttribute [0]':
125 // an array of unknown size cannot be used in a range-based for statement. 97 // an array of unknown size cannot be used in a range-based for statement.
126 for (size_t i = 0; i < arraysize(kAttributes); i++) { 98 for (size_t i = 0; i < arraysize(kAttributes); i++) {
127 const auto& attribute = kAttributes[i]; 99 const auto& attribute = kAttributes[i];
128 DCHECK_EQ(std::string(attribute.name).find(kSeparator), std::string::npos); 100 DCHECK_EQ(std::string(attribute.name).find(kSeparator), std::string::npos);
129 if (attribute.get_value_func()) { 101 if (attribute.get_value_func()) {
130 if (!result.empty()) { 102 result.push_back(attribute.name);
131 result.append(kSeparator);
132 }
133 result.append(attribute.name);
134 } 103 }
135 } 104 }
105 #if defined(OS_WIN)
106 {
107 webrtc::DxgiDuplicatorController::D3dInfo info;
108 webrtc::ScreenCapturerWinDirectx::RetrieveD3dInfo(&info);
109 if (info.min_feature_level >= D3D_FEATURE_LEVEL_10_0) {
110 result.push_back("MinD3DGT10");
111 }
112 if (info.min_feature_level >= D3D_FEATURE_LEVEL_11_0) {
113 result.push_back("MinD3DGT11");
114 }
115 if (info.min_feature_level >= D3D_FEATURE_LEVEL_12_0) {
116 result.push_back("MinD3DGT12");
117 }
136 118
137 return result; 119 auto version = base::win::GetVersion();
120 if (version >= base::win::VERSION_WIN8) {
121 result.push_back("Win8+");
122 }
123 if (version >= base::win::VERSION_WIN8_1) {
124 result.push_back("Win81+");
125 }
126 if (version >= base::win::VERSION_WIN10) {
127 result.push_back("Win10+");
128 }
129 }
130 #endif
131
132 return base::JoinString(result, kSeparator);
138 } 133 }
139 134
140 } // namespace remoting 135 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698