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

Unified Diff: android_webview/browser/gl_surface_factory.cc

Issue 22277004: Add gfx::SurfaceFactoryWebview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: null out on detach Created 7 years, 4 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: android_webview/browser/gl_surface_factory.cc
diff --git a/android_webview/browser/gl_surface_factory.cc b/android_webview/browser/gl_surface_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fdcc0dcfdcfea2f729929d0cb011a3a9e220f529
--- /dev/null
+++ b/android_webview/browser/gl_surface_factory.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 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 "android_webview/browser/gl_surface_factory.h"
+
+#include "ui/gl/gl_bindings.h"
+
+namespace android_webview {
+
+namespace {
+// Intentionally leaky.
+GLSurfaceFactory* g_gl_surface_factory = 0;
+} // namespace
+
+// static
+GLSurfaceFactory* GLSurfaceFactory::GetInstance() {
+ if (!g_gl_surface_factory)
+ g_gl_surface_factory = new GLSurfaceFactory;
+ return g_gl_surface_factory;
+}
+
+GLSurfaceFactory::GLSurfaceFactory() {}
+
+GLSurfaceFactory::~GLSurfaceFactory() {}
+
+void GLSurfaceFactory::SetNextCallback(const CreateSurfaceCallback& callback) {
+ create_callback_ = callback;
+}
+
+scoped_refptr<gfx::GLSurface> GLSurfaceFactory::CreateNonOwnedViewSurface() {
+ if (create_callback_.is_null()) {
+ LOG(WARNING) << "Creating on-screen surface not associated with a webview";
+ return NULL;
+ }
+ return create_callback_.Run();
+}
+
+void GLSurfaceFactory::ResetCallback() {
+ create_callback_.Reset();
+}
+
+} // namespace android_webview

Powered by Google App Engine
This is Rietveld 408576698