Rename frame classes
[chromium-blink-merge.git] / cc / tiles / tile.h
blob083c76314a70af63b0c91afffcb392185ed68ca5
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
3 // found in the LICENSE file.
5 #ifndef CC_TILES_TILE_H_
6 #define CC_TILES_TILE_H_
8 #include "base/memory/ref_counted.h"
9 #include "cc/tiles/tile_draw_info.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h"
13 namespace cc {
15 class PrioritizedTile;
16 class TileManager;
17 struct TilePriority;
19 class CC_EXPORT Tile {
20 public:
21 class CC_EXPORT Deleter {
22 public:
23 void operator()(Tile* tile) const;
26 class CC_EXPORT CreateInfo {
27 public:
28 int tiling_i_index;
29 int tiling_j_index;
30 gfx::Rect enclosing_layer_rect;
31 gfx::Rect content_rect;
32 float contents_scale;
34 CreateInfo(int tiling_i_index,
35 int tiling_j_index,
36 const gfx::Rect& enclosing_layer_rect,
37 const gfx::Rect& content_rect,
38 float contents_scale)
39 : tiling_i_index(tiling_i_index),
40 tiling_j_index(tiling_j_index),
41 enclosing_layer_rect(enclosing_layer_rect),
42 content_rect(content_rect),
43 contents_scale(contents_scale) {}
46 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 };
48 typedef uint64 Id;
50 Id id() const {
51 return id_;
54 // TODO(vmpstr): Move this to the iterators.
55 bool required_for_activation() const { return required_for_activation_; }
56 void set_required_for_activation(bool is_required) {
57 required_for_activation_ = is_required;
59 bool required_for_draw() const { return required_for_draw_; }
60 void set_required_for_draw(bool is_required) {
61 required_for_draw_ = is_required;
64 bool use_picture_analysis() const {
65 return !!(flags_ & USE_PICTURE_ANALYSIS);
68 void AsValueInto(base::trace_event::TracedValue* value) const;
70 const TileDrawInfo& draw_info() const { return draw_info_; }
71 TileDrawInfo& draw_info() { return draw_info_; }
73 float contents_scale() const { return contents_scale_; }
74 const gfx::Rect& content_rect() const { return content_rect_; }
75 const gfx::Rect& enclosing_layer_rect() const {
76 return enclosing_layer_rect_;
79 int layer_id() const { return layer_id_; }
81 int source_frame_number() const { return source_frame_number_; }
83 size_t GPUMemoryUsageInBytes() const;
85 const gfx::Size& desired_texture_size() const { return content_rect_.size(); }
87 int tiling_i_index() const { return tiling_i_index_; }
88 int tiling_j_index() const { return tiling_j_index_; }
90 void SetInvalidated(const gfx::Rect& invalid_content_rect,
91 Id previous_tile_id) {
92 invalidated_content_rect_ = invalid_content_rect;
93 invalidated_id_ = previous_tile_id;
96 Id invalidated_id() const { return invalidated_id_; }
97 const gfx::Rect& invalidated_content_rect() const {
98 return invalidated_content_rect_;
101 private:
102 friend class TileManager;
103 friend class FakeTileManager;
104 friend class FakePictureLayerImpl;
106 // Methods called by by tile manager.
107 Tile(TileManager* tile_manager,
108 const CreateInfo& info,
109 int layer_id,
110 int source_frame_number,
111 int flags);
112 ~Tile();
114 bool HasRasterTask() const { return !!raster_task_.get(); }
116 TileManager* const tile_manager_;
117 const gfx::Rect content_rect_;
118 const gfx::Rect enclosing_layer_rect_;
119 const float contents_scale_;
121 TileDrawInfo draw_info_;
123 const int layer_id_;
124 const int source_frame_number_;
125 const int flags_;
126 const int tiling_i_index_;
127 const int tiling_j_index_;
128 bool required_for_activation_ : 1;
129 bool required_for_draw_ : 1;
131 Id id_;
133 // The rect bounding the changes in this Tile vs the previous tile it
134 // replaced.
135 gfx::Rect invalidated_content_rect_;
136 // The |id_| of the Tile that was invalidated and replaced by this tile.
137 Id invalidated_id_;
139 unsigned scheduled_priority_;
141 scoped_refptr<RasterTask> raster_task_;
143 DISALLOW_COPY_AND_ASSIGN(Tile);
146 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>;
148 } // namespace cc
150 #endif // CC_TILES_TILE_H_