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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 SkColor borderColor; | 126 SkColor borderColor; |
127 float borderWidth; | 127 float borderWidth; |
128 | 128 |
129 if (m_skipsDraw || !tile || !tile->resourceId()) { | 129 if (m_skipsDraw || !tile || !tile->resourceId()) { |
130 borderColor = DebugColors::MissingTileBorderColor(); | 130 borderColor = DebugColors::MissingTileBorderColor(); |
131 borderWidth = DebugColors::MissingTileBorderWidth(layerTreeH
ostImpl()); | 131 borderWidth = DebugColors::MissingTileBorderWidth(layerTreeH
ostImpl()); |
132 } else { | 132 } else { |
133 borderColor = DebugColors::TileBorderColor(); | 133 borderColor = DebugColors::TileBorderColor(); |
134 borderWidth = DebugColors::TileBorderWidth(layerTreeHostImpl
()); | 134 borderWidth = DebugColors::TileBorderWidth(layerTreeHostImpl
()); |
135 } | 135 } |
136 quadSink.append(DebugBorderDrawQuad::create(sharedQuadState, til
eRect, borderColor, borderWidth).PassAs<DrawQuad>(), appendQuadsData); | 136 scoped_ptr<DebugBorderDrawQuad> debugBorderQuad = DebugBorderDra
wQuad::Create(); |
| 137 debugBorderQuad->SetNew(sharedQuadState, tileRect, borderColor,
borderWidth); |
| 138 quadSink.append(debugBorderQuad.PassAs<DrawQuad>(), appendQuadsD
ata); |
137 } | 139 } |
138 } | 140 } |
139 } | 141 } |
140 | 142 |
141 if (m_skipsDraw) | 143 if (m_skipsDraw) |
142 return; | 144 return; |
143 | 145 |
144 for (int j = top; j <= bottom; ++j) { | 146 for (int j = top; j <= bottom; ++j) { |
145 for (int i = left; i <= right; ++i) { | 147 for (int i = left; i <= right; ++i) { |
146 DrawableTile* tile = tileAt(i, j); | 148 DrawableTile* tile = tileAt(i, j); |
147 gfx::Rect tileRect = m_tiler->tileBounds(i, j); | 149 gfx::Rect tileRect = m_tiler->tileBounds(i, j); |
148 gfx::Rect displayRect = tileRect; | 150 gfx::Rect displayRect = tileRect; |
149 tileRect.Intersect(contentRect); | 151 tileRect.Intersect(contentRect); |
150 | 152 |
151 // Skip empty tiles. | 153 // Skip empty tiles. |
152 if (tileRect.IsEmpty()) | 154 if (tileRect.IsEmpty()) |
153 continue; | 155 continue; |
154 | 156 |
155 if (!tile || !tile->resourceId()) { | 157 if (!tile || !tile->resourceId()) { |
156 if (drawCheckerboardForMissingTiles()) { | 158 if (drawCheckerboardForMissingTiles()) { |
157 SkColor checkerColor; | 159 SkColor checkerColor; |
158 if (showDebugBorders()) | 160 if (showDebugBorders()) |
159 checkerColor = tile ? DebugColors::InvalidatedTileChecke
rboardColor() : DebugColors::EvictedTileCheckerboardColor(); | 161 checkerColor = tile ? DebugColors::InvalidatedTileChecke
rboardColor() : DebugColors::EvictedTileCheckerboardColor(); |
160 else | 162 else |
161 checkerColor = kTileCheckerboardColor; | 163 checkerColor = kTileCheckerboardColor; |
162 | 164 |
163 appendQuadsData.hadMissingTiles |= quadSink.append(Checkerbo
ardDrawQuad::create(sharedQuadState, tileRect, checkerColor).PassAs<DrawQuad>(),
appendQuadsData); | 165 scoped_ptr<CheckerboardDrawQuad> checkerboardQuad = Checkerb
oardDrawQuad::Create(); |
164 } else | 166 checkerboardQuad->SetNew(sharedQuadState, tileRect, checkerC
olor); |
165 appendQuadsData.hadMissingTiles |= quadSink.append(SolidColo
rDrawQuad::create(sharedQuadState, tileRect, backgroundColor()).PassAs<DrawQuad>
(), appendQuadsData); | 167 appendQuadsData.hadMissingTiles |= quadSink.append(checkerbo
ardQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 168 } else { |
| 169 scoped_ptr<SolidColorDrawQuad> solidColorQuad = SolidColorDr
awQuad::Create(); |
| 170 solidColorQuad->SetNew(sharedQuadState, tileRect, background
Color()); |
| 171 appendQuadsData.hadMissingTiles |= quadSink.append(solidColo
rQuad.PassAs<DrawQuad>(), appendQuadsData); |
| 172 } |
166 continue; | 173 continue; |
167 } | 174 } |
168 | 175 |
169 gfx::Rect tileOpaqueRect = contentsOpaque() ? tileRect : gfx::Inters
ectRects(tile->opaqueRect(), contentRect); | 176 gfx::Rect tileOpaqueRect = contentsOpaque() ? tileRect : gfx::Inters
ectRects(tile->opaqueRect(), contentRect); |
170 | 177 |
171 // Keep track of how the top left has moved, so the texture can be | 178 // Keep track of how the top left has moved, so the texture can be |
172 // offset the same amount. | 179 // offset the same amount. |
173 gfx::Vector2d displayOffset = tileRect.origin() - displayRect.origin
(); | 180 gfx::Vector2d displayOffset = tileRect.origin() - displayRect.origin
(); |
174 gfx::Vector2d textureOffset = m_tiler->textureOffset(i, j) + display
Offset; | 181 gfx::Vector2d textureOffset = m_tiler->textureOffset(i, j) + display
Offset; |
175 gfx::RectF texCoordRect = gfx::RectF(tileRect.size()) + textureOffse
t; | 182 gfx::RectF texCoordRect = gfx::RectF(tileRect.size()) + textureOffse
t; |
176 | 183 |
177 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); | 184 float tileWidth = static_cast<float>(m_tiler->tileSize().width()); |
178 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); | 185 float tileHeight = static_cast<float>(m_tiler->tileSize().height()); |
179 gfx::Size textureSize(tileWidth, tileHeight); | 186 gfx::Size textureSize(tileWidth, tileHeight); |
180 | 187 |
181 bool clipped = false; | 188 bool clipped = false; |
182 gfx::QuadF visibleContentInTargetQuad = MathUtil::mapQuad(drawTransf
orm(), gfx::QuadF(visibleContentRect()), clipped); | 189 gfx::QuadF visibleContentInTargetQuad = MathUtil::mapQuad(drawTransf
orm(), gfx::QuadF(visibleContentRect()), clipped); |
183 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad.
IsRectilinear(); | 190 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad.
IsRectilinear(); |
184 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget; | 191 bool useAA = m_tiler->hasBorderTexels() && !isAxisAlignedInTarget; |
185 | 192 |
186 bool leftEdgeAA = !i && useAA; | 193 bool leftEdgeAA = !i && useAA; |
187 bool topEdgeAA = !j && useAA; | 194 bool topEdgeAA = !j && useAA; |
188 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA; | 195 bool rightEdgeAA = i == m_tiler->numTilesX() - 1 && useAA; |
189 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA; | 196 bool bottomEdgeAA = j == m_tiler->numTilesY() - 1 && useAA; |
190 | 197 |
191 quadSink.append(TileDrawQuad::create(sharedQuadState, tileRect, tile
OpaqueRect, tile->resourceId(), texCoordRect, textureSize, tile->contentsSwizzle
d(), leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA).PassAs<DrawQuad>(), appen
dQuadsData); | 198 scoped_ptr<TileDrawQuad> quad = TileDrawQuad::Create(); |
| 199 quad->SetNew(sharedQuadState, tileRect, tileOpaqueRect, tile->resour
ceId(), texCoordRect, textureSize, tile->contentsSwizzled(), leftEdgeAA, topEdge
AA, rightEdgeAA, bottomEdgeAA); |
| 200 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
192 } | 201 } |
193 } | 202 } |
194 } | 203 } |
195 | 204 |
196 void TiledLayerImpl::setTilingData(const LayerTilingData& tiler) | 205 void TiledLayerImpl::setTilingData(const LayerTilingData& tiler) |
197 { | 206 { |
198 if (m_tiler) | 207 if (m_tiler) |
199 m_tiler->reset(); | 208 m_tiler->reset(); |
200 else | 209 else |
201 m_tiler = LayerTilingData::create(tiler.tileSize(), tiler.hasBorderTexel
s() ? LayerTilingData::HasBorderTexels : LayerTilingData::NoBorderTexels); | 210 m_tiler = LayerTilingData::create(tiler.tileSize(), tiler.hasBorderTexel
s() ? LayerTilingData::HasBorderTexels : LayerTilingData::NoBorderTexels); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 { | 244 { |
236 m_tiler->reset(); | 245 m_tiler->reset(); |
237 } | 246 } |
238 | 247 |
239 const char* TiledLayerImpl::layerTypeAsString() const | 248 const char* TiledLayerImpl::layerTypeAsString() const |
240 { | 249 { |
241 return "ContentLayer"; | 250 return "ContentLayer"; |
242 } | 251 } |
243 | 252 |
244 } // namespace cc | 253 } // namespace cc |
OLD | NEW |