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_TILE_MANAGER_H_ | 5 #ifndef CC_RESOURCES_TILE_MANAGER_H_ |
6 #define CC_RESOURCES_TILE_MANAGER_H_ | 6 #define CC_RESOURCES_TILE_MANAGER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "cc/base/ref_counted_managed.h" | 17 #include "cc/base/ref_counted_managed.h" |
18 #include "cc/base/unique_notifier.h" | 18 #include "cc/base/unique_notifier.h" |
19 #include "cc/debug/rendering_stats_instrumentation.h" | 19 #include "cc/debug/rendering_stats_instrumentation.h" |
20 #include "cc/resources/eviction_tile_priority_queue.h" | 20 #include "cc/resources/eviction_tile_priority_queue.h" |
21 #include "cc/resources/managed_tile_state.h" | 21 #include "cc/resources/managed_tile_state.h" |
22 #include "cc/resources/memory_history.h" | 22 #include "cc/resources/memory_history.h" |
23 #include "cc/resources/picture_pile_impl.h" | 23 #include "cc/resources/picture_pile_impl.h" |
24 #include "cc/resources/prioritized_tile_set.h" | 24 #include "cc/resources/prioritized_tile_set.h" |
25 #include "cc/resources/raster_tile_priority_queue.h" | 25 #include "cc/resources/raster_tile_priority_queue.h" |
26 #include "cc/resources/rasterizer.h" | 26 #include "cc/resources/rasterizer.h" |
27 #include "cc/resources/resource_pool.h" | 27 #include "cc/resources/resource_pool.h" |
28 #include "cc/resources/tile.h" | 28 #include "cc/resources/tile.h" |
29 | 29 |
30 namespace base { | |
31 namespace debug { | |
32 class ConvertableToTraceFormat; | |
33 class TracedValue; | |
34 } | |
35 } | |
36 | |
37 namespace cc { | 30 namespace cc { |
38 class PictureLayerImpl; | 31 class PictureLayerImpl; |
39 class ResourceProvider; | 32 class ResourceProvider; |
40 | 33 |
41 class CC_EXPORT TileManagerClient { | 34 class CC_EXPORT TileManagerClient { |
42 public: | 35 public: |
43 // Returns the set of layers that the tile manager should consider for raster. | 36 // Returns the set of layers that the tile manager should consider for raster. |
44 // TODO(vmpstr): Change the way we determine if we are ready to activate, so | 37 // TODO(vmpstr): Change the way we determine if we are ready to activate, so |
45 // that this can be removed. | 38 // that this can be removed. |
46 virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() const = 0; | 39 virtual const std::vector<PictureLayerImpl*>& GetPictureLayers() const = 0; |
(...skipping 23 matching lines...) Expand all Loading... |
70 protected: | 63 protected: |
71 virtual ~TileManagerClient() {} | 64 virtual ~TileManagerClient() {} |
72 }; | 65 }; |
73 | 66 |
74 struct RasterTaskCompletionStats { | 67 struct RasterTaskCompletionStats { |
75 RasterTaskCompletionStats(); | 68 RasterTaskCompletionStats(); |
76 | 69 |
77 size_t completed_count; | 70 size_t completed_count; |
78 size_t canceled_count; | 71 size_t canceled_count; |
79 }; | 72 }; |
80 scoped_refptr<base::debug::ConvertableToTraceFormat> | 73 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( |
81 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); | 74 const RasterTaskCompletionStats& stats); |
82 | 75 |
83 // This class manages tiles, deciding which should get rasterized and which | 76 // This class manages tiles, deciding which should get rasterized and which |
84 // should no longer have any memory assigned to them. Tile objects are "owned" | 77 // should no longer have any memory assigned to them. Tile objects are "owned" |
85 // by layers; they automatically register with the manager when they are | 78 // by layers; they automatically register with the manager when they are |
86 // created, and unregister from the manager when they are deleted. | 79 // created, and unregister from the manager when they are deleted. |
87 class CC_EXPORT TileManager : public RasterizerClient, | 80 class CC_EXPORT TileManager : public RasterizerClient, |
88 public RefCountedManager<Tile> { | 81 public RefCountedManager<Tile> { |
89 public: | 82 public: |
90 static scoped_ptr<TileManager> Create( | 83 static scoped_ptr<TileManager> Create( |
91 TileManagerClient* client, | 84 TileManagerClient* client, |
(...skipping 10 matching lines...) Expand all Loading... |
102 | 95 |
103 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, | 96 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, |
104 const gfx::Size& tile_size, | 97 const gfx::Size& tile_size, |
105 const gfx::Rect& content_rect, | 98 const gfx::Rect& content_rect, |
106 const gfx::Rect& opaque_rect, | 99 const gfx::Rect& opaque_rect, |
107 float contents_scale, | 100 float contents_scale, |
108 int layer_id, | 101 int layer_id, |
109 int source_frame_number, | 102 int source_frame_number, |
110 int flags); | 103 int flags); |
111 | 104 |
112 scoped_refptr<base::debug::ConvertableToTraceFormat> BasicStateAsValue() | 105 scoped_ptr<base::Value> BasicStateAsValue() const; |
113 const; | 106 scoped_ptr<base::Value> AllTilesAsValue() const; |
114 void BasicStateAsValueInto(base::debug::TracedValue* dict) const; | |
115 void AllTilesAsValueInto(base::debug::TracedValue* array) const; | |
116 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 107 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
117 return memory_stats_from_last_assign_; | 108 return memory_stats_from_last_assign_; |
118 } | 109 } |
119 | 110 |
120 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 111 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
121 for (size_t i = 0; i < tiles.size(); ++i) { | 112 for (size_t i = 0; i < tiles.size(); ++i) { |
122 ManagedTileState& mts = tiles[i]->managed_state(); | 113 ManagedTileState& mts = tiles[i]->managed_state(); |
123 ManagedTileState::TileVersion& tile_version = | 114 ManagedTileState::TileVersion& tile_version = |
124 mts.tile_versions[HIGH_QUALITY_RASTER_MODE]; | 115 mts.tile_versions[HIGH_QUALITY_RASTER_MODE]; |
125 | 116 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; | 249 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; |
259 | 250 |
260 UniqueNotifier ready_to_activate_check_notifier_; | 251 UniqueNotifier ready_to_activate_check_notifier_; |
261 | 252 |
262 DISALLOW_COPY_AND_ASSIGN(TileManager); | 253 DISALLOW_COPY_AND_ASSIGN(TileManager); |
263 }; | 254 }; |
264 | 255 |
265 } // namespace cc | 256 } // namespace cc |
266 | 257 |
267 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 258 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |