Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame& frame, | 325 void GLRenderer::DrawCheckerboardQuad(const DrawingFrame& frame, |
| 326 const CheckerboardDrawQuad* quad) { | 326 const CheckerboardDrawQuad* quad) { |
| 327 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 327 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 328 | 328 |
| 329 const TileCheckerboardProgram* program = GetTileCheckerboardProgram(); | 329 const TileCheckerboardProgram* program = GetTileCheckerboardProgram(); |
| 330 DCHECK(program && (program->initialized() || IsContextLost())); | 330 DCHECK(program && (program->initialized() || IsContextLost())); |
| 331 SetUseProgram(program->program()); | 331 SetUseProgram(program->program()); |
| 332 | 332 |
| 333 SkColor color = quad->color; | 333 SkColor color = quad->color; |
| 334 GLC(Context(), | 334 GLC(Context(), |
| 335 Context()->uniform4f(program->fragment_shader().colorLocation(), | 335 Context()->uniform4f(program->fragment_shader().color_location(), |
| 336 SkColorGetR(color) * (1.0f / 255.0f), | 336 SkColorGetR(color) * (1.0f / 255.0f), |
| 337 SkColorGetG(color) * (1.0f / 255.0f), | 337 SkColorGetG(color) * (1.0f / 255.0f), |
| 338 SkColorGetB(color) * (1.0f / 255.0f), | 338 SkColorGetB(color) * (1.0f / 255.0f), |
| 339 1)); | 339 1)); |
| 340 | 340 |
| 341 const int checkerboard_width = 16; | 341 const int checkerboard_width = 16; |
| 342 float frequency = 1.0f / checkerboard_width; | 342 float frequency = 1.0f / checkerboard_width; |
| 343 | 343 |
| 344 gfx::Rect tile_rect = quad->rect; | 344 gfx::Rect tile_rect = quad->rect; |
| 345 float tex_offset_x = tile_rect.x() % checkerboard_width; | 345 float tex_offset_x = tile_rect.x() % checkerboard_width; |
| 346 float tex_offset_y = tile_rect.y() % checkerboard_width; | 346 float tex_offset_y = tile_rect.y() % checkerboard_width; |
| 347 float tex_scale_x = tile_rect.width(); | 347 float tex_scale_x = tile_rect.width(); |
| 348 float tex_scale_y = tile_rect.height(); | 348 float tex_scale_y = tile_rect.height(); |
| 349 GLC(Context(), | 349 GLC(Context(), |
| 350 Context()->uniform4f(program->fragment_shader().texTransformLocation(), | 350 Context()->uniform4f(program->fragment_shader().tex_transform_location(), |
| 351 tex_offset_x, | 351 tex_offset_x, |
| 352 tex_offset_y, | 352 tex_offset_y, |
| 353 tex_scale_x, | 353 tex_scale_x, |
| 354 tex_scale_y)); | 354 tex_scale_y)); |
| 355 | 355 |
| 356 GLC(Context(), | 356 GLC(Context(), |
| 357 Context()->uniform1f(program->fragment_shader().frequencyLocation(), | 357 Context()->uniform1f(program->fragment_shader().frequency_location(), |
| 358 frequency)); | 358 frequency)); |
| 359 | 359 |
| 360 SetShaderOpacity(quad->opacity(), program->fragment_shader().alphaLocation()); | 360 SetShaderOpacity(quad->opacity(), program->fragment_shader().alpha_location()) ; |
|
enne (OOO)
2013/03/20 21:06:49
80 columns.
| |
| 361 DrawQuadGeometry(frame, | 361 DrawQuadGeometry(frame, |
| 362 quad->quadTransform(), | 362 quad->quadTransform(), |
| 363 quad->rect, | 363 quad->rect, |
| 364 program->vertex_shader().matrixLocation()); | 364 program->vertex_shader().matrix_location()); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame& frame, | 367 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame& frame, |
| 368 const DebugBorderDrawQuad* quad) { | 368 const DebugBorderDrawQuad* quad) { |
| 369 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 369 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 370 | 370 |
| 371 static float gl_matrix[16]; | 371 static float gl_matrix[16]; |
| 372 const DebugBorderProgram* program = GetDebugBorderProgram(); | 372 const DebugBorderProgram* program = GetDebugBorderProgram(); |
| 373 DCHECK(program && (program->initialized() || IsContextLost())); | 373 DCHECK(program && (program->initialized() || IsContextLost())); |
| 374 SetUseProgram(program->program()); | 374 SetUseProgram(program->program()); |
| 375 | 375 |
| 376 // Use the full quad_rect for debug quads to not move the edges based on | 376 // Use the full quad_rect for debug quads to not move the edges based on |
| 377 // partial swaps. | 377 // partial swaps. |
| 378 gfx::Rect layer_rect = quad->rect; | 378 gfx::Rect layer_rect = quad->rect; |
| 379 gfx::Transform render_matrix = quad->quadTransform(); | 379 gfx::Transform render_matrix = quad->quadTransform(); |
| 380 render_matrix.Translate(0.5f * layer_rect.width() + layer_rect.x(), | 380 render_matrix.Translate(0.5f * layer_rect.width() + layer_rect.x(), |
| 381 0.5f * layer_rect.height() + layer_rect.y()); | 381 0.5f * layer_rect.height() + layer_rect.y()); |
| 382 render_matrix.Scale(layer_rect.width(), layer_rect.height()); | 382 render_matrix.Scale(layer_rect.width(), layer_rect.height()); |
| 383 GLRenderer::ToGLMatrix(&gl_matrix[0], | 383 GLRenderer::ToGLMatrix(&gl_matrix[0], |
| 384 frame.projection_matrix * render_matrix); | 384 frame.projection_matrix * render_matrix); |
| 385 GLC(Context(), | 385 GLC(Context(), |
| 386 Context()->uniformMatrix4fv( | 386 Context()->uniformMatrix4fv( |
| 387 program->vertex_shader().matrixLocation(), 1, false, &gl_matrix[0])); | 387 program->vertex_shader().matrix_location(), 1, false, &gl_matrix[0])); |
| 388 | 388 |
| 389 SkColor color = quad->color; | 389 SkColor color = quad->color; |
| 390 float alpha = SkColorGetA(color) * (1.0f / 255.0f); | 390 float alpha = SkColorGetA(color) * (1.0f / 255.0f); |
| 391 | 391 |
| 392 GLC(Context(), | 392 GLC(Context(), |
| 393 Context()->uniform4f(program->fragment_shader().colorLocation(), | 393 Context()->uniform4f(program->fragment_shader().color_location(), |
| 394 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, | 394 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, |
| 395 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, | 395 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, |
| 396 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, | 396 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, |
| 397 alpha)); | 397 alpha)); |
| 398 | 398 |
| 399 GLC(Context(), Context()->lineWidth(quad->width)); | 399 GLC(Context(), Context()->lineWidth(quad->width)); |
| 400 | 400 |
| 401 // The indices for the line are stored in the same array as the triangle | 401 // The indices for the line are stored in the same array as the triangle |
| 402 // indices. | 402 // indices. |
| 403 GLC(Context(), | 403 GLC(Context(), |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 int shader_mask_tex_coord_offset_location = -1; | 721 int shader_mask_tex_coord_offset_location = -1; |
| 722 int shader_matrix_location = -1; | 722 int shader_matrix_location = -1; |
| 723 int shader_alpha_location = -1; | 723 int shader_alpha_location = -1; |
| 724 int shader_tex_transform_location = -1; | 724 int shader_tex_transform_location = -1; |
| 725 int shader_tex_scale_location = -1; | 725 int shader_tex_scale_location = -1; |
| 726 | 726 |
| 727 if (use_aa && mask_texture_id) { | 727 if (use_aa && mask_texture_id) { |
| 728 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA(); | 728 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA(); |
| 729 SetUseProgram(program->program()); | 729 SetUseProgram(program->program()); |
| 730 GLC(Context(), | 730 GLC(Context(), |
| 731 Context()->uniform1i(program->fragment_shader().samplerLocation(), 0)); | 731 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 732 | 732 |
| 733 shader_quad_location = program->vertex_shader().pointLocation(); | 733 shader_quad_location = program->vertex_shader().point_location(); |
| 734 shader_edge_location = program->fragment_shader().edgeLocation(); | 734 shader_edge_location = program->fragment_shader().edge_location(); |
| 735 shader_mask_sampler_location = | 735 shader_mask_sampler_location = |
| 736 program->fragment_shader().maskSamplerLocation(); | 736 program->fragment_shader().mask_sampler_location(); |
| 737 shader_mask_tex_coord_scale_location = | 737 shader_mask_tex_coord_scale_location = |
| 738 program->fragment_shader().maskTexCoordScaleLocation(); | 738 program->fragment_shader().mask_tex_coord_scale_location(); |
| 739 shader_mask_tex_coord_offset_location = | 739 shader_mask_tex_coord_offset_location = |
| 740 program->fragment_shader().maskTexCoordOffsetLocation(); | 740 program->fragment_shader().mask_tex_coord_offset_location(); |
| 741 shader_matrix_location = program->vertex_shader().matrixLocation(); | 741 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 742 shader_alpha_location = program->fragment_shader().alphaLocation(); | 742 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 743 shader_tex_scale_location = program->vertex_shader().texScaleLocation(); | 743 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 744 } else if (!use_aa && mask_texture_id) { | 744 } else if (!use_aa && mask_texture_id) { |
| 745 const RenderPassMaskProgram* program = GetRenderPassMaskProgram(); | 745 const RenderPassMaskProgram* program = GetRenderPassMaskProgram(); |
| 746 SetUseProgram(program->program()); | 746 SetUseProgram(program->program()); |
| 747 GLC(Context(), | 747 GLC(Context(), |
| 748 Context()->uniform1i(program->fragment_shader().samplerLocation(), 0)); | 748 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 749 | 749 |
| 750 shader_mask_sampler_location = | 750 shader_mask_sampler_location = |
| 751 program->fragment_shader().maskSamplerLocation(); | 751 program->fragment_shader().mask_sampler_location(); |
| 752 shader_mask_tex_coord_scale_location = | 752 shader_mask_tex_coord_scale_location = |
| 753 program->fragment_shader().maskTexCoordScaleLocation(); | 753 program->fragment_shader().mask_tex_coord_scale_location(); |
| 754 shader_mask_tex_coord_offset_location = | 754 shader_mask_tex_coord_offset_location = |
| 755 program->fragment_shader().maskTexCoordOffsetLocation(); | 755 program->fragment_shader().mask_tex_coord_offset_location(); |
| 756 shader_matrix_location = program->vertex_shader().matrixLocation(); | 756 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 757 shader_alpha_location = program->fragment_shader().alphaLocation(); | 757 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 758 shader_tex_transform_location = | 758 shader_tex_transform_location = |
| 759 program->vertex_shader().texTransformLocation(); | 759 program->vertex_shader().tex_transform_location(); |
| 760 } else if (use_aa && !mask_texture_id) { | 760 } else if (use_aa && !mask_texture_id) { |
| 761 const RenderPassProgramAA* program = GetRenderPassProgramAA(); | 761 const RenderPassProgramAA* program = GetRenderPassProgramAA(); |
| 762 SetUseProgram(program->program()); | 762 SetUseProgram(program->program()); |
| 763 GLC(Context(), | 763 GLC(Context(), |
| 764 Context()->uniform1i(program->fragment_shader().samplerLocation(), 0)); | 764 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 765 | 765 |
| 766 shader_quad_location = program->vertex_shader().pointLocation(); | 766 shader_quad_location = program->vertex_shader().point_location(); |
| 767 shader_edge_location = program->fragment_shader().edgeLocation(); | 767 shader_edge_location = program->fragment_shader().edge_location(); |
| 768 shader_matrix_location = program->vertex_shader().matrixLocation(); | 768 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 769 shader_alpha_location = program->fragment_shader().alphaLocation(); | 769 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 770 shader_tex_scale_location = program->vertex_shader().texScaleLocation(); | 770 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 771 } else { | 771 } else { |
| 772 const RenderPassProgram* program = GetRenderPassProgram(); | 772 const RenderPassProgram* program = GetRenderPassProgram(); |
| 773 SetUseProgram(program->program()); | 773 SetUseProgram(program->program()); |
| 774 GLC(Context(), | 774 GLC(Context(), |
| 775 Context()->uniform1i(program->fragment_shader().samplerLocation(), 0)); | 775 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 776 | 776 |
| 777 shader_matrix_location = program->vertex_shader().matrixLocation(); | 777 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 778 shader_alpha_location = program->fragment_shader().alphaLocation(); | 778 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 779 shader_tex_transform_location = | 779 shader_tex_transform_location = |
| 780 program->vertex_shader().texTransformLocation(); | 780 program->vertex_shader().tex_transform_location(); |
| 781 } | 781 } |
| 782 | 782 |
| 783 float tex_scale_x = | 783 float tex_scale_x = |
| 784 quad->rect.width() / static_cast<float>(contents_texture->size().width()); | 784 quad->rect.width() / static_cast<float>(contents_texture->size().width()); |
| 785 float tex_scale_y = quad->rect.height() / | 785 float tex_scale_y = quad->rect.height() / |
| 786 static_cast<float>(contents_texture->size().height()); | 786 static_cast<float>(contents_texture->size().height()); |
| 787 DCHECK_LE(tex_scale_x, 1.0f); | 787 DCHECK_LE(tex_scale_x, 1.0f); |
| 788 DCHECK_LE(tex_scale_y, 1.0f); | 788 DCHECK_LE(tex_scale_y, 1.0f); |
| 789 | 789 |
| 790 if (shader_tex_transform_location != -1) { | 790 if (shader_tex_transform_location != -1) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 unsigned color_location; | 851 unsigned color_location; |
| 852 unsigned point_location; | 852 unsigned point_location; |
| 853 unsigned tex_scale_location; | 853 unsigned tex_scale_location; |
| 854 unsigned edge_location; | 854 unsigned edge_location; |
| 855 }; | 855 }; |
| 856 | 856 |
| 857 template<class T> | 857 template<class T> |
| 858 static void SolidColorUniformLocation(T program, | 858 static void SolidColorUniformLocation(T program, |
| 859 SolidColorProgramUniforms* uniforms) { | 859 SolidColorProgramUniforms* uniforms) { |
| 860 uniforms->program = program->program(); | 860 uniforms->program = program->program(); |
| 861 uniforms->matrix_location = program->vertex_shader().matrixLocation(); | 861 uniforms->matrix_location = program->vertex_shader().matrix_location(); |
| 862 uniforms->color_location = program->fragment_shader().colorLocation(); | 862 uniforms->color_location = program->fragment_shader().color_location(); |
| 863 uniforms->point_location = program->vertex_shader().pointLocation(); | 863 uniforms->point_location = program->vertex_shader().point_location(); |
| 864 uniforms->tex_scale_location = program->vertex_shader().texScaleLocation(); | 864 uniforms->tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 865 uniforms->edge_location = program->fragment_shader().edgeLocation(); | 865 uniforms->edge_location = program->fragment_shader().edge_location(); |
| 866 } | 866 } |
| 867 | 867 |
| 868 bool GLRenderer::SetupQuadForAntialiasing( | 868 bool GLRenderer::SetupQuadForAntialiasing( |
| 869 const gfx::Transform& device_transform, | 869 const gfx::Transform& device_transform, |
| 870 const DrawQuad* quad, | 870 const DrawQuad* quad, |
| 871 gfx::QuadF* local_quad, | 871 gfx::QuadF* local_quad, |
| 872 float edge[24]) const { | 872 float edge[24]) const { |
| 873 gfx::Rect tile_rect = quad->visible_rect; | 873 gfx::Rect tile_rect = quad->visible_rect; |
| 874 | 874 |
| 875 bool clipped = false; | 875 bool clipped = false; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 unsigned edge_location; | 1015 unsigned edge_location; |
| 1016 unsigned matrix_location; | 1016 unsigned matrix_location; |
| 1017 unsigned alpha_location; | 1017 unsigned alpha_location; |
| 1018 unsigned point_location; | 1018 unsigned point_location; |
| 1019 }; | 1019 }; |
| 1020 | 1020 |
| 1021 template <class T> | 1021 template <class T> |
| 1022 static void TileUniformLocation(T program, TileProgramUniforms* uniforms) { | 1022 static void TileUniformLocation(T program, TileProgramUniforms* uniforms) { |
| 1023 uniforms->program = program->program(); | 1023 uniforms->program = program->program(); |
| 1024 uniforms->vertex_tex_transform_location = | 1024 uniforms->vertex_tex_transform_location = |
| 1025 program->vertex_shader().vertexTexTransformLocation(); | 1025 program->vertex_shader().vertex_tex_transform_location(); |
| 1026 uniforms->matrix_location = program->vertex_shader().matrixLocation(); | 1026 uniforms->matrix_location = program->vertex_shader().matrix_location(); |
| 1027 uniforms->point_location = program->vertex_shader().pointLocation(); | 1027 uniforms->point_location = program->vertex_shader().point_location(); |
| 1028 | 1028 |
| 1029 uniforms->sampler_location = program->fragment_shader().samplerLocation(); | 1029 uniforms->sampler_location = program->fragment_shader().sampler_location(); |
| 1030 uniforms->alpha_location = program->fragment_shader().alphaLocation(); | 1030 uniforms->alpha_location = program->fragment_shader().alpha_location(); |
| 1031 uniforms->fragment_tex_transform_location = | 1031 uniforms->fragment_tex_transform_location = |
| 1032 program->fragment_shader().fragmentTexTransformLocation(); | 1032 program->fragment_shader().fragment_tex_transform_location(); |
| 1033 uniforms->edge_location = program->fragment_shader().edgeLocation(); | 1033 uniforms->edge_location = program->fragment_shader().edge_location(); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 void GLRenderer::DrawTileQuad(const DrawingFrame& frame, | 1036 void GLRenderer::DrawTileQuad(const DrawingFrame& frame, |
| 1037 const TileDrawQuad* quad) { | 1037 const TileDrawQuad* quad) { |
| 1038 gfx::Rect tile_rect = quad->visible_rect; | 1038 gfx::Rect tile_rect = quad->visible_rect; |
| 1039 | 1039 |
| 1040 gfx::RectF tex_coord_rect = quad->tex_coord_rect; | 1040 gfx::RectF tex_coord_rect = quad->tex_coord_rect; |
| 1041 float tex_to_geom_scale_x = quad->rect.width() / tex_coord_rect.width(); | 1041 float tex_to_geom_scale_x = quad->rect.width() / tex_coord_rect.width(); |
| 1042 float tex_to_geom_scale_y = quad->rect.height() / tex_coord_rect.height(); | 1042 float tex_to_geom_scale_y = quad->rect.height() / tex_coord_rect.height(); |
| 1043 | 1043 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1198 GLC(Context(), Context()->activeTexture(GL_TEXTURE2)); | 1198 GLC(Context(), Context()->activeTexture(GL_TEXTURE2)); |
| 1199 ResourceProvider::ScopedSamplerGL u_plane_lock( | 1199 ResourceProvider::ScopedSamplerGL u_plane_lock( |
| 1200 resource_provider_, u_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); | 1200 resource_provider_, u_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); |
| 1201 GLC(Context(), Context()->activeTexture(GL_TEXTURE3)); | 1201 GLC(Context(), Context()->activeTexture(GL_TEXTURE3)); |
| 1202 ResourceProvider::ScopedSamplerGL v_plane_lock( | 1202 ResourceProvider::ScopedSamplerGL v_plane_lock( |
| 1203 resource_provider_, v_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); | 1203 resource_provider_, v_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); |
| 1204 | 1204 |
| 1205 SetUseProgram(program->program()); | 1205 SetUseProgram(program->program()); |
| 1206 | 1206 |
| 1207 GLC(Context(), | 1207 GLC(Context(), |
| 1208 Context()->uniform2f(program->vertex_shader().texScaleLocation(), | 1208 Context()->uniform2f(program->vertex_shader().tex_scale_location(), |
| 1209 quad->tex_scale.width(), | 1209 quad->tex_scale.width(), |
| 1210 quad->tex_scale.height())); | 1210 quad->tex_scale.height())); |
| 1211 GLC(Context(), | 1211 GLC(Context(), |
| 1212 Context()->uniform1i(program->fragment_shader().yTextureLocation(), 1)); | 1212 Context()->uniform1i(program->fragment_shader().y_texture_location(), 1)); |
| 1213 GLC(Context(), | 1213 GLC(Context(), |
| 1214 Context()->uniform1i(program->fragment_shader().uTextureLocation(), 2)); | 1214 Context()->uniform1i(program->fragment_shader().u_texture_location(), 2)); |
| 1215 GLC(Context(), | 1215 GLC(Context(), |
| 1216 Context()->uniform1i(program->fragment_shader().vTextureLocation(), 3)); | 1216 Context()->uniform1i(program->fragment_shader().v_texture_location(), 3)); |
| 1217 | 1217 |
| 1218 // These values are magic numbers that are used in the transformation from YUV | 1218 // These values are magic numbers that are used in the transformation from YUV |
| 1219 // to RGB color values. They are taken from the following webpage: | 1219 // to RGB color values. They are taken from the following webpage: |
| 1220 // http://www.fourcc.org/fccyvrgb.php | 1220 // http://www.fourcc.org/fccyvrgb.php |
| 1221 float yuv_to_rgb[9] = { | 1221 float yuv_to_rgb[9] = { |
| 1222 1.164f, 1.164f, 1.164f, | 1222 1.164f, 1.164f, 1.164f, |
| 1223 0.0f, -.391f, 2.018f, | 1223 0.0f, -.391f, 2.018f, |
| 1224 1.596f, -.813f, 0.0f, | 1224 1.596f, -.813f, 0.0f, |
| 1225 }; | 1225 }; |
| 1226 GLC(Context(), | 1226 GLC(Context(), |
| 1227 Context()->uniformMatrix3fv( | 1227 Context()->uniformMatrix3fv( |
| 1228 program->fragment_shader().yuvMatrixLocation(), 1, 0, yuv_to_rgb)); | 1228 program->fragment_shader().yuv_matrix_location(), 1, 0, yuv_to_rgb)); |
| 1229 | 1229 |
| 1230 // These values map to 16, 128, and 128 respectively, and are computed | 1230 // These values map to 16, 128, and 128 respectively, and are computed |
| 1231 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). | 1231 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). |
| 1232 // They are used in the YUV to RGBA conversion formula: | 1232 // They are used in the YUV to RGBA conversion formula: |
| 1233 // Y - 16 : Gives 16 values of head and footroom for overshooting | 1233 // Y - 16 : Gives 16 values of head and footroom for overshooting |
| 1234 // U - 128 : Turns unsigned U into signed U [-128,127] | 1234 // U - 128 : Turns unsigned U into signed U [-128,127] |
| 1235 // V - 128 : Turns unsigned V into signed V [-128,127] | 1235 // V - 128 : Turns unsigned V into signed V [-128,127] |
| 1236 float yuv_adjust[3] = { -0.0625f, -0.5f, -0.5f, }; | 1236 float yuv_adjust[3] = { -0.0625f, -0.5f, -0.5f, }; |
| 1237 GLC(Context(), | 1237 GLC(Context(), |
| 1238 Context()->uniform3fv( | 1238 Context()->uniform3fv( |
| 1239 program->fragment_shader().yuvAdjLocation(), 1, yuv_adjust)); | 1239 program->fragment_shader().yuv_adj_location(), 1, yuv_adjust)); |
| 1240 | 1240 |
| 1241 SetShaderOpacity(quad->opacity(), program->fragment_shader().alphaLocation()); | 1241 SetShaderOpacity(quad->opacity(), program->fragment_shader().alpha_location()) ; |
|
enne (OOO)
2013/03/20 21:06:49
80 columns.
| |
| 1242 DrawQuadGeometry(frame, | 1242 DrawQuadGeometry(frame, |
| 1243 quad->quadTransform(), | 1243 quad->quadTransform(), |
| 1244 quad->rect, | 1244 quad->rect, |
| 1245 program->vertex_shader().matrixLocation()); | 1245 program->vertex_shader().matrix_location()); |
| 1246 | 1246 |
| 1247 // Reset active texture back to texture 0. | 1247 // Reset active texture back to texture 0. |
| 1248 GLC(Context(), Context()->activeTexture(GL_TEXTURE0)); | 1248 GLC(Context(), Context()->activeTexture(GL_TEXTURE0)); |
| 1249 } | 1249 } |
| 1250 | 1250 |
| 1251 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame& frame, | 1251 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame& frame, |
| 1252 const StreamVideoDrawQuad* quad) { | 1252 const StreamVideoDrawQuad* quad) { |
| 1253 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1253 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1254 | 1254 |
| 1255 static float gl_matrix[16]; | 1255 static float gl_matrix[16]; |
| 1256 | 1256 |
| 1257 DCHECK(capabilities_.using_egl_image); | 1257 DCHECK(capabilities_.using_egl_image); |
| 1258 | 1258 |
| 1259 const VideoStreamTextureProgram* program = GetVideoStreamTextureProgram(); | 1259 const VideoStreamTextureProgram* program = GetVideoStreamTextureProgram(); |
| 1260 SetUseProgram(program->program()); | 1260 SetUseProgram(program->program()); |
| 1261 | 1261 |
| 1262 ToGLMatrix(&gl_matrix[0], quad->matrix); | 1262 ToGLMatrix(&gl_matrix[0], quad->matrix); |
| 1263 GLC(Context(), | 1263 GLC(Context(), |
| 1264 Context()->uniformMatrix4fv( | 1264 Context()->uniformMatrix4fv( |
| 1265 program->vertex_shader().texMatrixLocation(), 1, false, gl_matrix)); | 1265 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); |
| 1266 | 1266 |
| 1267 GLC(Context(), | 1267 GLC(Context(), |
| 1268 Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture_id)); | 1268 Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture_id)); |
| 1269 | 1269 |
| 1270 GLC(Context(), | 1270 GLC(Context(), |
| 1271 Context()->uniform1i(program->fragment_shader().samplerLocation(), 0)); | 1271 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 1272 | 1272 |
| 1273 SetShaderOpacity(quad->opacity(), program->fragment_shader().alphaLocation()); | 1273 SetShaderOpacity(quad->opacity(), program->fragment_shader().alpha_location()) ; |
|
enne (OOO)
2013/03/20 21:06:49
80 columns.
| |
| 1274 DrawQuadGeometry(frame, | 1274 DrawQuadGeometry(frame, |
| 1275 quad->quadTransform(), | 1275 quad->quadTransform(), |
| 1276 quad->rect, | 1276 quad->rect, |
| 1277 program->vertex_shader().matrixLocation()); | 1277 program->vertex_shader().matrix_location()); |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 struct TextureProgramBinding { | 1280 struct TextureProgramBinding { |
| 1281 template <class Program> | 1281 template <class Program> |
| 1282 void Set(Program* program, WebKit::WebGraphicsContext3D* context) { | 1282 void Set(Program* program, WebKit::WebGraphicsContext3D* context) { |
| 1283 DCHECK(program && (program->initialized() || context->isContextLost())); | 1283 DCHECK(program && (program->initialized() || context->isContextLost())); |
| 1284 program_id = program->program(); | 1284 program_id = program->program(); |
| 1285 sampler_location = program->fragment_shader().samplerLocation(); | 1285 sampler_location = program->fragment_shader().sampler_location(); |
| 1286 matrix_location = program->vertex_shader().matrixLocation(); | 1286 matrix_location = program->vertex_shader().matrix_location(); |
| 1287 alpha_location = program->fragment_shader().alphaLocation(); | 1287 alpha_location = program->fragment_shader().alpha_location(); |
| 1288 } | 1288 } |
| 1289 int program_id; | 1289 int program_id; |
| 1290 int sampler_location; | 1290 int sampler_location; |
| 1291 int matrix_location; | 1291 int matrix_location; |
| 1292 int alpha_location; | 1292 int alpha_location; |
| 1293 }; | 1293 }; |
| 1294 | 1294 |
| 1295 struct TexTransformTextureProgramBinding : TextureProgramBinding { | 1295 struct TexTransformTextureProgramBinding : TextureProgramBinding { |
| 1296 template <class Program> | 1296 template <class Program> |
| 1297 void Set(Program* program, WebKit::WebGraphicsContext3D* context) { | 1297 void Set(Program* program, WebKit::WebGraphicsContext3D* context) { |
| 1298 TextureProgramBinding::Set(program, context); | 1298 TextureProgramBinding::Set(program, context); |
| 1299 tex_transform_location = program->vertex_shader().texTransformLocation(); | 1299 tex_transform_location = program->vertex_shader().tex_transform_location(); |
| 1300 vertex_opacity_location = program->vertex_shader().vertexOpacityLocation(); | 1300 vertex_opacity_location = program->vertex_shader().vertex_opacity_location() ; |
|
enne (OOO)
2013/03/20 21:06:49
80 columns.
| |
| 1301 } | 1301 } |
| 1302 int tex_transform_location; | 1302 int tex_transform_location; |
| 1303 int vertex_opacity_location; | 1303 int vertex_opacity_location; |
| 1304 }; | 1304 }; |
| 1305 | 1305 |
| 1306 void GLRenderer::FlushTextureQuadCache() { | 1306 void GLRenderer::FlushTextureQuadCache() { |
| 1307 // Check to see if we have anything to draw. | 1307 // Check to see if we have anything to draw. |
| 1308 if (draw_cache_.program_id == 0) | 1308 if (draw_cache_.program_id == 0) |
| 1309 return; | 1309 return; |
| 1310 | 1310 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame& frame, | 1616 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame& frame, |
| 1617 int texture_id, | 1617 int texture_id, |
| 1618 gfx::Rect rect, | 1618 gfx::Rect rect, |
| 1619 const gfx::Transform& draw_matrix) { | 1619 const gfx::Transform& draw_matrix) { |
| 1620 const RenderPassProgram* program = GetRenderPassProgram(); | 1620 const RenderPassProgram* program = GetRenderPassProgram(); |
| 1621 | 1621 |
| 1622 GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id)); | 1622 GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id)); |
| 1623 | 1623 |
| 1624 SetUseProgram(program->program()); | 1624 SetUseProgram(program->program()); |
| 1625 GLC(Context(), | 1625 GLC(Context(), |
| 1626 Context()->uniform1i(program->fragment_shader().samplerLocation(), 0)); | 1626 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 1627 GLC(Context(), | 1627 GLC(Context(), |
| 1628 Context()->uniform4f(program->vertex_shader().texTransformLocation(), | 1628 Context()->uniform4f(program->vertex_shader().tex_transform_location(), |
| 1629 0.0f, | 1629 0.0f, |
| 1630 0.0f, | 1630 0.0f, |
| 1631 1.0f, | 1631 1.0f, |
| 1632 1.0f)); | 1632 1.0f)); |
| 1633 SetShaderOpacity(1, program->fragment_shader().alphaLocation()); | 1633 SetShaderOpacity(1, program->fragment_shader().alpha_location()); |
| 1634 DrawQuadGeometry( | 1634 DrawQuadGeometry( |
| 1635 frame, draw_matrix, rect, program->vertex_shader().matrixLocation()); | 1635 frame, draw_matrix, rect, program->vertex_shader().matrix_location()); |
| 1636 } | 1636 } |
| 1637 | 1637 |
| 1638 void GLRenderer::Finish() { | 1638 void GLRenderer::Finish() { |
| 1639 TRACE_EVENT0("cc", "GLRenderer::finish"); | 1639 TRACE_EVENT0("cc", "GLRenderer::finish"); |
| 1640 context_->finish(); | 1640 context_->finish(); |
| 1641 } | 1641 } |
| 1642 | 1642 |
| 1643 bool GLRenderer::SwapBuffers() { | 1643 bool GLRenderer::SwapBuffers() { |
| 1644 DCHECK(visible_); | 1644 DCHECK(visible_); |
| 1645 DCHECK(!is_backbuffer_discarded_); | 1645 DCHECK(!is_backbuffer_discarded_); |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2223 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2223 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
| 2224 | 2224 |
| 2225 ReleaseRenderPassTextures(); | 2225 ReleaseRenderPassTextures(); |
| 2226 } | 2226 } |
| 2227 | 2227 |
| 2228 bool GLRenderer::IsContextLost() { | 2228 bool GLRenderer::IsContextLost() { |
| 2229 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2229 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2230 } | 2230 } |
| 2231 | 2231 |
| 2232 } // namespace cc | 2232 } // namespace cc |
| OLD | NEW |