Chromium Code Reviews| Index: webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc |
| diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc |
| index bc19555b6a94e88083db3573c5c6c1247277cb8e..e3e698a6a7dff95cd771f2977534c1510147c685 100644 |
| --- a/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc |
| +++ b/webkit/compositor_bindings/web_layer_tree_view_impl_for_testing.cc |
| @@ -21,7 +21,9 @@ |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewClient.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebRenderingStats.h" |
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebSharedGraphicsContext3D.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
| +#include "ui/gl/context_provider.h" |
| #include "webkit/compositor_bindings/web_compositor_support_impl.h" |
| #include "webkit/compositor_bindings/web_compositor_support_software_output_device.h" |
| #include "webkit/compositor_bindings/web_layer_impl.h" |
| @@ -222,4 +224,66 @@ void WebLayerTreeViewImplForTesting::scheduleComposite() { |
| client_->scheduleComposite(); |
| } |
| +class WebLayerTreeViewImplForTesting::MainThreadContextProvider |
| + : public ui::ContextProvider { |
| + public: |
| + virtual bool InitializeOnMainThread() OVERRIDE { return true; } |
| + virtual bool BindToCurrentThread() OVERRIDE { return true; } |
| + |
| + virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
| + return WebSharedGraphicsContext3D::mainThreadContext(); |
| + } |
| + virtual class GrContext* GrContext() OVERRIDE { |
| + return WebSharedGraphicsContext3D::mainThreadGrContext(); |
| + } |
| + |
| + virtual void VerifyContexts() OVERRIDE {} |
| + protected: |
|
piman
2013/02/21 22:49:48
nit: blank line before 'protected:'
danakj
2013/02/22 01:56:31
Done.
|
| + virtual ~MainThreadContextProvider() {} |
| +}; |
| + |
| +scoped_refptr<ui::ContextProvider> |
| +WebLayerTreeViewImplForTesting::OffscreenContextProviderForMainThread() { |
| + if (!contexts_main_thread_) |
| + contexts_main_thread_ = new MainThreadContextProvider; |
| + return contexts_main_thread_; |
| +} |
| + |
| +class WebLayerTreeViewImplForTesting::CompositorThreadContextProvider |
| + : public ui::ContextProvider { |
| + public: |
| + CompositorThreadContextProvider() : destroyed_(false) {} |
| + |
| + virtual bool InitializeOnMainThread() OVERRIDE { |
| + return WebSharedGraphicsContext3D::createCompositorThreadContext(); |
| + } |
| + virtual bool BindToCurrentThread() OVERRIDE { |
| + return Context3d()->makeContextCurrent(); |
| + } |
| + |
| + virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
| + return WebSharedGraphicsContext3D::compositorThreadContext(); |
| + } |
| + virtual class GrContext* GrContext() OVERRIDE { |
| + return WebSharedGraphicsContext3D::compositorThreadGrContext(); |
| + } |
| + |
| + virtual void VerifyContexts() OVERRIDE { |
| + if (!Context3d() || Context3d()->isContextLost()) |
| + destroyed_ = true; |
|
piman
2013/02/21 22:49:48
same here wrt thread safety
danakj
2013/02/22 01:56:31
Done.
|
| + } |
| + bool destroyed() const { return destroyed_; } |
| + protected: |
|
piman
2013/02/21 22:49:48
nit: blank line before 'protected:'
danakj
2013/02/22 01:56:31
Done.
|
| + virtual ~CompositorThreadContextProvider() {} |
| + private: |
|
piman
2013/02/21 22:49:48
nit: blank line before 'private:'
danakj
2013/02/22 01:56:31
Done.
|
| + bool destroyed_; |
| +}; |
| + |
| +scoped_refptr<ui::ContextProvider> |
| +WebLayerTreeViewImplForTesting::OffscreenContextProviderForCompositorThread() { |
| + if (!contexts_compositor_thread_ || contexts_compositor_thread_->destroyed()) |
| + contexts_compositor_thread_ = new CompositorThreadContextProvider; |
| + return contexts_compositor_thread_; |
| +} |
| + |
| } // namespace WebKit |