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

Unified Diff: cc/resources/resource_format.cc

Issue 2089753003: cc: Use the correct internal format for glCopyTexImage2D calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copytextureformat: comments Created 4 years, 6 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 | « cc/resources/resource_format.h ('k') | cc/surfaces/surface_display_output_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_format.cc
diff --git a/cc/resources/resource_format.cc b/cc/resources/resource_format.cc
index 2eae8307355c7db49bb63febaf2084b81fb62f89..9a47c7e380df9ccd09ad6a31542f4480a9c9b095 100644
--- a/cc/resources/resource_format.cc
+++ b/cc/resources/resource_format.cc
@@ -63,14 +63,39 @@ GLenum GLDataFormat(ResourceFormat format) {
};
static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
"format_gl_data_format does not handle all cases.");
-
return format_gl_data_format[format];
}
GLenum GLInternalFormat(ResourceFormat format) {
+ // In GLES2, the internal format must match the texture format. (It no longer
+ // is true in GLES3, however it still holds for the BGRA extension.)
return GLDataFormat(format);
}
+GLenum GLCopyTextureInternalFormat(ResourceFormat format) {
+ // In GLES2, valid formats for glCopyTexImage2D are: GL_ALPHA, GL_LUMINANCE,
+ // GL_LUMINANCE_ALPHA, GL_RGB, or GL_RGBA.
+ // Extensions typically used for glTexImage2D do not also work for
+ // glCopyTexImage2D. For instance GL_BGRA_EXT may not be used for
+ // anything but gl(Sub)TexImage2D:
+ // https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_format_BGRA8888.txt
+ DCHECK_LE(format, RESOURCE_FORMAT_MAX);
+ static const GLenum format_gl_data_format[] = {
+ GL_RGBA, // RGBA_8888
+ GL_RGBA, // RGBA_4444
+ GL_RGBA, // BGRA_8888
+ GL_ALPHA, // ALPHA_8
+ GL_LUMINANCE, // LUMINANCE_8
+ GL_RGB, // RGB_565
+ GL_RGB, // ETC1
+ GL_LUMINANCE, // RED_8
+ GL_LUMINANCE, // LUMINANCE_F16
+ };
+ static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
+ "format_gl_data_format does not handle all cases.");
+ return format_gl_data_format[format];
+}
+
gfx::BufferFormat BufferFormat(ResourceFormat format) {
switch (format) {
case BGRA_8888:
« no previous file with comments | « cc/resources/resource_format.h ('k') | cc/surfaces/surface_display_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698