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