| 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 "cc/animation/mutable_properties.h" | 7 #include "cc/animation/mutable_properties.h" |
| 8 #include "cc/layers/painted_scrollbar_layer_impl.h" | 8 #include "cc/layers/painted_scrollbar_layer_impl.h" |
| 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 9 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
| 10 #include "cc/output/filter_operation.h" | 10 #include "cc/output/filter_operation.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 float arbitrary_number = 0.352f; | 149 float arbitrary_number = 0.352f; |
| 150 gfx::Size arbitrary_size = gfx::Size(111, 222); | 150 gfx::Size arbitrary_size = gfx::Size(111, 222); |
| 151 gfx::Point arbitrary_point = gfx::Point(333, 444); | 151 gfx::Point arbitrary_point = gfx::Point(333, 444); |
| 152 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); | 152 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); |
| 153 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); | 153 gfx::Rect arbitrary_rect = gfx::Rect(arbitrary_point, arbitrary_size); |
| 154 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); | 154 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); |
| 155 gfx::Transform arbitrary_transform; | 155 gfx::Transform arbitrary_transform; |
| 156 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 156 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
| 157 FilterOperations arbitrary_filters; | 157 FilterOperations arbitrary_filters; |
| 158 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); | 158 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
| 159 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; | |
| 160 | 159 |
| 161 // These properties are internal, and should not be considered "change" when | 160 // These properties are internal, and should not be considered "change" when |
| 162 // they are used. | 161 // they are used. |
| 163 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( | 162 EXECUTE_AND_VERIFY_NEEDS_PUSH_PROPERTIES_AND_SUBTREE_DID_NOT_CHANGE( |
| 164 root->SetUpdateRect(arbitrary_rect)); | 163 root->SetUpdateRect(arbitrary_rect)); |
| 165 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); | 164 EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); |
| 166 host_impl.active_tree()->property_trees()->needs_rebuild = true; | 165 host_impl.active_tree()->property_trees()->needs_rebuild = true; |
| 167 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 166 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 168 | 167 |
| 169 // Changing these properties affects the entire subtree of layers. | 168 // Changing these properties affects the entire subtree of layers. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 207 |
| 209 // After setting all these properties already, setting to the exact same | 208 // After setting all these properties already, setting to the exact same |
| 210 // values again should not cause any change. | 209 // values again should not cause any change. |
| 211 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true)); | 210 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetMasksToBounds(true)); |
| 212 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 211 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 213 root->SetPosition(arbitrary_point_f)); | 212 root->SetPosition(arbitrary_point_f)); |
| 214 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); | 213 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->Set3dSortingContextId(1)); |
| 215 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | 214 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( |
| 216 root->SetTransform(arbitrary_transform)); | 215 root->SetTransform(arbitrary_transform)); |
| 217 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); | 216 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetContentsOpaque(true)); |
| 218 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( | |
| 219 root->SetBlendMode(arbitrary_blend_mode)); | |
| 220 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); | 217 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetDrawsContent(true)); |
| 221 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size)); | 218 EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->SetBounds(bounds_size)); |
| 222 } | 219 } |
| 223 | 220 |
| 224 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { | 221 TEST(LayerImplTest, VerifyNeedsUpdateDrawProperties) { |
| 225 FakeImplTaskRunnerProvider task_runner_provider; | 222 FakeImplTaskRunnerProvider task_runner_provider; |
| 226 TestSharedBitmapManager shared_bitmap_manager; | 223 TestSharedBitmapManager shared_bitmap_manager; |
| 227 TestTaskGraphRunner task_graph_runner; | 224 TestTaskGraphRunner task_graph_runner; |
| 228 std::unique_ptr<OutputSurface> output_surface = | 225 std::unique_ptr<OutputSurface> output_surface = |
| 229 FakeOutputSurface::CreateDelegating3d(); | 226 FakeOutputSurface::CreateDelegating3d(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 250 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); | 247 gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f); |
| 251 float arbitrary_number = 0.352f; | 248 float arbitrary_number = 0.352f; |
| 252 gfx::Size arbitrary_size = gfx::Size(111, 222); | 249 gfx::Size arbitrary_size = gfx::Size(111, 222); |
| 253 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); | 250 gfx::Vector2d arbitrary_vector2d = gfx::Vector2d(111, 222); |
| 254 gfx::Size large_size = gfx::Size(1000, 1000); | 251 gfx::Size large_size = gfx::Size(1000, 1000); |
| 255 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); | 252 SkColor arbitrary_color = SkColorSetRGB(10, 20, 30); |
| 256 gfx::Transform arbitrary_transform; | 253 gfx::Transform arbitrary_transform; |
| 257 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); | 254 arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f); |
| 258 FilterOperations arbitrary_filters; | 255 FilterOperations arbitrary_filters; |
| 259 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); | 256 arbitrary_filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
| 260 SkXfermode::Mode arbitrary_blend_mode = SkXfermode::kMultiply_Mode; | |
| 261 | 257 |
| 262 // Set layer to draw content so that their draw property by property trees is | 258 // Set layer to draw content so that their draw property by property trees is |
| 263 // verified. | 259 // verified. |
| 264 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); | 260 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); |
| 265 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetDrawsContent(true)); | 261 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetDrawsContent(true)); |
| 266 // Render surface functions should not trigger update draw properties, because | 262 // Render surface functions should not trigger update draw properties, because |
| 267 // creating render surface is part of update draw properties. | 263 // creating render surface is part of update draw properties. |
| 268 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); | 264 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(true)); |
| 269 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(false)); | 265 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetHasRenderSurface(false)); |
| 270 // Create a render surface, because we must have a render surface if we have | 266 // Create a render surface, because we must have a render surface if we have |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true); | 302 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true); |
| 307 layer->NoteLayerPropertyChanged()); | 303 layer->NoteLayerPropertyChanged()); |
| 308 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f); | 304 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer2->SetPosition(arbitrary_point_f); |
| 309 layer->NoteLayerPropertyChanged()); | 305 layer->NoteLayerPropertyChanged()); |
| 310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1); | 306 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1); |
| 311 layer->NoteLayerPropertyChanged()); | 307 layer->NoteLayerPropertyChanged()); |
| 312 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( | 308 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 313 layer->SetBackgroundColor(arbitrary_color)); | 309 layer->SetBackgroundColor(arbitrary_color)); |
| 314 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( | 310 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 315 layer->OnOpacityAnimated(arbitrary_number)); | 311 layer->OnOpacityAnimated(arbitrary_number)); |
| 316 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBlendMode(arbitrary_blend_mode); | |
| 317 layer->NoteLayerPropertyChanged()); | |
| 318 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( | 312 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 319 layer->OnTransformAnimated(arbitrary_transform)); | 313 layer->OnTransformAnimated(arbitrary_transform)); |
| 320 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size); | 314 VERIFY_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size); |
| 321 layer->NoteLayerPropertyChanged()); | 315 layer->NoteLayerPropertyChanged()); |
| 322 | 316 |
| 323 // Unrelated functions, set to the same values, no needs update. | 317 // Unrelated functions, set to the same values, no needs update. |
| 324 layer->test_properties()->filters = arbitrary_filters; | 318 layer->test_properties()->filters = arbitrary_filters; |
| 325 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 319 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 326 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 320 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 327 layer->OnFilterAnimated(arbitrary_filters)); | 321 layer->OnFilterAnimated(arbitrary_filters)); |
| 328 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); | 322 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetMasksToBounds(true)); |
| 329 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); | 323 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetContentsOpaque(true)); |
| 330 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 324 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 331 layer2->SetPosition(arbitrary_point_f)); | 325 layer2->SetPosition(arbitrary_point_f)); |
| 332 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1)); | 326 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->Set3dSortingContextId(1)); |
| 333 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); | 327 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetDrawsContent(true)); |
| 334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 328 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 335 layer->SetBackgroundColor(arbitrary_color)); | 329 layer->SetBackgroundColor(arbitrary_color)); |
| 336 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 330 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 337 layer->SetBlendMode(arbitrary_blend_mode)); | |
| 338 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | |
| 339 layer->SetTransform(arbitrary_transform)); | 331 layer->SetTransform(arbitrary_transform)); |
| 340 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); | 332 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetBounds(arbitrary_size)); |
| 341 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0))); | 333 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES(layer->SetElementId(ElementId(2, 0))); |
| 342 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( | 334 VERIFY_NO_NEEDS_UPDATE_DRAW_PROPERTIES( |
| 343 layer->SetMutableProperties(MutableProperty::kTransform)); | 335 layer->SetMutableProperties(MutableProperty::kTransform)); |
| 344 } | 336 } |
| 345 | 337 |
| 346 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { | 338 TEST(LayerImplTest, SafeOpaqueBackgroundColor) { |
| 347 FakeImplTaskRunnerProvider task_runner_provider; | 339 FakeImplTaskRunnerProvider task_runner_provider; |
| 348 TestSharedBitmapManager shared_bitmap_manager; | 340 TestSharedBitmapManager shared_bitmap_manager; |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 556 |
| 565 pending_layer->PushPropertiesTo(layer()); | 557 pending_layer->PushPropertiesTo(layer()); |
| 566 | 558 |
| 567 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); | 559 EXPECT_VECTOR_EQ(gfx::Vector2dF(22, 23), layer()->CurrentScrollOffset()); |
| 568 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), | 560 EXPECT_VECTOR_EQ(layer()->CurrentScrollOffset(), |
| 569 pending_layer->CurrentScrollOffset()); | 561 pending_layer->CurrentScrollOffset()); |
| 570 } | 562 } |
| 571 | 563 |
| 572 } // namespace | 564 } // namespace |
| 573 } // namespace cc | 565 } // namespace cc |
| OLD | NEW |