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

Side by Side Diff: cc/resources/picture_layer_tiling.h

Issue 1127253002: Revert "cc: Remove Tile refcounting and RefCountedManaged." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/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
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_RESOURCES_PICTURE_LAYER_TILING_H_ 5 #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_H_
6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_ 6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/containers/scoped_ptr_hash_map.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
16 #include "cc/base/region.h" 16 #include "cc/base/region.h"
17 #include "cc/base/tiling_data.h" 17 #include "cc/base/tiling_data.h"
18 #include "cc/resources/tile.h" 18 #include "cc/resources/tile.h"
19 #include "cc/resources/tile_priority.h" 19 #include "cc/resources/tile_priority.h"
20 #include "cc/trees/occlusion.h" 20 #include "cc/trees/occlusion.h"
21 #include "ui/gfx/geometry/rect.h" 21 #include "ui/gfx/geometry/rect.h"
22 22
23 namespace base { 23 namespace base {
24 namespace trace_event { 24 namespace trace_event {
25 class TracedValue; 25 class TracedValue;
26 } 26 }
27 } 27 }
28 28
29 namespace cc { 29 namespace cc {
30 30
31 class PictureLayerTiling; 31 class PictureLayerTiling;
32 class RasterSource; 32 class RasterSource;
33 33
34 class CC_EXPORT PictureLayerTilingClient { 34 class CC_EXPORT PictureLayerTilingClient {
35 public: 35 public:
36 // Create a tile at the given content_rect (in the contents scale of the 36 // Create a tile at the given content_rect (in the contents scale of the
37 // tiling) This might return null if the client cannot create such a tile. 37 // tiling) This might return null if the client cannot create such a tile.
38 virtual ScopedTilePtr CreateTile(float contents_scale, 38 virtual scoped_refptr<Tile> CreateTile(float contents_scale,
39 const gfx::Rect& content_rect) = 0; 39 const gfx::Rect& content_rect) = 0;
40 virtual gfx::Size CalculateTileSize( 40 virtual gfx::Size CalculateTileSize(
41 const gfx::Size& content_bounds) const = 0; 41 const gfx::Size& content_bounds) const = 0;
42 // This invalidation region defines the area (if any, it can by null) that 42 // This invalidation region defines the area (if any, it can by null) that
43 // tiles can not be shared between pending and active trees. 43 // tiles can not be shared between pending and active trees.
44 virtual const Region* GetPendingInvalidation() = 0; 44 virtual const Region* GetPendingInvalidation() = 0;
45 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling( 45 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling(
46 const PictureLayerTiling* tiling) const = 0; 46 const PictureLayerTiling* tiling) const = 0;
47 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0; 47 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0;
48 virtual bool RequiresHighResToDraw() const = 0; 48 virtual bool RequiresHighResToDraw() const = 0;
49 49
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 RasterSource* raster_source() const { return raster_source_.get(); } 91 RasterSource* raster_source() const { return raster_source_.get(); }
92 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } 92 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); }
93 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 93 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
94 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 94 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
95 float contents_scale() const { return contents_scale_; } 95 float contents_scale() const { return contents_scale_; }
96 const TilingData* tiling_data() const { return &tiling_data_; } 96 const TilingData* tiling_data() const { return &tiling_data_; }
97 97
98 Tile* TileAt(int i, int j) const { 98 Tile* TileAt(int i, int j) const {
99 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 99 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
100 return iter == tiles_.end() ? nullptr : iter->second; 100 return iter == tiles_.end() ? nullptr : iter->second.get();
101 } 101 }
102 102
103 bool has_tiles() const { return !tiles_.empty(); } 103 bool has_tiles() const { return !tiles_.empty(); }
104 104
105 // For testing functionality. 105 // For testing functionality.
106 void CreateAllTilesForTesting() { 106 void CreateAllTilesForTesting() {
107 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); 107 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size()));
108 } 108 }
109 const TilingData& TilingDataForTesting() const { return tiling_data_; } 109 const TilingData& TilingDataForTesting() const { return tiling_data_; }
110 std::vector<Tile*> AllTilesForTesting() const { 110 std::vector<Tile*> AllTilesForTesting() const {
111 std::vector<Tile*> all_tiles; 111 std::vector<Tile*> all_tiles;
112 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 112 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
113 all_tiles.push_back(it->second.get());
114 return all_tiles;
115 }
116 void UpdateAllTilePrioritiesForTesting() {
117 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
118 UpdateTilePriority(it->second.get());
119 }
120 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const {
121 std::vector<scoped_refptr<Tile>> all_tiles;
122 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
113 all_tiles.push_back(it->second); 123 all_tiles.push_back(it->second);
114 return all_tiles; 124 return all_tiles;
115 } 125 }
116 void UpdateAllTilePrioritiesForTesting() {
117 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
118 UpdateTilePriority(it->second);
119 }
120 void SetAllTilesOccludedForTesting() { 126 void SetAllTilesOccludedForTesting() {
121 gfx::Rect viewport_in_layer_space = 127 gfx::Rect viewport_in_layer_space =
122 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); 128 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_);
123 current_occlusion_in_layer_space_ = 129 current_occlusion_in_layer_space_ =
124 Occlusion(gfx::Transform(), 130 Occlusion(gfx::Transform(),
125 SimpleEnclosedRegion(viewport_in_layer_space), 131 SimpleEnclosedRegion(viewport_in_layer_space),
126 SimpleEnclosedRegion(viewport_in_layer_space)); 132 SimpleEnclosedRegion(viewport_in_layer_space));
127 } 133 }
128 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 134 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
129 return current_visible_rect_; 135 return current_visible_rect_;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 int64 target_area, 208 int64 target_area,
203 const gfx::Rect& bounding_rect, 209 const gfx::Rect& bounding_rect,
204 RectExpansionCache* cache); 210 RectExpansionCache* cache);
205 211
206 protected: 212 protected:
207 friend class CoverageIterator; 213 friend class CoverageIterator;
208 friend class TilingSetRasterQueueAll; 214 friend class TilingSetRasterQueueAll;
209 friend class TilingSetRasterQueueRequired; 215 friend class TilingSetRasterQueueRequired;
210 friend class TilingSetEvictionQueue; 216 friend class TilingSetEvictionQueue;
211 217
212 using TileMapKey = std::pair<int, int>; 218 typedef std::pair<int, int> TileMapKey;
213 using TileMap = base::ScopedPtrHashMap<TileMapKey, ScopedTilePtr>; 219 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap;
214 220
215 struct FrameVisibleRect { 221 struct FrameVisibleRect {
216 gfx::Rect visible_rect_in_content_space; 222 gfx::Rect visible_rect_in_content_space;
217 double frame_time_in_seconds = 0.0; 223 double frame_time_in_seconds = 0.0;
218 }; 224 };
219 225
220 PictureLayerTiling(WhichTree tree, 226 PictureLayerTiling(WhichTree tree,
221 float contents_scale, 227 float contents_scale,
222 scoped_refptr<RasterSource> raster_source, 228 scoped_refptr<RasterSource> raster_source,
223 PictureLayerTilingClient* client, 229 PictureLayerTilingClient* client,
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 346
341 private: 347 private:
342 DISALLOW_ASSIGN(PictureLayerTiling); 348 DISALLOW_ASSIGN(PictureLayerTiling);
343 349
344 RectExpansionCache expansion_cache_; 350 RectExpansionCache expansion_cache_;
345 }; 351 };
346 352
347 } // namespace cc 353 } // namespace cc
348 354
349 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 355 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698