| 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 | |
| 48 class DrawableTile : public CCLayerTilingData::Tile { | 38 class DrawableTile : public CCLayerTilingData::Tile { |
| 49 WTF_MAKE_NONCOPYABLE(DrawableTile); | 39 WTF_MAKE_NONCOPYABLE(DrawableTile); |
| 50 public: | 40 public: |
| 51 static PassOwnPtr<DrawableTile> create() { return adoptPtr(new DrawableTile(
)); } | 41 static PassOwnPtr<DrawableTile> create() { return adoptPtr(new DrawableTile(
)); } |
| 52 | 42 |
| 53 CCResourceProvider::ResourceId resourceId() const { return m_resourceId; } | 43 CCResourceProvider::ResourceId resourceId() const { return m_resourceId; } |
| 54 void setResourceId(CCResourceProvider::ResourceId resourceId) { m_resourceId
= resourceId; } | 44 void setResourceId(CCResourceProvider::ResourceId resourceId) { m_resourceId
= resourceId; } |
| 55 | 45 |
| 56 private: | 46 private: |
| 57 DrawableTile() : m_resourceId(0) { } | 47 DrawableTile() : m_resourceId(0) { } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 DrawableTile* tile = tileAt(i, j); | 139 DrawableTile* tile = tileAt(i, j); |
| 150 IntRect tileRect = m_tiler->tileBounds(i, j); | 140 IntRect tileRect = m_tiler->tileBounds(i, j); |
| 151 IntRect displayRect = tileRect; | 141 IntRect displayRect = tileRect; |
| 152 tileRect.intersect(contentRect); | 142 tileRect.intersect(contentRect); |
| 153 | 143 |
| 154 // Skip empty tiles. | 144 // Skip empty tiles. |
| 155 if (tileRect.isEmpty()) | 145 if (tileRect.isEmpty()) |
| 156 continue; | 146 continue; |
| 157 | 147 |
| 158 if (!tile || !tile->resourceId()) { | 148 if (!tile || !tile->resourceId()) { |
| 159 if (drawCheckerboardForMissingTiles()) { | 149 if (drawCheckerboardForMissingTiles()) |
| 160 SkColor defaultColor = SkColorSetRGB(defaultCheckerboardColo
rRed, defaultCheckerboardColorGreen, defaultCheckerboardColorBlue); | 150 appendQuadsData.hadMissingTiles |= quadSink.append(CCChecker
boardDrawQuad::create(sharedQuadState, tileRect), appendQuadsData); |
| 161 SkColor evictedColor = SkColorSetRGB(debugTileEvictedChecker
boardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedCheckerbo
ardColorBlue); | 151 else |
| 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), appendQuadsData)
; | |
| 171 } else | |
| 172 appendQuadsData.hadMissingTiles |= quadSink.append(CCSolidCo
lorDrawQuad::create(sharedQuadState, tileRect, backgroundColor()), appendQuadsDa
ta); | 152 appendQuadsData.hadMissingTiles |= quadSink.append(CCSolidCo
lorDrawQuad::create(sharedQuadState, tileRect, backgroundColor()), appendQuadsDa
ta); |
| 173 continue; | 153 continue; |
| 174 } | 154 } |
| 175 | 155 |
| 176 IntRect tileOpaqueRect = tile->opaqueRect(); | 156 IntRect tileOpaqueRect = tile->opaqueRect(); |
| 177 tileOpaqueRect.intersect(contentRect); | 157 tileOpaqueRect.intersect(contentRect); |
| 178 | 158 |
| 179 // Keep track of how the top left has moved, so the texture can be | 159 // Keep track of how the top left has moved, so the texture can be |
| 180 // offset the same amount. | 160 // offset the same amount. |
| 181 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX
MinYCorner(); | 161 IntSize displayOffset = tileRect.minXMinYCorner() - displayRect.minX
MinYCorner(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 211 | 191 |
| 212 void CCTiledLayerImpl::pushTileProperties(int i, int j, CCResourceProvider::Reso
urceId resourceId, const IntRect& opaqueRect) | 192 void CCTiledLayerImpl::pushTileProperties(int i, int j, CCResourceProvider::Reso
urceId resourceId, const IntRect& opaqueRect) |
| 213 { | 193 { |
| 214 DrawableTile* tile = tileAt(i, j); | 194 DrawableTile* tile = tileAt(i, j); |
| 215 if (!tile) | 195 if (!tile) |
| 216 tile = createTile(i, j); | 196 tile = createTile(i, j); |
| 217 tile->setResourceId(resourceId); | 197 tile->setResourceId(resourceId); |
| 218 tile->setOpaqueRect(opaqueRect); | 198 tile->setOpaqueRect(opaqueRect); |
| 219 } | 199 } |
| 220 | 200 |
| 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 | |
| 230 Region CCTiledLayerImpl::visibleContentOpaqueRegion() const | 201 Region CCTiledLayerImpl::visibleContentOpaqueRegion() const |
| 231 { | 202 { |
| 232 if (m_skipsDraw) | 203 if (m_skipsDraw) |
| 233 return Region(); | 204 return Region(); |
| 234 if (opaque()) | 205 if (opaque()) |
| 235 return visibleContentRect(); | 206 return visibleContentRect(); |
| 236 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); | 207 return m_tiler->opaqueRegionInContentRect(visibleContentRect()); |
| 237 } | 208 } |
| 238 | 209 |
| 239 void CCTiledLayerImpl::didLoseContext() | 210 void CCTiledLayerImpl::didLoseContext() |
| 240 { | 211 { |
| 241 m_tiler->reset(); | 212 m_tiler->reset(); |
| 242 } | 213 } |
| 243 | 214 |
| 244 const char* CCTiledLayerImpl::layerTypeAsString() const | 215 const char* CCTiledLayerImpl::layerTypeAsString() const |
| 245 { | 216 { |
| 246 return "ContentLayer"; | 217 return "ContentLayer"; |
| 247 } | 218 } |
| 248 | 219 |
| 249 } // namespace cc | 220 } // namespace cc |
| 250 | 221 |
| 251 #endif // USE(ACCELERATED_COMPOSITING) | 222 #endif // USE(ACCELERATED_COMPOSITING) |
| OLD | NEW |