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

Unified Diff: cc/grcontext_provider.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: cc/grcontext_provider.cc
diff --git a/cc/grcontext_provider.cc b/cc/grcontext_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8b7ea7647272ed96afef437ceee0a8fbdee651a8
--- /dev/null
+++ b/cc/grcontext_provider.cc
@@ -0,0 +1,42 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/grcontext_provider.h"
+
+#include "cc/resource_provider.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
+#include "third_party/skia/include/gpu/GrContext.h"
+
+namespace cc {
+
+GrContextProvider::GrContextProvider(ResourceProvider* resource_provider)
+ : resource_provider_(resource_provider),
+ context3d_(NULL),
+ gr_context_(NULL) {
+}
+
+GrContextProvider::~GrContextProvider() {}
+
+void GrContextProvider::BeginUsingContexts() {
+ // Flush the compositor context to ensure that textures there are available
+ // in the shared context.
+ resource_provider_->flush();
+
+ // Make sure ganesh uses the correct GL context.
+ if (context3d())
+ context3d()->makeContextCurrent();
+}
+
+void GrContextProvider::FinishUsingContexts() {
+ // Flush ganesh context so that all the rendered stuff appears on the
+ // texture.
+ if (gr_context())
+ gr_context()->flush();
+ // Flush the GL context so rendering results from this context are
+ // visible in the compositor's context.
+ if (context3d())
+ context3d()->flush();
+}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698