| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_gl_api_implementation.h" | 5 #include "ui/gl/gl_gl_api_implementation.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 | 119 |
| 120 static void GL_BINDING_CALL CustomTexStorage2DEXT( | 120 static void GL_BINDING_CALL CustomTexStorage2DEXT( |
| 121 GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, | 121 GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, |
| 122 GLsizei height) { | 122 GLsizei height) { |
| 123 GLenum gl_internal_format = GetTexInternalFormat(internalformat); | 123 GLenum gl_internal_format = GetTexInternalFormat(internalformat); |
| 124 return g_driver_gl.orig_fn.glTexStorage2DEXTFn( | 124 return g_driver_gl.orig_fn.glTexStorage2DEXTFn( |
| 125 target, levels, gl_internal_format, width, height); | 125 target, levels, gl_internal_format, width, height); |
| 126 } | 126 } |
| 127 | 127 |
| 128 static void GL_BINDING_CALL CustomReadPixels( |
| 129 GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, |
| 130 GLenum type, void* pixels) { |
| 131 GLenum gl_type = GetTexType(type); |
| 132 return g_driver_gl.orig_fn.glReadPixelsFn( |
| 133 x, y, width, height, format, gl_type, pixels); |
| 134 } |
| 135 |
| 128 } // anonymous namespace | 136 } // anonymous namespace |
| 129 | 137 |
| 130 void DriverGL::Initialize() { | 138 void DriverGL::Initialize() { |
| 131 InitializeBindings(); | 139 InitializeBindings(); |
| 132 } | 140 } |
| 133 | 141 |
| 134 void DriverGL::InitializeExtensions(GLContext* context) { | 142 void DriverGL::InitializeExtensions(GLContext* context) { |
| 135 InitializeExtensionBindings(context); | 143 InitializeExtensionBindings(context); |
| 136 orig_fn = fn; | 144 orig_fn = fn; |
| 137 fn.glTexImage2DFn = | 145 fn.glTexImage2DFn = |
| 138 reinterpret_cast<glTexImage2DProc>(CustomTexImage2D); | 146 reinterpret_cast<glTexImage2DProc>(CustomTexImage2D); |
| 139 fn.glTexSubImage2DFn = | 147 fn.glTexSubImage2DFn = |
| 140 reinterpret_cast<glTexSubImage2DProc>(CustomTexSubImage2D); | 148 reinterpret_cast<glTexSubImage2DProc>(CustomTexSubImage2D); |
| 141 fn.glTexStorage2DEXTFn = | 149 fn.glTexStorage2DEXTFn = |
| 142 reinterpret_cast<glTexStorage2DEXTProc>(CustomTexStorage2DEXT); | 150 reinterpret_cast<glTexStorage2DEXTProc>(CustomTexStorage2DEXT); |
| 151 fn.glReadPixelsFn = |
| 152 reinterpret_cast<glReadPixelsProc>(CustomReadPixels); |
| 143 } | 153 } |
| 144 | 154 |
| 145 void InitializeGLBindingsGL() { | 155 void InitializeGLBindingsGL() { |
| 146 g_driver_gl.Initialize(); | 156 g_driver_gl.Initialize(); |
| 147 if (!g_real_gl) { | 157 if (!g_real_gl) { |
| 148 g_real_gl = new RealGLApi(); | 158 g_real_gl = new RealGLApi(); |
| 149 g_trace_gl = new TraceGLApi(g_real_gl); | 159 g_trace_gl = new TraceGLApi(g_real_gl); |
| 150 } | 160 } |
| 151 g_real_gl->Initialize(&g_driver_gl); | 161 g_real_gl->Initialize(&g_driver_gl); |
| 152 g_gl = g_real_gl; | 162 g_gl = g_real_gl; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { | 316 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { |
| 307 switch (name) { | 317 switch (name) { |
| 308 case GL_EXTENSIONS: | 318 case GL_EXTENSIONS: |
| 309 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); | 319 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); |
| 310 default: | 320 default: |
| 311 return driver_->fn.glGetStringFn(name); | 321 return driver_->fn.glGetStringFn(name); |
| 312 } | 322 } |
| 313 } | 323 } |
| 314 | 324 |
| 315 } // namespace gfx | 325 } // namespace gfx |
| OLD | NEW |