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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "cc/resource_pool.h" | 12 #include "cc/resource_pool.h" |
13 #include "cc/tile_priority.h" | 13 #include "cc/tile_priority.h" |
14 | 14 |
15 #if defined(COMPILER_GCC) | |
16 namespace BASE_HASH_NAMESPACE { | |
17 template<> | |
18 struct hash<SkPixelRef*> { | |
nduca
2012/12/06 08:46:53
Can we make SkLazyPixelRef have an id() field on i
qinmin
2012/12/07 05:06:28
SkPixelRef has getGenerationId() call. But the rev
| |
19 size_t operator()(SkPixelRef* ptr) const { | |
20 return hash<size_t>()(reinterpret_cast<size_t>(ptr)); | |
21 } | |
22 }; | |
23 } // namespace BASE_HASH_NAMESPACE | |
24 #endif // COMPILER_GCC | |
25 | |
15 namespace base { | 26 namespace base { |
16 class SequencedWorkerPool; | 27 class SequencedWorkerPool; |
17 } | 28 } |
18 | 29 |
19 namespace cc { | 30 namespace cc { |
20 | 31 |
32 class Image; | |
21 class Tile; | 33 class Tile; |
22 class TileVersion; | 34 class TileVersion; |
23 struct RenderingStats; | 35 struct RenderingStats; |
24 class ResourceProvider; | 36 class ResourceProvider; |
25 | 37 |
26 class CC_EXPORT TileManagerClient { | 38 class CC_EXPORT TileManagerClient { |
27 public: | 39 public: |
28 virtual void ScheduleManageTiles() = 0; | 40 virtual void ScheduleManageTiles() = 0; |
29 virtual void ScheduleRedraw() = 0; | 41 virtual void ScheduleRedraw() = 0; |
30 | 42 |
31 protected: | 43 protected: |
32 virtual ~TileManagerClient() {} | 44 virtual ~TileManagerClient() {} |
33 }; | 45 }; |
34 | 46 |
35 // Tile manager classifying tiles into a few basic | 47 // Tile manager classifying tiles into a few basic |
36 // bins: | 48 // bins: |
37 enum TileManagerBin { | 49 enum TileManagerBin { |
38 NOW_BIN = 0, // Needed ASAP. | 50 NOW_BIN = 0, // Needed ASAP. |
39 SOON_BIN = 1, // Impl-side version of prepainting. | 51 SOON_BIN = 1, // Impl-side version of prepainting. |
40 EVENTUALLY_BIN = 2, // Nice to have, if we've got memory and time. | 52 EVENTUALLY_BIN = 2, // Nice to have, if we've got memory and time. |
41 NEVER_BIN = 3, // Dont bother. | 53 NEVER_BIN = 3, // Dont bother. |
42 NUM_BINS = 4 | 54 NUM_BINS = 4 |
43 }; | 55 }; |
44 | 56 |
57 // Current progress of image decoding jobs. | |
58 enum ImageDecodingProgress { | |
59 NOT_STARTED = 0, | |
60 IN_PROGRESS = 1, | |
61 FINISHED = 2 | |
62 }; | |
63 | |
45 // This is state that is specific to a tile that is | 64 // This is state that is specific to a tile that is |
46 // managed by the TileManager. | 65 // managed by the TileManager. |
47 class CC_EXPORT ManagedTileState { | 66 class CC_EXPORT ManagedTileState { |
48 public: | 67 public: |
49 ManagedTileState(); | 68 ManagedTileState(); |
50 ~ManagedTileState(); | 69 ~ManagedTileState(); |
51 | 70 |
52 // Persisted state: valid all the time. | 71 // Persisted state: valid all the time. |
53 bool can_use_gpu_memory; | 72 bool can_use_gpu_memory; |
54 bool can_be_freed; | 73 bool can_be_freed; |
55 ResourceProvider::ResourceId resource_id; | 74 ResourceProvider::ResourceId resource_id; |
56 bool resource_id_is_being_initialized; | 75 bool resource_id_is_being_initialized; |
57 bool contents_swizzled; | 76 bool contents_swizzled; |
58 | 77 |
59 // Ephemeral state, valid only during Manage. | 78 // Ephemeral state, valid only during Manage. |
60 TileManagerBin bin; | 79 TileManagerBin bin; |
61 TileResolution resolution; | 80 TileResolution resolution; |
62 float time_to_needed_in_seconds; | 81 float time_to_needed_in_seconds; |
82 std::vector<SkPixelRef*> pixel_refs; | |
nduca
2012/12/06 08:46:53
hmm.... isn't it sufficient to track num_pending_d
qinmin
2012/12/07 05:06:28
Then we need a map in TileManager to map from skpi
| |
63 }; | 83 }; |
64 | 84 |
65 // This class manages tiles, deciding which should get rasterized and which | 85 // This class manages tiles, deciding which should get rasterized and which |
66 // should no longer have any memory assigned to them. Tile objects are "owned" | 86 // should no longer have any memory assigned to them. Tile objects are "owned" |
67 // by layers; they automatically register with the manager when they are | 87 // by layers; they automatically register with the manager when they are |
68 // created, and unregister from the manager when they are deleted. | 88 // created, and unregister from the manager when they are deleted. |
69 class CC_EXPORT TileManager { | 89 class CC_EXPORT TileManager { |
70 public: | 90 public: |
71 TileManager(TileManagerClient* client, ResourceProvider *resource_provider); | 91 TileManager(TileManagerClient* client, ResourceProvider *resource_provider); |
72 virtual ~TileManager(); | 92 virtual ~TileManager(); |
(...skipping 17 matching lines...) Expand all Loading... | |
90 void FreeResourcesForTile(Tile*); | 110 void FreeResourcesForTile(Tile*); |
91 void ScheduleManageTiles(); | 111 void ScheduleManageTiles(); |
92 void DispatchMoreRasterTasks(); | 112 void DispatchMoreRasterTasks(); |
93 void DispatchOneRasterTask(scoped_refptr<Tile>); | 113 void DispatchOneRasterTask(scoped_refptr<Tile>); |
94 void OnRasterTaskCompleted( | 114 void OnRasterTaskCompleted( |
95 scoped_refptr<Tile>, | 115 scoped_refptr<Tile>, |
96 ResourceProvider::ResourceId, | 116 ResourceProvider::ResourceId, |
97 scoped_refptr<PicturePileImpl>, | 117 scoped_refptr<PicturePileImpl>, |
98 RenderingStats*); | 118 RenderingStats*); |
99 void DidFinishTileInitialization(Tile*, ResourceProvider::ResourceId); | 119 void DidFinishTileInitialization(Tile*, ResourceProvider::ResourceId); |
120 bool HasUndecodedImages(Tile*, std::vector<SkPixelRef*>&); | |
Alpha Left Google
2012/12/05 20:24:28
This seems to be called over and over again, does
qinmin
2012/12/07 05:06:28
No, this just check if the tile has undecoded imag
| |
121 void OnImageDecoded(scoped_refptr<Image> image); | |
122 void SpawnImageDecodingTask(SkPixelRef*); | |
reveman
2012/12/05 19:48:46
Maybe DispatchOneImageDecodingTask/OnImageDecoding
qinmin
2012/12/07 05:06:28
Done.
| |
100 | 123 |
101 TileManagerClient* client_; | 124 TileManagerClient* client_; |
102 scoped_ptr<ResourcePool> resource_pool_; | 125 scoped_ptr<ResourcePool> resource_pool_; |
103 bool manage_tiles_pending_; | 126 bool manage_tiles_pending_; |
104 int pending_raster_tasks_; | 127 int pending_raster_tasks_; |
105 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | 128 scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
106 | 129 |
107 GlobalStateThatImpactsTilePriority global_state_; | 130 GlobalStateThatImpactsTilePriority global_state_; |
108 | 131 |
109 typedef std::vector<Tile*> TileVector; | 132 typedef std::vector<Tile*> TileVector; |
110 TileVector tiles_; | 133 TileVector tiles_; |
111 TileVector tiles_that_need_to_be_rasterized_; | 134 TileVector tiles_that_need_to_be_rasterized_; |
112 | 135 |
136 typedef base::hash_map<uint32_t, scoped_refptr<Tile> > TileMap; | |
reveman
2012/12/05 19:48:46
where is TileMap used?
qinmin
2012/12/07 05:06:28
This is originally wrote to map SkPixelRef* to til
| |
137 | |
138 typedef base::hash_map<SkPixelRef*, ImageDecodingProgress> | |
139 PixelRefDecodingProgress; | |
140 PixelRefDecodingProgress decoding_progress_; | |
nduca
2012/12/06 08:46:53
All you need is IsDecodeTaskPending. Finished is n
qinmin
2012/12/07 05:06:28
changed it to pending_decode_tasks_ hashmap here.
| |
141 | |
113 RenderingStats rendering_stats_; | 142 RenderingStats rendering_stats_; |
114 }; | 143 }; |
115 | 144 |
116 } // namespace cc | 145 } // namespace cc |
117 | 146 |
118 #endif // CC_TILE_MANAGER_H_ | 147 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |