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

Side by Side Diff: ui/gl/gl_image_io_surface.mm

Issue 1708263002: gpu: Expose internal format R8 instead of RED. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ResourceProvider should use R8 too. Created 4 years, 10 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
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 "ui/gl/gl_image_io_surface.h" 5 #include "ui/gl/gl_image_io_surface.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/strings/stringize_macros.h" 11 #include "base/strings/stringize_macros.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/trace_event/memory_allocator_dump.h" 13 #include "base/trace_event/memory_allocator_dump.h"
14 #include "base/trace_event/memory_dump_manager.h" 14 #include "base/trace_event/memory_dump_manager.h"
15 #include "base/trace_event/process_memory_dump.h" 15 #include "base/trace_event/process_memory_dump.h"
16 #include "ui/gl/gl_bindings.h" 16 #include "ui/gl/gl_bindings.h"
17 #include "ui/gl/gl_context.h" 17 #include "ui/gl/gl_context.h"
18 #include "ui/gl/gl_helper.h" 18 #include "ui/gl/gl_helper.h"
19 #include "ui/gl/gl_version_info.h"
19 #include "ui/gl/scoped_binders.h" 20 #include "ui/gl/scoped_binders.h"
20 21
21 // Note that this must be included after gl_bindings.h to avoid conflicts. 22 // Note that this must be included after gl_bindings.h to avoid conflicts.
22 #include <OpenGL/CGLIOSurface.h> 23 #include <OpenGL/CGLIOSurface.h>
23 #include <Quartz/Quartz.h> 24 #include <Quartz/Quartz.h>
24 #include <stddef.h> 25 #include <stddef.h>
25 26
26 using gfx::BufferFormat; 27 using gfx::BufferFormat;
27 28
28 namespace gl { 29 namespace gl {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 vec3 yuv = vec3( 62 vec3 yuv = vec3(
62 texture2DRect(a_y_texture, v_texCoord).r, 63 texture2DRect(a_y_texture, v_texCoord).r,
63 texture2DRect(a_uv_texture, v_texCoord * 0.5).rg); 64 texture2DRect(a_uv_texture, v_texCoord * 0.5).rg);
64 gl_FragColor = vec4(yuv_matrix * (yuv + yuv_adj), 1.0); 65 gl_FragColor = vec4(yuv_matrix * (yuv + yuv_adj), 1.0);
65 } 66 }
66 ); 67 );
67 // clang-format on 68 // clang-format on
68 69
69 bool ValidInternalFormat(unsigned internalformat) { 70 bool ValidInternalFormat(unsigned internalformat) {
70 switch (internalformat) { 71 switch (internalformat) {
71 case GL_RED: 72 case GL_R8:
72 case GL_BGRA_EXT: 73 case GL_BGRA_EXT:
73 case GL_RGB: 74 case GL_RGB:
74 case GL_RGB_YCBCR_420V_CHROMIUM: 75 case GL_RGB_YCBCR_420V_CHROMIUM:
75 case GL_RGB_YCBCR_422_CHROMIUM: 76 case GL_RGB_YCBCR_422_CHROMIUM:
76 case GL_RGBA: 77 case GL_RGBA:
77 return true; 78 return true;
78 default: 79 default:
79 return false; 80 return false;
80 } 81 }
81 } 82 }
(...skipping 17 matching lines...) Expand all
99 case BufferFormat::YUV_420: 100 case BufferFormat::YUV_420:
100 return false; 101 return false;
101 } 102 }
102 103
103 NOTREACHED(); 104 NOTREACHED();
104 return false; 105 return false;
105 } 106 }
106 107
107 GLenum TextureFormat(BufferFormat format) { 108 GLenum TextureFormat(BufferFormat format) {
108 switch (format) { 109 switch (format) {
109 case BufferFormat::R_8: 110 case BufferFormat::R_8: {
110 return GL_RED; 111 const gfx::GLVersionInfo* version_info =
reveman 2016/02/20 01:07:55 Can this case be implemented this way? return gfx
Daniele Castagna 2016/02/20 01:16:16 Done.
112 gfx::GLContext::GetCurrent()->GetVersionInfo();
113 if (version_info->IsAtLeastGL(3, 0) ||
114 version_info->IsAtLeastGLES(3, 0)) {
115 return GL_R8;
116 } else {
117 return GL_RED;
118 }
119 }
111 case BufferFormat::BGRA_8888: 120 case BufferFormat::BGRA_8888:
112 case BufferFormat::RGBA_8888: 121 case BufferFormat::RGBA_8888:
113 return GL_RGBA; 122 return GL_RGBA;
114 case BufferFormat::UYVY_422: 123 case BufferFormat::UYVY_422:
115 return GL_RGB; 124 return GL_RGB;
116 case BufferFormat::YUV_420_BIPLANAR: 125 case BufferFormat::YUV_420_BIPLANAR:
117 return GL_RGB_YCBCR_420V_CHROMIUM; 126 return GL_RGB_YCBCR_420V_CHROMIUM;
118 case BufferFormat::ATC: 127 case BufferFormat::ATC:
119 case BufferFormat::ATCIA: 128 case BufferFormat::ATCIA:
120 case BufferFormat::DXT1: 129 case BufferFormat::DXT1:
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 g_widget_to_layer_map.Pointer()->erase(widget); 427 g_widget_to_layer_map.Pointer()->erase(widget);
419 } 428 }
420 429
421 // static 430 // static
422 unsigned GLImageIOSurface::GetInternalFormatForTesting( 431 unsigned GLImageIOSurface::GetInternalFormatForTesting(
423 gfx::BufferFormat format) { 432 gfx::BufferFormat format) {
424 DCHECK(ValidFormat(format)); 433 DCHECK(ValidFormat(format));
425 return TextureFormat(format); 434 return TextureFormat(format);
426 } 435 }
427 } // namespace gl 436 } // namespace gl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698