OLD | NEW |
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 Loading... |
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 18 matching lines...) Expand all Loading... |
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 return gfx::GLContext::GetCurrent()->GetVersionInfo()->IsES3Capable() |
| 112 ? GL_R8 |
| 113 : GL_RED; |
111 case BufferFormat::BGRA_8888: | 114 case BufferFormat::BGRA_8888: |
112 case BufferFormat::RGBA_8888: | 115 case BufferFormat::RGBA_8888: |
113 return GL_RGBA; | 116 return GL_RGBA; |
114 case BufferFormat::UYVY_422: | 117 case BufferFormat::UYVY_422: |
115 return GL_RGB; | 118 return GL_RGB; |
116 case BufferFormat::YUV_420_BIPLANAR: | 119 case BufferFormat::YUV_420_BIPLANAR: |
117 return GL_RGB_YCBCR_420V_CHROMIUM; | 120 return GL_RGB_YCBCR_420V_CHROMIUM; |
118 case BufferFormat::ATC: | 121 case BufferFormat::ATC: |
119 case BufferFormat::ATCIA: | 122 case BufferFormat::ATCIA: |
120 case BufferFormat::DXT1: | 123 case BufferFormat::DXT1: |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 g_widget_to_layer_map.Pointer()->erase(widget); | 421 g_widget_to_layer_map.Pointer()->erase(widget); |
419 } | 422 } |
420 | 423 |
421 // static | 424 // static |
422 unsigned GLImageIOSurface::GetInternalFormatForTesting( | 425 unsigned GLImageIOSurface::GetInternalFormatForTesting( |
423 gfx::BufferFormat format) { | 426 gfx::BufferFormat format) { |
424 DCHECK(ValidFormat(format)); | 427 DCHECK(ValidFormat(format)); |
425 return TextureFormat(format); | 428 return TextureFormat(format); |
426 } | 429 } |
427 } // namespace gl | 430 } // namespace gl |
OLD | NEW |