diff options
author | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 20:52:19 +0000 |
---|---|---|
committer | reveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-02 20:52:19 +0000 |
commit | 13044fe74b3d04972fe95e62602cbf3bf4644651 (patch) | |
tree | fd645bc798f6f37ce303e80a7966222f71e82735 /cc/resources/resource_update_controller.cc | |
parent | 2a0bda87c855c157269ff40ff5c580e16b5a250e (diff) | |
download | chromium_src-13044fe74b3d04972fe95e62602cbf3bf4644651.zip chromium_src-13044fe74b3d04972fe95e62602cbf3bf4644651.tar.gz chromium_src-13044fe74b3d04972fe95e62602cbf3bf4644651.tar.bz2 |
cc: Prevent ResourceUpdateContoller from uploading textures after lost context
If the context was lost in the middle of the ResourceUpdateController
uploading textures, it would previously continue uploading textures.
ResourceUpdateController now stops uploading immediately and notifies
its client that the uploads have completed, which will allow the
commit to complete.
The LayerTreeHostContextTestLostContextWhileUpdatingResources unit
test now relys on the first draw to trigger the end of the test.
Relying on the first commit to end the test was incorrect before
this patch and would be incorrect after this patch, since losing the
context doesn't prevent the commit from finishing. Previously, the
end of the test was racing with the expected number of times the
context would be lost.
In order to rely on the first draw to end the test, SingleThreadProxy
now checks for lost context before drawing.
BUG=313790
TBR=danakj
Review URL: https://codereview.chromium.org/99553002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238178 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/resources/resource_update_controller.cc')
-rw-r--r-- | cc/resources/resource_update_controller.cc | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/cc/resources/resource_update_controller.cc b/cc/resources/resource_update_controller.cc index 59c536b..8681335 100644 --- a/cc/resources/resource_update_controller.cc +++ b/cc/resources/resource_update_controller.cc @@ -32,11 +32,7 @@ size_t ResourceUpdateController::MaxPartialTextureUpdates() { size_t ResourceUpdateController::MaxFullUpdatesPerTick( ResourceProvider* resource_provider) { - double textures_per_second = resource_provider->EstimatedUploadsPerSecond(); - size_t textures_per_tick = - floor(resource_provider->TextureUpdateTickRate().InSecondsF() * - textures_per_second); - return textures_per_tick ? textures_per_tick : 1; + return resource_provider->EstimatedUploadsPerTick(); } ResourceUpdateController::ResourceUpdateController( @@ -113,12 +109,9 @@ void ResourceUpdateController::OnTimerFired() { client_->ReadyToFinalizeTextureUpdates(); } -base::TimeTicks ResourceUpdateController::Now() const { - return gfx::FrameTime::Now(); -} - -base::TimeDelta ResourceUpdateController::UpdateMoreTexturesTime() const { - return resource_provider_->TextureUpdateTickRate(); +base::TimeTicks ResourceUpdateController::UpdateMoreTexturesCompletionTime() { + return resource_provider_->EstimatedUploadCompletionTime( + texture_updates_per_tick_); } size_t ResourceUpdateController::UpdateMoreTexturesSize() const { @@ -129,25 +122,14 @@ size_t ResourceUpdateController::MaxBlockingUpdates() const { return UpdateMoreTexturesSize() * kMaxBlockingUpdateIntervals; } -base::TimeDelta ResourceUpdateController::PendingUpdateTime() const { - base::TimeDelta update_one_resource_time = - UpdateMoreTexturesTime() / UpdateMoreTexturesSize(); - return update_one_resource_time * resource_provider_->NumBlockingUploads(); -} - bool ResourceUpdateController::UpdateMoreTexturesIfEnoughTimeRemaining() { while (resource_provider_->NumBlockingUploads() < MaxBlockingUpdates()) { if (!queue_->FullUploadSize()) return false; if (!time_limit_.is_null()) { - // Estimated completion time of all pending updates. - base::TimeTicks completion_time = Now() + PendingUpdateTime(); - - // Time remaining based on current completion estimate. - base::TimeDelta time_remaining = time_limit_ - completion_time; - - if (time_remaining < UpdateMoreTexturesTime()) + base::TimeTicks completion_time = UpdateMoreTexturesCompletionTime(); + if (completion_time > time_limit_) return true; } |