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

Unified Diff: ui/compositor/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: Remove the GrContextProvider::ScopedContexts guard classes 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: ui/compositor/compositor.cc
diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc
index 9e7c4d54496ee96db23b3253c0519a9e2c6d90a8..95773b1c3548c1c4b9f0ff7b13dae77b3e2695d2 100644
--- a/ui/compositor/compositor.cc
+++ b/ui/compositor/compositor.cc
@@ -29,6 +29,7 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h"
+#include "webkit/gpu/grcontext_for_webgraphicscontext3d.h"
#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
#if defined(OS_CHROMEOS)
@@ -141,6 +142,9 @@ DefaultContextFactory::~DefaultContextFactory() {
}
bool DefaultContextFactory::Initialize() {
+ if (g_test_compositor_enabled)
+ return true;
+
// The following line of code exists soley to disable IO restrictions
// on this thread long enough to perform the GL bindings.
// TODO(wjmaclean) Remove this when GL initialisation cleaned up.
@@ -163,6 +167,53 @@ WebKit::WebGraphicsContext3D* DefaultContextFactory::CreateOffscreenContext() {
return CreateContextCommon(NULL, true);
}
+WebKit::WebGraphicsContext3D*
+DefaultContextFactory::OffscreenContextForMainThread() {
+ if (!test_offscreen_context_main_thread_) {
+ scoped_ptr<ui::TestWebGraphicsContext3D> test_context(
piman 2013/02/13 19:13:31 Mmh, we should only be creating TestWGC3D-type con
danakj 2013/02/13 20:47:10 The downside to this is that then we need storage
piman 2013/02/14 00:16:08 Why couldn't they still be fields in DefaultContex
+ new ui::TestWebGraphicsContext3D());
+ test_context->Initialize();
+ test_offscreen_context_main_thread_ =
+ test_context.PassAs<WebKit::WebGraphicsContext3D>();
+ }
+ return test_offscreen_context_main_thread_.get();
+}
+
+WebKit::WebGraphicsContext3D*
+DefaultContextFactory::OffscreenContextForCompositorThread() {
+ if (!test_offscreen_context_compositor_thread_) {
+ scoped_ptr<ui::TestWebGraphicsContext3D> test_context(
+ new ui::TestWebGraphicsContext3D());
+ test_context->Initialize();
+ test_offscreen_context_compositor_thread_ =
+ test_context.PassAs<WebKit::WebGraphicsContext3D>();
+ }
+ return test_offscreen_context_compositor_thread_.get();
+}
+
+GrContext* DefaultContextFactory::OffscreenGrContextForMainThread() {
+ if (!grcontext_main_thread_ && test_offscreen_context_main_thread_) {
+ grcontext_main_thread_.reset(
+ new webkit::gpu::GrContextForWebGraphicsContext3D(
+ test_offscreen_context_main_thread_.get()));
+ }
+ return grcontext_main_thread_->gr_context();
+}
+
+GrContext* DefaultContextFactory::OffscreenGrContextForCompositorThread() {
+ if (!grcontext_compositor_thread_ &&
+ test_offscreen_context_compositor_thread_) {
+ grcontext_compositor_thread_.reset(
+ new webkit::gpu::GrContextForWebGraphicsContext3D(
+ test_offscreen_context_compositor_thread_.get()));
+ }
+ return grcontext_compositor_thread_->gr_context();
+}
+
+void DefaultContextFactory::DestroyOffscreenContext3dForCompositorThread() {
+ test_offscreen_context_compositor_thread_.reset();
+}
+
void DefaultContextFactory::RemoveCompositor(Compositor* compositor) {
}
@@ -521,6 +572,28 @@ scoped_ptr<cc::OutputSurface> Compositor::createOutputSurface() {
void Compositor::didRecreateOutputSurface(bool success) {
}
+WebKit::WebGraphicsContext3D*
+Compositor::OffscreenContext3dForMainThread() {
+ return ContextFactory::GetInstance()->OffscreenContextForMainThread();
+}
+
+WebKit::WebGraphicsContext3D*
+Compositor::OffscreenContext3dForCompositorThread() {
+ return ContextFactory::GetInstance()->OffscreenContextForCompositorThread();
+}
+
+GrContext* Compositor::OffscreenGrContextForMainThread() {
+ return ContextFactory::GetInstance()->OffscreenGrContextForMainThread();
+}
+
+GrContext* Compositor::OffscreenGrContextForCompositorThread() {
+ return ContextFactory::GetInstance()->OffscreenGrContextForCompositorThread();
+}
+
+void Compositor::DestroyOffscreenContext3dForCompositorThread() {
+ ContextFactory::GetInstance()->DestroyOffscreenContext3dForCompositorThread();
+}
+
scoped_ptr<cc::InputHandler> Compositor::createInputHandler() {
return scoped_ptr<cc::InputHandler>();
}

Powered by Google App Engine
This is Rietveld 408576698