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

Side by Side Diff: cc/tiled_layer_impl.cc

Issue 11189043: cc: Rename cc classes and members to match filenames (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
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 #include "config.h" 5 #include "config.h"
6 6
7 #include "CCTiledLayerImpl.h" 7 #include "CCTiledLayerImpl.h"
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 26 matching lines...) Expand all
37 static const int defaultCheckerboardColorRed = 241; 37 static const int defaultCheckerboardColorRed = 241;
38 static const int defaultCheckerboardColorGreen = 241; 38 static const int defaultCheckerboardColorGreen = 241;
39 static const int defaultCheckerboardColorBlue = 241; 39 static const int defaultCheckerboardColorBlue = 241;
40 static const int debugTileEvictedCheckerboardColorRed = 255; 40 static const int debugTileEvictedCheckerboardColorRed = 255;
41 static const int debugTileEvictedCheckerboardColorGreen = 200; 41 static const int debugTileEvictedCheckerboardColorGreen = 200;
42 static const int debugTileEvictedCheckerboardColorBlue = 200; 42 static const int debugTileEvictedCheckerboardColorBlue = 200;
43 static const int debugTileInvalidatedCheckerboardColorRed = 128; 43 static const int debugTileInvalidatedCheckerboardColorRed = 128;
44 static const int debugTileInvalidatedCheckerboardColorGreen = 200; 44 static const int debugTileInvalidatedCheckerboardColorGreen = 200;
45 static const int debugTileInvalidatedCheckerboardColorBlue = 245; 45 static const int debugTileInvalidatedCheckerboardColorBlue = 245;
46 46
47 class DrawableTile : public CCLayerTilingData::Tile { 47 class DrawableTile : public LayerTilingData::Tile {
48 public: 48 public:
49 static scoped_ptr<DrawableTile> create() { return make_scoped_ptr(new Drawab leTile()); } 49 static scoped_ptr<DrawableTile> create() { return make_scoped_ptr(new Drawab leTile()); }
50 50
51 CCResourceProvider::ResourceId resourceId() const { return m_resourceId; } 51 ResourceProvider::ResourceId resourceId() const { return m_resourceId; }
52 void setResourceId(CCResourceProvider::ResourceId resourceId) { m_resourceId = resourceId; } 52 void setResourceId(ResourceProvider::ResourceId resourceId) { m_resourceId = resourceId; }
53 53
54 private: 54 private:
55 DrawableTile() : m_resourceId(0) { } 55 DrawableTile() : m_resourceId(0) { }
56 56
57 CCResourceProvider::ResourceId m_resourceId; 57 ResourceProvider::ResourceId m_resourceId;
58 58
59 DISALLOW_COPY_AND_ASSIGN(DrawableTile); 59 DISALLOW_COPY_AND_ASSIGN(DrawableTile);
60 }; 60 };
61 61
62 CCTiledLayerImpl::CCTiledLayerImpl(int id) 62 TiledLayerImpl::TiledLayerImpl(int id)
63 : CCLayerImpl(id) 63 : LayerImpl(id)
64 , m_skipsDraw(true) 64 , m_skipsDraw(true)
65 , m_contentsSwizzled(false) 65 , m_contentsSwizzled(false)
66 { 66 {
67 } 67 }
68 68
69 CCTiledLayerImpl::~CCTiledLayerImpl() 69 TiledLayerImpl::~TiledLayerImpl()
70 { 70 {
71 } 71 }
72 72
73 CCResourceProvider::ResourceId CCTiledLayerImpl::contentsResourceId() const 73 ResourceProvider::ResourceId TiledLayerImpl::contentsResourceId() const
74 { 74 {
75 // This function is only valid for single texture layers, e.g. masks. 75 // This function is only valid for single texture layers, e.g. masks.
76 ASSERT(m_tiler); 76 ASSERT(m_tiler);
77 ASSERT(m_tiler->numTilesX() == 1); 77 ASSERT(m_tiler->numTilesX() == 1);
78 ASSERT(m_tiler->numTilesY() == 1); 78 ASSERT(m_tiler->numTilesY() == 1);
79 79
80 DrawableTile* tile = tileAt(0, 0); 80 DrawableTile* tile = tileAt(0, 0);
81 CCResourceProvider::ResourceId resourceId = tile ? tile->resourceId() : 0; 81 ResourceProvider::ResourceId resourceId = tile ? tile->resourceId() : 0;
82 return resourceId; 82 return resourceId;
83 } 83 }
84 84
85 void CCTiledLayerImpl::dumpLayerProperties(std::string* str, int indent) const 85 void TiledLayerImpl::dumpLayerProperties(std::string* str, int indent) const
86 { 86 {
87 str->append(indentString(indent)); 87 str->append(indentString(indent));
88 base::StringAppendF(str, "skipsDraw: %d\n", (!m_tiler || m_skipsDraw)); 88 base::StringAppendF(str, "skipsDraw: %d\n", (!m_tiler || m_skipsDraw));
89 CCLayerImpl::dumpLayerProperties(str, indent); 89 LayerImpl::dumpLayerProperties(str, indent);
90 } 90 }
91 91
92 bool CCTiledLayerImpl::hasTileAt(int i, int j) const 92 bool TiledLayerImpl::hasTileAt(int i, int j) const
93 { 93 {
94 return m_tiler->tileAt(i, j); 94 return m_tiler->tileAt(i, j);
95 } 95 }
96 96
97 bool CCTiledLayerImpl::hasResourceIdForTileAt(int i, int j) const 97 bool TiledLayerImpl::hasResourceIdForTileAt(int i, int j) const
98 { 98 {
99 return hasTileAt(i, j) && tileAt(i, j)->resourceId(); 99 return hasTileAt(i, j) && tileAt(i, j)->resourceId();
100 } 100 }
101 101
102 DrawableTile* CCTiledLayerImpl::tileAt(int i, int j) const 102 DrawableTile* TiledLayerImpl::tileAt(int i, int j) const
103 { 103 {
104 return static_cast<DrawableTile*>(m_tiler->tileAt(i, j)); 104 return static_cast<DrawableTile*>(m_tiler->tileAt(i, j));
105 } 105 }
106 106
107 DrawableTile* CCTiledLayerImpl::createTile(int i, int j) 107 DrawableTile* TiledLayerImpl::createTile(int i, int j)
108 { 108 {
109 scoped_ptr<DrawableTile> tile(DrawableTile::create()); 109 scoped_ptr<DrawableTile> tile(DrawableTile::create());
110 DrawableTile* addedTile = tile.get(); 110 DrawableTile* addedTile = tile.get();
111 m_tiler->addTile(tile.PassAs<CCLayerTilingData::Tile>(), i, j); 111 m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j);
112 return addedTile; 112 return addedTile;
113 } 113 }
114 114
115 void CCTiledLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appe ndQuadsData) 115 void TiledLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad sData)
116 { 116 {
117 const IntRect& contentRect = visibleContentRect(); 117 const IntRect& contentRect = visibleContentRect();
118 118
119 if (!m_tiler || m_tiler->hasEmptyBounds() || contentRect.isEmpty()) 119 if (!m_tiler || m_tiler->hasEmptyBounds() || contentRect.isEmpty())
120 return; 120 return;
121 121
122 CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createShare dQuadState()); 122 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState());
123 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); 123 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
124 124
125 int left, top, right, bottom; 125 int left, top, right, bottom;
126 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); 126 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom);
127 127
128 if (hasDebugBorders()) { 128 if (hasDebugBorders()) {
129 for (int j = top; j <= bottom; ++j) { 129 for (int j = top; j <= bottom; ++j) {
130 for (int i = left; i <= right; ++i) { 130 for (int i = left; i <= right; ++i) {
131 DrawableTile* tile = tileAt(i, j); 131 DrawableTile* tile = tileAt(i, j);
132 IntRect tileRect = m_tiler->tileBounds(i, j); 132 IntRect tileRect = m_tiler->tileBounds(i, j);
133 SkColor borderColor; 133 SkColor borderColor;
134 134
135 if (m_skipsDraw || !tile || !tile->resourceId()) 135 if (m_skipsDraw || !tile || !tile->resourceId())
136 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile BorderMissingTileColorRed, debugTileBorderMissingTileColorGreen, debugTileBorder MissingTileColorBlue); 136 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile BorderMissingTileColorRed, debugTileBorderMissingTileColorGreen, debugTileBorder MissingTileColorBlue);
137 else 137 else
138 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); 138 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue);
139 quadSink.append(CCDebugBorderDrawQuad::create(sharedQuadState, t ileRect, borderColor, debugTileBorderWidth).PassAs<CCDrawQuad>(), appendQuadsDat a); 139 quadSink.append(DebugBorderDrawQuad::create(sharedQuadState, til eRect, borderColor, debugTileBorderWidth).PassAs<DrawQuad>(), appendQuadsData);
140 } 140 }
141 } 141 }
142 } 142 }
143 143
144 if (m_skipsDraw) 144 if (m_skipsDraw)
145 return; 145 return;
146 146
147 for (int j = top; j <= bottom; ++j) { 147 for (int j = top; j <= bottom; ++j) {
148 for (int i = left; i <= right; ++i) { 148 for (int i = left; i <= right; ++i) {
149 DrawableTile* tile = tileAt(i, j); 149 DrawableTile* tile = tileAt(i, j);
(...skipping 10 matching lines...) Expand all
160 SkColor defaultColor = SkColorSetRGB(defaultCheckerboardColo rRed, defaultCheckerboardColorGreen, defaultCheckerboardColorBlue); 160 SkColor defaultColor = SkColorSetRGB(defaultCheckerboardColo rRed, defaultCheckerboardColorGreen, defaultCheckerboardColorBlue);
161 SkColor evictedColor = SkColorSetRGB(debugTileEvictedChecker boardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedCheckerbo ardColorBlue); 161 SkColor evictedColor = SkColorSetRGB(debugTileEvictedChecker boardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedCheckerbo ardColorBlue);
162 SkColor invalidatedColor = SkColorSetRGB(debugTileInvalidate dCheckerboardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedC heckerboardColorBlue); 162 SkColor invalidatedColor = SkColorSetRGB(debugTileInvalidate dCheckerboardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedC heckerboardColorBlue);
163 163
164 SkColor checkerColor; 164 SkColor checkerColor;
165 if (hasDebugBorders()) 165 if (hasDebugBorders())
166 checkerColor = tile ? invalidatedColor : evictedColor; 166 checkerColor = tile ? invalidatedColor : evictedColor;
167 else 167 else
168 checkerColor = defaultColor; 168 checkerColor = defaultColor;
169 169
170 appendQuadsData.hadMissingTiles |= quadSink.append(CCChecker boardDrawQuad::create(sharedQuadState, tileRect, checkerColor).PassAs<CCDrawQuad >(), appendQuadsData); 170 appendQuadsData.hadMissingTiles |= quadSink.append(Checkerbo ardDrawQuad::create(sharedQuadState, tileRect, checkerColor).PassAs<DrawQuad>(), appendQuadsData);
171 } else 171 } else
172 appendQuadsData.hadMissingTiles |= quadSink.append(CCSolidCo lorDrawQuad::create(sharedQuadState, tileRect, backgroundColor()).PassAs<CCDrawQ uad>(), appendQuadsData); 172 appendQuadsData.hadMissingTiles |= quadSink.append(SolidColo rDrawQuad::create(sharedQuadState, tileRect, backgroundColor()).PassAs<DrawQuad> (), appendQuadsData);
173 continue; 173 continue;
174 } 174 }
175 175
176 IntRect tileOpaqueRect = tile->opaqueRect(); 176 IntRect tileOpaqueRect = tile->opaqueRect();
177 tileOpaqueRect.intersect(contentRect); 177 tileOpaqueRect.intersect(contentRect);
178 178
179 // Keep track of how the top left has moved, so the texture can be 179 // Keep track of how the top left has moved, so the texture can be
180 // offset the same amount. 180 // offset the same amount.
181 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX MinYCorner(); 181 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX MinYCorner();
182 IntPoint textureOffset = m_tiler->textureOffset(i, j) + displayOffse t; 182 IntPoint textureOffset = m_tiler->textureOffset(i, j) + displayOffse t;
183 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); 183 float tileWidth = static_cast<float>(m_tiler->tileSize().width());
184 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); 184 float tileHeight = static_cast<float>(m_tiler->tileSize().height());
185 IntSize textureSize(tileWidth, tileHeight); 185 IntSize textureSize(tileWidth, tileHeight);
186 186
187 bool clipped = false; 187 bool clipped = false;
188 FloatQuad visibleContentInTargetQuad = CCMathUtil::mapQuad(drawTrans form(), FloatQuad(visibleContentRect()), clipped); 188 FloatQuad visibleContentInTargetQuad = MathUtil::mapQuad(drawTransfo rm(), FloatQuad(visibleContentRect()), clipped);
189 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad. isRectilinear(); 189 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad. isRectilinear();
190 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget; 190 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget;
191 191
192 bool leftEdgeAA = !i && useAA; 192 bool leftEdgeAA = !i && useAA;
193 bool topEdgeAA = !j && useAA; 193 bool topEdgeAA = !j && useAA;
194 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA; 194 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA;
195 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA; 195 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA;
196 196
197 const GC3Dint textureFilter = m_tiler->hasBorderTexels() ? GraphicsC ontext3D::LINEAR : GraphicsContext3D::NEAREST; 197 const GC3Dint textureFilter = m_tiler->hasBorderTexels() ? GraphicsC ontext3D::LINEAR : GraphicsContext3D::NEAREST;
198 quadSink.append(CCTileDrawQuad::create(sharedQuadState, tileRect, ti leOpaqueRect, tile->resourceId(), textureOffset, textureSize, textureFilter, con tentsSwizzled(), leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA).PassAs<CCDraw Quad>(), appendQuadsData); 198 quadSink.append(TileDrawQuad::create(sharedQuadState, tileRect, tile OpaqueRect, tile->resourceId(), textureOffset, textureSize, textureFilter, conte ntsSwizzled(), leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA).PassAs<DrawQuad >(), appendQuadsData);
199 } 199 }
200 } 200 }
201 } 201 }
202 202
203 void CCTiledLayerImpl::setTilingData(const CCLayerTilingData& tiler) 203 void TiledLayerImpl::setTilingData(const LayerTilingData& tiler)
204 { 204 {
205 if (m_tiler) 205 if (m_tiler)
206 m_tiler->reset(); 206 m_tiler->reset();
207 else 207 else
208 m_tiler = CCLayerTilingData::create(tiler.tileSize(), tiler.hasBorderTex els() ? CCLayerTilingData::HasBorderTexels : CCLayerTilingData::NoBorderTexels); 208 m_tiler = LayerTilingData::create(tiler.tileSize(), tiler.hasBorderTexel s() ? LayerTilingData::HasBorderTexels : LayerTilingData::NoBorderTexels);
209 *m_tiler = tiler; 209 *m_tiler = tiler;
210 } 210 }
211 211
212 void CCTiledLayerImpl::pushTileProperties(int i, int j, CCResourceProvider::Reso urceId resourceId, const IntRect& opaqueRect) 212 void TiledLayerImpl::pushTileProperties(int i, int j, ResourceProvider::Resource Id resourceId, const IntRect& opaqueRect)
213 { 213 {
214 DrawableTile* tile = tileAt(i, j); 214 DrawableTile* tile = tileAt(i, j);
215 if (!tile) 215 if (!tile)
216 tile = createTile(i, j); 216 tile = createTile(i, j);
217 tile->setResourceId(resourceId); 217 tile->setResourceId(resourceId);
218 tile->setOpaqueRect(opaqueRect); 218 tile->setOpaqueRect(opaqueRect);
219 } 219 }
220 220
221 void CCTiledLayerImpl::pushInvalidTile(int i, int j) 221 void TiledLayerImpl::pushInvalidTile(int i, int j)
222 { 222 {
223 DrawableTile* tile = tileAt(i, j); 223 DrawableTile* tile = tileAt(i, j);
224 if (!tile) 224 if (!tile)
225 tile = createTile(i, j); 225 tile = createTile(i, j);
226 tile->setResourceId(0); 226 tile->setResourceId(0);
227 tile->setOpaqueRect(IntRect()); 227 tile->setOpaqueRect(IntRect());
228 } 228 }
229 229
230 Region CCTiledLayerImpl::visibleContentOpaqueRegion() const 230 Region TiledLayerImpl::visibleContentOpaqueRegion() const
231 { 231 {
232 if (m_skipsDraw) 232 if (m_skipsDraw)
233 return Region(); 233 return Region();
234 if (contentsOpaque()) 234 if (contentsOpaque())
235 return visibleContentRect(); 235 return visibleContentRect();
236 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); 236 return m_tiler->opaqueRegionInContentRect(visibleContentRect());
237 } 237 }
238 238
239 void CCTiledLayerImpl::didLoseContext() 239 void TiledLayerImpl::didLoseContext()
240 { 240 {
241 m_tiler->reset(); 241 m_tiler->reset();
242 } 242 }
243 243
244 const char* CCTiledLayerImpl::layerTypeAsString() const 244 const char* TiledLayerImpl::layerTypeAsString() const
245 { 245 {
246 return "ContentLayer"; 246 return "ContentLayer";
247 } 247 }
248 248
249 } // namespace cc 249 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698