OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h" | 5 #include "webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/synchronization/lock.h" |
| 10 #include "cc/context_provider.h" |
9 #include "cc/fake_web_graphics_context_3d.h" | 11 #include "cc/fake_web_graphics_context_3d.h" |
10 #include "cc/input_handler.h" | 12 #include "cc/input_handler.h" |
11 #include "cc/layer.h" | 13 #include "cc/layer.h" |
12 #include "cc/layer_tree_host.h" | 14 #include "cc/layer_tree_host.h" |
13 #include "cc/output_surface.h" | 15 #include "cc/output_surface.h" |
14 #include "cc/switches.h" | 16 #include "cc/switches.h" |
15 #include "cc/thread.h" | 17 #include "cc/thread.h" |
16 #include "cc/thread_impl.h" | 18 #include "cc/thread_impl.h" |
17 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" | 19 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" |
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" |
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h" | 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebInputHandler.h" |
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" |
21 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" | 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" |
22 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli
ent.h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewCli
ent.h" |
23 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h
" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h
" |
| 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsCo
ntext3D.h" |
24 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
25 #include "webkit/compositor_bindings/web_compositor_support_impl.h" | 28 #include "webkit/compositor_bindings/web_compositor_support_impl.h" |
26 #include "webkit/compositor_bindings/web_compositor_support_software_output_devi
ce.h" | 29 #include "webkit/compositor_bindings/web_compositor_support_software_output_devi
ce.h" |
27 #include "webkit/compositor_bindings/web_layer_impl.h" | 30 #include "webkit/compositor_bindings/web_layer_impl.h" |
28 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" | 31 #include "webkit/compositor_bindings/web_rendering_stats_impl.h" |
29 #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h" | 32 #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h" |
30 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | 33 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
31 | 34 |
32 namespace WebKit { | 35 namespace WebKit { |
33 | 36 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 218 |
216 void WebLayerTreeViewImplForTesting::didCommitAndDrawFrame() { } | 219 void WebLayerTreeViewImplForTesting::didCommitAndDrawFrame() { } |
217 | 220 |
218 void WebLayerTreeViewImplForTesting::didCompleteSwapBuffers() { } | 221 void WebLayerTreeViewImplForTesting::didCompleteSwapBuffers() { } |
219 | 222 |
220 void WebLayerTreeViewImplForTesting::scheduleComposite() { | 223 void WebLayerTreeViewImplForTesting::scheduleComposite() { |
221 if (client_) | 224 if (client_) |
222 client_->scheduleComposite(); | 225 client_->scheduleComposite(); |
223 } | 226 } |
224 | 227 |
| 228 class WebLayerTreeViewImplForTesting::MainThreadContextProvider |
| 229 : public cc::ContextProvider { |
| 230 public: |
| 231 virtual bool InitializeOnMainThread() OVERRIDE { return true; } |
| 232 virtual bool BindToCurrentThread() OVERRIDE { return true; } |
| 233 |
| 234 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
| 235 return WebSharedGraphicsContext3D::mainThreadContext(); |
| 236 } |
| 237 virtual class GrContext* GrContext() OVERRIDE { |
| 238 return WebSharedGraphicsContext3D::mainThreadGrContext(); |
| 239 } |
| 240 |
| 241 virtual void VerifyContexts() OVERRIDE {} |
| 242 |
| 243 protected: |
| 244 virtual ~MainThreadContextProvider() {} |
| 245 }; |
| 246 |
| 247 scoped_refptr<cc::ContextProvider> |
| 248 WebLayerTreeViewImplForTesting::OffscreenContextProviderForMainThread() { |
| 249 if (!contexts_main_thread_) |
| 250 contexts_main_thread_ = new MainThreadContextProvider; |
| 251 return contexts_main_thread_; |
| 252 } |
| 253 |
| 254 class WebLayerTreeViewImplForTesting::CompositorThreadContextProvider |
| 255 : public cc::ContextProvider { |
| 256 public: |
| 257 CompositorThreadContextProvider() : destroyed_(false) {} |
| 258 |
| 259 virtual bool InitializeOnMainThread() OVERRIDE { |
| 260 return WebSharedGraphicsContext3D::createCompositorThreadContext(); |
| 261 } |
| 262 virtual bool BindToCurrentThread() OVERRIDE { |
| 263 return Context3d()->makeContextCurrent(); |
| 264 } |
| 265 |
| 266 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
| 267 return WebSharedGraphicsContext3D::compositorThreadContext(); |
| 268 } |
| 269 virtual class GrContext* GrContext() OVERRIDE { |
| 270 return WebSharedGraphicsContext3D::compositorThreadGrContext(); |
| 271 } |
| 272 |
| 273 virtual void VerifyContexts() OVERRIDE { |
| 274 if (Context3d() && !Context3d()->isContextLost()) |
| 275 return; |
| 276 base::AutoLock lock(destroyed_lock_); |
| 277 destroyed_ = true; |
| 278 } |
| 279 |
| 280 bool DestroyedOnMainThread() { |
| 281 base::AutoLock lock(destroyed_lock_); |
| 282 return destroyed_; |
| 283 } |
| 284 |
| 285 protected: |
| 286 virtual ~CompositorThreadContextProvider() {} |
| 287 |
| 288 private: |
| 289 base::Lock destroyed_lock_; |
| 290 bool destroyed_; |
| 291 }; |
| 292 |
| 293 scoped_refptr<cc::ContextProvider> |
| 294 WebLayerTreeViewImplForTesting::OffscreenContextProviderForCompositorThread() { |
| 295 if (!contexts_compositor_thread_ || |
| 296 contexts_compositor_thread_->DestroyedOnMainThread()) |
| 297 contexts_compositor_thread_ = new CompositorThreadContextProvider; |
| 298 return contexts_compositor_thread_; |
| 299 } |
| 300 |
225 } // namespace WebKit | 301 } // namespace WebKit |
OLD | NEW |