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