| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_RESOURCE_UPDATE_CONTROLLER_H_ | |
| 6 #define CC_RESOURCE_UPDATE_CONTROLLER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/time.h" | |
| 12 #include "cc/base/cc_export.h" | |
| 13 #include "cc/resource_update_queue.h" | |
| 14 | |
| 15 namespace cc { | |
| 16 | |
| 17 class ResourceProvider; | |
| 18 class Thread; | |
| 19 | |
| 20 class ResourceUpdateControllerClient { | |
| 21 public: | |
| 22 virtual void ReadyToFinalizeTextureUpdates() = 0; | |
| 23 | |
| 24 protected: | |
| 25 virtual ~ResourceUpdateControllerClient() {} | |
| 26 }; | |
| 27 | |
| 28 class CC_EXPORT ResourceUpdateController { | |
| 29 public: | |
| 30 static scoped_ptr<ResourceUpdateController> Create( | |
| 31 ResourceUpdateControllerClient* client, | |
| 32 Thread* thread, | |
| 33 scoped_ptr<ResourceUpdateQueue> queue, | |
| 34 ResourceProvider* resource_provider) { | |
| 35 return make_scoped_ptr(new ResourceUpdateController( | |
| 36 client, thread, queue.Pass(), resource_provider)); | |
| 37 } | |
| 38 static size_t MaxPartialTextureUpdates(); | |
| 39 | |
| 40 virtual ~ResourceUpdateController(); | |
| 41 | |
| 42 // Discard uploads to textures that were evicted on the impl thread. | |
| 43 void DiscardUploadsToEvictedResources(); | |
| 44 | |
| 45 void PerformMoreUpdates(base::TimeTicks time_limit); | |
| 46 void Finalize(); | |
| 47 | |
| 48 | |
| 49 // Virtual for testing. | |
| 50 virtual base::TimeTicks Now() const; | |
| 51 virtual base::TimeDelta UpdateMoreTexturesTime() const; | |
| 52 virtual size_t UpdateMoreTexturesSize() const; | |
| 53 | |
| 54 protected: | |
| 55 ResourceUpdateController(ResourceUpdateControllerClient* client, | |
| 56 Thread* thread, | |
| 57 scoped_ptr<ResourceUpdateQueue> queue, | |
| 58 ResourceProvider* resource_provider); | |
| 59 | |
| 60 private: | |
| 61 static size_t MaxFullUpdatesPerTick(ResourceProvider* resource_provider); | |
| 62 | |
| 63 size_t MaxBlockingUpdates() const; | |
| 64 base::TimeDelta PendingUpdateTime() const; | |
| 65 | |
| 66 void UpdateTexture(ResourceUpdate update); | |
| 67 | |
| 68 // This returns true when there were textures left to update. | |
| 69 bool UpdateMoreTexturesIfEnoughTimeRemaining(); | |
| 70 void UpdateMoreTexturesNow(); | |
| 71 void OnTimerFired(); | |
| 72 | |
| 73 ResourceUpdateControllerClient* client_; | |
| 74 scoped_ptr<ResourceUpdateQueue> queue_; | |
| 75 bool contents_textures_purged_; | |
| 76 ResourceProvider* resource_provider_; | |
| 77 base::TimeTicks time_limit_; | |
| 78 size_t texture_updates_per_tick_; | |
| 79 bool first_update_attempt_; | |
| 80 Thread* thread_; | |
| 81 base::WeakPtrFactory<ResourceUpdateController> weak_factory_; | |
| 82 bool task_posted_; | |
| 83 | |
| 84 DISALLOW_COPY_AND_ASSIGN(ResourceUpdateController); | |
| 85 }; | |
| 86 | |
| 87 } // namespace cc | |
| 88 | |
| 89 #endif // CC_RESOURCE_UPDATE_CONTROLLER_H_ | |
| OLD | NEW |