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

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

Issue 26880010: gfx: Add FrameTime and DisplayTime classes (Closed) Base URL: http://git.chromium.org/chromium/src.git@checkHighResNow4
Patch Set: WIP Created 7 years, 1 month 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
« no previous file with comments | « cc/resources/resource_update_controller.h ('k') | cc/scheduler/frame_rate_controller.h » ('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/resource_update_controller.h" 5 #include "cc/resources/resource_update_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "cc/resources/prioritized_resource.h" 10 #include "cc/resources/prioritized_resource.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 resource_provider_(resource_provider), 49 resource_provider_(resource_provider),
50 texture_updates_per_tick_(MaxFullUpdatesPerTick(resource_provider)), 50 texture_updates_per_tick_(MaxFullUpdatesPerTick(resource_provider)),
51 first_update_attempt_(true), 51 first_update_attempt_(true),
52 task_runner_(task_runner), 52 task_runner_(task_runner),
53 task_posted_(false), 53 task_posted_(false),
54 weak_factory_(this) {} 54 weak_factory_(this) {}
55 55
56 ResourceUpdateController::~ResourceUpdateController() {} 56 ResourceUpdateController::~ResourceUpdateController() {}
57 57
58 void ResourceUpdateController::PerformMoreUpdates( 58 void ResourceUpdateController::PerformMoreUpdates(
59 base::TimeTicks time_limit) { 59 gfx::FrameTime time_limit) {
60 time_limit_ = time_limit; 60 time_limit_ = time_limit;
61 61
62 // Update already in progress. 62 // Update already in progress.
63 if (task_posted_) 63 if (task_posted_)
64 return; 64 return;
65 65
66 // Call UpdateMoreTexturesNow() directly unless it's the first update 66 // Call UpdateMoreTexturesNow() directly unless it's the first update
67 // attempt. This ensures that we empty the update queue in a finite 67 // attempt. This ensures that we empty the update queue in a finite
68 // amount of time. 68 // amount of time.
69 if (!first_update_attempt_) 69 if (!first_update_attempt_)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 resource_provider_->FlushUploads(); 107 resource_provider_->FlushUploads();
108 } 108 }
109 109
110 void ResourceUpdateController::OnTimerFired() { 110 void ResourceUpdateController::OnTimerFired() {
111 task_posted_ = false; 111 task_posted_ = false;
112 if (!UpdateMoreTexturesIfEnoughTimeRemaining()) 112 if (!UpdateMoreTexturesIfEnoughTimeRemaining())
113 client_->ReadyToFinalizeTextureUpdates(); 113 client_->ReadyToFinalizeTextureUpdates();
114 } 114 }
115 115
116 base::TimeTicks ResourceUpdateController::Now() const { 116 gfx::FrameTime ResourceUpdateController::Now() const {
117 return gfx::FrameTime::Now(); 117 return gfx::FrameTime::Now();
118 } 118 }
119 119
120 base::TimeDelta ResourceUpdateController::UpdateMoreTexturesTime() const { 120 base::TimeDelta ResourceUpdateController::UpdateMoreTexturesTime() const {
121 return resource_provider_->TextureUpdateTickRate(); 121 return resource_provider_->TextureUpdateTickRate();
122 } 122 }
123 123
124 size_t ResourceUpdateController::UpdateMoreTexturesSize() const { 124 size_t ResourceUpdateController::UpdateMoreTexturesSize() const {
125 return texture_updates_per_tick_; 125 return texture_updates_per_tick_;
126 } 126 }
127 127
128 size_t ResourceUpdateController::MaxBlockingUpdates() const { 128 size_t ResourceUpdateController::MaxBlockingUpdates() const {
129 return UpdateMoreTexturesSize() * kMaxBlockingUpdateIntervals; 129 return UpdateMoreTexturesSize() * kMaxBlockingUpdateIntervals;
130 } 130 }
131 131
132 base::TimeDelta ResourceUpdateController::PendingUpdateTime() const { 132 base::TimeDelta ResourceUpdateController::PendingUpdateTime() const {
133 base::TimeDelta update_one_resource_time = 133 base::TimeDelta update_one_resource_time =
134 UpdateMoreTexturesTime() / UpdateMoreTexturesSize(); 134 UpdateMoreTexturesTime() / UpdateMoreTexturesSize();
135 return update_one_resource_time * resource_provider_->NumBlockingUploads(); 135 return update_one_resource_time * resource_provider_->NumBlockingUploads();
136 } 136 }
137 137
138 bool ResourceUpdateController::UpdateMoreTexturesIfEnoughTimeRemaining() { 138 bool ResourceUpdateController::UpdateMoreTexturesIfEnoughTimeRemaining() {
139 while (resource_provider_->NumBlockingUploads() < MaxBlockingUpdates()) { 139 while (resource_provider_->NumBlockingUploads() < MaxBlockingUpdates()) {
140 if (!queue_->FullUploadSize()) 140 if (!queue_->FullUploadSize())
141 return false; 141 return false;
142 142
143 if (!time_limit_.is_null()) { 143 if (!time_limit_.is_null()) {
144 // Estimated completion time of all pending updates. 144 // Estimated completion time of all pending updates.
145 base::TimeTicks completion_time = Now() + PendingUpdateTime(); 145 gfx::FrameTime completion_time =
146 Now() + PendingUpdateTime();
146 147
147 // Time remaining based on current completion estimate. 148 // Time remaining based on current completion estimate.
148 base::TimeDelta time_remaining = time_limit_ - completion_time; 149 base::TimeDelta time_remaining = time_limit_ - completion_time;
149 150
150 if (time_remaining < UpdateMoreTexturesTime()) 151 if (time_remaining < UpdateMoreTexturesTime())
151 return true; 152 return true;
152 } 153 }
153 154
154 UpdateMoreTexturesNow(); 155 UpdateMoreTexturesNow();
155 } 156 }
(...skipping 14 matching lines...) Expand all
170 if (!uploads) 171 if (!uploads)
171 return; 172 return;
172 173
173 while (queue_->FullUploadSize() && uploads--) 174 while (queue_->FullUploadSize() && uploads--)
174 UpdateTexture(queue_->TakeFirstFullUpload()); 175 UpdateTexture(queue_->TakeFirstFullUpload());
175 176
176 resource_provider_->FlushUploads(); 177 resource_provider_->FlushUploads();
177 } 178 }
178 179
179 } // namespace cc 180 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_update_controller.h ('k') | cc/scheduler/frame_rate_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698