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/layers/tiled_layer_impl.h" | 5 #include "cc/layers/tiled_layer_impl.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); | 135 for (LayerTilingData::TileMap::const_iterator iter = tiler_->tiles().begin(); |
136 iter != tiler_->tiles().end(); | 136 iter != tiler_->tiles().end(); |
137 ++iter) { | 137 ++iter) { |
138 int i = iter->first.first; | 138 int i = iter->first.first; |
139 int j = iter->first.second; | 139 int j = iter->first.second; |
140 DrawableTile* tile = static_cast<DrawableTile*>(iter->second); | 140 DrawableTile* tile = static_cast<DrawableTile*>(iter->second); |
141 DCHECK(tile); | 141 DCHECK(tile); |
142 tiled_layer->PushTileProperties(i, | 142 tiled_layer->PushTileProperties(i, |
143 j, | 143 j, |
144 tile->resource_id(), | 144 tile->resource_id(), |
145 tile->opaque_rect(), | |
146 tile->contents_swizzled()); | 145 tile->contents_swizzled()); |
147 } | 146 } |
148 } | 147 } |
149 | 148 |
150 bool TiledLayerImpl::WillDraw(DrawMode draw_mode, | 149 bool TiledLayerImpl::WillDraw(DrawMode draw_mode, |
151 ResourceProvider* resource_provider) { | 150 ResourceProvider* resource_provider) { |
152 if (!tiler_ || tiler_->has_empty_bounds() || | 151 if (!tiler_ || tiler_->has_empty_bounds() || |
153 visible_content_rect().IsEmpty() || | 152 visible_content_rect().IsEmpty() || |
154 draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 153 draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
155 return false; | 154 return false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 231 } |
233 | 232 |
234 CheckerboardDrawQuad* checkerboard_quad = | 233 CheckerboardDrawQuad* checkerboard_quad = |
235 render_pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); | 234 render_pass->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |
236 checkerboard_quad->SetNew( | 235 checkerboard_quad->SetNew( |
237 shared_quad_state, tile_rect, visible_tile_rect, checker_color); | 236 shared_quad_state, tile_rect, visible_tile_rect, checker_color); |
238 append_quads_data->num_missing_tiles++; | 237 append_quads_data->num_missing_tiles++; |
239 continue; | 238 continue; |
240 } | 239 } |
241 | 240 |
242 gfx::Rect tile_opaque_rect = | 241 gfx::Rect tile_opaque_rect = contents_opaque() ? tile_rect : gfx::Rect(); |
243 contents_opaque() ? tile_rect : gfx::IntersectRects( | |
244 tile->opaque_rect(), tile_rect); | |
245 | 242 |
246 // Keep track of how the top left has moved, so the texture can be | 243 // Keep track of how the top left has moved, so the texture can be |
247 // offset the same amount. | 244 // offset the same amount. |
248 gfx::Vector2d display_offset = tile_rect.origin() - display_rect.origin(); | 245 gfx::Vector2d display_offset = tile_rect.origin() - display_rect.origin(); |
249 gfx::Vector2d texture_offset = | 246 gfx::Vector2d texture_offset = |
250 tiler_->texture_offset(i, j) + display_offset; | 247 tiler_->texture_offset(i, j) + display_offset; |
251 gfx::RectF tex_coord_rect = gfx::RectF(tile_rect.size()) + texture_offset; | 248 gfx::RectF tex_coord_rect = gfx::RectF(tile_rect.size()) + texture_offset; |
252 | 249 |
253 float tile_width = static_cast<float>(tiler_->tile_size().width()); | 250 float tile_width = static_cast<float>(tiler_->tile_size().width()); |
254 float tile_height = static_cast<float>(tiler_->tile_size().height()); | 251 float tile_height = static_cast<float>(tiler_->tile_size().height()); |
(...skipping 21 matching lines...) Expand all Loading... |
276 ? LayerTilingData::HAS_BORDER_TEXELS | 273 ? LayerTilingData::HAS_BORDER_TEXELS |
277 : LayerTilingData::NO_BORDER_TEXELS); | 274 : LayerTilingData::NO_BORDER_TEXELS); |
278 } | 275 } |
279 *tiler_ = tiler; | 276 *tiler_ = tiler; |
280 } | 277 } |
281 | 278 |
282 void TiledLayerImpl::PushTileProperties( | 279 void TiledLayerImpl::PushTileProperties( |
283 int i, | 280 int i, |
284 int j, | 281 int j, |
285 ResourceProvider::ResourceId resource_id, | 282 ResourceProvider::ResourceId resource_id, |
286 const gfx::Rect& opaque_rect, | |
287 bool contents_swizzled) { | 283 bool contents_swizzled) { |
288 DrawableTile* tile = TileAt(i, j); | 284 DrawableTile* tile = TileAt(i, j); |
289 if (!tile) | 285 if (!tile) |
290 tile = CreateTile(i, j); | 286 tile = CreateTile(i, j); |
291 tile->set_resource_id(resource_id); | 287 tile->set_resource_id(resource_id); |
292 tile->set_opaque_rect(opaque_rect); | |
293 tile->set_contents_swizzled(contents_swizzled); | 288 tile->set_contents_swizzled(contents_swizzled); |
294 } | 289 } |
295 | 290 |
296 void TiledLayerImpl::PushInvalidTile(int i, int j) { | 291 void TiledLayerImpl::PushInvalidTile(int i, int j) { |
297 DrawableTile* tile = TileAt(i, j); | 292 DrawableTile* tile = TileAt(i, j); |
298 if (!tile) | 293 if (!tile) |
299 tile = CreateTile(i, j); | 294 tile = CreateTile(i, j); |
300 tile->set_resource_id(0); | 295 tile->set_resource_id(0); |
301 tile->set_opaque_rect(gfx::Rect()); | |
302 tile->set_contents_swizzled(false); | 296 tile->set_contents_swizzled(false); |
303 } | 297 } |
304 | 298 |
305 SimpleEnclosedRegion TiledLayerImpl::VisibleContentOpaqueRegion() const { | 299 SimpleEnclosedRegion TiledLayerImpl::VisibleContentOpaqueRegion() const { |
306 if (skips_draw_) | 300 if (skips_draw_) |
307 return SimpleEnclosedRegion(); | 301 return SimpleEnclosedRegion(); |
308 if (contents_opaque()) | 302 return LayerImpl::VisibleContentOpaqueRegion(); |
309 return SimpleEnclosedRegion(visible_content_rect()); | |
310 return tiler_->OpaqueRegionInContentRect(visible_content_rect()); | |
311 } | 303 } |
312 | 304 |
313 void TiledLayerImpl::ReleaseResources() { | 305 void TiledLayerImpl::ReleaseResources() { |
314 tiler_->reset(); | 306 tiler_->reset(); |
315 } | 307 } |
316 | 308 |
317 const char* TiledLayerImpl::LayerTypeAsString() const { | 309 const char* TiledLayerImpl::LayerTypeAsString() const { |
318 return "cc::TiledLayerImpl"; | 310 return "cc::TiledLayerImpl"; |
319 } | 311 } |
320 | 312 |
321 } // namespace cc | 313 } // namespace cc |
OLD | NEW |