Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gl/gl_surface.h" | 5 #include "ui/gl/gl_surface.h" |
| 6 | 6 |
| 7 #include <EGL/egl.h> | |
| 8 | |
| 9 #include "base/logging.h" | 7 #include "base/logging.h" |
| 10 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "ui/base/ozone/surface_factory_ozone.h" | |
|
rjkroege
2013/05/17 22:17:06
I'm not convinced that this file is worth refactor
piman
2013/05/18 01:47:19
TBH, with the suggested change to pass the VSyncPr
rjkroege
2013/05/21 17:36:28
Done.
| |
| 11 #include "ui/gl/egl_util.h" | 10 #include "ui/gl/egl_util.h" |
| 12 #include "ui/gl/gl_bindings.h" | 11 #include "ui/gl/gl_bindings.h" |
| 13 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
| 14 #include "ui/gl/gl_implementation.h" | 13 #include "ui/gl/gl_implementation.h" |
| 15 #include "ui/gl/gl_surface_egl.h" | 14 #include "ui/gl/gl_surface_egl.h" |
| 16 #include "ui/gl/gl_surface_stub.h" | 15 #include "ui/gl/gl_surface_stub.h" |
| 17 | 16 |
| 18 using ui::GetLastEGLErrorString; | 17 using ui::GetLastEGLErrorString; |
| 19 | 18 |
| 20 namespace gfx { | 19 namespace gfx { |
| 21 | 20 |
| 22 bool GLSurface::InitializeOneOffInternal() { | 21 bool GLSurface::InitializeOneOffInternal() { |
| 23 static bool initialized = false; | 22 static bool initialized = false; |
| 24 if (initialized) | 23 if (initialized) |
| 25 return true; | 24 return true; |
| 26 | 25 |
| 27 switch (GetGLImplementation()) { | 26 switch (GetGLImplementation()) { |
| 28 case kGLImplementationEGLGLES2: | 27 case kGLImplementationEGLGLES2: |
| 28 ui::SurfaceFactory::GetInstance()->InitializeHardware(); | |
| 29 if (!GLSurfaceEGL::InitializeOneOff()) { | 29 if (!GLSurfaceEGL::InitializeOneOff()) { |
| 30 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; | 30 LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed."; |
| 31 return false; | 31 return false; |
| 32 } | 32 } |
| 33 break; | 33 break; |
| 34 default: | 34 default: |
| 35 NOTREACHED(); | 35 NOTREACHED(); |
| 36 break; | 36 break; |
| 37 } | 37 } |
| 38 | 38 |
| 39 initialized = true; | 39 initialized = true; |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| 42 | |
| 42 // static | 43 // static |
| 43 scoped_refptr<GLSurface> | 44 scoped_refptr<GLSurface> |
| 44 GLSurface::CreateViewGLSurface(bool software, gfx::AcceleratedWidget window) { | 45 GLSurface::CreateViewGLSurface(bool software, gfx::AcceleratedWidget window) { |
| 45 if (software) | 46 if (software) |
| 46 return NULL; | 47 return NULL; |
| 47 | 48 |
| 48 switch (GetGLImplementation()) { | 49 switch (GetGLImplementation()) { |
| 49 case kGLImplementationEGLGLES2: { | 50 case kGLImplementationEGLGLES2: { |
| 50 scoped_refptr<GLSurface> surface; | 51 scoped_refptr<GLSurface> surface; |
| 51 if (window) | 52 if (window) |
| 52 surface = new NativeViewGLSurfaceEGL(false, window); | 53 surface = new NativeViewGLSurfaceEGL(false, window); |
| 53 else | 54 else |
| 54 surface = new GLSurfaceStub(); | 55 surface = new GLSurfaceStub(); |
| 55 if (!surface->Initialize()) | 56 bool success; |
| 57 if (GLSurfaceEGL::IsSyncControlSupported()) { | |
| 58 success = surface->Initialize(); | |
| 59 } else { | |
| 60 VSyncProvider* sync_provider = | |
| 61 ui::SurfaceFactory::GetInstance()->GetVSyncProvider(window); | |
| 62 success = surface->Initialize(sync_provider); | |
| 63 } | |
| 64 if (!success) | |
| 56 return NULL; | 65 return NULL; |
| 57 return surface; | 66 return surface; |
| 58 } | 67 } |
| 59 default: | 68 default: |
| 60 NOTREACHED(); | 69 NOTREACHED(); |
| 61 return NULL; | 70 return NULL; |
| 62 } | 71 } |
| 63 } | 72 } |
| 64 | 73 |
| 65 // static | 74 // static |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 76 return NULL; | 85 return NULL; |
| 77 return surface; | 86 return surface; |
| 78 } | 87 } |
| 79 default: | 88 default: |
| 80 NOTREACHED(); | 89 NOTREACHED(); |
| 81 return NULL; | 90 return NULL; |
| 82 } | 91 } |
| 83 } | 92 } |
| 84 | 93 |
| 85 } // namespace gfx | 94 } // namespace gfx |
| OLD | NEW |