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

Side by Side Diff: ui/gl/gl_image_memory.cc

Issue 1741513002: Revert of gpu: Expose internal format R8 instead of RED. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « ui/gl/gl_image_io_surface.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_image_memory.h" 5 #include "ui/gl/gl_image_memory.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "ui/gfx/buffer_format_util.h" 12 #include "ui/gfx/buffer_format_util.h"
13 #include "ui/gl/gl_bindings.h" 13 #include "ui/gl/gl_bindings.h"
14 #include "ui/gl/gl_context.h" 14 #include "ui/gl/gl_context.h"
15 #include "ui/gl/gl_version_info.h" 15 #include "ui/gl/gl_version_info.h"
16 16
17 using gfx::BufferFormat; 17 using gfx::BufferFormat;
18 18
19 namespace gl { 19 namespace gl {
20 namespace { 20 namespace {
21 21
22 bool ValidInternalFormat(unsigned internalformat) { 22 bool ValidInternalFormat(unsigned internalformat) {
23 switch (internalformat) { 23 switch (internalformat) {
24 case GL_ATC_RGB_AMD: 24 case GL_ATC_RGB_AMD:
25 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: 25 case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
26 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: 26 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
27 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: 27 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
28 case GL_ETC1_RGB8_OES: 28 case GL_ETC1_RGB8_OES:
29 case GL_R8: 29 case GL_RED:
30 case GL_RGB: 30 case GL_RGB:
31 case GL_RGBA: 31 case GL_RGBA:
32 case GL_BGRA_EXT: 32 case GL_BGRA_EXT:
33 return true; 33 return true;
34 default: 34 default:
35 return false; 35 return false;
36 } 36 }
37 } 37 }
38 38
39 bool ValidFormat(BufferFormat format) { 39 bool ValidFormat(BufferFormat format) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return GL_ATC_RGB_AMD; 92 return GL_ATC_RGB_AMD;
93 case BufferFormat::ATCIA: 93 case BufferFormat::ATCIA:
94 return GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD; 94 return GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD;
95 case BufferFormat::DXT1: 95 case BufferFormat::DXT1:
96 return GL_COMPRESSED_RGB_S3TC_DXT1_EXT; 96 return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
97 case BufferFormat::DXT5: 97 case BufferFormat::DXT5:
98 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; 98 return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
99 case BufferFormat::ETC1: 99 case BufferFormat::ETC1:
100 return GL_ETC1_RGB8_OES; 100 return GL_ETC1_RGB8_OES;
101 case BufferFormat::R_8: 101 case BufferFormat::R_8:
102 return gfx::GLContext::GetCurrent()->GetVersionInfo()->IsES3Capable() 102 return GL_RED;
103 ? GL_R8
104 : GL_RED;
105 case BufferFormat::RGBA_4444: 103 case BufferFormat::RGBA_4444:
106 case BufferFormat::RGBA_8888: 104 case BufferFormat::RGBA_8888:
107 return GL_RGBA; 105 return GL_RGBA;
108 case BufferFormat::BGRA_8888: 106 case BufferFormat::BGRA_8888:
109 return GL_BGRA_EXT; 107 return GL_BGRA_EXT;
110 case BufferFormat::RGBX_8888: 108 case BufferFormat::RGBX_8888:
111 case BufferFormat::BGRX_8888: 109 case BufferFormat::BGRX_8888:
112 return GL_RGB; 110 return GL_RGB;
113 case BufferFormat::YUV_420: 111 case BufferFormat::YUV_420:
114 case BufferFormat::YUV_420_BIPLANAR: 112 case BufferFormat::YUV_420_BIPLANAR:
115 case BufferFormat::UYVY_422: 113 case BufferFormat::UYVY_422:
116 NOTREACHED(); 114 NOTREACHED();
117 return 0; 115 return 0;
118 } 116 }
119 117
120 NOTREACHED(); 118 NOTREACHED();
121 return 0; 119 return 0;
122 } 120 }
123 121
124 GLenum DataFormat(BufferFormat format) { 122 GLenum DataFormat(BufferFormat format) {
125 switch (format) { 123 switch (format) {
126 case BufferFormat::RGBX_8888: 124 case BufferFormat::RGBX_8888:
127 return GL_RGBA; 125 return GL_RGBA;
128 case BufferFormat::BGRX_8888: 126 case BufferFormat::BGRX_8888:
129 return GL_BGRA_EXT; 127 return GL_BGRA_EXT;
130 case BufferFormat::R_8:
131 return GL_RED;
132 case BufferFormat::RGBA_4444: 128 case BufferFormat::RGBA_4444:
133 case BufferFormat::RGBA_8888: 129 case BufferFormat::RGBA_8888:
134 case BufferFormat::BGRA_8888: 130 case BufferFormat::BGRA_8888:
131 case BufferFormat::R_8:
135 case BufferFormat::ATC: 132 case BufferFormat::ATC:
136 case BufferFormat::ATCIA: 133 case BufferFormat::ATCIA:
137 case BufferFormat::DXT1: 134 case BufferFormat::DXT1:
138 case BufferFormat::DXT5: 135 case BufferFormat::DXT5:
139 case BufferFormat::ETC1: 136 case BufferFormat::ETC1:
140 return TextureFormat(format); 137 return TextureFormat(format);
141 case BufferFormat::YUV_420: 138 case BufferFormat::YUV_420:
142 case BufferFormat::YUV_420_BIPLANAR: 139 case BufferFormat::YUV_420_BIPLANAR:
143 case BufferFormat::UYVY_422: 140 case BufferFormat::UYVY_422:
144 NOTREACHED(); 141 NOTREACHED();
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 return false; 444 return false;
448 } 445 }
449 446
450 // static 447 // static
451 unsigned GLImageMemory::GetInternalFormatForTesting(BufferFormat format) { 448 unsigned GLImageMemory::GetInternalFormatForTesting(BufferFormat format) {
452 DCHECK(ValidFormat(format)); 449 DCHECK(ValidFormat(format));
453 return TextureFormat(format); 450 return TextureFormat(format);
454 } 451 }
455 452
456 } // namespace gl 453 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_image_io_surface.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698