| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 task_runner_(new base::NullTaskRunner) { | 101 task_runner_(new base::NullTaskRunner) { |
| 102 manager_.RegisterSurfaceClientId(id_allocator_.client_id()); | 102 manager_.RegisterSurfaceClientId(id_allocator_.client_id()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 ~DisplayTest() override { | 105 ~DisplayTest() override { |
| 106 manager_.InvalidateSurfaceClientId(id_allocator_.client_id()); | 106 manager_.InvalidateSurfaceClientId(id_allocator_.client_id()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void SetUpDisplay(const RendererSettings& settings, | 109 void SetUpDisplay(const RendererSettings& settings, |
| 110 std::unique_ptr<TestWebGraphicsContext3D> context) { | 110 std::unique_ptr<TestWebGraphicsContext3D> context) { |
| 111 std::unique_ptr<BeginFrameSource> begin_frame_source( |
| 112 new StubBeginFrameSource); |
| 113 |
| 111 std::unique_ptr<FakeOutputSurface> output_surface; | 114 std::unique_ptr<FakeOutputSurface> output_surface; |
| 112 if (context) { | 115 if (context) { |
| 113 output_surface = FakeOutputSurface::Create3d(std::move(context)); | 116 output_surface = FakeOutputSurface::Create3d(std::move(context)); |
| 114 } else { | 117 } else { |
| 115 std::unique_ptr<TestSoftwareOutputDevice> device( | 118 std::unique_ptr<TestSoftwareOutputDevice> device( |
| 116 new TestSoftwareOutputDevice); | 119 new TestSoftwareOutputDevice); |
| 117 software_output_device_ = device.get(); | 120 software_output_device_ = device.get(); |
| 118 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); | 121 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); |
| 119 } | 122 } |
| 120 output_surface_ = output_surface.get(); | 123 output_surface_ = output_surface.get(); |
| 121 | 124 |
| 122 std::unique_ptr<TestDisplayScheduler> scheduler( | 125 std::unique_ptr<TestDisplayScheduler> scheduler( |
| 123 new TestDisplayScheduler(&begin_frame_source_, task_runner_.get())); | 126 new TestDisplayScheduler(begin_frame_source.get(), task_runner_.get())); |
| 124 scheduler_ = scheduler.get(); | 127 scheduler_ = scheduler.get(); |
| 125 | 128 |
| 126 display_ = base::MakeUnique<Display>( | 129 display_ = base::MakeUnique<Display>( |
| 127 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, | 130 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, |
| 128 settings, &begin_frame_source_, std::move(output_surface), | 131 settings, std::move(begin_frame_source), std::move(output_surface), |
| 129 std::move(scheduler), | 132 std::move(scheduler), |
| 130 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); | 133 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); |
| 131 display_->SetVisible(true); | 134 display_->SetVisible(true); |
| 132 } | 135 } |
| 133 | 136 |
| 134 protected: | 137 protected: |
| 135 void SubmitCompositorFrame(RenderPassList* pass_list, | 138 void SubmitCompositorFrame(RenderPassList* pass_list, |
| 136 const SurfaceId& surface_id) { | 139 const SurfaceId& surface_id) { |
| 137 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 140 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
| 138 pass_list->swap(frame_data->render_pass_list); | 141 pass_list->swap(frame_data->render_pass_list); |
| 139 | 142 |
| 140 CompositorFrame frame; | 143 CompositorFrame frame; |
| 141 frame.delegated_frame_data = std::move(frame_data); | 144 frame.delegated_frame_data = std::move(frame_data); |
| 142 | 145 |
| 143 factory_.SubmitCompositorFrame(surface_id, std::move(frame), | 146 factory_.SubmitCompositorFrame(surface_id, std::move(frame), |
| 144 SurfaceFactory::DrawCallback()); | 147 SurfaceFactory::DrawCallback()); |
| 145 } | 148 } |
| 146 | 149 |
| 147 static constexpr int kArbitraryClientId = 3; | 150 static constexpr int kArbitraryClientId = 3; |
| 148 | 151 |
| 149 SurfaceManager manager_; | 152 SurfaceManager manager_; |
| 150 FakeSurfaceFactoryClient surface_factory_client_; | 153 FakeSurfaceFactoryClient surface_factory_client_; |
| 151 SurfaceFactory factory_; | 154 SurfaceFactory factory_; |
| 152 SurfaceIdAllocator id_allocator_; | 155 SurfaceIdAllocator id_allocator_; |
| 153 StubBeginFrameSource begin_frame_source_; | |
| 154 scoped_refptr<base::NullTaskRunner> task_runner_; | 156 scoped_refptr<base::NullTaskRunner> task_runner_; |
| 155 TestSharedBitmapManager shared_bitmap_manager_; | 157 TestSharedBitmapManager shared_bitmap_manager_; |
| 156 std::unique_ptr<Display> display_; | 158 std::unique_ptr<Display> display_; |
| 157 TestSoftwareOutputDevice* software_output_device_ = nullptr; | 159 TestSoftwareOutputDevice* software_output_device_ = nullptr; |
| 158 FakeOutputSurface* output_surface_ = nullptr; | 160 FakeOutputSurface* output_surface_ = nullptr; |
| 159 TestDisplayScheduler* scheduler_ = nullptr; | 161 TestDisplayScheduler* scheduler_ = nullptr; |
| 160 }; | 162 }; |
| 161 | 163 |
| 162 class StubDisplayClient : public DisplayClient { | 164 class StubDisplayClient : public DisplayClient { |
| 163 public: | 165 public: |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 495 |
| 494 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 496 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
| 495 display_->Resize(gfx::Size(250, 250)); | 497 display_->Resize(gfx::Size(250, 250)); |
| 496 testing::Mock::VerifyAndClearExpectations(context_ptr); | 498 testing::Mock::VerifyAndClearExpectations(context_ptr); |
| 497 | 499 |
| 498 factory_.Destroy(surface_id); | 500 factory_.Destroy(surface_id); |
| 499 } | 501 } |
| 500 | 502 |
| 501 } // namespace | 503 } // namespace |
| 502 } // namespace cc | 504 } // namespace cc |
| OLD | NEW |