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 && |
| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 float ideal_page_scale = page_scale_factor; | 386 float ideal_page_scale = page_scale_factor; |
| 382 float ideal_device_scale = device_scale_factor; | 387 float ideal_device_scale = device_scale_factor; |
| 383 float ideal_source_scale = | 388 float ideal_source_scale = |
| 384 ideal_contents_scale / ideal_page_scale / ideal_device_scale; | 389 ideal_contents_scale / ideal_page_scale / ideal_device_scale; |
| 385 | 390 |
| 386 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); | 391 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); |
| 387 ideal_page_scale_ = ideal_page_scale; | 392 ideal_page_scale_ = ideal_page_scale; |
| 388 ideal_device_scale_ = ideal_device_scale; | 393 ideal_device_scale_ = ideal_device_scale; |
| 389 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | 394 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); |
| 390 | 395 |
| 396 if (draw_properties().can_draw_directly_to_backbuffer && | |
|
danakj
2013/05/16 15:17:55
There's this check here, and there's a DrawsConten
enne (OOO)
2013/05/16 20:34:11
Done.
| |
| 397 layer_tree_impl()->settings().force_direct_layer_drawing) { | |
| 398 *contents_scale_x = ideal_contents_scale_; | |
| 399 *contents_scale_y = ideal_contents_scale_; | |
| 400 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), | |
| 401 ideal_contents_scale_, | |
| 402 ideal_contents_scale_)); | |
| 403 return; | |
| 404 } | |
| 405 | |
| 391 ManageTilings(animating_transform_to_screen); | 406 ManageTilings(animating_transform_to_screen); |
| 392 | 407 |
| 393 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | 408 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. |
| 394 // There are (usually) several tilings at different scales. However, the | 409 // There are (usually) several tilings at different scales. However, the |
| 395 // content bounds is the (integer!) space in which quads are generated. | 410 // content bounds is the (integer!) space in which quads are generated. |
| 396 // In order to guarantee that we can fill this integer space with any set of | 411 // In order to guarantee that we can fill this integer space with any set of |
| 397 // tilings (and then map back to floating point texture coordinates), the | 412 // tilings (and then map back to floating point texture coordinates), the |
| 398 // contents scale must be at least as large as the largest of the tilings. | 413 // contents scale must be at least as large as the largest of the tilings. |
| 399 float max_contents_scale = min_contents_scale; | 414 float max_contents_scale = min_contents_scale; |
| 400 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 415 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 944 raster_source_scale_ = 0.f; | 959 raster_source_scale_ = 0.f; |
| 945 raster_contents_scale_ = 0.f; | 960 raster_contents_scale_ = 0.f; |
| 946 low_res_raster_contents_scale_ = 0.f; | 961 low_res_raster_contents_scale_ = 0.f; |
| 947 } | 962 } |
| 948 | 963 |
| 949 bool PictureLayerImpl::CanHaveTilings() const { | 964 bool PictureLayerImpl::CanHaveTilings() const { |
| 950 if (!DrawsContent()) | 965 if (!DrawsContent()) |
| 951 return false; | 966 return false; |
| 952 if (pile_->recorded_region().IsEmpty()) | 967 if (pile_->recorded_region().IsEmpty()) |
| 953 return false; | 968 return false; |
| 969 if (draw_properties().can_draw_directly_to_backbuffer && | |
| 970 layer_tree_impl()->settings().force_direct_layer_drawing) | |
| 971 return false; | |
| 954 return true; | 972 return true; |
| 955 } | 973 } |
| 956 | 974 |
| 957 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { | 975 bool PictureLayerImpl::CanHaveTilingWithScale(float contents_scale) const { |
| 958 if (!CanHaveTilings()) | 976 if (!CanHaveTilings()) |
| 959 return false; | 977 return false; |
| 960 if (contents_scale < MinimumContentsScale()) | 978 if (contents_scale < MinimumContentsScale()) |
| 961 return false; | 979 return false; |
| 962 return true; | 980 return true; |
| 963 } | 981 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 975 state->Set("tilings", tilings_->AsValue().release()); | 993 state->Set("tilings", tilings_->AsValue().release()); |
| 976 state->Set("pictures", pile_->AsValue().release()); | 994 state->Set("pictures", pile_->AsValue().release()); |
| 977 state->Set("invalidation", invalidation_.AsValue().release()); | 995 state->Set("invalidation", invalidation_.AsValue().release()); |
| 978 } | 996 } |
| 979 | 997 |
| 980 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { | 998 size_t PictureLayerImpl::GPUMemoryUsageInBytes() const { |
| 981 return tilings_->GPUMemoryUsageInBytes(); | 999 return tilings_->GPUMemoryUsageInBytes(); |
| 982 } | 1000 } |
| 983 | 1001 |
| 984 } // namespace cc | 1002 } // namespace cc |
| OLD | NEW |