| 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 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <limits> | 10 #include <limits> |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 bool use_low_memory_policy = | 411 bool use_low_memory_policy = |
| 412 base::SysInfo::IsLowEndDevice() && !using_synchronous_compositor; | 412 base::SysInfo::IsLowEndDevice() && !using_synchronous_compositor; |
| 413 if (use_low_memory_policy) { | 413 if (use_low_memory_policy) { |
| 414 // On low-end we want to be very carefull about killing other | 414 // On low-end we want to be very carefull about killing other |
| 415 // apps. So initially we use 50% more memory to avoid flickering | 415 // apps. So initially we use 50% more memory to avoid flickering |
| 416 // or raster-on-demand. | 416 // or raster-on-demand. |
| 417 settings.max_memory_for_prepaint_percentage = 67; | 417 settings.max_memory_for_prepaint_percentage = 67; |
| 418 | 418 |
| 419 // RGBA_4444 textures are only enabled by default for low end devices | 419 // RGBA_4444 textures are only enabled by default for low end devices |
| 420 // and are disabled for Android WebView as it doesn't support the format. | 420 // and are disabled for Android WebView as it doesn't support the format. |
| 421 if (!cmd.HasSwitch(switches::kDisableRGBA4444Textures)) | 421 if (!cmd.HasSwitch(switches::kDisableRGBA4444Textures) && |
| 422 base::SysInfo::AmountOfPhysicalMemoryMB() <= 512) |
| 422 settings.renderer_settings.preferred_tile_format = cc::RGBA_4444; | 423 settings.renderer_settings.preferred_tile_format = cc::RGBA_4444; |
| 423 } else { | 424 } else { |
| 424 // On other devices we have increased memory excessively to avoid | 425 // On other devices we have increased memory excessively to avoid |
| 425 // raster-on-demand already, so now we reserve 50% _only_ to avoid | 426 // raster-on-demand already, so now we reserve 50% _only_ to avoid |
| 426 // raster-on-demand, and use 50% of the memory otherwise. | 427 // raster-on-demand, and use 50% of the memory otherwise. |
| 427 settings.max_memory_for_prepaint_percentage = 50; | 428 settings.max_memory_for_prepaint_percentage = 50; |
| 428 } | 429 } |
| 429 // Webview does not own the surface so should not clear it. | 430 // Webview does not own the surface so should not clear it. |
| 430 settings.renderer_settings.should_clear_root_render_pass = | 431 settings.renderer_settings.should_clear_root_render_pass = |
| 431 !using_synchronous_compositor; | 432 !using_synchronous_compositor; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 // Nexus 4/10(2GB) 256MB (normally 128MB) | 544 // Nexus 4/10(2GB) 256MB (normally 128MB) |
| 544 // Droid Razr M(1GB) 114MB (normally 57MB) | 545 // Droid Razr M(1GB) 114MB (normally 57MB) |
| 545 // Galaxy Nexus(1GB) 100MB (normally 50MB) | 546 // Galaxy Nexus(1GB) 100MB (normally 50MB) |
| 546 // Xoom(1GB) 100MB (normally 50MB) | 547 // Xoom(1GB) 100MB (normally 50MB) |
| 547 // Nexus S(low-end) 8MB (normally 8MB) | 548 // Nexus S(low-end) 8MB (normally 8MB) |
| 548 // Note that the compositor now uses only some of this memory for | 549 // Note that the compositor now uses only some of this memory for |
| 549 // pre-painting and uses the rest only for 'emergencies'. | 550 // pre-painting and uses the rest only for 'emergencies'. |
| 550 if (actual.bytes_limit_when_visible == 0) { | 551 if (actual.bytes_limit_when_visible == 0) { |
| 551 // NOTE: Non-low-end devices use only 50% of these limits, | 552 // NOTE: Non-low-end devices use only 50% of these limits, |
| 552 // except during 'emergencies' where 100% can be used. | 553 // except during 'emergencies' where 100% can be used. |
| 553 if (!base::SysInfo::IsLowEndDevice()) { | 554 if (physical_memory_mb >= 1536) |
| 554 if (physical_memory_mb >= 1536) | 555 actual.bytes_limit_when_visible = physical_memory_mb / 8; // >192MB |
| 555 actual.bytes_limit_when_visible = physical_memory_mb / 8; // >192MB | 556 else if (physical_memory_mb >= 1152) |
| 556 else if (physical_memory_mb >= 1152) | 557 actual.bytes_limit_when_visible = physical_memory_mb / 8; // >144MB |
| 557 actual.bytes_limit_when_visible = physical_memory_mb / 8; // >144MB | 558 else if (physical_memory_mb >= 768) |
| 558 else if (physical_memory_mb >= 768) | 559 actual.bytes_limit_when_visible = physical_memory_mb / 10; // >76MB |
| 559 actual.bytes_limit_when_visible = physical_memory_mb / 10; // >76MB | 560 else if (physical_memory_mb >= 513) |
| 560 else | 561 actual.bytes_limit_when_visible = physical_memory_mb / 12; // <64MB |
| 561 actual.bytes_limit_when_visible = physical_memory_mb / 12; // <64MB | 562 else |
| 562 } else { | 563 // Devices with this little RAM have very little headroom so we hardcode |
| 563 // Low-end devices have 512MB or less memory by definition | 564 // the limit rather than relying on the heuristics above. (They also use |
| 564 // so we hard code the limit rather than relying on the heuristics | 565 // 4444 textures so we can use a lower limit.) |
| 565 // above. Low-end devices use 4444 textures so we can use a lower limit. | |
| 566 actual.bytes_limit_when_visible = 8; | 566 actual.bytes_limit_when_visible = 8; |
| 567 } | 567 |
| 568 actual.bytes_limit_when_visible = | 568 actual.bytes_limit_when_visible = |
| 569 actual.bytes_limit_when_visible * 1024 * 1024; | 569 actual.bytes_limit_when_visible * 1024 * 1024; |
| 570 // Clamp the observed value to a specific range on Android. | 570 // Clamp the observed value to a specific range on Android. |
| 571 actual.bytes_limit_when_visible = std::max( | 571 actual.bytes_limit_when_visible = std::max( |
| 572 actual.bytes_limit_when_visible, static_cast<size_t>(8 * 1024 * 1024)); | 572 actual.bytes_limit_when_visible, static_cast<size_t>(8 * 1024 * 1024)); |
| 573 actual.bytes_limit_when_visible = | 573 actual.bytes_limit_when_visible = |
| 574 std::min(actual.bytes_limit_when_visible, | 574 std::min(actual.bytes_limit_when_visible, |
| 575 static_cast<size_t>(256 * 1024 * 1024)); | 575 static_cast<size_t>(256 * 1024 * 1024)); |
| 576 } | 576 } |
| 577 actual.priority_cutoff_when_visible = | 577 actual.priority_cutoff_when_visible = |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 void RenderWidgetCompositor::SetContentSourceId(uint32_t id) { | 1147 void RenderWidgetCompositor::SetContentSourceId(uint32_t id) { |
| 1148 layer_tree_host_->SetContentSourceId(id); | 1148 layer_tree_host_->SetContentSourceId(id); |
| 1149 } | 1149 } |
| 1150 | 1150 |
| 1151 void RenderWidgetCompositor::SetLocalSurfaceId( | 1151 void RenderWidgetCompositor::SetLocalSurfaceId( |
| 1152 const cc::LocalSurfaceId& local_surface_id) { | 1152 const cc::LocalSurfaceId& local_surface_id) { |
| 1153 layer_tree_host_->SetLocalSurfaceId(local_surface_id); | 1153 layer_tree_host_->SetLocalSurfaceId(local_surface_id); |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 } // namespace content | 1156 } // namespace content |
| OLD | NEW |