| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/containers/flat_set.h" | 5 #include "base/containers/flat_set.h" |
| 6 #include "cc/surfaces/compositor_frame_sink_support.h" | 6 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 7 #include "cc/surfaces/surface_id.h" | 7 #include "cc/surfaces/surface_id.h" |
| 8 #include "cc/surfaces/surface_manager.h" | 8 #include "cc/surfaces/surface_manager.h" |
| 9 #include "cc/surfaces/surface_observer.h" | 9 #include "cc/surfaces/surface_observer.h" |
| 10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 MakeCompositorFrame({child_id2}, empty_surface_ids(), | 638 MakeCompositorFrame({child_id2}, empty_surface_ids(), |
| 639 TransferableResourceArray())); | 639 TransferableResourceArray())); |
| 640 | 640 |
| 641 // Verify that the CompositorFrame is blocked on |child_id2|. | 641 // Verify that the CompositorFrame is blocked on |child_id2|. |
| 642 EXPECT_FALSE(child_surface1()->HasActiveFrame()); | 642 EXPECT_FALSE(child_surface1()->HasActiveFrame()); |
| 643 EXPECT_TRUE(child_surface1()->HasPendingFrame()); | 643 EXPECT_TRUE(child_surface1()->HasPendingFrame()); |
| 644 EXPECT_THAT(child_surface1()->blocking_surfaces(), | 644 EXPECT_THAT(child_surface1()->blocking_surfaces(), |
| 645 UnorderedElementsAre(child_id2)); | 645 UnorderedElementsAre(child_id2)); |
| 646 | 646 |
| 647 // Evict child_support1's current Surface. | 647 // Evict child_support1's current Surface. |
| 648 // TODO(fsamuel): EvictFrame => EvictCurrentSurface. | 648 // TODO(fsamuel): EvictCurrentSurface => EvictCurrentSurface. |
| 649 child_support1().EvictFrame(); | 649 child_support1().EvictCurrentSurface(); |
| 650 | 650 |
| 651 // The parent Surface should immediately activate. | 651 // The parent Surface should immediately activate. |
| 652 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 652 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 653 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 653 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 654 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 654 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 655 EXPECT_FALSE(dependency_tracker().has_deadline()); | 655 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 656 } | 656 } |
| 657 | 657 |
| 658 // This test verifies that if a surface has both a pending and active | 658 // This test verifies that if a surface has both a pending and active |
| 659 // CompositorFrame and the pending CompositorFrame activates, replacing the | 659 // CompositorFrame and the pending CompositorFrame activates, replacing the |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 Surface* surface = surface_manager().GetSurfaceForId(child_id); | 1039 Surface* surface = surface_manager().GetSurfaceForId(child_id); |
| 1040 EXPECT_NE(nullptr, surface); | 1040 EXPECT_NE(nullptr, surface); |
| 1041 | 1041 |
| 1042 // Add a reference from the parent to the child. | 1042 // Add a reference from the parent to the child. |
| 1043 parent_support().SubmitCompositorFrame( | 1043 parent_support().SubmitCompositorFrame( |
| 1044 parent_id.local_surface_id(), | 1044 parent_id.local_surface_id(), |
| 1045 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); | 1045 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1046 | 1046 |
| 1047 // Attempt to destroy the child surface. The surface must still exist since | 1047 // Attempt to destroy the child surface. The surface must still exist since |
| 1048 // the parent needs it but it will be marked as destroyed. | 1048 // the parent needs it but it will be marked as destroyed. |
| 1049 child_support1().EvictFrame(); | 1049 child_support1().EvictCurrentSurface(); |
| 1050 surface = surface_manager().GetSurfaceForId(child_id); | 1050 surface = surface_manager().GetSurfaceForId(child_id); |
| 1051 EXPECT_NE(nullptr, surface); | 1051 EXPECT_NE(nullptr, surface); |
| 1052 EXPECT_TRUE(surface->destroyed()); | 1052 EXPECT_TRUE(surface->destroyed()); |
| 1053 | 1053 |
| 1054 // Child submits another frame to the same local surface id that is marked | 1054 // Child submits another frame to the same local surface id that is marked |
| 1055 // destroyed. | 1055 // destroyed. |
| 1056 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1056 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1057 MakeCompositorFrame()); | 1057 MakeCompositorFrame()); |
| 1058 | 1058 |
| 1059 // Verify that the surface that was marked destroyed is recovered and is being | 1059 // Verify that the surface that was marked destroyed is recovered and is being |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1077 // Add a reference from parent. | 1077 // Add a reference from parent. |
| 1078 parent_support().SubmitCompositorFrame( | 1078 parent_support().SubmitCompositorFrame( |
| 1079 parent_id.local_surface_id(), | 1079 parent_id.local_surface_id(), |
| 1080 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); | 1080 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1081 | 1081 |
| 1082 // Remove the reference from parant. This allows us to destroy the surface. | 1082 // Remove the reference from parant. This allows us to destroy the surface. |
| 1083 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1083 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 1084 MakeCompositorFrame()); | 1084 MakeCompositorFrame()); |
| 1085 | 1085 |
| 1086 // Destroy the surface. | 1086 // Destroy the surface. |
| 1087 child_support1().EvictFrame(); | 1087 child_support1().EvictCurrentSurface(); |
| 1088 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1088 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1089 | 1089 |
| 1090 // Submit another frame with the same local surface id. This should work fine | 1090 // Submit another frame with the same local surface id. This should work fine |
| 1091 // and a new surface must be created. | 1091 // and a new surface must be created. |
| 1092 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1092 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1093 MakeCompositorFrame()); | 1093 MakeCompositorFrame()); |
| 1094 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1094 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 // This test verifies that a crash does not occur if garbage collection is | 1097 // This test verifies that a crash does not occur if garbage collection is |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 DidReceiveCompositorFrameAck(Eq(returned_resources2))); | 1381 DidReceiveCompositorFrameAck(Eq(returned_resources2))); |
| 1382 child_support1().SubmitCompositorFrame( | 1382 child_support1().SubmitCompositorFrame( |
| 1383 child_id1.local_surface_id(), | 1383 child_id1.local_surface_id(), |
| 1384 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), | 1384 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 1385 {resource2})); | 1385 {resource2})); |
| 1386 testing::Mock::VerifyAndClearExpectations(&support_client_); | 1386 testing::Mock::VerifyAndClearExpectations(&support_client_); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 } // namespace test | 1389 } // namespace test |
| 1390 } // namespace cc | 1390 } // namespace cc |
| OLD | NEW |