1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/gl/gl_surface.h"
9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h"
11 #include "ui/gl/android_native_window.h"
12 #include "ui/gl/egl_util.h"
13 #include "ui/gl/gl_bindings.h"
14 #include "ui/gl/gl_context.h"
15 #include "ui/gl/gl_implementation.h"
16 #include "ui/gl/gl_surface_egl.h"
17 #include "ui/gl/gl_surface_stub.h"
19 using ui::GetLastEGLErrorString
;
23 bool GLSurface::InitializeOneOffInternal() {
24 static bool initialized
= false;
28 switch (GetGLImplementation()) {
29 case kGLImplementationEGLGLES2
:
30 if (!GLSurfaceEGL::InitializeOneOff()) {
31 LOG(ERROR
) << "GLSurfaceEGL::InitializeOneOff failed.";
44 scoped_refptr
<GLSurface
>
45 GLSurface::CreateViewGLSurface(bool software
, gfx::AcceleratedWidget window
) {
49 switch (GetGLImplementation()) {
50 case kGLImplementationEGLGLES2
: {
51 scoped_refptr
<GLSurface
> surface
;
53 surface
= new NativeViewGLSurfaceEGL(false, window
);
55 surface
= new GLSurfaceStub();
56 if (!surface
->Initialize())
67 scoped_refptr
<GLSurface
>
68 GLSurface::CreateOffscreenGLSurface(bool software
, const gfx::Size
& size
) {
72 switch (GetGLImplementation()) {
73 case kGLImplementationEGLGLES2
: {
74 scoped_refptr
<PbufferGLSurfaceEGL
> surface(
75 new PbufferGLSurfaceEGL(false, size
));
76 if (!surface
->Initialize())