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

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

Issue 1139903005: Add PERSISTENT_MAP usage for GpuMemoryBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: persistentmap: . Created 5 years, 7 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
OLDNEW
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 "content/browser/gpu/browser_gpu_channel_host_factory.h" 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/profiler/scoped_tracker.h" 10 #include "base/profiler/scoped_tracker.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 g_enabled_gpu_memory_buffer_usages.Get().insert(usage); 247 g_enabled_gpu_memory_buffer_usages.Get().insert(usage);
248 } 248 }
249 249
250 // static 250 // static
251 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( 251 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled(
252 gfx::GpuMemoryBuffer::Usage usage) { 252 gfx::GpuMemoryBuffer::Usage usage) {
253 return g_enabled_gpu_memory_buffer_usages.Get().count(usage) != 0; 253 return g_enabled_gpu_memory_buffer_usages.Get().count(usage) != 0;
254 } 254 }
255 255
256 // static 256 // static
257 uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget() { 257 uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget(
258 if (!IsGpuMemoryBufferFactoryUsageEnabled(gfx::GpuMemoryBuffer::MAP)) 258 gfx::GpuMemoryBuffer::Format format,
259 gfx::GpuMemoryBuffer::Usage usage) {
260 if (!IsGpuMemoryBufferFactoryUsageEnabled(usage))
259 return GL_TEXTURE_2D; 261 return GL_TEXTURE_2D;
260 262
261 std::vector<gfx::GpuMemoryBufferType> supported_types; 263 std::vector<gfx::GpuMemoryBufferType> supported_types;
262 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); 264 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types);
263 DCHECK(!supported_types.empty()); 265 DCHECK(!supported_types.empty());
264 266
265 // The GPU service will always use the preferred type. 267 // The GPU service will always use the preferred type, if the |format| and
268 // |usage| allows.
266 gfx::GpuMemoryBufferType type = supported_types[0]; 269 gfx::GpuMemoryBufferType type = supported_types[0];
267 270
271 if (!IsGpuMemoryBufferConfigurationSupportedInternal(format, usage, type))
272 return GL_TEXTURE_2D;
273
268 switch (type) { 274 switch (type) {
269 case gfx::SURFACE_TEXTURE_BUFFER: 275 case gfx::SURFACE_TEXTURE_BUFFER:
270 case gfx::OZONE_NATIVE_BUFFER: 276 case gfx::OZONE_NATIVE_BUFFER:
271 // GPU memory buffers that are shared with the GL using EGLImages require 277 // GPU memory buffers that are shared with the GL using EGLImages require
272 // TEXTURE_EXTERNAL_OES. 278 // TEXTURE_EXTERNAL_OES.
273 return GL_TEXTURE_EXTERNAL_OES; 279 return GL_TEXTURE_EXTERNAL_OES;
274 case gfx::IO_SURFACE_BUFFER: 280 case gfx::IO_SURFACE_BUFFER:
275 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB. 281 // IOSurface backed images require GL_TEXTURE_RECTANGLE_ARB.
276 return GL_TEXTURE_RECTANGLE_ARB; 282 return GL_TEXTURE_RECTANGLE_ARB;
277 default: 283 default:
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 host->AddFilter(filter.get()); 470 host->AddFilter(filter.get());
465 } 471 }
466 472
467 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferConfigurationSupported( 473 bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferConfigurationSupported(
468 gfx::GpuMemoryBuffer::Format format, 474 gfx::GpuMemoryBuffer::Format format,
469 gfx::GpuMemoryBuffer::Usage usage) { 475 gfx::GpuMemoryBuffer::Usage usage) {
470 // Return early if usage is not enabled. 476 // Return early if usage is not enabled.
471 if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) 477 if (!IsGpuMemoryBufferFactoryUsageEnabled(usage))
472 return false; 478 return false;
473 479
474 // Preferred type is always used by factory.
475 std::vector<gfx::GpuMemoryBufferType> supported_types; 480 std::vector<gfx::GpuMemoryBufferType> supported_types;
476 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); 481 GpuMemoryBufferFactory::GetSupportedTypes(&supported_types);
477 DCHECK(!supported_types.empty()); 482 DCHECK(!supported_types.empty());
478 switch (supported_types[0]) { 483
484 // The GPU service will always use the preferred type, if the |format| and
485 // |usage| allows.
486 gfx::GpuMemoryBufferType type = supported_types[0];
487
488 return IsGpuMemoryBufferConfigurationSupportedInternal(format, usage, type);
489 }
490
491 // static
492 bool BrowserGpuChannelHostFactory::
493 IsGpuMemoryBufferConfigurationSupportedInternal(
494 gfx::GpuMemoryBuffer::Format format,
495 gfx::GpuMemoryBuffer::Usage usage,
496 gfx::GpuMemoryBufferType type) {
497 switch (type) {
479 case gfx::SHARED_MEMORY_BUFFER: 498 case gfx::SHARED_MEMORY_BUFFER:
480 // Shared memory buffers must be created in-process. 499 // Shared memory buffers must be created in-process.
481 return false; 500 return false;
482 #if defined(OS_MACOSX) 501 #if defined(OS_MACOSX)
483 case gfx::IO_SURFACE_BUFFER: 502 case gfx::IO_SURFACE_BUFFER:
484 return GpuMemoryBufferFactoryIOSurface:: 503 return GpuMemoryBufferFactoryIOSurface::
485 IsGpuMemoryBufferConfigurationSupported(format, usage); 504 IsGpuMemoryBufferConfigurationSupported(format, usage);
486 #endif 505 #endif
487 #if defined(OS_ANDROID) 506 #if defined(OS_ANDROID)
488 case gfx::SURFACE_TEXTURE_BUFFER: 507 case gfx::SURFACE_TEXTURE_BUFFER:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 DCHECK_CURRENTLY_ON(BrowserThread::IO); 577 DCHECK_CURRENTLY_ON(BrowserThread::IO);
559 578
560 CreateGpuMemoryBufferCallbackMap::iterator iter = 579 CreateGpuMemoryBufferCallbackMap::iterator iter =
561 create_gpu_memory_buffer_requests_.find(request_id); 580 create_gpu_memory_buffer_requests_.find(request_id);
562 DCHECK(iter != create_gpu_memory_buffer_requests_.end()); 581 DCHECK(iter != create_gpu_memory_buffer_requests_.end());
563 iter->second.Run(handle); 582 iter->second.Run(handle);
564 create_gpu_memory_buffer_requests_.erase(iter); 583 create_gpu_memory_buffer_requests_.erase(iter);
565 } 584 }
566 585
567 } // namespace content 586 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698