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 "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
8 #include "ui/compositor/reflector.h" | 8 #include "ui/compositor/reflector.h" |
9 #include "ui/gl/gl_implementation.h" | 9 #include "ui/gl/gl_implementation.h" |
10 #include "ui/gl/gl_surface.h" | 10 #include "ui/gl/gl_surface.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 scoped_ptr<cc::OutputSurface> InProcessContextFactory::CreateOutputSurface( | 23 scoped_ptr<cc::OutputSurface> InProcessContextFactory::CreateOutputSurface( |
24 Compositor* compositor, | 24 Compositor* compositor, |
25 bool software_fallback) { | 25 bool software_fallback) { |
26 DCHECK(!software_fallback); | 26 DCHECK(!software_fallback); |
27 blink::WebGraphicsContext3D::Attributes attrs; | 27 blink::WebGraphicsContext3D::Attributes attrs; |
28 attrs.depth = false; | 28 attrs.depth = false; |
29 attrs.stencil = false; | 29 attrs.stencil = false; |
30 attrs.antialias = false; | 30 attrs.antialias = false; |
31 attrs.shareResources = true; | 31 attrs.shareResources = true; |
| 32 bool lose_context_when_out_of_memory = true; |
32 | 33 |
33 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; | 34 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; |
34 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( | 35 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( |
35 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( | 36 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( |
36 attrs, compositor->widget())); | 37 attrs, lose_context_when_out_of_memory, compositor->widget())); |
37 CHECK(context3d); | 38 CHECK(context3d); |
38 | 39 |
39 using webkit::gpu::ContextProviderInProcess; | 40 using webkit::gpu::ContextProviderInProcess; |
40 scoped_refptr<ContextProviderInProcess> context_provider = | 41 scoped_refptr<ContextProviderInProcess> context_provider = |
41 ContextProviderInProcess::Create(context3d.Pass(), "UICompositor"); | 42 ContextProviderInProcess::Create(context3d.Pass(), "UICompositor"); |
42 | 43 |
43 return make_scoped_ptr(new cc::OutputSurface(context_provider)); | 44 return make_scoped_ptr(new cc::OutputSurface(context_provider)); |
44 } | 45 } |
45 | 46 |
46 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( | 47 scoped_refptr<Reflector> InProcessContextFactory::CreateReflector( |
47 Compositor* mirroed_compositor, | 48 Compositor* mirroed_compositor, |
48 Layer* mirroring_layer) { | 49 Layer* mirroring_layer) { |
49 return new Reflector(); | 50 return new Reflector(); |
50 } | 51 } |
51 | 52 |
52 void InProcessContextFactory::RemoveReflector( | 53 void InProcessContextFactory::RemoveReflector( |
53 scoped_refptr<Reflector> reflector) {} | 54 scoped_refptr<Reflector> reflector) {} |
54 | 55 |
55 scoped_refptr<cc::ContextProvider> | 56 scoped_refptr<cc::ContextProvider> |
56 InProcessContextFactory::OffscreenCompositorContextProvider() { | 57 InProcessContextFactory::OffscreenCompositorContextProvider() { |
57 if (!offscreen_compositor_contexts_.get() || | 58 if (!offscreen_compositor_contexts_.get() || |
58 !offscreen_compositor_contexts_->DestroyedOnMainThread()) { | 59 !offscreen_compositor_contexts_->DestroyedOnMainThread()) { |
| 60 bool lose_context_when_out_of_memory = true; |
59 offscreen_compositor_contexts_ = | 61 offscreen_compositor_contexts_ = |
60 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); | 62 webkit::gpu::ContextProviderInProcess::CreateOffscreen( |
| 63 lose_context_when_out_of_memory); |
61 } | 64 } |
62 return offscreen_compositor_contexts_; | 65 return offscreen_compositor_contexts_; |
63 } | 66 } |
64 | 67 |
65 scoped_refptr<cc::ContextProvider> | 68 scoped_refptr<cc::ContextProvider> |
66 InProcessContextFactory::SharedMainThreadContextProvider() { | 69 InProcessContextFactory::SharedMainThreadContextProvider() { |
67 if (shared_main_thread_contexts_ && | 70 if (shared_main_thread_contexts_ && |
68 !shared_main_thread_contexts_->DestroyedOnMainThread()) | 71 !shared_main_thread_contexts_->DestroyedOnMainThread()) |
69 return shared_main_thread_contexts_; | 72 return shared_main_thread_contexts_; |
70 | 73 |
71 if (ui::Compositor::WasInitializedWithThread()) { | 74 if (ui::Compositor::WasInitializedWithThread()) { |
| 75 bool lose_context_when_out_of_memory = false; |
72 shared_main_thread_contexts_ = | 76 shared_main_thread_contexts_ = |
73 webkit::gpu::ContextProviderInProcess::CreateOffscreen(); | 77 webkit::gpu::ContextProviderInProcess::CreateOffscreen( |
| 78 lose_context_when_out_of_memory); |
74 } else { | 79 } else { |
75 shared_main_thread_contexts_ = | 80 shared_main_thread_contexts_ = |
76 static_cast<webkit::gpu::ContextProviderInProcess*>( | 81 static_cast<webkit::gpu::ContextProviderInProcess*>( |
77 OffscreenCompositorContextProvider().get()); | 82 OffscreenCompositorContextProvider().get()); |
78 } | 83 } |
79 if (shared_main_thread_contexts_ && | 84 if (shared_main_thread_contexts_ && |
80 !shared_main_thread_contexts_->BindToCurrentThread()) | 85 !shared_main_thread_contexts_->BindToCurrentThread()) |
81 shared_main_thread_contexts_ = NULL; | 86 shared_main_thread_contexts_ = NULL; |
82 | 87 |
83 return shared_main_thread_contexts_; | 88 return shared_main_thread_contexts_; |
84 } | 89 } |
85 | 90 |
86 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} | 91 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} |
87 | 92 |
88 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } | 93 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } |
89 | 94 |
90 } // namespace ui | 95 } // namespace ui |
OLD | NEW |