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