Commit eed11942 authored by Fady Samuel's avatar Fady Samuel Committed by Commit Bot

Surface synchronization: Accept update from parent if embed token changed

The ChildLocalSurfaceIdAllocator should accept updates from the parent if
the embed token changed. This can happen if an iframe performs a cross-process
navigation.

Bug: 672962
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I1f78a39d787bc7cf43b13e2092f4b5974eace954
Reviewed-on: https://chromium-review.googlesource.com/1096104Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Commit-Queue: Fady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566436}
parent 83cfe106
...@@ -17,8 +17,10 @@ ChildLocalSurfaceIdAllocator::ChildLocalSurfaceIdAllocator() ...@@ -17,8 +17,10 @@ ChildLocalSurfaceIdAllocator::ChildLocalSurfaceIdAllocator()
bool ChildLocalSurfaceIdAllocator::UpdateFromParent( bool ChildLocalSurfaceIdAllocator::UpdateFromParent(
const LocalSurfaceId& parent_allocated_local_surface_id) { const LocalSurfaceId& parent_allocated_local_surface_id) {
if (parent_allocated_local_surface_id.parent_sequence_number() > if ((parent_allocated_local_surface_id.parent_sequence_number() >
current_local_surface_id_.parent_sequence_number()) { current_local_surface_id_.parent_sequence_number()) ||
parent_allocated_local_surface_id.embed_token() !=
current_local_surface_id_.embed_token()) {
current_local_surface_id_.parent_sequence_number_ = current_local_surface_id_.parent_sequence_number_ =
parent_allocated_local_surface_id.parent_sequence_number_; parent_allocated_local_surface_id.parent_sequence_number_;
current_local_surface_id_.embed_token_ = current_local_surface_id_.embed_token_ =
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "components/viz/common/surfaces/child_local_surface_id_allocator.h" #include "components/viz/common/surfaces/child_local_surface_id_allocator.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
// ChildLocalSurfaceIdAllocator has 1 accessor which does not alter state: // ChildLocalSurfaceIdAllocator has 1 accessor which does not alter state:
...@@ -105,6 +106,26 @@ TEST(ChildLocalSurfaceIdAllocatorTest, ...@@ -105,6 +106,26 @@ TEST(ChildLocalSurfaceIdAllocatorTest,
parent_allocated_local_surface_id.embed_token()); parent_allocated_local_surface_id.embed_token());
} }
// UpdateFromParent() on a child allocator should accept the parent's
// LocalSurfaceId if only the embed_token changed.
TEST(ChildLocalSurfaceIdAllocatorTest, UpdateFromParentEmbedTokenChanged) {
ParentLocalSurfaceIdAllocator parent_allocator;
ParentLocalSurfaceIdAllocator parent_allocator2;
ChildLocalSurfaceIdAllocator child_allocator;
EXPECT_TRUE(parent_allocator.GenerateId().is_valid());
EXPECT_TRUE(child_allocator.UpdateFromParent(
parent_allocator.GetCurrentLocalSurfaceId()));
EXPECT_LE(
parent_allocator2.GetCurrentLocalSurfaceId().parent_sequence_number(),
parent_allocator.GetCurrentLocalSurfaceId().parent_sequence_number());
EXPECT_NE(parent_allocator2.GetCurrentLocalSurfaceId().embed_token(),
parent_allocator.GetCurrentLocalSurfaceId().embed_token());
EXPECT_TRUE(child_allocator.UpdateFromParent(
parent_allocator2.GetCurrentLocalSurfaceId()));
}
// GenerateId() on a child allocator should monotonically increment the child // GenerateId() on a child allocator should monotonically increment the child
// sequence number. // sequence number.
TEST(ChildLocalSurfaceIdAllocatorTest, TEST(ChildLocalSurfaceIdAllocatorTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment