OLD | NEW |
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" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // The GPU service will always use the preferred type. | 84 // The GPU service will always use the preferred type. |
85 return supported_types[0]; | 85 return supported_types[0]; |
86 } | 86 } |
87 | 87 |
88 std::vector<GpuMemoryBufferFactory::Configuration> | 88 std::vector<GpuMemoryBufferFactory::Configuration> |
89 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) { | 89 GetSupportedGpuMemoryBufferConfigurations(gfx::GpuMemoryBufferType type) { |
90 std::vector<GpuMemoryBufferFactory::Configuration> configurations; | 90 std::vector<GpuMemoryBufferFactory::Configuration> configurations; |
91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 91 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
92 switches::kEnableNativeGpuMemoryBuffers)) { | 92 switches::kEnableNativeGpuMemoryBuffers)) { |
93 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = { | 93 const GpuMemoryBufferFactory::Configuration kNativeConfigurations[] = { |
94 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::MAP}, | 94 {gfx::BufferFormat::R_8, gfx::BufferUsage::MAP}, |
95 {gfx::GpuMemoryBuffer::R_8, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 95 {gfx::BufferFormat::R_8, gfx::BufferUsage::PERSISTENT_MAP}, |
96 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::MAP}, | 96 {gfx::BufferFormat::RGBA_4444, gfx::BufferUsage::MAP}, |
97 {gfx::GpuMemoryBuffer::RGBA_4444, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 97 {gfx::BufferFormat::RGBA_4444, gfx::BufferUsage::PERSISTENT_MAP}, |
98 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::MAP}, | 98 {gfx::BufferFormat::RGBA_8888, gfx::BufferUsage::MAP}, |
99 {gfx::GpuMemoryBuffer::RGBA_8888, gfx::GpuMemoryBuffer::PERSISTENT_MAP}, | 99 {gfx::BufferFormat::RGBA_8888, gfx::BufferUsage::PERSISTENT_MAP}, |
100 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::MAP}, | 100 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::MAP}, |
101 {gfx::GpuMemoryBuffer::BGRA_8888, | 101 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::PERSISTENT_MAP}}; |
102 gfx::GpuMemoryBuffer::PERSISTENT_MAP}}; | |
103 for (auto& configuration : kNativeConfigurations) { | 102 for (auto& configuration : kNativeConfigurations) { |
104 if (IsGpuMemoryBufferFactoryConfigurationSupported(type, configuration)) | 103 if (IsGpuMemoryBufferFactoryConfigurationSupported(type, configuration)) |
105 configurations.push_back(configuration); | 104 configurations.push_back(configuration); |
106 } | 105 } |
107 } | 106 } |
108 | 107 |
109 #if defined(USE_OZONE) || defined(OS_MACOSX) | 108 #if defined(USE_OZONE) || defined(OS_MACOSX) |
110 const GpuMemoryBufferFactory::Configuration kScanoutConfigurations[] = { | 109 const GpuMemoryBufferFactory::Configuration kScanoutConfigurations[] = { |
111 {gfx::GpuMemoryBuffer::BGRA_8888, gfx::GpuMemoryBuffer::SCANOUT}, | 110 {gfx::BufferFormat::BGRA_8888, gfx::BufferUsage::SCANOUT}, |
112 {gfx::GpuMemoryBuffer::RGBX_8888, gfx::GpuMemoryBuffer::SCANOUT}}; | 111 {gfx::BufferFormat::RGBX_8888, gfx::BufferUsage::SCANOUT}}; |
113 for (auto& configuration : kScanoutConfigurations) { | 112 for (auto& configuration : kScanoutConfigurations) { |
114 if (IsGpuMemoryBufferFactoryConfigurationSupported(type, configuration)) | 113 if (IsGpuMemoryBufferFactoryConfigurationSupported(type, configuration)) |
115 configurations.push_back(configuration); | 114 configurations.push_back(configuration); |
116 } | 115 } |
117 #endif | 116 #endif |
118 | 117 |
119 return configurations; | 118 return configurations; |
120 } | 119 } |
121 | 120 |
122 BrowserGpuMemoryBufferManager* g_gpu_memory_buffer_manager = nullptr; | 121 BrowserGpuMemoryBufferManager* g_gpu_memory_buffer_manager = nullptr; |
123 | 122 |
124 // Global atomic to generate gpu memory buffer unique IDs. | 123 // Global atomic to generate gpu memory buffer unique IDs. |
125 base::StaticAtomicSequenceNumber g_next_gpu_memory_buffer_id; | 124 base::StaticAtomicSequenceNumber g_next_gpu_memory_buffer_id; |
126 | 125 |
127 } // namespace | 126 } // namespace |
128 | 127 |
129 struct BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferRequest { | 128 struct BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferRequest { |
130 AllocateGpuMemoryBufferRequest(const gfx::Size& size, | 129 AllocateGpuMemoryBufferRequest(const gfx::Size& size, |
131 gfx::GpuMemoryBuffer::Format format, | 130 gfx::BufferFormat format, |
132 gfx::GpuMemoryBuffer::Usage usage, | 131 gfx::BufferUsage usage, |
133 int client_id, | 132 int client_id, |
134 int surface_id) | 133 int surface_id) |
135 : event(true, false), | 134 : event(true, false), |
136 size(size), | 135 size(size), |
137 format(format), | 136 format(format), |
138 usage(usage), | 137 usage(usage), |
139 client_id(client_id), | 138 client_id(client_id), |
140 surface_id(surface_id) {} | 139 surface_id(surface_id) {} |
141 ~AllocateGpuMemoryBufferRequest() {} | 140 ~AllocateGpuMemoryBufferRequest() {} |
142 base::WaitableEvent event; | 141 base::WaitableEvent event; |
143 gfx::Size size; | 142 gfx::Size size; |
144 gfx::GpuMemoryBuffer::Format format; | 143 gfx::BufferFormat format; |
145 gfx::GpuMemoryBuffer::Usage usage; | 144 gfx::BufferUsage usage; |
146 int client_id; | 145 int client_id; |
147 int surface_id; | 146 int surface_id; |
148 scoped_ptr<gfx::GpuMemoryBuffer> result; | 147 scoped_ptr<gfx::GpuMemoryBuffer> result; |
149 }; | 148 }; |
150 | 149 |
151 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager(int gpu_client_id) | 150 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager(int gpu_client_id) |
152 : factory_type_(GetGpuMemoryBufferFactoryType()), | 151 : factory_type_(GetGpuMemoryBufferFactoryType()), |
153 supported_configurations_( | 152 supported_configurations_( |
154 GetSupportedGpuMemoryBufferConfigurations(factory_type_)), | 153 GetSupportedGpuMemoryBufferConfigurations(factory_type_)), |
155 gpu_client_id_(gpu_client_id), | 154 gpu_client_id_(gpu_client_id), |
156 gpu_host_id_(0) { | 155 gpu_host_id_(0) { |
157 DCHECK(!g_gpu_memory_buffer_manager); | 156 DCHECK(!g_gpu_memory_buffer_manager); |
158 g_gpu_memory_buffer_manager = this; | 157 g_gpu_memory_buffer_manager = this; |
159 } | 158 } |
160 | 159 |
161 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() { | 160 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() { |
162 g_gpu_memory_buffer_manager = nullptr; | 161 g_gpu_memory_buffer_manager = nullptr; |
163 } | 162 } |
164 | 163 |
165 // static | 164 // static |
166 BrowserGpuMemoryBufferManager* BrowserGpuMemoryBufferManager::current() { | 165 BrowserGpuMemoryBufferManager* BrowserGpuMemoryBufferManager::current() { |
167 return g_gpu_memory_buffer_manager; | 166 return g_gpu_memory_buffer_manager; |
168 } | 167 } |
169 | 168 |
170 // static | 169 // static |
171 uint32 BrowserGpuMemoryBufferManager::GetImageTextureTarget( | 170 uint32 BrowserGpuMemoryBufferManager::GetImageTextureTarget( |
172 gfx::GpuMemoryBuffer::Format format, | 171 gfx::BufferFormat format, |
173 gfx::GpuMemoryBuffer::Usage usage) { | 172 gfx::BufferUsage usage) { |
174 gfx::GpuMemoryBufferType type = GetGpuMemoryBufferFactoryType(); | 173 gfx::GpuMemoryBufferType type = GetGpuMemoryBufferFactoryType(); |
175 for (auto& configuration : GetSupportedGpuMemoryBufferConfigurations(type)) { | 174 for (auto& configuration : GetSupportedGpuMemoryBufferConfigurations(type)) { |
176 if (configuration.format != format || configuration.usage != usage) | 175 if (configuration.format != format || configuration.usage != usage) |
177 continue; | 176 continue; |
178 | 177 |
179 switch (type) { | 178 switch (type) { |
180 case gfx::SURFACE_TEXTURE_BUFFER: | 179 case gfx::SURFACE_TEXTURE_BUFFER: |
181 case gfx::OZONE_NATIVE_PIXMAP: | 180 case gfx::OZONE_NATIVE_PIXMAP: |
182 // GPU memory buffers that are shared with the GL using EGLImages | 181 // GPU memory buffers that are shared with the GL using EGLImages |
183 // require TEXTURE_EXTERNAL_OES. | 182 // require TEXTURE_EXTERNAL_OES. |
184 return GL_TEXTURE_EXTERNAL_OES; | 183 return GL_TEXTURE_EXTERNAL_OES; |
185 case gfx::IO_SURFACE_BUFFER: | 184 case gfx::IO_SURFACE_BUFFER: |
186 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. | 185 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. |
187 return GL_TEXTURE_RECTANGLE_ARB; | 186 return GL_TEXTURE_RECTANGLE_ARB; |
188 default: | 187 default: |
189 return GL_TEXTURE_2D; | 188 return GL_TEXTURE_2D; |
190 } | 189 } |
191 } | 190 } |
192 | 191 |
193 return GL_TEXTURE_2D; | 192 return GL_TEXTURE_2D; |
194 } | 193 } |
195 | 194 |
196 scoped_ptr<gfx::GpuMemoryBuffer> | 195 scoped_ptr<gfx::GpuMemoryBuffer> |
197 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBuffer( | 196 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBuffer(const gfx::Size& size, |
198 const gfx::Size& size, | 197 gfx::BufferFormat format, |
199 gfx::GpuMemoryBuffer::Format format, | 198 gfx::BufferUsage usage) { |
200 gfx::GpuMemoryBuffer::Usage usage) { | |
201 return AllocateGpuMemoryBufferForSurface(size, format, usage, 0); | 199 return AllocateGpuMemoryBufferForSurface(size, format, usage, 0); |
202 } | 200 } |
203 | 201 |
204 scoped_ptr<gfx::GpuMemoryBuffer> | 202 scoped_ptr<gfx::GpuMemoryBuffer> |
205 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForScanout( | 203 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForScanout( |
206 const gfx::Size& size, | 204 const gfx::Size& size, |
207 gfx::GpuMemoryBuffer::Format format, | 205 gfx::BufferFormat format, |
208 int32 surface_id) { | 206 int32 surface_id) { |
209 DCHECK_GT(surface_id, 0); | 207 DCHECK_GT(surface_id, 0); |
210 return AllocateGpuMemoryBufferForSurface( | 208 return AllocateGpuMemoryBufferForSurface( |
211 size, format, gfx::GpuMemoryBuffer::SCANOUT, surface_id); | 209 size, format, gfx::BufferUsage::SCANOUT, surface_id); |
212 } | 210 } |
213 | 211 |
214 void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess( | 212 void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess( |
215 const gfx::Size& size, | 213 const gfx::Size& size, |
216 gfx::GpuMemoryBuffer::Format format, | 214 gfx::BufferFormat format, |
217 gfx::GpuMemoryBuffer::Usage usage, | 215 gfx::BufferUsage usage, |
218 base::ProcessHandle child_process_handle, | 216 base::ProcessHandle child_process_handle, |
219 int child_client_id, | 217 int child_client_id, |
220 const AllocationCallback& callback) { | 218 const AllocationCallback& callback) { |
221 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 219 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
222 | 220 |
223 gfx::GpuMemoryBufferId new_id = g_next_gpu_memory_buffer_id.GetNext(); | 221 gfx::GpuMemoryBufferId new_id = g_next_gpu_memory_buffer_id.GetNext(); |
224 | 222 |
225 // Use service side allocation if this is a supported configuration. | 223 // Use service side allocation if this is a supported configuration. |
226 if (IsGpuMemoryBufferConfigurationSupported(format, usage)) { | 224 if (IsGpuMemoryBufferConfigurationSupported(format, usage)) { |
227 AllocateGpuMemoryBufferOnIO(new_id, size, format, usage, child_client_id, 0, | 225 AllocateGpuMemoryBufferOnIO(new_id, size, format, usage, child_client_id, 0, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if (host) | 336 if (host) |
339 host->DestroyGpuMemoryBuffer(buffer.first, client_id, 0); | 337 host->DestroyGpuMemoryBuffer(buffer.first, client_id, 0); |
340 } | 338 } |
341 | 339 |
342 clients_.erase(client_it); | 340 clients_.erase(client_it); |
343 } | 341 } |
344 | 342 |
345 scoped_ptr<gfx::GpuMemoryBuffer> | 343 scoped_ptr<gfx::GpuMemoryBuffer> |
346 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface( | 344 BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface( |
347 const gfx::Size& size, | 345 const gfx::Size& size, |
348 gfx::GpuMemoryBuffer::Format format, | 346 gfx::BufferFormat format, |
349 gfx::GpuMemoryBuffer::Usage usage, | 347 gfx::BufferUsage usage, |
350 int32 surface_id) { | 348 int32 surface_id) { |
351 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); | 349 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO)); |
352 | 350 |
353 AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_, | 351 AllocateGpuMemoryBufferRequest request(size, format, usage, gpu_client_id_, |
354 surface_id); | 352 surface_id); |
355 BrowserThread::PostTask( | 353 BrowserThread::PostTask( |
356 BrowserThread::IO, FROM_HERE, | 354 BrowserThread::IO, FROM_HERE, |
357 base::Bind( | 355 base::Bind( |
358 &BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurfaceOnIO, | 356 &BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurfaceOnIO, |
359 base::Unretained(this), // Safe as we wait for result below. | 357 base::Unretained(this), // Safe as we wait for result below. |
360 base::Unretained(&request))); | 358 base::Unretained(&request))); |
361 | 359 |
362 // We're blocking the UI thread, which is generally undesirable. | 360 // We're blocking the UI thread, which is generally undesirable. |
363 TRACE_EVENT0( | 361 TRACE_EVENT0( |
364 "browser", | 362 "browser", |
365 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface"); | 363 "BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurface"); |
366 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 364 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
367 request.event.Wait(); | 365 request.event.Wait(); |
368 return request.result.Pass(); | 366 return request.result.Pass(); |
369 } | 367 } |
370 | 368 |
371 bool BrowserGpuMemoryBufferManager::IsGpuMemoryBufferConfigurationSupported( | 369 bool BrowserGpuMemoryBufferManager::IsGpuMemoryBufferConfigurationSupported( |
372 gfx::GpuMemoryBuffer::Format format, | 370 gfx::BufferFormat format, |
373 gfx::GpuMemoryBuffer::Usage usage) const { | 371 gfx::BufferUsage usage) const { |
374 for (auto& configuration : supported_configurations_) { | 372 for (auto& configuration : supported_configurations_) { |
375 if (configuration.format == format && configuration.usage == usage) | 373 if (configuration.format == format && configuration.usage == usage) |
376 return true; | 374 return true; |
377 } | 375 } |
378 return false; | 376 return false; |
379 } | 377 } |
380 | 378 |
381 void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurfaceOnIO( | 379 void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForSurfaceOnIO( |
382 AllocateGpuMemoryBufferRequest* request) { | 380 AllocateGpuMemoryBufferRequest* request) { |
383 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 381 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
384 | 382 |
385 gfx::GpuMemoryBufferId new_id = g_next_gpu_memory_buffer_id.GetNext(); | 383 gfx::GpuMemoryBufferId new_id = g_next_gpu_memory_buffer_id.GetNext(); |
386 | 384 |
387 // Use service side allocation if this is a supported configuration. | 385 // Use service side allocation if this is a supported configuration. |
388 if (IsGpuMemoryBufferConfigurationSupported(request->format, | 386 if (IsGpuMemoryBufferConfigurationSupported(request->format, |
389 request->usage)) { | 387 request->usage)) { |
390 // Note: Unretained is safe as this is only used for synchronous allocation | 388 // Note: Unretained is safe as this is only used for synchronous allocation |
391 // from a non-IO thread. | 389 // from a non-IO thread. |
392 AllocateGpuMemoryBufferOnIO( | 390 AllocateGpuMemoryBufferOnIO( |
393 new_id, request->size, request->format, request->usage, | 391 new_id, request->size, request->format, request->usage, |
394 request->client_id, request->surface_id, false, | 392 request->client_id, request->surface_id, false, |
395 base::Bind(&BrowserGpuMemoryBufferManager:: | 393 base::Bind(&BrowserGpuMemoryBufferManager:: |
396 GpuMemoryBufferAllocatedForSurfaceOnIO, | 394 GpuMemoryBufferAllocatedForSurfaceOnIO, |
397 base::Unretained(this), base::Unretained(request))); | 395 base::Unretained(this), base::Unretained(request))); |
398 return; | 396 return; |
399 } | 397 } |
400 | 398 |
401 DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(request->format)) | 399 DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(request->format)) |
402 << request->format; | 400 << static_cast<int>(request->format); |
403 DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(request->usage)) | 401 DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(request->usage)) |
404 << request->usage; | 402 << static_cast<int>(request->usage); |
405 | 403 |
406 BufferMap& buffers = clients_[request->client_id]; | 404 BufferMap& buffers = clients_[request->client_id]; |
407 DCHECK(buffers.find(new_id) == buffers.end()); | 405 DCHECK(buffers.find(new_id) == buffers.end()); |
408 | 406 |
409 // Allocate shared memory buffer as fallback. | 407 // Allocate shared memory buffer as fallback. |
410 buffers[new_id] = BufferInfo(request->size, gfx::SHARED_MEMORY_BUFFER, | 408 buffers[new_id] = BufferInfo(request->size, gfx::SHARED_MEMORY_BUFFER, |
411 request->format, request->usage, 0); | 409 request->format, request->usage, 0); |
412 // Note: Unretained is safe as IO thread is stopped before manager is | 410 // Note: Unretained is safe as IO thread is stopped before manager is |
413 // destroyed. | 411 // destroyed. |
414 request->result = GpuMemoryBufferImplSharedMemory::Create( | 412 request->result = GpuMemoryBufferImplSharedMemory::Create( |
(...skipping 25 matching lines...) Expand all Loading... |
440 &GpuMemoryBufferDeleted, | 438 &GpuMemoryBufferDeleted, |
441 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 439 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
442 base::Bind(&BrowserGpuMemoryBufferManager::DestroyGpuMemoryBufferOnIO, | 440 base::Bind(&BrowserGpuMemoryBufferManager::DestroyGpuMemoryBufferOnIO, |
443 base::Unretained(this), handle.id, request->client_id))); | 441 base::Unretained(this), handle.id, request->client_id))); |
444 request->event.Signal(); | 442 request->event.Signal(); |
445 } | 443 } |
446 | 444 |
447 void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO( | 445 void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferOnIO( |
448 gfx::GpuMemoryBufferId id, | 446 gfx::GpuMemoryBufferId id, |
449 const gfx::Size& size, | 447 const gfx::Size& size, |
450 gfx::GpuMemoryBuffer::Format format, | 448 gfx::BufferFormat format, |
451 gfx::GpuMemoryBuffer::Usage usage, | 449 gfx::BufferUsage usage, |
452 int client_id, | 450 int client_id, |
453 int surface_id, | 451 int surface_id, |
454 bool reused_gpu_process, | 452 bool reused_gpu_process, |
455 const AllocationCallback& callback) { | 453 const AllocationCallback& callback) { |
456 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 454 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
457 | 455 |
458 BufferMap& buffers = clients_[client_id]; | 456 BufferMap& buffers = clients_[client_id]; |
459 DCHECK(buffers.find(id) == buffers.end()); | 457 DCHECK(buffers.find(id) == buffers.end()); |
460 | 458 |
461 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); | 459 GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // If we failed after re-using the GPU process, it may have died in the | 530 // If we failed after re-using the GPU process, it may have died in the |
533 // mean time. Retry to have a chance to create a fresh GPU process. | 531 // mean time. Retry to have a chance to create a fresh GPU process. |
534 if (handle.is_null() && reused_gpu_process) { | 532 if (handle.is_null() && reused_gpu_process) { |
535 DVLOG(1) << "Failed to create buffer through existing GPU process. " | 533 DVLOG(1) << "Failed to create buffer through existing GPU process. " |
536 "Trying to restart GPU process."; | 534 "Trying to restart GPU process."; |
537 // If the GPU process has already been restarted, retry without failure | 535 // If the GPU process has already been restarted, retry without failure |
538 // when GPU process host ID already exists. | 536 // when GPU process host ID already exists. |
539 if (gpu_host_id != gpu_host_id_) | 537 if (gpu_host_id != gpu_host_id_) |
540 reused_gpu_process = false; | 538 reused_gpu_process = false; |
541 gfx::Size size = buffer_it->second.size; | 539 gfx::Size size = buffer_it->second.size; |
542 gfx::GpuMemoryBuffer::Format format = buffer_it->second.format; | 540 gfx::BufferFormat format = buffer_it->second.format; |
543 gfx::GpuMemoryBuffer::Usage usage = buffer_it->second.usage; | 541 gfx::BufferUsage usage = buffer_it->second.usage; |
544 // Remove the buffer entry and call AllocateGpuMemoryBufferOnIO again. | 542 // Remove the buffer entry and call AllocateGpuMemoryBufferOnIO again. |
545 buffers.erase(buffer_it); | 543 buffers.erase(buffer_it); |
546 AllocateGpuMemoryBufferOnIO(id, size, format, usage, client_id, | 544 AllocateGpuMemoryBufferOnIO(id, size, format, usage, client_id, |
547 surface_id, reused_gpu_process, callback); | 545 surface_id, reused_gpu_process, callback); |
548 } else { | 546 } else { |
549 // Remove the buffer entry and run the allocation callback with an empty | 547 // Remove the buffer entry and run the allocation callback with an empty |
550 // handle to indicate failure. | 548 // handle to indicate failure. |
551 buffers.erase(buffer_it); | 549 buffers.erase(buffer_it); |
552 callback.Run(gfx::GpuMemoryBufferHandle()); | 550 callback.Run(gfx::GpuMemoryBufferHandle()); |
553 } | 551 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 } | 583 } |
586 | 584 |
587 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); | 585 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); |
588 if (host) | 586 if (host) |
589 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); | 587 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); |
590 | 588 |
591 buffers.erase(buffer_it); | 589 buffers.erase(buffer_it); |
592 } | 590 } |
593 | 591 |
594 } // namespace content | 592 } // namespace content |
OLD | NEW |