| 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/resources/raster_source.h" | 9 #include "cc/resources/raster_source.h" |
| 10 #include "cc/resources/tile_draw_info.h" | 10 #include "cc/resources/tile_draw_info.h" |
| 11 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
| 12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 | 15 |
| 16 class PrioritizedTile; |
| 16 class TileManager; | 17 class TileManager; |
| 17 struct TilePriority; | 18 struct TilePriority; |
| 18 | 19 |
| 19 class CC_EXPORT Tile { | 20 class CC_EXPORT Tile { |
| 20 public: | 21 public: |
| 21 class CC_EXPORT Deleter { | 22 class CC_EXPORT Deleter { |
| 22 public: | 23 public: |
| 23 void operator()(Tile* tile) const; | 24 void operator()(Tile* tile) const; |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; | 27 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; |
| 27 | 28 |
| 28 typedef uint64 Id; | 29 typedef uint64 Id; |
| 29 | 30 |
| 30 Id id() const { | 31 Id id() const { |
| 31 return id_; | 32 return id_; |
| 32 } | 33 } |
| 33 | 34 |
| 34 RasterSource* raster_source() { return raster_source_.get(); } | |
| 35 | |
| 36 const RasterSource* raster_source() const { return raster_source_.get(); } | |
| 37 | |
| 38 // TODO(vmpstr): Move this to the iterators. | 35 // TODO(vmpstr): Move this to the iterators. |
| 39 bool required_for_activation() const { return required_for_activation_; } | 36 bool required_for_activation() const { return required_for_activation_; } |
| 40 void set_required_for_activation(bool is_required) { | 37 void set_required_for_activation(bool is_required) { |
| 41 required_for_activation_ = is_required; | 38 required_for_activation_ = is_required; |
| 42 } | 39 } |
| 43 bool required_for_draw() const { return required_for_draw_; } | 40 bool required_for_draw() const { return required_for_draw_; } |
| 44 void set_required_for_draw(bool is_required) { | 41 void set_required_for_draw(bool is_required) { |
| 45 required_for_draw_ = is_required; | 42 required_for_draw_ = is_required; |
| 46 } | 43 } |
| 47 | 44 |
| 48 bool use_picture_analysis() const { | 45 bool use_picture_analysis() const { |
| 49 return !!(flags_ & USE_PICTURE_ANALYSIS); | 46 return !!(flags_ & USE_PICTURE_ANALYSIS); |
| 50 } | 47 } |
| 51 | 48 |
| 52 bool HasResource() const { return draw_info_.has_resource(); } | 49 bool HasResource() const { return draw_info_.has_resource(); } |
| 53 bool NeedsRaster() const { | 50 bool NeedsRaster() const { |
| 54 return draw_info_.mode() == TileDrawInfo::OOM_MODE || | 51 return draw_info_.mode() == TileDrawInfo::OOM_MODE || |
| 55 !draw_info_.IsReadyToDraw(); | 52 !draw_info_.IsReadyToDraw(); |
| 56 } | 53 } |
| 57 | 54 |
| 58 void AsValueWithPriorityInto(const TilePriority& priority, | 55 void AsValueWithPriorityInto(const PrioritizedTile& prioritized_tile, |
| 59 base::trace_event::TracedValue* dict) const; | 56 base::trace_event::TracedValue* dict) const; |
| 60 | 57 |
| 61 inline bool IsReadyToDraw() const { return draw_info_.IsReadyToDraw(); } | 58 inline bool IsReadyToDraw() const { return draw_info_.IsReadyToDraw(); } |
| 62 | 59 |
| 63 const TileDrawInfo& draw_info() const { return draw_info_; } | 60 const TileDrawInfo& draw_info() const { return draw_info_; } |
| 64 | 61 |
| 65 TileDrawInfo& draw_info() { return draw_info_; } | 62 TileDrawInfo& draw_info() { return draw_info_; } |
| 66 | 63 |
| 67 float contents_scale() const { return contents_scale_; } | 64 float contents_scale() const { return contents_scale_; } |
| 68 gfx::Rect content_rect() const { return content_rect_; } | 65 gfx::Rect content_rect() const { return content_rect_; } |
| 69 | 66 |
| 70 int layer_id() const { return layer_id_; } | 67 int layer_id() const { return layer_id_; } |
| 71 | 68 |
| 72 int source_frame_number() const { return source_frame_number_; } | 69 int source_frame_number() const { return source_frame_number_; } |
| 73 | 70 |
| 74 void set_raster_source(RasterSource* raster_source) { | |
| 75 DCHECK(raster_source->CoversRect(content_rect_, contents_scale_)) | |
| 76 << "Recording rect: " | |
| 77 << gfx::ScaleToEnclosingRect(content_rect_, 1.f / contents_scale_) | |
| 78 .ToString(); | |
| 79 raster_source_ = raster_source; | |
| 80 } | |
| 81 | |
| 82 size_t GPUMemoryUsageInBytes() const; | 71 size_t GPUMemoryUsageInBytes() const; |
| 83 | 72 |
| 84 gfx::Size desired_texture_size() const { return desired_texture_size_; } | 73 gfx::Size desired_texture_size() const { return desired_texture_size_; } |
| 85 | 74 |
| 86 void set_tiling_index(int i, int j) { | 75 void set_tiling_index(int i, int j) { |
| 87 tiling_i_index_ = i; | 76 tiling_i_index_ = i; |
| 88 tiling_j_index_ = j; | 77 tiling_j_index_ = j; |
| 89 } | 78 } |
| 90 int tiling_i_index() const { return tiling_i_index_; } | 79 int tiling_i_index() const { return tiling_i_index_; } |
| 91 int tiling_j_index() const { return tiling_j_index_; } | 80 int tiling_j_index() const { return tiling_j_index_; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 102 const gfx::Rect& content_rect, | 91 const gfx::Rect& content_rect, |
| 103 float contents_scale, | 92 float contents_scale, |
| 104 int layer_id, | 93 int layer_id, |
| 105 int source_frame_number, | 94 int source_frame_number, |
| 106 int flags); | 95 int flags); |
| 107 ~Tile(); | 96 ~Tile(); |
| 108 | 97 |
| 109 bool HasRasterTask() const { return !!raster_task_.get(); } | 98 bool HasRasterTask() const { return !!raster_task_.get(); } |
| 110 | 99 |
| 111 TileManager* tile_manager_; | 100 TileManager* tile_manager_; |
| 112 scoped_refptr<RasterSource> raster_source_; | |
| 113 gfx::Size desired_texture_size_; | 101 gfx::Size desired_texture_size_; |
| 114 gfx::Rect content_rect_; | 102 gfx::Rect content_rect_; |
| 115 float contents_scale_; | 103 float contents_scale_; |
| 116 | 104 |
| 117 TileDrawInfo draw_info_; | 105 TileDrawInfo draw_info_; |
| 118 | 106 |
| 119 int layer_id_; | 107 int layer_id_; |
| 120 int source_frame_number_; | 108 int source_frame_number_; |
| 121 int flags_; | 109 int flags_; |
| 122 int tiling_i_index_; | 110 int tiling_i_index_; |
| 123 int tiling_j_index_; | 111 int tiling_j_index_; |
| 124 bool required_for_activation_ : 1; | 112 bool required_for_activation_ : 1; |
| 125 bool required_for_draw_ : 1; | 113 bool required_for_draw_ : 1; |
| 126 | 114 |
| 127 Id id_; | 115 Id id_; |
| 128 static Id s_next_id_; | 116 static Id s_next_id_; |
| 129 | 117 |
| 130 unsigned scheduled_priority_; | 118 unsigned scheduled_priority_; |
| 131 | 119 |
| 132 scoped_refptr<RasterTask> raster_task_; | 120 scoped_refptr<RasterTask> raster_task_; |
| 133 | 121 |
| 134 DISALLOW_COPY_AND_ASSIGN(Tile); | 122 DISALLOW_COPY_AND_ASSIGN(Tile); |
| 135 }; | 123 }; |
| 136 | 124 |
| 137 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>; | 125 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>; |
| 138 | 126 |
| 139 } // namespace cc | 127 } // namespace cc |
| 140 | 128 |
| 141 #endif // CC_RESOURCES_TILE_H_ | 129 #endif // CC_RESOURCES_TILE_H_ |
| OLD | NEW |