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/raster_source.h" | 10 #include "cc/resources/raster_source.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 typedef uint64 Id; | 24 typedef uint64 Id; |
25 | 25 |
26 Id id() const { | 26 Id id() const { |
27 return id_; | 27 return id_; |
28 } | 28 } |
29 | 29 |
30 RasterSource* raster_source() { return raster_source_.get(); } | 30 RasterSource* raster_source() { return raster_source_.get(); } |
31 | 31 |
32 const RasterSource* raster_source() const { return raster_source_.get(); } | 32 const RasterSource* raster_source() const { return raster_source_.get(); } |
33 | 33 |
34 const TilePriority& priority() const { return priority_; } | 34 const TilePriority& priority(WhichTree tree) const { |
| 35 return priority_[tree]; |
| 36 } |
35 | 37 |
36 void set_priority(const TilePriority& priority) { priority_ = priority; } | 38 TilePriority priority_for_tree_priority(TreePriority tree_priority) const { |
| 39 switch (tree_priority) { |
| 40 case SMOOTHNESS_TAKES_PRIORITY: |
| 41 return priority_[ACTIVE_TREE]; |
| 42 case NEW_CONTENT_TAKES_PRIORITY: |
| 43 return priority_[PENDING_TREE]; |
| 44 case SAME_PRIORITY_FOR_BOTH_TREES: |
| 45 return combined_priority(); |
| 46 default: |
| 47 NOTREACHED(); |
| 48 return TilePriority(); |
| 49 } |
| 50 } |
| 51 |
| 52 TilePriority combined_priority() const { |
| 53 return TilePriority(priority_[ACTIVE_TREE], |
| 54 priority_[PENDING_TREE]); |
| 55 } |
| 56 |
| 57 void SetPriority(WhichTree tree, const TilePriority& priority) { |
| 58 priority_[tree] = priority; |
| 59 } |
37 | 60 |
38 // TODO(vmpstr): Move this to the iterators. | 61 // TODO(vmpstr): Move this to the iterators. |
39 void set_is_occluded(bool is_occluded) { is_occluded_ = is_occluded; } | 62 void set_is_occluded(WhichTree tree, bool is_occluded) { |
40 bool is_occluded() const { return is_occluded_; } | 63 is_occluded_[tree] = is_occluded; |
| 64 } |
| 65 |
| 66 bool is_occluded(WhichTree tree) const { return is_occluded_[tree]; } |
| 67 |
| 68 void set_shared(bool is_shared) { is_shared_ = is_shared; } |
| 69 bool is_shared() const { return is_shared_; } |
| 70 |
| 71 bool is_occluded_combined() const { |
| 72 return is_occluded_[ACTIVE_TREE] && is_occluded_[PENDING_TREE]; |
| 73 } |
41 | 74 |
42 // TODO(vmpstr): Move this to the iterators. | 75 // TODO(vmpstr): Move this to the iterators. |
43 bool required_for_activation() const { return required_for_activation_; } | 76 bool required_for_activation() const { return required_for_activation_; } |
44 void set_required_for_activation(bool is_required) { | 77 void set_required_for_activation(bool is_required) { |
45 required_for_activation_ = is_required; | 78 required_for_activation_ = is_required; |
46 } | 79 } |
47 bool required_for_draw() const { return required_for_draw_; } | 80 bool required_for_draw() const { return required_for_draw_; } |
48 void set_required_for_draw(bool is_required) { | 81 void set_required_for_draw(bool is_required) { |
49 required_for_draw_ = is_required; | 82 required_for_draw_ = is_required; |
50 } | 83 } |
(...skipping 17 matching lines...) Expand all Loading... |
68 | 101 |
69 TileDrawInfo& draw_info() { return draw_info_; } | 102 TileDrawInfo& draw_info() { return draw_info_; } |
70 | 103 |
71 float contents_scale() const { return contents_scale_; } | 104 float contents_scale() const { return contents_scale_; } |
72 gfx::Rect content_rect() const { return content_rect_; } | 105 gfx::Rect content_rect() const { return content_rect_; } |
73 | 106 |
74 int layer_id() const { return layer_id_; } | 107 int layer_id() const { return layer_id_; } |
75 | 108 |
76 int source_frame_number() const { return source_frame_number_; } | 109 int source_frame_number() const { return source_frame_number_; } |
77 | 110 |
78 void set_raster_source(RasterSource* raster_source) { | 111 void set_raster_source(scoped_refptr<RasterSource> raster_source) { |
79 DCHECK(raster_source->CoversRect(content_rect_, contents_scale_)) | 112 DCHECK(raster_source->CoversRect(content_rect_, contents_scale_)) |
80 << "Recording rect: " | 113 << "Recording rect: " |
81 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_) | 114 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_) |
82 .ToString(); | 115 .ToString(); |
83 raster_source_ = raster_source; | 116 raster_source_ = raster_source; |
84 } | 117 } |
85 | 118 |
86 size_t GPUMemoryUsageInBytes() const; | 119 size_t GPUMemoryUsageInBytes() const; |
87 | 120 |
88 gfx::Size desired_texture_size() const { return desired_texture_size_; } | 121 gfx::Size desired_texture_size() const { return desired_texture_size_; } |
(...skipping 22 matching lines...) Expand all Loading... |
111 int source_frame_number, | 144 int source_frame_number, |
112 int flags); | 145 int flags); |
113 ~Tile(); | 146 ~Tile(); |
114 | 147 |
115 bool HasRasterTask() const { return !!raster_task_.get(); } | 148 bool HasRasterTask() const { return !!raster_task_.get(); } |
116 | 149 |
117 scoped_refptr<RasterSource> raster_source_; | 150 scoped_refptr<RasterSource> raster_source_; |
118 gfx::Size desired_texture_size_; | 151 gfx::Size desired_texture_size_; |
119 gfx::Rect content_rect_; | 152 gfx::Rect content_rect_; |
120 float contents_scale_; | 153 float contents_scale_; |
121 bool is_occluded_; | 154 bool is_occluded_[LAST_TREE + 1]; |
122 | 155 |
123 TilePriority priority_; | 156 TilePriority priority_[LAST_TREE + 1]; |
124 TileDrawInfo draw_info_; | 157 TileDrawInfo draw_info_; |
125 | 158 |
126 int layer_id_; | 159 int layer_id_; |
127 int source_frame_number_; | 160 int source_frame_number_; |
128 int flags_; | 161 int flags_; |
129 int tiling_i_index_; | 162 int tiling_i_index_; |
130 int tiling_j_index_; | 163 int tiling_j_index_; |
| 164 bool is_shared_ : 1; |
131 bool required_for_activation_ : 1; | 165 bool required_for_activation_ : 1; |
132 bool required_for_draw_ : 1; | 166 bool required_for_draw_ : 1; |
133 | 167 |
134 Id id_; | 168 Id id_; |
135 static Id s_next_id_; | 169 static Id s_next_id_; |
136 | 170 |
137 unsigned scheduled_priority_; | 171 unsigned scheduled_priority_; |
138 | 172 |
139 scoped_refptr<RasterTask> raster_task_; | 173 scoped_refptr<RasterTask> raster_task_; |
140 | 174 |
141 DISALLOW_COPY_AND_ASSIGN(Tile); | 175 DISALLOW_COPY_AND_ASSIGN(Tile); |
142 }; | 176 }; |
143 | 177 |
144 } // namespace cc | 178 } // namespace cc |
145 | 179 |
146 #endif // CC_RESOURCES_TILE_H_ | 180 #endif // CC_RESOURCES_TILE_H_ |
OLD | NEW |