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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; | 59 base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; |
60 | 60 |
61 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); | 61 DISALLOW_COPY_AND_ASSIGN(DirectOutputSurface); |
62 }; | 62 }; |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 InProcessContextFactory::InProcessContextFactory() | 66 InProcessContextFactory::InProcessContextFactory(bool context_factory_for_test) |
67 : next_surface_id_namespace_(1u), use_test_surface_(true) { | 67 : next_surface_id_namespace_(1u), |
| 68 use_test_surface_(true), |
| 69 context_factory_for_test_(context_factory_for_test) { |
68 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone) | 70 DCHECK_NE(gfx::GetGLImplementation(), gfx::kGLImplementationNone) |
69 << "If running tests, ensure that main() is calling " | 71 << "If running tests, ensure that main() is calling " |
70 << "gfx::GLSurface::InitializeOneOffForTests()"; | 72 << "gfx::GLSurface::InitializeOneOffForTests()"; |
71 | 73 |
72 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
73 bool use_thread = !CommandLine::ForCurrentProcess()->HasSwitch( | 75 bool use_thread = !CommandLine::ForCurrentProcess()->HasSwitch( |
74 switches::kUIDisableThreadedCompositing); | 76 switches::kUIDisableThreadedCompositing); |
75 #else | 77 #else |
76 bool use_thread = false; | 78 bool use_thread = false; |
77 #endif | 79 #endif |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 lose_context_when_out_of_memory); | 137 lose_context_when_out_of_memory); |
136 if (shared_main_thread_contexts_.get() && | 138 if (shared_main_thread_contexts_.get() && |
137 !shared_main_thread_contexts_->BindToCurrentThread()) | 139 !shared_main_thread_contexts_->BindToCurrentThread()) |
138 shared_main_thread_contexts_ = NULL; | 140 shared_main_thread_contexts_ = NULL; |
139 | 141 |
140 return shared_main_thread_contexts_; | 142 return shared_main_thread_contexts_; |
141 } | 143 } |
142 | 144 |
143 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} | 145 void InProcessContextFactory::RemoveCompositor(Compositor* compositor) {} |
144 | 146 |
145 bool InProcessContextFactory::DoesCreateTestContexts() { return false; } | 147 bool InProcessContextFactory::DoesCreateTestContexts() { |
| 148 return context_factory_for_test_; |
| 149 } |
146 | 150 |
147 cc::SharedBitmapManager* InProcessContextFactory::GetSharedBitmapManager() { | 151 cc::SharedBitmapManager* InProcessContextFactory::GetSharedBitmapManager() { |
148 return &shared_bitmap_manager_; | 152 return &shared_bitmap_manager_; |
149 } | 153 } |
150 | 154 |
151 gpu::GpuMemoryBufferManager* | 155 gpu::GpuMemoryBufferManager* |
152 InProcessContextFactory::GetGpuMemoryBufferManager() { | 156 InProcessContextFactory::GetGpuMemoryBufferManager() { |
153 return &gpu_memory_buffer_manager_; | 157 return &gpu_memory_buffer_manager_; |
154 } | 158 } |
155 | 159 |
156 base::MessageLoopProxy* InProcessContextFactory::GetCompositorMessageLoop() { | 160 base::MessageLoopProxy* InProcessContextFactory::GetCompositorMessageLoop() { |
157 if (!compositor_thread_) | 161 if (!compositor_thread_) |
158 return NULL; | 162 return NULL; |
159 return compositor_thread_->message_loop_proxy().get(); | 163 return compositor_thread_->message_loop_proxy().get(); |
160 } | 164 } |
161 | 165 |
162 scoped_ptr<cc::SurfaceIdAllocator> | 166 scoped_ptr<cc::SurfaceIdAllocator> |
163 InProcessContextFactory::CreateSurfaceIdAllocator() { | 167 InProcessContextFactory::CreateSurfaceIdAllocator() { |
164 return make_scoped_ptr( | 168 return make_scoped_ptr( |
165 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); | 169 new cc::SurfaceIdAllocator(next_surface_id_namespace_++)); |
166 } | 170 } |
167 | 171 |
168 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, | 172 void InProcessContextFactory::ResizeDisplay(ui::Compositor* compositor, |
169 const gfx::Size& size) { | 173 const gfx::Size& size) { |
170 } | 174 } |
171 | 175 |
172 } // namespace ui | 176 } // namespace ui |
OLD | NEW |