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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 101 |
| 102 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 102 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 103 AppendQuadsData* append_quads_data) { | 103 AppendQuadsData* append_quads_data) { |
| 104 gfx::Rect rect(visible_content_rect()); | 104 gfx::Rect rect(visible_content_rect()); |
| 105 gfx::Rect content_rect(content_bounds()); | 105 gfx::Rect content_rect(content_bounds()); |
| 106 | 106 |
| 107 SharedQuadState* shared_quad_state = | 107 SharedQuadState* shared_quad_state = |
| 108 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 108 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
| 109 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 109 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 110 | 110 |
| 111 if (!append_quads_data->allow_tile_draw_quads) { | 111 bool use_ganesh = draw_properties().can_draw_directly_to_backbuffer && |
|
danakj
2013/05/17 23:24:01
nit: ganesh
enne (OOO)
2013/05/17 23:52:50
Done.
| |
| 112 layer_tree_impl()->settings().force_direct_layer_drawing; | |
| 113 | |
| 114 if (use_ganesh || !append_quads_data->allow_tile_draw_quads) { | |
| 112 gfx::Rect geometry_rect = rect; | 115 gfx::Rect geometry_rect = rect; |
| 113 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 116 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
| 114 gfx::Size texture_size = rect.size(); | 117 gfx::Size texture_size = rect.size(); |
| 115 gfx::RectF texture_rect = gfx::RectF(texture_size); | 118 gfx::RectF texture_rect = gfx::RectF(texture_size); |
| 116 gfx::Rect quad_content_rect = rect; | 119 gfx::Rect quad_content_rect = rect; |
| 117 float contents_scale = contents_scale_x(); | 120 float contents_scale = contents_scale_x(); |
| 118 | 121 |
| 119 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 122 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 120 quad->SetNew(shared_quad_state, | 123 quad->SetNew(shared_quad_state, |
| 121 geometry_rect, | 124 geometry_rect, |
| 122 opaque_rect, | 125 opaque_rect, |
| 123 texture_rect, | 126 texture_rect, |
| 124 texture_size, | 127 texture_size, |
| 125 false, | 128 false, |
| 126 quad_content_rect, | 129 quad_content_rect, |
| 127 contents_scale, | 130 contents_scale, |
| 131 use_ganesh, | |
| 128 pile_); | 132 pile_); |
| 129 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) | 133 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| 130 append_quads_data->num_missing_tiles++; | 134 append_quads_data->num_missing_tiles++; |
| 131 return; | 135 return; |
| 132 } | 136 } |
| 133 | 137 |
| 134 bool clipped = false; | 138 bool clipped = false; |
| 135 gfx::QuadF target_quad = MathUtil::MapQuad( | 139 gfx::QuadF target_quad = MathUtil::MapQuad( |
| 136 draw_transform(), | 140 draw_transform(), |
| 137 gfx::QuadF(rect), | 141 gfx::QuadF(rect), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 | 255 |
| 252 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 256 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 253 quad->SetNew(shared_quad_state, | 257 quad->SetNew(shared_quad_state, |
| 254 geometry_rect, | 258 geometry_rect, |
| 255 opaque_rect, | 259 opaque_rect, |
| 256 texture_rect, | 260 texture_rect, |
| 257 iter.texture_size(), | 261 iter.texture_size(), |
| 258 drawing_info.contents_swizzled(), | 262 drawing_info.contents_swizzled(), |
| 259 iter->content_rect(), | 263 iter->content_rect(), |
| 260 iter->contents_scale(), | 264 iter->contents_scale(), |
| 265 use_ganesh, | |
| 261 pile_); | 266 pile_); |
| 262 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 267 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 263 break; | 268 break; |
| 264 } | 269 } |
| 265 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 270 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
| 266 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 271 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 267 quad->SetNew(shared_quad_state, | 272 quad->SetNew(shared_quad_state, |
| 268 geometry_rect, | 273 geometry_rect, |
| 269 drawing_info.get_solid_color(), | 274 drawing_info.get_solid_color(), |
| 270 false); | 275 false); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 } | 362 } |
| 358 | 363 |
| 359 void PictureLayerImpl::CalculateContentsScale( | 364 void PictureLayerImpl::CalculateContentsScale( |
| 360 float ideal_contents_scale, | 365 float ideal_contents_scale, |
| 361 float device_scale_factor, | 366 float device_scale_factor, |
| 362 float page_scale_factor, | 367 float page_scale_factor, |
| 363 bool animating_transform_to_screen, | 368 bool animating_transform_to_screen, |
| 364 float* contents_scale_x, | 369 float* contents_scale_x, |
| 365 float* contents_scale_y, | 370 float* contents_scale_y, |
| 366 gfx::Size* content_bounds) { | 371 gfx::Size* content_bounds) { |
| 367 if (!DrawsContent()) { | 372 if (!CanHaveTilings()) { |
| 368 DCHECK(!tilings_->num_tilings()); | 373 *contents_scale_x = ideal_contents_scale_; |
|
danakj
2013/05/17 23:24:01
the ideal value still needs to be set on the class
enne (OOO)
2013/05/17 23:52:50
OOPS. I will set all values here for sanity.
| |
| 374 *contents_scale_y = ideal_contents_scale_; | |
| 375 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), | |
| 376 ideal_contents_scale_, | |
| 377 ideal_contents_scale_)); | |
| 369 return; | 378 return; |
| 370 } | 379 } |
| 371 | 380 |
| 372 float min_contents_scale = MinimumContentsScale(); | 381 float min_contents_scale = MinimumContentsScale(); |
| 373 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); | 382 float min_page_scale = layer_tree_impl()->min_page_scale_factor(); |
| 374 float min_device_scale = 1.f; | 383 float min_device_scale = 1.f; |
| 375 float min_source_scale = | 384 float min_source_scale = |
| 376 min_contents_scale / min_page_scale / min_device_scale; | 385 min_contents_scale / min_page_scale / min_device_scale; |
| 377 | 386 |
| 378 float ideal_page_scale = page_scale_factor; | 387 float ideal_page_scale = page_scale_factor; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 return ratio1 < ratio2; | 704 return ratio1 < ratio2; |
| 696 } | 705 } |
| 697 | 706 |
| 698 } // namespace | 707 } // namespace |
| 699 | 708 |
| 700 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { | 709 void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) { |
| 701 DCHECK(ideal_contents_scale_); | 710 DCHECK(ideal_contents_scale_); |
| 702 DCHECK(ideal_page_scale_); | 711 DCHECK(ideal_page_scale_); |
| 703 DCHECK(ideal_device_scale_); | 712 DCHECK(ideal_device_scale_); |
| 704 DCHECK(ideal_source_scale_); | 713 DCHECK(ideal_source_scale_); |
| 705 | 714 DCHECK(CanHaveTilings()); |
| 706 if (!CanHaveTilings()) | |
| 707 return; | |
| 708 | 715 |
| 709 bool change_target_tiling = | 716 bool change_target_tiling = |
| 710 raster_page_scale_ == 0.f || | 717 raster_page_scale_ == 0.f || |
| 711 raster_device_scale_ == 0.f || | 718 raster_device_scale_ == 0.f || |
| 712 raster_source_scale_ == 0.f || | 719 raster_source_scale_ == 0.f || |
| 713 raster_contents_scale_ == 0.f || | 720 raster_contents_scale_ == 0.f || |
| 714 low_res_raster_contents_scale_ == 0.f || | 721 low_res_raster_contents_scale_ == 0.f || |
| 715 ShouldAdjustRasterScale(animating_transform_to_screen); | 722 ShouldAdjustRasterScale(animating_transform_to_screen); |
| 716 | 723 |
| 717 if (layer_tree_impl()->IsActiveTree()) { | 724 if (layer_tree_impl()->IsActiveTree()) { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 raster_source_scale_ = 0.f; | 948 raster_source_scale_ = 0.f; |
| 942 raster_contents_scale_ = 0.f; | 949 raster_contents_scale_ = 0.f; |
| 943 low_res_raster_contents_scale_ = 0.f; | 950 low_res_raster_contents_scale_ = 0.f; |
| 944 } | 951 } |
| 945 | 952 |
| 946 bool PictureLayerImpl::CanHaveTilings() const { | 953 bool PictureLayerImpl::CanHaveTilings() const { |
| 947 if (!DrawsContent()) | 954 if (!DrawsContent()) |
| 948 return false; | 955 return false; |
| 949 if (pile_->recorded_region().IsEmpty()) | 956 if (pile_->recorded_region().IsEmpty()) |
| 950 return false; | 957 return false; |
| 958 if (draw_properties().can_draw_directly_to_backbuffer && | |
| 959 layer_tree_impl()->settings().force_direct_layer_drawing) | |
| 960 return false; | |
| 951 return true; | 961 return true; |
| 952 } | 962 } |
| 953 | 963 |
| 954 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 964 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
| 955 if (!CanHaveTilings()) | 965 if (!CanHaveTilings()) |
| 956 return false; | 966 return false; |
| 957 if (contents_scale < MinimumContentsScale()) | 967 if (contents_scale < MinimumContentsScale()) |
| 958 return false; | 968 return false; |
| 959 return true; | 969 return true; |
| 960 } | 970 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 972 state->Set("tilings", tilings_->AsValue().release()); | 982 state->Set("tilings", tilings_->AsValue().release()); |
| 973 state->Set("pictures", pile_->AsValue().release()); | 983 state->Set("pictures", pile_->AsValue().release()); |
| 974 state->Set("invalidation", invalidation_.AsValue().release()); | 984 state->Set("invalidation", invalidation_.AsValue().release()); |
| 975 } | 985 } |
| 976 | 986 |
| 977 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { | 987 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |
| 978 return tilings_->GPUMemoryUsageInBytes(); | 988 return tilings_->GPUMemoryUsageInBytes(); |
| 979 } | 989 } |
| 980 | 990 |
| 981 } // namespace cc | 991 } // namespace cc |
| OLD | NEW |