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/stringprintf.h" | 8 #include "base/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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 masks_to_bounds_(false), | 46 masks_to_bounds_(false), |
47 contents_opaque_(false), | 47 contents_opaque_(false), |
48 opacity_(1.0), | 48 opacity_(1.0), |
49 preserves_3d_(false), | 49 preserves_3d_(false), |
50 use_parent_backface_visibility_(false), | 50 use_parent_backface_visibility_(false), |
51 draw_checkerboard_for_missing_tiles_(false), | 51 draw_checkerboard_for_missing_tiles_(false), |
52 draws_content_(false), | 52 draws_content_(false), |
53 force_render_surface_(false), | 53 force_render_surface_(false), |
54 is_container_for_fixed_position_layers_(false), | 54 is_container_for_fixed_position_layers_(false), |
55 draw_depth_(0.f), | 55 draw_depth_(0.f), |
| 56 compositing_reasons_(WebKit::CompositingReasonUnknown), |
56 #ifndef NDEBUG | 57 #ifndef NDEBUG |
57 between_will_draw_and_did_draw_(false), | 58 between_will_draw_and_did_draw_(false), |
58 #endif | 59 #endif |
59 horizontal_scrollbar_layer_(NULL), | 60 horizontal_scrollbar_layer_(NULL), |
60 vertical_scrollbar_layer_(NULL) { | 61 vertical_scrollbar_layer_(NULL) { |
61 DCHECK_GT(layer_id_, 0); | 62 DCHECK_GT(layer_id_, 0); |
62 DCHECK(layer_tree_impl_); | 63 DCHECK(layer_tree_impl_); |
63 layer_tree_impl_->RegisterLayer(this); | 64 layer_tree_impl_->RegisterLayer(this); |
64 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); | 65 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); |
65 layer_animation_controller_ = | 66 layer_animation_controller_ = |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 } | 346 } |
346 | 347 |
347 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { | 348 void LayerImpl::PushPropertiesTo(LayerImpl* layer) { |
348 layer->SetAnchorPoint(anchor_point_); | 349 layer->SetAnchorPoint(anchor_point_); |
349 layer->SetAnchorPointZ(anchor_point_z_); | 350 layer->SetAnchorPointZ(anchor_point_z_); |
350 layer->SetBackgroundColor(background_color_); | 351 layer->SetBackgroundColor(background_color_); |
351 layer->SetBounds(bounds_); | 352 layer->SetBounds(bounds_); |
352 layer->SetContentBounds(content_bounds()); | 353 layer->SetContentBounds(content_bounds()); |
353 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); | 354 layer->SetContentsScale(contents_scale_x(), contents_scale_y()); |
354 layer->SetDebugName(debug_name_); | 355 layer->SetDebugName(debug_name_); |
| 356 layer->SetCompositingReasons(compositing_reasons_); |
355 layer->SetDoubleSided(double_sided_); | 357 layer->SetDoubleSided(double_sided_); |
356 layer->SetDrawCheckerboardForMissingTiles( | 358 layer->SetDrawCheckerboardForMissingTiles( |
357 draw_checkerboard_for_missing_tiles_); | 359 draw_checkerboard_for_missing_tiles_); |
358 layer->SetForceRenderSurface(force_render_surface_); | 360 layer->SetForceRenderSurface(force_render_surface_); |
359 layer->SetDrawsContent(DrawsContent()); | 361 layer->SetDrawsContent(DrawsContent()); |
360 layer->SetFilters(filters()); | 362 layer->SetFilters(filters()); |
361 layer->SetFilter(filter()); | 363 layer->SetFilter(filter()); |
362 layer->SetBackgroundFilters(background_filters()); | 364 layer->SetBackgroundFilters(background_filters()); |
363 layer->SetMasksToBounds(masks_to_bounds_); | 365 layer->SetMasksToBounds(masks_to_bounds_); |
364 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 366 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 if (horizontal_scrollbar_layer_) | 998 if (horizontal_scrollbar_layer_) |
997 horizontal_scrollbar_layer_->set_scroll_layer_id(id()); | 999 horizontal_scrollbar_layer_->set_scroll_layer_id(id()); |
998 } | 1000 } |
999 | 1001 |
1000 void LayerImpl::SetVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbar_layer) { | 1002 void LayerImpl::SetVerticalScrollbarLayer(ScrollbarLayerImpl* scrollbar_layer) { |
1001 vertical_scrollbar_layer_ = scrollbar_layer; | 1003 vertical_scrollbar_layer_ = scrollbar_layer; |
1002 if (vertical_scrollbar_layer_) | 1004 if (vertical_scrollbar_layer_) |
1003 vertical_scrollbar_layer_->set_scroll_layer_id(id()); | 1005 vertical_scrollbar_layer_->set_scroll_layer_id(id()); |
1004 } | 1006 } |
1005 | 1007 |
| 1008 scoped_ptr<base::Value> |
| 1009 CompositingReasonsAsValue(WebKit::WebCompositingReasons reasons) { |
| 1010 scoped_ptr<base::ListValue> reason_list(new base::ListValue()); |
| 1011 |
| 1012 if (reasons == WebKit::CompositingReasonUnknown) { |
| 1013 reason_list->AppendString("No reasons given"); |
| 1014 return reason_list.PassAs<base::Value>(); |
| 1015 } |
| 1016 |
| 1017 if (reasons & WebKit::CompositingReason3DTransform) |
| 1018 reason_list->AppendString("Has a 3d Transform"); |
| 1019 |
| 1020 if (reasons & WebKit::CompositingReasonVideo) |
| 1021 reason_list->AppendString("Is accelerated video"); |
| 1022 |
| 1023 if (reasons & WebKit::CompositingReasonCanvas) |
| 1024 reason_list->AppendString("Is accelerated canvas"); |
| 1025 |
| 1026 if (reasons & WebKit::CompositingReasonPlugin) |
| 1027 reason_list->AppendString("Is accelerated plugin"); |
| 1028 |
| 1029 if (reasons & WebKit::CompositingReasonIFrame) |
| 1030 reason_list->AppendString("Is accelerated iframe"); |
| 1031 |
| 1032 if (reasons & WebKit::CompositingReasonBackfaceVisibilityHidden) |
| 1033 reason_list->AppendString("Has backface-visibility: hidden"); |
| 1034 |
| 1035 if (reasons & WebKit::CompositingReasonAnimation) |
| 1036 reason_list->AppendString("Has accelerated animation"); |
| 1037 |
| 1038 if (reasons & WebKit::CompositingReasonFilters) |
| 1039 reason_list->AppendString("Has accelerated filters"); |
| 1040 |
| 1041 if (reasons & WebKit::CompositingReasonPositionFixed) |
| 1042 reason_list->AppendString("Is fixed position"); |
| 1043 |
| 1044 if (reasons & WebKit::CompositingReasonPositionSticky) |
| 1045 reason_list->AppendString("Is sticky position"); |
| 1046 |
| 1047 if (reasons & WebKit::CompositingReasonOverflowScrollingTouch) |
| 1048 reason_list->AppendString("Is a scrollable overflow element"); |
| 1049 |
| 1050 if (reasons & WebKit::CompositingReasonBlending) |
| 1051 reason_list->AppendString("Has a blend mode"); |
| 1052 |
| 1053 if (reasons & WebKit::CompositingReasonAssumedOverlap) |
| 1054 reason_list->AppendString("Might overlap a composited animation"); |
| 1055 |
| 1056 if (reasons & WebKit::CompositingReasonOverlap) |
| 1057 reason_list->AppendString("Overlaps other composited content"); |
| 1058 |
| 1059 if (reasons & WebKit::CompositingReasonNegativeZIndexChildren) |
| 1060 reason_list->AppendString("Might overlap negative z-index " |
| 1061 "composited content"); |
| 1062 |
| 1063 if (reasons & WebKit::CompositingReasonTransformWithCompositedDescendants) |
| 1064 reason_list->AppendString("Has a transform needed by a " |
| 1065 "composited descendant"); |
| 1066 |
| 1067 if (reasons & WebKit::CompositingReasonOpacityWithCompositedDescendants) |
| 1068 reason_list->AppendString("Has opacity needed by a composited " |
| 1069 "descendant"); |
| 1070 |
| 1071 if (reasons & WebKit::CompositingReasonMaskWithCompositedDescendants) |
| 1072 reason_list->AppendString("Has a mask needed by a composited " |
| 1073 "descendant"); |
| 1074 |
| 1075 if (reasons & WebKit::CompositingReasonReflectionWithCompositedDescendants) |
| 1076 reason_list->AppendString("Has a reflection with a composited " |
| 1077 "descendant"); |
| 1078 |
| 1079 if (reasons & WebKit::CompositingReasonFilterWithCompositedDescendants) |
| 1080 reason_list->AppendString("Is a filter effect with a composited " |
| 1081 "descendant"); |
| 1082 |
| 1083 if (reasons & WebKit::CompositingReasonBlendingWithCompositedDescendants) |
| 1084 reason_list->AppendString("Has a blend mode with a composited " |
| 1085 "descendant"); |
| 1086 |
| 1087 if (reasons & WebKit::CompositingReasonClipsCompositingDescendants) |
| 1088 reason_list->AppendString("Clips a composited descendant"); |
| 1089 |
| 1090 if (reasons & WebKit::CompositingReasonPerspective) |
| 1091 reason_list->AppendString("Has a perspective transform needed by a " |
| 1092 "composited 3d descendant"); |
| 1093 |
| 1094 if (reasons & WebKit::CompositingReasonPreserve3D) |
| 1095 reason_list->AppendString("Has preserves-3d style with composited " |
| 1096 "3d descendant"); |
| 1097 |
| 1098 if (reasons & WebKit::CompositingReasonReflectionOfCompositedParent) |
| 1099 reason_list->AppendString("Is the reflection of a composited layer"); |
| 1100 |
| 1101 if (reasons & WebKit::CompositingReasonRoot) |
| 1102 reason_list->AppendString("Is the root"); |
| 1103 |
| 1104 if (reasons & WebKit::CompositingReasonLayerForClip) |
| 1105 reason_list->AppendString("Convenience layer, parent of main layer to " |
| 1106 "clip subtree"); |
| 1107 |
| 1108 if (reasons & WebKit::CompositingReasonLayerForDescendantClip) |
| 1109 reason_list->AppendString("Convenience layer, child of main layer to " |
| 1110 "clip scrolling container"); |
| 1111 |
| 1112 if (reasons & WebKit::CompositingReasonLayerForScrollbar) |
| 1113 reason_list->AppendString("Convenience layer for rendering scrollbar"); |
| 1114 |
| 1115 if (reasons & WebKit::CompositingReasonsLayerForScrollingContainer) |
| 1116 reason_list->AppendString("Convenience layer, the scrolling container"); |
| 1117 |
| 1118 if (reasons & WebKit::CompositingReasonsLayerForForeground) |
| 1119 reason_list->AppendString("Convenience layer, when main layer has " |
| 1120 "negative z-index content"); |
| 1121 |
| 1122 return reason_list.PassAs<base::Value>(); |
| 1123 } |
| 1124 |
1006 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { | 1125 void LayerImpl::AsValueInto(base::DictionaryValue* state) const { |
1007 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); | 1126 TracedValue::MakeDictIntoImplicitSnapshot(state, LayerTypeAsString(), this); |
1008 state->SetInteger("layer_id", id()); | 1127 state->SetInteger("layer_id", id()); |
1009 state->Set("bounds", MathUtil::AsValue(bounds()).release()); | 1128 state->Set("bounds", MathUtil::AsValue(bounds()).release()); |
1010 state->SetInteger("draws_content", DrawsContent()); | 1129 state->SetInteger("draws_content", DrawsContent()); |
| 1130 state->Set("compositing_reasons", |
| 1131 CompositingReasonsAsValue(compositing_reasons_).release()); |
1011 | 1132 |
1012 bool clipped; | 1133 bool clipped; |
1013 gfx::QuadF layer_quad = MathUtil::MapQuad( | 1134 gfx::QuadF layer_quad = MathUtil::MapQuad( |
1014 screen_space_transform(), | 1135 screen_space_transform(), |
1015 gfx::QuadF(gfx::Rect(content_bounds())), | 1136 gfx::QuadF(gfx::Rect(content_bounds())), |
1016 &clipped); | 1137 &clipped); |
1017 state->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); | 1138 state->Set("layer_quad", MathUtil::AsValue(layer_quad).release()); |
1018 | 1139 |
1019 | 1140 |
1020 scoped_ptr<base::ListValue> children_list(new base::ListValue()); | 1141 scoped_ptr<base::ListValue> children_list(new base::ListValue()); |
1021 for (size_t i = 0; i < children_.size(); ++i) | 1142 for (size_t i = 0; i < children_.size(); ++i) |
1022 children_list->Append(children_[i]->AsValue().release()); | 1143 children_list->Append(children_[i]->AsValue().release()); |
1023 state->Set("children", children_list.release()); | 1144 state->Set("children", children_list.release()); |
1024 if (mask_layer_) | 1145 if (mask_layer_) |
1025 state->Set("mask_layer", mask_layer_->AsValue().release()); | 1146 state->Set("mask_layer", mask_layer_->AsValue().release()); |
1026 if (replica_layer_) | 1147 if (replica_layer_) |
1027 state->Set("replica_layer", replica_layer_->AsValue().release()); | 1148 state->Set("replica_layer", replica_layer_->AsValue().release()); |
1028 } | 1149 } |
1029 | 1150 |
1030 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1151 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1031 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1152 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1032 AsValueInto(state.get()); | 1153 AsValueInto(state.get()); |
1033 return state.PassAs<base::Value>(); | 1154 return state.PassAs<base::Value>(); |
1034 } | 1155 } |
1035 | 1156 |
1036 } // namespace cc | 1157 } // namespace cc |
OLD | NEW |