| 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 <queue> |    8 #include <queue> | 
|    9 #include <set> |    9 #include <set> | 
|   10 #include <vector> |   10 #include <vector> | 
|   11  |   11  | 
|   12 #include "base/containers/hash_tables.h" |   12 #include "base/containers/hash_tables.h" | 
|   13 #include "base/memory/scoped_ptr.h" |   13 #include "base/memory/scoped_ptr.h" | 
|   14 #include "base/values.h" |   14 #include "base/values.h" | 
|   15 #include "cc/base/ref_counted_managed.h" |   15 #include "cc/base/ref_counted_managed.h" | 
|   16 #include "cc/debug/rendering_stats_instrumentation.h" |   16 #include "cc/debug/rendering_stats_instrumentation.h" | 
|   17 #include "cc/resources/managed_tile_state.h" |   17 #include "cc/resources/managed_tile_state.h" | 
|   18 #include "cc/resources/memory_history.h" |   18 #include "cc/resources/memory_history.h" | 
|   19 #include "cc/resources/picture_pile_impl.h" |   19 #include "cc/resources/picture_pile_impl.h" | 
|   20 #include "cc/resources/prioritized_tile_set.h" |   20 #include "cc/resources/prioritized_tile_set.h" | 
|   21 #include "cc/resources/raster_worker_pool.h" |   21 #include "cc/resources/raster_worker_pool.h" | 
|   22 #include "cc/resources/resource_pool.h" |   22 #include "cc/resources/resource_pool.h" | 
|   23 #include "cc/resources/tile.h" |   23 #include "cc/resources/tile.h" | 
 |   24 #include "cc/resources/tile_bundle.h" | 
|   24  |   25  | 
|   25 namespace cc { |   26 namespace cc { | 
|   26 class ResourceProvider; |   27 class ResourceProvider; | 
|   27  |   28  | 
|   28 class CC_EXPORT TileManagerClient { |   29 class CC_EXPORT TileManagerClient { | 
|   29  public: |   30  public: | 
|   30   virtual void NotifyReadyToActivate() = 0; |   31   virtual void NotifyReadyToActivate() = 0; | 
|   31  |   32  | 
|   32  protected: |   33  protected: | 
|   33   virtual ~TileManagerClient() {} |   34   virtual ~TileManagerClient() {} | 
|   34 }; |   35 }; | 
|   35  |   36  | 
|   36 struct RasterTaskCompletionStats { |   37 struct RasterTaskCompletionStats { | 
|   37   RasterTaskCompletionStats(); |   38   RasterTaskCompletionStats(); | 
|   38  |   39  | 
|   39   size_t completed_count; |   40   size_t completed_count; | 
|   40   size_t canceled_count; |   41   size_t canceled_count; | 
|   41 }; |   42 }; | 
|   42 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( |   43 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( | 
|   43     const RasterTaskCompletionStats& stats); |   44     const RasterTaskCompletionStats& stats); | 
|   44  |   45  | 
|   45 // This class manages tiles, deciding which should get rasterized and which |   46 // This class manages tiles, deciding which should get rasterized and which | 
|   46 // should no longer have any memory assigned to them. Tile objects are "owned" |   47 // should no longer have any memory assigned to them. Tile objects are "owned" | 
|   47 // by layers; they automatically register with the manager when they are |   48 // by layers; they automatically register with the manager when they are | 
|   48 // created, and unregister from the manager when they are deleted. |   49 // created, and unregister from the manager when they are deleted. | 
|   49 class CC_EXPORT TileManager : public RasterWorkerPoolClient, |   50 class CC_EXPORT TileManager : public RasterWorkerPoolClient, | 
|   50                               public RefCountedManager<Tile> { |   51                               public RefCountedManager<Tile>, | 
 |   52                               public RefCountedManager<TileBundle> { | 
|   51  public: |   53  public: | 
|   52   static scoped_ptr<TileManager> Create( |   54   static scoped_ptr<TileManager> Create( | 
|   53       TileManagerClient* client, |   55       TileManagerClient* client, | 
|   54       ResourceProvider* resource_provider, |   56       ResourceProvider* resource_provider, | 
|   55       size_t num_raster_threads, |   57       size_t num_raster_threads, | 
|   56       RenderingStatsInstrumentation* rendering_stats_instrumentation, |   58       RenderingStatsInstrumentation* rendering_stats_instrumentation, | 
|   57       bool use_map_image, |   59       bool use_map_image, | 
|   58       size_t max_transfer_buffer_usage_bytes, |   60       size_t max_transfer_buffer_usage_bytes, | 
|   59       size_t max_raster_usage_bytes, |   61       size_t max_raster_usage_bytes, | 
|   60       GLenum map_image_texture_target); |   62       GLenum map_image_texture_target); | 
|   61   virtual ~TileManager(); |   63   virtual ~TileManager(); | 
|   62  |   64  | 
|   63   void ManageTiles(const GlobalStateThatImpactsTilePriority& state); |   65   void ManageTiles(const GlobalStateThatImpactsTilePriority& state); | 
|   64  |   66  | 
|   65   // Returns true when visible tiles have been initialized. |   67   // Returns true when visible tiles have been initialized. | 
|   66   bool UpdateVisibleTiles(); |   68   bool UpdateVisibleTiles(); | 
|   67  |   69  | 
|   68   scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, |   70   scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, | 
|   69                                  gfx::Size tile_size, |   71                                  gfx::Size tile_size, | 
|   70                                  gfx::Rect content_rect, |   72                                  gfx::Rect content_rect, | 
|   71                                  gfx::Rect opaque_rect, |   73                                  gfx::Rect opaque_rect, | 
|   72                                  float contents_scale, |   74                                  float contents_scale, | 
|   73                                  int layer_id, |   75                                  int layer_id, | 
|   74                                  int source_frame_number, |   76                                  int source_frame_number, | 
|   75                                  int flags); |   77                                  int flags); | 
|   76  |   78  | 
 |   79   scoped_refptr<TileBundle> CreateTileBundle(int offset_x, | 
 |   80                                              int offset_y, | 
 |   81                                              int width, | 
 |   82                                              int height); | 
 |   83  | 
|   77   scoped_ptr<base::Value> BasicStateAsValue() const; |   84   scoped_ptr<base::Value> BasicStateAsValue() const; | 
|   78   scoped_ptr<base::Value> AllTilesAsValue() const; |   85   scoped_ptr<base::Value> AllTilesAsValue() const; | 
|   79   void GetMemoryStats(size_t* memory_required_bytes, |   86   void GetMemoryStats(size_t* memory_required_bytes, | 
|   80                       size_t* memory_nice_to_have_bytes, |   87                       size_t* memory_nice_to_have_bytes, | 
|   81                       size_t* memory_allocated_bytes, |   88                       size_t* memory_allocated_bytes, | 
|   82                       size_t* memory_used_bytes) const; |   89                       size_t* memory_used_bytes) const; | 
|   83  |   90  | 
|   84   const MemoryHistory::Entry& memory_stats_from_last_assign() const { |   91   const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 
|   85     return memory_stats_from_last_assign_; |   92     return memory_stats_from_last_assign_; | 
|   86   } |   93   } | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|  117   } |  124   } | 
|  118  |  125  | 
|  119  protected: |  126  protected: | 
|  120   TileManager(TileManagerClient* client, |  127   TileManager(TileManagerClient* client, | 
|  121               ResourceProvider* resource_provider, |  128               ResourceProvider* resource_provider, | 
|  122               scoped_ptr<RasterWorkerPool> raster_worker_pool, |  129               scoped_ptr<RasterWorkerPool> raster_worker_pool, | 
|  123               size_t num_raster_threads, |  130               size_t num_raster_threads, | 
|  124               size_t max_raster_usage_bytes, |  131               size_t max_raster_usage_bytes, | 
|  125               RenderingStatsInstrumentation* rendering_stats_instrumentation); |  132               RenderingStatsInstrumentation* rendering_stats_instrumentation); | 
|  126  |  133  | 
|  127   // Methods called by Tile |  134   // Methods called by Tile and TileBundle | 
 |  135   friend class TileBundle; | 
|  128   friend class Tile; |  136   friend class Tile; | 
 |  137  | 
|  129   void DidChangeTilePriority(Tile* tile); |  138   void DidChangeTilePriority(Tile* tile); | 
 |  139   void DidChangeTileBundlePriority(TileBundle* bundle); | 
|  130  |  140  | 
|  131   void CleanUpReleasedTiles(); |  141   void CleanUpReleasedTiles(); | 
|  132  |  142  | 
|  133   // Overriden from RefCountedManager<Tile>: |  143   // Overridden from RefCountedManager<Tile>: | 
|  134   virtual void Release(Tile* tile) OVERRIDE; |  144   virtual void Release(Tile* tile) OVERRIDE; | 
|  135  |  145  | 
|  136   // Overriden from RasterWorkerPoolClient: |  146   // Overridden from RefCountedManager<TileBundle>: | 
 |  147   virtual void Release(TileBundle* bundle) OVERRIDE; | 
 |  148  | 
 |  149   // Overridden from RasterWorkerPoolClient: | 
|  137   virtual bool ShouldForceTasksRequiredForActivationToComplete() const |  150   virtual bool ShouldForceTasksRequiredForActivationToComplete() const | 
|  138       OVERRIDE; |  151       OVERRIDE; | 
|  139   virtual void DidFinishRunningTasks() OVERRIDE; |  152   virtual void DidFinishRunningTasks() OVERRIDE; | 
|  140   virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE; |  153   virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE; | 
|  141  |  154  | 
|  142   typedef std::vector<Tile*> TileVector; |  155   typedef std::vector<Tile*> TileVector; | 
|  143   typedef std::set<Tile*> TileSet; |  156   typedef std::set<Tile*> TileSet; | 
|  144  |  157  | 
|  145   // Virtual for test |  158   // Virtual for test | 
|  146   virtual void ScheduleTasks( |  159   virtual void ScheduleTasks( | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  179   void UpdatePrioritizedTileSetIfNeeded(); |  192   void UpdatePrioritizedTileSetIfNeeded(); | 
|  180  |  193  | 
|  181   TileManagerClient* client_; |  194   TileManagerClient* client_; | 
|  182   scoped_ptr<ResourcePool> resource_pool_; |  195   scoped_ptr<ResourcePool> resource_pool_; | 
|  183   scoped_ptr<RasterWorkerPool> raster_worker_pool_; |  196   scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 
|  184   GlobalStateThatImpactsTilePriority global_state_; |  197   GlobalStateThatImpactsTilePriority global_state_; | 
|  185  |  198  | 
|  186   typedef base::hash_map<Tile::Id, Tile*> TileMap; |  199   typedef base::hash_map<Tile::Id, Tile*> TileMap; | 
|  187   TileMap tiles_; |  200   TileMap tiles_; | 
|  188  |  201  | 
 |  202   typedef base::hash_map<TileBundle::Id, TileBundle*> TileBundleMap; | 
 |  203   TileBundleMap bundles_; | 
 |  204  | 
|  189   PrioritizedTileSet prioritized_tiles_; |  205   PrioritizedTileSet prioritized_tiles_; | 
|  190   bool prioritized_tiles_dirty_; |  206   bool prioritized_tiles_dirty_; | 
|  191  |  207  | 
|  192   bool all_tiles_that_need_to_be_rasterized_have_memory_; |  208   bool all_tiles_that_need_to_be_rasterized_have_memory_; | 
|  193   bool all_tiles_required_for_activation_have_memory_; |  209   bool all_tiles_required_for_activation_have_memory_; | 
|  194  |  210  | 
|  195   size_t memory_required_bytes_; |  211   size_t memory_required_bytes_; | 
|  196   size_t memory_nice_to_have_bytes_; |  212   size_t memory_nice_to_have_bytes_; | 
|  197  |  213  | 
|  198   size_t bytes_releasable_; |  214   size_t bytes_releasable_; | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  210   typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; |  226   typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; | 
|  211   typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; |  227   typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; | 
|  212   LayerPixelRefTaskMap image_decode_tasks_; |  228   LayerPixelRefTaskMap image_decode_tasks_; | 
|  213  |  229  | 
|  214   typedef base::hash_map<int, int> LayerCountMap; |  230   typedef base::hash_map<int, int> LayerCountMap; | 
|  215   LayerCountMap used_layer_counts_; |  231   LayerCountMap used_layer_counts_; | 
|  216  |  232  | 
|  217   RasterTaskCompletionStats update_visible_tiles_stats_; |  233   RasterTaskCompletionStats update_visible_tiles_stats_; | 
|  218  |  234  | 
|  219   std::vector<Tile*> released_tiles_; |  235   std::vector<Tile*> released_tiles_; | 
 |  236   std::vector<TileBundle*> released_tile_bundles_; | 
|  220  |  237  | 
|  221   DISALLOW_COPY_AND_ASSIGN(TileManager); |  238   DISALLOW_COPY_AND_ASSIGN(TileManager); | 
|  222 }; |  239 }; | 
|  223  |  240  | 
|  224 }  // namespace cc |  241 }  // namespace cc | 
|  225  |  242  | 
|  226 #endif  // CC_RESOURCES_TILE_MANAGER_H_ |  243 #endif  // CC_RESOURCES_TILE_MANAGER_H_ | 
| OLD | NEW |