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

Side by Side Diff: content/common/gpu/gpu_memory_manager.cc

Issue 22923016: Minimize GPU memory usage on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/gpu/gpu_memory_manager.h" 5 #include "content/common/gpu/gpu_memory_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 bytes_minimum_per_client_ = 16 * 1024 * 1024; 72 bytes_minimum_per_client_ = 16 * 1024 * 1024;
73 #elif defined(OS_CHROMEOS) 73 #elif defined(OS_CHROMEOS)
74 bytes_default_per_client_ = 64 * 1024 * 1024; 74 bytes_default_per_client_ = 64 * 1024 * 1024;
75 bytes_minimum_per_client_ = 4 * 1024 * 1024; 75 bytes_minimum_per_client_ = 4 * 1024 * 1024;
76 #else 76 #else
77 bytes_default_per_client_ = 64 * 1024 * 1024; 77 bytes_default_per_client_ = 64 * 1024 * 1024;
78 bytes_minimum_per_client_ = 64 * 1024 * 1024; 78 bytes_minimum_per_client_ = 64 * 1024 * 1024;
79 #endif 79 #endif
80 80
81 // On Android, always discard everything that is nonvisible. 81 // On Android, always discard everything that is nonvisible.
82 // On Mac, use as little memory as possible to avoid stability issues. 82 // On Linux and Mac, use as little memory as possible to avoid stability
83 #if defined(OS_ANDROID) || defined(OS_MACOSX) 83 // issues.
84 // http://crbug.com/145600 (Linux)
85 // http://crbug.com/141377 (Mac)
86 #if defined(OS_ANDROID) || defined(OS_MACOSX) || \
87 (defined(OS_LINUX) && !defined(OS_CHROMEOS))
84 allow_nonvisible_memory_ = false; 88 allow_nonvisible_memory_ = false;
85 #else 89 #else
86 allow_nonvisible_memory_ = true; 90 allow_nonvisible_memory_ = true;
87 #endif 91 #endif
88 92
89 if (command_line->HasSwitch(switches::kForceGpuMemAvailableMb)) { 93 if (command_line->HasSwitch(switches::kForceGpuMemAvailableMb)) {
90 base::StringToUint64( 94 base::StringToUint64(
91 command_line->GetSwitchValueASCII(switches::kForceGpuMemAvailableMb), 95 command_line->GetSwitchValueASCII(switches::kForceGpuMemAvailableMb),
92 &bytes_available_gpu_memory_); 96 &bytes_available_gpu_memory_);
93 bytes_available_gpu_memory_ *= 1024 * 1024; 97 bytes_available_gpu_memory_ *= 1024 * 1024;
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 3 * client_state->managed_memory_stats_.bytes_nice_to_have / 4; 771 3 * client_state->managed_memory_stats_.bytes_nice_to_have / 4;
768 772
769 // Populate and send the allocation to the client 773 // Populate and send the allocation to the client
770 GpuMemoryAllocation allocation; 774 GpuMemoryAllocation allocation;
771 775
772 allocation.browser_allocation.suggest_have_frontbuffer = 776 allocation.browser_allocation.suggest_have_frontbuffer =
773 !client_state->hibernated_; 777 !client_state->hibernated_;
774 778
775 allocation.renderer_allocation.bytes_limit_when_visible = 779 allocation.renderer_allocation.bytes_limit_when_visible =
776 client_state->bytes_allocation_when_visible_; 780 client_state->bytes_allocation_when_visible_;
777 // Use a more conservative memory allocation policy on Mac because the 781 // Use a more conservative memory allocation policy on Linux and Mac
778 // platform is unstable when under memory pressure. 782 // because the platform is unstable when under memory pressure.
779 // http://crbug.com/141377 783 // http://crbug.com/145600 (Linux)
784 // http://crbug.com/141377 (Mac)
780 allocation.renderer_allocation.priority_cutoff_when_visible = 785 allocation.renderer_allocation.priority_cutoff_when_visible =
781 #if defined(OS_MACOSX) 786 #if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
782 GpuMemoryAllocationForRenderer::kPriorityCutoffAllowNiceToHave; 787 GpuMemoryAllocationForRenderer::kPriorityCutoffAllowNiceToHave;
783 #else 788 #else
784 GpuMemoryAllocationForRenderer::kPriorityCutoffAllowEverything; 789 GpuMemoryAllocationForRenderer::kPriorityCutoffAllowEverything;
785 #endif 790 #endif
786 791
787 allocation.renderer_allocation.bytes_limit_when_not_visible = 792 allocation.renderer_allocation.bytes_limit_when_not_visible =
788 client_state->bytes_allocation_when_nonvisible_; 793 client_state->bytes_allocation_when_nonvisible_;
789 allocation.renderer_allocation.priority_cutoff_when_not_visible = 794 allocation.renderer_allocation.priority_cutoff_when_not_visible =
790 GpuMemoryAllocationForRenderer::kPriorityCutoffAllowOnlyRequired; 795 GpuMemoryAllocationForRenderer::kPriorityCutoffAllowOnlyRequired;
791 796
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 894
890 void GpuMemoryManager::RemoveClientFromList( 895 void GpuMemoryManager::RemoveClientFromList(
891 GpuMemoryManagerClientState* client_state) { 896 GpuMemoryManagerClientState* client_state) {
892 DCHECK(client_state->list_iterator_valid_); 897 DCHECK(client_state->list_iterator_valid_);
893 ClientStateList* client_list = GetClientList(client_state); 898 ClientStateList* client_list = GetClientList(client_state);
894 client_list->erase(client_state->list_iterator_); 899 client_list->erase(client_state->list_iterator_);
895 client_state->list_iterator_valid_ = false; 900 client_state->list_iterator_valid_ = false;
896 } 901 }
897 902
898 } // namespace content 903 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698