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

Side by Side Diff: cc/layer_tiling_data.cc

Issue 11144023: cc: Store tiles, painters, tiling data in scoped_ptr (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 2 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/layer_tiling_data.h ('k') | cc/layer_tree_host_impl_unittest.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 5
6 #include "config.h" 6 #include "config.h"
7 7
8 #include "CCLayerTilingData.h" 8 #include "CCLayerTilingData.h"
9 9
10 using namespace std; 10 using namespace std;
11 11
12 namespace cc { 12 namespace cc {
13 13
14 PassOwnPtr<CCLayerTilingData> CCLayerTilingData::create(const IntSize& tileSize, BorderTexelOption border) 14 scoped_ptr<CCLayerTilingData> CCLayerTilingData::create(const IntSize& tileSize, BorderTexelOption border)
15 { 15 {
16 return adoptPtr(new CCLayerTilingData(tileSize, border)); 16 return make_scoped_ptr(new CCLayerTilingData(tileSize, border));
17 } 17 }
18 18
19 CCLayerTilingData::CCLayerTilingData(const IntSize& tileSize, BorderTexelOption border) 19 CCLayerTilingData::CCLayerTilingData(const IntSize& tileSize, BorderTexelOption border)
20 : m_tilingData(tileSize, IntSize(), border == HasBorderTexels) 20 : m_tilingData(tileSize, IntSize(), border == HasBorderTexels)
21 { 21 {
22 setTileSize(tileSize); 22 setTileSize(tileSize);
23 } 23 }
24 24
25 CCLayerTilingData::~CCLayerTilingData() 25 CCLayerTilingData::~CCLayerTilingData()
26 { 26 {
(...skipping 24 matching lines...) Expand all
51 m_tilingData.setHasBorderTexels(borderTexels); 51 m_tilingData.setHasBorderTexels(borderTexels);
52 } 52 }
53 53
54 const CCLayerTilingData& CCLayerTilingData::operator=(const CCLayerTilingData& t iler) 54 const CCLayerTilingData& CCLayerTilingData::operator=(const CCLayerTilingData& t iler)
55 { 55 {
56 m_tilingData = tiler.m_tilingData; 56 m_tilingData = tiler.m_tilingData;
57 57
58 return *this; 58 return *this;
59 } 59 }
60 60
61 void CCLayerTilingData::addTile(PassOwnPtr<Tile> tile, int i, int j) 61 void CCLayerTilingData::addTile(scoped_ptr<Tile> tile, int i, int j)
62 { 62 {
63 ASSERT(!tileAt(i, j)); 63 ASSERT(!tileAt(i, j));
64 tile->moveTo(i, j); 64 tile->moveTo(i, j);
65 m_tiles.add(make_pair(i, j), tile); 65 m_tiles.add(make_pair(i, j), tile.Pass());
66 } 66 }
67 67
68 PassOwnPtr<CCLayerTilingData::Tile> CCLayerTilingData::takeTile(int i, int j) 68 scoped_ptr<CCLayerTilingData::Tile> CCLayerTilingData::takeTile(int i, int j)
69 { 69 {
70 return m_tiles.take(make_pair(i, j)); 70 return m_tiles.take_and_erase(make_pair(i, j));
71 } 71 }
72 72
73 CCLayerTilingData::Tile* CCLayerTilingData::tileAt(int i, int j) const 73 CCLayerTilingData::Tile* CCLayerTilingData::tileAt(int i, int j) const
74 { 74 {
75 return m_tiles.get(make_pair(i, j)); 75 return m_tiles.get(make_pair(i, j));
76 } 76 }
77 77
78 void CCLayerTilingData::reset() 78 void CCLayerTilingData::reset()
79 { 79 {
80 m_tiles.clear(); 80 m_tiles.clear();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 if (size.isEmpty()) { 127 if (size.isEmpty()) {
128 m_tiles.clear(); 128 m_tiles.clear();
129 return; 129 return;
130 } 130 }
131 131
132 // Any tiles completely outside our new bounds are invalid and should be dro pped. 132 // Any tiles completely outside our new bounds are invalid and should be dro pped.
133 int left, top, right, bottom; 133 int left, top, right, bottom;
134 contentRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom ); 134 contentRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom );
135 Vector<TileMapKey> invalidTileKeys; 135 Vector<TileMapKey> invalidTileKeys;
136 for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it ) { 136 for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it ) {
137 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE
138 if (it->key.first > right || it->key.second > bottom)
139 invalidTileKeys.append(it->key);
140 #else
141 if (it->first.first > right || it->first.second > bottom) 137 if (it->first.first > right || it->first.second > bottom)
142 invalidTileKeys.append(it->first); 138 invalidTileKeys.append(it->first);
143 #endif
144 } 139 }
145 for (size_t i = 0; i < invalidTileKeys.size(); ++i) 140 for (size_t i = 0; i < invalidTileKeys.size(); ++i)
146 m_tiles.remove(invalidTileKeys[i]); 141 m_tiles.erase(invalidTileKeys[i]);
147 } 142 }
148 143
149 IntSize CCLayerTilingData::bounds() const 144 IntSize CCLayerTilingData::bounds() const
150 { 145 {
151 return m_tilingData.totalSize(); 146 return m_tilingData.totalSize();
152 } 147 }
153 148
154 } // namespace cc 149 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tiling_data.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698