Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: cc/surfaces/compositor_frame_sink_support_unittest.cc

Issue 2736053004: SurfaceIds must be reusable as soon as their surfaces are marked destroyed (Closed)
Patch Set: Make deregister private Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/surfaces/surface_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "cc/surfaces/compositor_frame_sink_support.h" 5 #include "cc/surfaces/compositor_frame_sink_support.h"
6 6
7 #include "base/debug/stack_trace.h" 7 #include "base/debug/stack_trace.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/surfaces/compositor_frame_sink_support_client.h" 10 #include "cc/surfaces/compositor_frame_sink_support_client.h"
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); 977 MakeCompositorFrameWithResources(empty_surface_ids(), {resource}));
978 { 978 {
979 InSequence x; 979 InSequence x;
980 EXPECT_CALL(support_client_, ReclaimResources(_)); 980 EXPECT_CALL(support_client_, ReclaimResources(_));
981 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck()); 981 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck());
982 } 982 }
983 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 983 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
984 CompositorFrame()); 984 CompositorFrame());
985 } 985 }
986 986
987 // Verifies that if a surface is marked destroyed and a new frame arrives for
988 // it, it will be recovered.
989 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) {
990 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
991 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3);
992
993 // Add a reference from the parent to the child.
994 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
995 MakeCompositorFrame({child_id}));
996
997 // Create the child surface by submitting a frame to it.
998 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id));
999 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1000 CompositorFrame());
1001
1002 // Verify that the child surface is created.
1003 Surface* surface = surface_manager().GetSurfaceForId(child_id);
1004 EXPECT_NE(nullptr, surface);
1005
1006 // Attempt to destroy the child surface. The surface must still exist since
1007 // the parent needs it but it will be marked as destroyed.
1008 child_support1().EvictFrame();
1009 surface = surface_manager().GetSurfaceForId(child_id);
1010 EXPECT_NE(nullptr, surface);
1011 EXPECT_TRUE(surface->destroyed());
1012
1013 // Child submits another frame to the same local surface id that is marked
1014 // destroyed.
1015 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1016 CompositorFrame());
1017
1018 // Verify that the surface that was marked destroyed is recovered and is being
1019 // used again.
1020 Surface* surface2 = surface_manager().GetSurfaceForId(child_id);
1021 EXPECT_EQ(surface, surface2);
1022 EXPECT_FALSE(surface2->destroyed());
1023 }
1024
1025 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist
1026 // anymore, it can still be reused for new surfaces.
1027 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) {
1028 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
1029 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3);
1030
1031 // Add a reference from parent.
1032 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1033 MakeCompositorFrame({child_id}));
1034
1035 // Submit the first frame. Creates the surface.
1036 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1037 CompositorFrame());
1038 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id));
1039
1040 // Remove the reference from parant. This allows us to destroy the surface.
1041 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1042 CompositorFrame());
1043
1044 // Destroy the surface.
1045 child_support1().EvictFrame();
1046 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id));
1047
1048 // Submit another frame with the same local surface id. This should work fine
1049 // and a new surface must be created.
1050 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1051 CompositorFrame());
1052 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id));
1053 }
1054
987 } // namespace test 1055 } // namespace test
988 } // namespace cc 1056 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698