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_PICTURE_LAYER_TILING_H_ | 5 #ifndef CC_PICTURE_LAYER_TILING_H_ |
6 #define CC_PICTURE_LAYER_TILING_H_ | 6 #define CC_PICTURE_LAYER_TILING_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 int right_; | 79 int right_; |
80 int bottom_; | 80 int bottom_; |
81 | 81 |
82 friend class PictureLayerTiling; | 82 friend class PictureLayerTiling; |
83 }; | 83 }; |
84 | 84 |
85 Region OpaqueRegionInContentRect(const gfx::Rect&) const; | 85 Region OpaqueRegionInContentRect(const gfx::Rect&) const; |
86 | 86 |
87 void Reset() { return tiles_.clear(); } | 87 void Reset() { return tiles_.clear(); } |
88 | 88 |
| 89 void UpdateTilePriorities(const gfx::Size& view_port, |
| 90 const gfx::Transform& last_transform, |
| 91 const gfx::Transform& current_transform, |
| 92 double time_delta); |
| 93 |
89 protected: | 94 protected: |
| 95 // TODO(qinmin): modify ui/range/Range.h to support template so that we |
| 96 // don't need to define this. |
| 97 struct Range { |
| 98 Range(double start, double end) : start_(start), end_(end) {} |
| 99 Range Intersects(const Range& other); |
| 100 bool IsEmpty(); |
| 101 double start_; |
| 102 double end_; |
| 103 }; |
| 104 |
90 typedef std::pair<int, int> TileMapKey; | 105 typedef std::pair<int, int> TileMapKey; |
91 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; | 106 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; |
92 | 107 |
93 PictureLayerTiling(float contents_scale, gfx::Size tileSize); | 108 PictureLayerTiling(float contents_scale, gfx::Size tileSize); |
94 Tile* TileAt(int, int) const; | 109 Tile* TileAt(int, int) const; |
95 void CreateTile(int i, int j); | 110 void CreateTile(int i, int j); |
96 | 111 |
| 112 // Calculate the time for the |current_bounds| to intersect with the |
| 113 // |target_bounds| given its previous location and time delta. |
| 114 // This function should work for both scaling and scrolling case. |
| 115 double TimeForBoundsToIntersect(gfx::Rect previous_bounds, |
| 116 gfx::Rect current_bounds, |
| 117 double time_delta, |
| 118 gfx::Rect target_bounds); |
| 119 |
| 120 // Calculate a time range that |value| will be larger than |threshold| |
| 121 // given the velocity of its change. |
| 122 Range TimeRangeValueLargerThanThreshold(int value, |
| 123 int threshold, |
| 124 double velocity); |
| 125 |
97 PictureLayerTilingClient* client_; | 126 PictureLayerTilingClient* client_; |
98 float contents_scale_; | 127 float contents_scale_; |
99 gfx::Size layer_bounds_; | 128 gfx::Size layer_bounds_; |
100 TileMap tiles_; | 129 TileMap tiles_; |
101 TilingData tiling_data_; | 130 TilingData tiling_data_; |
102 | 131 |
103 friend class Iterator; | 132 friend class Iterator; |
| 133 friend class PictureLayerTilingTest; |
104 }; | 134 }; |
105 | 135 |
106 } // namespace cc | 136 } // namespace cc |
107 | 137 |
108 #endif // CC_PICTURE_LAYER_TILING_H_ | 138 #endif // CC_PICTURE_LAYER_TILING_H_ |
OLD | NEW |