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" |
11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
12 #include "cc/output/output_surface_client.h" | 12 #include "cc/output/output_surface_client.h" |
13 #include "cc/surfaces/surface_id_allocator.h" | 13 #include "cc/surfaces/surface_id_allocator.h" |
14 #include "cc/test/pixel_test_output_surface.h" | 14 #include "cc/test/pixel_test_output_surface.h" |
15 #include "cc/test/test_shared_bitmap_manager.h" | 15 #include "cc/test/test_shared_bitmap_manager.h" |
16 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" | |
17 #include "gpu/command_buffer/client/context_support.h" | 16 #include "gpu/command_buffer/client/context_support.h" |
18 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" |
19 #include "ui/compositor/compositor_switches.h" | 18 #include "ui/compositor/compositor_switches.h" |
20 #include "ui/compositor/reflector.h" | 19 #include "ui/compositor/reflector.h" |
| 20 #include "ui/compositor/test/in_process_context_provider.h" |
21 #include "ui/gl/gl_implementation.h" | 21 #include "ui/gl/gl_implementation.h" |
22 #include "ui/gl/gl_surface.h" | 22 #include "ui/gl/gl_surface.h" |
23 #include "webkit/common/gpu/context_provider_in_process.h" | |
24 | 23 |
25 namespace ui { | 24 namespace ui { |
26 namespace { | 25 namespace { |
27 | 26 |
28 // An OutputSurface implementation that directly draws and swaps to an actual | 27 // An OutputSurface implementation that directly draws and swaps to an actual |
29 // GL surface. | 28 // GL surface. |
30 class DirectOutputSurface : public cc::OutputSurface { | 29 class DirectOutputSurface : public cc::OutputSurface { |
31 public: | 30 public: |
32 explicit DirectOutputSurface( | 31 explicit DirectOutputSurface( |
33 const scoped_refptr<cc::ContextProvider>& context_provider) | 32 const scoped_refptr<cc::ContextProvider>& context_provider) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 base::WeakPtr<Compositor> compositor, | 85 base::WeakPtr<Compositor> compositor, |
87 bool software_fallback) { | 86 bool software_fallback) { |
88 DCHECK(!software_fallback); | 87 DCHECK(!software_fallback); |
89 blink::WebGraphicsContext3D::Attributes attrs; | 88 blink::WebGraphicsContext3D::Attributes attrs; |
90 attrs.depth = false; | 89 attrs.depth = false; |
91 attrs.stencil = false; | 90 attrs.stencil = false; |
92 attrs.antialias = false; | 91 attrs.antialias = false; |
93 attrs.shareResources = true; | 92 attrs.shareResources = true; |
94 bool lose_context_when_out_of_memory = true; | 93 bool lose_context_when_out_of_memory = true; |
95 | 94 |
96 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 95 scoped_refptr<InProcessContextProvider> context_provider = |
97 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( | 96 InProcessContextProvider::Create(attrs, lose_context_when_out_of_memory, |
98 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( | 97 compositor->widget(), "UICompositor"); |
99 attrs, lose_context_when_out_of_memory, compositor->widget())); | |
100 CHECK(context3d); | |
101 | |
102 using webkit::gpu::ContextProviderInProcess; | |
103 scoped_refptr<ContextProviderInProcess> context_provider = | |
104 ContextProviderInProcess::Create(context3d.Pass(), "UICompositor"); | |
105 | 98 |
106 if (use_test_surface_) { | 99 if (use_test_surface_) { |
107 bool flipped_output_surface = false; | 100 bool flipped_output_surface = false; |
108 compositor->SetOutputSurface(make_scoped_ptr(new cc::PixelTestOutputSurface( | 101 compositor->SetOutputSurface(make_scoped_ptr(new cc::PixelTestOutputSurface( |
109 context_provider, flipped_output_surface))); | 102 context_provider, flipped_output_surface))); |
110 } else { | 103 } else { |
111 compositor->SetOutputSurface( | 104 compositor->SetOutputSurface( |
112 make_scoped_ptr(new DirectOutputSurface(context_provider))); | 105 make_scoped_ptr(new DirectOutputSurface(context_provider))); |
113 } | 106 } |
114 } | 107 } |
115 | 108 |
116 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( | 109 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( |
117 Compositor* mirroed_compositor, | 110 Compositor* mirroed_compositor, |
118 Layer* mirroring_layer) { | 111 Layer* mirroring_layer) { |
119 return new Reflector(); | 112 return new Reflector(); |
120 } | 113 } |
121 | 114 |
122 void InProcessContextFactory::RemoveReflector( | 115 void InProcessContextFactory::RemoveReflector( |
123 scoped_refptr<Reflector> reflector) {} | 116 scoped_refptr<Reflector> reflector) {} |
124 | 117 |
125 scoped_refptr<cc::ContextProvider> | 118 scoped_refptr<cc::ContextProvider> |
126 InProcessContextFactory::SharedMainThreadContextProvider() { | 119 InProcessContextFactory::SharedMainThreadContextProvider() { |
127 if (shared_main_thread_contexts_.get() && | 120 if (shared_main_thread_contexts_.get() && |
128 !shared_main_thread_contexts_->DestroyedOnMainThread()) | 121 !shared_main_thread_contexts_->DestroyedOnMainThread()) |
129 return shared_main_thread_contexts_; | 122 return shared_main_thread_contexts_; |
130 | 123 |
131 bool lose_context_when_out_of_memory = false; | 124 bool lose_context_when_out_of_memory = false; |
132 shared_main_thread_contexts_ = | 125 shared_main_thread_contexts_ = InProcessContextProvider::CreateOffscreen( |
133 webkit::gpu::ContextProviderInProcess::CreateOffscreen( | 126 lose_context_when_out_of_memory); |
134 lose_context_when_out_of_memory); | |
135 if (shared_main_thread_contexts_.get() && | 127 if (shared_main_thread_contexts_.get() && |
136 !shared_main_thread_contexts_->BindToCurrentThread()) | 128 !shared_main_thread_contexts_->BindToCurrentThread()) |
137 shared_main_thread_contexts_ = NULL; | 129 shared_main_thread_contexts_ = NULL; |
138 | 130 |
139 return shared_main_thread_contexts_; | 131 return shared_main_thread_contexts_; |
140 } | 132 } |
141 | 133 |
142 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} | 134 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} |
143 | 135 |
144 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } | 136 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } |
(...skipping 17 matching lines...) Expand all Loading... |
162 InProcessContextFactory::CreateSurfaceIdAllocator() { | 154 InProcessContextFactory::CreateSurfaceIdAllocator() { |
163 return make_scoped_ptr( | 155 return make_scoped_ptr( |
164 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); | 156 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); |
165 } | 157 } |
166 | 158 |
167 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 159 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
168 const gfx::Size& size) { | 160 const gfx::Size& size) { |
169 } | 161 } |
170 | 162 |
171 } // namespace ui | 163 } // namespace ui |
OLD | NEW |