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

Side by Side Diff: cc/output/gl_renderer.cc

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

Powered by Google App Engine
This is Rietveld 408576698