OLD | NEW |
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/test/null_task_runner.h" | 9 #include "base/test/null_task_runner.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
11 #include "cc/output/copy_output_result.h" | 11 #include "cc/output/copy_output_result.h" |
12 #include "cc/output/delegated_frame_data.h" | 12 #include "cc/output/delegated_frame_data.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/display_client.h" | 17 #include "cc/surfaces/display_client.h" |
18 #include "cc/surfaces/display_scheduler.h" | 18 #include "cc/surfaces/display_scheduler.h" |
19 #include "cc/surfaces/frame_sink_id.h" | 19 #include "cc/surfaces/frame_sink_id.h" |
20 #include "cc/surfaces/surface.h" | 20 #include "cc/surfaces/surface.h" |
21 #include "cc/surfaces/surface_factory.h" | 21 #include "cc/surfaces/surface_factory.h" |
22 #include "cc/surfaces/surface_factory_client.h" | 22 #include "cc/surfaces/surface_factory_client.h" |
23 #include "cc/surfaces/surface_id_allocator.h" | 23 #include "cc/surfaces/surface_id_allocator.h" |
24 #include "cc/surfaces/surface_manager.h" | 24 #include "cc/surfaces/surface_manager.h" |
25 #include "cc/test/fake_output_surface.h" | 25 #include "cc/test/fake_output_surface.h" |
26 #include "cc/test/scheduler_test_common.h" | 26 #include "cc/test/scheduler_test_common.h" |
27 #include "cc/test/test_shared_bitmap_manager.h" | 27 #include "cc/test/test_shared_bitmap_manager.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 { |
34 namespace { | 35 namespace { |
35 | 36 |
36 static constexpr FrameSinkId kArbitraryFrameSinkId(3, 3); | 37 static constexpr FrameSinkId kArbitraryFrameSinkId(3, 3); |
37 | 38 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 manager_.InvalidateFrameSinkId(kArbitraryFrameSinkId); | 109 manager_.InvalidateFrameSinkId(kArbitraryFrameSinkId); |
109 } | 110 } |
110 | 111 |
111 void SetUpDisplay(const RendererSettings& settings, | 112 void SetUpDisplay(const RendererSettings& settings, |
112 std::unique_ptr<TestWebGraphicsContext3D> context) { | 113 std::unique_ptr<TestWebGraphicsContext3D> context) { |
113 std::unique_ptr<BeginFrameSource> begin_frame_source( | 114 std::unique_ptr<BeginFrameSource> begin_frame_source( |
114 new StubBeginFrameSource); | 115 new StubBeginFrameSource); |
115 | 116 |
116 std::unique_ptr<FakeOutputSurface> output_surface; | 117 std::unique_ptr<FakeOutputSurface> output_surface; |
117 if (context) { | 118 if (context) { |
118 output_surface = FakeOutputSurface::Create3d(std::move(context)); | 119 auto provider = TestContextProvider::Create(std::move(context)); |
| 120 provider->BindToCurrentThread(); |
| 121 output_surface = FakeOutputSurface::Create3d(std::move(provider)); |
119 } else { | 122 } else { |
120 std::unique_ptr<TestSoftwareOutputDevice> device( | 123 std::unique_ptr<TestSoftwareOutputDevice> device( |
121 new TestSoftwareOutputDevice); | 124 new TestSoftwareOutputDevice); |
122 software_output_device_ = device.get(); | 125 software_output_device_ = device.get(); |
123 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); | 126 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); |
124 } | 127 } |
125 output_surface_ = output_surface.get(); | 128 output_surface_ = output_surface.get(); |
126 | 129 |
127 std::unique_ptr<TestDisplayScheduler> scheduler( | 130 std::unique_ptr<TestDisplayScheduler> scheduler( |
128 new TestDisplayScheduler(begin_frame_source.get(), task_runner_.get())); | 131 new TestDisplayScheduler(begin_frame_source.get(), task_runner_.get())); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 495 |
493 testing::Mock::VerifyAndClearExpectations(context_ptr); | 496 testing::Mock::VerifyAndClearExpectations(context_ptr); |
494 | 497 |
495 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 498 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
496 display_->Resize(gfx::Size(250, 250)); | 499 display_->Resize(gfx::Size(250, 250)); |
497 testing::Mock::VerifyAndClearExpectations(context_ptr); | 500 testing::Mock::VerifyAndClearExpectations(context_ptr); |
498 | 501 |
499 factory_.Destroy(local_frame_id); | 502 factory_.Destroy(local_frame_id); |
500 } | 503 } |
501 | 504 |
| 505 class CountLossDisplayClient : public StubDisplayClient { |
| 506 public: |
| 507 CountLossDisplayClient() = default; |
| 508 |
| 509 void DisplayOutputSurfaceLost() override { ++loss_count_; } |
| 510 |
| 511 int loss_count() const { return loss_count_; } |
| 512 |
| 513 private: |
| 514 int loss_count_ = 0; |
| 515 }; |
| 516 |
| 517 TEST_F(DisplayTest, ContextLossInformsClient) { |
| 518 SetUpDisplay(RendererSettings(), TestWebGraphicsContext3D::Create()); |
| 519 |
| 520 CountLossDisplayClient client; |
| 521 display_->Initialize(&client, &manager_, kArbitraryFrameSinkId); |
| 522 |
| 523 // Verify DidLoseOutputSurface callback is hooked up correctly. |
| 524 EXPECT_EQ(0, client.loss_count()); |
| 525 output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM( |
| 526 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 527 output_surface_->context_provider()->ContextGL()->Flush(); |
| 528 EXPECT_EQ(1, client.loss_count()); |
| 529 } |
| 530 |
502 } // namespace | 531 } // namespace |
503 } // namespace cc | 532 } // namespace cc |
OLD | NEW |