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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 bool lose_context_when_out_of_memory = true; | 110 bool lose_context_when_out_of_memory = true; |
109 | 111 |
110 scoped_refptr<InProcessContextProvider> context_provider = | 112 scoped_refptr<InProcessContextProvider> context_provider = |
111 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_, | 113 InProcessContextProvider::Create(attribs, &gpu_memory_buffer_manager_, |
112 &image_factory_, | 114 &image_factory_, |
113 lose_context_when_out_of_memory, | 115 lose_context_when_out_of_memory, |
114 compositor->widget(), "UICompositor"); | 116 compositor->widget(), "UICompositor"); |
| 117 scoped_refptr<InProcessContextProvider> worker_context_provider = |
| 118 InProcessContextProvider::CreateOffscreen(&gpu_memory_buffer_manager_, |
| 119 &image_factory_, false); |
115 | 120 |
116 scoped_ptr<cc::OutputSurface> real_output_surface; | 121 scoped_ptr<cc::OutputSurface> real_output_surface; |
117 | 122 |
118 if (use_test_surface_) { | 123 if (use_test_surface_) { |
119 bool flipped_output_surface = false; | 124 bool flipped_output_surface = false; |
120 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( | 125 real_output_surface = make_scoped_ptr(new cc::PixelTestOutputSurface( |
121 context_provider, flipped_output_surface)); | 126 context_provider, worker_context_provider, flipped_output_surface)); |
122 } else { | 127 } else { |
123 real_output_surface = | 128 real_output_surface = make_scoped_ptr( |
124 make_scoped_ptr(new DirectOutputSurface(context_provider)); | 129 new DirectOutputSurface(context_provider, worker_context_provider)); |
125 } | 130 } |
126 | 131 |
127 if (surface_manager_) { | 132 if (surface_manager_) { |
128 scoped_ptr<cc::OnscreenDisplayClient> display_client( | 133 scoped_ptr<cc::OnscreenDisplayClient> display_client( |
129 new cc::OnscreenDisplayClient( | 134 new cc::OnscreenDisplayClient( |
130 real_output_surface.Pass(), surface_manager_, | 135 real_output_surface.Pass(), surface_manager_, |
131 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), | 136 GetSharedBitmapManager(), GetGpuMemoryBufferManager(), |
132 compositor->GetRendererSettings(), compositor->task_runner())); | 137 compositor->GetRendererSettings(), compositor->task_runner())); |
133 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( | 138 scoped_ptr<cc::SurfaceDisplayOutputSurface> surface_output_surface( |
134 new cc::SurfaceDisplayOutputSurface(surface_manager_, | 139 new cc::SurfaceDisplayOutputSurface( |
135 compositor->surface_id_allocator(), | 140 surface_manager_, compositor->surface_id_allocator(), |
136 context_provider)); | 141 context_provider, worker_context_provider)); |
137 display_client->set_surface_output_surface(surface_output_surface.get()); | 142 display_client->set_surface_output_surface(surface_output_surface.get()); |
138 surface_output_surface->set_display_client(display_client.get()); | 143 surface_output_surface->set_display_client(display_client.get()); |
139 | 144 |
140 compositor->SetOutputSurface(surface_output_surface.Pass()); | 145 compositor->SetOutputSurface(surface_output_surface.Pass()); |
141 | 146 |
142 delete per_compositor_data_[compositor.get()]; | 147 delete per_compositor_data_[compositor.get()]; |
143 per_compositor_data_[compositor.get()] = display_client.release(); | 148 per_compositor_data_[compositor.get()] = display_client.release(); |
144 } else { | 149 } else { |
145 compositor->SetOutputSurface(real_output_surface.Pass()); | 150 compositor->SetOutputSurface(real_output_surface.Pass()); |
146 } | 151 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 214 } |
210 | 215 |
211 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 216 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
212 const gfx::Size& size) { | 217 const gfx::Size& size) { |
213 if (!per_compositor_data_.count(compositor)) | 218 if (!per_compositor_data_.count(compositor)) |
214 return; | 219 return; |
215 per_compositor_data_[compositor]->display()->Resize(size); | 220 per_compositor_data_[compositor]->display()->Resize(size); |
216 } | 221 } |
217 | 222 |
218 } // namespace ui | 223 } // namespace ui |
OLD | NEW |