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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 ~FakeReflector() override {} | 34 ~FakeReflector() override {} |
35 void OnMirroringCompositorResized() override {} | 35 void OnMirroringCompositorResized() override {} |
36 void AddMirroringLayer(Layer* layer) override {} | 36 void AddMirroringLayer(Layer* layer) override {} |
37 void RemoveMirroringLayer(Layer* layer) override {} | 37 void RemoveMirroringLayer(Layer* layer) override {} |
38 }; | 38 }; |
39 | 39 |
40 // An OutputSurface implementation that directly draws and swaps to an actual | 40 // An OutputSurface implementation that directly draws and swaps to an actual |
41 // GL surface. | 41 // GL surface. |
42 class DirectOutputSurface : public cc::OutputSurface { | 42 class DirectOutputSurface : public cc::OutputSurface { |
43 public: | 43 public: |
44 explicit DirectOutputSurface( | 44 DirectOutputSurface( |
45 const scoped_refptr<cc::ContextProvider>& context_provider) | 45 const scoped_refptr<cc::ContextProvider>& context_provider, |
46 : cc::OutputSurface(context_provider), weak_ptr_factory_(this) {} | 46 const scoped_refptr<cc::ContextProvider>& worker_context_provider) |
| 47 : cc::OutputSurface(context_provider, worker_context_provider), |
| 48 weak_ptr_factory_(this) {} |
47 | 49 |
48 ~DirectOutputSurface() override {} | 50 ~DirectOutputSurface() override {} |
49 | 51 |
50 // cc::OutputSurface implementation | 52 // cc::OutputSurface implementation |
51 void SwapBuffers(cc::CompositorFrame* frame) override { | 53 void SwapBuffers(cc::CompositorFrame* frame) override { |
52 DCHECK(context_provider_.get()); | 54 DCHECK(context_provider_.get()); |
53 DCHECK(frame->gl_frame_data); | 55 DCHECK(frame->gl_frame_data); |
54 if (frame->gl_frame_data->sub_buffer_rect == | 56 if (frame->gl_frame_data->sub_buffer_rect == |
55 gfx::Rect(frame->gl_frame_data->size)) { | 57 gfx::Rect(frame->gl_frame_data->size)) { |
56 context_provider_->ContextSupport()->Swap(); | 58 context_provider_->ContextSupport()->Swap(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 attribs.stencil_size = 0; | 105 attribs.stencil_size = 0; |
104 attribs.samples = 0; | 106 attribs.samples = 0; |
105 attribs.sample_buffers = 0; | 107 attribs.sample_buffers = 0; |
106 attribs.fail_if_major_perf_caveat = false; | 108 attribs.fail_if_major_perf_caveat = false; |
107 attribs.bind_generates_resource = false; | 109 attribs.bind_generates_resource = false; |
108 | 110 |
109 scoped_refptr<InProcessContextProvider> context_provider = | 111 scoped_refptr<InProcessContextProvider> context_provider = |
110 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_, | 112 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_, |
111 &image_factory_, | 113 &image_factory_, |
112 compositor->widget(), "UICompositor"); | 114 compositor->widget(), "UICompositor"); |
| 115 scoped_refptr<InProcessContextProvider> worker_context_provider = |
| 116 InProcessContextProvider::CreateOffscreen(&gpu_memory_buffer_manager_, |
| 117 &image_factory_); |
113 | 118 |
114 scoped_ptr<cc::OutputSurface> real_output_surface; | 119 scoped_ptr<cc::OutputSurface> real_output_surface; |
115 | 120 |
116 if (use_test_surface_) { | 121 if (use_test_surface_) { |
117 bool flipped_output_surface = false; | 122 bool flipped_output_surface = false; |
118 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( | 123 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( |
119 context_provider, flipped_output_surface)); | 124 context_provider, worker_context_provider, flipped_output_surface)); |
120 } else { | 125 } else { |
121 real_output_surface = | 126 real_output_surface = make_scoped_ptr( |
122 make_scoped_ptr(new DirectOutputSurface(context_provider)); | 127 new DirectOutputSurface(context_provider, worker_context_provider)); |
123 } | 128 } |
124 | 129 |
125 if (surface_manager_) { | 130 if (surface_manager_) { |
126 scoped_ptr<cc::OnscreenDisplayClient> display_client( | 131 scoped_ptr<cc::OnscreenDisplayClient> display_client( |
127 new cc::OnscreenDisplayClient( | 132 new cc::OnscreenDisplayClient( |
128 real_output_surface.Pass(), surface_manager_, | 133 real_output_surface.Pass(), surface_manager_, |
129 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 134 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
130 compositor->GetRendererSettings(), compositor->task_runner())); | 135 compositor->GetRendererSettings(), compositor->task_runner())); |
131 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 136 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
132 new cc::SurfaceDisplayOutputSurface(surface_manager_, | 137 new cc::SurfaceDisplayOutputSurface( |
133 compositor->surface_id_allocator(), | 138 surface_manager_, compositor->surface_id_allocator(), |
134 context_provider)); | 139 context_provider, worker_context_provider)); |
135 display_client->set_surface_output_surface(surface_output_surface.get()); | 140 display_client->set_surface_output_surface(surface_output_surface.get()); |
136 surface_output_surface->set_display_client(display_client.get()); | 141 surface_output_surface->set_display_client(display_client.get()); |
137 | 142 |
138 compositor->SetOutputSurface(surface_output_surface.Pass()); | 143 compositor->SetOutputSurface(surface_output_surface.Pass()); |
139 | 144 |
140 delete per_compositor_data_[compositor.get()]; | 145 delete per_compositor_data_[compositor.get()]; |
141 per_compositor_data_[compositor.get()] = display_client.release(); | 146 per_compositor_data_[compositor.get()] = display_client.release(); |
142 } else { | 147 } else { |
143 compositor->SetOutputSurface(real_output_surface.Pass()); | 148 compositor->SetOutputSurface(real_output_surface.Pass()); |
144 } | 149 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 212 } |
208 | 213 |
209 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 214 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
210 const gfx::Size& size) { | 215 const gfx::Size& size) { |
211 if (!per_compositor_data_.count(compositor)) | 216 if (!per_compositor_data_.count(compositor)) |
212 return; | 217 return; |
213 per_compositor_data_[compositor]->display()->Resize(size); | 218 per_compositor_data_[compositor]->display()->Resize(size); |
214 } | 219 } |
215 | 220 |
216 } // namespace ui | 221 } // namespace ui |
OLD | NEW |