Chromium Code Reviews| 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" | 16 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 17 #include "gpu/command_buffer/client/context_support.h" | 17 #include "gpu/command_buffer/client/context_support.h" |
| 18 #include "gpu/command_buffer/client/gles2_interface.h" | 18 #include "gpu/command_buffer/client/gles2_interface.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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 bool software_fallback) { | 87 bool software_fallback) { |
| 88 DCHECK(!software_fallback); | 88 DCHECK(!software_fallback); |
| 89 blink::WebGraphicsContext3D::Attributes attrs; | 89 blink::WebGraphicsContext3D::Attributes attrs; |
| 90 attrs.depth = false; | 90 attrs.depth = false; |
| 91 attrs.stencil = false; | 91 attrs.stencil = false; |
| 92 attrs.antialias = false; | 92 attrs.antialias = false; |
| 93 attrs.shareResources = true; | 93 attrs.shareResources = true; |
| 94 bool lose_context_when_out_of_memory = true; | 94 bool lose_context_when_out_of_memory = true; |
| 95 | 95 |
| 96 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; | 96 using gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl; |
| 97 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( | 97 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( |
|
tfarina
2015/01/20 23:23:52
Is about this that are talking about or is it some
piman
2015/01/21 00:10:23
Right, the current code creates a WebGraphicsConte
| |
| 98 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( | 98 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( |
| 99 attrs, lose_context_when_out_of_memory, compositor->widget())); | 99 attrs, lose_context_when_out_of_memory, compositor->widget())); |
| 100 CHECK(context3d); | 100 CHECK(context3d); |
| 101 | 101 |
| 102 using webkit::gpu::ContextProviderInProcess; | 102 scoped_refptr<InProcessContextProvider> context_provider = |
| 103 scoped_refptr<ContextProviderInProcess> context_provider = | 103 InProcessContextProvider::Create(context3d.Pass(), "UICompositor"); |
| 104 ContextProviderInProcess::Create(context3d.Pass(), "UICompositor"); | |
| 105 | 104 |
| 106 if (use_test_surface_) { | 105 if (use_test_surface_) { |
| 107 bool flipped_output_surface = false; | 106 bool flipped_output_surface = false; |
| 108 compositor->SetOutputSurface(make_scoped_ptr(new cc::PixelTestOutputSurface( | 107 compositor->SetOutputSurface(make_scoped_ptr(new cc::PixelTestOutputSurface( |
| 109 context_provider, flipped_output_surface))); | 108 context_provider, flipped_output_surface))); |
| 110 } else { | 109 } else { |
| 111 compositor->SetOutputSurface( | 110 compositor->SetOutputSurface( |
| 112 make_scoped_ptr(new DirectOutputSurface(context_provider))); | 111 make_scoped_ptr(new DirectOutputSurface(context_provider))); |
| 113 } | 112 } |
| 114 } | 113 } |
| 115 | 114 |
| 116 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( | 115 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( |
| 117 Compositor* mirroed_compositor, | 116 Compositor* mirroed_compositor, |
| 118 Layer* mirroring_layer) { | 117 Layer* mirroring_layer) { |
| 119 return new Reflector(); | 118 return new Reflector(); |
| 120 } | 119 } |
| 121 | 120 |
| 122 void InProcessContextFactory::RemoveReflector( | 121 void InProcessContextFactory::RemoveReflector( |
| 123 scoped_refptr<Reflector> reflector) {} | 122 scoped_refptr<Reflector> reflector) {} |
| 124 | 123 |
| 125 scoped_refptr<cc::ContextProvider> | 124 scoped_refptr<cc::ContextProvider> |
| 126 InProcessContextFactory::SharedMainThreadContextProvider() { | 125 InProcessContextFactory::SharedMainThreadContextProvider() { |
| 127 if (shared_main_thread_contexts_.get() && | 126 if (shared_main_thread_contexts_.get() && |
| 128 !shared_main_thread_contexts_->DestroyedOnMainThread()) | 127 !shared_main_thread_contexts_->DestroyedOnMainThread()) |
| 129 return shared_main_thread_contexts_; | 128 return shared_main_thread_contexts_; |
| 130 | 129 |
| 131 bool lose_context_when_out_of_memory = false; | 130 bool lose_context_when_out_of_memory = false; |
| 132 shared_main_thread_contexts_ = | 131 shared_main_thread_contexts_ = InProcessContextProvider::CreateOffscreen( |
| 133 webkit::gpu::ContextProviderInProcess::CreateOffscreen( | 132 lose_context_when_out_of_memory); |
| 134 lose_context_when_out_of_memory); | |
| 135 if (shared_main_thread_contexts_.get() && | 133 if (shared_main_thread_contexts_.get() && |
| 136 !shared_main_thread_contexts_->BindToCurrentThread()) | 134 !shared_main_thread_contexts_->BindToCurrentThread()) |
| 137 shared_main_thread_contexts_ = NULL; | 135 shared_main_thread_contexts_ = NULL; |
| 138 | 136 |
| 139 return shared_main_thread_contexts_; | 137 return shared_main_thread_contexts_; |
| 140 } | 138 } |
| 141 | 139 |
| 142 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} | 140 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} |
| 143 | 141 |
| 144 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } | 142 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 162 InProcessContextFactory::CreateSurfaceIdAllocator() { | 160 InProcessContextFactory::CreateSurfaceIdAllocator() { |
| 163 return make_scoped_ptr( | 161 return make_scoped_ptr( |
| 164 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); | 162 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); |
| 165 } | 163 } |
| 166 | 164 |
| 167 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 165 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
| 168 const gfx::Size& size) { | 166 const gfx::Size& size) { |
| 169 } | 167 } |
| 170 | 168 |
| 171 } // namespace ui | 169 } // namespace ui |
| OLD | NEW |