OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/compositor/test/in_process_context_factory.h" | 5 #include "ui/compositor/test/in_process_context_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 ~FakeReflector() override {} | 42 ~FakeReflector() override {} |
43 void OnMirroringCompositorResized() override {} | 43 void OnMirroringCompositorResized() override {} |
44 void AddMirroringLayer(Layer* layer) override {} | 44 void AddMirroringLayer(Layer* layer) override {} |
45 void RemoveMirroringLayer(Layer* layer) override {} | 45 void RemoveMirroringLayer(Layer* layer) override {} |
46 }; | 46 }; |
47 | 47 |
48 // An OutputSurface implementation that directly draws and swaps to an actual | 48 // An OutputSurface implementation that directly draws and swaps to an actual |
49 // GL surface. | 49 // GL surface. |
50 class DirectOutputSurface : public cc::OutputSurface { | 50 class DirectOutputSurface : public cc::OutputSurface { |
51 public: | 51 public: |
52 DirectOutputSurface( | 52 DirectOutputSurface(scoped_refptr<InProcessContextProvider> context_provider) |
53 scoped_refptr<InProcessContextProvider> context_provider, | 53 : cc::OutputSurface(std::move(context_provider)), |
54 scoped_refptr<InProcessContextProvider> worker_context_provider) | |
55 : cc::OutputSurface(std::move(context_provider), | |
56 std::move(worker_context_provider), | |
57 nullptr), | |
58 weak_ptr_factory_(this) {} | 54 weak_ptr_factory_(this) {} |
59 | 55 |
60 ~DirectOutputSurface() override {} | 56 ~DirectOutputSurface() override {} |
61 | 57 |
62 // cc::OutputSurface implementation. | 58 // cc::OutputSurface implementation. |
63 bool BindToClient(cc::OutputSurfaceClient* client) override { | 59 bool BindToClient(cc::OutputSurfaceClient* client) override { |
64 if (!OutputSurface::BindToClient(client)) | 60 if (!OutputSurface::BindToClient(client)) |
65 return false; | 61 return false; |
66 return true; | 62 return true; |
67 } | 63 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 scoped_refptr<InProcessContextProvider> context_provider = | 150 scoped_refptr<InProcessContextProvider> context_provider = |
155 InProcessContextProvider::Create( | 151 InProcessContextProvider::Create( |
156 attribs, shared_worker_context_provider_.get(), | 152 attribs, shared_worker_context_provider_.get(), |
157 &gpu_memory_buffer_manager_, &image_factory_, compositor->widget(), | 153 &gpu_memory_buffer_manager_, &image_factory_, compositor->widget(), |
158 "UICompositor"); | 154 "UICompositor"); |
159 | 155 |
160 std::unique_ptr<cc::OutputSurface> display_output_surface; | 156 std::unique_ptr<cc::OutputSurface> display_output_surface; |
161 if (use_test_surface_) { | 157 if (use_test_surface_) { |
162 bool flipped_output_surface = false; | 158 bool flipped_output_surface = false; |
163 display_output_surface = base::MakeUnique<cc::PixelTestOutputSurface>( | 159 display_output_surface = base::MakeUnique<cc::PixelTestOutputSurface>( |
164 context_provider, shared_worker_context_provider_, | 160 context_provider, flipped_output_surface); |
165 flipped_output_surface); | |
166 } else { | 161 } else { |
167 display_output_surface = base::MakeUnique<DirectOutputSurface>( | 162 display_output_surface = |
168 context_provider, shared_worker_context_provider_); | 163 base::MakeUnique<DirectOutputSurface>(context_provider); |
169 } | 164 } |
170 | 165 |
171 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( | 166 std::unique_ptr<cc::DelayBasedBeginFrameSource> begin_frame_source( |
172 new cc::DelayBasedBeginFrameSource( | 167 new cc::DelayBasedBeginFrameSource( |
173 base::MakeUnique<cc::DelayBasedTimeSource>( | 168 base::MakeUnique<cc::DelayBasedTimeSource>( |
174 compositor->task_runner().get()))); | 169 compositor->task_runner().get()))); |
175 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( | 170 std::unique_ptr<cc::DisplayScheduler> scheduler(new cc::DisplayScheduler( |
176 begin_frame_source.get(), compositor->task_runner().get(), | 171 begin_frame_source.get(), compositor->task_runner().get(), |
177 display_output_surface->capabilities().max_frames_pending)); | 172 display_output_surface->capabilities().max_frames_pending)); |
178 per_compositor_data_[compositor.get()] = base::MakeUnique<cc::Display>( | 173 per_compositor_data_[compositor.get()] = base::MakeUnique<cc::Display>( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 262 |
268 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { | 263 void InProcessContextFactory::AddObserver(ContextFactoryObserver* observer) { |
269 observer_list_.AddObserver(observer); | 264 observer_list_.AddObserver(observer); |
270 } | 265 } |
271 | 266 |
272 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { | 267 void InProcessContextFactory::RemoveObserver(ContextFactoryObserver* observer) { |
273 observer_list_.RemoveObserver(observer); | 268 observer_list_.RemoveObserver(observer); |
274 } | 269 } |
275 | 270 |
276 } // namespace ui | 271 } // namespace ui |
OLD | NEW |