OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/yuv_to_rgb_converter.h" | 5 #include "ui/gl/yuv_to_rgb_converter.h" |
6 | 6 |
7 #include "base/strings/stringize_macros.h" | 7 #include "base/strings/stringize_macros.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "ui/gl/gl_helper.h" | 9 #include "ui/gl/gl_helper.h" |
10 #include "ui/gl/gl_implementation.h" | 10 #include "ui/gl/gl_version_info.h" |
11 #include "ui/gl/scoped_api.h" | 11 #include "ui/gl/scoped_api.h" |
12 #include "ui/gl/scoped_binders.h" | 12 #include "ui/gl/scoped_binders.h" |
13 | 13 |
14 namespace gl { | 14 namespace gl { |
15 namespace { | 15 namespace { |
16 | 16 |
17 const char kVertexHeaderCompatiblityProfile[] = | 17 const char kVertexHeaderCompatiblityProfile[] = |
18 "#version 110\n" | 18 "#version 110\n" |
19 "#define ATTRIBUTE attribute\n" | 19 "#define ATTRIBUTE attribute\n" |
20 "#define VARYING varying\n"; | 20 "#define VARYING varying\n"; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 vec3 yuv = vec3( | 63 vec3 yuv = vec3( |
64 TEX(a_y_texture, v_texCoord).r, | 64 TEX(a_y_texture, v_texCoord).r, |
65 TEX(a_uv_texture, v_texCoord * 0.5).rg); | 65 TEX(a_uv_texture, v_texCoord * 0.5).rg); |
66 FRAGCOLOR = vec4(yuv_matrix * (yuv + yuv_adj), 1.0); | 66 FRAGCOLOR = vec4(yuv_matrix * (yuv + yuv_adj), 1.0); |
67 } | 67 } |
68 ); | 68 ); |
69 // clang-format on | 69 // clang-format on |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 YUVToRGBConverter::YUVToRGBConverter() { | 73 YUVToRGBConverter::YUVToRGBConverter(const GLVersionInfo& gl_version_info) { |
74 bool use_core_profile = | 74 bool use_core_profile = gl_version_info.is_desktop_core_profile; |
75 GetGLImplementation() == kGLImplementationDesktopGLCoreProfile; | |
76 ScopedSetGLToRealGLApi scoped_set_gl_api; | 75 ScopedSetGLToRealGLApi scoped_set_gl_api; |
77 glGenFramebuffersEXT(1, &framebuffer_); | 76 glGenFramebuffersEXT(1, &framebuffer_); |
78 vertex_buffer_ = GLHelper::SetupQuadVertexBuffer(); | 77 vertex_buffer_ = GLHelper::SetupQuadVertexBuffer(); |
79 vertex_shader_ = GLHelper::LoadShader( | 78 vertex_shader_ = GLHelper::LoadShader( |
80 GL_VERTEX_SHADER, | 79 GL_VERTEX_SHADER, |
81 base::StringPrintf("%s\n%s", | 80 base::StringPrintf("%s\n%s", |
82 use_core_profile ? kVertexHeaderCoreProfile | 81 use_core_profile ? kVertexHeaderCoreProfile |
83 : kVertexHeaderCompatiblityProfile, | 82 : kVertexHeaderCompatiblityProfile, |
84 kVertexShader) | 83 kVertexShader) |
85 .c_str()); | 84 .c_str()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 157 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
159 target, 0, 0); | 158 target, 0, 0); |
160 glActiveTexture(GL_TEXTURE0); | 159 glActiveTexture(GL_TEXTURE0); |
161 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture0_binding); | 160 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture0_binding); |
162 glActiveTexture(GL_TEXTURE1); | 161 glActiveTexture(GL_TEXTURE1); |
163 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture1_binding); | 162 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture1_binding); |
164 glActiveTexture(old_active_texture); | 163 glActiveTexture(old_active_texture); |
165 } | 164 } |
166 | 165 |
167 } // namespace gl | 166 } // namespace gl |
OLD | NEW |