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

Side by Side Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 1165823003: Re-land: content: Enable native GpuMemoryBuffers by default on MacOSX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make sure native buffers are disabled when using mesa Created 5 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 | content/child/child_thread_impl_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/gpu/browser_gpu_memory_buffer_manager.h" 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 #include "base/trace_event/process_memory_dump.h" 13 #include "base/trace_event/process_memory_dump.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "content/browser/gpu/gpu_process_host.h" 15 #include "content/browser/gpu/gpu_process_host.h"
16 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" 16 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
17 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" 17 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
18 #include "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h" 18 #include "content/common/gpu/gpu_memory_buffer_factory_shared_memory.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
21 #include "gpu/GLES2/gl2extchromium.h" 21 #include "gpu/GLES2/gl2extchromium.h"
22 #include "ui/gl/gl_switches.h"
22 23
23 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
24 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h" 25 #include "content/common/gpu/gpu_memory_buffer_factory_io_surface.h"
25 #endif 26 #endif
26 27
27 #if defined(OS_ANDROID) 28 #if defined(OS_ANDROID)
28 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h" 29 #include "content/common/gpu/gpu_memory_buffer_factory_surface_texture.h"
29 #endif 30 #endif
30 31
31 #if defined(USE_OZONE) 32 #if defined(USE_OZONE)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); 81 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types);
81 DCHECK(!supported_types.empty()); 82 DCHECK(!supported_types.empty());
82 83
83 // The GPU service will always use the preferred type. 84 // The GPU service will always use the preferred type.
84 return supported_types[0]; 85 return supported_types[0];
85 } 86 }
86 87
87 std::vector<GpuMemoryBufferFactory::Configuration> 88 std::vector<GpuMemoryBufferFactory::Configuration>
88 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) { 89 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) {
89 std::vector<GpuMemoryBufferFactory::Configuration> configurations; 90 std::vector<GpuMemoryBufferFactory::Configuration> configurations;
90 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 91 #if defined(OS_MACOSX)
91 switches::kEnableNativeGpuMemoryBuffers)) { 92 bool enable_native_gpu_memory_buffers =
93 !base::CommandLine::ForCurrentProcess()->HasSwitch(
94 switches::kDisableNativeGpuMemoryBuffers);
95 #else
96 bool enable_native_gpu_memory_buffers =
97 base::CommandLine::ForCurrentProcess()->HasSwitch(
98 switches::kEnableNativeGpuMemoryBuffers);
99 #endif
100
101 // Disable native buffers when using Mesa.
102 if (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
103 switches::kUseGL) == gfx::kGLImplementationOSMesaName) {
104 enable_native_gpu_memory_buffers = false;
105 }
106
107 if (enable_native_gpu_memory_buffers) {
92 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = { 108 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = {
93 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP}, 109 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP},
94 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, 110 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP},
95 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::MAP}, 111 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::MAP},
96 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, 112 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::PERSISTENT_MAP},
97 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP}, 113 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP},
98 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, 114 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP},
99 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP}, 115 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP},
100 {gfx::GpuMemoryBuffer::BGRA_8888, 116 {gfx::GpuMemoryBuffer::BGRA_8888,
101 gfx::GpuMemoryBuffer::PERSISTENT_MAP}}; 117 gfx::GpuMemoryBuffer::PERSISTENT_MAP}};
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 576 }
561 577
562 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); 578 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id);
563 if (host) 579 if (host)
564 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); 580 host->DestroyGpuMemoryBuffer(id, client_id, sync_point);
565 581
566 buffers.erase(buffer_it); 582 buffers.erase(buffer_it);
567 } 583 }
568 584
569 } // namespace content 585 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/child_thread_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698