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

Side by Side Diff: cc/layer_tiling_data.cc

Issue 11264056: cc: Use gfx:: Geometry types for positions, bounds, and related things. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ScaleAsVector Created 8 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
« no previous file with comments | « cc/layer_tiling_data.h ('k') | cc/layer_tree_host.h » ('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 "cc/layer_tiling_data.h" 8 #include "cc/layer_tiling_data.h"
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 11
12 using namespace std; 12 using namespace std;
13 13
14 namespace cc { 14 namespace cc {
15 15
16 scoped_ptr<LayerTilingData> LayerTilingData::create(const IntSize& tileSize, Bor derTexelOption border) 16 scoped_ptr<LayerTilingData> LayerTilingData::create(const gfx::Size& tileSize, B orderTexelOption border)
17 { 17 {
18 return make_scoped_ptr(new LayerTilingData(tileSize, border)); 18 return make_scoped_ptr(new LayerTilingData(tileSize, border));
19 } 19 }
20 20
21 LayerTilingData::LayerTilingData(const IntSize& tileSize, BorderTexelOption bord er) 21 LayerTilingData::LayerTilingData(const gfx::Size& tileSize, BorderTexelOption bo rder)
22 : m_tilingData(tileSize, IntSize(), border == HasBorderTexels) 22 : m_tilingData(cc::IntSize(tileSize), cc::IntSize(), border == HasBorderTexe ls)
23 { 23 {
24 setTileSize(tileSize); 24 setTileSize(tileSize);
25 } 25 }
26 26
27 LayerTilingData::~LayerTilingData() 27 LayerTilingData::~LayerTilingData()
28 { 28 {
29 } 29 }
30 30
31 void LayerTilingData::setTileSize(const IntSize& size) 31 void LayerTilingData::setTileSize(const gfx::Size& size)
32 { 32 {
33 if (tileSize() == size) 33 if (tileSize() == size)
34 return; 34 return;
35 35
36 reset(); 36 reset();
37 37
38 m_tilingData.setMaxTextureSize(size); 38 m_tilingData.setMaxTextureSize(cc::IntSize(size));
39 } 39 }
40 40
41 IntSize LayerTilingData::tileSize() const 41 gfx::Size LayerTilingData::tileSize() const
42 { 42 {
43 return m_tilingData.maxTextureSize(); 43 return cc::IntSize(m_tilingData.maxTextureSize());
44 } 44 }
45 45
46 void LayerTilingData::setBorderTexelOption(BorderTexelOption borderTexelOption) 46 void LayerTilingData::setBorderTexelOption(BorderTexelOption borderTexelOption)
47 { 47 {
48 bool borderTexels = borderTexelOption == HasBorderTexels; 48 bool borderTexels = borderTexelOption == HasBorderTexels;
49 if (hasBorderTexels() == borderTexels) 49 if (hasBorderTexels() == borderTexels)
50 return; 50 return;
51 51
52 reset(); 52 reset();
53 m_tilingData.setHasBorderTexels(borderTexels); 53 m_tilingData.setHasBorderTexels(borderTexels);
(...skipping 21 matching lines...) Expand all
75 LayerTilingData::Tile* LayerTilingData::tileAt(int i, int j) const 75 LayerTilingData::Tile* LayerTilingData::tileAt(int i, int j) const
76 { 76 {
77 return m_tiles.get(make_pair(i, j)); 77 return m_tiles.get(make_pair(i, j));
78 } 78 }
79 79
80 void LayerTilingData::reset() 80 void LayerTilingData::reset()
81 { 81 {
82 m_tiles.clear(); 82 m_tiles.clear();
83 } 83 }
84 84
85 void LayerTilingData::contentRectToTileIndices(const IntRect& contentRect, int& left, int& top, int& right, int& bottom) const 85 void LayerTilingData::contentRectToTileIndices(const gfx::Rect& contentRect, int & left, int& top, int& right, int& bottom) const
86 { 86 {
87 // An empty rect doesn't result in an empty set of tiles, so don't pass an e mpty rect. 87 // An empty rect doesn't result in an empty set of tiles, so don't pass an e mpty rect.
88 // FIXME: Possibly we should fill a vector of tiles instead, 88 // FIXME: Possibly we should fill a vector of tiles instead,
89 // since the normal use of this function is to enumerate some tiles. 89 // since the normal use of this function is to enumerate some tiles.
90 DCHECK(!contentRect.isEmpty()); 90 DCHECK(!contentRect.IsEmpty());
91 91
92 left = m_tilingData.tileXIndexFromSrcCoord(contentRect.x()); 92 left = m_tilingData.tileXIndexFromSrcCoord(contentRect.x());
93 top = m_tilingData.tileYIndexFromSrcCoord(contentRect.y()); 93 top = m_tilingData.tileYIndexFromSrcCoord(contentRect.y());
94 right = m_tilingData.tileXIndexFromSrcCoord(contentRect.maxX() - 1); 94 right = m_tilingData.tileXIndexFromSrcCoord(contentRect.right() - 1);
95 bottom = m_tilingData.tileYIndexFromSrcCoord(contentRect.maxY() - 1); 95 bottom = m_tilingData.tileYIndexFromSrcCoord(contentRect.bottom() - 1);
96 } 96 }
97 97
98 IntRect LayerTilingData::tileRect(const Tile* tile) const 98 gfx::Rect LayerTilingData::tileRect(const Tile* tile) const
99 { 99 {
100 IntRect tileRect = m_tilingData.tileBoundsWithBorder(tile->i(), tile->j()); 100 gfx::Rect tileRect = cc::IntRect(m_tilingData.tileBoundsWithBorder(tile->i() , tile->j()));
101 tileRect.setSize(tileSize()); 101 tileRect.set_size(tileSize());
102 return tileRect; 102 return tileRect;
103 } 103 }
104 104
105 Region LayerTilingData::opaqueRegionInContentRect(const IntRect& contentRect) co nst 105 Region LayerTilingData::opaqueRegionInContentRect(const gfx::Rect& contentRect) const
106 { 106 {
107 if (contentRect.isEmpty()) 107 if (contentRect.IsEmpty())
108 return Region(); 108 return Region();
109 109
110 Region opaqueRegion; 110 Region opaqueRegion;
111 int left, top, right, bottom; 111 int left, top, right, bottom;
112 contentRectToTileIndices(contentRect, left, top, right, bottom); 112 contentRectToTileIndices(contentRect, left, top, right, bottom);
113 for (int j = top; j <= bottom; ++j) { 113 for (int j = top; j <= bottom; ++j) {
114 for (int i = left; i <= right; ++i) { 114 for (int i = left; i <= right; ++i) {
115 Tile* tile = tileAt(i, j); 115 Tile* tile = tileAt(i, j);
116 if (!tile) 116 if (!tile)
117 continue; 117 continue;
118 118
119 IntRect tileOpaqueRect = intersection(contentRect, tile->opaqueRect( )); 119 gfx::Rect tileOpaqueRect = gfx::IntersectRects(contentRect, tile->op aqueRect());
120 opaqueRegion.unite(tileOpaqueRect); 120 opaqueRegion.unite(cc::IntRect(tileOpaqueRect));
121 } 121 }
122 } 122 }
123 return opaqueRegion; 123 return opaqueRegion;
124 } 124 }
125 125
126 void LayerTilingData::setBounds(const IntSize& size) 126 void LayerTilingData::setBounds(const gfx::Size& size)
127 { 127 {
128 m_tilingData.setTotalSize(size); 128 m_tilingData.setTotalSize(cc::IntSize(size));
129 if (size.isEmpty()) { 129 if (size.IsEmpty()) {
130 m_tiles.clear(); 130 m_tiles.clear();
131 return; 131 return;
132 } 132 }
133 133
134 // Any tiles completely outside our new bounds are invalid and should be dro pped. 134 // Any tiles completely outside our new bounds are invalid and should be dro pped.
135 int left, top, right, bottom; 135 int left, top, right, bottom;
136 contentRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom ); 136 contentRectToTileIndices(gfx::Rect(gfx::Point(), size), left, top, right, bo ttom);
137 std::vector<TileMapKey> invalidTileKeys; 137 std::vector<TileMapKey> invalidTileKeys;
138 for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it ) { 138 for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it ) {
139 if (it->first.first > right || it->first.second > bottom) 139 if (it->first.first > right || it->first.second > bottom)
140 invalidTileKeys.push_back(it->first); 140 invalidTileKeys.push_back(it->first);
141 } 141 }
142 for (size_t i = 0; i < invalidTileKeys.size(); ++i) 142 for (size_t i = 0; i < invalidTileKeys.size(); ++i)
143 m_tiles.erase(invalidTileKeys[i]); 143 m_tiles.erase(invalidTileKeys[i]);
144 } 144 }
145 145
146 IntSize LayerTilingData::bounds() const 146 gfx::Size LayerTilingData::bounds() const
147 { 147 {
148 return m_tilingData.totalSize(); 148 return cc::IntSize(m_tilingData.totalSize());
149 } 149 }
150 150
151 } // namespace cc 151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tiling_data.h ('k') | cc/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698