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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "cc/resources/resource_format.h" 5 #include "cc/resources/resource_format.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/GLES2/gl2.h"
8 #include "third_party/khronos/GLES2/gl2ext.h" 8 #include "third_party/khronos/GLES2/gl2ext.h"
9 9
10 namespace cc { 10 namespace cc {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 GL_BGRA_EXT, // BGRA_8888 56 GL_BGRA_EXT, // BGRA_8888
57 GL_ALPHA, // ALPHA_8 57 GL_ALPHA, // ALPHA_8
58 GL_LUMINANCE, // LUMINANCE_8 58 GL_LUMINANCE, // LUMINANCE_8
59 GL_RGB, // RGB_565 59 GL_RGB, // RGB_565
60 GL_ETC1_RGB8_OES, // ETC1 60 GL_ETC1_RGB8_OES, // ETC1
61 GL_RED_EXT, // RED_8 61 GL_RED_EXT, // RED_8
62 GL_LUMINANCE, // LUMINANCE_F16 62 GL_LUMINANCE, // LUMINANCE_F16
63 }; 63 };
64 static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), 64 static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
65 "format_gl_data_format does not handle all cases."); 65 "format_gl_data_format does not handle all cases.");
66
67 return format_gl_data_format[format]; 66 return format_gl_data_format[format];
68 } 67 }
69 68
70 GLenum GLInternalFormat(ResourceFormat format) { 69 GLenum GLInternalFormat(ResourceFormat format) {
70 // In GLES2, the internal format must match the texture format. (It no longer
71 // is true in GLES3, however it still holds for the BGRA extension.)
71 return GLDataFormat(format); 72 return GLDataFormat(format);
72 } 73 }
73 74
75 GLenum GLCopyTextureInternalFormat(ResourceFormat format) {
76 // In GLES2, valid formats for glCopyTexImage2D are: GL_ALPHA, GL_LUMINANCE,
77 // GL_LUMINANCE_ALPHA, GL_RGB, or GL_RGBA.
78 // Extensions typically used for glTexImage2D do not also work for
79 // glCopyTexImage2D. For instance GL_BGRA_EXT may not be used for
80 // anything but gl(Sub)TexImage2D:
81 // https://www.khronos.org/registry/gles/extensions/EXT/EXT_texture_format_BGR A8888.txt
82 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
83 static const GLenum format_gl_data_format[] = {
84 GL_RGBA, // RGBA_8888
85 GL_RGBA, // RGBA_4444
86 GL_RGBA, // BGRA_8888
87 GL_ALPHA, // ALPHA_8
88 GL_LUMINANCE, // LUMINANCE_8
89 GL_RGB, // RGB_565
90 GL_RGB, // ETC1
91 GL_LUMINANCE, // RED_8
92 GL_LUMINANCE, // LUMINANCE_F16
93 };
94 static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
95 "format_gl_data_format does not handle all cases.");
96 return format_gl_data_format[format];
97 }
98
74 gfx::BufferFormat BufferFormat(ResourceFormat format) { 99 gfx::BufferFormat BufferFormat(ResourceFormat format) {
75 switch (format) { 100 switch (format) {
76 case BGRA_8888: 101 case BGRA_8888:
77 return gfx::BufferFormat::BGRA_8888; 102 return gfx::BufferFormat::BGRA_8888;
78 case RED_8: 103 case RED_8:
79 return gfx::BufferFormat::R_8; 104 return gfx::BufferFormat::R_8;
80 case RGBA_4444: 105 case RGBA_4444:
81 return gfx::BufferFormat::RGBA_4444; 106 return gfx::BufferFormat::RGBA_4444;
82 case RGBA_8888: 107 case RGBA_8888:
83 return gfx::BufferFormat::RGBA_8888; 108 return gfx::BufferFormat::RGBA_8888;
(...skipping 25 matching lines...) Expand all
109 case ETC1: 134 case ETC1:
110 case RED_8: 135 case RED_8:
111 case LUMINANCE_F16: 136 case LUMINANCE_F16:
112 return false; 137 return false;
113 } 138 }
114 NOTREACHED(); 139 NOTREACHED();
115 return false; 140 return false;
116 } 141 }
117 142
118 } // namespace cc 143 } // namespace cc
OLDNEW
« 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