Commit 932d1d0e authored by Chris Blume's avatar Chris Blume Committed by Commit Bot

viz/service & viz/test to use default LSI

Previously, ParentLocalSurfaceIdAllocator would default to an invalid
LocalSurfaceId. A new LSI had to be explicitly allocated before the
normal behavior could use it.

With ParentLocalSurfaceIdAllocator now default initializing a valid LSI,
the various call sites no longer need to explicitly check for the
uninitialized state.

viz/service & viz/test contain some of those call sites.

BUG=837030

Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Iace37fb0be4c6389fdf2c89dbd4bb77c9696036f
Reviewed-on: https://chromium-review.googlesource.com/1038124
Commit-Queue: Fady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555306}
parent a21ef767
...@@ -378,7 +378,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest { ...@@ -378,7 +378,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
void SetUp() override { void SetUp() override {
SurfaceAggregatorTest::SetUp(); SurfaceAggregatorTest::SetUp();
root_local_surface_id_ = allocator_.GenerateId(); root_local_surface_id_ = allocator_.GetCurrentLocalSurfaceId();
root_surface_ = manager_.surface_manager()->GetSurfaceForId( root_surface_ = manager_.surface_manager()->GetSurfaceForId(
SurfaceId(support_->frame_sink_id(), root_local_surface_id_)); SurfaceId(support_->frame_sink_id(), root_local_surface_id_));
} }
......
...@@ -93,9 +93,7 @@ void DirectLayerTreeFrameSink::SubmitCompositorFrame(CompositorFrame frame) { ...@@ -93,9 +93,7 @@ void DirectLayerTreeFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
DCHECK_LE(BeginFrameArgs::kStartingFrameNumber, DCHECK_LE(BeginFrameArgs::kStartingFrameNumber,
frame.metadata.begin_frame_ack.sequence_number); frame.metadata.begin_frame_ack.sequence_number);
if (!parent_local_surface_id_allocator_.GetCurrentLocalSurfaceId() if (frame.size_in_pixels() != last_swap_frame_size_ ||
.is_valid() ||
frame.size_in_pixels() != last_swap_frame_size_ ||
frame.device_scale_factor() != device_scale_factor_) { frame.device_scale_factor() != device_scale_factor_) {
parent_local_surface_id_allocator_.GenerateId(); parent_local_surface_id_allocator_.GenerateId();
last_swap_frame_size_ = frame.size_in_pixels(); last_swap_frame_size_ = frame.size_in_pixels();
......
...@@ -121,7 +121,6 @@ TEST_F(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { ...@@ -121,7 +121,6 @@ TEST_F(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
// Submit the root frame. // Submit the root frame.
ParentLocalSurfaceIdAllocator root_allocator; ParentLocalSurfaceIdAllocator root_allocator;
root_allocator.GenerateId();
SurfaceId root_surface_id(kRootFrameSink, SurfaceId root_surface_id(kRootFrameSink,
root_allocator.GetCurrentLocalSurfaceId()); root_allocator.GetCurrentLocalSurfaceId());
root_support().SubmitCompositorFrame( root_support().SubmitCompositorFrame(
...@@ -146,7 +145,6 @@ TEST_F(SurfaceHittestTest, Hittest_SingleSurface) { ...@@ -146,7 +145,6 @@ TEST_F(SurfaceHittestTest, Hittest_SingleSurface) {
// Submit the root frame. // Submit the root frame.
ParentLocalSurfaceIdAllocator root_allocator; ParentLocalSurfaceIdAllocator root_allocator;
root_allocator.GenerateId();
SurfaceId root_surface_id(kRootFrameSink, SurfaceId root_surface_id(kRootFrameSink,
root_allocator.GetCurrentLocalSurfaceId()); root_allocator.GetCurrentLocalSurfaceId());
root_support().SubmitCompositorFrame( root_support().SubmitCompositorFrame(
...@@ -167,7 +165,6 @@ TEST_F(SurfaceHittestTest, Hittest_ChildSurface) { ...@@ -167,7 +165,6 @@ TEST_F(SurfaceHittestTest, Hittest_ChildSurface) {
// Add a reference to the child surface on the root surface. // Add a reference to the child surface on the root surface.
ParentLocalSurfaceIdAllocator child_allocator; ParentLocalSurfaceIdAllocator child_allocator;
child_allocator.GenerateId();
SurfaceId child_surface_id(kChildFrameSink, SurfaceId child_surface_id(kChildFrameSink,
child_allocator.GetCurrentLocalSurfaceId()); child_allocator.GetCurrentLocalSurfaceId());
gfx::Rect child_rect(200, 200); gfx::Rect child_rect(200, 200);
...@@ -179,7 +176,6 @@ TEST_F(SurfaceHittestTest, Hittest_ChildSurface) { ...@@ -179,7 +176,6 @@ TEST_F(SurfaceHittestTest, Hittest_ChildSurface) {
// Submit the root frame. // Submit the root frame.
ParentLocalSurfaceIdAllocator root_allocator; ParentLocalSurfaceIdAllocator root_allocator;
root_allocator.GenerateId();
SurfaceId root_surface_id(kRootFrameSink, SurfaceId root_surface_id(kRootFrameSink,
root_allocator.GetCurrentLocalSurfaceId()); root_allocator.GetCurrentLocalSurfaceId());
root_support().SubmitCompositorFrame( root_support().SubmitCompositorFrame(
...@@ -267,7 +263,6 @@ TEST_F(SurfaceHittestTest, Hittest_OccludedChildSurface) { ...@@ -267,7 +263,6 @@ TEST_F(SurfaceHittestTest, Hittest_OccludedChildSurface) {
// Add a reference to the child surface on the root surface. // Add a reference to the child surface on the root surface.
ParentLocalSurfaceIdAllocator child_allocator; ParentLocalSurfaceIdAllocator child_allocator;
child_allocator.GenerateId();
SurfaceId child_surface_id(kChildFrameSink, SurfaceId child_surface_id(kChildFrameSink,
child_allocator.GetCurrentLocalSurfaceId()); child_allocator.GetCurrentLocalSurfaceId());
gfx::Rect child_rect(200, 200); gfx::Rect child_rect(200, 200);
...@@ -279,7 +274,6 @@ TEST_F(SurfaceHittestTest, Hittest_OccludedChildSurface) { ...@@ -279,7 +274,6 @@ TEST_F(SurfaceHittestTest, Hittest_OccludedChildSurface) {
// Submit the root frame. // Submit the root frame.
ParentLocalSurfaceIdAllocator root_allocator; ParentLocalSurfaceIdAllocator root_allocator;
root_allocator.GenerateId();
SurfaceId root_surface_id(kRootFrameSink, SurfaceId root_surface_id(kRootFrameSink,
root_allocator.GetCurrentLocalSurfaceId()); root_allocator.GetCurrentLocalSurfaceId());
root_support().SubmitCompositorFrame( root_support().SubmitCompositorFrame(
...@@ -332,7 +326,8 @@ TEST_F(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { ...@@ -332,7 +326,8 @@ TEST_F(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
// Add a reference to the child surface on the root surface. // Add a reference to the child surface on the root surface.
ParentLocalSurfaceIdAllocator child_allocator; ParentLocalSurfaceIdAllocator child_allocator;
LocalSurfaceId child_local_surface_id = child_allocator.GenerateId(); LocalSurfaceId child_local_surface_id =
child_allocator.GetCurrentLocalSurfaceId();
SurfaceId child_surface_id(kChildFrameSink, child_local_surface_id); SurfaceId child_surface_id(kChildFrameSink, child_local_surface_id);
gfx::Rect child_rect(200, 200); gfx::Rect child_rect(200, 200);
CreateSurfaceDrawQuad( CreateSurfaceDrawQuad(
...@@ -343,7 +338,6 @@ TEST_F(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { ...@@ -343,7 +338,6 @@ TEST_F(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
// Submit the root frame. // Submit the root frame.
ParentLocalSurfaceIdAllocator root_allocator; ParentLocalSurfaceIdAllocator root_allocator;
root_allocator.GenerateId();
SurfaceId root_surface_id(kRootFrameSink, SurfaceId root_surface_id(kRootFrameSink,
root_allocator.GetCurrentLocalSurfaceId()); root_allocator.GetCurrentLocalSurfaceId());
root_support().SubmitCompositorFrame( root_support().SubmitCompositorFrame(
...@@ -416,7 +410,6 @@ TEST_F(SurfaceHittestTest, Hittest_RenderPassDrawQuad) { ...@@ -416,7 +410,6 @@ TEST_F(SurfaceHittestTest, Hittest_RenderPassDrawQuad) {
// Submit the root frame. // Submit the root frame.
ParentLocalSurfaceIdAllocator root_allocator; ParentLocalSurfaceIdAllocator root_allocator;
root_allocator.GenerateId();
SurfaceId root_surface_id(kRootFrameSink, SurfaceId root_surface_id(kRootFrameSink,
root_allocator.GetCurrentLocalSurfaceId()); root_allocator.GetCurrentLocalSurfaceId());
root_support().SubmitCompositorFrame( root_support().SubmitCompositorFrame(
...@@ -451,7 +444,6 @@ TEST_F(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { ...@@ -451,7 +444,6 @@ TEST_F(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
// Add a reference to the child surface on the root surface. // Add a reference to the child surface on the root surface.
ParentLocalSurfaceIdAllocator child_allocator; ParentLocalSurfaceIdAllocator child_allocator;
child_allocator.GenerateId();
SurfaceId child_surface_id(kChildFrameSink, SurfaceId child_surface_id(kChildFrameSink,
child_allocator.GetCurrentLocalSurfaceId()); child_allocator.GetCurrentLocalSurfaceId());
gfx::Rect child_rect(200, 200); gfx::Rect child_rect(200, 200);
...@@ -463,7 +455,6 @@ TEST_F(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { ...@@ -463,7 +455,6 @@ TEST_F(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
// Submit the root frame. // Submit the root frame.
ParentLocalSurfaceIdAllocator root_allocator; ParentLocalSurfaceIdAllocator root_allocator;
root_allocator.GenerateId();
SurfaceId root_surface_id(kRootFrameSink, SurfaceId root_surface_id(kRootFrameSink,
root_allocator.GetCurrentLocalSurfaceId()); root_allocator.GetCurrentLocalSurfaceId());
root_support().SubmitCompositorFrame( root_support().SubmitCompositorFrame(
......
...@@ -163,7 +163,7 @@ void TestLayerTreeFrameSink::SubmitCompositorFrame(CompositorFrame frame) { ...@@ -163,7 +163,7 @@ void TestLayerTreeFrameSink::SubmitCompositorFrame(CompositorFrame frame) {
LocalSurfaceId local_surface_id = LocalSurfaceId local_surface_id =
parent_local_surface_id_allocator_->GetCurrentLocalSurfaceId(); parent_local_surface_id_allocator_->GetCurrentLocalSurfaceId();
if (!local_surface_id.is_valid() || frame_size != display_size_ || if (frame_size != display_size_ ||
device_scale_factor != device_scale_factor_) { device_scale_factor != device_scale_factor_) {
local_surface_id = parent_local_surface_id_allocator_->GenerateId(); local_surface_id = parent_local_surface_id_allocator_->GenerateId();
display_->SetLocalSurfaceId(local_surface_id, device_scale_factor); display_->SetLocalSurfaceId(local_surface_id, device_scale_factor);
......
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