Chromium Code Reviews| 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 | 8 |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 SharedQuadState* shared_quad_state = | 98 SharedQuadState* shared_quad_state = |
| 99 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 99 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
| 100 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 100 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 101 | 101 |
| 102 bool clipped = false; | 102 bool clipped = false; |
| 103 gfx::QuadF target_quad = MathUtil::MapQuad( | 103 gfx::QuadF target_quad = MathUtil::MapQuad( |
| 104 draw_transform(), | 104 draw_transform(), |
| 105 gfx::QuadF(rect), | 105 gfx::QuadF(rect), |
| 106 &clipped); | 106 &clipped); |
| 107 if (ShowDebugBorders()) { | 107 if (ShowDebugBorders()) { |
| 108 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 108 for (PictureLayerTilingSet::CoverageIterator iter( |
| 109 contents_scale_x(), | 109 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
| 110 rect, | |
| 111 ideal_contents_scale_); | |
| 112 iter; | 110 iter; |
| 113 ++iter) { | 111 ++iter) { |
| 114 SkColor color; | 112 SkColor color; |
| 115 float width; | 113 float width; |
| 116 if (*iter && iter->drawing_info().IsReadyToDraw()) { | 114 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
| 117 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); | 115 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); |
| 118 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || | 116 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || |
| 119 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { | 117 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { |
| 120 color = DebugColors::SolidColorTileBorderColor(); | 118 color = DebugColors::SolidColorTileBorderColor(); |
| 121 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 119 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 143 debug_border_quad->SetNew(shared_quad_state, geometry_rect, color, width); | 141 debug_border_quad->SetNew(shared_quad_state, geometry_rect, color, width); |
| 144 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>(), | 142 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>(), |
| 145 append_quads_data); | 143 append_quads_data); |
| 146 } | 144 } |
| 147 } | 145 } |
| 148 | 146 |
| 149 // Keep track of the tilings that were used so that tilings that are | 147 // Keep track of the tilings that were used so that tilings that are |
| 150 // unused can be considered for removal. | 148 // unused can be considered for removal. |
| 151 std::vector<PictureLayerTiling*> seen_tilings; | 149 std::vector<PictureLayerTiling*> seen_tilings; |
| 152 | 150 |
| 153 for (PictureLayerTilingSet::Iterator iter(tilings_.get(), | 151 for (PictureLayerTilingSet::CoverageIterator iter( |
| 154 contents_scale_x(), | 152 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
| 155 rect, | |
| 156 ideal_contents_scale_); | |
| 157 iter; | 153 iter; |
| 158 ++iter) { | 154 ++iter) { |
| 159 gfx::Rect geometry_rect = iter.geometry_rect(); | 155 gfx::Rect geometry_rect = iter.geometry_rect(); |
| 160 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { | 156 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { |
| 161 if (DrawCheckerboardForMissingTiles()) { | 157 if (DrawCheckerboardForMissingTiles()) { |
| 162 // TODO(enne): Figure out how to show debug "invalidated checker" color | 158 // TODO(enne): Figure out how to show debug "invalidated checker" color |
| 163 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 159 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
| 164 SkColor color = DebugColors::DefaultCheckerboardColor(); | 160 SkColor color = DebugColors::DefaultCheckerboardColor(); |
| 165 quad->SetNew(shared_quad_state, geometry_rect, color); | 161 quad->SetNew(shared_quad_state, geometry_rect, color); |
| 166 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) | 162 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 if (is_mask_ == is_mask) | 468 if (is_mask_ == is_mask) |
| 473 return; | 469 return; |
| 474 is_mask_ = is_mask; | 470 is_mask_ = is_mask; |
| 475 if (tilings_) | 471 if (tilings_) |
| 476 tilings_->RemoveAllTiles(); | 472 tilings_->RemoveAllTiles(); |
| 477 } | 473 } |
| 478 | 474 |
| 479 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 475 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
| 480 gfx::Rect content_rect(content_bounds()); | 476 gfx::Rect content_rect(content_bounds()); |
| 481 float scale = contents_scale_x(); | 477 float scale = contents_scale_x(); |
| 482 for (PictureLayerTilingSet::Iterator | 478 for (PictureLayerTilingSet::CoverageIterator |
| 483 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); | 479 iter(tilings_.get(), scale, content_rect, ideal_contents_scale_); |
| 484 iter; | 480 iter; |
| 485 ++iter) { | 481 ++iter) { |
| 486 // Mask resource not ready yet. | 482 // Mask resource not ready yet. |
| 487 if (!*iter || | 483 if (!*iter || |
| 488 iter->drawing_info().mode() != | 484 iter->drawing_info().mode() != |
| 489 ManagedTileState::DrawingInfo::TEXTURE_MODE || | 485 ManagedTileState::DrawingInfo::TEXTURE_MODE || |
| 490 !iter->drawing_info().IsReadyToDraw()) | 486 !iter->drawing_info().IsReadyToDraw()) |
| 491 return 0; | 487 return 0; |
| 492 // Masks only supported if they fit on exactly one tile. | 488 // Masks only supported if they fit on exactly one tile. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 519 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_)); | 515 std::min(twin->ideal_contents_scale_, twin->raster_contents_scale_)); |
| 520 } | 516 } |
| 521 | 517 |
| 522 Region missing_region = rect; | 518 Region missing_region = rect; |
| 523 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 519 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| 524 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 520 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
| 525 | 521 |
| 526 if (tiling->contents_scale() < min_acceptable_scale) | 522 if (tiling->contents_scale() < min_acceptable_scale) |
| 527 continue; | 523 continue; |
| 528 | 524 |
| 529 for (PictureLayerTiling::Iterator iter(tiling, contents_scale_x(), rect); | 525 for (PictureLayerTiling::CoverageIterator |
|
danakj
2013/03/27 23:52:58
nit: is this wrapping super weird or is it just me
enne (OOO)
2013/03/28 17:45:07
Yeah, that is really unexpected. Filed http://b/8
| |
| 526 iter(tiling, contents_scale_x(), rect); | |
| 530 iter; | 527 iter; |
| 531 ++iter) { | 528 ++iter) { |
| 532 if (should_force_uploads && *iter) | 529 if (should_force_uploads && *iter) |
| 533 layer_tree_impl()->tile_manager()->ForceTileUploadToComplete(*iter); | 530 layer_tree_impl()->tile_manager()->ForceTileUploadToComplete(*iter); |
| 534 // A null tile (i.e. no recording) is considered "ready". | 531 // A null tile (i.e. no recording) is considered "ready". |
| 535 if (!*iter || iter->drawing_info().IsReadyToDraw()) | 532 if (!*iter || iter->drawing_info().IsReadyToDraw()) |
| 536 missing_region.Subtract(iter.geometry_rect()); | 533 missing_region.Subtract(iter.geometry_rect()); |
| 537 } | 534 } |
| 538 } | 535 } |
| 539 | 536 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 841 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 838 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
| 842 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 839 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 843 LayerImpl::AsValueInto(state.get()); | 840 LayerImpl::AsValueInto(state.get()); |
| 844 | 841 |
| 845 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 842 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 846 state->Set("tilings", tilings_->AsValue().release()); | 843 state->Set("tilings", tilings_->AsValue().release()); |
| 847 return state.PassAs<base::Value>(); | 844 return state.PassAs<base::Value>(); |
| 848 } | 845 } |
| 849 | 846 |
| 850 } // namespace cc | 847 } // namespace cc |
| OLD | NEW |