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

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

Issue 62283012: cc: Added tile bundles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2013 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_RESOURCES_TILE_BUNDLE_H_
6 #define CC_RESOURCES_TILE_BUNDLE_H_
7
8 #include <utility>
9
10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ref_counted.h"
12 #include "cc/base/ref_counted_managed.h"
13 #include "cc/resources/tile_priority.h"
14
15 namespace cc {
16
17 class TileManager;
18 class Tile;
19 class PictureLayerTilingClient;
20 class PictureLayerTiling;
21 class CC_EXPORT TileBundle : public RefCountedManaged<TileBundle> {
22 public:
23 typedef uint64 Id;
24 typedef std::pair<int, int> TileMapKey;
25 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
26
27 inline Id id() const { return id_; }
28
29 Tile* TileAt(int index_x, int index_y);
30 bool RemoveTileAt(int index_x, int index_y);
31 void AddTileAt(int index_x,
32 int index_y,
33 scoped_refptr<Tile> tile);
34 size_t TileCount() const;
35
36 void DidBecomeRecycled();
37 void DidBecomeActive();
38
39 TileBundle* GetTwinBundle();
40 bool IsRecycled() const;
41 bool IsActive() const;
42 bool IsPending() const;
43
44
45 void SetClient(PictureLayerTilingClient* client) {
46 client_ = client;
47 }
48
49 void SetTiling(PictureLayerTiling* tiling) {
50 tiling_ = tiling;
51 }
52
53 void MarkRequiredForActivation() {
54 priority_.required_for_activation = true;
55 }
56
57 void SetPriority(const TilePriority& priority) {
58 priority_ = priority;
59 }
60
61 TilePriority GetPriority() const {
62 return priority_;
63 }
64
65 class Iterator {
66 public:
67 explicit Iterator(TileBundle* bundle);
68 ~Iterator();
69
70 inline Iterator& operator++() {
71 DCHECK(iterator_ != bundle_->tiles_.end());
72 ++iterator_;
73 return *this;
74 }
75
76 inline Tile* operator*() { return iterator_->second.get(); }
77 inline Tile* operator->() { return iterator_->second.get(); }
78 inline operator bool() const { return iterator_ != bundle_->tiles_.end(); }
79
80 inline int index_x() {
81 return iterator_->first.first + bundle_->offset_x_;
82 }
83 inline int index_y() {
84 return iterator_->first.second + bundle_->offset_y_;
85 }
86
87 private:
88 TileBundle* bundle_;
89 TileBundle::TileMap::const_iterator iterator_;
90 };
91
92 private:
93 friend class TileManager;
94 friend class Iterator;
95
96 TileBundle(TileManager* tile_manager,
97 int width,
98 int height,
99 int offset_x,
100 int offset_y);
101 ~TileBundle();
102
103 TileMapKey ComputeLocalIndex(int index_x, int index_y);
104
105 PictureLayerTiling* tiling_;
106
107 TileMap tiles_;
enne (OOO) 2013/11/20 21:20:30 I wonder if there's a way to do this generally but
108 int width_;
enne (OOO) 2013/11/20 21:20:30 Do bundles need their width/height/offset explicit
109 int height_;
110 int offset_x_;
111 int offset_y_;
112
113 TilePriority priority_;
114 PictureLayerTilingClient* client_;
enne (OOO) 2013/11/20 21:20:30 I wish this wasn't necessary.
115
116 Id id_;
117 static Id s_next_id_;
118 };
119
120 } // namespace cc
121
122 #endif // CC_RESOURCES_TILE_BUNDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698