Chromium Code Reviews| Index: content/renderer/gpu/render_widget_compositor.cc |
| diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc |
| index 619944058745584281693ddead3001f48580e381..03747b5b134979125ade848cb9cbb3d44000d4f2 100644 |
| --- a/content/renderer/gpu/render_widget_compositor.cc |
| +++ b/content/renderer/gpu/render_widget_compositor.cc |
| @@ -16,7 +16,9 @@ |
| #include "content/renderer/gpu/compositor_thread.h" |
| #include "content/renderer/render_thread_impl.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewClient.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_layer_impl.h" |
| #include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h" |
| @@ -422,4 +424,66 @@ void RenderWidgetCompositor::scheduleComposite() { |
| client_->scheduleComposite(); |
| } |
| +class RenderWidgetCompositor::MainThreadContextProvider |
| + : public ui::ContextProvider { |
| + public: |
| + virtual bool InitializeOnMainThread() OVERRIDE { return true; } |
| + virtual bool BindToCurrentThread() OVERRIDE { return true; } |
| + |
| + virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
| + return WebKit::WebSharedGraphicsContext3D::mainThreadContext(); |
| + } |
| + virtual class GrContext* GrContext() OVERRIDE { |
| + return WebKit::WebSharedGraphicsContext3D::mainThreadGrContext(); |
| + } |
| + |
| + virtual void VerifyContexts() OVERRIDE {} |
| + protected: |
| + virtual ~MainThreadContextProvider() {} |
| +}; |
| + |
| +scoped_refptr<ui::ContextProvider> |
| +RenderWidgetCompositor::OffscreenContextProviderForMainThread() { |
| + if (!contexts_main_thread_) |
| + contexts_main_thread_ = new MainThreadContextProvider; |
| + return contexts_main_thread_; |
| +} |
| + |
| +class RenderWidgetCompositor::CompositorThreadContextProvider |
| + : public ui::ContextProvider { |
| + public: |
| + CompositorThreadContextProvider() : destroyed_(false) {} |
| + |
| + virtual bool InitializeOnMainThread() OVERRIDE { |
| + return WebKit::WebSharedGraphicsContext3D::createCompositorThreadContext(); |
| + } |
| + virtual bool BindToCurrentThread() OVERRIDE { |
| + return Context3d()->makeContextCurrent(); |
| + } |
| + |
| + virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE { |
| + return WebKit::WebSharedGraphicsContext3D::compositorThreadContext(); |
| + } |
| + virtual class GrContext* GrContext() OVERRIDE { |
| + return WebKit::WebSharedGraphicsContext3D::compositorThreadGrContext(); |
| + } |
| + |
| + virtual void VerifyContexts() OVERRIDE { |
| + destroyed_ = !Context3d() || Context3d()->isContextLost(); |
|
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> |
| +RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() { |
| + if (!contexts_compositor_thread_ || |
| + contexts_compositor_thread_->destroyed()) |
| + contexts_compositor_thread_ = new CompositorThreadContextProvider; |
| + return contexts_compositor_thread_; |
| +} |
| + |
| } // namespace content |