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_TILE_MANAGER_H_ | 5 #ifndef CC_TILE_MANAGER_H_ |
6 #define CC_TILE_MANAGER_H_ | 6 #define CC_TILE_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "cc/layer_tree_host_impl.h" |
11 #include "cc/tile_priority.h" | 12 #include "cc/tile_priority.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 | 15 |
15 class Tile; | 16 class Tile; |
16 class TileVersion; | 17 class TileVersion; |
17 class ResourceProvider; | 18 class ResourceProvider; |
18 | 19 |
19 class TileManagerClient { | 20 class TileManagerClient { |
20 public: | 21 public: |
21 virtual void ScheduleManageTiles() = 0; | 22 virtual void ScheduleManageTiles() = 0; |
22 | 23 |
23 protected: | 24 protected: |
24 virtual ~TileManagerClient() {} | 25 virtual ~TileManagerClient() {} |
25 }; | 26 }; |
26 | 27 |
| 28 // Tile manager classifying tiles into a few basic |
| 29 // bins: |
| 30 enum TileManagerBin { |
| 31 NOW_BIN = 0, // Needed ASAP. |
| 32 SOON_BIN = 1, // Impl-side version of prepainting. |
| 33 EVENTUALLY_BIN = 2, // Nice to have, if we've got memory and time. |
| 34 NEVER_BIN = 3, // Dont bother. |
| 35 NUM_BINS = 4 |
| 36 }; |
| 37 |
| 38 // This is state that is specific to a tile that is |
| 39 // managed by the TileManager. |
| 40 class ManagedTileState { |
| 41 public: |
| 42 ManagedTileState() |
| 43 : can_use_gpu_memory(false) |
| 44 , resource_id(0) |
| 45 , resource_id_can_be_freed(0) {} |
| 46 |
| 47 // Persisted state: valid all the time. |
| 48 bool can_use_gpu_memory; |
| 49 ResourceProvider::ResourceId resource_id; |
| 50 bool resource_id_can_be_freed; |
| 51 |
| 52 // Ephemeral state, valid only during Manage. |
| 53 TileManagerBin bin; |
| 54 TileResolution resolution; |
| 55 float time_to_needed_in_seconds; |
| 56 }; |
| 57 |
27 // This class manages tiles, deciding which should get rasterized and which | 58 // This class manages tiles, deciding which should get rasterized and which |
28 // should no longer have any memory assigned to them. Tile objects are "owned" | 59 // should no longer have any memory assigned to them. Tile objects are "owned" |
29 // by layers; they automatically register with the manager when they are | 60 // by layers; they automatically register with the manager when they are |
30 // created, and unregister from the manager when they are deleted. | 61 // created, and unregister from the manager when they are deleted. |
31 class TileManager { | 62 class TileManager { |
32 public: | 63 public: |
33 TileManager(TileManagerClient* client); | 64 TileManager(TileManagerClient* client); |
34 ~TileManager(); | 65 ~TileManager(); |
35 | 66 |
36 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 67 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
37 void ManageTiles(); | 68 void ManageTiles(); |
38 | 69 |
39 protected: | 70 protected: |
40 // Methods called by Tile | 71 // Methods called by Tile |
41 void DidCreateTileVersion(TileVersion*); | 72 friend class Tile; |
42 void WillModifyTileVersionPriority(TileVersion*, const TilePriority& new_prior
ity); | 73 void RegisterTile(Tile*); |
43 void DidDeleteTileVersion(TileVersion*); | 74 void UnregisterTile(Tile*); |
| 75 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); |
44 | 76 |
45 private: | 77 private: |
46 friend class Tile; | 78 void FreeResourcesForTile(Tile*); |
47 void ScheduleManageTiles(); | 79 void ScheduleManageTiles(); |
| 80 void ScheduleMorePaintingJobs(); |
48 | 81 |
49 TileManagerClient* client_; | 82 TileManagerClient* client_; |
50 bool manage_tiles_pending_; | 83 bool manage_tiles_pending_; |
51 | 84 |
52 GlobalStateThatImpactsTilePriority global_state_; | 85 GlobalStateThatImpactsTilePriority global_state_; |
53 std::vector<TileVersion*> tile_versions_; | 86 |
| 87 typedef std::vector<Tile*> TileVector; |
| 88 TileVector tiles_; |
| 89 TileVector tiles_that_need_to_be_painted_; |
54 }; | 90 }; |
55 | 91 |
56 } // namespace cc | 92 } // namespace cc |
57 | 93 |
58 #endif // CC_TILE_MANAGER_H_ | 94 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |