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

Side by Side Diff: cc/CCLayerTilingData.cpp

Issue 11122003: [cc] Rename all cc/ filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/CCLayerTilingData.h ('k') | cc/CCLayerTreeHost.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5
6 #include "config.h"
7
8 #if USE(ACCELERATED_COMPOSITING)
9
10 #include "CCLayerTilingData.h"
11
12 using namespace std;
13
14 namespace cc {
15
16 PassOwnPtr<CCLayerTilingData> CCLayerTilingData::create(const IntSize& tileSize, BorderTexelOption border)
17 {
18 return adoptPtr(new CCLayerTilingData(tileSize, border));
19 }
20
21 CCLayerTilingData::CCLayerTilingData(const IntSize& tileSize, BorderTexelOption border)
22 : m_tilingData(tileSize, IntSize(), border == HasBorderTexels)
23 {
24 setTileSize(tileSize);
25 }
26
27 CCLayerTilingData::~CCLayerTilingData()
28 {
29 }
30
31 void CCLayerTilingData::setTileSize(const IntSize& size)
32 {
33 if (tileSize() == size)
34 return;
35
36 reset();
37
38 m_tilingData.setMaxTextureSize(size);
39 }
40
41 IntSize CCLayerTilingData::tileSize() const
42 {
43 return m_tilingData.maxTextureSize();
44 }
45
46 void CCLayerTilingData::setBorderTexelOption(BorderTexelOption borderTexelOption )
47 {
48 bool borderTexels = borderTexelOption == HasBorderTexels;
49 if (hasBorderTexels() == borderTexels)
50 return;
51
52 reset();
53 m_tilingData.setHasBorderTexels(borderTexels);
54 }
55
56 const CCLayerTilingData& CCLayerTilingData::operator=(const CCLayerTilingData& t iler)
57 {
58 m_tilingData = tiler.m_tilingData;
59
60 return *this;
61 }
62
63 void CCLayerTilingData::addTile(PassOwnPtr<Tile> tile, int i, int j)
64 {
65 ASSERT(!tileAt(i, j));
66 tile->moveTo(i, j);
67 m_tiles.add(make_pair(i, j), tile);
68 }
69
70 PassOwnPtr<CCLayerTilingData::Tile> CCLayerTilingData::takeTile(int i, int j)
71 {
72 return m_tiles.take(make_pair(i, j));
73 }
74
75 CCLayerTilingData::Tile* CCLayerTilingData::tileAt(int i, int j) const
76 {
77 return m_tiles.get(make_pair(i, j));
78 }
79
80 void CCLayerTilingData::reset()
81 {
82 m_tiles.clear();
83 }
84
85 void CCLayerTilingData::contentRectToTileIndices(const IntRect& contentRect, int & left, int& top, int& right, int& bottom) const
86 {
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,
89 // since the normal use of this function is to enumerate some tiles.
90 ASSERT(!contentRect.isEmpty());
91
92 left = m_tilingData.tileXIndexFromSrcCoord(contentRect.x());
93 top = m_tilingData.tileYIndexFromSrcCoord(contentRect.y());
94 right = m_tilingData.tileXIndexFromSrcCoord(contentRect.maxX() - 1);
95 bottom = m_tilingData.tileYIndexFromSrcCoord(contentRect.maxY() - 1);
96 }
97
98 IntRect CCLayerTilingData::tileRect(const Tile* tile) const
99 {
100 IntRect tileRect = m_tilingData.tileBoundsWithBorder(tile->i(), tile->j());
101 tileRect.setSize(tileSize());
102 return tileRect;
103 }
104
105 Region CCLayerTilingData::opaqueRegionInContentRect(const IntRect& contentRect) const
106 {
107 if (contentRect.isEmpty())
108 return Region();
109
110 Region opaqueRegion;
111 int left, top, right, bottom;
112 contentRectToTileIndices(contentRect, left, top, right, bottom);
113 for (int j = top; j <= bottom; ++j) {
114 for (int i = left; i <= right; ++i) {
115 Tile* tile = tileAt(i, j);
116 if (!tile)
117 continue;
118
119 IntRect tileOpaqueRect = intersection(contentRect, tile->opaqueRect( ));
120 opaqueRegion.unite(tileOpaqueRect);
121 }
122 }
123 return opaqueRegion;
124 }
125
126 void CCLayerTilingData::setBounds(const IntSize& size)
127 {
128 m_tilingData.setTotalSize(size);
129 if (size.isEmpty()) {
130 m_tiles.clear();
131 return;
132 }
133
134 // Any tiles completely outside our new bounds are invalid and should be dro pped.
135 int left, top, right, bottom;
136 contentRectToTileIndices(IntRect(IntPoint(), size), left, top, right, bottom );
137 Vector<TileMapKey> invalidTileKeys;
138 for (TileMap::const_iterator it = m_tiles.begin(); it != m_tiles.end(); ++it ) {
139 #if WTF_NEW_HASHMAP_ITERATORS_INTERFACE
140 if (it->key.first > right || it->key.second > bottom)
141 invalidTileKeys.append(it->key);
142 #else
143 if (it->first.first > right || it->first.second > bottom)
144 invalidTileKeys.append(it->first);
145 #endif
146 }
147 for (size_t i = 0; i < invalidTileKeys.size(); ++i)
148 m_tiles.remove(invalidTileKeys[i]);
149 }
150
151 IntSize CCLayerTilingData::bounds() const
152 {
153 return m_tilingData.totalSize();
154 }
155
156 } // namespace cc
157
158 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « cc/CCLayerTilingData.h ('k') | cc/CCLayerTreeHost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698