| 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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "cc/base/ref_counted_managed.h" | 11 #include "cc/base/ref_counted_managed.h" |
| 12 #include "cc/resources/managed_tile_state.h" | 12 #include "cc/resources/managed_tile_state.h" |
| 13 #include "cc/resources/raster_mode.h" | 13 #include "cc/resources/raster_mode.h" |
| 14 #include "cc/resources/tile_bundle.h" | 14 #include "cc/resources/tile_priority.h" |
| 15 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 class PicturePileImpl; | 20 class PicturePileImpl; |
| 21 | 21 |
| 22 class CC_EXPORT Tile : public RefCountedManaged<Tile> { | 22 class CC_EXPORT Tile : public RefCountedManaged<Tile> { |
| 23 public: | 23 public: |
| 24 enum TileRasterFlags { | 24 enum TileRasterFlags { |
| 25 USE_LCD_TEXT = 1 << 0, | 25 USE_LCD_TEXT = 1 << 0, |
| 26 USE_GPU_RASTERIZATION = 1 << 1 | 26 USE_GPU_RASTERIZATION = 1 << 1 |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 typedef uint64 Id; | 29 typedef uint64 Id; |
| 30 | 30 |
| 31 Id id() const { | 31 Id id() const { |
| 32 return id_; | 32 return id_; |
| 33 } | 33 } |
| 34 | 34 |
| 35 PicturePileImpl* picture_pile() { | 35 PicturePileImpl* picture_pile() { |
| 36 return picture_pile_.get(); | 36 return picture_pile_.get(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 const PicturePileImpl* picture_pile() const { | 39 const PicturePileImpl* picture_pile() const { |
| 40 return picture_pile_.get(); | 40 return picture_pile_.get(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 const TilePriority& priority(WhichTree tree) const { |
| 44 return priority_[tree]; |
| 45 } |
| 46 |
| 47 TilePriority combined_priority() const { |
| 48 return TilePriority(priority_[ACTIVE_TREE], |
| 49 priority_[PENDING_TREE]); |
| 50 } |
| 51 |
| 52 void SetPriority(WhichTree tree, const TilePriority& priority); |
| 53 |
| 43 void MarkRequiredForActivation(); | 54 void MarkRequiredForActivation(); |
| 44 | 55 |
| 45 bool required_for_activation() const { | 56 bool required_for_activation() const { |
| 46 return required_for_activation_; | 57 return priority_[PENDING_TREE].required_for_activation; |
| 47 } | 58 } |
| 48 | 59 |
| 49 void set_can_use_lcd_text(bool can_use_lcd_text) { | 60 void set_can_use_lcd_text(bool can_use_lcd_text) { |
| 50 if (can_use_lcd_text) | 61 if (can_use_lcd_text) |
| 51 flags_ |= USE_LCD_TEXT; | 62 flags_ |= USE_LCD_TEXT; |
| 52 else | 63 else |
| 53 flags_ &= ~USE_LCD_TEXT; | 64 flags_ &= ~USE_LCD_TEXT; |
| 54 } | 65 } |
| 55 | 66 |
| 56 bool can_use_lcd_text() const { | 67 bool can_use_lcd_text() const { |
| 57 return !!(flags_ & USE_LCD_TEXT); | 68 return !!(flags_ & USE_LCD_TEXT); |
| 58 } | 69 } |
| 59 | 70 |
| 60 void set_use_gpu_rasterization(bool use_gpu_rasterization) { | 71 void set_use_gpu_rasterization(bool use_gpu_rasterization) { |
| 61 if (use_gpu_rasterization) | 72 if (use_gpu_rasterization) |
| 62 flags_ |= USE_GPU_RASTERIZATION; | 73 flags_ |= USE_GPU_RASTERIZATION; |
| 63 else | 74 else |
| 64 flags_ &= ~USE_GPU_RASTERIZATION; | 75 flags_ &= ~USE_GPU_RASTERIZATION; |
| 65 } | 76 } |
| 66 | 77 |
| 67 bool use_gpu_rasterization() const { | 78 bool use_gpu_rasterization() const { |
| 68 return !!(flags_ & USE_GPU_RASTERIZATION); | 79 return !!(flags_ & USE_GPU_RASTERIZATION); |
| 69 } | 80 } |
| 70 | 81 |
| 71 bool is_visible() const { | |
| 72 return is_visible_; | |
| 73 } | |
| 74 | |
| 75 void set_is_visible(bool is_visible) { | |
| 76 is_visible_ = is_visible; | |
| 77 } | |
| 78 | |
| 79 scoped_ptr<base::Value> AsValue() const; | 82 scoped_ptr<base::Value> AsValue() const; |
| 80 | 83 |
| 81 inline bool IsReadyToDraw() const { | 84 inline bool IsReadyToDraw() const { |
| 82 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 85 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
| 83 if (managed_state_.tile_versions[mode].IsReadyToDraw()) | 86 if (managed_state_.tile_versions[mode].IsReadyToDraw()) |
| 84 return true; | 87 return true; |
| 85 } | 88 } |
| 86 return false; | 89 return false; |
| 87 } | 90 } |
| 88 | 91 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 ManagedTileState& managed_state() { return managed_state_; } | 147 ManagedTileState& managed_state() { return managed_state_; } |
| 145 const ManagedTileState& managed_state() const { return managed_state_; } | 148 const ManagedTileState& managed_state() const { return managed_state_; } |
| 146 | 149 |
| 147 TileManager* tile_manager_; | 150 TileManager* tile_manager_; |
| 148 scoped_refptr<PicturePileImpl> picture_pile_; | 151 scoped_refptr<PicturePileImpl> picture_pile_; |
| 149 gfx::Rect tile_size_; | 152 gfx::Rect tile_size_; |
| 150 gfx::Rect content_rect_; | 153 gfx::Rect content_rect_; |
| 151 float contents_scale_; | 154 float contents_scale_; |
| 152 gfx::Rect opaque_rect_; | 155 gfx::Rect opaque_rect_; |
| 153 | 156 |
| 157 TilePriority priority_[NUM_TREES]; |
| 154 ManagedTileState managed_state_; | 158 ManagedTileState managed_state_; |
| 155 int layer_id_; | 159 int layer_id_; |
| 156 int source_frame_number_; | 160 int source_frame_number_; |
| 157 int flags_; | 161 int flags_; |
| 158 bool required_for_activation_; | |
| 159 bool is_visible_; | |
| 160 | 162 |
| 161 Id id_; | 163 Id id_; |
| 162 static Id s_next_id_; | 164 static Id s_next_id_; |
| 163 | 165 |
| 164 DISALLOW_COPY_AND_ASSIGN(Tile); | 166 DISALLOW_COPY_AND_ASSIGN(Tile); |
| 165 }; | 167 }; |
| 166 | 168 |
| 167 } // namespace cc | 169 } // namespace cc |
| 168 | 170 |
| 169 #endif // CC_RESOURCES_TILE_H_ | 171 #endif // CC_RESOURCES_TILE_H_ |
| OLD | NEW |