OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/compositor/gl_helper_scaling.h" | 5 #include "content/browser/compositor/gl_helper_scaling.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void Execute(GLuint source_texture, | 162 void Execute(GLuint source_texture, |
163 const std::vector<GLuint>& dest_textures) override { | 163 const std::vector<GLuint>& dest_textures) override { |
164 if (subscaler_) { | 164 if (subscaler_) { |
165 subscaler_->Scale(source_texture, intermediate_texture_); | 165 subscaler_->Scale(source_texture, intermediate_texture_); |
166 source_texture = intermediate_texture_; | 166 source_texture = intermediate_texture_; |
167 } | 167 } |
168 | 168 |
169 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( | 169 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( |
170 gl_, dst_framebuffer_); | 170 gl_, dst_framebuffer_); |
171 DCHECK_GT(dest_textures.size(), 0U); | 171 DCHECK_GT(dest_textures.size(), 0U); |
172 scoped_ptr<GLenum[]> buffers(new GLenum[dest_textures.size()]); | 172 std::unique_ptr<GLenum[]> buffers(new GLenum[dest_textures.size()]); |
173 for (size_t t = 0; t < dest_textures.size(); t++) { | 173 for (size_t t = 0; t < dest_textures.size(); t++) { |
174 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dest_textures[t]); | 174 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dest_textures[t]); |
175 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + t, | 175 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + t, |
176 GL_TEXTURE_2D, dest_textures[t], 0); | 176 GL_TEXTURE_2D, dest_textures[t], 0); |
177 buffers[t] = GL_COLOR_ATTACHMENT0 + t; | 177 buffers[t] = GL_COLOR_ATTACHMENT0 + t; |
178 } | 178 } |
179 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, source_texture); | 179 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, source_texture); |
180 | 180 |
181 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 181 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
182 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 182 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const gfx::Size& DstSize() override { return spec_.dst_size; } | 225 const gfx::Size& DstSize() override { return spec_.dst_size; } |
226 | 226 |
227 private: | 227 private: |
228 GLES2Interface* gl_; | 228 GLES2Interface* gl_; |
229 GLHelperScaling* scaler_helper_; | 229 GLHelperScaling* scaler_helper_; |
230 GLHelperScaling::ScalerStage spec_; | 230 GLHelperScaling::ScalerStage spec_; |
231 GLfloat color_weights_[4]; | 231 GLfloat color_weights_[4]; |
232 GLuint intermediate_texture_; | 232 GLuint intermediate_texture_; |
233 scoped_refptr<ShaderProgram> shader_program_; | 233 scoped_refptr<ShaderProgram> shader_program_; |
234 ScopedFramebuffer dst_framebuffer_; | 234 ScopedFramebuffer dst_framebuffer_; |
235 scoped_ptr<ScalerImpl> subscaler_; | 235 std::unique_ptr<ScalerImpl> subscaler_; |
236 }; | 236 }; |
237 | 237 |
238 GLHelperScaling::ScalerStage::ScalerStage(ShaderType shader_, | 238 GLHelperScaling::ScalerStage::ScalerStage(ShaderType shader_, |
239 gfx::Size src_size_, | 239 gfx::Size src_size_, |
240 gfx::Rect src_subrect_, | 240 gfx::Rect src_subrect_, |
241 gfx::Size dst_size_, | 241 gfx::Size dst_size_, |
242 bool scale_x_, | 242 bool scale_x_, |
243 bool vertically_flip_texture_, | 243 bool vertically_flip_texture_, |
244 bool swizzle_) | 244 bool swizzle_) |
245 : shader(shader_), | 245 : shader(shader_), |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 gl_->Uniform2f(src_pixelsize_location_, src_size.width(), src_size.height()); | 872 gl_->Uniform2f(src_pixelsize_location_, src_size.width(), src_size.height()); |
873 gl_->Uniform2f(dst_pixelsize_location_, static_cast<float>(dst_size.width()), | 873 gl_->Uniform2f(dst_pixelsize_location_, static_cast<float>(dst_size.width()), |
874 static_cast<float>(dst_size.height())); | 874 static_cast<float>(dst_size.height())); |
875 | 875 |
876 gl_->Uniform2f(scaling_vector_location_, scale_x ? 1.0 : 0.0, | 876 gl_->Uniform2f(scaling_vector_location_, scale_x ? 1.0 : 0.0, |
877 scale_x ? 0.0 : 1.0); | 877 scale_x ? 0.0 : 1.0); |
878 gl_->Uniform4fv(color_weights_location_, 1, color_weights); | 878 gl_->Uniform4fv(color_weights_location_, 1, color_weights); |
879 } | 879 } |
880 | 880 |
881 } // namespace content | 881 } // namespace content |
OLD | NEW |