| 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 AsValueInto(base::trace_event::TracedValue* value) const; |
| 59 base::trace_event::TracedValue* dict) const; | |
| 60 | 56 |
| 61 inline bool IsReadyToDraw() const { return draw_info_.IsReadyToDraw(); } | 57 inline bool IsReadyToDraw() const { return draw_info_.IsReadyToDraw(); } |
| 62 | 58 |
| 63 const TileDrawInfo& draw_info() const { return draw_info_; } | 59 const TileDrawInfo& draw_info() const { return draw_info_; } |
| 64 | 60 |
| 65 TileDrawInfo& draw_info() { return draw_info_; } | 61 TileDrawInfo& draw_info() { return draw_info_; } |
| 66 | 62 |
| 67 float contents_scale() const { return contents_scale_; } | 63 float contents_scale() const { return contents_scale_; } |
| 68 gfx::Rect content_rect() const { return content_rect_; } | 64 gfx::Rect content_rect() const { return content_rect_; } |
| 69 | 65 |
| 70 int layer_id() const { return layer_id_; } | 66 int layer_id() const { return layer_id_; } |
| 71 | 67 |
| 72 int source_frame_number() const { return source_frame_number_; } | 68 int source_frame_number() const { return source_frame_number_; } |
| 73 | 69 |
| 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; | 70 size_t GPUMemoryUsageInBytes() const; |
| 83 | 71 |
| 84 gfx::Size desired_texture_size() const { return desired_texture_size_; } | 72 gfx::Size desired_texture_size() const { return desired_texture_size_; } |
| 85 | 73 |
| 86 void set_tiling_index(int i, int j) { | 74 void set_tiling_index(int i, int j) { |
| 87 tiling_i_index_ = i; | 75 tiling_i_index_ = i; |
| 88 tiling_j_index_ = j; | 76 tiling_j_index_ = j; |
| 89 } | 77 } |
| 90 int tiling_i_index() const { return tiling_i_index_; } | 78 int tiling_i_index() const { return tiling_i_index_; } |
| 91 int tiling_j_index() const { return tiling_j_index_; } | 79 int tiling_j_index() const { return tiling_j_index_; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 102 const gfx::Rect& content_rect, | 90 const gfx::Rect& content_rect, |
| 103 float contents_scale, | 91 float contents_scale, |
| 104 int layer_id, | 92 int layer_id, |
| 105 int source_frame_number, | 93 int source_frame_number, |
| 106 int flags); | 94 int flags); |
| 107 ~Tile(); | 95 ~Tile(); |
| 108 | 96 |
| 109 bool HasRasterTask() const { return !!raster_task_.get(); } | 97 bool HasRasterTask() const { return !!raster_task_.get(); } |
| 110 | 98 |
| 111 TileManager* tile_manager_; | 99 TileManager* tile_manager_; |
| 112 scoped_refptr<RasterSource> raster_source_; | |
| 113 gfx::Size desired_texture_size_; | 100 gfx::Size desired_texture_size_; |
| 114 gfx::Rect content_rect_; | 101 gfx::Rect content_rect_; |
| 115 float contents_scale_; | 102 float contents_scale_; |
| 116 | 103 |
| 117 TileDrawInfo draw_info_; | 104 TileDrawInfo draw_info_; |
| 118 | 105 |
| 119 int layer_id_; | 106 int layer_id_; |
| 120 int source_frame_number_; | 107 int source_frame_number_; |
| 121 int flags_; | 108 int flags_; |
| 122 int tiling_i_index_; | 109 int tiling_i_index_; |
| 123 int tiling_j_index_; | 110 int tiling_j_index_; |
| 124 bool required_for_activation_ : 1; | 111 bool required_for_activation_ : 1; |
| 125 bool required_for_draw_ : 1; | 112 bool required_for_draw_ : 1; |
| 126 | 113 |
| 127 Id id_; | 114 Id id_; |
| 128 static Id s_next_id_; | 115 static Id s_next_id_; |
| 129 | 116 |
| 130 unsigned scheduled_priority_; | 117 unsigned scheduled_priority_; |
| 131 | 118 |
| 132 scoped_refptr<RasterTask> raster_task_; | 119 scoped_refptr<RasterTask> raster_task_; |
| 133 | 120 |
| 134 DISALLOW_COPY_AND_ASSIGN(Tile); | 121 DISALLOW_COPY_AND_ASSIGN(Tile); |
| 135 }; | 122 }; |
| 136 | 123 |
| 137 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>; | 124 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>; |
| 138 | 125 |
| 139 } // namespace cc | 126 } // namespace cc |
| 140 | 127 |
| 141 #endif // CC_RESOURCES_TILE_H_ | 128 #endif // CC_RESOURCES_TILE_H_ |
| OLD | NEW |