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

Unified Diff: ui/gl/gl_gl_api_implementation.cc

Issue 14902003: Move WrappedTexImage functionality to ui/gl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 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_gl_api_implementation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_gl_api_implementation.cc
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index 303ae1d1f8aa4f82aba7497f8d72c62c616aef1f..b8d8c5c6b3057ea5fe5d687b4d5820a43bb39407 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/string_util.h"
#include "ui/gl/gl_context.h"
+#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_state_restorer.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h"
@@ -99,6 +100,105 @@ void RealGLApi::Initialize(DriverGL* driver) {
InitializeBase(driver);
}
+static inline GLenum GetTexInternalFormat(GLenum internal_format) {
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
+ if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT)
+ return GL_RGBA8;
+ }
+ return internal_format;
+}
+
+// TODO(epenner): Could the above function be merged into this and removed?
+static inline GLenum GetTexInternalFormat(GLenum internal_format,
+ GLenum format,
+ GLenum type) {
+ GLenum gl_internal_format = GetTexInternalFormat(internal_format);
+
+ if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
+ return gl_internal_format;
+
+ if (type == GL_FLOAT) {
+ switch (format) {
+ case GL_RGBA:
+ gl_internal_format = GL_RGBA32F_ARB;
+ break;
+ case GL_RGB:
+ gl_internal_format = GL_RGB32F_ARB;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ gl_internal_format = GL_LUMINANCE_ALPHA32F_ARB;
+ break;
+ case GL_LUMINANCE:
+ gl_internal_format = GL_LUMINANCE32F_ARB;
+ break;
+ case GL_ALPHA:
+ gl_internal_format = GL_ALPHA32F_ARB;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ } else if (type == GL_HALF_FLOAT_OES) {
+ switch (format) {
+ case GL_RGBA:
+ gl_internal_format = GL_RGBA16F_ARB;
+ break;
+ case GL_RGB:
+ gl_internal_format = GL_RGB16F_ARB;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ gl_internal_format = GL_LUMINANCE_ALPHA16F_ARB;
+ break;
+ case GL_LUMINANCE:
+ gl_internal_format = GL_LUMINANCE16F_ARB;
+ break;
+ case GL_ALPHA:
+ gl_internal_format = GL_ALPHA16F_ARB;
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ }
+ return gl_internal_format;
+}
+
+static inline GLenum GetTexType(GLenum type) {
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
+ if (type == GL_HALF_FLOAT_OES)
+ return GL_HALF_FLOAT_ARB;
+ }
+ return type;
+}
+
+void RealGLApi::glTexImage2DFn(
+ GLenum target, GLint level, GLint internalformat,
+ GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type,
+ const void* pixels) {
+ GLenum gl_internal_format = GetTexInternalFormat(
+ internalformat, format, type);
+ GLenum gl_type = GetTexType(type);
+ return driver_->fn.glTexImage2DFn(
+ target, level, gl_internal_format, width, height, border, format, gl_type,
+ pixels);
+}
+
+void RealGLApi::glTexSubImage2DFn(
+ GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
+ GLsizei height, GLenum format, GLenum type, const void* pixels) {
+ GLenum gl_type = GetTexType(type);
+ return driver_->fn.glTexSubImage2DFn(
+ target, level, xoffset, yoffset, width, height, format, gl_type, pixels);
+}
+
+void RealGLApi::glTexStorage2DEXTFn(
+ GLenum target, GLsizei levels, GLenum internalformat, GLsizei width,
+ GLsizei height) {
+ GLenum gl_internal_format = GetTexInternalFormat(internalformat);
+ return driver_->fn.glTexStorage2DEXTFn(
+ target, levels, gl_internal_format, width, height);
+}
+
TraceGLApi::~TraceGLApi() {
}
« no previous file with comments | « ui/gl/gl_gl_api_implementation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698