Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
| 10 #include "cc/animation/scrollbar_animation_controller.h" | 10 #include "cc/animation/scrollbar_animation_controller.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 should_scroll_on_main_thread_(false), | 43 should_scroll_on_main_thread_(false), |
| 44 have_wheel_event_handlers_(false), | 44 have_wheel_event_handlers_(false), |
| 45 background_color_(0), | 45 background_color_(0), |
| 46 stacking_order_changed_(false), | 46 stacking_order_changed_(false), |
| 47 double_sided_(true), | 47 double_sided_(true), |
| 48 layer_property_changed_(false), | 48 layer_property_changed_(false), |
| 49 layer_surface_property_changed_(false), | 49 layer_surface_property_changed_(false), |
| 50 masks_to_bounds_(false), | 50 masks_to_bounds_(false), |
| 51 contents_opaque_(false), | 51 contents_opaque_(false), |
| 52 opacity_(1.0), | 52 opacity_(1.0), |
| 53 blend_mode_(SkXfermode::kSrcOver_Mode), | |
| 54 is_root_for_isolated_group_(false), | |
| 53 preserves_3d_(false), | 55 preserves_3d_(false), |
| 54 use_parent_backface_visibility_(false), | 56 use_parent_backface_visibility_(false), |
| 55 draw_checkerboard_for_missing_tiles_(false), | 57 draw_checkerboard_for_missing_tiles_(false), |
| 56 draws_content_(false), | 58 draws_content_(false), |
| 57 hide_layer_and_subtree_(false), | 59 hide_layer_and_subtree_(false), |
| 58 force_render_surface_(false), | 60 force_render_surface_(false), |
| 59 is_container_for_fixed_position_layers_(false), | 61 is_container_for_fixed_position_layers_(false), |
| 60 draw_depth_(0.f), | 62 draw_depth_(0.f), |
| 61 compositing_reasons_(kCompositingReasonUnknown), | 63 compositing_reasons_(kCompositingReasonUnknown), |
| 62 current_draw_mode_(DRAW_MODE_NONE), | 64 current_draw_mode_(DRAW_MODE_NONE), |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 draw_properties_.render_surface.reset(); | 238 draw_properties_.render_surface.reset(); |
| 237 } | 239 } |
| 238 | 240 |
| 239 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const { | 241 scoped_ptr<SharedQuadState> LayerImpl::CreateSharedQuadState() const { |
| 240 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); | 242 scoped_ptr<SharedQuadState> state = SharedQuadState::Create(); |
| 241 state->SetAll(draw_properties_.target_space_transform, | 243 state->SetAll(draw_properties_.target_space_transform, |
| 242 draw_properties_.content_bounds, | 244 draw_properties_.content_bounds, |
| 243 draw_properties_.visible_content_rect, | 245 draw_properties_.visible_content_rect, |
| 244 draw_properties_.clip_rect, | 246 draw_properties_.clip_rect, |
| 245 draw_properties_.is_clipped, | 247 draw_properties_.is_clipped, |
| 246 draw_properties_.opacity); | 248 draw_properties_.opacity, |
| 249 blend_mode_); | |
| 247 return state.Pass(); | 250 return state.Pass(); |
| 248 } | 251 } |
| 249 | 252 |
| 250 bool LayerImpl::WillDraw(DrawMode draw_mode, | 253 bool LayerImpl::WillDraw(DrawMode draw_mode, |
| 251 ResourceProvider* resource_provider) { | 254 ResourceProvider* resource_provider) { |
| 252 // WillDraw/DidDraw must be matched. | 255 // WillDraw/DidDraw must be matched. |
| 253 DCHECK_NE(DRAW_MODE_NONE, draw_mode); | 256 DCHECK_NE(DRAW_MODE_NONE, draw_mode); |
| 254 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); | 257 DCHECK_EQ(DRAW_MODE_NONE, current_draw_mode_); |
| 255 current_draw_mode_ = draw_mode; | 258 current_draw_mode_ = draw_mode; |
| 256 return true; | 259 return true; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 504 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
| 502 layer->SetFilters(filters()); | 505 layer->SetFilters(filters()); |
| 503 layer->SetBackgroundFilters(background_filters()); | 506 layer->SetBackgroundFilters(background_filters()); |
| 504 layer->SetMasksToBounds(masks_to_bounds_); | 507 layer->SetMasksToBounds(masks_to_bounds_); |
| 505 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 508 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
| 506 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 509 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
| 507 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 510 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 508 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 511 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| 509 layer->SetContentsOpaque(contents_opaque_); | 512 layer->SetContentsOpaque(contents_opaque_); |
| 510 layer->SetOpacity(opacity_); | 513 layer->SetOpacity(opacity_); |
| 514 layer->SetBlendMode(blend_mode_); | |
| 515 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | |
| 511 layer->SetPosition(position_); | 516 layer->SetPosition(position_); |
| 512 layer->SetIsContainerForFixedPositionLayers( | 517 layer->SetIsContainerForFixedPositionLayers( |
| 513 is_container_for_fixed_position_layers_); | 518 is_container_for_fixed_position_layers_); |
| 514 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); | 519 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); |
| 515 layer->SetPositionConstraint(position_constraint_); | 520 layer->SetPositionConstraint(position_constraint_); |
| 516 layer->SetPreserves3d(preserves_3d()); | 521 layer->SetPreserves3d(preserves_3d()); |
| 517 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 522 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
| 518 layer->SetSublayerTransform(sublayer_transform_); | 523 layer->SetSublayerTransform(sublayer_transform_); |
| 519 layer->SetTransform(transform_); | 524 layer->SetTransform(transform_); |
| 520 | 525 |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 bool LayerImpl::OpacityIsAnimating() const { | 862 bool LayerImpl::OpacityIsAnimating() const { |
| 858 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); | 863 return layer_animation_controller_->IsAnimatingProperty(Animation::Opacity); |
| 859 } | 864 } |
| 860 | 865 |
| 861 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { | 866 bool LayerImpl::OpacityIsAnimatingOnImplOnly() const { |
| 862 Animation* opacity_animation = | 867 Animation* opacity_animation = |
| 863 layer_animation_controller_->GetAnimation(Animation::Opacity); | 868 layer_animation_controller_->GetAnimation(Animation::Opacity); |
| 864 return opacity_animation && opacity_animation->is_impl_only(); | 869 return opacity_animation && opacity_animation->is_impl_only(); |
| 865 } | 870 } |
| 866 | 871 |
| 872 void LayerImpl::SetBlendMode(SkXfermode::Mode blendMode) { | |
| 873 if (blend_mode_ == blendMode) | |
| 874 return; | |
| 875 | |
| 876 blend_mode_ = blendMode; | |
| 877 NoteLayerSurfacePropertyChanged(); | |
| 878 } | |
| 879 | |
| 880 void LayerImpl::SetIsRootForIsolatedGroup(bool root) { | |
| 881 if (is_root_for_isolated_group_ == root) | |
| 882 return; | |
| 883 | |
| 884 is_root_for_isolated_group_ = root; | |
| 885 NoteLayerSurfacePropertyChanged(); | |
|
enne (OOO)
2013/10/11 18:14:35
Should this really cause damage? It seems to me th
rosca
2013/10/16 14:54:47
Done.
| |
| 886 } | |
| 887 | |
| 867 void LayerImpl::SetPosition(gfx::PointF position) { | 888 void LayerImpl::SetPosition(gfx::PointF position) { |
| 868 if (position_ == position) | 889 if (position_ == position) |
| 869 return; | 890 return; |
| 870 | 891 |
| 871 position_ = position; | 892 position_ = position; |
| 872 NoteLayerPropertyChangedForSubtree(); | 893 NoteLayerPropertyChangedForSubtree(); |
| 873 } | 894 } |
| 874 | 895 |
| 875 void LayerImpl::SetPreserves3d(bool preserves3_d) { | 896 void LayerImpl::SetPreserves3d(bool preserves3_d) { |
| 876 if (preserves_3d_ == preserves3_d) | 897 if (preserves_3d_ == preserves3_d) |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 | 1274 |
| 1254 if (reasons & kCompositingReasonLayerForMask) | 1275 if (reasons & kCompositingReasonLayerForMask) |
| 1255 reason_list->AppendString("Is a mask layer"); | 1276 reason_list->AppendString("Is a mask layer"); |
| 1256 | 1277 |
| 1257 if (reasons & kCompositingReasonOverflowScrollingParent) | 1278 if (reasons & kCompositingReasonOverflowScrollingParent) |
| 1258 reason_list->AppendString("Scroll parent is not an ancestor"); | 1279 reason_list->AppendString("Scroll parent is not an ancestor"); |
| 1259 | 1280 |
| 1260 if (reasons & kCompositingReasonOutOfFlowClipping) | 1281 if (reasons & kCompositingReasonOutOfFlowClipping) |
| 1261 reason_list->AppendString("Has clipping ancestor"); | 1282 reason_list->AppendString("Has clipping ancestor"); |
| 1262 | 1283 |
| 1284 if (reasons & kCompositingReasonIsolateCompositedDescendants) | |
| 1285 reason_list->AppendString("Should isolate composited dscendants"); | |
| 1286 | |
| 1263 return reason_list.PassAs<base::Value>(); | 1287 return reason_list.PassAs<base::Value>(); |
| 1264 } | 1288 } |
| 1265 | 1289 |
| 1266 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1290 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { |
| 1267 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); | 1291 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); |
| 1268 state->SetInteger("layer_id", id()); | 1292 state->SetInteger("layer_id", id()); |
| 1269 state->SetString("layer_name", debug_name()); | 1293 state->SetString("layer_name", debug_name()); |
| 1270 state->Set("bounds", MathUtil::AsValue(bounds()).release()); | 1294 state->Set("bounds", MathUtil::AsValue(bounds()).release()); |
| 1271 state->SetInteger("draws_content", DrawsContent()); | 1295 state->SetInteger("draws_content", DrawsContent()); |
| 1272 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); | 1296 state->SetInteger("gpu_memory_usage", GPUMemoryUsageInBytes()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1313 | 1337 |
| 1314 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1338 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
| 1315 | 1339 |
| 1316 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1340 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
| 1317 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1341 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 1318 AsValueInto(state.get()); | 1342 AsValueInto(state.get()); |
| 1319 return state.PassAs<base::Value>(); | 1343 return state.PassAs<base::Value>(); |
| 1320 } | 1344 } |
| 1321 | 1345 |
| 1322 } // namespace cc | 1346 } // namespace cc |
| OLD | NEW |