diff options
Diffstat (limited to 'content/browser')
6 files changed, 34 insertions, 80 deletions
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index 50d0d82..7c90c64 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -469,8 +469,6 @@ void BrowserMainLoop::EarlyInitialization() { if (parsed_command_line_.HasSwitch(switches::kEnableNativeGpuMemoryBuffers)) { BrowserGpuChannelHostFactory::EnableGpuMemoryBufferFactoryUsage( gfx::GpuMemoryBuffer::MAP); - BrowserGpuChannelHostFactory::EnableGpuMemoryBufferFactoryUsage( - gfx::GpuMemoryBuffer::PERSISTENT_MAP); } #if defined(USE_OZONE) diff --git a/content/browser/compositor/gpu_process_transport_factory.cc b/content/browser/compositor/gpu_process_transport_factory.cc index 6173d6c..112405f 100644 --- a/content/browser/compositor/gpu_process_transport_factory.cc +++ b/content/browser/compositor/gpu_process_transport_factory.cc @@ -402,19 +402,7 @@ void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor* compositor) { bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; } uint32 GpuProcessTransportFactory::GetImageTextureTarget() { - // TODO(reveman): We currently assume that the compositor will use BGRA_8888 - // if it's able to, and RGBA_8888 otherwise. Since we don't know what it will - // use we hardcode BGRA_8888 here for now. We should instead - // move decisions about GpuMemoryBuffer format to the browser embedder so we - // know it here, and pass that decision to the compositor for each usage. - // crbug.com/490362 - gfx::GpuMemoryBuffer::Format format = gfx::GpuMemoryBuffer::BGRA_8888; - - // TODO(danakj): When one-copy uploads support partial update, change this - // usage to PERSISTENT_MAP for one-copy. - gfx::GpuMemoryBuffer::Usage usage = gfx::GpuMemoryBuffer::MAP; - - return BrowserGpuChannelHostFactory::GetImageTextureTarget(format, usage); + return BrowserGpuChannelHostFactory::GetImageTextureTarget(); } cc::SharedBitmapManager* GpuProcessTransportFactory::GetSharedBitmapManager() { diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc index 4019ccb..205542c 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.cc +++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc @@ -43,38 +43,8 @@ namespace { base::LazyInstance<std::set<gfx::GpuMemoryBuffer::Usage>> g_enabled_gpu_memory_buffer_usages; - -bool IsGpuMemoryBufferFactoryConfigurationSupported( - gfx::GpuMemoryBuffer::Format format, - gfx::GpuMemoryBuffer::Usage usage, - gfx::GpuMemoryBufferType type) { - switch (type) { - case gfx::SHARED_MEMORY_BUFFER: - // Shared memory buffers must be created in-process. - return false; -#if defined(OS_MACOSX) - case gfx::IO_SURFACE_BUFFER: - return GpuMemoryBufferFactoryIOSurface:: - IsGpuMemoryBufferConfigurationSupported(format, usage); -#endif -#if defined(OS_ANDROID) - case gfx::SURFACE_TEXTURE_BUFFER: - return GpuMemoryBufferFactorySurfaceTexture:: - IsGpuMemoryBufferConfigurationSupported(format, usage); -#endif -#if defined(USE_OZONE) - case gfx::OZONE_NATIVE_BUFFER: - return GpuMemoryBufferFactoryOzoneNativeBuffer:: - IsGpuMemoryBufferConfigurationSupported(format, usage); -#endif - default: - NOTREACHED(); - return false; - } } -} // namespace - BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; struct BrowserGpuChannelHostFactory::CreateRequest { @@ -284,23 +254,17 @@ bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferFactoryUsageEnabled( } // static -uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget( - gfx::GpuMemoryBuffer::Format format, - gfx::GpuMemoryBuffer::Usage usage) { - if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) +uint32 BrowserGpuChannelHostFactory::GetImageTextureTarget() { + if (!IsGpuMemoryBufferFactoryUsageEnabled(gfx::GpuMemoryBuffer::MAP)) return GL_TEXTURE_2D; std::vector<gfx::GpuMemoryBufferType> supported_types; GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); DCHECK(!supported_types.empty()); - // The GPU service will always use the preferred type, if the |format| and - // |usage| allows. + // The GPU service will always use the preferred type. gfx::GpuMemoryBufferType type = supported_types[0]; - if (!IsGpuMemoryBufferFactoryConfigurationSupported(format, usage, type)) - return GL_TEXTURE_2D; - switch (type) { case gfx::SURFACE_TEXTURE_BUFFER: case gfx::OZONE_NATIVE_BUFFER: @@ -507,15 +471,33 @@ bool BrowserGpuChannelHostFactory::IsGpuMemoryBufferConfigurationSupported( if (!IsGpuMemoryBufferFactoryUsageEnabled(usage)) return false; + // Preferred type is always used by factory. std::vector<gfx::GpuMemoryBufferType> supported_types; GpuMemoryBufferFactory::GetSupportedTypes(&supported_types); DCHECK(!supported_types.empty()); - - // The GPU service will always use the preferred type, if the |format| and - // |usage| allows. - gfx::GpuMemoryBufferType type = supported_types[0]; - - return IsGpuMemoryBufferFactoryConfigurationSupported(format, usage, type); + switch (supported_types[0]) { + case gfx::SHARED_MEMORY_BUFFER: + // Shared memory buffers must be created in-process. + return false; +#if defined(OS_MACOSX) + case gfx::IO_SURFACE_BUFFER: + return GpuMemoryBufferFactoryIOSurface:: + IsGpuMemoryBufferConfigurationSupported(format, usage); +#endif +#if defined(OS_ANDROID) + case gfx::SURFACE_TEXTURE_BUFFER: + return GpuMemoryBufferFactorySurfaceTexture:: + IsGpuMemoryBufferConfigurationSupported(format, usage); +#endif +#if defined(USE_OZONE) + case gfx::OZONE_NATIVE_BUFFER: + return GpuMemoryBufferFactoryOzoneNativeBuffer:: + IsGpuMemoryBufferConfigurationSupported(format, usage); +#endif + default: + NOTREACHED(); + return false; + } } void BrowserGpuChannelHostFactory::CreateGpuMemoryBuffer( diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.h b/content/browser/gpu/browser_gpu_channel_host_factory.h index aac6e69..b4df563 100644 --- a/content/browser/gpu/browser_gpu_channel_host_factory.h +++ b/content/browser/gpu/browser_gpu_channel_host_factory.h @@ -29,8 +29,7 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory gfx::GpuMemoryBuffer::Usage usage); static bool IsGpuMemoryBufferFactoryUsageEnabled( gfx::GpuMemoryBuffer::Usage usage); - static uint32 GetImageTextureTarget(gfx::GpuMemoryBuffer::Format format, - gfx::GpuMemoryBuffer::Usage usage); + static uint32 GetImageTextureTarget(); // Overridden from GpuChannelHostFactory: bool IsMainThread() override; diff --git a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc index 2db48f1..70184a0 100644 --- a/content/browser/gpu/browser_gpu_memory_buffer_manager.cc +++ b/content/browser/gpu/browser_gpu_memory_buffer_manager.cc @@ -99,9 +99,8 @@ BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferCommon( // by factory. if (!gpu_memory_buffer_factory_host_->IsGpuMemoryBufferConfigurationSupported( format, usage)) { - DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(format)) - << format; - DCHECK(GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) << usage; + DCHECK(GpuMemoryBufferImplSharedMemory::IsFormatSupported(format)); + DCHECK_EQ(usage, gfx::GpuMemoryBuffer::MAP); return GpuMemoryBufferImplSharedMemory::Create( g_next_gpu_memory_buffer_id.GetNext(), size, format); } @@ -143,8 +142,8 @@ void BrowserGpuMemoryBufferManager::AllocateGpuMemoryBufferForChildProcess( format, usage)) { // Early out if we cannot fallback to shared memory buffer. if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || - !GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage) || - !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format)) { + !GpuMemoryBufferImplSharedMemory::IsSizeValidForFormat(size, format) || + usage != gfx::GpuMemoryBuffer::MAP) { callback.Run(gfx::GpuMemoryBufferHandle()); return; } diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 2d0d2c6..9179690 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -1133,22 +1133,10 @@ static void AppendCompositorCommandLineFlags(base::CommandLine* command_line) { if (IsForceGpuRasterizationEnabled()) command_line->AppendSwitch(switches::kForceGpuRasterization); - // TODO(reveman): We currently assume that the compositor will use BGRA_8888 - // if it's able to, and RGBA_8888 otherwise. Since we don't know what it will - // use we hardcode BGRA_8888 here for now. We should instead - // move decisions about GpuMemoryBuffer format to the browser embedder so we - // know it here, and pass that decision to the compositor for each usage. - // crbug.com/490362 - gfx::GpuMemoryBuffer::Format format = gfx::GpuMemoryBuffer::BGRA_8888; - - // TODO(danakj): When one-copy uploads support partial update, change this - // usage to PERSISTENT_MAP for one-copy. - gfx::GpuMemoryBuffer::Usage usage = gfx::GpuMemoryBuffer::MAP; - command_line->AppendSwitchASCII( switches::kUseImageTextureTarget, base::UintToString( - BrowserGpuChannelHostFactory::GetImageTextureTarget(format, usage))); + BrowserGpuChannelHostFactory::GetImageTextureTarget())); // Appending disable-gpu-feature switches due to software rendering list. GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |