| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "ui/gl/gl_surface.h" | |
| 6 | |
| 7 #include <EGL/egl.h> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/memory/ref_counted.h" | |
| 11 #include "ui/gl/egl_util.h" | |
| 12 #include "ui/gl/gl_bindings.h" | |
| 13 #include "ui/gl/gl_context.h" | |
| 14 #include "ui/gl/gl_implementation.h" | |
| 15 #include "ui/gl/gl_surface_egl.h" | |
| 16 #include "ui/gl/gl_surface_stub.h" | |
| 17 | |
| 18 using ui::GetLastEGLErrorString; | |
| 19 | |
| 20 namespace gfx { | |
| 21 | |
| 22 bool GLSurface::InitializeOneOffInternal() { | |
| 23 static bool initialized = false; | |
| 24 if (initialized) | |
| 25 return true; | |
| 26 | |
| 27 switch (GetGLImplementation()) { | |
| 28 case kGLImplementationEGLGLES2: | |
| 29 if (!GLSurfaceEGL::InitializeOneOff()) { | |
| 30 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | |
| 31 return false; | |
| 32 } | |
| 33 break; | |
| 34 default: | |
| 35 NOTREACHED(); | |
| 36 break; | |
| 37 } | |
| 38 | |
| 39 initialized = true; | |
| 40 return true; | |
| 41 } | |
| 42 // static | |
| 43 scoped_refptr<GLSurface> | |
| 44 GLSurface::CreateViewGLSurface(bool software, gfx::AcceleratedWidget window) { | |
| 45 if (software) | |
| 46 return NULL; | |
| 47 | |
| 48 switch (GetGLImplementation()) { | |
| 49 case kGLImplementationEGLGLES2: { | |
| 50 scoped_refptr<GLSurface> surface; | |
| 51 if (window) | |
| 52 surface = new NativeViewGLSurfaceEGL(false, window); | |
| 53 else | |
| 54 surface = new GLSurfaceStub(); | |
| 55 if (!surface->Initialize()) | |
| 56 return NULL; | |
| 57 return surface; | |
| 58 } | |
| 59 default: | |
| 60 NOTREACHED(); | |
| 61 return NULL; | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 // static | |
| 66 scoped_refptr<GLSurface> | |
| 67 GLSurface::CreateOffscreenGLSurface(bool software, const gfx::Size& size) { | |
| 68 if (software) | |
| 69 return NULL; | |
| 70 | |
| 71 switch (GetGLImplementation()) { | |
| 72 case kGLImplementationEGLGLES2: { | |
| 73 scoped_refptr<PbufferGLSurfaceEGL> surface( | |
| 74 new PbufferGLSurfaceEGL(false, size)); | |
| 75 if (!surface->Initialize()) | |
| 76 return NULL; | |
| 77 return surface; | |
| 78 } | |
| 79 default: | |
| 80 NOTREACHED(); | |
| 81 return NULL; | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 } // namespace gfx | |
| OLD | NEW |