| Index: cc/resource_update_controller.cc
|
| diff --git a/cc/resource_update_controller.cc b/cc/resource_update_controller.cc
|
| index 498f884290fd4c5117507f10264074366ad751cf..b3133c9846885a2730f743c5b616e39d810482c5 100644
|
| --- a/cc/resource_update_controller.cc
|
| +++ b/cc/resource_update_controller.cc
|
| @@ -11,6 +11,7 @@
|
| #include "cc/proxy.h"
|
| #include "cc/resource_provider.h"
|
| #include "cc/texture_copier.h"
|
| +#include "cc/thread.h"
|
| #include "third_party/khronos/GLES2/gl2.h"
|
| #include "third_party/skia/include/gpu/SkGpuDevice.h"
|
| #include <limits>
|
| @@ -71,11 +72,13 @@ size_t ResourceUpdateController::maxFullUpdatesPerTick(
|
|
|
| ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClient* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvider* resourceProvider)
|
| : m_client(client)
|
| - , m_timer(new Timer(thread, this))
|
| , m_queue(queue.Pass())
|
| , m_resourceProvider(resourceProvider)
|
| , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider))
|
| , m_firstUpdateAttempt(true)
|
| + , m_thread(thread)
|
| + , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this))
|
| + , m_taskPosted(false)
|
| {
|
| }
|
|
|
| @@ -89,7 +92,7 @@ void ResourceUpdateController::performMoreUpdates(
|
| m_timeLimit = timeLimit;
|
|
|
| // Update already in progress.
|
| - if (m_timer->isActive())
|
| + if (m_taskPosted)
|
| return;
|
|
|
| // Call updateMoreTexturesNow() directly unless it's the first update
|
| @@ -98,8 +101,11 @@ void ResourceUpdateController::performMoreUpdates(
|
| if (m_firstUpdateAttempt) {
|
| // Post a 0-delay task when no updates were left. When it runs,
|
| // readyToFinalizeTextureUpdates() will be called.
|
| - if (!updateMoreTexturesIfEnoughTimeRemaining())
|
| - m_timer->startOneShot(0);
|
| + if (!updateMoreTexturesIfEnoughTimeRemaining()) {
|
| + m_taskPosted = true;
|
| + m_thread->postTask(base::Bind(&ResourceUpdateController::onTimerFired,
|
| + m_weakFactory.GetWeakPtr()));
|
| + }
|
|
|
| m_firstUpdateAttempt = false;
|
| } else
|
| @@ -222,6 +228,7 @@ void ResourceUpdateController::finalize()
|
|
|
| void ResourceUpdateController::onTimerFired()
|
| {
|
| + m_taskPosted = false;
|
| ResourceProvider::debugNotifyEnterZone(0xB000000);
|
| if (!updateMoreTexturesIfEnoughTimeRemaining())
|
| m_client->readyToFinalizeTextureUpdates();
|
| @@ -254,7 +261,10 @@ bool ResourceUpdateController::updateMoreTexturesIfEnoughTimeRemaining()
|
| // time estimate. We use a different timeout here to prevent unnecessary
|
| // amounts of idle time when blocking uploads have reached the max.
|
| if (m_resourceProvider->numBlockingUploads() >= maxBlockingUpdates()) {
|
| - m_timer->startOneShot(uploaderBusyTickRate);
|
| + m_taskPosted = true;
|
| + m_thread->postDelayedTask(base::Bind(&ResourceUpdateController::onTimerFired,
|
| + m_weakFactory.GetWeakPtr()),
|
| + uploaderBusyTickRate * 1000);
|
| return true;
|
| }
|
|
|
| @@ -273,9 +283,10 @@ void ResourceUpdateController::updateMoreTexturesNow()
|
| {
|
| size_t uploads = std::min(
|
| m_queue->fullUploadSize(), updateMoreTexturesSize());
|
| - m_timer->startOneShot(
|
| - updateMoreTexturesTime().InSecondsF() / updateMoreTexturesSize() *
|
| - uploads);
|
| + m_taskPosted = true;
|
| + m_thread->postDelayedTask(base::Bind(&ResourceUpdateController::onTimerFired,
|
| + m_weakFactory.GetWeakPtr()),
|
| + updateMoreTexturesTime().InSecondsF() / updateMoreTexturesSize() * uploads * 1000);
|
|
|
| if (!uploads)
|
| return;
|
|
|