| 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_H_ | 5 #ifndef CC_RESOURCES_TILE_H_ |
| 6 #define CC_RESOURCES_TILE_H_ | 6 #define CC_RESOURCES_TILE_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "cc/base/ref_counted_managed.h" | 9 #include "cc/base/ref_counted_managed.h" |
| 10 #include "cc/resources/managed_tile_state.h" | 10 #include "cc/resources/managed_tile_state.h" |
| 11 #include "cc/resources/picture_pile_impl.h" | 11 #include "cc/resources/raster_source.h" |
| 12 #include "cc/resources/tile_priority.h" | 12 #include "cc/resources/tile_priority.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 class CC_EXPORT Tile : public RefCountedManaged<Tile> { | 18 class CC_EXPORT Tile : public RefCountedManaged<Tile> { |
| 19 public: | 19 public: |
| 20 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; | 20 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; |
| 21 | 21 |
| 22 typedef uint64 Id; | 22 typedef uint64 Id; |
| 23 | 23 |
| 24 Id id() const { | 24 Id id() const { |
| 25 return id_; | 25 return id_; |
| 26 } | 26 } |
| 27 | 27 |
| 28 PicturePileImpl* picture_pile() { | 28 RasterSource* raster_source() { return raster_source_.get(); } |
| 29 return picture_pile_.get(); | |
| 30 } | |
| 31 | 29 |
| 32 const PicturePileImpl* picture_pile() const { | 30 const RasterSource* raster_source() const { return raster_source_.get(); } |
| 33 return picture_pile_.get(); | |
| 34 } | |
| 35 | 31 |
| 36 const TilePriority& priority(WhichTree tree) const { | 32 const TilePriority& priority(WhichTree tree) const { |
| 37 return priority_[tree]; | 33 return priority_[tree]; |
| 38 } | 34 } |
| 39 | 35 |
| 40 TilePriority priority_for_tree_priority(TreePriority tree_priority) const { | 36 TilePriority priority_for_tree_priority(TreePriority tree_priority) const { |
| 41 switch (tree_priority) { | 37 switch (tree_priority) { |
| 42 case SMOOTHNESS_TAKES_PRIORITY: | 38 case SMOOTHNESS_TAKES_PRIORITY: |
| 43 return priority_[ACTIVE_TREE]; | 39 return priority_[ACTIVE_TREE]; |
| 44 case NEW_CONTENT_TAKES_PRIORITY: | 40 case NEW_CONTENT_TAKES_PRIORITY: |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 109 |
| 114 ManagedTileState::DrawInfo& draw_info() { return managed_state_.draw_info; } | 110 ManagedTileState::DrawInfo& draw_info() { return managed_state_.draw_info; } |
| 115 | 111 |
| 116 float contents_scale() const { return contents_scale_; } | 112 float contents_scale() const { return contents_scale_; } |
| 117 gfx::Rect content_rect() const { return content_rect_; } | 113 gfx::Rect content_rect() const { return content_rect_; } |
| 118 | 114 |
| 119 int layer_id() const { return layer_id_; } | 115 int layer_id() const { return layer_id_; } |
| 120 | 116 |
| 121 int source_frame_number() const { return source_frame_number_; } | 117 int source_frame_number() const { return source_frame_number_; } |
| 122 | 118 |
| 123 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 119 void set_raster_source(scoped_refptr<RasterSource> raster_source) { |
| 124 DCHECK(pile->CanRaster(contents_scale_, content_rect_)) | 120 DCHECK(raster_source->RasterCoversRect(content_rect_, contents_scale_)) |
| 125 << "Recording rect: " | 121 << "Recording rect: " |
| 126 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_) | 122 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_) |
| 127 .ToString(); | 123 .ToString(); |
| 128 picture_pile_ = pile; | 124 raster_source_ = raster_source; |
| 129 } | 125 } |
| 130 | 126 |
| 131 size_t GPUMemoryUsageInBytes() const; | 127 size_t GPUMemoryUsageInBytes() const; |
| 132 | 128 |
| 133 gfx::Size size() const { return size_; } | 129 gfx::Size size() const { return size_; } |
| 134 | 130 |
| 135 void set_tiling_index(int i, int j) { | 131 void set_tiling_index(int i, int j) { |
| 136 tiling_i_index_ = i; | 132 tiling_i_index_ = i; |
| 137 tiling_j_index_ = j; | 133 tiling_j_index_ = j; |
| 138 } | 134 } |
| 139 int tiling_i_index() const { return tiling_i_index_; } | 135 int tiling_i_index() const { return tiling_i_index_; } |
| 140 int tiling_j_index() const { return tiling_j_index_; } | 136 int tiling_j_index() const { return tiling_j_index_; } |
| 141 | 137 |
| 142 private: | 138 private: |
| 143 friend class TileManager; | 139 friend class TileManager; |
| 144 friend class PrioritizedTileSet; | 140 friend class PrioritizedTileSet; |
| 145 friend class FakeTileManager; | 141 friend class FakeTileManager; |
| 146 friend class BinComparator; | 142 friend class BinComparator; |
| 147 friend class FakePictureLayerImpl; | 143 friend class FakePictureLayerImpl; |
| 148 | 144 |
| 149 // Methods called by by tile manager. | 145 // Methods called by by tile manager. |
| 150 Tile(TileManager* tile_manager, | 146 Tile(TileManager* tile_manager, |
| 151 PicturePileImpl* picture_pile, | 147 RasterSource* raster_source, |
| 152 const gfx::Size& tile_size, | 148 const gfx::Size& tile_size, |
| 153 const gfx::Rect& content_rect, | 149 const gfx::Rect& content_rect, |
| 154 float contents_scale, | 150 float contents_scale, |
| 155 int layer_id, | 151 int layer_id, |
| 156 int source_frame_number, | 152 int source_frame_number, |
| 157 int flags); | 153 int flags); |
| 158 ~Tile(); | 154 ~Tile(); |
| 159 | 155 |
| 160 ManagedTileState& managed_state() { return managed_state_; } | 156 ManagedTileState& managed_state() { return managed_state_; } |
| 161 const ManagedTileState& managed_state() const { return managed_state_; } | 157 const ManagedTileState& managed_state() const { return managed_state_; } |
| 162 | 158 |
| 163 bool HasRasterTask() const; | 159 bool HasRasterTask() const; |
| 164 | 160 |
| 165 TileManager* tile_manager_; | 161 TileManager* tile_manager_; |
| 166 scoped_refptr<PicturePileImpl> picture_pile_; | 162 scoped_refptr<RasterSource> raster_source_; |
| 167 gfx::Size size_; | 163 gfx::Size size_; |
| 168 gfx::Rect content_rect_; | 164 gfx::Rect content_rect_; |
| 169 float contents_scale_; | 165 float contents_scale_; |
| 170 bool is_occluded_[NUM_TREES]; | 166 bool is_occluded_[NUM_TREES]; |
| 171 | 167 |
| 172 TilePriority priority_[NUM_TREES]; | 168 TilePriority priority_[NUM_TREES]; |
| 173 ManagedTileState managed_state_; | 169 ManagedTileState managed_state_; |
| 174 int layer_id_; | 170 int layer_id_; |
| 175 int source_frame_number_; | 171 int source_frame_number_; |
| 176 int flags_; | 172 int flags_; |
| 177 bool is_shared_; | 173 bool is_shared_; |
| 178 int tiling_i_index_; | 174 int tiling_i_index_; |
| 179 int tiling_j_index_; | 175 int tiling_j_index_; |
| 180 bool required_for_activation_; | 176 bool required_for_activation_; |
| 181 | 177 |
| 182 Id id_; | 178 Id id_; |
| 183 static Id s_next_id_; | 179 static Id s_next_id_; |
| 184 | 180 |
| 185 DISALLOW_COPY_AND_ASSIGN(Tile); | 181 DISALLOW_COPY_AND_ASSIGN(Tile); |
| 186 }; | 182 }; |
| 187 | 183 |
| 188 } // namespace cc | 184 } // namespace cc |
| 189 | 185 |
| 190 #endif // CC_RESOURCES_TILE_H_ | 186 #endif // CC_RESOURCES_TILE_H_ |
| OLD | NEW |