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 | 9 |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 | 138 |
139 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 139 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
140 AppendQuadsData* append_quads_data) { | 140 AppendQuadsData* append_quads_data) { |
141 DCHECK(!needs_post_commit_initialization_); | 141 DCHECK(!needs_post_commit_initialization_); |
142 gfx::Rect rect(visible_content_rect()); | 142 gfx::Rect rect(visible_content_rect()); |
143 gfx::Rect content_rect(content_bounds()); | 143 gfx::Rect content_rect(content_bounds()); |
144 | 144 |
145 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 145 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); |
146 PopulateSharedQuadState(shared_quad_state); | 146 PopulateSharedQuadState(shared_quad_state); |
147 | 147 |
148 gfx::Transform scaled_transform = draw_transform(); | |
149 scaled_transform.Scale(contents_scale_x(), contents_scale_x()); | |
enne (OOO)
2014/05/13 18:04:09
This contents_scale is the wrong value. You need
danakj
2014/05/13 18:10:07
the contents_scale_x() is going to be 1 always now
| |
150 | |
148 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 151 if (current_draw_mode_ == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
149 AppendDebugBorderQuad( | 152 AppendDebugBorderQuad( |
150 quad_sink, | 153 quad_sink, |
151 shared_quad_state, | 154 shared_quad_state, |
152 append_quads_data, | 155 append_quads_data, |
153 DebugColors::DirectPictureBorderColor(), | 156 DebugColors::DirectPictureBorderColor(), |
154 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); | 157 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
155 | 158 |
156 gfx::Rect geometry_rect = rect; | 159 gfx::Rect geometry_rect = rect; |
157 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 160 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
158 gfx::Rect visible_geometry_rect = | 161 gfx::Rect visible_geometry_rect = |
159 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 162 quad_sink->UnoccludedContentRect(geometry_rect, scaled_transform); |
160 if (visible_geometry_rect.IsEmpty()) | 163 if (visible_geometry_rect.IsEmpty()) |
161 return; | 164 return; |
162 | 165 |
163 gfx::Size texture_size = rect.size(); | 166 gfx::Size texture_size = rect.size(); |
164 gfx::RectF texture_rect = gfx::RectF(texture_size); | 167 gfx::RectF texture_rect = gfx::RectF(texture_size); |
165 gfx::Rect quad_content_rect = rect; | 168 gfx::Rect quad_content_rect = rect; |
166 float contents_scale = contents_scale_x(); | 169 float contents_scale = contents_scale_x(); |
167 | 170 |
168 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 171 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
169 quad->SetNew(shared_quad_state, | 172 quad->SetNew(shared_quad_state, |
170 geometry_rect, | 173 geometry_rect, |
171 opaque_rect, | 174 opaque_rect, |
172 visible_geometry_rect, | 175 visible_geometry_rect, |
173 texture_rect, | 176 texture_rect, |
174 texture_size, | 177 texture_size, |
175 RGBA_8888, | 178 RGBA_8888, |
176 quad_content_rect, | 179 quad_content_rect, |
177 contents_scale, | 180 contents_scale, |
178 pile_); | 181 pile_); |
179 quad_sink->Append(quad.PassAs<DrawQuad>()); | 182 quad_sink->Append(quad.PassAs<DrawQuad>()); |
180 append_quads_data->num_missing_tiles++; | 183 append_quads_data->num_missing_tiles++; |
181 return; | 184 return; |
182 } | 185 } |
183 | 186 |
184 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 187 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
185 | 188 |
186 if (ShowDebugBorders()) { | 189 if (ShowDebugBorders()) { |
187 for (PictureLayerTilingSet::CoverageIterator iter( | 190 for (PictureLayerTilingSet::CoverageIterator iter( |
188 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 191 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
enne (OOO)
2014/05/13 18:04:09
This should be max_contents_scale.
| |
189 iter; | 192 iter; |
190 ++iter) { | 193 ++iter) { |
191 SkColor color; | 194 SkColor color; |
192 float width; | 195 float width; |
193 if (*iter && iter->IsReadyToDraw()) { | 196 if (*iter && iter->IsReadyToDraw()) { |
194 ManagedTileState::TileVersion::Mode mode = | 197 ManagedTileState::TileVersion::Mode mode = |
195 iter->GetTileVersionForDrawing().mode(); | 198 iter->GetTileVersionForDrawing().mode(); |
196 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { | 199 if (mode == ManagedTileState::TileVersion::SOLID_COLOR_MODE) { |
197 color = DebugColors::SolidColorTileBorderColor(); | 200 color = DebugColors::SolidColorTileBorderColor(); |
198 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 201 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
(...skipping 30 matching lines...) Expand all Loading... | |
229 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); | 232 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); |
230 } | 233 } |
231 } | 234 } |
232 | 235 |
233 // Keep track of the tilings that were used so that tilings that are | 236 // Keep track of the tilings that were used so that tilings that are |
234 // unused can be considered for removal. | 237 // unused can be considered for removal. |
235 std::vector<PictureLayerTiling*> seen_tilings; | 238 std::vector<PictureLayerTiling*> seen_tilings; |
236 | 239 |
237 bool had_checkerboard_quads = false; | 240 bool had_checkerboard_quads = false; |
238 for (PictureLayerTilingSet::CoverageIterator iter( | 241 for (PictureLayerTilingSet::CoverageIterator iter( |
239 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 242 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
enne (OOO)
2014/05/13 18:04:09
This should be max_contents_scale.
danakj
2014/05/13 18:10:07
we should use the computed scale from above everyw
| |
240 iter; | 243 iter; |
241 ++iter) { | 244 ++iter) { |
242 gfx::Rect geometry_rect = iter.geometry_rect(); | 245 gfx::Rect geometry_rect = iter.geometry_rect(); |
243 gfx::Rect visible_geometry_rect = | 246 gfx::Rect visible_geometry_rect = |
244 quad_sink->UnoccludedContentRect(geometry_rect, draw_transform()); | 247 quad_sink->UnoccludedContentRect(geometry_rect, scaled_transform); |
245 if (visible_geometry_rect.IsEmpty()) | 248 if (visible_geometry_rect.IsEmpty()) |
246 continue; | 249 continue; |
247 | 250 |
248 append_quads_data->visible_content_area += | 251 append_quads_data->visible_content_area += |
249 visible_geometry_rect.width() * visible_geometry_rect.height(); | 252 visible_geometry_rect.width() * visible_geometry_rect.height(); |
250 | 253 |
251 if (!*iter || !iter->IsReadyToDraw()) { | 254 if (!*iter || !iter->IsReadyToDraw()) { |
252 had_checkerboard_quads = true; | 255 had_checkerboard_quads = true; |
253 if (draw_checkerboard_for_missing_tiles()) { | 256 if (draw_checkerboard_for_missing_tiles()) { |
254 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); | 257 scoped_ptr<CheckerboardDrawQuad> quad = CheckerboardDrawQuad::Create(); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 DCHECK_GT(min_page_scale, 0.f); | 494 DCHECK_GT(min_page_scale, 0.f); |
492 float min_device_scale = 1.f; | 495 float min_device_scale = 1.f; |
493 float min_source_scale = | 496 float min_source_scale = |
494 min_contents_scale / min_page_scale / min_device_scale; | 497 min_contents_scale / min_page_scale / min_device_scale; |
495 | 498 |
496 float ideal_page_scale = page_scale_factor; | 499 float ideal_page_scale = page_scale_factor; |
497 float ideal_device_scale = device_scale_factor; | 500 float ideal_device_scale = device_scale_factor; |
498 float ideal_source_scale = | 501 float ideal_source_scale = |
499 ideal_contents_scale / ideal_page_scale / ideal_device_scale; | 502 ideal_contents_scale / ideal_page_scale / ideal_device_scale; |
500 | 503 |
501 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); | 504 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); |
danakj
2014/05/13 18:10:07
we still need to compute these values, but during
| |
502 ideal_page_scale_ = ideal_page_scale; | 505 ideal_page_scale_ = ideal_page_scale; |
503 ideal_device_scale_ = ideal_device_scale; | 506 ideal_device_scale_ = ideal_device_scale; |
504 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | 507 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); |
505 | 508 |
506 ManageTilings(animating_transform_to_screen, | |
507 maximum_animation_contents_scale); | |
508 | |
509 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | 509 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. |
510 // There are (usually) several tilings at different scales. However, the | 510 // There are (usually) several tilings at different scales. However, the |
511 // content bounds is the (integer!) space in which quads are generated. | 511 // content bounds is the (integer!) space in which quads are generated. |
512 // In order to guarantee that we can fill this integer space with any set of | 512 // In order to guarantee that we can fill this integer space with any set of |
513 // tilings (and then map back to floating point texture coordinates), the | 513 // tilings (and then map back to floating point texture coordinates), the |
514 // contents scale must be at least as large as the largest of the tilings. | 514 // contents scale must be at least as large as the largest of the tilings. |
515 float max_contents_scale = min_contents_scale; | 515 float max_contents_scale = min_contents_scale; |
516 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 516 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
517 const PictureLayerTiling* tiling = tilings_->tiling_at(i); | 517 const PictureLayerTiling* tiling = tilings_->tiling_at(i); |
518 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); | 518 max_contents_scale = std::max(max_contents_scale, tiling->contents_scale()); |
519 } | 519 } |
520 | |
521 *contents_scale_x = max_contents_scale; | 520 *contents_scale_x = max_contents_scale; |
danakj
2014/05/13 18:10:07
we would always set these to 1 now, and move this
|
enne (OOO)
2014/05/13 18:04:09
You need to remove this whole block of code and ju
danakj
2014/05/13 18:11:41
The LayerImpl implementation of this method should
|
522 *contents_scale_y = max_contents_scale; | 521 *contents_scale_y = max_contents_scale; |
523 *content_bounds = gfx::ToCeiledSize( | 522 *content_bounds = gfx::ToCeiledSize( |
524 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); | 523 gfx::ScaleSize(bounds(), max_contents_scale, max_contents_scale)); |
525 } | 524 } |
526 | 525 |
527 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 526 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
528 return pile_->GetFlattenedPicture(); | 527 return pile_->GetFlattenedPicture(); |
529 } | 528 } |
530 | 529 |
531 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 530 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); | 692 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); |
694 } else { | 693 } else { |
695 RemoveAllTilings(); | 694 RemoveAllTilings(); |
696 } | 695 } |
697 | 696 |
698 SanityCheckTilingState(); | 697 SanityCheckTilingState(); |
699 } | 698 } |
700 | 699 |
701 void PictureLayerImpl::SyncTiling( | 700 void PictureLayerImpl::SyncTiling( |
702 const PictureLayerTiling* tiling) { | 701 const PictureLayerTiling* tiling) { |
703 if (!CanHaveTilingWithScale(tiling->contents_scale())) | 702 if (!CanHaveTilingWithScale(tiling->contents_scale()) || |
703 !IsDrawnRenderSurfaceLayerListMember()) | |
704 return; | 704 return; |
705 tilings_->AddTiling(tiling->contents_scale()); | 705 tilings_->AddTiling(tiling->contents_scale()); |
706 | 706 |
707 // If this tree needs update draw properties, then the tiling will | 707 // If this tree needs update draw properties, then the tiling will |
708 // get updated prior to drawing or activation. If this tree does not | 708 // get updated prior to drawing or activation. If this tree does not |
709 // need update draw properties, then its transforms are up to date and | 709 // need update draw properties, then its transforms are up to date and |
710 // we can create tiles for this tiling immediately. | 710 // we can create tiles for this tiling immediately. |
711 if (!layer_tree_impl()->needs_update_draw_properties() && | 711 if (!layer_tree_impl()->needs_update_draw_properties() && |
712 should_update_tile_priorities_) { | 712 should_update_tile_priorities_) { |
713 UpdateTilePriorities(); | 713 UpdateTilePriorities(); |
714 } | 714 } |
715 } | 715 } |
716 | 716 |
717 void PictureLayerImpl::SetIsMask(bool is_mask) { | 717 void PictureLayerImpl::SetIsMask(bool is_mask) { |
718 if (is_mask_ == is_mask) | 718 if (is_mask_ == is_mask) |
719 return; | 719 return; |
720 is_mask_ = is_mask; | 720 is_mask_ = is_mask; |
721 if (tilings_) | 721 if (tilings_) |
722 tilings_->RemoveAllTiles(); | 722 tilings_->RemoveAllTiles(); |
723 } | 723 } |
724 | 724 |
725 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { | 725 ResourceProvider::ResourceId PictureLayerImpl::ContentsResourceId() const { |
726 gfx::Rect content_rect(content_bounds()); | 726 gfx::Rect content_rect(content_bounds()); |
727 float scale = contents_scale_x(); | 727 float scale = contents_scale_x(); |
danakj
2014/05/13 18:10:07
This should also be the max scale from the tilings
| |
728 PictureLayerTilingSet::CoverageIterator iter( | 728 PictureLayerTilingSet::CoverageIterator iter( |
729 tilings_.get(), scale, content_rect, ideal_contents_scale_); | 729 tilings_.get(), scale, content_rect, ideal_contents_scale_); |
730 | 730 |
731 // Mask resource not ready yet. | 731 // Mask resource not ready yet. |
732 if (!iter || !*iter) | 732 if (!iter || !*iter) |
733 return 0; | 733 return 0; |
734 | 734 |
735 // Masks only supported if they fit on exactly one tile. | 735 // Masks only supported if they fit on exactly one tile. |
736 if (iter.geometry_rect() != content_rect) | 736 if (iter.geometry_rect() != content_rect) |
737 return 0; | 737 return 0; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 << "A layer with no tilings shouldn't have valid raster scales"; | 975 << "A layer with no tilings shouldn't have valid raster scales"; |
976 } | 976 } |
977 | 977 |
978 if (change_target_tiling) { | 978 if (change_target_tiling) { |
979 RecalculateRasterScales(animating_transform_to_screen, | 979 RecalculateRasterScales(animating_transform_to_screen, |
980 maximum_animation_contents_scale); | 980 maximum_animation_contents_scale); |
981 } | 981 } |
982 | 982 |
983 was_animating_transform_to_screen_ = animating_transform_to_screen; | 983 was_animating_transform_to_screen_ = animating_transform_to_screen; |
984 | 984 |
985 if (!change_target_tiling) | 985 if (!change_target_tiling || !IsDrawnRenderSurfaceLayerListMember()) |
danakj
2014/05/13 18:10:07
Let's do this change separately
| |
986 return; | 986 return; |
987 | 987 |
988 PictureLayerTiling* high_res = NULL; | 988 PictureLayerTiling* high_res = NULL; |
989 PictureLayerTiling* low_res = NULL; | 989 PictureLayerTiling* low_res = NULL; |
990 | 990 |
991 PictureLayerTiling* previous_low_res = NULL; | 991 PictureLayerTiling* previous_low_res = NULL; |
992 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 992 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
993 PictureLayerTiling* tiling = tilings_->tiling_at(i); | 993 PictureLayerTiling* tiling = tilings_->tiling_at(i); |
994 if (tiling->contents_scale() == raster_contents_scale_) | 994 if (tiling->contents_scale() == raster_contents_scale_) |
995 high_res = tiling; | 995 high_res = tiling; |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 return iterator_index_ < iterators_.size(); | 1557 return iterator_index_ < iterators_.size(); |
1558 } | 1558 } |
1559 | 1559 |
1560 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( | 1560 bool PictureLayerImpl::LayerEvictionTileIterator::IsCorrectType( |
1561 PictureLayerTiling::TilingEvictionTileIterator* it) const { | 1561 PictureLayerTiling::TilingEvictionTileIterator* it) const { |
1562 return it->get_type() == iteration_stage_ && | 1562 return it->get_type() == iteration_stage_ && |
1563 (**it)->required_for_activation() == required_for_activation_; | 1563 (**it)->required_for_activation() == required_for_activation_; |
1564 } | 1564 } |
1565 | 1565 |
1566 } // namespace cc | 1566 } // namespace cc |
OLD | NEW |