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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 ++iter) { | 112 ++iter) { |
113 SkColor color; | 113 SkColor color; |
114 float width; | 114 float width; |
115 if (*iter && iter->drawing_info().IsReadyToDraw()) { | 115 if (*iter && iter->drawing_info().IsReadyToDraw()) { |
116 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); | 116 ManagedTileState::DrawingInfo::Mode mode = iter->drawing_info().mode(); |
117 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || | 117 if (mode == ManagedTileState::DrawingInfo::SOLID_COLOR_MODE || |
118 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { | 118 mode == ManagedTileState::DrawingInfo::TRANSPARENT_MODE) { |
119 color = DebugColors::SolidColorTileBorderColor(); | 119 color = DebugColors::SolidColorTileBorderColor(); |
120 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); | 120 width = DebugColors::SolidColorTileBorderWidth(layer_tree_impl()); |
121 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { | 121 } else if (mode == ManagedTileState::DrawingInfo::PICTURE_PILE_MODE) { |
122 color = DebugColors::PictureTileBorderColor(); | 122 if (CanDrawDirectlyToBackbuffer()) { |
123 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); | 123 color = DebugColors::DirectPictureTileBorderColor(); |
| 124 width = |
| 125 DebugColors::DirectPictureTileBorderWidth(layer_tree_impl()); |
| 126 } else { |
| 127 color = DebugColors::PictureTileBorderColor(); |
| 128 width = DebugColors::PictureTileBorderWidth(layer_tree_impl()); |
| 129 } |
124 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { | 130 } else if (iter->priority(ACTIVE_TREE).resolution == HIGH_RESOLUTION) { |
125 color = DebugColors::HighResTileBorderColor(); | 131 color = DebugColors::HighResTileBorderColor(); |
126 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); | 132 width = DebugColors::HighResTileBorderWidth(layer_tree_impl()); |
127 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { | 133 } else if (iter->priority(ACTIVE_TREE).resolution == LOW_RESOLUTION) { |
128 color = DebugColors::LowResTileBorderColor(); | 134 color = DebugColors::LowResTileBorderColor(); |
129 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); | 135 width = DebugColors::LowResTileBorderWidth(layer_tree_impl()); |
130 } else if (iter->contents_scale() > contents_scale_x()) { | 136 } else if (iter->contents_scale() > contents_scale_x()) { |
131 color = DebugColors::ExtraHighResTileBorderColor(); | 137 color = DebugColors::ExtraHighResTileBorderColor(); |
132 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); | 138 width = DebugColors::ExtraHighResTileBorderWidth(layer_tree_impl()); |
133 } else { | 139 } else { |
134 color = DebugColors::ExtraLowResTileBorderColor(); | 140 color = DebugColors::ExtraLowResTileBorderColor(); |
135 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); | 141 width = DebugColors::ExtraLowResTileBorderWidth(layer_tree_impl()); |
136 } | 142 } |
137 } else { | 143 } else { |
138 color = DebugColors::MissingTileBorderColor(); | 144 color = DebugColors::MissingTileBorderColor(); |
139 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); | 145 width = DebugColors::MissingTileBorderWidth(layer_tree_impl()); |
140 } | 146 } |
141 | 147 |
142 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = | 148 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
143 DebugBorderDrawQuad::Create(); | 149 DebugBorderDrawQuad::Create(); |
144 gfx::Rect geometry_rect = iter.geometry_rect(); | 150 gfx::Rect geometry_rect = iter.geometry_rect(); |
145 debug_border_quad->SetNew(shared_quad_state, geometry_rect, color, width); | 151 debug_border_quad->SetNew(shared_quad_state, geometry_rect, color, width); |
146 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>(), | 152 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>(), |
147 append_quads_data); | 153 append_quads_data); |
148 } | 154 } |
149 } | 155 } |
150 | 156 |
| 157 if (CanDrawDirectlyToBackbuffer() && |
| 158 layer_tree_impl()->settings().draw_layers_with_ganesh) { |
| 159 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
| 160 gfx::Rect opaque_rect; |
| 161 quad->SetNew(shared_quad_state, |
| 162 content_rect, |
| 163 opaque_rect, |
| 164 gfx::RectF(0, 0, 1, 1), |
| 165 content_rect.size(), |
| 166 false, |
| 167 content_rect, |
| 168 contents_scale_x(), |
| 169 CanDrawDirectlyToBackbuffer(), |
| 170 pile_); |
| 171 if (quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data)) |
| 172 append_quads_data->num_missing_tiles++; |
| 173 return; |
| 174 } |
| 175 |
151 // Keep track of the tilings that were used so that tilings that are | 176 // Keep track of the tilings that were used so that tilings that are |
152 // unused can be considered for removal. | 177 // unused can be considered for removal. |
153 std::vector<PictureLayerTiling*> seen_tilings; | 178 std::vector<PictureLayerTiling*> seen_tilings; |
154 | 179 |
155 for (PictureLayerTilingSet::CoverageIterator iter( | 180 for (PictureLayerTilingSet::CoverageIterator iter( |
156 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); | 181 tilings_.get(), contents_scale_x(), rect, ideal_contents_scale_); |
157 iter; | 182 iter; |
158 ++iter) { | 183 ++iter) { |
159 gfx::Rect geometry_rect = iter.geometry_rect(); | 184 gfx::Rect geometry_rect = iter.geometry_rect(); |
160 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { | 185 if (!*iter || !iter->drawing_info().IsReadyToDraw()) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 246 |
222 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); | 247 scoped_ptr<PictureDrawQuad> quad = PictureDrawQuad::Create(); |
223 quad->SetNew(shared_quad_state, | 248 quad->SetNew(shared_quad_state, |
224 geometry_rect, | 249 geometry_rect, |
225 opaque_rect, | 250 opaque_rect, |
226 texture_rect, | 251 texture_rect, |
227 iter.texture_size(), | 252 iter.texture_size(), |
228 drawing_info.contents_swizzled(), | 253 drawing_info.contents_swizzled(), |
229 iter->content_rect(), | 254 iter->content_rect(), |
230 iter->contents_scale(), | 255 iter->contents_scale(), |
| 256 CanDrawDirectlyToBackbuffer(), |
231 pile_); | 257 pile_); |
232 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 258 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
233 break; | 259 break; |
234 } | 260 } |
235 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { | 261 case ManagedTileState::DrawingInfo::SOLID_COLOR_MODE: { |
236 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 262 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
237 quad->SetNew(shared_quad_state, | 263 quad->SetNew(shared_quad_state, |
238 geometry_rect, | 264 geometry_rect, |
239 drawing_info.get_solid_color()); | 265 drawing_info.get_solid_color()); |
240 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); | 266 quad_sink->Append(quad.PassAs<DrawQuad>(), append_quads_data); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 float ideal_page_scale = layer_tree_impl()->total_page_scale_factor(); | 366 float ideal_page_scale = layer_tree_impl()->total_page_scale_factor(); |
341 float ideal_device_scale = layer_tree_impl()->device_scale_factor(); | 367 float ideal_device_scale = layer_tree_impl()->device_scale_factor(); |
342 float ideal_source_scale = | 368 float ideal_source_scale = |
343 ideal_contents_scale / ideal_page_scale / ideal_device_scale; | 369 ideal_contents_scale / ideal_page_scale / ideal_device_scale; |
344 | 370 |
345 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); | 371 ideal_contents_scale_ = std::max(ideal_contents_scale, min_contents_scale); |
346 ideal_page_scale_ = ideal_page_scale; | 372 ideal_page_scale_ = ideal_page_scale; |
347 ideal_device_scale_ = ideal_device_scale; | 373 ideal_device_scale_ = ideal_device_scale; |
348 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); | 374 ideal_source_scale_ = std::max(ideal_source_scale, min_source_scale); |
349 | 375 |
| 376 if (CanDrawDirectlyToBackbuffer() && |
| 377 layer_tree_impl()->settings().draw_layers_with_ganesh) { |
| 378 if (tilings_) |
| 379 tilings_->RemoveAllTilings(); |
| 380 |
| 381 *contents_scale_x = ideal_contents_scale_; |
| 382 *contents_scale_y = ideal_contents_scale_; |
| 383 *content_bounds = gfx::ToCeiledSize(gfx::ScaleSize(bounds(), |
| 384 ideal_contents_scale_, |
| 385 ideal_contents_scale_)); |
| 386 return; |
| 387 } |
| 388 |
350 ManageTilings(animating_transform_to_screen); | 389 ManageTilings(animating_transform_to_screen); |
351 | 390 |
352 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. | 391 // The content scale and bounds for a PictureLayerImpl is somewhat fictitious. |
353 // There are (usually) several tilings at different scales. However, the | 392 // There are (usually) several tilings at different scales. However, the |
354 // content bounds is the (integer!) space in which quads are generated. | 393 // content bounds is the (integer!) space in which quads are generated. |
355 // In order to guarantee that we can fill this integer space with any set of | 394 // In order to guarantee that we can fill this integer space with any set of |
356 // tilings (and then map back to floating point texture coordinates), the | 395 // tilings (and then map back to floating point texture coordinates), the |
357 // contents scale must be at least as large as the largest of the tilings. | 396 // contents scale must be at least as large as the largest of the tilings. |
358 float max_contents_scale = min_contents_scale; | 397 float max_contents_scale = min_contents_scale; |
359 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { | 398 for (size_t i = 0; i < tilings_->num_tilings(); ++i) { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 return 0; | 579 return 0; |
541 return iter->drawing_info().get_resource_id(); | 580 return iter->drawing_info().get_resource_id(); |
542 } | 581 } |
543 return 0; | 582 return 0; |
544 } | 583 } |
545 | 584 |
546 bool PictureLayerImpl::AreVisibleResourcesReady() const { | 585 bool PictureLayerImpl::AreVisibleResourcesReady() const { |
547 DCHECK(layer_tree_impl()->IsPendingTree()); | 586 DCHECK(layer_tree_impl()->IsPendingTree()); |
548 DCHECK(ideal_contents_scale_); | 587 DCHECK(ideal_contents_scale_); |
549 | 588 |
| 589 if (!tilings_->num_tilings()) |
| 590 return true; |
| 591 |
550 gfx::Rect rect(visible_content_rect()); | 592 gfx::Rect rect(visible_content_rect()); |
551 | 593 |
552 float min_acceptable_scale = | 594 float min_acceptable_scale = |
553 std::min(raster_contents_scale_, ideal_contents_scale_); | 595 std::min(raster_contents_scale_, ideal_contents_scale_); |
554 | 596 |
555 TreePriority tree_priority = | 597 TreePriority tree_priority = |
556 layer_tree_impl()->tile_manager()->GlobalState().tree_priority; | 598 layer_tree_impl()->tile_manager()->GlobalState().tree_priority; |
557 bool should_force_uploads = | 599 bool should_force_uploads = |
558 tree_priority != SMOOTHNESS_TAKES_PRIORITY && | 600 tree_priority != SMOOTHNESS_TAKES_PRIORITY && |
559 layer_tree_impl()->animationRegistrar()-> | 601 layer_tree_impl()->animationRegistrar()-> |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { | 955 scoped_ptr<base::Value> PictureLayerImpl::AsValue() const { |
914 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 956 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
915 LayerImpl::AsValueInto(state.get()); | 957 LayerImpl::AsValueInto(state.get()); |
916 | 958 |
917 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); | 959 state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
918 state->Set("tilings", tilings_->AsValue().release()); | 960 state->Set("tilings", tilings_->AsValue().release()); |
919 return state.PassAs<base::Value>(); | 961 return state.PassAs<base::Value>(); |
920 } | 962 } |
921 | 963 |
922 } // namespace cc | 964 } // namespace cc |
OLD | NEW |