| 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 "cc/tiled_layer_impl.h" | 5 #include "cc/tiled_layer_impl.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "cc/append_quads_data.h" | 9 #include "cc/append_quads_data.h" |
| 10 #include "cc/checkerboard_draw_quad.h" | 10 #include "cc/checkerboard_draw_quad.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 DrawableTile* TiledLayerImpl::createTile(int i, int j) | 109 DrawableTile* TiledLayerImpl::createTile(int i, int j) |
| 110 { | 110 { |
| 111 scoped_ptr<DrawableTile> tile(DrawableTile::create()); | 111 scoped_ptr<DrawableTile> tile(DrawableTile::create()); |
| 112 DrawableTile* addedTile = tile.get(); | 112 DrawableTile* addedTile = tile.get(); |
| 113 m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j); | 113 m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j); |
| 114 return addedTile; | 114 return addedTile; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void TiledLayerImpl::getDebugBorderProperties(SkColor* color, float* width) cons
t |
| 118 { |
| 119 // Tiled content layers are orange. |
| 120 *color = SkColorSetARGBInline(128, 255, 128, 0); |
| 121 *width = 2; |
| 122 } |
| 123 |
| 117 void TiledLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
sData) | 124 void TiledLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuad
sData) |
| 118 { | 125 { |
| 119 const gfx::Rect& contentRect = visibleContentRect(); | 126 const gfx::Rect& contentRect = visibleContentRect(); |
| 120 | 127 |
| 121 if (!m_tiler || m_tiler->hasEmptyBounds() || contentRect.IsEmpty()) | 128 if (!m_tiler || m_tiler->hasEmptyBounds() || contentRect.IsEmpty()) |
| 122 return; | 129 return; |
| 123 | 130 |
| 124 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); | 131 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); |
| 125 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 132 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
| 126 | 133 |
| 127 int left, top, right, bottom; | 134 int left, top, right, bottom; |
| 128 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); | 135 m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom); |
| 129 | 136 |
| 130 if (hasDebugBorders()) { | 137 if (showDebugBorders()) { |
| 131 for (int j = top; j <= bottom; ++j) { | 138 for (int j = top; j <= bottom; ++j) { |
| 132 for (int i = left; i <= right; ++i) { | 139 for (int i = left; i <= right; ++i) { |
| 133 DrawableTile* tile = tileAt(i, j); | 140 DrawableTile* tile = tileAt(i, j); |
| 134 gfx::Rect tileRect = m_tiler->tileBounds(i, j); | 141 gfx::Rect tileRect = m_tiler->tileBounds(i, j); |
| 135 SkColor borderColor; | 142 SkColor borderColor; |
| 136 | 143 |
| 137 if (m_skipsDraw || !tile || !tile->resourceId()) | 144 if (m_skipsDraw || !tile || !tile->resourceId()) |
| 138 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderMissingTileColorRed, debugTileBorderMissingTileColorGreen, debugTileBorder
MissingTileColorBlue); | 145 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderMissingTileColorRed, debugTileBorderMissingTileColorGreen, debugTileBorder
MissingTileColorBlue); |
| 139 else | 146 else |
| 140 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); | 147 borderColor = SkColorSetARGB(debugTileBorderAlpha, debugTile
BorderColorRed, debugTileBorderColorGreen, debugTileBorderColorBlue); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 157 if (tileRect.IsEmpty()) | 164 if (tileRect.IsEmpty()) |
| 158 continue; | 165 continue; |
| 159 | 166 |
| 160 if (!tile || !tile->resourceId()) { | 167 if (!tile || !tile->resourceId()) { |
| 161 if (drawCheckerboardForMissingTiles()) { | 168 if (drawCheckerboardForMissingTiles()) { |
| 162 SkColor defaultColor = SkColorSetRGB(defaultCheckerboardColo
rRed, defaultCheckerboardColorGreen, defaultCheckerboardColorBlue); | 169 SkColor defaultColor = SkColorSetRGB(defaultCheckerboardColo
rRed, defaultCheckerboardColorGreen, defaultCheckerboardColorBlue); |
| 163 SkColor evictedColor = SkColorSetRGB(debugTileEvictedChecker
boardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedCheckerbo
ardColorBlue); | 170 SkColor evictedColor = SkColorSetRGB(debugTileEvictedChecker
boardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedCheckerbo
ardColorBlue); |
| 164 SkColor invalidatedColor = SkColorSetRGB(debugTileInvalidate
dCheckerboardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedC
heckerboardColorBlue); | 171 SkColor invalidatedColor = SkColorSetRGB(debugTileInvalidate
dCheckerboardColorRed, debugTileEvictedCheckerboardColorGreen, debugTileEvictedC
heckerboardColorBlue); |
| 165 | 172 |
| 166 SkColor checkerColor; | 173 SkColor checkerColor; |
| 167 if (hasDebugBorders()) | 174 if (showDebugBorders()) |
| 168 checkerColor = tile ? invalidatedColor : evictedColor; | 175 checkerColor = tile ? invalidatedColor : evictedColor; |
| 169 else | 176 else |
| 170 checkerColor = defaultColor; | 177 checkerColor = defaultColor; |
| 171 | 178 |
| 172 appendQuadsData.hadMissingTiles |= quadSink.append(Checkerbo
ardDrawQuad::create(sharedQuadState, tileRect, checkerColor).PassAs<DrawQuad>(),
appendQuadsData); | 179 appendQuadsData.hadMissingTiles |= quadSink.append(Checkerbo
ardDrawQuad::create(sharedQuadState, tileRect, checkerColor).PassAs<DrawQuad>(),
appendQuadsData); |
| 173 } else | 180 } else |
| 174 appendQuadsData.hadMissingTiles |= quadSink.append(SolidColo
rDrawQuad::create(sharedQuadState, tileRect, backgroundColor()).PassAs<DrawQuad>
(), appendQuadsData); | 181 appendQuadsData.hadMissingTiles |= quadSink.append(SolidColo
rDrawQuad::create(sharedQuadState, tileRect, backgroundColor()).PassAs<DrawQuad>
(), appendQuadsData); |
| 175 continue; | 182 continue; |
| 176 } | 183 } |
| 177 | 184 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 { | 250 { |
| 244 m_tiler->reset(); | 251 m_tiler->reset(); |
| 245 } | 252 } |
| 246 | 253 |
| 247 const char* TiledLayerImpl::layerTypeAsString() const | 254 const char* TiledLayerImpl::layerTypeAsString() const |
| 248 { | 255 { |
| 249 return "ContentLayer"; | 256 return "ContentLayer"; |
| 250 } | 257 } |
| 251 | 258 |
| 252 } // namespace cc | 259 } // namespace cc |
| OLD | NEW |