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" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (use_gpu_rasterization) | 72 if (use_gpu_rasterization) |
73 flags_ |= USE_GPU_RASTERIZATION; | 73 flags_ |= USE_GPU_RASTERIZATION; |
74 else | 74 else |
75 flags_ &= ~USE_GPU_RASTERIZATION; | 75 flags_ &= ~USE_GPU_RASTERIZATION; |
76 } | 76 } |
77 | 77 |
78 bool use_gpu_rasterization() const { | 78 bool use_gpu_rasterization() const { |
79 return !!(flags_ & USE_GPU_RASTERIZATION); | 79 return !!(flags_ & USE_GPU_RASTERIZATION); |
80 } | 80 } |
81 | 81 |
| 82 bool NeedsRasterForMode(RasterMode mode) const { |
| 83 return !managed_state_.tile_versions[mode].IsReadyToDraw(); |
| 84 } |
| 85 |
| 86 bool HasResources() const { |
| 87 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
| 88 if (managed_state_.tile_versions[mode].has_resource()) |
| 89 return true; |
| 90 } |
| 91 return false; |
| 92 } |
| 93 |
82 scoped_ptr<base::Value> AsValue() const; | 94 scoped_ptr<base::Value> AsValue() const; |
83 | 95 |
84 inline bool IsReadyToDraw() const { | 96 inline bool IsReadyToDraw() const { |
85 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { | 97 for (int mode = 0; mode < NUM_RASTER_MODES; ++mode) { |
86 if (managed_state_.tile_versions[mode].IsReadyToDraw()) | 98 if (managed_state_.tile_versions[mode].IsReadyToDraw()) |
87 return true; | 99 return true; |
88 } | 100 } |
89 return false; | 101 return false; |
90 } | 102 } |
91 | 103 |
(...skipping 17 matching lines...) Expand all Loading... |
109 | 121 |
110 int source_frame_number() const { return source_frame_number_; } | 122 int source_frame_number() const { return source_frame_number_; } |
111 | 123 |
112 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { | 124 void set_picture_pile(scoped_refptr<PicturePileImpl> pile) { |
113 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); | 125 DCHECK(pile->CanRaster(contents_scale_, content_rect_)); |
114 picture_pile_ = pile; | 126 picture_pile_ = pile; |
115 } | 127 } |
116 | 128 |
117 size_t GPUMemoryUsageInBytes() const; | 129 size_t GPUMemoryUsageInBytes() const; |
118 | 130 |
| 131 gfx::Size size() const { return tile_size_.size(); } |
| 132 |
| 133 RasterMode DetermineRasterModeForTree(WhichTree tree) const; |
| 134 RasterMode DetermineOverallRasterMode() const; |
| 135 |
| 136 // Functionality used in tests. |
119 RasterMode GetRasterModeForTesting() const { | 137 RasterMode GetRasterModeForTesting() const { |
120 return managed_state().raster_mode; | 138 return managed_state().raster_mode; |
121 } | 139 } |
122 ManagedTileState::TileVersion& GetTileVersionForTesting(RasterMode mode) { | 140 ManagedTileState::TileVersion& GetTileVersionForTesting(RasterMode mode) { |
123 return managed_state_.tile_versions[mode]; | 141 return managed_state_.tile_versions[mode]; |
124 } | 142 } |
125 | 143 |
126 gfx::Size size() const { return tile_size_.size(); } | |
127 | |
128 private: | 144 private: |
129 friend class TileManager; | 145 friend class TileManager; |
130 friend class PrioritizedTileSet; | 146 friend class PrioritizedTileSet; |
131 friend class FakeTileManager; | 147 friend class FakeTileManager; |
132 friend class BinComparator; | 148 friend class BinComparator; |
133 friend class FakePictureLayerImpl; | 149 friend class FakePictureLayerImpl; |
134 | 150 |
135 // Methods called by by tile manager. | 151 // Methods called by by tile manager. |
136 Tile(TileManager* tile_manager, | 152 Tile(TileManager* tile_manager, |
137 PicturePileImpl* picture_pile, | 153 PicturePileImpl* picture_pile, |
138 const gfx::Size& tile_size, | 154 const gfx::Size& tile_size, |
139 const gfx::Rect& content_rect, | 155 const gfx::Rect& content_rect, |
140 const gfx::Rect& opaque_rect, | 156 const gfx::Rect& opaque_rect, |
141 float contents_scale, | 157 float contents_scale, |
142 int layer_id, | 158 int layer_id, |
143 int source_frame_number, | 159 int source_frame_number, |
144 int flags); | 160 int flags); |
145 ~Tile(); | 161 ~Tile(); |
146 | 162 |
147 ManagedTileState& managed_state() { return managed_state_; } | 163 ManagedTileState& managed_state() { return managed_state_; } |
148 const ManagedTileState& managed_state() const { return managed_state_; } | 164 const ManagedTileState& managed_state() const { return managed_state_; } |
| 165 RasterMode DetermineRasterModeForResolution(TileResolution resolution) const; |
149 | 166 |
150 TileManager* tile_manager_; | 167 TileManager* tile_manager_; |
151 scoped_refptr<PicturePileImpl> picture_pile_; | 168 scoped_refptr<PicturePileImpl> picture_pile_; |
152 gfx::Rect tile_size_; | 169 gfx::Rect tile_size_; |
153 gfx::Rect content_rect_; | 170 gfx::Rect content_rect_; |
154 float contents_scale_; | 171 float contents_scale_; |
155 gfx::Rect opaque_rect_; | 172 gfx::Rect opaque_rect_; |
156 | 173 |
157 TilePriority priority_[NUM_TREES]; | 174 TilePriority priority_[NUM_TREES]; |
158 ManagedTileState managed_state_; | 175 ManagedTileState managed_state_; |
159 int layer_id_; | 176 int layer_id_; |
160 int source_frame_number_; | 177 int source_frame_number_; |
161 int flags_; | 178 int flags_; |
162 | 179 |
163 Id id_; | 180 Id id_; |
164 static Id s_next_id_; | 181 static Id s_next_id_; |
165 | 182 |
166 DISALLOW_COPY_AND_ASSIGN(Tile); | 183 DISALLOW_COPY_AND_ASSIGN(Tile); |
167 }; | 184 }; |
168 | 185 |
169 } // namespace cc | 186 } // namespace cc |
170 | 187 |
171 #endif // CC_RESOURCES_TILE_H_ | 188 #endif // CC_RESOURCES_TILE_H_ |
OLD | NEW |