| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 491 |
| 492 if (cmd.HasSwitch(cc::switches::kEnableTileCompression)) { | 492 if (cmd.HasSwitch(cc::switches::kEnableTileCompression)) { |
| 493 settings.renderer_settings.preferred_tile_format = cc::ETC1; | 493 settings.renderer_settings.preferred_tile_format = cc::ETC1; |
| 494 } | 494 } |
| 495 | 495 |
| 496 settings.max_staging_buffer_usage_in_bytes = 32 * 1024 * 1024; // 32MB | 496 settings.max_staging_buffer_usage_in_bytes = 32 * 1024 * 1024; // 32MB |
| 497 // Use 1/4th of staging buffers on low-end devices. | 497 // Use 1/4th of staging buffers on low-end devices. |
| 498 if (base::SysInfo::IsLowEndDevice()) | 498 if (base::SysInfo::IsLowEndDevice()) |
| 499 settings.max_staging_buffer_usage_in_bytes /= 4; | 499 settings.max_staging_buffer_usage_in_bytes /= 4; |
| 500 | 500 |
| 501 cc::ManagedMemoryPolicy current = settings.memory_policy_; | 501 cc::ManagedMemoryPolicy defaults = settings.gpu_memory_policy; |
| 502 settings.memory_policy_ = GetGpuMemoryPolicy(current); | 502 settings.gpu_memory_policy = GetGpuMemoryPolicy(defaults); |
| 503 settings.software_memory_policy.num_resources_limit = |
| 504 base::SharedMemory::GetHandleLimit() / 3; |
| 503 | 505 |
| 504 settings.use_cached_picture_raster = | 506 settings.use_cached_picture_raster = |
| 505 !cmd.HasSwitch(cc::switches::kDisableCachedPictureRaster); | 507 !cmd.HasSwitch(cc::switches::kDisableCachedPictureRaster); |
| 506 | 508 |
| 507 return settings; | 509 return settings; |
| 508 } | 510 } |
| 509 | 511 |
| 510 // static | 512 // static |
| 511 cc::ManagedMemoryPolicy RenderWidgetCompositor::GetGpuMemoryPolicy( | 513 cc::ManagedMemoryPolicy RenderWidgetCompositor::GetGpuMemoryPolicy( |
| 512 const cc::ManagedMemoryPolicy& policy) { | 514 const cc::ManagedMemoryPolicy& default_policy) { |
| 513 cc::ManagedMemoryPolicy actual = policy; | 515 cc::ManagedMemoryPolicy actual = default_policy; |
| 514 actual.bytes_limit_when_visible = 0; | 516 actual.bytes_limit_when_visible = 0; |
| 515 | 517 |
| 516 // If the value was overridden on the command line, use the specified value. | 518 // If the value was overridden on the command line, use the specified value. |
| 517 static bool client_hard_limit_bytes_overridden = | 519 static bool client_hard_limit_bytes_overridden = |
| 518 base::CommandLine::ForCurrentProcess()->HasSwitch( | 520 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 519 switches::kForceGpuMemAvailableMb); | 521 switches::kForceGpuMemAvailableMb); |
| 520 if (client_hard_limit_bytes_overridden) { | 522 if (client_hard_limit_bytes_overridden) { |
| 521 if (base::StringToSizeT( | 523 if (base::StringToSizeT( |
| 522 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 524 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 523 switches::kForceGpuMemAvailableMb), | 525 switches::kForceGpuMemAvailableMb), |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 | 1143 |
| 1142 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); | 1144 remote_proto_channel_receiver_->OnProtoReceived(std::move(deserialized)); |
| 1143 } | 1145 } |
| 1144 | 1146 |
| 1145 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( | 1147 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( |
| 1146 float device_scale) { | 1148 float device_scale) { |
| 1147 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); | 1149 layer_tree_host_->GetLayerTree()->SetPaintedDeviceScaleFactor(device_scale); |
| 1148 } | 1150 } |
| 1149 | 1151 |
| 1150 } // namespace content | 1152 } // namespace content |
| OLD | NEW |