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

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: 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: 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

Powered by Google App Engine
This is Rietveld 408576698