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

Unified Diff: content/renderer/gpu/render_widget_compositor.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: Fix typo 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
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.h ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 85bd2f7e5ad5c1612df2acc6e87cc608454000ba..4b53c67c7d3d90602c6f292bd002e1440e1e0c39 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -7,7 +7,9 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "base/string_number_conversions.h"
+#include "base/synchronization/lock.h"
#include "base/time.h"
+#include "cc/context_provider.h"
#include "cc/layer.h"
#include "cc/layer_tree_debug_state.h"
#include "cc/layer_tree_host.h"
@@ -16,6 +18,7 @@
#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 "webkit/compositor_bindings/web_layer_impl.h"
#include "webkit/compositor_bindings/web_to_ccinput_handler_adapter.h"
@@ -440,4 +443,76 @@ void RenderWidgetCompositor::scheduleComposite() {
client_->scheduleComposite();
}
+class RenderWidgetCompositor::MainThreadContextProvider
+ : public cc::ContextProvider {
+ public:
+ virtual bool InitializeOnMainThread() OVERRIDE { return true; }
+ virtual bool BindToCurrentThread() OVERRIDE { return true; }
+
+ virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE {
+ return WebKit::WebSharedGraphicsContext3D::mainThreadContext();
jamesr 2013/02/22 19:11:40 We also have WebKit::WebView::sharedGraphicsContex
danakj 2013/02/22 19:17:53 Ohh, okay. Thanks for the heads up.
+ }
+ virtual class GrContext* GrContext() OVERRIDE {
+ return WebKit::WebSharedGraphicsContext3D::mainThreadGrContext();
+ }
+
+ virtual void VerifyContexts() OVERRIDE {}
+
+ protected:
+ virtual ~MainThreadContextProvider() {}
+};
+
+scoped_refptr<cc::ContextProvider>
+RenderWidgetCompositor::OffscreenContextProviderForMainThread() {
+ if (!contexts_main_thread_)
+ contexts_main_thread_ = new MainThreadContextProvider;
+ return contexts_main_thread_;
+}
+
+class RenderWidgetCompositor::CompositorThreadContextProvider
+ : public cc::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 {
+ if (Context3d() && !Context3d()->isContextLost())
+ return;
+ base::AutoLock lock(destroyed_lock_);
+ destroyed_ = true;
+ }
+ bool DestroyedOnMainThread() {
+ base::AutoLock lock(destroyed_lock_);
+ return destroyed_;
+ }
+
+ protected:
+ virtual ~CompositorThreadContextProvider() {}
+
+ private:
+ base::Lock destroyed_lock_;
+ bool destroyed_;
+};
+
+scoped_refptr<cc::ContextProvider>
+RenderWidgetCompositor::OffscreenContextProviderForCompositorThread() {
+ if (!contexts_compositor_thread_ ||
+ contexts_compositor_thread_->DestroyedOnMainThread())
+ contexts_compositor_thread_ = new CompositorThreadContextProvider;
+ return contexts_compositor_thread_;
+}
+
} // namespace content
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.h ('k') | ui/compositor/compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698