OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
15 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/sys_info.h" | |
18 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 19 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
19 #include "base/threading/platform_thread.h" | 20 #include "base/threading/platform_thread.h" |
20 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
21 #include "build/build_config.h" | 22 #include "build/build_config.h" |
22 #include "content/child/child_process.h" | 23 #include "content/child/child_process.h" |
23 #include "content/common/content_constants_internal.h" | 24 #include "content/common/content_constants_internal.h" |
24 #include "content/common/gpu_host_messages.h" | 25 #include "content/common/gpu_host_messages.h" |
25 #include "content/common/sandbox_linux/sandbox_linux.h" | 26 #include "content/common/sandbox_linux/sandbox_linux.h" |
26 #include "content/gpu/gpu_child_thread.h" | 27 #include "content/gpu/gpu_child_thread.h" |
27 #include "content/gpu/gpu_process.h" | 28 #include "content/gpu/gpu_process.h" |
28 #include "content/gpu/gpu_watchdog_thread.h" | 29 #include "content/gpu/gpu_watchdog_thread.h" |
29 #include "content/public/common/content_client.h" | 30 #include "content/public/common/content_client.h" |
30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
31 #include "content/public/common/main_function_params.h" | 32 #include "content/public/common/main_function_params.h" |
32 #include "gpu/command_buffer/service/gpu_switches.h" | 33 #include "gpu/command_buffer/service/gpu_switches.h" |
33 #include "gpu/config/gpu_info_collector.h" | 34 #include "gpu/config/gpu_info_collector.h" |
34 #include "gpu/config/gpu_switches.h" | 35 #include "gpu/config/gpu_switches.h" |
35 #include "gpu/config/gpu_util.h" | 36 #include "gpu/config/gpu_util.h" |
36 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 37 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
37 #include "gpu/ipc/service/gpu_config.h" | 38 #include "gpu/ipc/service/gpu_config.h" |
38 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 39 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
39 #include "ui/events/platform/platform_event_source.h" | 40 #include "ui/events/platform/platform_event_source.h" |
40 #include "ui/gl/gl_context.h" | 41 #include "ui/gl/gl_context.h" |
41 #include "ui/gl/gl_implementation.h" | 42 #include "ui/gl/gl_implementation.h" |
42 #include "ui/gl/gl_surface.h" | 43 #include "ui/gl/gl_surface.h" |
43 #include "ui/gl/gl_switches.h" | 44 #include "ui/gl/gl_switches.h" |
44 #include "ui/gl/gpu_switching_manager.h" | 45 #include "ui/gl/gpu_switching_manager.h" |
45 | 46 |
47 #if defined(OS_POSIX) | |
48 #include <dlfcn.h> | |
49 #endif | |
50 | |
46 #if defined(OS_WIN) | 51 #if defined(OS_WIN) |
47 #include <dwmapi.h> | 52 #include <dwmapi.h> |
48 #include <windows.h> | 53 #include <windows.h> |
49 #endif | 54 #endif |
50 | 55 |
51 #if defined(OS_ANDROID) | 56 #if defined(OS_ANDROID) |
52 #include "base/trace_event/memory_dump_manager.h" | 57 #include "base/trace_event/memory_dump_manager.h" |
53 #include "components/tracing/graphics_memory_dump_provider_android.h" | 58 #include "components/tracing/graphics_memory_dump_provider_android.h" |
54 #endif | 59 #endif |
55 | 60 |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 { | 479 { |
475 TRACE_EVENT0("gpu", "Warm up rand"); | 480 TRACE_EVENT0("gpu", "Warm up rand"); |
476 // Warm up the random subsystem, which needs to be done pre-sandbox on all | 481 // Warm up the random subsystem, which needs to be done pre-sandbox on all |
477 // platforms. | 482 // platforms. |
478 (void) base::RandUint64(); | 483 (void) base::RandUint64(); |
479 } | 484 } |
480 | 485 |
481 #if defined(OS_WIN) | 486 #if defined(OS_WIN) |
482 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | 487 media::DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
483 #endif | 488 #endif |
489 | |
490 #if defined(OS_LINUX) | |
491 if (command_line.HasSwitch(switches::kGpuSandboxStartEarly)) { | |
492 // XXX: move all above code to the new GpuProcessPolicyEarlySandbox. | |
493 | |
494 // uname is used from GpuControlList when calling | |
495 // gpu::ApplyGpuDriverBugWorkarounds. | |
496 base::SysInfo::OperatingSystemVersion(); | |
497 | |
498 // Cannot use base::LoadNativeLibrary because it uses RTLD_LAZY. | |
499 // We want to avoid the situation where a required symbol is loaded | |
500 // after the sandbox is ON. So load all symbols now. | |
501 // XXX: Instead of the library name above, uses: | |
502 // ui/gl/gl_implementation_x11.cc::kGLLibraryName, kGLESv2LibraryName, ... | |
503 dlopen("libglapi.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); | |
504 dlopen("libGL.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); | |
505 | |
506 // XXX: find a way to determine when we know we are going to use llvmpipe | |
507 // driver. | |
508 dlopen("dri/swrast_dri.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); | |
Ken Russell (switch to Gerrit)
2016/05/04 20:36:17
Yes, this is not acceptable to commit in its curre
| |
509 } | |
510 #endif | |
511 | |
484 return true; | 512 return true; |
485 } | 513 } |
486 | 514 |
487 #if !defined(OS_MACOSX) | 515 #if !defined(OS_MACOSX) |
488 bool CollectGraphicsInfo(gpu::GPUInfo& gpu_info) { | 516 bool CollectGraphicsInfo(gpu::GPUInfo& gpu_info) { |
489 TRACE_EVENT0("gpu,startup", "Collect Graphics Info"); | 517 TRACE_EVENT0("gpu,startup", "Collect Graphics Info"); |
490 | 518 |
491 bool res = true; | 519 bool res = true; |
492 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info); | 520 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info); |
493 switch (result) { | 521 switch (result) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 return true; | 638 return true; |
611 } | 639 } |
612 | 640 |
613 return false; | 641 return false; |
614 } | 642 } |
615 #endif // defined(OS_WIN) | 643 #endif // defined(OS_WIN) |
616 | 644 |
617 } // namespace. | 645 } // namespace. |
618 | 646 |
619 } // namespace content | 647 } // namespace content |
OLD | NEW |