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

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

Issue 2144423003: Mac h264: Add GLImage copy support for non-rectangle targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 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_implementation.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 glDeleteProgram(program_); 114 glDeleteProgram(program_);
115 glDeleteShader(vertex_shader_); 115 glDeleteShader(vertex_shader_);
116 glDeleteShader(fragment_shader_); 116 glDeleteShader(fragment_shader_);
117 glDeleteBuffersARB(1, &vertex_buffer_); 117 glDeleteBuffersARB(1, &vertex_buffer_);
118 glDeleteFramebuffersEXT(1, &framebuffer_); 118 glDeleteFramebuffersEXT(1, &framebuffer_);
119 } 119 }
120 120
121 void YUVToRGBConverter::CopyYUV420ToRGB(unsigned target, 121 void YUVToRGBConverter::CopyYUV420ToRGB(unsigned target,
122 const gfx::Size& size, 122 const gfx::Size& size,
123 unsigned rgb_texture) { 123 unsigned rgb_texture) {
124 // Only support for rectangle targets exists so far.
125 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_RECTANGLE_ARB), target);
126 ScopedSetGLToRealGLApi scoped_set_gl_api; 124 ScopedSetGLToRealGLApi scoped_set_gl_api;
127 125
128 // Note that state restoration is done explicitly instead of scoped binders to 126 // Note that state restoration is done explicitly instead of scoped binders to
129 // avoid https://crbug.com/601729. 127 // avoid https://crbug.com/601729.
130 GLint old_active_texture = -1; 128 GLint old_active_texture = -1;
131 glGetIntegerv(GL_ACTIVE_TEXTURE, &old_active_texture); 129 glGetIntegerv(GL_ACTIVE_TEXTURE, &old_active_texture);
132 GLint old_texture0_binding = -1; 130 GLint old_texture0_binding = -1;
133 glActiveTexture(GL_TEXTURE0); 131 glActiveTexture(GL_TEXTURE0);
134 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_texture0_binding); 132 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_texture0_binding);
135 GLint old_texture1_binding = -1; 133 GLint old_texture1_binding = -1;
136 glActiveTexture(GL_TEXTURE1); 134 glActiveTexture(GL_TEXTURE1);
137 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_texture1_binding); 135 glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_texture1_binding);
138 136
139 // Allocate the rgb texture. 137 // Allocate the rgb texture.
140 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, rgb_texture); 138 glBindTexture(target, rgb_texture);
141 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, size.width(), size.height(), 139 glTexImage2D(target, 0, GL_RGB, size.width(), size.height(),
142 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr); 140 0, GL_RGB, GL_UNSIGNED_BYTE, nullptr);
143 141
144 // Set up and issue the draw call. 142 // Set up and issue the draw call.
145 glActiveTexture(GL_TEXTURE0); 143 glActiveTexture(GL_TEXTURE0);
146 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, y_texture_); 144 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, y_texture_);
147 glActiveTexture(GL_TEXTURE1); 145 glActiveTexture(GL_TEXTURE1);
148 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, uv_texture_); 146 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, uv_texture_);
149 ScopedFrameBufferBinder framebuffer_binder(framebuffer_); 147 ScopedFrameBufferBinder framebuffer_binder(framebuffer_);
150 ScopedViewport viewport(0, 0, size.width(), size.height()); 148 ScopedViewport viewport(0, 0, size.width(), size.height());
151 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 149 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
152 GL_TEXTURE_RECTANGLE_ARB, rgb_texture, 0); 150 target, rgb_texture, 0);
153 DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 151 DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
154 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER)); 152 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER));
155 ScopedUseProgram use_program(program_); 153 ScopedUseProgram use_program(program_);
156 glUniform2f(size_location_, size.width(), size.height()); 154 glUniform2f(size_location_, size.width(), size.height());
157 GLHelper::DrawQuad(vertex_buffer_); 155 GLHelper::DrawQuad(vertex_buffer_);
158 156
159 // Restore previous state. 157 // Restore previous state.
160 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 158 glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
161 GL_TEXTURE_RECTANGLE_ARB, 0, 0); 159 target, 0, 0);
162 glActiveTexture(GL_TEXTURE0); 160 glActiveTexture(GL_TEXTURE0);
163 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture0_binding); 161 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture0_binding);
164 glActiveTexture(GL_TEXTURE1); 162 glActiveTexture(GL_TEXTURE1);
165 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture1_binding); 163 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, old_texture1_binding);
166 glActiveTexture(old_active_texture); 164 glActiveTexture(old_active_texture);
167 } 165 }
168 166
169 } // namespace gl 167 } // 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