OLD | NEW |
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 #if USE(ACCELERATED_COMPOSITING) | 7 #if USE(ACCELERATED_COMPOSITING) |
8 | 8 |
9 #include "CCTiledLayerImpl.h" | 9 #include "CCTiledLayerImpl.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 static const int debugTileBorderWidth = 1; | 29 static const int debugTileBorderWidth = 1; |
30 static const int debugTileBorderAlpha = 100; | 30 static const int debugTileBorderAlpha = 100; |
31 static const int debugTileBorderColorRed = 80; | 31 static const int debugTileBorderColorRed = 80; |
32 static const int debugTileBorderColorGreen = 200; | 32 static const int debugTileBorderColorGreen = 200; |
33 static const int debugTileBorderColorBlue = 200; | 33 static const int debugTileBorderColorBlue = 200; |
34 static const int debugTileBorderMissingTileColorRed = 255; | 34 static const int debugTileBorderMissingTileColorRed = 255; |
35 static const int debugTileBorderMissingTileColorGreen = 0; | 35 static const int debugTileBorderMissingTileColorGreen = 0; |
36 static const int debugTileBorderMissingTileColorBlue = 0; | 36 static const int debugTileBorderMissingTileColorBlue = 0; |
37 | 37 |
| 38 static const int defaultCheckerboardColorRed = 241; |
| 39 static const int defaultCheckerboardColorGreen = 241; |
| 40 static const int defaultCheckerboardColorBlue = 241; |
| 41 static const int debugTileEvictedCheckerboardColorRed = 255; |
| 42 static const int debugTileEvictedCheckerboardColorGreen = 200; |
| 43 static const int debugTileEvictedCheckerboardColorBlue = 200; |
| 44 static const int debugTileInvalidatedCheckerboardColorRed = 128; |
| 45 static const int debugTileInvalidatedCheckerboardColorGreen = 200; |
| 46 static const int debugTileInvalidatedCheckerboardColorBlue = 245; |
| 47 |
38 class DrawableTile : public CCLayerTilingData::Tile { | 48 class DrawableTile : public CCLayerTilingData::Tile { |
39 WTF_MAKE_NONCOPYABLE(DrawableTile); | 49 WTF_MAKE_NONCOPYABLE(DrawableTile); |
40 public: | 50 public: |
41 static PassOwnPtr<DrawableTile> create() { return adoptPtr(new DrawableTile(
)); } | 51 static PassOwnPtr<DrawableTile> create() { return adoptPtr(new DrawableTile(
)); } |
42 | 52 |
43 CCResourceProvider::ResourceId resourceId() const { return m_resourceId; } | 53 CCResourceProvider::ResourceId resourceId() const { return m_resourceId; } |
44 void setResourceId(CCResourceProvider::ResourceId resourceId) { m_resourceId
= resourceId; } | 54 void setResourceId(CCResourceProvider::ResourceId resourceId) { m_resourceId
= resourceId; } |
45 | 55 |
46 private: | 56 private: |
47 DrawableTile() : m_resourceId(0) { } | 57 DrawableTile() : m_resourceId(0) { } |
(...skipping 29 matching lines...) Expand all Loading... |
77 str->append(indentString(indent)); | 87 str->append(indentString(indent)); |
78 base::StringAppendF(str, "skipsDraw: %d\n", (!m_tiler || m_skipsDraw)); | 88 base::StringAppendF(str, "skipsDraw: %d\n", (!m_tiler || m_skipsDraw)); |
79 CCLayerImpl::dumpLayerProperties(str, indent); | 89 CCLayerImpl::dumpLayerProperties(str, indent); |
80 } | 90 } |
81 | 91 |
82 bool CCTiledLayerImpl::hasTileAt(int i, int j) const | 92 bool CCTiledLayerImpl::hasTileAt(int i, int j) const |
83 { | 93 { |
84 return m_tiler->tileAt(i, j); | 94 return m_tiler->tileAt(i, j); |
85 } | 95 } |
86 | 96 |
87 bool CCTiledLayerImpl::hasTextureIdForTileAt(int i, int j) const | 97 bool CCTiledLayerImpl::hasResourceIdForTileAt(int i, int j) const |
88 { | 98 { |
89 return hasTileAt(i, j) && tileAt(i, j)->resourceId(); | 99 return hasTileAt(i, j) && tileAt(i, j)->resourceId(); |
90 } | 100 } |
91 | 101 |
92 DrawableTile* CCTiledLayerImpl::tileAt(int i, int j) const | 102 DrawableTile* CCTiledLayerImpl::tileAt(int i, int j) const |
93 { | 103 { |
94 return static_cast<DrawableTile*>(m_tiler->tileAt(i, j)); | 104 return static_cast<DrawableTile*>(m_tiler->tileAt(i, j)); |
95 } | 105 } |
96 | 106 |
97 DrawableTile* CCTiledLayerImpl::createTile(int i, int j) | 107 DrawableTile* CCTiledLayerImpl::createTile(int i, int j) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 DrawableTile* tile = tileAt(i, j); | 149 DrawableTile* tile = tileAt(i, j); |
140 IntRect tileRect = m_tiler->tileBounds(i, j); | 150 IntRect tileRect = m_tiler->tileBounds(i, j); |
141 IntRect displayRect = tileRect; | 151 IntRect displayRect = tileRect; |
142 tileRect.intersect(contentRect); | 152 tileRect.intersect(contentRect); |
143 | 153 |
144 // Skip empty tiles. | 154 // Skip empty tiles. |
145 if (tileRect.isEmpty()) | 155 if (tileRect.isEmpty()) |
146 continue; | 156 continue; |
147 | 157 |
148 if (!tile || !tile->resourceId()) { | 158 if (!tile || !tile->resourceId()) { |
149 if (drawCheckerboardForMissingTiles()) | 159 if (drawCheckerboardForMissingTiles()) { |
150 appendQuadsData.hadMissingTiles |= quadSink.append(CCChecker
boardDrawQuad::create(sharedQuadState, tileRect).PassAs<CCDrawQuad>(), appendQua
dsData); | 160 SkColor defaultColor = SkColorSetRGB(defaultCheckerboardColo
rRed, defaultCheckerboardColorGreen, defaultCheckerboardColorBlue); |
151 else | 161 SkColor evictedColor = SkColorSetRGB(debugTileEvictedChecker
boardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedCheckerbo
ardColorBlue); |
| 162 SkColor invalidatedColor = SkColorSetRGB(debugTileInvalidate
dCheckerboardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedC
heckerboardColorBlue); |
| 163 |
| 164 SkColor checkerColor; |
| 165 if (hasDebugBorders()) |
| 166 checkerColor = tile ? invalidatedColor : evictedColor; |
| 167 else |
| 168 checkerColor = defaultColor; |
| 169 |
| 170 appendQuadsData.hadMissingTiles |= quadSink.append(CCChecker
boardDrawQuad::create(sharedQuadState, tileRect, checkerColor).PassAs<CCDrawQuad
>(), appendQuadsData); |
| 171 } else |
152 appendQuadsData.hadMissingTiles |= quadSink.append(CCSolidCo
lorDrawQuad::create(sharedQuadState, tileRect, backgroundColor()).PassAs<CCDrawQ
uad>(), appendQuadsData); | 172 appendQuadsData.hadMissingTiles |= quadSink.append(CCSolidCo
lorDrawQuad::create(sharedQuadState, tileRect, backgroundColor()).PassAs<CCDrawQ
uad>(), appendQuadsData); |
153 continue; | 173 continue; |
154 } | 174 } |
155 | 175 |
156 IntRect tileOpaqueRect = tile->opaqueRect(); | 176 IntRect tileOpaqueRect = tile->opaqueRect(); |
157 tileOpaqueRect.intersect(contentRect); | 177 tileOpaqueRect.intersect(contentRect); |
158 | 178 |
159 // 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 |
160 // offset the same amount. | 180 // offset the same amount. |
161 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX
MinYCorner(); | 181 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX
MinYCorner(); |
(...skipping 29 matching lines...) Expand all Loading... |
191 | 211 |
192 void CCTiledLayerImpl::pushTileProperties(int i, int j, CCResourceProvider::Reso
urceId resourceId, const IntRect& opaqueRect) | 212 void CCTiledLayerImpl::pushTileProperties(int i, int j, CCResourceProvider::Reso
urceId resourceId, const IntRect& opaqueRect) |
193 { | 213 { |
194 DrawableTile* tile = tileAt(i, j); | 214 DrawableTile* tile = tileAt(i, j); |
195 if (!tile) | 215 if (!tile) |
196 tile = createTile(i, j); | 216 tile = createTile(i, j); |
197 tile->setResourceId(resourceId); | 217 tile->setResourceId(resourceId); |
198 tile->setOpaqueRect(opaqueRect); | 218 tile->setOpaqueRect(opaqueRect); |
199 } | 219 } |
200 | 220 |
| 221 void CCTiledLayerImpl::pushInvalidTile(int i, int j) |
| 222 { |
| 223 DrawableTile* tile = tileAt(i, j); |
| 224 if (!tile) |
| 225 tile = createTile(i, j); |
| 226 tile->setResourceId(0); |
| 227 tile->setOpaqueRect(IntRect()); |
| 228 } |
| 229 |
201 Region CCTiledLayerImpl::visibleContentOpaqueRegion() const | 230 Region CCTiledLayerImpl::visibleContentOpaqueRegion() const |
202 { | 231 { |
203 if (m_skipsDraw) | 232 if (m_skipsDraw) |
204 return Region(); | 233 return Region(); |
205 if (opaque()) | 234 if (opaque()) |
206 return visibleContentRect(); | 235 return visibleContentRect(); |
207 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); | 236 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); |
208 } | 237 } |
209 | 238 |
210 void CCTiledLayerImpl::didLoseContext() | 239 void CCTiledLayerImpl::didLoseContext() |
211 { | 240 { |
212 m_tiler->reset(); | 241 m_tiler->reset(); |
213 } | 242 } |
214 | 243 |
215 const char* CCTiledLayerImpl::layerTypeAsString() const | 244 const char* CCTiledLayerImpl::layerTypeAsString() const |
216 { | 245 { |
217 return "ContentLayer"; | 246 return "ContentLayer"; |
218 } | 247 } |
219 | 248 |
220 } // namespace cc | 249 } // namespace cc |
221 | 250 |
222 #endif // USE(ACCELERATED_COMPOSITING) | 251 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |