Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: cc/tiles/tile.h

Issue 1318733006: cc: Do the math for a tile's content rect in layer space once. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_TILES_TILE_H_ 5 #ifndef CC_TILES_TILE_H_
6 #define CC_TILES_TILE_H_ 6 #define CC_TILES_TILE_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "cc/tiles/tile_draw_info.h" 9 #include "cc/tiles/tile_draw_info.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
12 12
13 namespace cc { 13 namespace cc {
14 14
15 class PrioritizedTile; 15 class PrioritizedTile;
16 class TileManager; 16 class TileManager;
17 struct TilePriority; 17 struct TilePriority;
18 18
19 class CC_EXPORT Tile { 19 class CC_EXPORT Tile {
20 public: 20 public:
21 class CC_EXPORT Deleter { 21 class CC_EXPORT Deleter {
22 public: 22 public:
23 void operator()(Tile* tile) const; 23 void operator()(Tile* tile) const;
24 }; 24 };
25 25
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;
33
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) {}
44 };
45
26 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 }; 46 enum TileRasterFlags { USE_PICTURE_ANALYSIS = 1 << 0 };
27 47
28 typedef uint64 Id; 48 typedef uint64 Id;
29 49
30 Id id() const { 50 Id id() const {
31 return id_; 51 return id_;
32 } 52 }
33 53
34 // TODO(vmpstr): Move this to the iterators. 54 // TODO(vmpstr): Move this to the iterators.
35 bool required_for_activation() const { return required_for_activation_; } 55 bool required_for_activation() const { return required_for_activation_; }
36 void set_required_for_activation(bool is_required) { 56 void set_required_for_activation(bool is_required) {
37 required_for_activation_ = is_required; 57 required_for_activation_ = is_required;
38 } 58 }
39 bool required_for_draw() const { return required_for_draw_; } 59 bool required_for_draw() const { return required_for_draw_; }
40 void set_required_for_draw(bool is_required) { 60 void set_required_for_draw(bool is_required) {
41 required_for_draw_ = is_required; 61 required_for_draw_ = is_required;
42 } 62 }
43 63
44 bool use_picture_analysis() const { 64 bool use_picture_analysis() const {
45 return !!(flags_ & USE_PICTURE_ANALYSIS); 65 return !!(flags_ & USE_PICTURE_ANALYSIS);
46 } 66 }
47 67
48 void AsValueInto(base::trace_event::TracedValue* value) const; 68 void AsValueInto(base::trace_event::TracedValue* value) const;
49 69
50 const TileDrawInfo& draw_info() const { return draw_info_; } 70 const TileDrawInfo& draw_info() const { return draw_info_; }
51 TileDrawInfo& draw_info() { return draw_info_; } 71 TileDrawInfo& draw_info() { return draw_info_; }
52 72
53 float contents_scale() const { return contents_scale_; } 73 float contents_scale() const { return contents_scale_; }
54 gfx::Rect content_rect() const { return content_rect_; } 74 const gfx::Rect& content_rect() const { return content_rect_; }
75 const gfx::Rect& enclosing_layer_rect() const {
76 return enclosing_layer_rect_;
77 }
55 78
56 int layer_id() const { return layer_id_; } 79 int layer_id() const { return layer_id_; }
57 80
58 int source_frame_number() const { return source_frame_number_; } 81 int source_frame_number() const { return source_frame_number_; }
59 82
60 size_t GPUMemoryUsageInBytes() const; 83 size_t GPUMemoryUsageInBytes() const;
61 84
62 gfx::Size desired_texture_size() const { return desired_texture_size_; } 85 const gfx::Size& desired_texture_size() const { return content_rect_.size(); }
63 86
64 void set_tiling_index(int i, int j) {
65 tiling_i_index_ = i;
66 tiling_j_index_ = j;
67 }
68 int tiling_i_index() const { return tiling_i_index_; } 87 int tiling_i_index() const { return tiling_i_index_; }
69 int tiling_j_index() const { return tiling_j_index_; } 88 int tiling_j_index() const { return tiling_j_index_; }
70 89
71 void SetInvalidated(const gfx::Rect& invalid_content_rect, 90 void SetInvalidated(const gfx::Rect& invalid_content_rect,
72 Id previous_tile_id) { 91 Id previous_tile_id) {
73 invalidated_content_rect_ = invalid_content_rect; 92 invalidated_content_rect_ = invalid_content_rect;
74 invalidated_id_ = previous_tile_id; 93 invalidated_id_ = previous_tile_id;
75 } 94 }
76 95
77 Id invalidated_id() const { return invalidated_id_; } 96 Id invalidated_id() const { return invalidated_id_; }
78 const gfx::Rect& invalidated_content_rect() const { 97 const gfx::Rect& invalidated_content_rect() const {
79 return invalidated_content_rect_; 98 return invalidated_content_rect_;
80 } 99 }
81 100
82 private: 101 private:
83 friend class TileManager; 102 friend class TileManager;
84 friend class FakeTileManager; 103 friend class FakeTileManager;
85 friend class FakePictureLayerImpl; 104 friend class FakePictureLayerImpl;
86 105
87 // Methods called by by tile manager. 106 // Methods called by by tile manager.
88 Tile(TileManager* tile_manager, 107 Tile(TileManager* tile_manager,
89 const gfx::Size& desired_texture_size, 108 const CreateInfo& info,
90 const gfx::Rect& content_rect,
91 float contents_scale,
92 int layer_id, 109 int layer_id,
93 int source_frame_number, 110 int source_frame_number,
94 int flags); 111 int flags);
95 ~Tile(); 112 ~Tile();
96 113
97 bool HasRasterTask() const { return !!raster_task_.get(); } 114 bool HasRasterTask() const { return !!raster_task_.get(); }
98 115
99 TileManager* tile_manager_; 116 TileManager* const tile_manager_;
100 gfx::Size desired_texture_size_; 117 const gfx::Rect content_rect_;
101 gfx::Rect content_rect_; 118 const gfx::Rect enclosing_layer_rect_;
102 float contents_scale_; 119 const float contents_scale_;
103 120
104 TileDrawInfo draw_info_; 121 TileDrawInfo draw_info_;
105 122
106 int layer_id_; 123 const int layer_id_;
107 int source_frame_number_; 124 const int source_frame_number_;
108 int flags_; 125 const int flags_;
109 int tiling_i_index_; 126 const int tiling_i_index_;
110 int tiling_j_index_; 127 const int tiling_j_index_;
111 bool required_for_activation_ : 1; 128 bool required_for_activation_ : 1;
112 bool required_for_draw_ : 1; 129 bool required_for_draw_ : 1;
113 130
114 Id id_; 131 Id id_;
115 static Id s_next_id_; 132 static Id s_next_id_;
116 133
117 // The rect bounding the changes in this Tile vs the previous tile it 134 // The rect bounding the changes in this Tile vs the previous tile it
118 // replaced. 135 // replaced.
119 gfx::Rect invalidated_content_rect_; 136 gfx::Rect invalidated_content_rect_;
120 // The |id_| of the Tile that was invalidated and replaced by this tile. 137 // The |id_| of the Tile that was invalidated and replaced by this tile.
121 Id invalidated_id_; 138 Id invalidated_id_;
122 139
123 unsigned scheduled_priority_; 140 unsigned scheduled_priority_;
124 141
125 scoped_refptr<RasterTask> raster_task_; 142 scoped_refptr<RasterTask> raster_task_;
126 143
127 DISALLOW_COPY_AND_ASSIGN(Tile); 144 DISALLOW_COPY_AND_ASSIGN(Tile);
128 }; 145 };
129 146
130 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>; 147 using ScopedTilePtr = scoped_ptr<Tile, Tile::Deleter>;
131 148
132 } // namespace cc 149 } // namespace cc
133 150
134 #endif // CC_TILES_TILE_H_ 151 #endif // CC_TILES_TILE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698