Index: cc/surfaces/surface_synchronization_unittest.cc |
diff --git a/cc/surfaces/compositor_frame_sink_support_unittest.cc b/cc/surfaces/surface_synchronization_unittest.cc |
similarity index 85% |
copy from cc/surfaces/compositor_frame_sink_support_unittest.cc |
copy to cc/surfaces/surface_synchronization_unittest.cc |
index 7451f8cb5d7c68e4c5dbdf52f8848ab3f38738ad..8c2148682c945b097de4f07abdd5e96f181f0a85 100644 |
--- a/cc/surfaces/compositor_frame_sink_support_unittest.cc |
+++ b/cc/surfaces/surface_synchronization_unittest.cc |
@@ -3,68 +3,35 @@ |
// found in the LICENSE file. |
#include "cc/surfaces/compositor_frame_sink_support.h" |
- |
-#include "base/macros.h" |
-#include "cc/output/compositor_frame.h" |
-#include "cc/surfaces/compositor_frame_sink_support_client.h" |
-#include "cc/surfaces/frame_sink_id.h" |
#include "cc/surfaces/surface_id.h" |
#include "cc/surfaces/surface_manager.h" |
+#include "cc/surfaces/surface_observer.h" |
#include "cc/test/begin_frame_args_test.h" |
#include "cc/test/compositor_frame_helpers.h" |
#include "cc/test/fake_external_begin_frame_source.h" |
+#include "cc/test/mock_compositor_frame_sink_support_client.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
-using testing::UnorderedElementsAre; |
-using testing::IsEmpty; |
-using testing::SizeIs; |
-using testing::Invoke; |
using testing::_; |
using testing::Eq; |
+using testing::IsEmpty; |
+using testing::UnorderedElementsAre; |
namespace cc { |
+namespace test { |
namespace { |
+constexpr bool kIsRoot = true; |
+constexpr bool kIsChildRoot = false; |
+constexpr bool kHandlesFrameSinkIdInvalidation = true; |
+constexpr bool kNeedsSyncPoints = true; |
constexpr FrameSinkId kDisplayFrameSink(2, 0); |
constexpr FrameSinkId kParentFrameSink(3, 0); |
constexpr FrameSinkId kChildFrameSink1(65563, 0); |
constexpr FrameSinkId kChildFrameSink2(65564, 0); |
constexpr FrameSinkId kArbitraryFrameSink(1337, 7331); |
-class MockCompositorFrameSinkSupportClient |
- : public CompositorFrameSinkSupportClient { |
- public: |
- MockCompositorFrameSinkSupportClient() { |
- ON_CALL(*this, ReclaimResources(_)) |
- .WillByDefault(Invoke( |
- this, |
- &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); |
- ON_CALL(*this, DidReceiveCompositorFrameAck(_)) |
- .WillByDefault(Invoke( |
- this, |
- &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); |
- } |
- |
- ReturnedResourceArray& last_returned_resources() { |
- return last_returned_resources_; |
- } |
- |
- // CompositorFrameSinkSupportClient implementation. |
- MOCK_METHOD1(DidReceiveCompositorFrameAck, |
- void(const ReturnedResourceArray&)); |
- MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); |
- MOCK_METHOD1(ReclaimResources, void(const ReturnedResourceArray&)); |
- MOCK_METHOD2(WillDrawSurface, void(const LocalSurfaceId&, const gfx::Rect&)); |
- |
- private: |
- void ReclaimResourcesInternal(const ReturnedResourceArray& resources) { |
- last_returned_resources_ = resources; |
- } |
- |
- ReturnedResourceArray last_returned_resources_; |
-}; |
- |
std::vector<SurfaceId> empty_surface_ids() { |
return std::vector<SurfaceId>(); |
} |
@@ -75,66 +42,14 @@ SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { |
LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); |
} |
-CompositorFrame MakeCompositorFrame( |
- std::vector<SurfaceId> activation_dependencies, |
- std::vector<SurfaceId> referenced_surfaces, |
- TransferableResourceArray resource_list) { |
- CompositorFrame compositor_frame = test::MakeCompositorFrame(); |
- compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, true); |
- compositor_frame.metadata.activation_dependencies = |
- std::move(activation_dependencies); |
- compositor_frame.metadata.referenced_surfaces = |
- std::move(referenced_surfaces); |
- compositor_frame.resource_list = std::move(resource_list); |
- return compositor_frame; |
-} |
- |
-CompositorFrame MakeCompositorFrame() { |
- return MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
- TransferableResourceArray()); |
-} |
- |
-CompositorFrame MakeCompositorFrame( |
- std::vector<SurfaceId> activation_dependencies) { |
- return MakeCompositorFrame(activation_dependencies, activation_dependencies, |
- TransferableResourceArray()); |
-} |
- |
-CompositorFrame MakeCompositorFrame( |
- std::vector<SurfaceId> activation_dependencies, |
- std::vector<SurfaceId> referenced_surfaces) { |
- return MakeCompositorFrame(std::move(activation_dependencies), |
- std::move(referenced_surfaces), |
- TransferableResourceArray()); |
-} |
- |
-CompositorFrame MakeCompositorFrameWithResources( |
- std::vector<SurfaceId> activation_dependencies, |
- TransferableResourceArray resource_list) { |
- return MakeCompositorFrame(activation_dependencies, empty_surface_ids(), |
- std::move(resource_list)); |
-} |
- |
-TransferableResource MakeResource(ResourceId id, |
- ResourceFormat format, |
- uint32_t filter, |
- const gfx::Size& size) { |
- TransferableResource resource; |
- resource.id = id; |
- resource.format = format; |
- resource.filter = filter; |
- resource.size = size; |
- return resource; |
-} |
- |
} // namespace |
-class CompositorFrameSinkSupportTest : public testing::Test, |
- public SurfaceObserver { |
+class SurfaceSynchronizationTest : public testing::Test, |
+ public SurfaceObserver { |
public: |
- CompositorFrameSinkSupportTest() |
+ SurfaceSynchronizationTest() |
: surface_manager_(SurfaceManager::LifetimeType::REFERENCES) {} |
- ~CompositorFrameSinkSupportTest() override {} |
+ ~SurfaceSynchronizationTest() override {} |
CompositorFrameSinkSupport& display_support() { return *supports_[0]; } |
Surface* display_surface() { |
@@ -188,10 +103,7 @@ class CompositorFrameSinkSupportTest : public testing::Test, |
// testing::Test: |
void SetUp() override { |
testing::Test::SetUp(); |
- constexpr bool is_root = true; |
- constexpr bool is_child_root = false; |
- constexpr bool handles_frame_sink_id_invalidation = true; |
- constexpr bool needs_sync_points = true; |
+ |
begin_frame_source_ = |
base::MakeUnique<FakeExternalBeginFrameSource>(0.f, false); |
surface_manager_.SetDependencyTracker( |
@@ -199,17 +111,17 @@ class CompositorFrameSinkSupportTest : public testing::Test, |
begin_frame_source_.get())); |
surface_manager_.AddObserver(this); |
supports_.push_back(CompositorFrameSinkSupport::Create( |
- &support_client_, &surface_manager_, kDisplayFrameSink, is_root, |
- handles_frame_sink_id_invalidation, needs_sync_points)); |
+ &support_client_, &surface_manager_, kDisplayFrameSink, kIsRoot, |
+ kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
supports_.push_back(CompositorFrameSinkSupport::Create( |
- &support_client_, &surface_manager_, kParentFrameSink, is_child_root, |
- handles_frame_sink_id_invalidation, needs_sync_points)); |
+ &support_client_, &surface_manager_, kParentFrameSink, kIsChildRoot, |
+ kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
supports_.push_back(CompositorFrameSinkSupport::Create( |
- &support_client_, &surface_manager_, kChildFrameSink1, is_child_root, |
- handles_frame_sink_id_invalidation, needs_sync_points)); |
+ &support_client_, &surface_manager_, kChildFrameSink1, kIsChildRoot, |
+ kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
supports_.push_back(CompositorFrameSinkSupport::Create( |
- &support_client_, &surface_manager_, kChildFrameSink2, is_child_root, |
- handles_frame_sink_id_invalidation, needs_sync_points)); |
+ &support_client_, &surface_manager_, kChildFrameSink2, kIsChildRoot, |
+ kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
// Normally, the BeginFrameSource would be registered by the Display. We |
// register it here so that BeginFrames are received by the display support, |
@@ -252,12 +164,12 @@ class CompositorFrameSinkSupportTest : public testing::Test, |
std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; |
std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; |
- DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupportTest); |
+ DISALLOW_COPY_AND_ASSIGN(SurfaceSynchronizationTest); |
}; |
// The display root surface should have a surface reference from the top-level |
// root added/removed when a CompositorFrame is submitted with a new SurfaceId. |
-TEST_F(CompositorFrameSinkSupportTest, RootSurfaceReceivesReferences) { |
+TEST_F(SurfaceSynchronizationTest, RootSurfaceReceivesReferences) { |
const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); |
const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); |
@@ -286,14 +198,15 @@ TEST_F(CompositorFrameSinkSupportTest, RootSurfaceReceivesReferences) { |
} |
// The parent Surface is blocked on |child_id1| and |child_id2|. |
-TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) { |
+TEST_F(SurfaceSynchronizationTest, BlockedOnTwo) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id1, child_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id1, child_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// parent_support is blocked on |child_id1| and |child_id2|. |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -325,14 +238,15 @@ TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) { |
} |
// The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. |
-TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) { |
+TEST_F(SurfaceSynchronizationTest, BlockedChain) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id1}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id1}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// parent_support is blocked on |child_id1|. |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -345,7 +259,8 @@ TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) { |
child_support1().SubmitCompositorFrame( |
child_id1.local_surface_id(), |
- MakeCompositorFrame({child_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// child_support1 should now be blocked on |child_id2|. |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -364,7 +279,9 @@ TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) { |
// Submit a CompositorFrame without any dependencies to |child_id2|. |
// parent_support should be activated. |
child_support2().SubmitCompositorFrame( |
- child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); |
+ child_id2.local_surface_id(), |
+ MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
+ TransferableResourceArray())); |
EXPECT_FALSE(dependency_tracker().has_deadline()); |
@@ -386,15 +303,15 @@ TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) { |
} |
// parent_surface and child_surface1 are blocked on |child_id2|. |
-TEST_F(CompositorFrameSinkSupportTest, |
- DisplayCompositorLockingTwoBlockedOnOne) { |
+TEST_F(SurfaceSynchronizationTest, TwoBlockedOnOne) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// parent_support is blocked on |child_id2|. |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -406,7 +323,8 @@ TEST_F(CompositorFrameSinkSupportTest, |
// child_support1 should now be blocked on |child_id2|. |
child_support1().SubmitCompositorFrame( |
child_id1.local_surface_id(), |
- MakeCompositorFrame({child_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
EXPECT_FALSE(child_surface1()->HasActiveFrame()); |
@@ -438,14 +356,15 @@ TEST_F(CompositorFrameSinkSupportTest, |
// parent_surface is blocked on |child_id1|, and child_surface2 is blocked on |
// |child_id2| until the deadline hits. |
-TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingDeadlineHits) { |
+TEST_F(SurfaceSynchronizationTest, DeadlineHits) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id1}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id1}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// parent_support is blocked on |child_id1|. |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -456,7 +375,8 @@ TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingDeadlineHits) { |
child_support1().SubmitCompositorFrame( |
child_id1.local_surface_id(), |
- MakeCompositorFrame({child_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// child_support1 should now be blocked on |child_id2|. |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -508,8 +428,7 @@ TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingDeadlineHits) { |
// Verifies that the deadline does not reset if we submit CompositorFrames |
// to new Surfaces with unresolved dependencies. |
-TEST_F(CompositorFrameSinkSupportTest, |
- DisplayCompositorLockingFramesSubmittedAfterDeadlineSet) { |
+TEST_F(SurfaceSynchronizationTest, FramesSubmittedAfterDeadlineSet) { |
const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); |
BeginFrameArgs args = |
CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
@@ -517,7 +436,8 @@ TEST_F(CompositorFrameSinkSupportTest, |
LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); |
support(i).SubmitCompositorFrame( |
local_surface_id, |
- MakeCompositorFrame({arbitrary_id}, empty_surface_ids())); |
+ MakeCompositorFrame({arbitrary_id}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// The deadline has been set. |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -542,15 +462,15 @@ TEST_F(CompositorFrameSinkSupportTest, |
// This test verifies at the Surface activates once a CompositorFrame is |
// submitted that has no unresolved dependencies. |
-TEST_F(CompositorFrameSinkSupportTest, |
- DisplayCompositorLockingNewFrameOverridesOldDependencies) { |
+TEST_F(SurfaceSynchronizationTest, NewFrameOverridesOldDependencies) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); |
// Submit a CompositorFrame that depends on |arbitrary_id|. |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({arbitrary_id}, empty_surface_ids())); |
+ MakeCompositorFrame({arbitrary_id}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// Verify that the CompositorFrame is blocked on |arbitrary_id|. |
EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
@@ -571,8 +491,7 @@ TEST_F(CompositorFrameSinkSupportTest, |
// This test verifies that a pending CompositorFrame does not affect surface |
// references. A new surface from a child will continue to exist as a temporary |
// reference until the parent's frame activates. |
-TEST_F(CompositorFrameSinkSupportTest, |
- OnlyActiveFramesAffectSurfaceReferences) { |
+TEST_F(SurfaceSynchronizationTest, OnlyActiveFramesAffectSurfaceReferences) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
@@ -600,7 +519,8 @@ TEST_F(CompositorFrameSinkSupportTest, |
EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id2}, {child_id1})); |
+ MakeCompositorFrame({child_id2}, {child_id1}, |
+ TransferableResourceArray())); |
EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
EXPECT_THAT(parent_surface()->blocking_surfaces(), |
@@ -637,21 +557,22 @@ TEST_F(CompositorFrameSinkSupportTest, |
// This test verifies that we do not double count returned resources when a |
// CompositorFrame starts out as pending, then becomes active, and then is |
// replaced with another active CompositorFrame. |
-TEST_F(CompositorFrameSinkSupportTest, |
- DisplayCompositorLockingResourcesOnlyReturnedOnce) { |
+TEST_F(SurfaceSynchronizationTest, ResourcesOnlyReturnedOnce) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
// The parent submits a CompositorFrame that depends on |child_id| before the |
// child submits a CompositorFrame. The CompositorFrame also has resources in |
// its resource list. |
- TransferableResource resource = |
- MakeResource(1337 /* id */, ALPHA_8 /* format */, 1234 /* filter */, |
- gfx::Size(1234, 5678)); |
+ TransferableResource resource; |
+ resource.id = 1337; |
+ resource.format = ALPHA_8; |
+ resource.filter = 1234; |
+ resource.size = gfx::Size(1234, 5678); |
TransferableResourceArray resource_list = {resource}; |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrameWithResources({child_id}, resource_list)); |
+ MakeCompositorFrame({child_id}, empty_surface_ids(), resource_list)); |
// Verify that the CompositorFrame is blocked on |child_id|. |
EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
@@ -660,7 +581,9 @@ TEST_F(CompositorFrameSinkSupportTest, |
UnorderedElementsAre(child_id)); |
child_support1().SubmitCompositorFrame( |
- child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); |
+ child_id.local_surface_id(), |
+ MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
+ TransferableResourceArray())); |
// Verify that the child CompositorFrame activates immediately. |
EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
@@ -672,23 +595,26 @@ TEST_F(CompositorFrameSinkSupportTest, |
EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
+ ReturnedResourceArray returned_resources = {resource.ToReturnedResource()}; |
+ EXPECT_CALL(support_client_, |
+ DidReceiveCompositorFrameAck(returned_resources)); |
+ |
// The parent submits a CompositorFrame without any dependencies. That frame |
// should activate immediately, replacing the earlier frame. The resource from |
// the earlier frame should be returned to the client. |
parent_support().SubmitCompositorFrame( |
- parent_id.local_surface_id(), MakeCompositorFrame({empty_surface_ids()})); |
+ parent_id.local_surface_id(), |
+ MakeCompositorFrame({empty_surface_ids()}, {empty_surface_ids()}, |
+ TransferableResourceArray())); |
EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
- ReturnedResource returned_resource = resource.ToReturnedResource(); |
- EXPECT_THAT(support_client_.last_returned_resources(), |
- UnorderedElementsAre(returned_resource)); |
} |
// The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. |
// child_support1 evicts its blocked Surface. The parent surface should |
// activate. |
-TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { |
+TEST_F(SurfaceSynchronizationTest, EvictSurfaceWithPendingFrame) { |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
@@ -696,7 +622,8 @@ TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { |
// Submit a CompositorFrame that depends on |child_id1|. |
parent_support().SubmitCompositorFrame( |
parent_id1.local_surface_id(), |
- MakeCompositorFrame({child_id1}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id1}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// Verify that the CompositorFrame is blocked on |child_id1|. |
EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
@@ -707,7 +634,8 @@ TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { |
// Submit a CompositorFrame that depends on |child_id2|. |
child_support1().SubmitCompositorFrame( |
child_id1.local_surface_id(), |
- MakeCompositorFrame({child_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// Verify that the CompositorFrame is blocked on |child_id2|. |
EXPECT_FALSE(child_surface1()->HasActiveFrame()); |
@@ -731,7 +659,7 @@ TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { |
// existing active CompositorFrame, then the surface reference hierarchy will be |
// updated allowing garbage collection of surfaces that are no longer |
// referenced. |
-TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { |
+TEST_F(SurfaceSynchronizationTest, DropStaleReferencesAfterActivation) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
@@ -741,7 +669,8 @@ TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { |
EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id1}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id1}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// Verify that the CompositorFrame is blocked on |child_id|. |
EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
@@ -773,7 +702,8 @@ TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { |
// Submit a new parent CompositorFrame to add a reference. |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame(empty_surface_ids(), {child_id1})); |
+ MakeCompositorFrame(empty_surface_ids(), {child_id1}, |
+ TransferableResourceArray())); |
// Verify that the parent Surface has activated. |
EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
@@ -790,7 +720,8 @@ TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { |
EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
testing::Mock::VerifyAndClearExpectations(&support_client_); |
// The parent surface should now have both a pending and activate |
@@ -818,7 +749,7 @@ TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { |
// Checks whether the latency info are moved to the new surface from the old |
// one when LocalSurfaceId changes. No frame has unresolved dependencies. |
-TEST_F(CompositorFrameSinkSupportTest, |
+TEST_F(SurfaceSynchronizationTest, |
LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) { |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
@@ -888,7 +819,7 @@ TEST_F(CompositorFrameSinkSupportTest, |
// Checks whether the latency info are moved to the new surface from the old |
// one when LocalSurfaceId changes. Old surface has unresolved dependencies. |
-TEST_F(CompositorFrameSinkSupportTest, |
+TEST_F(SurfaceSynchronizationTest, |
LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
@@ -916,7 +847,8 @@ TEST_F(CompositorFrameSinkSupportTest, |
ui::LatencyInfo info2; |
info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); |
- CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids()); |
+ CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids(), |
+ TransferableResourceArray()); |
frame2.metadata.latency_info.push_back(info2); |
parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
@@ -964,7 +896,7 @@ TEST_F(CompositorFrameSinkSupportTest, |
// Checks whether the latency info are moved to the new surface from the old |
// one when LocalSurfaceId changes. The new surface has unresolved dependencies. |
-TEST_F(CompositorFrameSinkSupportTest, |
+TEST_F(SurfaceSynchronizationTest, |
LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
@@ -999,7 +931,8 @@ TEST_F(CompositorFrameSinkSupportTest, |
ui::LatencyInfo info2; |
info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); |
- CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids()); |
+ CompositorFrame frame2 = MakeCompositorFrame({child_id}, empty_surface_ids(), |
+ TransferableResourceArray()); |
frame2.metadata.latency_info.push_back(info2); |
parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), |
@@ -1041,7 +974,7 @@ TEST_F(CompositorFrameSinkSupportTest, |
ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
} |
-TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { |
+TEST_F(SurfaceSynchronizationTest, PassesOnBeginFrameAcks) { |
const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
// Request BeginFrames. |
@@ -1073,13 +1006,14 @@ TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { |
} |
// Checks that resources and ack are sent together if possible. |
-TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesWithAck) { |
+TEST_F(SurfaceSynchronizationTest, ReturnResourcesWithAck) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
TransferableResource resource; |
resource.id = 1234; |
parent_support().SubmitCompositorFrame( |
parent_id.local_surface_id(), |
- MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); |
+ MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
+ {resource})); |
ReturnedResourceArray returned_resources; |
TransferableResource::ReturnResources({resource}, &returned_resources); |
EXPECT_CALL(support_client_, ReclaimResources(_)).Times(0); |
@@ -1091,7 +1025,7 @@ TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesWithAck) { |
// Verifies that if a surface is marked destroyed and a new frame arrives for |
// it, it will be recovered. |
-TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { |
+TEST_F(SurfaceSynchronizationTest, SurfaceResurrection) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); |
@@ -1105,8 +1039,9 @@ TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { |
EXPECT_NE(nullptr, surface); |
// Add a reference from the parent to the child. |
- parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id})); |
+ parent_support().SubmitCompositorFrame( |
+ parent_id.local_surface_id(), |
+ MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
// Attempt to destroy the child surface. The surface must still exist since |
// the parent needs it but it will be marked as destroyed. |
@@ -1129,7 +1064,7 @@ TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { |
// Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist |
// anymore, it can still be reused for new surfaces. |
-TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { |
+TEST_F(SurfaceSynchronizationTest, LocalSurfaceIdIsReusable) { |
const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); |
@@ -1139,8 +1074,9 @@ TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { |
EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); |
// Add a reference from parent. |
- parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
- MakeCompositorFrame({child_id})); |
+ parent_support().SubmitCompositorFrame( |
+ parent_id.local_surface_id(), |
+ MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
// Remove the reference from parant. This allows us to destroy the surface. |
parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
@@ -1164,7 +1100,7 @@ TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { |
// activated subtree refer to the same dependency. The old subtree was activated |
// by deadline, and the new subtree was activated by a dependency finally |
// resolving. |
-TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) { |
+TEST_F(SurfaceSynchronizationTest, DependencyTrackingGarbageCollection) { |
const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
@@ -1172,10 +1108,12 @@ TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) { |
parent_support().SubmitCompositorFrame( |
parent_id1.local_surface_id(), |
- MakeCompositorFrame({child_id}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id}, empty_surface_ids(), |
+ TransferableResourceArray())); |
display_support().SubmitCompositorFrame( |
display_id.local_surface_id(), |
- MakeCompositorFrame({parent_id1}, empty_surface_ids())); |
+ MakeCompositorFrame({parent_id1}, empty_surface_ids(), |
+ TransferableResourceArray())); |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
@@ -1197,10 +1135,12 @@ TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) { |
parent_support().SubmitCompositorFrame( |
parent_id2.local_surface_id(), |
- MakeCompositorFrame({child_id}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id}, empty_surface_ids(), |
+ TransferableResourceArray())); |
display_support().SubmitCompositorFrame( |
display_id.local_surface_id(), |
- MakeCompositorFrame({parent_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({parent_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// The display surface now has two CompositorFrames. One that is pending, |
// indirectly blocked on child_id and one that is active, also indirectly |
@@ -1222,7 +1162,7 @@ TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) { |
// deadline activation. SurfaceDependencyTracker is also tracking a surface |
// from that subtree due to an unresolved dependency. This test verifies that |
// this dependency resolution does not crash. |
-TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) { |
+TEST_F(SurfaceSynchronizationTest, GarbageCollectionOnDeadline) { |
const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
@@ -1231,10 +1171,13 @@ TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) { |
// |parent_id1| is blocked on |child_id|. |
parent_support().SubmitCompositorFrame( |
parent_id1.local_surface_id(), |
- MakeCompositorFrame({child_id}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id}, empty_surface_ids(), |
+ TransferableResourceArray())); |
- display_support().SubmitCompositorFrame(display_id.local_surface_id(), |
- MakeCompositorFrame({parent_id1})); |
+ display_support().SubmitCompositorFrame( |
+ display_id.local_surface_id(), |
+ MakeCompositorFrame({parent_id1}, {parent_id1}, |
+ TransferableResourceArray())); |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
EXPECT_TRUE(display_surface()->HasPendingFrame()); |
@@ -1258,12 +1201,14 @@ TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) { |
// a candidate for garbage collection. |
display_support().SubmitCompositorFrame( |
display_id.local_surface_id(), |
- MakeCompositorFrame({parent_id2}, empty_surface_ids())); |
+ MakeCompositorFrame({parent_id2}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// Now |parent_id1| is only kept alive by the active |display_id| frame. |
parent_support().SubmitCompositorFrame( |
parent_id2.local_surface_id(), |
- MakeCompositorFrame({child_id}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id}, empty_surface_ids(), |
+ TransferableResourceArray())); |
// SurfaceDependencyTracker should now be tracking |display_id|, |parent_id1| |
// and |parent_id2|. By activating the pending |display_id| frame by deadline, |
@@ -1280,7 +1225,7 @@ TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) { |
// This test verifies that a CompositorFrame will only blocked on embedded |
// surfaces but not on other retained surface IDs in the CompositorFrame. |
-TEST_F(CompositorFrameSinkSupportTest, OnlyBlockOnEmbeddedSurfaces) { |
+TEST_F(SurfaceSynchronizationTest, OnlyBlockOnEmbeddedSurfaces) { |
const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
@@ -1292,7 +1237,8 @@ TEST_F(CompositorFrameSinkSupportTest, OnlyBlockOnEmbeddedSurfaces) { |
display_support().SubmitCompositorFrame( |
display_id.local_surface_id(), |
- MakeCompositorFrame({parent_id1}, {parent_id2})); |
+ MakeCompositorFrame({parent_id1}, {parent_id2}, |
+ TransferableResourceArray())); |
EXPECT_TRUE(display_surface()->HasPendingFrame()); |
EXPECT_FALSE(display_surface()->HasActiveFrame()); |
@@ -1319,14 +1265,15 @@ TEST_F(CompositorFrameSinkSupportTest, OnlyBlockOnEmbeddedSurfaces) { |
// This test verifies that a late arriving CompositorFrame activates immediately |
// and does not trigger a new deadline. |
-TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) { |
+TEST_F(SurfaceSynchronizationTest, LateArrivingDependency) { |
const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
display_support().SubmitCompositorFrame( |
display_id.local_surface_id(), |
- MakeCompositorFrame({parent_id1}, empty_surface_ids())); |
+ MakeCompositorFrame({parent_id1}, empty_surface_ids(), |
+ TransferableResourceArray())); |
EXPECT_TRUE(display_surface()->HasPendingFrame()); |
EXPECT_FALSE(display_surface()->HasActiveFrame()); |
@@ -1349,7 +1296,8 @@ TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) { |
// scheduling a deadline and without waiting for dependencies to resolve. |
parent_support().SubmitCompositorFrame( |
parent_id1.local_surface_id(), |
- MakeCompositorFrame({child_id1}, empty_surface_ids())); |
+ MakeCompositorFrame({child_id1}, empty_surface_ids(), |
+ TransferableResourceArray())); |
EXPECT_FALSE(dependency_tracker().has_deadline()); |
EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
@@ -1358,7 +1306,7 @@ TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) { |
// This test verifies that CompositorFrames submitted to a surface referenced |
// by a parent CompositorFrame as a fallback will be rejected and ACK'ed |
// immediately. |
-TEST_F(CompositorFrameSinkSupportTest, FallbackSurfacesClosed) { |
+TEST_F(SurfaceSynchronizationTest, FallbackSurfacesClosed) { |
const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
// This is the fallback child surface that the parent holds a reference to. |
const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
@@ -1369,9 +1317,11 @@ TEST_F(CompositorFrameSinkSupportTest, FallbackSurfacesClosed) { |
// DidReceiveCompositorFrameAck should call on immediate activation. |
// However, resources will not be returned because this frame is a candidate |
// for display. |
- TransferableResource resource = |
- MakeResource(1337 /* id */, ALPHA_8 /* format */, 1234 /* filter */, |
- gfx::Size(1234, 5678)); |
+ TransferableResource resource; |
+ resource.id = 1337; |
+ resource.format = ALPHA_8; |
+ resource.filter = 1234; |
+ resource.size = gfx::Size(1234, 5678); |
ReturnedResourceArray returned_resources; |
TransferableResource::ReturnResources({resource}, &returned_resources); |
@@ -1379,7 +1329,8 @@ TEST_F(CompositorFrameSinkSupportTest, FallbackSurfacesClosed) { |
DidReceiveCompositorFrameAck(Eq(ReturnedResourceArray()))); |
child_support1().SubmitCompositorFrame( |
child_id1.local_surface_id(), |
- MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); |
+ MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
+ {resource})); |
testing::Mock::VerifyAndClearExpectations(&support_client_); |
// The parent is blocked on |child_id2| and references |child_id1|. The |
@@ -1387,23 +1338,27 @@ TEST_F(CompositorFrameSinkSupportTest, FallbackSurfacesClosed) { |
// while the parent CompositorFrame is blocked. |
parent_support().SubmitCompositorFrame( |
parent_id1.local_surface_id(), |
- MakeCompositorFrame({child_id2}, {child_id1})); |
+ MakeCompositorFrame({child_id2}, {child_id1}, |
+ TransferableResourceArray())); |
EXPECT_TRUE(dependency_tracker().has_deadline()); |
EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
// Resources will be returned immediately because |child_id1|'s surface is |
// closed. |
- TransferableResource resource2 = |
- MakeResource(1246 /* id */, ALPHA_8 /* format */, 1357 /* filter */, |
- gfx::Size(8765, 4321)); |
+ TransferableResource resource2; |
+ resource2.id = 1246; |
+ resource2.format = ALPHA_8; |
+ resource2.filter = 1357; |
+ resource2.size = gfx::Size(8765, 4321); |
ReturnedResourceArray returned_resources2; |
TransferableResource::ReturnResources({resource2}, &returned_resources2); |
EXPECT_CALL(support_client_, |
DidReceiveCompositorFrameAck(Eq(returned_resources2))); |
child_support1().SubmitCompositorFrame( |
child_id1.local_surface_id(), |
- MakeCompositorFrameWithResources(empty_surface_ids(), {resource2})); |
+ MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
+ {resource2})); |
testing::Mock::VerifyAndClearExpectations(&support_client_); |
// Advance BeginFrames to trigger a deadline. This activates the |
@@ -1425,8 +1380,10 @@ TEST_F(CompositorFrameSinkSupportTest, FallbackSurfacesClosed) { |
DidReceiveCompositorFrameAck(Eq(returned_resources2))); |
child_support1().SubmitCompositorFrame( |
child_id1.local_surface_id(), |
- MakeCompositorFrameWithResources(empty_surface_ids(), {resource2})); |
+ MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
+ {resource2})); |
testing::Mock::VerifyAndClearExpectations(&support_client_); |
} |
+} // namespace test |
} // namespace cc |