Preserve viewport scrolling layer when a fling starts
[chromium-blink-merge.git] / cc / tiles / tile.h
blobe53c2ac52f808a23e5658b476eca2244b3e6f005
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 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 };
28 typedef uint64 Id;
30 Id id() const {
31 return id_;
34 // TODO(vmpstr): Move this to the iterators.
35 bool required_for_activation() const { return required_for_activation_; }
36 void set_required_for_activation(bool is_required) {
37 required_for_activation_ = is_required;
39 bool required_for_draw() const { return required_for_draw_; }
40 void set_required_for_draw(bool is_required) {
41 required_for_draw_ = is_required;
44 bool use_picture_analysis() const {
45 return !!(flags_ & USE_PICTURE_ANALYSIS);
48 void AsValueInto(base::trace_event::TracedValue* value) const;
50 const TileDrawInfo& draw_info() const { return draw_info_; }
51 TileDrawInfo& draw_info() { return draw_info_; }
53 float contents_scale() const { return contents_scale_; }
54 gfx::Rect content_rect() const { return content_rect_; }
56 int layer_id() const { return layer_id_; }
58 int source_frame_number() const { return source_frame_number_; }
60 size_t GPUMemoryUsageInBytes() const;
62 gfx::Size desired_texture_size() const { return desired_texture_size_; }
64 void set_tiling_index(int i, int j) {
65 tiling_i_index_ = i;
66 tiling_j_index_ = j;
68 int tiling_i_index() const { return tiling_i_index_; }
69 int tiling_j_index() const { return tiling_j_index_; }
71 void SetInvalidated(const gfx::Rect& invalid_content_rect,
72 Id previous_tile_id) {
73 invalidated_content_rect_ = invalid_content_rect;
74 invalidated_id_ = previous_tile_id;
77 Id invalidated_id() const { return invalidated_id_; }
78 const gfx::Rect& invalidated_content_rect() const {
79 return invalidated_content_rect_;
82 private:
83 friend class TileManager;
84 friend class FakeTileManager;
85 friend class FakePictureLayerImpl;
87 // Methods called by by tile manager.
88 Tile(TileManager* tile_manager,
89 const gfx::Size& desired_texture_size,
90 const gfx::Rect& content_rect,
91 float contents_scale,
92 int layer_id,
93 int source_frame_number,
94 int flags);
95 ~Tile();
97 bool HasRasterTask() const { return !!raster_task_.get(); }
99 TileManager* tile_manager_;
100 gfx::Size desired_texture_size_;
101 gfx::Rect content_rect_;
102 float contents_scale_;
104 TileDrawInfo draw_info_;
106 int layer_id_;
107 int source_frame_number_;
108 int flags_;
109 int tiling_i_index_;
110 int tiling_j_index_;
111 bool required_for_activation_ : 1;
112 bool required_for_draw_ : 1;
114 Id id_;
115 static Id s_next_id_;
117 // The rect bounding the changes in this Tile vs the previous tile it
118 // replaced.
119 gfx::Rect invalidated_content_rect_;
120 // The |id_| of the Tile that was invalidated and replaced by this tile.
121 Id invalidated_id_;
123 unsigned scheduled_priority_;
125 scoped_refptr<RasterTask> raster_task_;
127 DISALLOW_COPY_AND_ASSIGN(Tile);
130 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>;
132 } // namespace cc
134 #endif // CC_TILES_TILE_H_