| 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" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 bool damaged; | 93 bool damaged; |
| 94 bool display_resized_; | 94 bool display_resized_; |
| 95 bool has_new_root_surface; | 95 bool has_new_root_surface; |
| 96 bool swapped; | 96 bool swapped; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 class DisplayTest : public testing::Test { | 99 class DisplayTest : public testing::Test { |
| 100 public: | 100 public: |
| 101 DisplayTest() | 101 DisplayTest() |
| 102 : factory_(&manager_, &surface_factory_client_), | 102 : factory_(kArbitraryFrameSinkId, &manager_, &surface_factory_client_), |
| 103 id_allocator_(kArbitraryFrameSinkId), | 103 id_allocator_(kArbitraryFrameSinkId), |
| 104 task_runner_(new base::NullTaskRunner) { | 104 task_runner_(new base::NullTaskRunner) { |
| 105 manager_.RegisterFrameSinkId(id_allocator_.frame_sink_id()); | 105 manager_.RegisterFrameSinkId(kArbitraryFrameSinkId); |
| 106 } | 106 } |
| 107 | 107 |
| 108 ~DisplayTest() override { | 108 ~DisplayTest() override { |
| 109 manager_.InvalidateFrameSinkId(id_allocator_.frame_sink_id()); | 109 manager_.InvalidateFrameSinkId(kArbitraryFrameSinkId); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void SetUpDisplay(const RendererSettings& settings, | 112 void SetUpDisplay(const RendererSettings& settings, |
| 113 std::unique_ptr<TestWebGraphicsContext3D> context) { | 113 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 114 std::unique_ptr<BeginFrameSource> begin_frame_source( | 114 std::unique_ptr<BeginFrameSource> begin_frame_source( |
| 115 new StubBeginFrameSource); | 115 new StubBeginFrameSource); |
| 116 | 116 |
| 117 std::unique_ptr<FakeOutputSurface> output_surface; | 117 std::unique_ptr<FakeOutputSurface> output_surface; |
| 118 if (context) { | 118 if (context) { |
| 119 output_surface = FakeOutputSurface::Create3d(std::move(context)); | 119 output_surface = FakeOutputSurface::Create3d(std::move(context)); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 // Check that frame is damaged and swapped only under correct conditions. | 177 // Check that frame is damaged and swapped only under correct conditions. |
| 178 TEST_F(DisplayTest, DisplayDamaged) { | 178 TEST_F(DisplayTest, DisplayDamaged) { |
| 179 RendererSettings settings; | 179 RendererSettings settings; |
| 180 settings.partial_swap_enabled = true; | 180 settings.partial_swap_enabled = true; |
| 181 settings.finish_rendering_on_resize = true; | 181 settings.finish_rendering_on_resize = true; |
| 182 SetUpDisplay(settings, nullptr); | 182 SetUpDisplay(settings, nullptr); |
| 183 | 183 |
| 184 StubDisplayClient client; | 184 StubDisplayClient client; |
| 185 display_->Initialize(&client, &manager_, id_allocator_.frame_sink_id()); | 185 display_->Initialize(&client, &manager_, kArbitraryFrameSinkId); |
| 186 | 186 |
| 187 SurfaceId surface_id(id_allocator_.GenerateId()); | 187 SurfaceId surface_id(id_allocator_.GenerateId()); |
| 188 EXPECT_FALSE(scheduler_->damaged); | 188 EXPECT_FALSE(scheduler_->damaged); |
| 189 EXPECT_FALSE(scheduler_->has_new_root_surface); | 189 EXPECT_FALSE(scheduler_->has_new_root_surface); |
| 190 display_->SetSurfaceId(surface_id, 1.f); | 190 display_->SetSurfaceId(surface_id, 1.f); |
| 191 EXPECT_FALSE(scheduler_->damaged); | 191 EXPECT_FALSE(scheduler_->damaged); |
| 192 EXPECT_FALSE(scheduler_->display_resized_); | 192 EXPECT_FALSE(scheduler_->display_resized_); |
| 193 EXPECT_TRUE(scheduler_->has_new_root_surface); | 193 EXPECT_TRUE(scheduler_->has_new_root_surface); |
| 194 | 194 |
| 195 scheduler_->ResetDamageForTest(); | 195 scheduler_->ResetDamageForTest(); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 settings.partial_swap_enabled = true; | 438 settings.partial_swap_enabled = true; |
| 439 settings.finish_rendering_on_resize = true; | 439 settings.finish_rendering_on_resize = true; |
| 440 | 440 |
| 441 std::unique_ptr<MockedContext> context(new MockedContext()); | 441 std::unique_ptr<MockedContext> context(new MockedContext()); |
| 442 MockedContext* context_ptr = context.get(); | 442 MockedContext* context_ptr = context.get(); |
| 443 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); | 443 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()).Times(0); |
| 444 | 444 |
| 445 SetUpDisplay(settings, std::move(context)); | 445 SetUpDisplay(settings, std::move(context)); |
| 446 | 446 |
| 447 StubDisplayClient client; | 447 StubDisplayClient client; |
| 448 display_->Initialize(&client, &manager_, id_allocator_.frame_sink_id()); | 448 display_->Initialize(&client, &manager_, kArbitraryFrameSinkId); |
| 449 | 449 |
| 450 display_->SetSurfaceId(surface_id, 1.f); | 450 display_->SetSurfaceId(surface_id, 1.f); |
| 451 | 451 |
| 452 display_->Resize(gfx::Size(100, 100)); | 452 display_->Resize(gfx::Size(100, 100)); |
| 453 factory_.Create(surface_id); | 453 factory_.Create(surface_id); |
| 454 | 454 |
| 455 { | 455 { |
| 456 RenderPassList pass_list; | 456 RenderPassList pass_list; |
| 457 std::unique_ptr<RenderPass> pass = RenderPass::Create(); | 457 std::unique_ptr<RenderPass> pass = RenderPass::Create(); |
| 458 pass->output_rect = gfx::Rect(0, 0, 100, 100); | 458 pass->output_rect = gfx::Rect(0, 0, 100, 100); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 495 |
| 496 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 496 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
| 497 display_->Resize(gfx::Size(250, 250)); | 497 display_->Resize(gfx::Size(250, 250)); |
| 498 testing::Mock::VerifyAndClearExpectations(context_ptr); | 498 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 499 | 499 |
| 500 factory_.Destroy(surface_id); | 500 factory_.Destroy(surface_id); |
| 501 } | 501 } |
| 502 | 502 |
| 503 } // namespace | 503 } // namespace |
| 504 } // namespace cc | 504 } // namespace cc |
| OLD | NEW |