| 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 "base/memory/ptr_util.h" |
| 5 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 6 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 7 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "cc/scheduler/begin_frame_source.h" |
| 8 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.h" |
| 9 #include "cc/test/test_context_provider.h" | 11 #include "cc/test/test_context_provider.h" |
| 10 #include "cc/test/test_web_graphics_context_3d.h" | 12 #include "cc/test/test_web_graphics_context_3d.h" |
| 11 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" | 13 #include "components/display_compositor/compositor_overlay_candidate_validator.h
" |
| 12 #include "content/browser/compositor/browser_compositor_output_surface.h" | 14 #include "content/browser/compositor/browser_compositor_output_surface.h" |
| 13 #include "content/browser/compositor/reflector_impl.h" | 15 #include "content/browser/compositor/reflector_impl.h" |
| 14 #include "content/browser/compositor/reflector_texture.h" | 16 #include "content/browser/compositor/reflector_texture.h" |
| 15 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 17 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/compositor/compositor.h" | 19 #include "ui/compositor/compositor.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 new TestOverlayCandidatesOzone()))); | 69 new TestOverlayCandidatesOzone()))); |
| 68 #else | 70 #else |
| 69 return nullptr; | 71 return nullptr; |
| 70 #endif // defined(USE_OZONE) | 72 #endif // defined(USE_OZONE) |
| 71 } | 73 } |
| 72 | 74 |
| 73 class TestOutputSurface : public BrowserCompositorOutputSurface { | 75 class TestOutputSurface : public BrowserCompositorOutputSurface { |
| 74 public: | 76 public: |
| 75 TestOutputSurface(scoped_refptr<cc::ContextProvider> context_provider, | 77 TestOutputSurface(scoped_refptr<cc::ContextProvider> context_provider, |
| 76 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, | 78 scoped_refptr<ui::CompositorVSyncManager> vsync_manager, |
| 77 base::SingleThreadTaskRunner* task_runner) | 79 cc::SyntheticBeginFrameSource* begin_frame_source) |
| 78 : BrowserCompositorOutputSurface(std::move(context_provider), | 80 : BrowserCompositorOutputSurface(std::move(context_provider), |
| 79 std::move(vsync_manager), | 81 std::move(vsync_manager), |
| 80 task_runner, | 82 begin_frame_source, |
| 81 CreateTestValidatorOzone()) { | 83 CreateTestValidatorOzone()) { |
| 82 surface_size_ = gfx::Size(256, 256); | 84 surface_size_ = gfx::Size(256, 256); |
| 83 device_scale_factor_ = 1.f; | 85 device_scale_factor_ = 1.f; |
| 84 } | 86 } |
| 85 | 87 |
| 86 void SetFlip(bool flip) { capabilities_.flipped_output_surface = flip; } | 88 void SetFlip(bool flip) { capabilities_.flipped_output_surface = flip; } |
| 87 | 89 |
| 88 void SwapBuffers(cc::CompositorFrame* frame) override {} | 90 void SwapBuffers(cc::CompositorFrame* frame) override {} |
| 89 | 91 |
| 90 void OnReflectorChanged() override { | 92 void OnReflectorChanged() override { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 120 void SetUp() override { | 122 void SetUp() override { |
| 121 bool enable_pixel_output = false; | 123 bool enable_pixel_output = false; |
| 122 ui::ContextFactory* context_factory = | 124 ui::ContextFactory* context_factory = |
| 123 ui::InitializeContextFactoryForTests(enable_pixel_output); | 125 ui::InitializeContextFactoryForTests(enable_pixel_output); |
| 124 ImageTransportFactory::InitializeForUnitTests( | 126 ImageTransportFactory::InitializeForUnitTests( |
| 125 std::unique_ptr<ImageTransportFactory>( | 127 std::unique_ptr<ImageTransportFactory>( |
| 126 new NoTransportImageTransportFactory)); | 128 new NoTransportImageTransportFactory)); |
| 127 message_loop_.reset(new base::MessageLoop()); | 129 message_loop_.reset(new base::MessageLoop()); |
| 128 task_runner_ = message_loop_->task_runner(); | 130 task_runner_ = message_loop_->task_runner(); |
| 129 compositor_task_runner_ = new FakeTaskRunner(); | 131 compositor_task_runner_ = new FakeTaskRunner(); |
| 132 begin_frame_source_.reset(new cc::SyntheticBeginFrameSource( |
| 133 compositor_task_runner_.get(), cc::BeginFrameArgs::DefaultInterval())); |
| 130 compositor_.reset( | 134 compositor_.reset( |
| 131 new ui::Compositor(context_factory, compositor_task_runner_.get())); | 135 new ui::Compositor(context_factory, compositor_task_runner_.get())); |
| 132 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); | 136 compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); |
| 133 output_surface_ = std::unique_ptr<TestOutputSurface>(new TestOutputSurface( | 137 output_surface_ = base::MakeUnique<TestOutputSurface>( |
| 134 cc::TestContextProvider::Create(cc::TestWebGraphicsContext3D::Create()), | 138 cc::TestContextProvider::Create(cc::TestWebGraphicsContext3D::Create()), |
| 135 compositor_->vsync_manager(), compositor_task_runner_.get())); | 139 compositor_->vsync_manager(), begin_frame_source_.get()); |
| 136 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 140 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 137 | 141 |
| 138 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 142 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
| 139 compositor_->SetRootLayer(root_layer_.get()); | 143 compositor_->SetRootLayer(root_layer_.get()); |
| 140 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 144 mirroring_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
| 141 compositor_->root_layer()->Add(mirroring_layer_.get()); | 145 compositor_->root_layer()->Add(mirroring_layer_.get()); |
| 142 gfx::Size size = output_surface_->SurfaceSize(); | 146 gfx::Size size = output_surface_->SurfaceSize(); |
| 143 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); | 147 mirroring_layer_->SetBounds(gfx::Rect(size.width(), size.height())); |
| 144 } | 148 } |
| 145 | 149 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 159 } | 163 } |
| 160 compositor_.reset(); | 164 compositor_.reset(); |
| 161 ui::TerminateContextFactoryForTests(); | 165 ui::TerminateContextFactoryForTests(); |
| 162 ImageTransportFactory::Terminate(); | 166 ImageTransportFactory::Terminate(); |
| 163 } | 167 } |
| 164 | 168 |
| 165 void UpdateTexture() { reflector_->OnSourcePostSubBuffer(kSubRect); } | 169 void UpdateTexture() { reflector_->OnSourcePostSubBuffer(kSubRect); } |
| 166 | 170 |
| 167 protected: | 171 protected: |
| 168 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 172 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
| 173 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source_; |
| 169 cc::FakeOutputSurfaceClient output_surface_client_; | 174 cc::FakeOutputSurfaceClient output_surface_client_; |
| 170 std::unique_ptr<base::MessageLoop> message_loop_; | 175 std::unique_ptr<base::MessageLoop> message_loop_; |
| 171 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 176 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 172 std::unique_ptr<ui::Compositor> compositor_; | 177 std::unique_ptr<ui::Compositor> compositor_; |
| 173 std::unique_ptr<ui::Layer> root_layer_; | 178 std::unique_ptr<ui::Layer> root_layer_; |
| 174 std::unique_ptr<ui::Layer> mirroring_layer_; | 179 std::unique_ptr<ui::Layer> mirroring_layer_; |
| 175 std::unique_ptr<ReflectorImpl> reflector_; | 180 std::unique_ptr<ReflectorImpl> reflector_; |
| 176 std::unique_ptr<TestOutputSurface> output_surface_; | 181 std::unique_ptr<TestOutputSurface> output_surface_; |
| 177 }; | 182 }; |
| 178 | 183 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 plane_2.plane_z_order = 1; | 221 plane_2.plane_z_order = 1; |
| 217 list.push_back(plane_1); | 222 list.push_back(plane_1); |
| 218 list.push_back(plane_2); | 223 list.push_back(plane_2); |
| 219 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); | 224 output_surface_->GetOverlayCandidateValidator()->CheckOverlaySupport(&list); |
| 220 EXPECT_FALSE(list[0].overlay_handled); | 225 EXPECT_FALSE(list[0].overlay_handled); |
| 221 } | 226 } |
| 222 #endif // defined(USE_OZONE) | 227 #endif // defined(USE_OZONE) |
| 223 | 228 |
| 224 } // namespace | 229 } // namespace |
| 225 } // namespace content | 230 } // namespace content |
| OLD | NEW |