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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 TRACE_EVENT0("gpu", "Initialize sandbox"); | 234 TRACE_EVENT0("gpu", "Initialize sandbox"); |
235 bool do_init_sandbox = true; | 235 bool do_init_sandbox = true; |
236 | 236 |
237 #if defined(OS_CHROMEOS) && defined(NDEBUG) | 237 #if defined(OS_CHROMEOS) && defined(NDEBUG) |
238 // On Chrome OS and when not on a debug build, initialize | 238 // On Chrome OS and when not on a debug build, initialize |
239 // the GPU process' sandbox only for Intel GPUs. | 239 // the GPU process' sandbox only for Intel GPUs. |
240 do_init_sandbox = gpu_info.gpu.vendor_id == 0x8086; // Intel GPU. | 240 do_init_sandbox = gpu_info.gpu.vendor_id == 0x8086; // Intel GPU. |
241 #endif | 241 #endif |
242 | 242 |
243 if (do_init_sandbox) { | 243 if (do_init_sandbox) { |
244 if (watchdog_thread.get()) | 244 if (watchdog_thread) |
245 watchdog_thread->Stop(); | 245 watchdog_thread->Stop(); |
246 gpu_info.sandboxed = LinuxSandbox::InitializeSandbox(); | 246 gpu_info.sandboxed = LinuxSandbox::InitializeSandbox(); |
247 if (watchdog_thread.get()) | 247 if (watchdog_thread) |
248 watchdog_thread->Start(); | 248 watchdog_thread->Start(); |
249 } | 249 } |
250 } | 250 } |
251 #endif | 251 #endif |
252 | 252 |
253 #if defined(OS_WIN) | 253 #if defined(OS_WIN) |
254 { | 254 { |
255 TRACE_EVENT0("gpu", "Lower token"); | 255 TRACE_EVENT0("gpu", "Lower token"); |
256 // For windows, if the target_services interface is not zero, the process | 256 // For windows, if the target_services interface is not zero, the process |
257 // is sandboxed and we must call LowerToken() before rendering untrusted | 257 // is sandboxed and we must call LowerToken() before rendering untrusted |
(...skipping 25 matching lines...) Expand all Loading... |
283 | 283 |
284 return 0; | 284 return 0; |
285 } | 285 } |
286 | 286 |
287 namespace { | 287 namespace { |
288 | 288 |
289 #if defined(OS_LINUX) | 289 #if defined(OS_LINUX) |
290 void CreateDummyGlContext() { | 290 void CreateDummyGlContext() { |
291 scoped_refptr<gfx::GLSurface> surface( | 291 scoped_refptr<gfx::GLSurface> surface( |
292 gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1))); | 292 gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1))); |
293 if (!surface.get()) { | 293 if (!surface) { |
294 VLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed"; | 294 VLOG(1) << "gfx::GLSurface::CreateOffscreenGLSurface failed"; |
295 return; | 295 return; |
296 } | 296 } |
297 | 297 |
298 // On Linux, this is needed to make sure /dev/nvidiactl has | 298 // On Linux, this is needed to make sure /dev/nvidiactl has |
299 // been opened and its descriptor cached. | 299 // been opened and its descriptor cached. |
300 scoped_refptr<gfx::GLContext> context( | 300 scoped_refptr<gfx::GLContext> context( |
301 gfx::GLContext::CreateGLContext(NULL, | 301 gfx::GLContext::CreateGLContext(NULL, |
302 surface, | 302 surface, |
303 gfx::PreferDiscreteGpu)); | 303 gfx::PreferDiscreteGpu)); |
304 if (!context.get()) { | 304 if (!context) { |
305 VLOG(1) << "gfx::GLContext::CreateGLContext failed"; | 305 VLOG(1) << "gfx::GLContext::CreateGLContext failed"; |
306 return; | 306 return; |
307 } | 307 } |
308 | 308 |
309 // Similarly, this is needed for /dev/nvidia0. | 309 // Similarly, this is needed for /dev/nvidia0. |
310 if (context->MakeCurrent(surface)) { | 310 if (context->MakeCurrent(surface)) { |
311 context->ReleaseCurrent(surface.get()); | 311 context->ReleaseCurrent(surface.get()); |
312 } else { | 312 } else { |
313 VLOG(1) << "gfx::GLContext::MakeCurrent failed"; | 313 VLOG(1) << "gfx::GLContext::MakeCurrent failed"; |
314 } | 314 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 TRACE_EVENT0("gpu", "Initialize DXVA"); | 364 TRACE_EVENT0("gpu", "Initialize DXVA"); |
365 // Initialize H/W video decoding stuff which fails in the sandbox. | 365 // Initialize H/W video decoding stuff which fails in the sandbox. |
366 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); | 366 DXVAVideoDecodeAccelerator::PreSandboxInitialization(); |
367 } | 367 } |
368 #endif | 368 #endif |
369 } | 369 } |
370 | 370 |
371 } // namespace. | 371 } // namespace. |
372 | 372 |
373 } // namespace content | 373 } // namespace content |
OLD | NEW |