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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, | 144 ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, |
145 intermediate_texture_); | 145 intermediate_texture_); |
146 gl_->TexImage2D(GL_TEXTURE_2D, | 146 gl_->TexImage2D(GL_TEXTURE_2D, |
147 0, | 147 0, |
148 GL_RGBA, | 148 GL_RGBA, |
149 spec_.src_size.width(), | 149 spec_.src_size.width(), |
150 spec_.src_size.height(), | 150 spec_.src_size.height(), |
151 0, | 151 0, |
152 GL_RGBA, | 152 GL_RGBA, |
153 GL_UNSIGNED_BYTE, | 153 GL_UNSIGNED_BYTE, |
154 NULL); | 154 nullptr); |
155 } | 155 } |
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. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 gfx::Size src_size, | 276 gfx::Size src_size, |
277 gfx::Rect src_subrect, | 277 gfx::Rect src_subrect, |
278 const gfx::Size& dst_size, | 278 const gfx::Size& dst_size, |
279 bool vertically_flip_texture, | 279 bool vertically_flip_texture, |
280 bool swizzle, | 280 bool swizzle, |
281 std::deque<GLHelperScaling::ScaleOp>* x_ops, | 281 std::deque<GLHelperScaling::ScaleOp>* x_ops, |
282 std::deque<GLHelperScaling::ScaleOp>* y_ops, | 282 std::deque<GLHelperScaling::ScaleOp>* y_ops, |
283 std::vector<ScalerStage>* scaler_stages) { | 283 std::vector<ScalerStage>* scaler_stages) { |
284 while (!x_ops->empty() || !y_ops->empty()) { | 284 while (!x_ops->empty() || !y_ops->empty()) { |
285 gfx::Size intermediate_size = src_subrect.size(); | 285 gfx::Size intermediate_size = src_subrect.size(); |
286 std::deque<ScaleOp>* current_queue = NULL; | 286 std::deque<ScaleOp>* current_queue = nullptr; |
287 | 287 |
288 if (!y_ops->empty()) { | 288 if (!y_ops->empty()) { |
289 current_queue = y_ops; | 289 current_queue = y_ops; |
290 } else { | 290 } else { |
291 current_queue = x_ops; | 291 current_queue = x_ops; |
292 } | 292 } |
293 | 293 |
294 ShaderType current_shader = SHADER_BILINEAR; | 294 ShaderType current_shader = SHADER_BILINEAR; |
295 switch (current_queue->front().scale_factor) { | 295 switch (current_queue->front().scale_factor) { |
296 case 0: | 296 case 0: |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 bool swizzle) { | 444 bool swizzle) { |
445 std::vector<ScalerStage> scaler_stages; | 445 std::vector<ScalerStage> scaler_stages; |
446 ComputeScalerStages(quality, | 446 ComputeScalerStages(quality, |
447 src_size, | 447 src_size, |
448 src_subrect, | 448 src_subrect, |
449 dst_size, | 449 dst_size, |
450 vertically_flip_texture, | 450 vertically_flip_texture, |
451 swizzle, | 451 swizzle, |
452 &scaler_stages); | 452 &scaler_stages); |
453 | 453 |
454 ScalerImpl* ret = NULL; | 454 ScalerImpl* ret = nullptr; |
455 for (unsigned int i = 0; i < scaler_stages.size(); i++) { | 455 for (unsigned int i = 0; i < scaler_stages.size(); i++) { |
456 ret = new ScalerImpl(gl_, this, scaler_stages[i], ret, NULL); | 456 ret = new ScalerImpl(gl_, this, scaler_stages[i], ret, nullptr); |
457 } | 457 } |
458 return ret; | 458 return ret; |
459 } | 459 } |
460 | 460 |
461 GLHelper::ScalerInterface* GLHelperScaling::CreatePlanarScaler( | 461 GLHelper::ScalerInterface* GLHelperScaling::CreatePlanarScaler( |
462 const gfx::Size& src_size, | 462 const gfx::Size& src_size, |
463 const gfx::Rect& src_subrect, | 463 const gfx::Rect& src_subrect, |
464 const gfx::Size& dst_size, | 464 const gfx::Size& dst_size, |
465 bool vertically_flip_texture, | 465 bool vertically_flip_texture, |
466 bool swizzle, | 466 bool swizzle, |
467 const float color_weights[4]) { | 467 const float color_weights[4]) { |
468 ScalerStage stage(SHADER_PLANAR, | 468 ScalerStage stage(SHADER_PLANAR, |
469 src_size, | 469 src_size, |
470 src_subrect, | 470 src_subrect, |
471 dst_size, | 471 dst_size, |
472 true, | 472 true, |
473 vertically_flip_texture, | 473 vertically_flip_texture, |
474 swizzle); | 474 swizzle); |
475 return new ScalerImpl(gl_, this, stage, NULL, color_weights); | 475 return new ScalerImpl(gl_, this, stage, nullptr, color_weights); |
476 } | 476 } |
477 | 477 |
478 GLHelperScaling::ShaderInterface* GLHelperScaling::CreateYuvMrtShader( | 478 GLHelperScaling::ShaderInterface* GLHelperScaling::CreateYuvMrtShader( |
479 const gfx::Size& src_size, | 479 const gfx::Size& src_size, |
480 const gfx::Rect& src_subrect, | 480 const gfx::Rect& src_subrect, |
481 const gfx::Size& dst_size, | 481 const gfx::Size& dst_size, |
482 bool vertically_flip_texture, | 482 bool vertically_flip_texture, |
483 bool swizzle, | 483 bool swizzle, |
484 ShaderType shader) { | 484 ShaderType shader) { |
485 DCHECK(shader == SHADER_YUV_MRT_PASS1 || shader == SHADER_YUV_MRT_PASS2); | 485 DCHECK(shader == SHADER_YUV_MRT_PASS1 || shader == SHADER_YUV_MRT_PASS2); |
486 ScalerStage stage(shader, | 486 ScalerStage stage(shader, |
487 src_size, | 487 src_size, |
488 src_subrect, | 488 src_subrect, |
489 dst_size, | 489 dst_size, |
490 true, | 490 true, |
491 vertically_flip_texture, | 491 vertically_flip_texture, |
492 swizzle); | 492 swizzle); |
493 return new ScalerImpl(gl_, this, stage, NULL, NULL); | 493 return new ScalerImpl(gl_, this, stage, nullptr, nullptr); |
494 } | 494 } |
495 | 495 |
496 const GLfloat GLHelperScaling::kVertexAttributes[] = { | 496 const GLfloat GLHelperScaling::kVertexAttributes[] = { |
497 -1.0f, -1.0f, 0.0f, 0.0f, // vertex 0 | 497 -1.0f, -1.0f, 0.0f, 0.0f, // vertex 0 |
498 1.0f, -1.0f, 1.0f, 0.0f, // vertex 1 | 498 1.0f, -1.0f, 1.0f, 0.0f, // vertex 1 |
499 -1.0f, 1.0f, 0.0f, 1.0f, // vertex 2 | 499 -1.0f, 1.0f, 0.0f, 1.0f, // vertex 2 |
500 1.0f, 1.0f, 1.0f, 1.0f, }; // vertex 3 | 500 1.0f, 1.0f, 1.0f, 1.0f, }; // vertex 3 |
501 | 501 |
502 void GLHelperScaling::InitBuffer() { | 502 void GLHelperScaling::InitBuffer() { |
503 ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder(gl_, | 503 ScopedBufferBinder<GL_ARRAY_BUFFER> buffer_binder(gl_, |
(...skipping 416 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 |