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/common/gpu/client/gl_helper_scaling.h" | 5 #include "content/common/gpu/client/gl_helper_scaling.h" |
6 | 6 |
7 #include <deque> | 7 #include <deque> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 156 } |
157 | 157 |
158 virtual ~ScalerImpl() { | 158 virtual ~ScalerImpl() { |
159 if (intermediate_texture_) { | 159 if (intermediate_texture_) { |
160 gl_->DeleteTextures(1, &intermediate_texture_); | 160 gl_->DeleteTextures(1, &intermediate_texture_); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 // GLHelperShader::ShaderInterface implementation. | 164 // GLHelperShader::ShaderInterface implementation. |
165 virtual void Execute(GLuint source_texture, | 165 virtual void Execute(GLuint source_texture, |
166 const std::vector<GLuint>& dest_textures) OVERRIDE { | 166 const std::vector<GLuint>& dest_textures) override { |
167 if (subscaler_) { | 167 if (subscaler_) { |
168 subscaler_->Scale(source_texture, intermediate_texture_); | 168 subscaler_->Scale(source_texture, intermediate_texture_); |
169 source_texture = intermediate_texture_; | 169 source_texture = intermediate_texture_; |
170 } | 170 } |
171 | 171 |
172 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( | 172 ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder( |
173 gl_, dst_framebuffer_); | 173 gl_, dst_framebuffer_); |
174 DCHECK_GT(dest_textures.size(), 0U); | 174 DCHECK_GT(dest_textures.size(), 0U); |
175 scoped_ptr<GLenum[]> buffers(new GLenum[dest_textures.size()]); | 175 scoped_ptr<GLenum[]> buffers(new GLenum[dest_textures.size()]); |
176 for (size_t t = 0; t < dest_textures.size(); t++) { | 176 for (size_t t = 0; t < dest_textures.size(); t++) { |
(...skipping 30 matching lines...) Expand all Loading... |
207 } | 207 } |
208 // Conduct texture mapping by drawing a quad composed of two triangles. | 208 // Conduct texture mapping by drawing a quad composed of two triangles. |
209 gl_->DrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 209 gl_->DrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
210 if (dest_textures.size() > 1) { | 210 if (dest_textures.size() > 1) { |
211 // Set the draw buffers back to not confuse others. | 211 // Set the draw buffers back to not confuse others. |
212 gl_->DrawBuffersEXT(1, &buffers[0]); | 212 gl_->DrawBuffersEXT(1, &buffers[0]); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 // GLHelper::ScalerInterface implementation. | 216 // GLHelper::ScalerInterface implementation. |
217 virtual void Scale(GLuint source_texture, GLuint dest_texture) OVERRIDE { | 217 virtual void Scale(GLuint source_texture, GLuint dest_texture) override { |
218 std::vector<GLuint> tmp(1); | 218 std::vector<GLuint> tmp(1); |
219 tmp[0] = dest_texture; | 219 tmp[0] = dest_texture; |
220 Execute(source_texture, tmp); | 220 Execute(source_texture, tmp); |
221 } | 221 } |
222 | 222 |
223 virtual const gfx::Size& SrcSize() OVERRIDE { | 223 virtual const gfx::Size& SrcSize() override { |
224 if (subscaler_) { | 224 if (subscaler_) { |
225 return subscaler_->SrcSize(); | 225 return subscaler_->SrcSize(); |
226 } | 226 } |
227 return spec_.src_size; | 227 return spec_.src_size; |
228 } | 228 } |
229 virtual const gfx::Rect& SrcSubrect() OVERRIDE { | 229 virtual const gfx::Rect& SrcSubrect() override { |
230 if (subscaler_) { | 230 if (subscaler_) { |
231 return subscaler_->SrcSubrect(); | 231 return subscaler_->SrcSubrect(); |
232 } | 232 } |
233 return spec_.src_subrect; | 233 return spec_.src_subrect; |
234 } | 234 } |
235 virtual const gfx::Size& DstSize() OVERRIDE { return spec_.dst_size; } | 235 virtual const gfx::Size& DstSize() override { return spec_.dst_size; } |
236 | 236 |
237 private: | 237 private: |
238 GLES2Interface* gl_; | 238 GLES2Interface* gl_; |
239 GLHelperScaling* scaler_helper_; | 239 GLHelperScaling* scaler_helper_; |
240 GLHelperScaling::ScalerStage spec_; | 240 GLHelperScaling::ScalerStage spec_; |
241 GLfloat color_weights_[4]; | 241 GLfloat color_weights_[4]; |
242 GLuint intermediate_texture_; | 242 GLuint intermediate_texture_; |
243 scoped_refptr<ShaderProgram> shader_program_; | 243 scoped_refptr<ShaderProgram> shader_program_; |
244 ScopedFramebuffer dst_framebuffer_; | 244 ScopedFramebuffer dst_framebuffer_; |
245 scoped_ptr<ScalerImpl> subscaler_; | 245 scoped_ptr<ScalerImpl> subscaler_; |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 gl_->Uniform2f(dst_pixelsize_location_, | 920 gl_->Uniform2f(dst_pixelsize_location_, |
921 static_cast<float>(dst_size.width()), | 921 static_cast<float>(dst_size.width()), |
922 static_cast<float>(dst_size.height())); | 922 static_cast<float>(dst_size.height())); |
923 | 923 |
924 gl_->Uniform2f( | 924 gl_->Uniform2f( |
925 scaling_vector_location_, scale_x ? 1.0 : 0.0, scale_x ? 0.0 : 1.0); | 925 scaling_vector_location_, scale_x ? 1.0 : 0.0, scale_x ? 0.0 : 1.0); |
926 gl_->Uniform4fv(color_weights_location_, 1, color_weights); | 926 gl_->Uniform4fv(color_weights_location_, 1, color_weights); |
927 } | 927 } |
928 | 928 |
929 } // namespace content | 929 } // namespace content |
OLD | NEW |