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 = CanDrawDirectlyToBackbuffer() && |
| 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 (CanDrawDirectlyToBackbuffer() && | |
| 397 layer_tree_impl()->settings().force_direct_layer_drawing) { | |
| 398 if (tilings_) | |
| 399 tilings_->RemoveAllTilings(); | |
|
danakj
2013/05/15 20:33:16
Don't you also want to prevent syncing tilings to
enne (OOO)
2013/05/15 22:34:38
Done.
| |
| 400 | |
| 401 *contents_scale_x = ideal_contents_scale_; | |
| 402 *contents_scale_y = ideal_contents_scale_; | |
| 403 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), | |
| 404 ideal_contents_scale_, | |
| 405 ideal_contents_scale_)); | |
| 406 return; | |
| 407 } | |
| 408 | |
| 391 ManageTilings(animating_transform_to_screen); | 409 ManageTilings(animating_transform_to_screen); |
| 392 | 410 |
| 393 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | 411 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. |
| 394 // There are (usually) several tilings at different scales. However, the | 412 // There are (usually) several tilings at different scales. However, the |
| 395 // content bounds is the (integer!) space in which quads are generated. | 413 // 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 | 414 // 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 | 415 // 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. | 416 // contents scale must be at least as large as the largest of the tilings. |
| 399 float max_contents_scale = min_contents_scale; | 417 float max_contents_scale = min_contents_scale; |
| 400 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 418 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 951 } | 969 } |
| 952 | 970 |
| 953 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 971 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| 954 LayerImpl::AsValueInto(state); | 972 LayerImpl::AsValueInto(state); |
| 955 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 973 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 956 state->Set("tilings", tilings_->AsValue().release()); | 974 state->Set("tilings", tilings_->AsValue().release()); |
| 957 state->Set("invalidation", invalidation_.AsValue().release()); | 975 state->Set("invalidation", invalidation_.AsValue().release()); |
| 958 } | 976 } |
| 959 | 977 |
| 960 } // namespace cc | 978 } // namespace cc |
| OLD | NEW |