| 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/trees/damage_tracker.h" | 5 #include "cc/trees/damage_tracker.h" | 
| 6 | 6 | 
| 7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" | 
| 8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" | 
|  | 9 #include "cc/output/filter_operation.h" | 
|  | 10 #include "cc/output/filter_operations.h" | 
| 9 #include "cc/test/fake_impl_proxy.h" | 11 #include "cc/test/fake_impl_proxy.h" | 
| 10 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" | 
| 11 #include "cc/test/geometry_test_utils.h" | 13 #include "cc/test/geometry_test_utils.h" | 
| 12 #include "cc/trees/layer_tree_host_common.h" | 14 #include "cc/trees/layer_tree_host_common.h" | 
| 13 #include "cc/trees/single_thread_proxy.h" | 15 #include "cc/trees/single_thread_proxy.h" | 
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" | 
| 15 #include "third_party/WebKit/public/platform/WebFilterOperation.h" |  | 
| 16 #include "third_party/WebKit/public/platform/WebFilterOperations.h" |  | 
| 17 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 17 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 
| 18 #include "ui/gfx/quad_f.h" | 18 #include "ui/gfx/quad_f.h" | 
| 19 | 19 | 
| 20 using WebKit::WebFilterOperation; |  | 
| 21 using WebKit::WebFilterOperations; |  | 
| 22 |  | 
| 23 namespace cc { | 20 namespace cc { | 
| 24 namespace { | 21 namespace { | 
| 25 | 22 | 
| 26 void ExecuteCalculateDrawProperties( | 23 void ExecuteCalculateDrawProperties( | 
| 27     LayerImpl* root, | 24     LayerImpl* root, | 
| 28     LayerImplList& render_surface_layer_list) { | 25     LayerImplList& render_surface_layer_list) { | 
| 29   int dummy_max_texture_size = 512; | 26   int dummy_max_texture_size = 512; | 
| 30 | 27 | 
| 31   // Sanity check: The test itself should create the root layer's render | 28   // Sanity check: The test itself should create the root layer's render | 
| 32   //               surface, so that the surface (and its damage tracker) can | 29   //               surface, so that the surface (and its damage tracker) can | 
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 413   gfx::RectF damage_we_care_about = | 410   gfx::RectF damage_we_care_about = | 
| 414           gfx::RectF(gfx::PointF(), gfx::SizeF(500.f, 500.f)); | 411           gfx::RectF(gfx::PointF(), gfx::SizeF(500.f, 500.f)); | 
| 415   EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); | 412   EXPECT_TRUE(root_damage_rect.Contains(damage_we_care_about)); | 
| 416 } | 413 } | 
| 417 | 414 | 
| 418 TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { | 415 TEST_F(DamageTrackerTest, VerifyDamageForBlurredSurface) { | 
| 419   scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 416   scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 
| 420   LayerImpl* surface = root->children()[0]; | 417   LayerImpl* surface = root->children()[0]; | 
| 421   LayerImpl* child = surface->children()[0]; | 418   LayerImpl* child = surface->children()[0]; | 
| 422 | 419 | 
| 423   WebFilterOperations filters; | 420   FilterOperations filters; | 
| 424   filters.append(WebFilterOperation::createBlurFilter(5)); | 421   filters.Append(FilterOperation::CreateBlurFilter(5)); | 
| 425   int outset_top, outset_right, outset_bottom, outset_left; | 422   int outset_top, outset_right, outset_bottom, outset_left; | 
| 426   filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 423   filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left); | 
| 427 | 424 | 
| 428   // Setting the filter will damage the whole surface. | 425   // Setting the filter will damage the whole surface. | 
| 429   ClearDamageForAllSurfaces(root.get()); | 426   ClearDamageForAllSurfaces(root.get()); | 
| 430   surface->SetFilters(filters); | 427   surface->SetFilters(filters); | 
| 431   EmulateDrawingOneFrame(root.get()); | 428   EmulateDrawingOneFrame(root.get()); | 
| 432 | 429 | 
| 433   // Setting the update rect should cause the corresponding damage to the | 430   // Setting the update rect should cause the corresponding damage to the | 
| 434   // surface, blurred based on the size of the blur filter. | 431   // surface, blurred based on the size of the blur filter. | 
| 435   ClearDamageForAllSurfaces(root.get()); | 432   ClearDamageForAllSurfaces(root.get()); | 
| 436   child->set_update_rect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); | 433   child->set_update_rect(gfx::RectF(1.f, 2.f, 3.f, 4.f)); | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 487 } | 484 } | 
| 488 | 485 | 
| 489 TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { | 486 TEST_F(DamageTrackerTest, VerifyDamageForBackgroundBlurredChild) { | 
| 490   scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 487   scoped_ptr<LayerImpl> root = CreateAndSetUpTestTreeWithTwoSurfaces(); | 
| 491   LayerImpl* child1 = root->children()[0]; | 488   LayerImpl* child1 = root->children()[0]; | 
| 492   LayerImpl* child2 = root->children()[1]; | 489   LayerImpl* child2 = root->children()[1]; | 
| 493 | 490 | 
| 494   // Allow us to set damage on child1 too. | 491   // Allow us to set damage on child1 too. | 
| 495   child1->SetDrawsContent(true); | 492   child1->SetDrawsContent(true); | 
| 496 | 493 | 
| 497   WebFilterOperations filters; | 494   FilterOperations filters; | 
| 498   filters.append(WebFilterOperation::createBlurFilter(2)); | 495   filters.Append(FilterOperation::CreateBlurFilter(2)); | 
| 499   int outset_top, outset_right, outset_bottom, outset_left; | 496   int outset_top, outset_right, outset_bottom, outset_left; | 
| 500   filters.getOutsets(outset_top, outset_right, outset_bottom, outset_left); | 497   filters.GetOutsets(&outset_top, &outset_right, &outset_bottom, &outset_left); | 
| 501 | 498 | 
| 502   // Setting the filter will damage the whole surface. | 499   // Setting the filter will damage the whole surface. | 
| 503   ClearDamageForAllSurfaces(root.get()); | 500   ClearDamageForAllSurfaces(root.get()); | 
| 504   child1->SetBackgroundFilters(filters); | 501   child1->SetBackgroundFilters(filters); | 
| 505   EmulateDrawingOneFrame(root.get()); | 502   EmulateDrawingOneFrame(root.get()); | 
| 506 | 503 | 
| 507   // CASE 1: Setting the update rect should cause the corresponding damage to | 504   // CASE 1: Setting the update rect should cause the corresponding damage to | 
| 508   //         the surface, blurred based on the size of the child's background | 505   //         the surface, blurred based on the size of the child's background | 
| 509   //         blur filter. | 506   //         blur filter. | 
| 510   ClearDamageForAllSurfaces(root.get()); | 507   ClearDamageForAllSurfaces(root.get()); | 
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1305 | 1302 | 
| 1306   ASSERT_TRUE(root == root->render_target()); | 1303   ASSERT_TRUE(root == root->render_target()); | 
| 1307   RenderSurfaceImpl* target_surface = root->render_surface(); | 1304   RenderSurfaceImpl* target_surface = root->render_surface(); | 
| 1308   target_surface->ClearLayerLists(); | 1305   target_surface->ClearLayerLists(); | 
| 1309   target_surface->damage_tracker()->UpdateDamageTrackingState( | 1306   target_surface->damage_tracker()->UpdateDamageTrackingState( | 
| 1310       target_surface->layer_list(), | 1307       target_surface->layer_list(), | 
| 1311       target_surface->OwningLayerId(), | 1308       target_surface->OwningLayerId(), | 
| 1312       false, | 1309       false, | 
| 1313       gfx::Rect(), | 1310       gfx::Rect(), | 
| 1314       NULL, | 1311       NULL, | 
| 1315       WebFilterOperations(), | 1312       FilterOperations(), | 
| 1316       NULL); | 1313       NULL); | 
| 1317 | 1314 | 
| 1318   gfx::RectF damage_rect = | 1315   gfx::RectF damage_rect = | 
| 1319           target_surface->damage_tracker()->current_damage_rect(); | 1316           target_surface->damage_tracker()->current_damage_rect(); | 
| 1320   EXPECT_TRUE(damage_rect.IsEmpty()); | 1317   EXPECT_TRUE(damage_rect.IsEmpty()); | 
| 1321 } | 1318 } | 
| 1322 | 1319 | 
| 1323 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { | 1320 TEST_F(DamageTrackerTest, VerifyDamageAccumulatesUntilReset) { | 
| 1324   // If damage is not cleared, it should accumulate. | 1321   // If damage is not cleared, it should accumulate. | 
| 1325 | 1322 | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 1353   // Damage should remain empty even after one frame, since there's yet no new | 1350   // Damage should remain empty even after one frame, since there's yet no new | 
| 1354   // damage. | 1351   // damage. | 
| 1355   EmulateDrawingOneFrame(root.get()); | 1352   EmulateDrawingOneFrame(root.get()); | 
| 1356   root_damage_rect = | 1353   root_damage_rect = | 
| 1357           root->render_surface()->damage_tracker()->current_damage_rect(); | 1354           root->render_surface()->damage_tracker()->current_damage_rect(); | 
| 1358   EXPECT_TRUE(root_damage_rect.IsEmpty()); | 1355   EXPECT_TRUE(root_damage_rect.IsEmpty()); | 
| 1359 } | 1356 } | 
| 1360 | 1357 | 
| 1361 }  // namespace | 1358 }  // namespace | 
| 1362 }  // namespace cc | 1359 }  // namespace cc | 
| OLD | NEW | 
|---|