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

Unified Diff: ui/gl/gl_surface_android.cc

Issue 196403008: gl: Move platform-specific EGL code into separate files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « ui/gl/gl.gyp ('k') | ui/gl/gl_surface_egl.h » ('j') | ui/gl/gl_surface_egl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_surface_android.cc
diff --git a/ui/gl/gl_surface_android.cc b/ui/gl/gl_surface_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..94786b9bb85318d87d6e5958a9ebc15bd932e708
--- /dev/null
+++ b/ui/gl/gl_surface_android.cc
@@ -0,0 +1,84 @@
+// Copyright 2014 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 "ui/gl/gl_surface.h"
+
+#include "base/logging.h"
+#include "base/memory/ref_counted.h"
+#include "third_party/khronos/EGL/egl.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/gl/gl_implementation.h"
+#include "ui/gl/gl_surface_egl.h"
+#include "ui/gl/gl_surface_osmesa.h"
+#include "ui/gl/gl_surface_stub.h"
+
+namespace gfx {
+
+// static
+bool GLSurface::InitializeOneOffInternal() {
+ switch (GetGLImplementation()) {
+ case kGLImplementationEGLGLES2:
+ if (!GLSurfaceEGL::InitializeOneOff(EGL_DEFAULT_DISPLAY)) {
+ LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
+ return false;
+ }
+ default:
+ break;
+ }
+ return true;
+}
+
+// static
+scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
+ gfx::AcceleratedWidget window) {
+
+ if (GetGLImplementation() == kGLImplementationOSMesaGL) {
+ scoped_refptr<GLSurface> surface(new GLSurfaceOSMesaHeadless());
+ if (!surface->Initialize())
+ return NULL;
+ return surface;
+ }
+ DCHECK(GetGLImplementation() == kGLImplementationEGLGLES2);
+ if (window != kNullAcceleratedWidget) {
+ scoped_refptr<GLSurface> surface = new NativeViewGLSurfaceEGL(window);
+ if (surface->Initialize())
+ return surface;
+ } else {
+ scoped_refptr<GLSurface> surface = new GLSurfaceStub();
+ if (surface->Initialize())
+ return surface;
+ }
+ return NULL;
+}
+
+// static
+scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
+ const gfx::Size& size) {
+ switch (GetGLImplementation()) {
+ case kGLImplementationOSMesaGL: {
+ scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(1, size));
+ if (!surface->Initialize())
+ return NULL;
+
+ return surface;
+ }
+ case kGLImplementationEGLGLES2: {
+ scoped_refptr<GLSurface> surface;
+ if (g_egl_surfaceless_context_supported &&
+ (size.width() == 0 && size.height() == 0)) {
+ surface = new SurfacelessEGL(size);
+ } else
rjkroege 2014/03/24 15:27:25 can you put the { in please.
spang 2014/03/24 18:17:08 Haha. Oops.
+ surface = new PbufferGLSurfaceEGL(size);
+
+ if (!surface->Initialize())
+ return NULL;
+ return surface;
+ }
+ default:
+ NOTREACHED();
+ return NULL;
+ }
+}
+
+} // namespace gfx
« no previous file with comments | « ui/gl/gl.gyp ('k') | ui/gl/gl_surface_egl.h » ('j') | ui/gl/gl_surface_egl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698