| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 EXPECT_TRUE(reason.empty()); | 151 EXPECT_TRUE(reason.empty()); |
| 152 | 152 |
| 153 const std::string blacklist_json = LONG_STRING_CONST( | 153 const std::string blacklist_json = LONG_STRING_CONST( |
| 154 { | 154 { |
| 155 "name": "gpu blacklist", | 155 "name": "gpu blacklist", |
| 156 "version": "0.1", | 156 "version": "0.1", |
| 157 "entries": [ | 157 "entries": [ |
| 158 { | 158 { |
| 159 "id": 1, | 159 "id": 1, |
| 160 "features": [ | 160 "features": [ |
| 161 "webgl" | 161 "accelerated_webgl" |
| 162 ] | 162 ] |
| 163 }, | 163 }, |
| 164 { | 164 { |
| 165 "id": 2, | 165 "id": 2, |
| 166 "gl_renderer": ".*GeForce.*", | 166 "gl_renderer": ".*GeForce.*", |
| 167 "features": [ | 167 "features": [ |
| 168 "accelerated_2d_canvas" | 168 "accelerated_2d_canvas" |
| 169 ] | 169 ] |
| 170 } | 170 } |
| 171 ] | 171 ] |
| 172 } | 172 } |
| 173 ); | 173 ); |
| 174 | 174 |
| 175 gpu::GPUInfo gpu_info; | 175 gpu::GPUInfo gpu_info; |
| 176 gpu_info.gpu.vendor_id = 0x10de; | 176 gpu_info.gpu.vendor_id = 0x10de; |
| 177 gpu_info.gpu.device_id = 0x0640; | 177 gpu_info.gpu.device_id = 0x0640; |
| 178 manager->InitializeForTesting(blacklist_json, gpu_info); | 178 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 179 | 179 |
| 180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 180 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 181 EXPECT_TRUE(reason.empty()); | 181 EXPECT_TRUE(reason.empty()); |
| 182 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 182 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 183 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 183 EXPECT_TRUE( |
| 184 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 184 | 185 |
| 185 gpu_info.gl_vendor = "NVIDIA"; | 186 gpu_info.gl_vendor = "NVIDIA"; |
| 186 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 187 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
| 187 manager->UpdateGpuInfo(gpu_info); | 188 manager->UpdateGpuInfo(gpu_info); |
| 188 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); | 189 EXPECT_FALSE(manager->GpuAccessAllowed(&reason)); |
| 189 EXPECT_FALSE(reason.empty()); | 190 EXPECT_FALSE(reason.empty()); |
| 190 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); | 191 EXPECT_EQ(2u, manager->GetBlacklistedFeatureCount()); |
| 191 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 192 EXPECT_TRUE( |
| 193 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 192 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 194 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 193 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 195 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 194 } | 196 } |
| 195 | 197 |
| 196 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { | 198 TEST_F(GpuDataManagerImplPrivateTest, GpuSideBlacklistingWebGL) { |
| 197 // If a feature is allowed in preliminary step (browser side), but | 199 // If a feature is allowed in preliminary step (browser side), but |
| 198 // disabled when GPU process launches and collects full GPU info, | 200 // disabled when GPU process launches and collects full GPU info, |
| 199 // it's too late to let renderer know, so we basically block all GPU | 201 // it's too late to let renderer know, so we basically block all GPU |
| 200 // access, to be on the safe side. | 202 // access, to be on the safe side. |
| 201 ScopedGpuDataManagerImplPrivate manager; | 203 ScopedGpuDataManagerImplPrivate manager; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 212 { | 214 { |
| 213 "id": 1, | 215 "id": 1, |
| 214 "features": [ | 216 "features": [ |
| 215 "accelerated_2d_canvas" | 217 "accelerated_2d_canvas" |
| 216 ] | 218 ] |
| 217 }, | 219 }, |
| 218 { | 220 { |
| 219 "id": 2, | 221 "id": 2, |
| 220 "gl_renderer": ".*GeForce.*", | 222 "gl_renderer": ".*GeForce.*", |
| 221 "features": [ | 223 "features": [ |
| 222 "webgl", | 224 "accelerated_webgl", |
| 223 "webgl2" | 225 "webgl2" |
| 224 ] | 226 ] |
| 225 } | 227 } |
| 226 ] | 228 ] |
| 227 } | 229 } |
| 228 ); | 230 ); |
| 229 | 231 |
| 230 gpu::GPUInfo gpu_info; | 232 gpu::GPUInfo gpu_info; |
| 231 gpu_info.gpu.vendor_id = 0x10de; | 233 gpu_info.gpu.vendor_id = 0x10de; |
| 232 gpu_info.gpu.device_id = 0x0640; | 234 gpu_info.gpu.device_id = 0x0640; |
| 233 manager->InitializeForTesting(blacklist_json, gpu_info); | 235 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 234 | 236 |
| 235 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 237 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 236 EXPECT_TRUE(reason.empty()); | 238 EXPECT_TRUE(reason.empty()); |
| 237 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 239 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 238 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 240 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 239 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 241 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 240 | 242 |
| 241 gpu_info.gl_vendor = "NVIDIA"; | 243 gpu_info.gl_vendor = "NVIDIA"; |
| 242 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; | 244 gpu_info.gl_renderer = "NVIDIA GeForce GT 120"; |
| 243 manager->UpdateGpuInfo(gpu_info); | 245 manager->UpdateGpuInfo(gpu_info); |
| 244 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); | 246 EXPECT_TRUE(manager->GpuAccessAllowed(&reason)); |
| 245 EXPECT_TRUE(reason.empty()); | 247 EXPECT_TRUE(reason.empty()); |
| 246 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); | 248 EXPECT_EQ(3u, manager->GetBlacklistedFeatureCount()); |
| 247 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 249 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 248 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 250 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 249 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 251 EXPECT_TRUE( |
| 252 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 250 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); | 253 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL2)); |
| 251 } | 254 } |
| 252 | 255 |
| 253 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { | 256 TEST_F(GpuDataManagerImplPrivateTest, GpuSideExceptions) { |
| 254 ScopedGpuDataManagerImplPrivate manager; | 257 ScopedGpuDataManagerImplPrivate manager; |
| 255 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 258 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 256 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 259 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 257 | 260 |
| 258 const std::string blacklist_json = LONG_STRING_CONST( | 261 const std::string blacklist_json = LONG_STRING_CONST( |
| 259 { | 262 { |
| 260 "name": "gpu blacklist", | 263 "name": "gpu blacklist", |
| 261 "version": "0.1", | 264 "version": "0.1", |
| 262 "entries": [ | 265 "entries": [ |
| 263 { | 266 { |
| 264 "id": 1, | 267 "id": 1, |
| 265 "exceptions": [ | 268 "exceptions": [ |
| 266 { | 269 { |
| 267 "gl_renderer": ".*GeForce.*" | 270 "gl_renderer": ".*GeForce.*" |
| 268 } | 271 } |
| 269 ], | 272 ], |
| 270 "features": [ | 273 "features": [ |
| 271 "webgl" | 274 "accelerated_webgl" |
| 272 ] | 275 ] |
| 273 } | 276 } |
| 274 ] | 277 ] |
| 275 } | 278 } |
| 276 ); | 279 ); |
| 277 gpu::GPUInfo gpu_info; | 280 gpu::GPUInfo gpu_info; |
| 278 gpu_info.gpu.vendor_id = 0x10de; | 281 gpu_info.gpu.vendor_id = 0x10de; |
| 279 gpu_info.gpu.device_id = 0x0640; | 282 gpu_info.gpu.device_id = 0x0640; |
| 280 manager->InitializeForTesting(blacklist_json, gpu_info); | 283 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 281 | 284 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 manager->DisableHardwareAcceleration(); | 318 manager->DisableHardwareAcceleration(); |
| 316 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); | 319 EXPECT_FALSE(manager->GpuAccessAllowed(NULL)); |
| 317 EXPECT_FALSE(manager->ShouldUseSwiftShader()); | 320 EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
| 318 | 321 |
| 319 // If SwiftShader is enabled, even if we blacklist GPU, | 322 // If SwiftShader is enabled, even if we blacklist GPU, |
| 320 // GPU process is still allowed. | 323 // GPU process is still allowed. |
| 321 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); | 324 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
| 322 manager->RegisterSwiftShaderPath(test_path); | 325 manager->RegisterSwiftShaderPath(test_path); |
| 323 EXPECT_TRUE(manager->ShouldUseSwiftShader()); | 326 EXPECT_TRUE(manager->ShouldUseSwiftShader()); |
| 324 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 327 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 325 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 328 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 329 manager->GetBlacklistedFeatureCount()); |
| 326 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 330 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 327 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 331 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 328 } | 332 } |
| 329 | 333 |
| 330 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { | 334 TEST_F(GpuDataManagerImplPrivateTest, SwiftShaderRendering2) { |
| 331 // Register SwiftShader, then blacklist. | 335 // Register SwiftShader, then blacklist. |
| 332 ScopedGpuDataManagerImplPrivate manager; | 336 ScopedGpuDataManagerImplPrivate manager; |
| 333 manager->InitializeForTesting("", gpu::GPUInfo()); | 337 manager->InitializeForTesting("", gpu::GPUInfo()); |
| 334 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 338 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 335 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 339 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 336 EXPECT_FALSE(manager->ShouldUseSwiftShader()); | 340 EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
| 337 | 341 |
| 338 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); | 342 const base::FilePath test_path(FILE_PATH_LITERAL("AnyPath")); |
| 339 manager->RegisterSwiftShaderPath(test_path); | 343 manager->RegisterSwiftShaderPath(test_path); |
| 340 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 344 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 341 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 345 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 342 EXPECT_FALSE(manager->ShouldUseSwiftShader()); | 346 EXPECT_FALSE(manager->ShouldUseSwiftShader()); |
| 343 | 347 |
| 344 manager->DisableHardwareAcceleration(); | 348 manager->DisableHardwareAcceleration(); |
| 345 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 349 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 346 EXPECT_TRUE(manager->ShouldUseSwiftShader()); | 350 EXPECT_TRUE(manager->ShouldUseSwiftShader()); |
| 347 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 351 EXPECT_EQ(static_cast<size_t>(gpu::NUMBER_OF_GPU_FEATURE_TYPES), |
| 352 manager->GetBlacklistedFeatureCount()); |
| 348 EXPECT_TRUE(manager->IsFeatureBlacklisted( | 353 EXPECT_TRUE(manager->IsFeatureBlacklisted( |
| 349 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); | 354 gpu::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS)); |
| 350 } | 355 } |
| 351 | 356 |
| 352 TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) { | 357 TEST_F(GpuDataManagerImplPrivateTest, GpuInfoUpdate) { |
| 353 ScopedGpuDataManagerImpl manager; | 358 ScopedGpuDataManagerImpl manager; |
| 354 | 359 |
| 355 TestObserver observer; | 360 TestObserver observer; |
| 356 manager->AddObserver(&observer); | 361 manager->AddObserver(&observer); |
| 357 | 362 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 "exceptions": [ | 571 "exceptions": [ |
| 567 { | 572 { |
| 568 "device_id": ["0x0042"], | 573 "device_id": ["0x0042"], |
| 569 "driver_version": { | 574 "driver_version": { |
| 570 "op": ">=", | 575 "op": ">=", |
| 571 "value": "8.0.2" | 576 "value": "8.0.2" |
| 572 } | 577 } |
| 573 } | 578 } |
| 574 ], | 579 ], |
| 575 "features": [ | 580 "features": [ |
| 576 "webgl" | 581 "accelerated_webgl" |
| 577 ] | 582 ] |
| 578 } | 583 } |
| 579 ] | 584 ] |
| 580 } | 585 } |
| 581 ); | 586 ); |
| 582 gpu::GPUInfo gpu_info; | 587 gpu::GPUInfo gpu_info; |
| 583 gpu_info.gpu.vendor_id = 0x8086; | 588 gpu_info.gpu.vendor_id = 0x8086; |
| 584 gpu_info.gpu.device_id = 0x0042; | 589 gpu_info.gpu.device_id = 0x0042; |
| 585 manager->InitializeForTesting(blacklist_json, gpu_info); | 590 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 586 | 591 |
| 587 // Not enough GPUInfo. | 592 // Not enough GPUInfo. |
| 588 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 593 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 589 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 594 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 590 | 595 |
| 591 // Now assume browser gets GL strings from local state. | 596 // Now assume browser gets GL strings from local state. |
| 592 // The entry applies, blacklist more features than from the preliminary step. | 597 // The entry applies, blacklist more features than from the preliminary step. |
| 593 // However, GPU process is not blocked because this is all browser side and | 598 // However, GPU process is not blocked because this is all browser side and |
| 594 // happens before renderer launching. | 599 // happens before renderer launching. |
| 595 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 600 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
| 596 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 601 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 597 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 602 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 598 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 603 EXPECT_TRUE( |
| 604 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 599 } | 605 } |
| 600 | 606 |
| 601 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { | 607 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsNoEffects) { |
| 602 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 608 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
| 603 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 609 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
| 604 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 610 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
| 605 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; | 611 const char* kGLVersionMesa802 = "2.1 Mesa 8.0.2-DEVEL"; |
| 606 | 612 |
| 607 ScopedGpuDataManagerImplPrivate manager; | 613 ScopedGpuDataManagerImplPrivate manager; |
| 608 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 614 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 619 "exceptions": [ | 625 "exceptions": [ |
| 620 { | 626 { |
| 621 "device_id": ["0x0042"], | 627 "device_id": ["0x0042"], |
| 622 "driver_version": { | 628 "driver_version": { |
| 623 "op": ">=", | 629 "op": ">=", |
| 624 "value": "8.0.2" | 630 "value": "8.0.2" |
| 625 } | 631 } |
| 626 } | 632 } |
| 627 ], | 633 ], |
| 628 "features": [ | 634 "features": [ |
| 629 "webgl" | 635 "accelerated_webgl" |
| 630 ] | 636 ] |
| 631 } | 637 } |
| 632 ] | 638 ] |
| 633 } | 639 } |
| 634 ); | 640 ); |
| 635 gpu::GPUInfo gpu_info; | 641 gpu::GPUInfo gpu_info; |
| 636 gpu_info.gpu.vendor_id = 0x8086; | 642 gpu_info.gpu.vendor_id = 0x8086; |
| 637 gpu_info.gpu.device_id = 0x0042; | 643 gpu_info.gpu.device_id = 0x0042; |
| 638 gpu_info.gl_vendor = kGLVendorMesa; | 644 gpu_info.gl_vendor = kGLVendorMesa; |
| 639 gpu_info.gl_renderer = kGLRendererMesa; | 645 gpu_info.gl_renderer = kGLRendererMesa; |
| 640 gpu_info.gl_version = kGLVersionMesa801; | 646 gpu_info.gl_version = kGLVersionMesa801; |
| 641 gpu_info.driver_vendor = "Mesa"; | 647 gpu_info.driver_vendor = "Mesa"; |
| 642 gpu_info.driver_version = "8.0.1"; | 648 gpu_info.driver_version = "8.0.1"; |
| 643 manager->InitializeForTesting(blacklist_json, gpu_info); | 649 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 644 | 650 |
| 645 // Full GPUInfo, the entry applies. | 651 // Full GPUInfo, the entry applies. |
| 646 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 652 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 647 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 653 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 648 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 654 EXPECT_TRUE( |
| 655 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 649 | 656 |
| 650 // Now assume browser gets GL strings from local state. | 657 // Now assume browser gets GL strings from local state. |
| 651 // SetGLStrings() has no effects because GPUInfo already got these strings. | 658 // SetGLStrings() has no effects because GPUInfo already got these strings. |
| 652 // (Otherwise the entry should not apply.) | 659 // (Otherwise the entry should not apply.) |
| 653 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); | 660 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa802); |
| 654 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 661 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 655 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 662 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 656 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 663 EXPECT_TRUE( |
| 664 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 657 } | 665 } |
| 658 | 666 |
| 659 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { | 667 TEST_F(GpuDataManagerImplPrivateTest, SetGLStringsDefered) { |
| 660 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; | 668 const char* kGLVendorMesa = "Tungsten Graphics, Inc"; |
| 661 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; | 669 const char* kGLRendererMesa = "Mesa DRI Intel(R) G41"; |
| 662 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; | 670 const char* kGLVersionMesa801 = "2.1 Mesa 8.0.1-DEVEL"; |
| 663 | 671 |
| 664 ScopedGpuDataManagerImplPrivate manager; | 672 ScopedGpuDataManagerImplPrivate manager; |
| 665 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); | 673 EXPECT_EQ(0u, manager->GetBlacklistedFeatureCount()); |
| 666 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 674 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 667 | 675 |
| 668 const std::string blacklist_json = LONG_STRING_CONST({ | 676 const std::string blacklist_json = LONG_STRING_CONST({ |
| 669 "name" : "gpu blacklist", | 677 "name" : "gpu blacklist", |
| 670 "version" : "0.1", | 678 "version" : "0.1", |
| 671 "entries" : [ { | 679 "entries" : [ { |
| 672 "id" : 1, | 680 "id" : 1, |
| 673 "vendor_id" : "0x8086", | 681 "vendor_id" : "0x8086", |
| 674 "device_id" : ["0x0042"], | 682 "device_id" : ["0x0042"], |
| 675 "driver_vendor" : "Mesa", | 683 "driver_vendor" : "Mesa", |
| 676 "driver_version" : {"op" : ">=", "value" : "8.0.0"}, | 684 "driver_version" : {"op" : ">=", "value" : "8.0.0"}, |
| 677 "features" : ["webgl"] | 685 "features" : ["accelerated_webgl"] |
| 678 } ] | 686 } ] |
| 679 }); | 687 }); |
| 680 | 688 |
| 681 // Check that it is allowed to call SetGLStrings before Initialize. | 689 // Check that it is allowed to call SetGLStrings before Initialize. |
| 682 | 690 |
| 683 // Assume browser gets GL strings from local state. | 691 // Assume browser gets GL strings from local state. |
| 684 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); | 692 manager->SetGLStrings(kGLVendorMesa, kGLRendererMesa, kGLVersionMesa801); |
| 685 | 693 |
| 686 gpu::GPUInfo gpu_info; | 694 gpu::GPUInfo gpu_info; |
| 687 gpu_info.gpu.vendor_id = 0x8086; | 695 gpu_info.gpu.vendor_id = 0x8086; |
| 688 gpu_info.gpu.device_id = 0x0042; | 696 gpu_info.gpu.device_id = 0x0042; |
| 689 manager->InitializeForTesting(blacklist_json, gpu_info); | 697 manager->InitializeForTesting(blacklist_json, gpu_info); |
| 690 | 698 |
| 691 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); | 699 EXPECT_TRUE(manager->GpuAccessAllowed(NULL)); |
| 692 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 700 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 693 EXPECT_TRUE(manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_WEBGL)); | 701 EXPECT_TRUE( |
| 702 manager->IsFeatureBlacklisted(gpu::GPU_FEATURE_TYPE_ACCELERATED_WEBGL)); |
| 694 } | 703 } |
| 695 #endif // OS_LINUX | 704 #endif // OS_LINUX |
| 696 | 705 |
| 697 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { | 706 TEST_F(GpuDataManagerImplPrivateTest, GpuDriverBugListSingle) { |
| 698 ScopedGpuDataManagerImplPrivate manager; | 707 ScopedGpuDataManagerImplPrivate manager; |
| 699 manager->gpu_driver_bugs_.insert(5); | 708 manager->gpu_driver_bugs_.insert(5); |
| 700 | 709 |
| 701 base::CommandLine command_line(0, NULL); | 710 base::CommandLine command_line(0, NULL); |
| 702 manager->AppendGpuCommandLine(&command_line, nullptr); | 711 manager->AppendGpuCommandLine(&command_line, nullptr); |
| 703 | 712 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 const std::string blacklist_json = LONG_STRING_CONST( | 776 const std::string blacklist_json = LONG_STRING_CONST( |
| 768 { | 777 { |
| 769 "name": "gpu blacklist", | 778 "name": "gpu blacklist", |
| 770 "version": "0.1", | 779 "version": "0.1", |
| 771 "entries": [ | 780 "entries": [ |
| 772 { | 781 { |
| 773 "id": 1, | 782 "id": 1, |
| 774 "vendor_id": "0x8086", | 783 "vendor_id": "0x8086", |
| 775 "multi_gpu_category": "active", | 784 "multi_gpu_category": "active", |
| 776 "features": [ | 785 "features": [ |
| 777 "webgl" | 786 "accelerated_webgl" |
| 778 ] | 787 ] |
| 779 } | 788 } |
| 780 ] | 789 ] |
| 781 } | 790 } |
| 782 ); | 791 ); |
| 783 | 792 |
| 784 // Two GPUs, the secondary Intel GPU is active. | 793 // Two GPUs, the secondary Intel GPU is active. |
| 785 gpu::GPUInfo gpu_info; | 794 gpu::GPUInfo gpu_info; |
| 786 gpu_info.gpu.vendor_id = 0x10de; | 795 gpu_info.gpu.vendor_id = 0x10de; |
| 787 gpu_info.gpu.device_id = 0x0640; | 796 gpu_info.gpu.device_id = 0x0640; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 832 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); | 841 EXPECT_TRUE(manager->UpdateActiveGpu(0x8086, 0x04a1)); |
| 833 { | 842 { |
| 834 base::RunLoop run_loop; | 843 base::RunLoop run_loop; |
| 835 run_loop.RunUntilIdle(); | 844 run_loop.RunUntilIdle(); |
| 836 } | 845 } |
| 837 EXPECT_TRUE(observer.gpu_info_updated()); | 846 EXPECT_TRUE(observer.gpu_info_updated()); |
| 838 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); | 847 EXPECT_EQ(1u, manager->GetBlacklistedFeatureCount()); |
| 839 } | 848 } |
| 840 | 849 |
| 841 } // namespace content | 850 } // namespace content |
| OLD | NEW |