Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: webkit/compositor_bindings/web_layer_tree_view_impl.cc

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android build Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/compositor_bindings/web_layer_tree_view_impl.cc
diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.cc b/webkit/compositor_bindings/web_layer_tree_view_impl.cc
index dba117c88ac00bc2e40cca90f63d154ffc1856a6..2fb135f22ceee098dfa95ae3b8c831211953cc5b 100644
--- a/webkit/compositor_bindings/web_layer_tree_view_impl.cc
+++ b/webkit/compositor_bindings/web_layer_tree_view_impl.cc
@@ -16,7 +16,9 @@
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeViewClient.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebLayerTreeView.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 "web_layer_impl.h"
#include "web_to_ccinput_handler_adapter.h"
#include "webkit/compositor_bindings/web_rendering_stats_impl.h"
@@ -283,4 +285,65 @@ void WebLayerTreeViewImpl::scheduleComposite()
m_client->scheduleComposite();
}
+class WebLayerTreeViewImpl::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> WebLayerTreeViewImpl::OffscreenContextProviderForMainThread() {
+ if (!m_contextsMainThread)
+ m_contextsMainThread = new MainThreadContextProvider;
+ return m_contextsMainThread;
+}
+
+class WebLayerTreeViewImpl::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> WebLayerTreeViewImpl::OffscreenContextProviderForCompositorThread() {
+ if (!m_contextsCompositorThread ||
+ m_contextsCompositorThread->destroyed()) {
+ m_contextsCompositorThread = new CompositorThreadContextProvider;
+ }
+ return m_contextsCompositorThread;
+}
+
} // namespace WebKit

Powered by Google App Engine
This is Rietveld 408576698