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

Side by Side Diff: cc/picture_layer_tiling.h

Issue 12471007: Part 8 of cc/ directory shuffles: resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef CC_PICTURE_LAYER_TILING_H_
6 #define CC_PICTURE_LAYER_TILING_H_
7
8 #include "base/basictypes.h"
9 #include "base/hash_tables.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/base/cc_export.h"
12 #include "cc/base/hash_pair.h"
13 #include "cc/base/region.h"
14 #include "cc/base/tiling_data.h"
15 #include "cc/tile.h"
16 #include "cc/tile_priority.h"
17 #include "ui/gfx/rect.h"
18
19 namespace cc {
20
21 class PictureLayerTiling;
22
23 class PictureLayerTilingClient {
24 public:
25 // Create a tile at the given content_rect (in the contents scale of the
26 // tiling) This might return null if the client cannot create such a tile.
27 virtual scoped_refptr<Tile> CreateTile(
28 PictureLayerTiling* tiling,
29 gfx::Rect content_rect) = 0;
30 virtual void UpdatePile(Tile* tile) = 0;
31 virtual gfx::Size CalculateTileSize(
32 gfx::Size current_tile_size,
33 gfx::Size content_bounds) = 0;
34 };
35
36 class CC_EXPORT PictureLayerTiling {
37 public:
38 ~PictureLayerTiling();
39
40 // Create a tiling with no tiles. CreateTiles must be called to add some.
41 static scoped_ptr<PictureLayerTiling> Create(float contents_scale);
42 scoped_ptr<PictureLayerTiling> Clone() const;
43
44 gfx::Size layer_bounds() const { return layer_bounds_; }
45 void SetLayerBounds(gfx::Size layer_bounds);
46 void Invalidate(const Region& layer_invalidation);
47
48 // Add any tiles that intersect with |layer_rect|. If any tiles already
49 // exist, then this leaves them as-is.
50 void CreateTilesFromLayerRect(gfx::Rect layer_rect);
51
52 void SetClient(PictureLayerTilingClient* client);
53 void set_resolution(TileResolution resolution) { resolution_ = resolution; }
54 TileResolution resolution() const { return resolution_; }
55
56 gfx::Rect ContentRect() const;
57 gfx::SizeF ContentSizeF() const;
58 float contents_scale() const { return contents_scale_; }
59
60 std::vector<Tile*> AllTilesForTesting() const {
61 std::vector<Tile*> all_tiles;
62 for (TileMap::const_iterator it = tiles_.begin();
63 it != tiles_.end(); ++it)
64 all_tiles.push_back(it->second);
65 return all_tiles;
66 }
67
68 enum LayerDeviceAlignment {
69 LayerDeviceAlignmentUnknown,
70 LayerAlignedToDevice,
71 LayerNotAlignedToDevice,
72 };
73
74 static gfx::Rect ExpandRectEquallyToAreaBoundedBy(
75 gfx::Rect starting_rect,
76 int64 target_area,
77 gfx::Rect bounding_rect);
78
79 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
80 // (i.e. no valid resource) this tiling should still iterate over them.
81 // The union of all geometry_rect calls for each element iterated over should
82 // exactly equal content_rect and no two geometry_rects should intersect.
83 class CC_EXPORT Iterator {
84 public:
85 Iterator();
86 Iterator(const PictureLayerTiling* tiling,
87 float dest_scale,
88 gfx::Rect rect,
89 LayerDeviceAlignment layerDeviceAlignment);
90 ~Iterator();
91
92 // Visible rect (no borders), always in the space of content_rect,
93 // regardless of the contents scale of the tiling.
94 gfx::Rect geometry_rect() const;
95 // Texture rect (in texels) for geometry_rect
96 gfx::RectF texture_rect() const;
97 gfx::Size texture_size() const;
98
99 // Full rect (including borders) of the current tile, always in the space
100 // of content_rect, regardless of the contents scale of the tiling.
101 gfx::Rect full_tile_geometry_rect() const;
102
103 Tile* operator->() const { return current_tile_; }
104 Tile* operator*() const { return current_tile_; }
105
106 Iterator& operator++();
107 operator bool() const { return tile_j_ <= bottom_; }
108
109 private:
110 const PictureLayerTiling* tiling_;
111 gfx::Rect dest_rect_;
112 float dest_to_content_scale_;
113
114 Tile* current_tile_;
115 gfx::Rect current_geometry_rect_;
116 int tile_i_;
117 int tile_j_;
118 int left_;
119 int top_;
120 int right_;
121 int bottom_;
122
123 friend class PictureLayerTiling;
124 };
125
126 Region OpaqueRegionInContentRect(const gfx::Rect&) const;
127
128 void Reset() { return tiles_.clear(); }
129
130 void UpdateTilePriorities(
131 WhichTree tree,
132 gfx::Size device_viewport,
133 const gfx::RectF& viewport_in_layer_space,
134 gfx::Size last_layer_bounds,
135 gfx::Size current_layer_bounds,
136 float last_layer_contents_scale,
137 float current_layer_contents_scale,
138 const gfx::Transform& last_screen_transform,
139 const gfx::Transform& current_screen_transform,
140 int current_source_frame_number,
141 double current_frame_time,
142 bool store_screen_space_quads_on_tiles);
143
144 // Copies the src_tree priority into the dst_tree priority for all tiles.
145 // The src_tree priority is reset to the lowest priority possible. This
146 // also updates the pile on each tile to be the current client's pile.
147 void DidBecomeActive();
148
149 scoped_ptr<base::Value> AsValue() const;
150
151 protected:
152 typedef std::pair<int, int> TileMapKey;
153 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
154
155 PictureLayerTiling(float contents_scale);
156 Tile* TileAt(int, int) const;
157 void CreateTilesFromContentRect(gfx::Rect layer_rect);
158 void CreateTile(int i, int j);
159
160 PictureLayerTilingClient* client_;
161 float contents_scale_;
162 gfx::Size layer_bounds_;
163 gfx::Rect last_prioritized_rect_;
164 // It is not legal to have a NULL tile in the tiles_ map.
165 TileMap tiles_;
166 TilingData tiling_data_;
167 TileResolution resolution_;
168 int last_source_frame_number_;
169 double last_impl_frame_time_;
170
171 friend class Iterator;
172 };
173
174 } // namespace cc
175
176 #endif // CC_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/picture_layer_impl.h ('k') | cc/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698