| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 invalidation_.Clear(); | 105 invalidation_.Clear(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 108 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 109 AppendQuadsData* append_quads_data) { | 109 AppendQuadsData* append_quads_data) { |
| 110 gfx::Rect rect(visible_content_rect()); | 110 gfx::Rect rect(visible_content_rect()); |
| 111 gfx::Rect content_rect(content_bounds()); | 111 gfx::Rect content_rect(content_bounds()); |
| 112 | 112 |
| 113 SharedQuadState* shared_quad_state = | 113 SharedQuadState* shared_quad_state = |
| 114 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 114 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
| 115 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | |
| 116 | 115 |
| 117 if (!append_quads_data->allow_tile_draw_quads) { | 116 bool draw_direct_to_backbuffer = |
| 117 draw_properties().can_draw_directly_to_backbuffer && |
| 118 layer_tree_impl()->settings().force_direct_layer_drawing; |
| 119 |
| 120 if (draw_direct_to_backbuffer || !append_quads_data->allow_tile_draw_quads) { |
| 121 AppendDebugBorderQuad( |
| 122 quad_sink, |
| 123 shared_quad_state, |
| 124 append_quads_data, |
| 125 DebugColors::DirectPictureBorderColor(), |
| 126 DebugColors::DirectPictureBorderWidth(layer_tree_impl())); |
| 127 |
| 118 gfx::Rect geometry_rect = rect; | 128 gfx::Rect geometry_rect = rect; |
| 119 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 129 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
| 120 gfx::Size texture_size = rect.size(); | 130 gfx::Size texture_size = rect.size(); |
| 121 gfx::RectF texture_rect = gfx::RectF(texture_size); | 131 gfx::RectF texture_rect = gfx::RectF(texture_size); |
| 122 gfx::Rect quad_content_rect = rect; | 132 gfx::Rect quad_content_rect = rect; |
| 123 float contents_scale = contents_scale_x(); | 133 float contents_scale = contents_scale_x(); |
| 124 | 134 |
| 125 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 135 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 126 quad->SetNew(shared_quad_state, | 136 quad->SetNew(shared_quad_state, |
| 127 geometry_rect, | 137 geometry_rect, |
| 128 opaque_rect, | 138 opaque_rect, |
| 129 texture_rect, | 139 texture_rect, |
| 130 texture_size, | 140 texture_size, |
| 131 false, | 141 false, |
| 132 quad_content_rect, | 142 quad_content_rect, |
| 133 contents_scale, | 143 contents_scale, |
| 144 draw_direct_to_backbuffer, |
| 134 pile_); | 145 pile_); |
| 135 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) | 146 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| 136 append_quads_data->num_missing_tiles++; | 147 append_quads_data->num_missing_tiles++; |
| 137 return; | 148 return; |
| 138 } | 149 } |
| 139 | 150 |
| 151 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 152 |
| 140 bool clipped = false; | 153 bool clipped = false; |
| 141 gfx::QuadF target_quad = MathUtil::MapQuad( | 154 gfx::QuadF target_quad = MathUtil::MapQuad( |
| 142 draw_transform(), | 155 draw_transform(), |
| 143 gfx::QuadF(rect), | 156 gfx::QuadF(rect), |
| 144 &clipped); | 157 &clipped); |
| 145 if (ShowDebugBorders()) { | 158 if (ShowDebugBorders()) { |
| 146 for (PictureLayerTilingSet::CoverageIterator iter( | 159 for (PictureLayerTilingSet::CoverageIterator iter( |
| 147 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 160 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
| 148 iter; | 161 iter; |
| 149 ++iter) { | 162 ++iter) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 270 |
| 258 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 271 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 259 quad->SetNew(shared_quad_state, | 272 quad->SetNew(shared_quad_state, |
| 260 geometry_rect, | 273 geometry_rect, |
| 261 opaque_rect, | 274 opaque_rect, |
| 262 texture_rect, | 275 texture_rect, |
| 263 iter.texture_size(), | 276 iter.texture_size(), |
| 264 tile_version.contents_swizzled(), | 277 tile_version.contents_swizzled(), |
| 265 iter->content_rect(), | 278 iter->content_rect(), |
| 266 iter->contents_scale(), | 279 iter->contents_scale(), |
| 280 draw_direct_to_backbuffer, |
| 267 pile_); | 281 pile_); |
| 268 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 282 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 269 break; | 283 break; |
| 270 } | 284 } |
| 271 case ManagedTileState::TileVersion::SOLID_COLOR_MODE: { | 285 case ManagedTileState::TileVersion::SOLID_COLOR_MODE: { |
| 272 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 286 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 273 quad->SetNew(shared_quad_state, | 287 quad->SetNew(shared_quad_state, |
| 274 geometry_rect, | 288 geometry_rect, |
| 275 tile_version.get_solid_color(), | 289 tile_version.get_solid_color(), |
| 276 false); | 290 false); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 377 } |
| 364 | 378 |
| 365 void PictureLayerImpl::CalculateContentsScale( | 379 void PictureLayerImpl::CalculateContentsScale( |
| 366 float ideal_contents_scale, | 380 float ideal_contents_scale, |
| 367 float device_scale_factor, | 381 float device_scale_factor, |
| 368 float page_scale_factor, | 382 float page_scale_factor, |
| 369 bool animating_transform_to_screen, | 383 bool animating_transform_to_screen, |
| 370 float* contents_scale_x, | 384 float* contents_scale_x, |
| 371 float* contents_scale_y, | 385 float* contents_scale_y, |
| 372 gfx::Size* content_bounds) { | 386 gfx::Size* content_bounds) { |
| 373 if (!DrawsContent()) { | 387 if (!CanHaveTilings()) { |
| 374 DCHECK(!tilings_->num_tilings()); | 388 ideal_page_scale_ = page_scale_factor; |
| 389 ideal_device_scale_ = device_scale_factor; |
| 390 ideal_contents_scale_ = ideal_contents_scale; |
| 391 ideal_source_scale_ = |
| 392 ideal_contents_scale_ / ideal_page_scale_ / ideal_device_scale_; |
| 393 *contents_scale_x = ideal_contents_scale_; |
| 394 *contents_scale_y = ideal_contents_scale_; |
| 395 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), |
| 396 ideal_contents_scale_, |
| 397 ideal_contents_scale_)); |
| 375 return; | 398 return; |
| 376 } | 399 } |
| 377 | 400 |
| 378 float min_contents_scale = MinimumContentsScale(); | 401 float min_contents_scale = MinimumContentsScale(); |
| 379 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | 402 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
| 380 float min_device_scale = 1.f; | 403 float min_device_scale = 1.f; |
| 381 float min_source_scale = | 404 float min_source_scale = |
| 382 min_contents_scale / min_page_scale / min_device_scale; | 405 min_contents_scale / min_page_scale / min_device_scale; |
| 383 | 406 |
| 384 float ideal_page_scale = page_scale_factor; | 407 float ideal_page_scale = page_scale_factor; |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 return ratio1 < ratio2; | 730 return ratio1 < ratio2; |
| 708 } | 731 } |
| 709 | 732 |
| 710 } // namespace | 733 } // namespace |
| 711 | 734 |
| 712 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { | 735 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| 713 DCHECK(ideal_contents_scale_); | 736 DCHECK(ideal_contents_scale_); |
| 714 DCHECK(ideal_page_scale_); | 737 DCHECK(ideal_page_scale_); |
| 715 DCHECK(ideal_device_scale_); | 738 DCHECK(ideal_device_scale_); |
| 716 DCHECK(ideal_source_scale_); | 739 DCHECK(ideal_source_scale_); |
| 717 | 740 DCHECK(CanHaveTilings()); |
| 718 if (!CanHaveTilings()) | |
| 719 return; | |
| 720 | 741 |
| 721 bool change_target_tiling = | 742 bool change_target_tiling = |
| 722 raster_page_scale_ == 0.f || | 743 raster_page_scale_ == 0.f || |
| 723 raster_device_scale_ == 0.f || | 744 raster_device_scale_ == 0.f || |
| 724 raster_source_scale_ == 0.f || | 745 raster_source_scale_ == 0.f || |
| 725 raster_contents_scale_ == 0.f || | 746 raster_contents_scale_ == 0.f || |
| 726 low_res_raster_contents_scale_ == 0.f || | 747 low_res_raster_contents_scale_ == 0.f || |
| 727 ShouldAdjustRasterScale(animating_transform_to_screen); | 748 ShouldAdjustRasterScale(animating_transform_to_screen); |
| 728 | 749 |
| 729 if (layer_tree_impl()->IsActiveTree()) { | 750 if (layer_tree_impl()->IsActiveTree()) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 low_res_raster_contents_scale_ = 0.f; | 956 low_res_raster_contents_scale_ = 0.f; |
| 936 } | 957 } |
| 937 | 958 |
| 938 bool PictureLayerImpl::CanHaveTilings() const { | 959 bool PictureLayerImpl::CanHaveTilings() const { |
| 939 if (!DrawsContent()) | 960 if (!DrawsContent()) |
| 940 return false; | 961 return false; |
| 941 if (pile_->recorded_region().IsEmpty()) | 962 if (pile_->recorded_region().IsEmpty()) |
| 942 return false; | 963 return false; |
| 943 if (!layer_tree_impl()->tile_manager()) | 964 if (!layer_tree_impl()->tile_manager()) |
| 944 return false; | 965 return false; |
| 966 if (draw_properties().can_draw_directly_to_backbuffer && |
| 967 layer_tree_impl()->settings().force_direct_layer_drawing) |
| 968 return false; |
| 945 return true; | 969 return true; |
| 946 } | 970 } |
| 947 | 971 |
| 948 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 972 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
| 949 if (!CanHaveTilings()) | 973 if (!CanHaveTilings()) |
| 950 return false; | 974 return false; |
| 951 if (contents_scale < MinimumContentsScale()) | 975 if (contents_scale < MinimumContentsScale()) |
| 952 return false; | 976 return false; |
| 953 return true; | 977 return true; |
| 954 } | 978 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 966 state->Set("tilings", tilings_->AsValue().release()); | 990 state->Set("tilings", tilings_->AsValue().release()); |
| 967 state->Set("pictures", pile_->AsValue().release()); | 991 state->Set("pictures", pile_->AsValue().release()); |
| 968 state->Set("invalidation", invalidation_.AsValue().release()); | 992 state->Set("invalidation", invalidation_.AsValue().release()); |
| 969 } | 993 } |
| 970 | 994 |
| 971 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { | 995 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |
| 972 return tilings_->GPUMemoryUsageInBytes(); | 996 return tilings_->GPUMemoryUsageInBytes(); |
| 973 } | 997 } |
| 974 | 998 |
| 975 } // namespace cc | 999 } // namespace cc |
| OLD | NEW |