OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 for (PictureLayerTilingSet::CoverageIterator iter( | 247 for (PictureLayerTilingSet::CoverageIterator iter( |
248 tilings_.get(), | 248 tilings_.get(), |
249 max_contents_scale, | 249 max_contents_scale, |
250 scaled_visible_content_rect, | 250 scaled_visible_content_rect, |
251 ideal_contents_scale_); | 251 ideal_contents_scale_); |
252 iter; | 252 iter; |
253 ++iter) { | 253 ++iter) { |
254 SkColor color; | 254 SkColor color; |
255 float width; | 255 float width; |
256 if (*iter && iter->IsReadyToDraw()) { | 256 if (*iter && iter->IsReadyToDraw()) { |
257 ManagedTileState::DrawInfo::Mode mode = iter->draw_info().mode(); | 257 TileDrawInfo::Mode mode = iter->draw_info().mode(); |
258 if (mode == ManagedTileState::DrawInfo::SOLID_COLOR_MODE) { | 258 if (mode == TileDrawInfo::SOLID_COLOR_MODE) { |
259 color = DebugColors::SolidColorTileBorderColor(); | 259 color = DebugColors::SolidColorTileBorderColor(); |
260 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 260 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
261 } else if (mode == ManagedTileState::DrawInfo::PICTURE_PILE_MODE) { | 261 } else if (mode == TileDrawInfo::PICTURE_PILE_MODE) { |
262 color = DebugColors::PictureTileBorderColor(); | 262 color = DebugColors::PictureTileBorderColor(); |
263 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 263 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
264 } else if (iter.resolution() == HIGH_RESOLUTION) { | 264 } else if (iter.resolution() == HIGH_RESOLUTION) { |
265 color = DebugColors::HighResTileBorderColor(); | 265 color = DebugColors::HighResTileBorderColor(); |
266 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 266 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
267 } else if (iter.resolution() == LOW_RESOLUTION) { | 267 } else if (iter.resolution() == LOW_RESOLUTION) { |
268 color = DebugColors::LowResTileBorderColor(); | 268 color = DebugColors::LowResTileBorderColor(); |
269 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 269 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
270 } else if (iter->contents_scale() > max_contents_scale) { | 270 } else if (iter->contents_scale() > max_contents_scale) { |
271 color = DebugColors::ExtraHighResTileBorderColor(); | 271 color = DebugColors::ExtraHighResTileBorderColor(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 gfx::Rect visible_geometry_rect = | 315 gfx::Rect visible_geometry_rect = |
316 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); | 316 scaled_occlusion.GetUnoccludedContentRect(geometry_rect); |
317 if (visible_geometry_rect.IsEmpty()) | 317 if (visible_geometry_rect.IsEmpty()) |
318 continue; | 318 continue; |
319 | 319 |
320 append_quads_data->visible_content_area += | 320 append_quads_data->visible_content_area += |
321 visible_geometry_rect.width() * visible_geometry_rect.height(); | 321 visible_geometry_rect.width() * visible_geometry_rect.height(); |
322 | 322 |
323 bool has_draw_quad = false; | 323 bool has_draw_quad = false; |
324 if (*iter && iter->IsReadyToDraw()) { | 324 if (*iter && iter->IsReadyToDraw()) { |
325 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); | 325 const TileDrawInfo& draw_info = iter->draw_info(); |
326 switch (draw_info.mode()) { | 326 switch (draw_info.mode()) { |
327 case ManagedTileState::DrawInfo::RESOURCE_MODE: { | 327 case TileDrawInfo::RESOURCE_MODE: { |
328 gfx::RectF texture_rect = iter.texture_rect(); | 328 gfx::RectF texture_rect = iter.texture_rect(); |
329 | 329 |
330 // The raster_contents_scale_ is the best scale that the layer is | 330 // The raster_contents_scale_ is the best scale that the layer is |
331 // trying to produce, even though it may not be ideal. Since that's | 331 // trying to produce, even though it may not be ideal. Since that's |
332 // the best the layer can promise in the future, consider those as | 332 // the best the layer can promise in the future, consider those as |
333 // complete. But if a tile is ideal scale, we don't want to consider | 333 // complete. But if a tile is ideal scale, we don't want to consider |
334 // it incomplete and trying to replace it with a tile at a worse | 334 // it incomplete and trying to replace it with a tile at a worse |
335 // scale. | 335 // scale. |
336 if (iter->contents_scale() != raster_contents_scale_ && | 336 if (iter->contents_scale() != raster_contents_scale_ && |
337 iter->contents_scale() != ideal_contents_scale_ && | 337 iter->contents_scale() != ideal_contents_scale_ && |
338 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { | 338 geometry_rect.Intersects(scaled_viewport_for_tile_priority)) { |
339 append_quads_data->num_incomplete_tiles++; | 339 append_quads_data->num_incomplete_tiles++; |
340 } | 340 } |
341 | 341 |
342 TileDrawQuad* quad = | 342 TileDrawQuad* quad = |
343 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); | 343 render_pass->CreateAndAppendDrawQuad<TileDrawQuad>(); |
344 quad->SetNew(shared_quad_state, | 344 quad->SetNew(shared_quad_state, |
345 geometry_rect, | 345 geometry_rect, |
346 opaque_rect, | 346 opaque_rect, |
347 visible_geometry_rect, | 347 visible_geometry_rect, |
348 draw_info.get_resource_id(), | 348 draw_info.get_resource_id(), |
349 texture_rect, | 349 texture_rect, |
350 iter.texture_size(), | 350 iter.texture_size(), |
351 draw_info.contents_swizzled(), | 351 draw_info.contents_swizzled(), |
352 nearest_neighbor_); | 352 nearest_neighbor_); |
353 has_draw_quad = true; | 353 has_draw_quad = true; |
354 break; | 354 break; |
355 } | 355 } |
356 case ManagedTileState::DrawInfo::PICTURE_PILE_MODE: { | 356 case TileDrawInfo::PICTURE_PILE_MODE: { |
357 if (!layer_tree_impl() | 357 if (!layer_tree_impl() |
358 ->GetRendererCapabilities() | 358 ->GetRendererCapabilities() |
359 .allow_rasterize_on_demand) { | 359 .allow_rasterize_on_demand) { |
360 ++on_demand_missing_tile_count; | 360 ++on_demand_missing_tile_count; |
361 break; | 361 break; |
362 } | 362 } |
363 | 363 |
364 gfx::RectF texture_rect = iter.texture_rect(); | 364 gfx::RectF texture_rect = iter.texture_rect(); |
365 | 365 |
366 ResourceProvider* resource_provider = | 366 ResourceProvider* resource_provider = |
367 layer_tree_impl()->resource_provider(); | 367 layer_tree_impl()->resource_provider(); |
368 ResourceFormat format = | 368 ResourceFormat format = |
369 resource_provider->memory_efficient_texture_format(); | 369 resource_provider->memory_efficient_texture_format(); |
370 PictureDrawQuad* quad = | 370 PictureDrawQuad* quad = |
371 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); | 371 render_pass->CreateAndAppendDrawQuad<PictureDrawQuad>(); |
372 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, | 372 quad->SetNew(shared_quad_state, geometry_rect, opaque_rect, |
373 visible_geometry_rect, texture_rect, iter.texture_size(), | 373 visible_geometry_rect, texture_rect, iter.texture_size(), |
374 nearest_neighbor_, format, iter->content_rect(), | 374 nearest_neighbor_, format, iter->content_rect(), |
375 iter->contents_scale(), raster_source_); | 375 iter->contents_scale(), raster_source_); |
376 has_draw_quad = true; | 376 has_draw_quad = true; |
377 break; | 377 break; |
378 } | 378 } |
379 case ManagedTileState::DrawInfo::SOLID_COLOR_MODE: { | 379 case TileDrawInfo::SOLID_COLOR_MODE: { |
380 SolidColorDrawQuad* quad = | 380 SolidColorDrawQuad* quad = |
381 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 381 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
382 quad->SetNew(shared_quad_state, | 382 quad->SetNew(shared_quad_state, |
383 geometry_rect, | 383 geometry_rect, |
384 visible_geometry_rect, | 384 visible_geometry_rect, |
385 draw_info.get_solid_color(), | 385 draw_info.get_solid_color(), |
386 false); | 386 false); |
387 has_draw_quad = true; | 387 has_draw_quad = true; |
388 break; | 388 break; |
389 } | 389 } |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 if (!iter || !*iter) { | 786 if (!iter || !*iter) { |
787 *resource_id = 0; | 787 *resource_id = 0; |
788 return; | 788 return; |
789 } | 789 } |
790 | 790 |
791 // Masks only supported if they fit on exactly one tile. | 791 // Masks only supported if they fit on exactly one tile. |
792 DCHECK(iter.geometry_rect() == content_rect) | 792 DCHECK(iter.geometry_rect() == content_rect) |
793 << "iter rect " << iter.geometry_rect().ToString() << " content rect " | 793 << "iter rect " << iter.geometry_rect().ToString() << " content rect " |
794 << content_rect.ToString(); | 794 << content_rect.ToString(); |
795 | 795 |
796 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); | 796 const TileDrawInfo& draw_info = iter->draw_info(); |
797 if (!draw_info.IsReadyToDraw() || | 797 if (!draw_info.IsReadyToDraw() || |
798 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { | 798 draw_info.mode() != TileDrawInfo::RESOURCE_MODE) { |
799 *resource_id = 0; | 799 *resource_id = 0; |
800 return; | 800 return; |
801 } | 801 } |
802 | 802 |
803 *resource_id = draw_info.get_resource_id(); | 803 *resource_id = draw_info.get_resource_id(); |
804 *resource_size = iter.texture_size(); | 804 *resource_size = iter.texture_size(); |
805 } | 805 } |
806 | 806 |
807 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { | 807 void PictureLayerImpl::SetNearestNeighbor(bool nearest_neighbor) { |
808 if (nearest_neighbor_ == nearest_neighbor) | 808 if (nearest_neighbor_ == nearest_neighbor) |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 | 1306 |
1307 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { | 1307 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { |
1308 if (!layer_tree_impl()->IsActiveTree()) | 1308 if (!layer_tree_impl()->IsActiveTree()) |
1309 return true; | 1309 return true; |
1310 | 1310 |
1311 return AllTilesRequiredAreReadyToDraw( | 1311 return AllTilesRequiredAreReadyToDraw( |
1312 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); | 1312 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); |
1313 } | 1313 } |
1314 | 1314 |
1315 } // namespace cc | 1315 } // namespace cc |
OLD | NEW |