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

Side by Side Diff: cc/resources/tile_manager.cc

Issue 13206004: cc: Fix build issues for adding ‘chromium_code’: 1 to cc.gyp and cc_tests.gyp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | « cc/resources/scoped_resource_unittest.cc ('k') | cc/scheduler/frame_rate_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/resources/tile_manager.h" 5 #include "cc/resources/tile_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 namespace { 24 namespace {
25 25
26 // If we raster too fast we become upload bound, and pending 26 // If we raster too fast we become upload bound, and pending
27 // uploads consume memory. For maximum upload throughput, we would 27 // uploads consume memory. For maximum upload throughput, we would
28 // want to allow for upload_throughput * pipeline_time of pending 28 // want to allow for upload_throughput * pipeline_time of pending
29 // uploads, after which we are just wasting memory. Since we don't 29 // uploads, after which we are just wasting memory. Since we don't
30 // know our upload throughput yet, this just caps our memory usage. 30 // know our upload throughput yet, this just caps our memory usage.
31 #if defined(OS_ANDROID) 31 #if defined(OS_ANDROID)
32 // For reference, the Nexus10 can upload 1MB in about 2.5ms. 32 // For reference, the Nexus10 can upload 1MB in about 2.5ms.
33 // Assuming a three frame deep pipeline this implies ~20MB. 33 // Assuming a three frame deep pipeline this implies ~20MB.
34 const int kMaxPendingUploadBytes = 20 * 1024 * 1024; 34 const size_t kMaxPendingUploadBytes = 20 * 1024 * 1024;
35 // TODO(epenner): We should remove this upload limit (crbug.com/176197) 35 // TODO(epenner): We should remove this upload limit (crbug.com/176197)
36 const int kMaxPendingUploads = 72; 36 const size_t kMaxPendingUploads = 72;
37 #else 37 #else
38 const int kMaxPendingUploadBytes = 100 * 1024 * 1024; 38 const size_t kMaxPendingUploadBytes = 100 * 1024 * 1024;
39 const int kMaxPendingUploads = 1000; 39 const size_t kMaxPendingUploads = 1000;
40 #endif 40 #endif
41 41
42 #if defined(OS_ANDROID) 42 #if defined(OS_ANDROID)
43 const int kMaxNumPendingTasksPerThread = 8; 43 const int kMaxNumPendingTasksPerThread = 8;
44 #else 44 #else
45 const int kMaxNumPendingTasksPerThread = 40; 45 const int kMaxNumPendingTasksPerThread = 40;
46 #endif 46 #endif
47 47
48 // Limit for time spent running cheap tasks during a single frame. 48 // Limit for time spent running cheap tasks during a single frame.
49 // TODO(skyostil): Determine this limit more dynamically. 49 // TODO(skyostil): Determine this limit more dynamically.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 bool prediction_benchmarking, 158 bool prediction_benchmarking,
159 RenderingStatsInstrumentation* rendering_stats_instrumentation) 159 RenderingStatsInstrumentation* rendering_stats_instrumentation)
160 : client_(client), 160 : client_(client),
161 resource_pool_(ResourcePool::Create(resource_provider)), 161 resource_pool_(ResourcePool::Create(resource_provider)),
162 raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)), 162 raster_worker_pool_(RasterWorkerPool::Create(this, num_raster_threads)),
163 manage_tiles_pending_(false), 163 manage_tiles_pending_(false),
164 manage_tiles_call_count_(0), 164 manage_tiles_call_count_(0),
165 bytes_pending_upload_(0), 165 bytes_pending_upload_(0),
166 has_performed_uploads_since_last_flush_(false), 166 has_performed_uploads_since_last_flush_(false),
167 ever_exceeded_memory_budget_(false), 167 ever_exceeded_memory_budget_(false),
168 rendering_stats_instrumentation_(rendering_stats_instrumentation),
168 max_prepaint_tile_distance_(max_prepaint_tile_distance), 169 max_prepaint_tile_distance_(max_prepaint_tile_distance),
169 use_cheapness_estimator_(use_cheapness_estimator), 170 use_cheapness_estimator_(use_cheapness_estimator),
170 use_color_estimator_(use_color_estimator), 171 use_color_estimator_(use_color_estimator),
171 prediction_benchmarking_(prediction_benchmarking), 172 prediction_benchmarking_(prediction_benchmarking),
172 did_initialize_visible_tile_(false), 173 did_initialize_visible_tile_(false),
173 pending_tasks_(0), 174 pending_tasks_(0),
174 max_pending_tasks_(kMaxNumPendingTasksPerThread * num_raster_threads), 175 max_pending_tasks_(kMaxNumPendingTasksPerThread * num_raster_threads) {
175 rendering_stats_instrumentation_(rendering_stats_instrumentation) {
176 for (int i = 0; i < NUM_STATES; ++i) { 176 for (int i = 0; i < NUM_STATES; ++i) {
177 for (int j = 0; j < NUM_TREES; ++j) { 177 for (int j = 0; j < NUM_TREES; ++j) {
178 for (int k = 0; k < NUM_BINS; ++k) 178 for (int k = 0; k < NUM_BINS; ++k)
179 raster_state_count_[i][j][k] = 0; 179 raster_state_count_[i][j][k] = 0;
180 } 180 }
181 } 181 }
182 } 182 }
183 183
184 TileManager::~TileManager() { 184 TileManager::~TileManager() {
185 // Reset global state and manage. This should cause 185 // Reset global state and manage. This should cause
186 // our memory usage to drop to zero. 186 // our memory usage to drop to zero.
187 global_state_ = GlobalStateThatImpactsTilePriority(); 187 global_state_ = GlobalStateThatImpactsTilePriority();
188 AssignGpuMemoryToTiles(); 188 AssignGpuMemoryToTiles();
189 // This should finish all pending tasks and release any uninitialized 189 // This should finish all pending tasks and release any uninitialized
190 // resources. 190 // resources.
191 raster_worker_pool_.reset(); 191 raster_worker_pool_.reset();
192 AbortPendingTileUploads(); 192 AbortPendingTileUploads();
193 DCHECK_EQ(tiles_with_pending_upload_.size(), 0); 193 DCHECK_EQ(0u, tiles_with_pending_upload_.size());
194 DCHECK_EQ(all_tiles_.size(), 0); 194 DCHECK_EQ(0u, all_tiles_.size());
195 DCHECK_EQ(live_or_allocated_tiles_.size(), 0); 195 DCHECK_EQ(0u, live_or_allocated_tiles_.size());
196 } 196 }
197 197
198 void TileManager::SetGlobalState( 198 void TileManager::SetGlobalState(
199 const GlobalStateThatImpactsTilePriority& global_state) { 199 const GlobalStateThatImpactsTilePriority& global_state) {
200 global_state_ = global_state; 200 global_state_ = global_state;
201 resource_pool_->SetMaxMemoryUsageBytes( 201 resource_pool_->SetMaxMemoryUsageBytes(
202 global_state_.memory_limit_in_bytes, 202 global_state_.memory_limit_in_bytes,
203 global_state_.unused_memory_limit_in_bytes); 203 global_state_.unused_memory_limit_in_bytes);
204 ScheduleManageTiles(); 204 ScheduleManageTiles();
205 UpdateCheapTasksTimeLimit(); 205 UpdateCheapTasksTimeLimit();
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 10); 1027 10);
1028 1028
1029 if (metadata.prediction_benchmarking) { 1029 if (metadata.prediction_benchmarking) {
1030 PicturePileImpl::Analysis analysis; 1030 PicturePileImpl::Analysis analysis;
1031 picture_pile->AnalyzeInRect(rect, contents_scale, &analysis); 1031 picture_pile->AnalyzeInRect(rect, contents_scale, &analysis);
1032 bool is_predicted_cheap = analysis.is_cheap_to_raster; 1032 bool is_predicted_cheap = analysis.is_cheap_to_raster;
1033 bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f; 1033 bool is_actually_cheap = duration.InMillisecondsF() <= 1.0f;
1034 RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap); 1034 RecordCheapnessPredictorResults(is_predicted_cheap, is_actually_cheap);
1035 1035
1036 DCHECK_EQ(bitmap.rowBytes(), 1036 DCHECK_EQ(bitmap.rowBytes(),
1037 bitmap.width() * bitmap.bytesPerPixel()); 1037 static_cast<size_t>(bitmap.width() * bitmap.bytesPerPixel()));
1038 1038
1039 RecordSolidColorPredictorResults( 1039 RecordSolidColorPredictorResults(
1040 reinterpret_cast<SkColor*>(bitmap.getPixels()), 1040 reinterpret_cast<SkColor*>(bitmap.getPixels()),
1041 bitmap.getSize() / bitmap.bytesPerPixel(), 1041 bitmap.getSize() / bitmap.bytesPerPixel(),
1042 analysis.is_solid_color, 1042 analysis.is_solid_color,
1043 analysis.solid_color, 1043 analysis.solid_color,
1044 analysis.is_transparent); 1044 analysis.is_transparent);
1045 } 1045 }
1046 } 1046 }
1047 } 1047 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 skia::LazyPixelRef* pixel_ref, 1115 skia::LazyPixelRef* pixel_ref,
1116 RenderingStatsInstrumentation* stats_instrumentation) { 1116 RenderingStatsInstrumentation* stats_instrumentation) {
1117 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask"); 1117 TRACE_EVENT0("cc", "TileManager::RunImageDecodeTask");
1118 base::TimeTicks start_time = stats_instrumentation->StartRecording(); 1118 base::TimeTicks start_time = stats_instrumentation->StartRecording();
1119 pixel_ref->Decode(); 1119 pixel_ref->Decode();
1120 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time); 1120 base::TimeDelta duration = stats_instrumentation->EndRecording(start_time);
1121 stats_instrumentation->AddDeferredImageDecode(duration); 1121 stats_instrumentation->AddDeferredImageDecode(duration);
1122 } 1122 }
1123 1123
1124 } // namespace cc 1124 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/scoped_resource_unittest.cc ('k') | cc/scheduler/frame_rate_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698