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

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

Issue 2835393003: Reject frames with invalid BeginFrameAck in CompositorFrameSinkSupport (Closed)
Patch Set: Fixed header Created 3 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/display.h" 5 #include "cc/surfaces/display.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/test/null_task_runner.h" 10 #include "base/test/null_task_runner.h"
11 #include "cc/output/compositor_frame.h" 11 #include "cc/output/compositor_frame.h"
12 #include "cc/output/copy_output_result.h" 12 #include "cc/output/copy_output_result.h"
13 #include "cc/output/texture_mailbox_deleter.h" 13 #include "cc/output/texture_mailbox_deleter.h"
14 #include "cc/quads/render_pass.h" 14 #include "cc/quads/render_pass.h"
15 #include "cc/resources/shared_bitmap_manager.h" 15 #include "cc/resources/shared_bitmap_manager.h"
16 #include "cc/scheduler/begin_frame_source.h" 16 #include "cc/scheduler/begin_frame_source.h"
17 #include "cc/surfaces/compositor_frame_sink_support.h" 17 #include "cc/surfaces/compositor_frame_sink_support.h"
18 #include "cc/surfaces/display_client.h" 18 #include "cc/surfaces/display_client.h"
19 #include "cc/surfaces/display_scheduler.h" 19 #include "cc/surfaces/display_scheduler.h"
20 #include "cc/surfaces/frame_sink_id.h" 20 #include "cc/surfaces/frame_sink_id.h"
21 #include "cc/surfaces/local_surface_id_allocator.h" 21 #include "cc/surfaces/local_surface_id_allocator.h"
22 #include "cc/surfaces/surface.h" 22 #include "cc/surfaces/surface.h"
23 #include "cc/surfaces/surface_manager.h" 23 #include "cc/surfaces/surface_manager.h"
24 #include "cc/test/compositor_frame_helpers.h"
24 #include "cc/test/fake_output_surface.h" 25 #include "cc/test/fake_output_surface.h"
25 #include "cc/test/scheduler_test_common.h" 26 #include "cc/test/scheduler_test_common.h"
26 #include "cc/test/test_shared_bitmap_manager.h" 27 #include "cc/test/test_shared_bitmap_manager.h"
27 #include "gpu/GLES2/gl2extchromium.h" 28 #include "gpu/GLES2/gl2extchromium.h"
28 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 31
31 using testing::AnyNumber; 32 using testing::AnyNumber;
32 33
33 namespace cc { 34 namespace cc {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, 119 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */,
119 settings, kArbitraryFrameSinkId, begin_frame_source_.get(), 120 settings, kArbitraryFrameSinkId, begin_frame_source_.get(),
120 std::move(output_surface), std::move(scheduler), 121 std::move(output_surface), std::move(scheduler),
121 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); 122 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get()));
122 display_->SetVisible(true); 123 display_->SetVisible(true);
123 } 124 }
124 125
125 protected: 126 protected:
126 void SubmitCompositorFrame(RenderPassList* pass_list, 127 void SubmitCompositorFrame(RenderPassList* pass_list,
127 const LocalSurfaceId& local_surface_id) { 128 const LocalSurfaceId& local_surface_id) {
128 CompositorFrame frame; 129 CompositorFrame frame = test::MakeCompositorFrame();
129 pass_list->swap(frame.render_pass_list); 130 pass_list->swap(frame.render_pass_list);
130 131
131 support_->SubmitCompositorFrame(local_surface_id, std::move(frame)); 132 support_->SubmitCompositorFrame(local_surface_id, std::move(frame));
132 } 133 }
133 134
134 SurfaceManager manager_; 135 SurfaceManager manager_;
135 std::unique_ptr<CompositorFrameSinkSupport> support_; 136 std::unique_ptr<CompositorFrameSinkSupport> support_;
136 LocalSurfaceIdAllocator id_allocator_; 137 LocalSurfaceIdAllocator id_allocator_;
137 scoped_refptr<base::NullTaskRunner> task_runner_; 138 scoped_refptr<base::NullTaskRunner> task_runner_;
138 TestSharedBitmapManager shared_bitmap_manager_; 139 TestSharedBitmapManager shared_bitmap_manager_;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // saved for next swap. 324 // saved for next swap.
324 { 325 {
325 pass = RenderPass::Create(); 326 pass = RenderPass::Create();
326 pass->output_rect = gfx::Rect(0, 0, 100, 100); 327 pass->output_rect = gfx::Rect(0, 0, 100, 100);
327 pass->damage_rect = gfx::Rect(10, 10, 0, 0); 328 pass->damage_rect = gfx::Rect(10, 10, 0, 0);
328 pass->id = 1; 329 pass->id = 1;
329 330
330 pass_list.push_back(std::move(pass)); 331 pass_list.push_back(std::move(pass));
331 scheduler_->ResetDamageForTest(); 332 scheduler_->ResetDamageForTest();
332 333
333 CompositorFrame frame; 334 CompositorFrame frame = test::MakeCompositorFrame();
334 pass_list.swap(frame.render_pass_list); 335 pass_list.swap(frame.render_pass_list);
335 frame.metadata.latency_info.push_back(ui::LatencyInfo()); 336 frame.metadata.latency_info.push_back(ui::LatencyInfo());
336 337
337 support_->SubmitCompositorFrame(local_surface_id, std::move(frame)); 338 support_->SubmitCompositorFrame(local_surface_id, std::move(frame));
338 EXPECT_TRUE(scheduler_->damaged); 339 EXPECT_TRUE(scheduler_->damaged);
339 EXPECT_FALSE(scheduler_->display_resized_); 340 EXPECT_FALSE(scheduler_->display_resized_);
340 EXPECT_FALSE(scheduler_->has_new_root_surface); 341 EXPECT_FALSE(scheduler_->has_new_root_surface);
341 342
342 scheduler_->swapped = false; 343 scheduler_->swapped = false;
343 display_->DrawAndSwap(); 344 display_->DrawAndSwap();
344 EXPECT_TRUE(scheduler_->swapped); 345 EXPECT_TRUE(scheduler_->swapped);
345 EXPECT_EQ(4u, output_surface_->num_sent_frames()); 346 EXPECT_EQ(4u, output_surface_->num_sent_frames());
346 } 347 }
347 348
348 // Resize should cause a swap if no frame was swapped at the previous size. 349 // Resize should cause a swap if no frame was swapped at the previous size.
349 { 350 {
350 scheduler_->swapped = false; 351 scheduler_->swapped = false;
351 display_->Resize(gfx::Size(200, 200)); 352 display_->Resize(gfx::Size(200, 200));
352 EXPECT_FALSE(scheduler_->swapped); 353 EXPECT_FALSE(scheduler_->swapped);
353 EXPECT_EQ(4u, output_surface_->num_sent_frames()); 354 EXPECT_EQ(4u, output_surface_->num_sent_frames());
354 355
355 pass = RenderPass::Create(); 356 pass = RenderPass::Create();
356 pass->output_rect = gfx::Rect(0, 0, 200, 200); 357 pass->output_rect = gfx::Rect(0, 0, 200, 200);
357 pass->damage_rect = gfx::Rect(10, 10, 10, 10); 358 pass->damage_rect = gfx::Rect(10, 10, 10, 10);
358 pass->id = 1; 359 pass->id = 1;
359 360
360 pass_list.push_back(std::move(pass)); 361 pass_list.push_back(std::move(pass));
361 scheduler_->ResetDamageForTest(); 362 scheduler_->ResetDamageForTest();
362 363
363 CompositorFrame frame; 364 CompositorFrame frame = test::MakeCompositorFrame();
364 pass_list.swap(frame.render_pass_list); 365 pass_list.swap(frame.render_pass_list);
365 366
366 support_->SubmitCompositorFrame(local_surface_id, std::move(frame)); 367 support_->SubmitCompositorFrame(local_surface_id, std::move(frame));
367 EXPECT_TRUE(scheduler_->damaged); 368 EXPECT_TRUE(scheduler_->damaged);
368 EXPECT_FALSE(scheduler_->display_resized_); 369 EXPECT_FALSE(scheduler_->display_resized_);
369 EXPECT_FALSE(scheduler_->has_new_root_surface); 370 EXPECT_FALSE(scheduler_->has_new_root_surface);
370 371
371 scheduler_->swapped = false; 372 scheduler_->swapped = false;
372 display_->Resize(gfx::Size(100, 100)); 373 display_->Resize(gfx::Size(100, 100));
373 EXPECT_TRUE(scheduler_->swapped); 374 EXPECT_TRUE(scheduler_->swapped);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // Verify DidLoseOutputSurface callback is hooked up correctly. 496 // Verify DidLoseOutputSurface callback is hooked up correctly.
496 EXPECT_EQ(0, client.loss_count()); 497 EXPECT_EQ(0, client.loss_count());
497 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( 498 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM(
498 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); 499 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
499 output_surface_->context_provider()->ContextGL()->Flush(); 500 output_surface_->context_provider()->ContextGL()->Flush();
500 EXPECT_EQ(1, client.loss_count()); 501 EXPECT_EQ(1, client.loss_count());
501 } 502 }
502 503
503 } // namespace 504 } // namespace
504 } // namespace cc 505 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698