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

Side by Side Diff: cc/layer_tiling_data.cc

Issue 11359030: Create cc::TilingData based on WebCore::TilingData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 "IntRect.h"
11 #include "IntSize.h"
12 #include "base/logging.h" 10 #include "base/logging.h"
13 11
14 using namespace std; 12 using namespace std;
15 13
16 namespace cc { 14 namespace cc {
17 15
18 scoped_ptr<LayerTilingData> LayerTilingData::create(const gfx::Size& tileSize, B orderTexelOption border) 16 scoped_ptr<LayerTilingData> LayerTilingData::create(const gfx::Size& tileSize, B orderTexelOption border)
19 { 17 {
20 return make_scoped_ptr(new LayerTilingData(tileSize, border)); 18 return make_scoped_ptr(new LayerTilingData(tileSize, border));
21 } 19 }
22 20
23 LayerTilingData::LayerTilingData(const gfx::Size& tileSize, BorderTexelOption bo rder) 21 LayerTilingData::LayerTilingData(const gfx::Size& tileSize, BorderTexelOption bo rder)
24 : m_tilingData(cc::IntSize(tileSize), cc::IntSize(), border == HasBorderTexe ls) 22 : m_tilingData(tileSize, gfx::Size(), border == HasBorderTexels)
25 { 23 {
26 setTileSize(tileSize); 24 setTileSize(tileSize);
27 } 25 }
28 26
29 LayerTilingData::~LayerTilingData() 27 LayerTilingData::~LayerTilingData()
30 { 28 {
31 } 29 }
32 30
33 void LayerTilingData::setTileSize(const gfx::Size& size) 31 void LayerTilingData::setTileSize(const gfx::Size& size)
34 { 32 {
35 if (tileSize() == size) 33 if (tileSize() == size)
36 return; 34 return;
37 35
38 reset(); 36 reset();
39 37
40 m_tilingData.setMaxTextureSize(cc::IntSize(size)); 38 m_tilingData.SetMaxTextureSize(size);
41 } 39 }
42 40
43 gfx::Size LayerTilingData::tileSize() const 41 gfx::Size LayerTilingData::tileSize() const
44 { 42 {
45 return cc::IntSize(m_tilingData.maxTextureSize()); 43 return m_tilingData.max_texture_size();
46 } 44 }
47 45
48 void LayerTilingData::setBorderTexelOption(BorderTexelOption borderTexelOption) 46 void LayerTilingData::setBorderTexelOption(BorderTexelOption borderTexelOption)
49 { 47 {
50 bool borderTexels = borderTexelOption == HasBorderTexels; 48 bool borderTexels = borderTexelOption == HasBorderTexels;
51 if (hasBorderTexels() == borderTexels) 49 if (hasBorderTexels() == borderTexels)
52 return; 50 return;
53 51
54 reset(); 52 reset();
55 m_tilingData.setHasBorderTexels(borderTexels); 53 m_tilingData.SetHasBorderTexels(borderTexels);
56 } 54 }
57 55
58 const LayerTilingData& LayerTilingData::operator=(const LayerTilingData& tiler) 56 const LayerTilingData& LayerTilingData::operator=(const LayerTilingData& tiler)
59 { 57 {
60 m_tilingData = tiler.m_tilingData; 58 m_tilingData = tiler.m_tilingData;
61 59
62 return *this; 60 return *this;
63 } 61 }
64 62
65 void LayerTilingData::addTile(scoped_ptr<Tile> tile, int i, int j) 63 void LayerTilingData::addTile(scoped_ptr<Tile> tile, int i, int j)
(...skipping 18 matching lines...) Expand all
84 m_tiles.clear(); 82 m_tiles.clear();
85 } 83 }
86 84
87 void LayerTilingData::contentRectToTileIndices(const gfx::Rect& 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
88 { 86 {
89 // 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.
90 // FIXME: Possibly we should fill a vector of tiles instead, 88 // FIXME: Possibly we should fill a vector of tiles instead,
91 // 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.
92 DCHECK(!contentRect.IsEmpty()); 90 DCHECK(!contentRect.IsEmpty());
93 91
94 left = m_tilingData.tileXIndexFromSrcCoord(contentRect.x()); 92 left = m_tilingData.TileXIndexFromSrcCoord(contentRect.x());
95 top = m_tilingData.tileYIndexFromSrcCoord(contentRect.y()); 93 top = m_tilingData.TileYIndexFromSrcCoord(contentRect.y());
96 right = m_tilingData.tileXIndexFromSrcCoord(contentRect.right() - 1); 94 right = m_tilingData.TileXIndexFromSrcCoord(contentRect.right() - 1);
97 bottom = m_tilingData.tileYIndexFromSrcCoord(contentRect.bottom() - 1); 95 bottom = m_tilingData.TileYIndexFromSrcCoord(contentRect.bottom() - 1);
98 } 96 }
99 97
100 gfx::Rect LayerTilingData::tileRect(const Tile* tile) const 98 gfx::Rect LayerTilingData::tileRect(const Tile* tile) const
101 { 99 {
102 gfx::Rect tileRect = cc::IntRect(m_tilingData.tileBoundsWithBorder(tile->i() , tile->j())); 100 gfx::Rect tileRect = m_tilingData.TileBoundsWithBorder(tile->i(), tile->j()) ;
103 tileRect.set_size(tileSize()); 101 tileRect.set_size(tileSize());
104 return tileRect; 102 return tileRect;
105 } 103 }
106 104
107 Region LayerTilingData::opaqueRegionInContentRect(const gfx::Rect& contentRect) const 105 Region LayerTilingData::opaqueRegionInContentRect(const gfx::Rect& contentRect) const
108 { 106 {
109 if (contentRect.IsEmpty()) 107 if (contentRect.IsEmpty())
110 return Region(); 108 return Region();
111 109
112 Region opaqueRegion; 110 Region opaqueRegion;
113 int left, top, right, bottom; 111 int left, top, right, bottom;
114 contentRectToTileIndices(contentRect, left, top, right, bottom); 112 contentRectToTileIndices(contentRect, left, top, right, bottom);
115 for (int j = top; j <= bottom; ++j) { 113 for (int j = top; j <= bottom; ++j) {
116 for (int i = left; i <= right; ++i) { 114 for (int i = left; i <= right; ++i) {
117 Tile* tile = tileAt(i, j); 115 Tile* tile = tileAt(i, j);
118 if (!tile) 116 if (!tile)
119 continue; 117 continue;
120 118
121 gfx::Rect tileOpaqueRect = gfx::IntersectRects(contentRect, tile->op aqueRect()); 119 gfx::Rect tileOpaqueRect = gfx::IntersectRects(contentRect, tile->op aqueRect());
122 opaqueRegion.Union(tileOpaqueRect); 120 opaqueRegion.Union(tileOpaqueRect);
123 } 121 }
124 } 122 }
125 return opaqueRegion; 123 return opaqueRegion;
126 } 124 }
127 125
128 void LayerTilingData::setBounds(const gfx::Size& size) 126 void LayerTilingData::setBounds(const gfx::Size& size)
129 { 127 {
130 m_tilingData.setTotalSize(cc::IntSize(size)); 128 m_tilingData.SetTotalSize(size);
131 if (size.IsEmpty()) { 129 if (size.IsEmpty()) {
132 m_tiles.clear(); 130 m_tiles.clear();
133 return; 131 return;
134 } 132 }
135 133
136 // 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.
137 int left, top, right, bottom; 135 int left, top, right, bottom;
138 contentRectToTileIndices(gfx::Rect(gfx::Point(), size), left, top, right, bo ttom); 136 contentRectToTileIndices(gfx::Rect(gfx::Point(), size), left, top, right, bo ttom);
139 std::vector<TileMapKey> invalidTileKeys; 137 std::vector<TileMapKey> invalidTileKeys;
140 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 ) {
141 if (it->first.first > right || it->first.second > bottom) 139 if (it->first.first > right || it->first.second > bottom)
142 invalidTileKeys.push_back(it->first); 140 invalidTileKeys.push_back(it->first);
143 } 141 }
144 for (size_t i = 0; i < invalidTileKeys.size(); ++i) 142 for (size_t i = 0; i < invalidTileKeys.size(); ++i)
145 m_tiles.erase(invalidTileKeys[i]); 143 m_tiles.erase(invalidTileKeys[i]);
146 } 144 }
147 145
148 gfx::Size LayerTilingData::bounds() const 146 gfx::Size LayerTilingData::bounds() const
149 { 147 {
150 return cc::IntSize(m_tilingData.totalSize()); 148 return m_tilingData.total_size();
151 } 149 }
152 150
153 } // namespace cc 151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tiling_data.h ('k') | cc/stubs/TilingData.h » ('j') | cc/tiling_data.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698