| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, | 93 void PictureLayerImpl::AppendQuads(QuadSink* quad_sink, |
| 94 AppendQuadsData* append_quads_data) { | 94 AppendQuadsData* append_quads_data) { |
| 95 gfx::Rect rect(visible_content_rect()); | 95 gfx::Rect rect(visible_content_rect()); |
| 96 gfx::Rect content_rect(content_bounds()); | 96 gfx::Rect content_rect(content_bounds()); |
| 97 | 97 |
| 98 SharedQuadState* shared_quad_state = | 98 SharedQuadState* shared_quad_state = |
| 99 quad_sink->UseSharedQuadState(CreateSharedQuadState()); | 99 quad_sink->UseSharedQuadState(CreateSharedQuadState()); |
| 100 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); | 100 AppendDebugBorderQuad(quad_sink, shared_quad_state, append_quads_data); |
| 101 | 101 |
| 102 if (!append_quads_data->allow_tile_draw_quads) { | 102 bool use_ganesh = CanDrawDirectlyToBackbuffer() && |
| 103 layer_tree_impl()->settings().force_direct_layer_drawing; |
| 104 |
| 105 if (use_ganesh || !append_quads_data->allow_tile_draw_quads) { |
| 103 gfx::Rect geometry_rect = rect; | 106 gfx::Rect geometry_rect = rect; |
| 104 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); | 107 gfx::Rect opaque_rect = contents_opaque() ? geometry_rect : gfx::Rect(); |
| 105 gfx::Size texture_size = rect.size(); | 108 gfx::Size texture_size = rect.size(); |
| 106 gfx::RectF texture_rect = gfx::RectF(texture_size); | 109 gfx::RectF texture_rect = gfx::RectF(texture_size); |
| 107 gfx::Rect quad_content_rect = rect; | 110 gfx::Rect quad_content_rect = rect; |
| 108 float contents_scale = contents_scale_x(); | 111 float contents_scale = contents_scale_x(); |
| 109 | 112 |
| 110 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 113 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 111 quad->SetNew(shared_quad_state, | 114 quad->SetNew(shared_quad_state, |
| 112 geometry_rect, | 115 geometry_rect, |
| 113 opaque_rect, | 116 opaque_rect, |
| 114 texture_rect, | 117 texture_rect, |
| 115 texture_size, | 118 texture_size, |
| 116 false, | 119 false, |
| 117 quad_content_rect, | 120 quad_content_rect, |
| 118 contents_scale, | 121 contents_scale, |
| 122 use_ganesh, |
| 119 pile_); | 123 pile_); |
| 120 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) | 124 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| 121 append_quads_data->num_missing_tiles++; | 125 append_quads_data->num_missing_tiles++; |
| 122 return; | 126 return; |
| 123 } | 127 } |
| 124 | 128 |
| 125 bool clipped = false; | 129 bool clipped = false; |
| 126 gfx::QuadF target_quad = MathUtil::MapQuad( | 130 gfx::QuadF target_quad = MathUtil::MapQuad( |
| 127 draw_transform(), | 131 draw_transform(), |
| 128 gfx::QuadF(rect), | 132 gfx::QuadF(rect), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 246 |
| 243 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 247 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 244 quad->SetNew(shared_quad_state, | 248 quad->SetNew(shared_quad_state, |
| 245 geometry_rect, | 249 geometry_rect, |
| 246 opaque_rect, | 250 opaque_rect, |
| 247 texture_rect, | 251 texture_rect, |
| 248 iter.texture_size(), | 252 iter.texture_size(), |
| 249 drawing_info.contents_swizzled(), | 253 drawing_info.contents_swizzled(), |
| 250 iter->content_rect(), | 254 iter->content_rect(), |
| 251 iter->contents_scale(), | 255 iter->contents_scale(), |
| 256 use_ganesh, |
| 252 pile_); | 257 pile_); |
| 253 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 258 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
| 254 break; | 259 break; |
| 255 } | 260 } |
| 256 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 261 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
| 257 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 262 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 258 quad->SetNew(shared_quad_state, | 263 quad->SetNew(shared_quad_state, |
| 259 geometry_rect, | 264 geometry_rect, |
| 260 drawing_info.get_solid_color(), | 265 drawing_info.get_solid_color(), |
| 261 false); | 266 false); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 float ideal_page_scale = page_scale_factor; | 377 float ideal_page_scale = page_scale_factor; |
| 373 float ideal_device_scale = device_scale_factor; | 378 float ideal_device_scale = device_scale_factor; |
| 374 float ideal_source_scale = | 379 float ideal_source_scale = |
| 375 ideal_contents_scale / ideal_page_scale / ideal_device_scale; | 380 ideal_contents_scale / ideal_page_scale / ideal_device_scale; |
| 376 | 381 |
| 377 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); | 382 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); |
| 378 ideal_page_scale_ = ideal_page_scale; | 383 ideal_page_scale_ = ideal_page_scale; |
| 379 ideal_device_scale_ = ideal_device_scale; | 384 ideal_device_scale_ = ideal_device_scale; |
| 380 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | 385 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); |
| 381 | 386 |
| 387 if (CanDrawDirectlyToBackbuffer() && |
| 388 layer_tree_impl()->settings().force_direct_layer_drawing) { |
| 389 if (tilings_) |
| 390 tilings_->RemoveAllTilings(); |
| 391 |
| 392 *contents_scale_x = ideal_contents_scale_; |
| 393 *contents_scale_y = ideal_contents_scale_; |
| 394 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), |
| 395 ideal_contents_scale_, |
| 396 ideal_contents_scale_)); |
| 397 return; |
| 398 } |
| 399 |
| 382 ManageTilings(animating_transform_to_screen); | 400 ManageTilings(animating_transform_to_screen); |
| 383 | 401 |
| 384 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | 402 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. |
| 385 // There are (usually) several tilings at different scales. However, the | 403 // There are (usually) several tilings at different scales. However, the |
| 386 // content bounds is the (integer!) space in which quads are generated. | 404 // content bounds is the (integer!) space in which quads are generated. |
| 387 // In order to guarantee that we can fill this integer space with any set of | 405 // In order to guarantee that we can fill this integer space with any set of |
| 388 // tilings (and then map back to floating point texture coordinates), the | 406 // tilings (and then map back to floating point texture coordinates), the |
| 389 // contents scale must be at least as large as the largest of the tilings. | 407 // contents scale must be at least as large as the largest of the tilings. |
| 390 float max_contents_scale = min_contents_scale; | 408 float max_contents_scale = min_contents_scale; |
| 391 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 409 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 961 |
| 944 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { | 962 void PictureLayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| 945 LayerImpl::AsValueInto(state); | 963 LayerImpl::AsValueInto(state); |
| 946 TracedValue::MakeDictIntoImplicitSnapshot( | 964 TracedValue::MakeDictIntoImplicitSnapshot( |
| 947 state, "cc::PictureLayerImpl", this); | 965 state, "cc::PictureLayerImpl", this); |
| 948 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 966 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
| 949 state->Set("tilings", tilings_->AsValue().release()); | 967 state->Set("tilings", tilings_->AsValue().release()); |
| 950 } | 968 } |
| 951 | 969 |
| 952 } // namespace cc | 970 } // namespace cc |
| OLD | NEW |