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

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

Issue 1065463002: cc: Remove GLC macro (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/shader.cc » ('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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 375
376 in_use_overlay_resources_.clear(); 376 in_use_overlay_resources_.clear();
377 377
378 CleanupSharedObjects(); 378 CleanupSharedObjects();
379 } 379 }
380 380
381 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const { 381 const RendererCapabilitiesImpl& GLRenderer::Capabilities() const {
382 return capabilities_; 382 return capabilities_;
383 } 383 }
384 384
385 void GLRenderer::DebugGLCall(GLES2Interface* gl,
386 const char* command,
387 const char* file,
388 int line) {
389 GLuint error = gl->GetError();
390 if (error != GL_NO_ERROR)
391 LOG(ERROR) << "GL command failed: File: " << file << "\n\tLine " << line
392 << "\n\tcommand: " << command << ", error "
393 << static_cast<int>(error) << "\n";
394 }
395
396 void GLRenderer::DidChangeVisibility() { 385 void GLRenderer::DidChangeVisibility() {
397 EnforceMemoryPolicy(); 386 EnforceMemoryPolicy();
398 387
399 context_support_->SetSurfaceVisible(visible()); 388 context_support_->SetSurfaceVisible(visible());
400 } 389 }
401 390
402 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); } 391 void GLRenderer::ReleaseRenderPassTextures() { render_pass_textures_.clear(); }
403 392
404 void GLRenderer::DiscardPixels() { 393 void GLRenderer::DiscardPixels() {
405 if (!capabilities_.using_discard_framebuffer) 394 if (!capabilities_.using_discard_framebuffer)
(...skipping 26 matching lines...) Expand all
432 SetScissorTestRect(render_pass_scissor); 421 SetScissorTestRect(render_pass_scissor);
433 ClearFramebuffer(frame); 422 ClearFramebuffer(frame);
434 break; 423 break;
435 } 424 }
436 } 425 }
437 426
438 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) { 427 void GLRenderer::ClearFramebuffer(DrawingFrame* frame) {
439 // On DEBUG builds, opaque render passes are cleared to blue to easily see 428 // On DEBUG builds, opaque render passes are cleared to blue to easily see
440 // regions that were not drawn on the screen. 429 // regions that were not drawn on the screen.
441 if (frame->current_render_pass->has_transparent_background) 430 if (frame->current_render_pass->has_transparent_background)
442 GLC(gl_, gl_->ClearColor(0, 0, 0, 0)); 431 gl_->ClearColor(0, 0, 0, 0);
443 else 432 else
444 GLC(gl_, gl_->ClearColor(0, 0, 1, 1)); 433 gl_->ClearColor(0, 0, 1, 1);
445 434
446 bool always_clear = false; 435 bool always_clear = false;
447 #ifndef NDEBUG 436 #ifndef NDEBUG
448 always_clear = true; 437 always_clear = true;
449 #endif 438 #endif
450 if (always_clear || frame->current_render_pass->has_transparent_background) { 439 if (always_clear || frame->current_render_pass->has_transparent_background) {
451 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT; 440 GLbitfield clear_bits = GL_COLOR_BUFFER_BIT;
452 if (always_clear) 441 if (always_clear)
453 clear_bits |= GL_STENCIL_BUFFER_BIT; 442 clear_bits |= GL_STENCIL_BUFFER_BIT;
454 gl_->Clear(clear_bits); 443 gl_->Clear(clear_bits);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 for (const auto& pass : *frame->render_passes_in_draw_order) { 491 for (const auto& pass : *frame->render_passes_in_draw_order) {
503 for (const auto& quad : pass->quad_list) 492 for (const auto& quad : pass->quad_list)
504 quad->IterateResources(wait_on_resource_syncpoints_callback); 493 quad->IterateResources(wait_on_resource_syncpoints_callback);
505 } 494 }
506 495
507 // TODO(enne): Do we need to reinitialize all of this state per frame? 496 // TODO(enne): Do we need to reinitialize all of this state per frame?
508 ReinitializeGLState(); 497 ReinitializeGLState();
509 } 498 }
510 499
511 void GLRenderer::DoNoOp() { 500 void GLRenderer::DoNoOp() {
512 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); 501 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0);
513 GLC(gl_, gl_->Flush()); 502 gl_->Flush();
514 } 503 }
515 504
516 void GLRenderer::DoDrawQuad(DrawingFrame* frame, 505 void GLRenderer::DoDrawQuad(DrawingFrame* frame,
517 const DrawQuad* quad, 506 const DrawQuad* quad,
518 const gfx::QuadF* clip_region) { 507 const gfx::QuadF* clip_region) {
519 DCHECK(quad->rect.Contains(quad->visible_rect)); 508 DCHECK(quad->rect.Contains(quad->visible_rect));
520 if (quad->material != DrawQuad::TEXTURE_CONTENT) { 509 if (quad->material != DrawQuad::TEXTURE_CONTENT) {
521 FlushTextureQuadCache(SHARED_BINDING); 510 FlushTextureQuadCache(SHARED_BINDING);
522 } 511 }
523 512
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 if (clip_region) { 569 if (clip_region) {
581 return; 570 return;
582 } 571 }
583 SetBlendEnabled(quad->ShouldDrawWithBlending()); 572 SetBlendEnabled(quad->ShouldDrawWithBlending());
584 573
585 const TileCheckerboardProgram* program = GetTileCheckerboardProgram(); 574 const TileCheckerboardProgram* program = GetTileCheckerboardProgram();
586 DCHECK(program && (program->initialized() || IsContextLost())); 575 DCHECK(program && (program->initialized() || IsContextLost()));
587 SetUseProgram(program->program()); 576 SetUseProgram(program->program());
588 577
589 SkColor color = quad->color; 578 SkColor color = quad->color;
590 GLC(gl_, 579 gl_->Uniform4f(program->fragment_shader().color_location(),
591 gl_->Uniform4f(program->fragment_shader().color_location(), 580 SkColorGetR(color) * (1.0f / 255.0f),
592 SkColorGetR(color) * (1.0f / 255.0f), 581 SkColorGetG(color) * (1.0f / 255.0f),
593 SkColorGetG(color) * (1.0f / 255.0f), 582 SkColorGetB(color) * (1.0f / 255.0f), 1);
594 SkColorGetB(color) * (1.0f / 255.0f),
595 1));
596 583
597 const int kCheckerboardWidth = 16; 584 const int kCheckerboardWidth = 16;
598 float frequency = 1.0f / kCheckerboardWidth; 585 float frequency = 1.0f / kCheckerboardWidth;
599 586
600 gfx::Rect tile_rect = quad->rect; 587 gfx::Rect tile_rect = quad->rect;
601 float tex_offset_x = 588 float tex_offset_x =
602 static_cast<int>(tile_rect.x() / quad->scale) % kCheckerboardWidth; 589 static_cast<int>(tile_rect.x() / quad->scale) % kCheckerboardWidth;
603 float tex_offset_y = 590 float tex_offset_y =
604 static_cast<int>(tile_rect.y() / quad->scale) % kCheckerboardWidth; 591 static_cast<int>(tile_rect.y() / quad->scale) % kCheckerboardWidth;
605 float tex_scale_x = tile_rect.width() / quad->scale; 592 float tex_scale_x = tile_rect.width() / quad->scale;
606 float tex_scale_y = tile_rect.height() / quad->scale; 593 float tex_scale_y = tile_rect.height() / quad->scale;
607 GLC(gl_, 594 gl_->Uniform4f(program->fragment_shader().tex_transform_location(),
608 gl_->Uniform4f(program->fragment_shader().tex_transform_location(), 595 tex_offset_x, tex_offset_y, tex_scale_x, tex_scale_y);
609 tex_offset_x,
610 tex_offset_y,
611 tex_scale_x,
612 tex_scale_y));
613 596
614 GLC(gl_, 597 gl_->Uniform1f(program->fragment_shader().frequency_location(), frequency);
615 gl_->Uniform1f(program->fragment_shader().frequency_location(),
616 frequency));
617 598
618 SetShaderOpacity(quad->opacity(), 599 SetShaderOpacity(quad->opacity(),
619 program->fragment_shader().alpha_location()); 600 program->fragment_shader().alpha_location());
620 DrawQuadGeometry(frame, 601 DrawQuadGeometry(frame,
621 quad->quadTransform(), 602 quad->quadTransform(),
622 quad->rect, 603 quad->rect,
623 program->vertex_shader().matrix_location()); 604 program->vertex_shader().matrix_location());
624 } 605 }
625 606
626 // This function does not handle 3D sorting right now, since the debug border 607 // This function does not handle 3D sorting right now, since the debug border
627 // quads are just drawn as their original quads and not in split pieces. This 608 // quads are just drawn as their original quads and not in split pieces. This
628 // results in some debug border quads drawing over foreground quads. 609 // results in some debug border quads drawing over foreground quads.
629 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame, 610 void GLRenderer::DrawDebugBorderQuad(const DrawingFrame* frame,
630 const DebugBorderDrawQuad* quad) { 611 const DebugBorderDrawQuad* quad) {
631 SetBlendEnabled(quad->ShouldDrawWithBlending()); 612 SetBlendEnabled(quad->ShouldDrawWithBlending());
632 613
633 static float gl_matrix[16]; 614 static float gl_matrix[16];
634 const DebugBorderProgram* program = GetDebugBorderProgram(); 615 const DebugBorderProgram* program = GetDebugBorderProgram();
635 DCHECK(program && (program->initialized() || IsContextLost())); 616 DCHECK(program && (program->initialized() || IsContextLost()));
636 SetUseProgram(program->program()); 617 SetUseProgram(program->program());
637 618
638 // Use the full quad_rect for debug quads to not move the edges based on 619 // Use the full quad_rect for debug quads to not move the edges based on
639 // partial swaps. 620 // partial swaps.
640 gfx::Rect layer_rect = quad->rect; 621 gfx::Rect layer_rect = quad->rect;
641 gfx::Transform render_matrix; 622 gfx::Transform render_matrix;
642 QuadRectTransform(&render_matrix, quad->quadTransform(), layer_rect); 623 QuadRectTransform(&render_matrix, quad->quadTransform(), layer_rect);
643 GLRenderer::ToGLMatrix(&gl_matrix[0], 624 GLRenderer::ToGLMatrix(&gl_matrix[0],
644 frame->projection_matrix * render_matrix); 625 frame->projection_matrix * render_matrix);
645 GLC(gl_, 626 gl_->UniformMatrix4fv(program->vertex_shader().matrix_location(), 1, false,
646 gl_->UniformMatrix4fv( 627 &gl_matrix[0]);
647 program->vertex_shader().matrix_location(), 1, false, &gl_matrix[0]));
648 628
649 SkColor color = quad->color; 629 SkColor color = quad->color;
650 float alpha = SkColorGetA(color) * (1.0f / 255.0f); 630 float alpha = SkColorGetA(color) * (1.0f / 255.0f);
651 631
652 GLC(gl_, 632 gl_->Uniform4f(program->fragment_shader().color_location(),
653 gl_->Uniform4f(program->fragment_shader().color_location(), 633 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
654 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 634 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
655 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 635 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, alpha);
656 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
657 alpha));
658 636
659 GLC(gl_, gl_->LineWidth(quad->width)); 637 gl_->LineWidth(quad->width);
660 638
661 // The indices for the line are stored in the same array as the triangle 639 // The indices for the line are stored in the same array as the triangle
662 // indices. 640 // indices.
663 GLC(gl_, gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0)); 641 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0);
664 } 642 }
665 643
666 static skia::RefPtr<SkImage> ApplyImageFilter( 644 static skia::RefPtr<SkImage> ApplyImageFilter(
667 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, 645 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
668 ResourceProvider* resource_provider, 646 ResourceProvider* resource_provider,
669 const gfx::Rect& rect, 647 const gfx::Rect& rect,
670 const gfx::Vector2dF& scale, 648 const gfx::Vector2dF& scale,
671 SkImageFilter* filter, 649 SkImageFilter* filter,
672 ScopedResource* source_texture_resource) { 650 ScopedResource* source_texture_resource) {
673 if (!filter) 651 if (!filter)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 case SkXfermode::kColor_Mode: 791 case SkXfermode::kColor_Mode:
814 equation = GL_HSL_COLOR_KHR; 792 equation = GL_HSL_COLOR_KHR;
815 break; 793 break;
816 case SkXfermode::kLuminosity_Mode: 794 case SkXfermode::kLuminosity_Mode:
817 equation = GL_HSL_LUMINOSITY_KHR; 795 equation = GL_HSL_LUMINOSITY_KHR;
818 break; 796 break;
819 default: 797 default:
820 return; 798 return;
821 } 799 }
822 800
823 GLC(gl_, gl_->BlendEquation(equation)); 801 gl_->BlendEquation(equation);
824 } else { 802 } else {
825 if (blend_mode == SkXfermode::kScreen_Mode) { 803 if (blend_mode == SkXfermode::kScreen_Mode) {
826 GLC(gl_, gl_->BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE)); 804 gl_->BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
827 } 805 }
828 } 806 }
829 } 807 }
830 808
831 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) { 809 void GLRenderer::RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode) {
832 if (blend_mode == SkXfermode::kSrcOver_Mode) 810 if (blend_mode == SkXfermode::kSrcOver_Mode)
833 return; 811 return;
834 812
835 if (use_blend_equation_advanced_) { 813 if (use_blend_equation_advanced_) {
836 GLC(gl_, gl_->BlendEquation(GL_FUNC_ADD)); 814 gl_->BlendEquation(GL_FUNC_ADD);
837 } else { 815 } else {
838 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 816 gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
839 } 817 }
840 } 818 }
841 819
842 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame, 820 bool GLRenderer::ShouldApplyBackgroundFilters(DrawingFrame* frame,
843 const RenderPassDrawQuad* quad) { 821 const RenderPassDrawQuad* quad) {
844 if (quad->background_filters.IsEmpty()) 822 if (quad->background_filters.IsEmpty())
845 return false; 823 return false;
846 824
847 // TODO(danakj): We only allow background filters on an opaque render surface 825 // TODO(danakj): We only allow background filters on an opaque render surface
848 // because other surfaces may contain translucent pixels, and the contents 826 // because other surfaces may contain translucent pixels, and the contents
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 } else { 1064 } else {
1087 contents_resource_lock = 1065 contents_resource_lock =
1088 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( 1066 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL(
1089 resource_provider_, contents_texture->id(), GL_LINEAR)); 1067 resource_provider_, contents_texture->id(), GL_LINEAR));
1090 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1068 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1091 contents_resource_lock->target()); 1069 contents_resource_lock->target());
1092 } 1070 }
1093 1071
1094 if (!use_shaders_for_blending) { 1072 if (!use_shaders_for_blending) {
1095 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) 1073 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_)
1096 GLC(gl_, gl_->BlendBarrierKHR()); 1074 gl_->BlendBarrierKHR();
1097 1075
1098 ApplyBlendModeUsingBlendFunc(blend_mode); 1076 ApplyBlendModeUsingBlendFunc(blend_mode);
1099 } 1077 }
1100 1078
1101 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1079 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1102 gl_, 1080 gl_,
1103 &highp_threshold_cache_, 1081 &highp_threshold_cache_,
1104 highp_threshold_min_, 1082 highp_threshold_min_,
1105 quad->shared_quad_state->visible_content_rect.bottom_right()); 1083 quad->shared_quad_state->visible_content_rect.bottom_right());
1106 1084
1107 ShaderLocations locations; 1085 ShaderLocations locations;
1108 1086
1109 DCHECK_EQ(background_texture || background_image, use_shaders_for_blending); 1087 DCHECK_EQ(background_texture || background_image, use_shaders_for_blending);
1110 BlendMode shader_blend_mode = use_shaders_for_blending 1088 BlendMode shader_blend_mode = use_shaders_for_blending
1111 ? BlendModeFromSkXfermode(blend_mode) 1089 ? BlendModeFromSkXfermode(blend_mode)
1112 : BLEND_MODE_NONE; 1090 : BLEND_MODE_NONE;
1113 1091
1114 if (use_aa && mask_texture_id && !use_color_matrix) { 1092 if (use_aa && mask_texture_id && !use_color_matrix) {
1115 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA( 1093 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA(
1116 tex_coord_precision, mask_sampler, 1094 tex_coord_precision, mask_sampler,
1117 shader_blend_mode, mask_for_background); 1095 shader_blend_mode, mask_for_background);
1118 SetUseProgram(program->program()); 1096 SetUseProgram(program->program());
1119 program->vertex_shader().FillLocations(&locations); 1097 program->vertex_shader().FillLocations(&locations);
1120 program->fragment_shader().FillLocations(&locations); 1098 program->fragment_shader().FillLocations(&locations);
1121 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1099 gl_->Uniform1i(locations.sampler, 0);
1122 } else if (!use_aa && mask_texture_id && !use_color_matrix) { 1100 } else if (!use_aa && mask_texture_id && !use_color_matrix) {
1123 const RenderPassMaskProgram* program = GetRenderPassMaskProgram( 1101 const RenderPassMaskProgram* program = GetRenderPassMaskProgram(
1124 tex_coord_precision, mask_sampler, 1102 tex_coord_precision, mask_sampler,
1125 shader_blend_mode, mask_for_background); 1103 shader_blend_mode, mask_for_background);
1126 SetUseProgram(program->program()); 1104 SetUseProgram(program->program());
1127 program->vertex_shader().FillLocations(&locations); 1105 program->vertex_shader().FillLocations(&locations);
1128 program->fragment_shader().FillLocations(&locations); 1106 program->fragment_shader().FillLocations(&locations);
1129 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1107 gl_->Uniform1i(locations.sampler, 0);
1130 } else if (use_aa && !mask_texture_id && !use_color_matrix) { 1108 } else if (use_aa && !mask_texture_id && !use_color_matrix) {
1131 const RenderPassProgramAA* program = 1109 const RenderPassProgramAA* program =
1132 GetRenderPassProgramAA(tex_coord_precision, shader_blend_mode); 1110 GetRenderPassProgramAA(tex_coord_precision, shader_blend_mode);
1133 SetUseProgram(program->program()); 1111 SetUseProgram(program->program());
1134 program->vertex_shader().FillLocations(&locations); 1112 program->vertex_shader().FillLocations(&locations);
1135 program->fragment_shader().FillLocations(&locations); 1113 program->fragment_shader().FillLocations(&locations);
1136 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1114 gl_->Uniform1i(locations.sampler, 0);
1137 } else if (use_aa && mask_texture_id && use_color_matrix) { 1115 } else if (use_aa && mask_texture_id && use_color_matrix) {
1138 const RenderPassMaskColorMatrixProgramAA* program = 1116 const RenderPassMaskColorMatrixProgramAA* program =
1139 GetRenderPassMaskColorMatrixProgramAA( 1117 GetRenderPassMaskColorMatrixProgramAA(
1140 tex_coord_precision, mask_sampler, 1118 tex_coord_precision, mask_sampler,
1141 shader_blend_mode, mask_for_background); 1119 shader_blend_mode, mask_for_background);
1142 SetUseProgram(program->program()); 1120 SetUseProgram(program->program());
1143 program->vertex_shader().FillLocations(&locations); 1121 program->vertex_shader().FillLocations(&locations);
1144 program->fragment_shader().FillLocations(&locations); 1122 program->fragment_shader().FillLocations(&locations);
1145 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1123 gl_->Uniform1i(locations.sampler, 0);
1146 } else if (use_aa && !mask_texture_id && use_color_matrix) { 1124 } else if (use_aa && !mask_texture_id && use_color_matrix) {
1147 const RenderPassColorMatrixProgramAA* program = 1125 const RenderPassColorMatrixProgramAA* program =
1148 GetRenderPassColorMatrixProgramAA(tex_coord_precision, 1126 GetRenderPassColorMatrixProgramAA(tex_coord_precision,
1149 shader_blend_mode); 1127 shader_blend_mode);
1150 SetUseProgram(program->program()); 1128 SetUseProgram(program->program());
1151 program->vertex_shader().FillLocations(&locations); 1129 program->vertex_shader().FillLocations(&locations);
1152 program->fragment_shader().FillLocations(&locations); 1130 program->fragment_shader().FillLocations(&locations);
1153 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1131 gl_->Uniform1i(locations.sampler, 0);
1154 } else if (!use_aa && mask_texture_id && use_color_matrix) { 1132 } else if (!use_aa && mask_texture_id && use_color_matrix) {
1155 const RenderPassMaskColorMatrixProgram* program = 1133 const RenderPassMaskColorMatrixProgram* program =
1156 GetRenderPassMaskColorMatrixProgram( 1134 GetRenderPassMaskColorMatrixProgram(
1157 tex_coord_precision, mask_sampler, 1135 tex_coord_precision, mask_sampler,
1158 shader_blend_mode, mask_for_background); 1136 shader_blend_mode, mask_for_background);
1159 SetUseProgram(program->program()); 1137 SetUseProgram(program->program());
1160 program->vertex_shader().FillLocations(&locations); 1138 program->vertex_shader().FillLocations(&locations);
1161 program->fragment_shader().FillLocations(&locations); 1139 program->fragment_shader().FillLocations(&locations);
1162 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1140 gl_->Uniform1i(locations.sampler, 0);
1163 } else if (!use_aa && !mask_texture_id && use_color_matrix) { 1141 } else if (!use_aa && !mask_texture_id && use_color_matrix) {
1164 const RenderPassColorMatrixProgram* program = 1142 const RenderPassColorMatrixProgram* program =
1165 GetRenderPassColorMatrixProgram(tex_coord_precision, shader_blend_mode); 1143 GetRenderPassColorMatrixProgram(tex_coord_precision, shader_blend_mode);
1166 SetUseProgram(program->program()); 1144 SetUseProgram(program->program());
1167 program->vertex_shader().FillLocations(&locations); 1145 program->vertex_shader().FillLocations(&locations);
1168 program->fragment_shader().FillLocations(&locations); 1146 program->fragment_shader().FillLocations(&locations);
1169 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1147 gl_->Uniform1i(locations.sampler, 0);
1170 } else { 1148 } else {
1171 const RenderPassProgram* program = 1149 const RenderPassProgram* program =
1172 GetRenderPassProgram(tex_coord_precision, shader_blend_mode); 1150 GetRenderPassProgram(tex_coord_precision, shader_blend_mode);
1173 SetUseProgram(program->program()); 1151 SetUseProgram(program->program());
1174 program->vertex_shader().FillLocations(&locations); 1152 program->vertex_shader().FillLocations(&locations);
1175 program->fragment_shader().FillLocations(&locations); 1153 program->fragment_shader().FillLocations(&locations);
1176 GLC(gl_, gl_->Uniform1i(locations.sampler, 0)); 1154 gl_->Uniform1i(locations.sampler, 0);
1177 } 1155 }
1178 float tex_scale_x = 1156 float tex_scale_x =
1179 quad->rect.width() / static_cast<float>(contents_texture->size().width()); 1157 quad->rect.width() / static_cast<float>(contents_texture->size().width());
1180 float tex_scale_y = quad->rect.height() / 1158 float tex_scale_y = quad->rect.height() /
1181 static_cast<float>(contents_texture->size().height()); 1159 static_cast<float>(contents_texture->size().height());
1182 DCHECK_LE(tex_scale_x, 1.0f); 1160 DCHECK_LE(tex_scale_x, 1.0f);
1183 DCHECK_LE(tex_scale_y, 1.0f); 1161 DCHECK_LE(tex_scale_y, 1.0f);
1184 1162
1185 DCHECK(locations.tex_transform != -1 || IsContextLost()); 1163 DCHECK(locations.tex_transform != -1 || IsContextLost());
1186 // Flip the content vertically in the shader, as the RenderPass input 1164 // Flip the content vertically in the shader, as the RenderPass input
1187 // texture is already oriented the same way as the framebuffer, but the 1165 // texture is already oriented the same way as the framebuffer, but the
1188 // projection transform does a flip. 1166 // projection transform does a flip.
1189 GLC(gl_, 1167 gl_->Uniform4f(locations.tex_transform, 0.0f, tex_scale_y, tex_scale_x,
1190 gl_->Uniform4f(locations.tex_transform, 1168 -tex_scale_y);
1191 0.0f,
1192 tex_scale_y,
1193 tex_scale_x,
1194 -tex_scale_y));
1195 1169
1196 GLint last_texture_unit = 0; 1170 GLint last_texture_unit = 0;
1197 if (locations.mask_sampler != -1) { 1171 if (locations.mask_sampler != -1) {
1198 DCHECK_NE(locations.mask_tex_coord_scale, 1); 1172 DCHECK_NE(locations.mask_tex_coord_scale, 1);
1199 DCHECK_NE(locations.mask_tex_coord_offset, 1); 1173 DCHECK_NE(locations.mask_tex_coord_offset, 1);
1200 GLC(gl_, gl_->Uniform1i(locations.mask_sampler, 1)); 1174 gl_->Uniform1i(locations.mask_sampler, 1);
1201 1175
1202 gfx::RectF mask_uv_rect = quad->MaskUVRect(); 1176 gfx::RectF mask_uv_rect = quad->MaskUVRect();
1203 if (mask_sampler != SAMPLER_TYPE_2D) { 1177 if (mask_sampler != SAMPLER_TYPE_2D) {
1204 mask_uv_rect.Scale(quad->mask_texture_size.width(), 1178 mask_uv_rect.Scale(quad->mask_texture_size.width(),
1205 quad->mask_texture_size.height()); 1179 quad->mask_texture_size.height());
1206 } 1180 }
1207 1181
1208 // Mask textures are oriented vertically flipped relative to the framebuffer 1182 // Mask textures are oriented vertically flipped relative to the framebuffer
1209 // and the RenderPass contents texture, so we flip the tex coords from the 1183 // and the RenderPass contents texture, so we flip the tex coords from the
1210 // RenderPass texture to find the mask texture coords. 1184 // RenderPass texture to find the mask texture coords.
1211 GLC(gl_, 1185 gl_->Uniform2f(locations.mask_tex_coord_offset, mask_uv_rect.x(),
1212 gl_->Uniform2f(locations.mask_tex_coord_offset, 1186 mask_uv_rect.bottom());
1213 mask_uv_rect.x(), 1187 gl_->Uniform2f(locations.mask_tex_coord_scale,
1214 mask_uv_rect.bottom())); 1188 mask_uv_rect.width() / tex_scale_x,
1215 GLC(gl_, 1189 -mask_uv_rect.height() / tex_scale_y);
1216 gl_->Uniform2f(locations.mask_tex_coord_scale,
1217 mask_uv_rect.width() / tex_scale_x,
1218 -mask_uv_rect.height() / tex_scale_y));
1219 1190
1220 last_texture_unit = 1; 1191 last_texture_unit = 1;
1221 } 1192 }
1222 1193
1223 if (locations.edge != -1) 1194 if (locations.edge != -1)
1224 GLC(gl_, gl_->Uniform3fv(locations.edge, 8, edge)); 1195 gl_->Uniform3fv(locations.edge, 8, edge);
1225 1196
1226 if (locations.viewport != -1) { 1197 if (locations.viewport != -1) {
1227 float viewport[4] = { 1198 float viewport[4] = {
1228 static_cast<float>(current_window_space_viewport_.x()), 1199 static_cast<float>(current_window_space_viewport_.x()),
1229 static_cast<float>(current_window_space_viewport_.y()), 1200 static_cast<float>(current_window_space_viewport_.y()),
1230 static_cast<float>(current_window_space_viewport_.width()), 1201 static_cast<float>(current_window_space_viewport_.width()),
1231 static_cast<float>(current_window_space_viewport_.height()), 1202 static_cast<float>(current_window_space_viewport_.height()),
1232 }; 1203 };
1233 GLC(gl_, gl_->Uniform4fv(locations.viewport, 1, viewport)); 1204 gl_->Uniform4fv(locations.viewport, 1, viewport);
1234 } 1205 }
1235 1206
1236 if (locations.color_matrix != -1) { 1207 if (locations.color_matrix != -1) {
1237 float matrix[16]; 1208 float matrix[16];
1238 for (int i = 0; i < 4; ++i) { 1209 for (int i = 0; i < 4; ++i) {
1239 for (int j = 0; j < 4; ++j) 1210 for (int j = 0; j < 4; ++j)
1240 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]); 1211 matrix[i * 4 + j] = SkScalarToFloat(color_matrix[j * 5 + i]);
1241 } 1212 }
1242 GLC(gl_, 1213 gl_->UniformMatrix4fv(locations.color_matrix, 1, false, matrix);
1243 gl_->UniformMatrix4fv(locations.color_matrix, 1, false, matrix));
1244 } 1214 }
1245 static const float kScale = 1.0f / 255.0f; 1215 static const float kScale = 1.0f / 255.0f;
1246 if (locations.color_offset != -1) { 1216 if (locations.color_offset != -1) {
1247 float offset[4]; 1217 float offset[4];
1248 for (int i = 0; i < 4; ++i) 1218 for (int i = 0; i < 4; ++i)
1249 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; 1219 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale;
1250 1220
1251 GLC(gl_, gl_->Uniform4fv(locations.color_offset, 1, offset)); 1221 gl_->Uniform4fv(locations.color_offset, 1, offset);
1252 } 1222 }
1253 1223
1254 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_background_sampler_lock; 1224 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_background_sampler_lock;
1255 if (locations.backdrop != -1) { 1225 if (locations.backdrop != -1) {
1256 DCHECK(background_texture || background_image); 1226 DCHECK(background_texture || background_image);
1257 DCHECK_NE(locations.backdrop, 0); 1227 DCHECK_NE(locations.backdrop, 0);
1258 DCHECK_NE(locations.backdrop_rect, 0); 1228 DCHECK_NE(locations.backdrop_rect, 0);
1259 1229
1260 GLC(gl_, gl_->Uniform1i(locations.backdrop, ++last_texture_unit)); 1230 gl_->Uniform1i(locations.backdrop, ++last_texture_unit);
1261 1231
1262 GLC(gl_, 1232 gl_->Uniform4f(locations.backdrop_rect, background_rect.x(),
1263 gl_->Uniform4f(locations.backdrop_rect, 1233 background_rect.y(), background_rect.width(),
1264 background_rect.x(), 1234 background_rect.height());
1265 background_rect.y(),
1266 background_rect.width(),
1267 background_rect.height()));
1268 1235
1269 if (background_image) { 1236 if (background_image) {
1270 GrTexture* texture = background_image->getTexture(); 1237 GrTexture* texture = background_image->getTexture();
1271 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit)); 1238 gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit);
1272 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); 1239 gl_->BindTexture(GL_TEXTURE_2D, texture->getTextureHandle());
1273 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); 1240 gl_->ActiveTexture(GL_TEXTURE0);
1274 if (mask_for_background) 1241 if (mask_for_background)
1275 GLC(gl_, gl_->Uniform1i(locations.original_backdrop, 1242 gl_->Uniform1i(locations.original_backdrop, ++last_texture_unit);
1276 ++last_texture_unit));
1277 } 1243 }
1278 if (background_texture) { 1244 if (background_texture) {
1279 shader_background_sampler_lock = make_scoped_ptr( 1245 shader_background_sampler_lock = make_scoped_ptr(
1280 new ResourceProvider::ScopedSamplerGL(resource_provider_, 1246 new ResourceProvider::ScopedSamplerGL(resource_provider_,
1281 background_texture->id(), 1247 background_texture->id(),
1282 GL_TEXTURE0 + last_texture_unit, 1248 GL_TEXTURE0 + last_texture_unit,
1283 GL_LINEAR)); 1249 GL_LINEAR));
1284 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), 1250 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D),
1285 shader_background_sampler_lock->target()); 1251 shader_background_sampler_lock->target());
1286 } 1252 }
1287 } 1253 }
1288 1254
1289 SetShaderOpacity(quad->opacity(), locations.alpha); 1255 SetShaderOpacity(quad->opacity(), locations.alpha);
1290 SetShaderQuadF(surface_quad, locations.quad); 1256 SetShaderQuadF(surface_quad, locations.quad);
1291 DrawQuadGeometry( 1257 DrawQuadGeometry(
1292 frame, quad->quadTransform(), quad->rect, locations.matrix); 1258 frame, quad->quadTransform(), quad->rect, locations.matrix);
1293 1259
1294 // Flush the compositor context before the filter bitmap goes out of 1260 // Flush the compositor context before the filter bitmap goes out of
1295 // scope, so the draw gets processed before the filter texture gets deleted. 1261 // scope, so the draw gets processed before the filter texture gets deleted.
1296 if (filter_image) 1262 if (filter_image)
1297 GLC(gl_, gl_->Flush()); 1263 gl_->Flush();
1298 1264
1299 if (!use_shaders_for_blending) 1265 if (!use_shaders_for_blending)
1300 RestoreBlendFuncToDefault(blend_mode); 1266 RestoreBlendFuncToDefault(blend_mode);
1301 } 1267 }
1302 1268
1303 struct SolidColorProgramUniforms { 1269 struct SolidColorProgramUniforms {
1304 unsigned program; 1270 unsigned program;
1305 unsigned matrix_location; 1271 unsigned matrix_location;
1306 unsigned viewport_location; 1272 unsigned viewport_location;
1307 unsigned quad_location; 1273 unsigned quad_location;
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 clip_region, &local_quad, edge); 1566 clip_region, &local_quad, edge);
1601 1567
1602 SolidColorProgramUniforms uniforms; 1568 SolidColorProgramUniforms uniforms;
1603 if (use_aa) { 1569 if (use_aa) {
1604 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms); 1570 SolidColorUniformLocation(GetSolidColorProgramAA(), &uniforms);
1605 } else { 1571 } else {
1606 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms); 1572 SolidColorUniformLocation(GetSolidColorProgram(), &uniforms);
1607 } 1573 }
1608 SetUseProgram(uniforms.program); 1574 SetUseProgram(uniforms.program);
1609 1575
1610 GLC(gl_, 1576 gl_->Uniform4f(uniforms.color_location,
1611 gl_->Uniform4f(uniforms.color_location, 1577 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha,
1612 (SkColorGetR(color) * (1.0f / 255.0f)) * alpha, 1578 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha,
1613 (SkColorGetG(color) * (1.0f / 255.0f)) * alpha, 1579 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, alpha);
1614 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha,
1615 alpha));
1616 if (use_aa) { 1580 if (use_aa) {
1617 float viewport[4] = { 1581 float viewport[4] = {
1618 static_cast<float>(current_window_space_viewport_.x()), 1582 static_cast<float>(current_window_space_viewport_.x()),
1619 static_cast<float>(current_window_space_viewport_.y()), 1583 static_cast<float>(current_window_space_viewport_.y()),
1620 static_cast<float>(current_window_space_viewport_.width()), 1584 static_cast<float>(current_window_space_viewport_.width()),
1621 static_cast<float>(current_window_space_viewport_.height()), 1585 static_cast<float>(current_window_space_viewport_.height()),
1622 }; 1586 };
1623 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport)); 1587 gl_->Uniform4fv(uniforms.viewport_location, 1, viewport);
1624 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge)); 1588 gl_->Uniform3fv(uniforms.edge_location, 8, edge);
1625 } 1589 }
1626 1590
1627 // Enable blending when the quad properties require it or if we decided 1591 // Enable blending when the quad properties require it or if we decided
1628 // to use antialiasing. 1592 // to use antialiasing.
1629 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa); 1593 SetBlendEnabled(quad->ShouldDrawWithBlending() || use_aa);
1630 1594
1631 // Normalize to tile_rect. 1595 // Normalize to tile_rect.
1632 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1596 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1633 1597
1634 SetShaderQuadF(local_quad, uniforms.quad_location); 1598 SetShaderQuadF(local_quad, uniforms.quad_location);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 TileProgramUniforms uniforms; 1737 TileProgramUniforms uniforms;
1774 if (quad->swizzle_contents) { 1738 if (quad->swizzle_contents) {
1775 TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision, sampler), 1739 TileUniformLocation(GetTileProgramSwizzleAA(tex_coord_precision, sampler),
1776 &uniforms); 1740 &uniforms);
1777 } else { 1741 } else {
1778 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler), 1742 TileUniformLocation(GetTileProgramAA(tex_coord_precision, sampler),
1779 &uniforms); 1743 &uniforms);
1780 } 1744 }
1781 1745
1782 SetUseProgram(uniforms.program); 1746 SetUseProgram(uniforms.program);
1783 GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0)); 1747 gl_->Uniform1i(uniforms.sampler_location, 0);
1784 1748
1785 float viewport[4] = { 1749 float viewport[4] = {
1786 static_cast<float>(current_window_space_viewport_.x()), 1750 static_cast<float>(current_window_space_viewport_.x()),
1787 static_cast<float>(current_window_space_viewport_.y()), 1751 static_cast<float>(current_window_space_viewport_.y()),
1788 static_cast<float>(current_window_space_viewport_.width()), 1752 static_cast<float>(current_window_space_viewport_.width()),
1789 static_cast<float>(current_window_space_viewport_.height()), 1753 static_cast<float>(current_window_space_viewport_.height()),
1790 }; 1754 };
1791 GLC(gl_, gl_->Uniform4fv(uniforms.viewport_location, 1, viewport)); 1755 gl_->Uniform4fv(uniforms.viewport_location, 1, viewport);
1792 GLC(gl_, gl_->Uniform3fv(uniforms.edge_location, 8, edge)); 1756 gl_->Uniform3fv(uniforms.edge_location, 8, edge);
1793 1757
1794 GLC(gl_, 1758 gl_->Uniform4f(uniforms.vertex_tex_transform_location, vertex_tex_translate_x,
1795 gl_->Uniform4f(uniforms.vertex_tex_transform_location, 1759 vertex_tex_translate_y, vertex_tex_scale_x,
1796 vertex_tex_translate_x, 1760 vertex_tex_scale_y);
1797 vertex_tex_translate_y, 1761 gl_->Uniform4f(uniforms.fragment_tex_transform_location,
1798 vertex_tex_scale_x, 1762 fragment_tex_translate_x, fragment_tex_translate_y,
1799 vertex_tex_scale_y)); 1763 fragment_tex_scale_x, fragment_tex_scale_y);
1800 GLC(gl_,
1801 gl_->Uniform4f(uniforms.fragment_tex_transform_location,
1802 fragment_tex_translate_x,
1803 fragment_tex_translate_y,
1804 fragment_tex_scale_x,
1805 fragment_tex_scale_y));
1806 1764
1807 // Blending is required for antialiasing. 1765 // Blending is required for antialiasing.
1808 SetBlendEnabled(true); 1766 SetBlendEnabled(true);
1809 1767
1810 // Normalize to tile_rect. 1768 // Normalize to tile_rect.
1811 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 1769 local_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
1812 1770
1813 SetShaderOpacity(quad->opacity(), uniforms.alpha_location); 1771 SetShaderOpacity(quad->opacity(), uniforms.alpha_location);
1814 SetShaderQuadF(local_quad, uniforms.quad_location); 1772 SetShaderQuadF(local_quad, uniforms.quad_location);
1815 1773
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 if (quad->swizzle_contents) { 1835 if (quad->swizzle_contents) {
1878 TileUniformLocation( 1836 TileUniformLocation(
1879 GetTileProgramSwizzleOpaque(tex_coord_precision, sampler), &uniforms); 1837 GetTileProgramSwizzleOpaque(tex_coord_precision, sampler), &uniforms);
1880 } else { 1838 } else {
1881 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision, sampler), 1839 TileUniformLocation(GetTileProgramOpaque(tex_coord_precision, sampler),
1882 &uniforms); 1840 &uniforms);
1883 } 1841 }
1884 } 1842 }
1885 1843
1886 SetUseProgram(uniforms.program); 1844 SetUseProgram(uniforms.program);
1887 GLC(gl_, gl_->Uniform1i(uniforms.sampler_location, 0)); 1845 gl_->Uniform1i(uniforms.sampler_location, 0);
1888 1846
1889 GLC(gl_, 1847 gl_->Uniform4f(uniforms.vertex_tex_transform_location, vertex_tex_translate_x,
1890 gl_->Uniform4f(uniforms.vertex_tex_transform_location, 1848 vertex_tex_translate_y, vertex_tex_scale_x,
1891 vertex_tex_translate_x, 1849 vertex_tex_scale_y);
1892 vertex_tex_translate_y,
1893 vertex_tex_scale_x,
1894 vertex_tex_scale_y));
1895 1850
1896 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1851 SetBlendEnabled(quad->ShouldDrawWithBlending());
1897 1852
1898 SetShaderOpacity(quad->opacity(), uniforms.alpha_location); 1853 SetShaderOpacity(quad->opacity(), uniforms.alpha_location);
1899 1854
1900 // Pass quad coordinates to the uniform in the same order as GeometryBinding 1855 // Pass quad coordinates to the uniform in the same order as GeometryBinding
1901 // does, then vertices will match the texture mapping in the vertex buffer. 1856 // does, then vertices will match the texture mapping in the vertex buffer.
1902 // The method SetShaderQuadF() changes the order of vertices and so it's 1857 // The method SetShaderQuadF() changes the order of vertices and so it's
1903 // not used here. 1858 // not used here.
1904 gfx::QuadF tile_rect(quad->visible_rect); 1859 gfx::QuadF tile_rect(quad->visible_rect);
(...skipping 21 matching lines...) Expand all
1926 float gl_quad[8] = { 1881 float gl_quad[8] = {
1927 tile_rect.p4().x(), 1882 tile_rect.p4().x(),
1928 tile_rect.p4().y(), 1883 tile_rect.p4().y(),
1929 tile_rect.p1().x(), 1884 tile_rect.p1().x(),
1930 tile_rect.p1().y(), 1885 tile_rect.p1().y(),
1931 tile_rect.p2().x(), 1886 tile_rect.p2().x(),
1932 tile_rect.p2().y(), 1887 tile_rect.p2().y(),
1933 tile_rect.p3().x(), 1888 tile_rect.p3().x(),
1934 tile_rect.p3().y(), 1889 tile_rect.p3().y(),
1935 }; 1890 };
1936 GLC(gl_, gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad)); 1891 gl_->Uniform2fv(uniforms.quad_location, 4, gl_quad);
1937 1892
1938 static float gl_matrix[16]; 1893 static float gl_matrix[16];
1939 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad->quadTransform()); 1894 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad->quadTransform());
1940 GLC(gl_, 1895 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]);
1941 gl_->UniformMatrix4fv(uniforms.matrix_location, 1, false, &gl_matrix[0]));
1942 1896
1943 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 1897 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
1944 } 1898 }
1945 1899
1946 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, 1900 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame,
1947 const YUVVideoDrawQuad* quad, 1901 const YUVVideoDrawQuad* quad,
1948 const gfx::QuadF* clip_region) { 1902 const gfx::QuadF* clip_region) {
1949 SetBlendEnabled(quad->ShouldDrawWithBlending()); 1903 SetBlendEnabled(quad->ShouldDrawWithBlending());
1950 1904
1951 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 1905 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
1952 gl_, 1906 gl_,
1953 &highp_threshold_cache_, 1907 &highp_threshold_cache_,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 v_texture_location = program->fragment_shader().v_texture_location(); 1968 v_texture_location = program->fragment_shader().v_texture_location();
2015 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); 1969 yuv_matrix_location = program->fragment_shader().yuv_matrix_location();
2016 yuv_adj_location = program->fragment_shader().yuv_adj_location(); 1970 yuv_adj_location = program->fragment_shader().yuv_adj_location();
2017 ya_clamp_rect_location = 1971 ya_clamp_rect_location =
2018 program->fragment_shader().ya_clamp_rect_location(); 1972 program->fragment_shader().ya_clamp_rect_location();
2019 uv_clamp_rect_location = 1973 uv_clamp_rect_location =
2020 program->fragment_shader().uv_clamp_rect_location(); 1974 program->fragment_shader().uv_clamp_rect_location();
2021 alpha_location = program->fragment_shader().alpha_location(); 1975 alpha_location = program->fragment_shader().alpha_location();
2022 } 1976 }
2023 1977
2024 GLC(gl_, 1978 gl_->Uniform2f(tex_scale_location, quad->tex_coord_rect.width(),
2025 gl_->Uniform2f(tex_scale_location, 1979 quad->tex_coord_rect.height());
2026 quad->tex_coord_rect.width(), 1980 gl_->Uniform2f(tex_offset_location, quad->tex_coord_rect.x(),
2027 quad->tex_coord_rect.height())); 1981 quad->tex_coord_rect.y());
2028 GLC(gl_,
2029 gl_->Uniform2f(tex_offset_location,
2030 quad->tex_coord_rect.x(),
2031 quad->tex_coord_rect.y()));
2032 // Clamping to half a texel inside the tex coord rect prevents bilinear 1982 // Clamping to half a texel inside the tex coord rect prevents bilinear
2033 // filtering from filtering outside the tex coord rect. 1983 // filtering from filtering outside the tex coord rect.
2034 gfx::RectF ya_clamp_rect(quad->tex_coord_rect); 1984 gfx::RectF ya_clamp_rect(quad->tex_coord_rect);
2035 // Special case: empty texture size implies no clamping. 1985 // Special case: empty texture size implies no clamping.
2036 if (!quad->ya_tex_size.IsEmpty()) { 1986 if (!quad->ya_tex_size.IsEmpty()) {
2037 ya_clamp_rect.Inset(0.5f / quad->ya_tex_size.width(), 1987 ya_clamp_rect.Inset(0.5f / quad->ya_tex_size.width(),
2038 0.5f / quad->ya_tex_size.height()); 1988 0.5f / quad->ya_tex_size.height());
2039 } 1989 }
2040 gfx::RectF uv_clamp_rect(quad->tex_coord_rect); 1990 gfx::RectF uv_clamp_rect(quad->tex_coord_rect);
2041 if (!quad->uv_tex_size.IsEmpty()) { 1991 if (!quad->uv_tex_size.IsEmpty()) {
2042 uv_clamp_rect.Inset(0.5f / quad->uv_tex_size.width(), 1992 uv_clamp_rect.Inset(0.5f / quad->uv_tex_size.width(),
2043 0.5f / quad->uv_tex_size.height()); 1993 0.5f / quad->uv_tex_size.height());
2044 } 1994 }
2045 GLC(gl_, gl_->Uniform4f(ya_clamp_rect_location, ya_clamp_rect.x(), 1995 gl_->Uniform4f(ya_clamp_rect_location, ya_clamp_rect.x(), ya_clamp_rect.y(),
2046 ya_clamp_rect.y(), ya_clamp_rect.right(), 1996 ya_clamp_rect.right(), ya_clamp_rect.bottom());
2047 ya_clamp_rect.bottom())); 1997 gl_->Uniform4f(uv_clamp_rect_location, uv_clamp_rect.x(), uv_clamp_rect.y(),
2048 GLC(gl_, gl_->Uniform4f(uv_clamp_rect_location, uv_clamp_rect.x(), 1998 uv_clamp_rect.right(), uv_clamp_rect.bottom());
2049 uv_clamp_rect.y(), uv_clamp_rect.right(),
2050 uv_clamp_rect.bottom()));
2051 1999
2052 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); 2000 gl_->Uniform1i(y_texture_location, 1);
2053 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); 2001 gl_->Uniform1i(u_texture_location, 2);
2054 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); 2002 gl_->Uniform1i(v_texture_location, 3);
2055 if (use_alpha_plane) 2003 if (use_alpha_plane)
2056 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); 2004 gl_->Uniform1i(a_texture_location, 4);
2057 2005
2058 // These values are magic numbers that are used in the transformation from YUV 2006 // These values are magic numbers that are used in the transformation from YUV
2059 // to RGB color values. They are taken from the following webpage: 2007 // to RGB color values. They are taken from the following webpage:
2060 // http://www.fourcc.org/fccyvrgb.php 2008 // http://www.fourcc.org/fccyvrgb.php
2061 float yuv_to_rgb_rec601[9] = { 2009 float yuv_to_rgb_rec601[9] = {
2062 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f, 2010 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f,
2063 }; 2011 };
2064 float yuv_to_rgb_jpeg[9] = { 2012 float yuv_to_rgb_jpeg[9] = {
2065 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414f, 0.0f, 2013 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414f, 0.0f,
2066 }; 2014 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 yuv_to_rgb = yuv_to_rgb_jpeg; 2047 yuv_to_rgb = yuv_to_rgb_jpeg;
2100 yuv_adjust = yuv_adjust_full; 2048 yuv_adjust = yuv_adjust_full;
2101 break; 2049 break;
2102 } 2050 }
2103 2051
2104 // The transform and vertex data are used to figure out the extents that the 2052 // The transform and vertex data are used to figure out the extents that the
2105 // un-antialiased quad should have and which vertex this is and the float 2053 // un-antialiased quad should have and which vertex this is and the float
2106 // quad passed in via uniform is the actual geometry that gets used to draw 2054 // quad passed in via uniform is the actual geometry that gets used to draw
2107 // it. This is why this centered rect is used and not the original quad_rect. 2055 // it. This is why this centered rect is used and not the original quad_rect.
2108 gfx::RectF tile_rect = quad->rect; 2056 gfx::RectF tile_rect = quad->rect;
2109 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); 2057 gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb);
2110 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); 2058 gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust);
2111 2059
2112 SetShaderOpacity(quad->opacity(), alpha_location); 2060 SetShaderOpacity(quad->opacity(), alpha_location);
2113 if (!clip_region) { 2061 if (!clip_region) {
2114 DrawQuadGeometry(frame, quad->quadTransform(), tile_rect, matrix_location); 2062 DrawQuadGeometry(frame, quad->quadTransform(), tile_rect, matrix_location);
2115 } else { 2063 } else {
2116 float uvs[8] = {0}; 2064 float uvs[8] = {0};
2117 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2065 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2118 gfx::QuadF region_quad = *clip_region; 2066 gfx::QuadF region_quad = *clip_region;
2119 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height()); 2067 region_quad.Scale(1.0f / tile_rect.width(), 1.0f / tile_rect.height());
2120 region_quad -= gfx::Vector2dF(0.5f, 0.5f); 2068 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
(...skipping 15 matching lines...) Expand all
2136 gl_, 2084 gl_,
2137 &highp_threshold_cache_, 2085 &highp_threshold_cache_,
2138 highp_threshold_min_, 2086 highp_threshold_min_,
2139 quad->shared_quad_state->visible_content_rect.bottom_right()); 2087 quad->shared_quad_state->visible_content_rect.bottom_right());
2140 2088
2141 const VideoStreamTextureProgram* program = 2089 const VideoStreamTextureProgram* program =
2142 GetVideoStreamTextureProgram(tex_coord_precision); 2090 GetVideoStreamTextureProgram(tex_coord_precision);
2143 SetUseProgram(program->program()); 2091 SetUseProgram(program->program());
2144 2092
2145 ToGLMatrix(&gl_matrix[0], quad->matrix); 2093 ToGLMatrix(&gl_matrix[0], quad->matrix);
2146 GLC(gl_, 2094 gl_->UniformMatrix4fv(program->vertex_shader().tex_matrix_location(), 1,
2147 gl_->UniformMatrix4fv( 2095 false, gl_matrix);
2148 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix));
2149 2096
2150 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2097 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2151 quad->resource_id); 2098 quad->resource_id);
2152 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2099 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2153 GLC(gl_, gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id())); 2100 gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id());
2154 2101
2155 GLC(gl_, gl_->Uniform1i(program->fragment_shader().sampler_location(), 0)); 2102 gl_->Uniform1i(program->fragment_shader().sampler_location(), 0);
2156 2103
2157 SetShaderOpacity(quad->opacity(), 2104 SetShaderOpacity(quad->opacity(),
2158 program->fragment_shader().alpha_location()); 2105 program->fragment_shader().alpha_location());
2159 if (!clip_region) { 2106 if (!clip_region) {
2160 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, 2107 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect,
2161 program->vertex_shader().matrix_location()); 2108 program->vertex_shader().matrix_location());
2162 } else { 2109 } else {
2163 gfx::QuadF region_quad(*clip_region); 2110 gfx::QuadF region_quad(*clip_region);
2164 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height()); 2111 region_quad.Scale(1.0f / quad->rect.width(), 1.0f / quad->rect.height());
2165 region_quad -= gfx::Vector2dF(0.5f, 0.5f); 2112 region_quad -= gfx::Vector2dF(0.5f, 0.5f);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2207 2154
2208 PrepareGeometry(flush_binding); 2155 PrepareGeometry(flush_binding);
2209 2156
2210 // Set the correct blending mode. 2157 // Set the correct blending mode.
2211 SetBlendEnabled(draw_cache_.needs_blending); 2158 SetBlendEnabled(draw_cache_.needs_blending);
2212 2159
2213 // Bind the program to the GL state. 2160 // Bind the program to the GL state.
2214 SetUseProgram(draw_cache_.program_id); 2161 SetUseProgram(draw_cache_.program_id);
2215 2162
2216 // Bind the correct texture sampler location. 2163 // Bind the correct texture sampler location.
2217 GLC(gl_, gl_->Uniform1i(draw_cache_.sampler_location, 0)); 2164 gl_->Uniform1i(draw_cache_.sampler_location, 0);
2218 2165
2219 // Assume the current active textures is 0. 2166 // Assume the current active textures is 0.
2220 ResourceProvider::ScopedSamplerGL locked_quad( 2167 ResourceProvider::ScopedSamplerGL locked_quad(
2221 resource_provider_, 2168 resource_provider_,
2222 draw_cache_.resource_id, 2169 draw_cache_.resource_id,
2223 draw_cache_.nearest_neighbor ? GL_NEAREST : GL_LINEAR); 2170 draw_cache_.nearest_neighbor ? GL_NEAREST : GL_LINEAR);
2224 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2171 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2225 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id())); 2172 gl_->BindTexture(GL_TEXTURE_2D, locked_quad.texture_id());
2226 2173
2227 static_assert(sizeof(Float4) == 4 * sizeof(float), 2174 static_assert(sizeof(Float4) == 4 * sizeof(float),
2228 "Float4 struct should be densely packed"); 2175 "Float4 struct should be densely packed");
2229 static_assert(sizeof(Float16) == 16 * sizeof(float), 2176 static_assert(sizeof(Float16) == 16 * sizeof(float),
2230 "Float16 struct should be densely packed"); 2177 "Float16 struct should be densely packed");
2231 2178
2232 // Upload the tranforms for both points and uvs. 2179 // Upload the tranforms for both points and uvs.
2233 GLC(gl_, 2180 gl_->UniformMatrix4fv(
2234 gl_->UniformMatrix4fv( 2181 static_cast<int>(draw_cache_.matrix_location),
2235 static_cast<int>(draw_cache_.matrix_location), 2182 static_cast<int>(draw_cache_.matrix_data.size()), false,
2236 static_cast<int>(draw_cache_.matrix_data.size()), 2183 reinterpret_cast<float*>(&draw_cache_.matrix_data.front()));
2237 false, 2184 gl_->Uniform4fv(static_cast<int>(draw_cache_.uv_xform_location),
2238 reinterpret_cast<float*>(&draw_cache_.matrix_data.front()))); 2185 static_cast<int>(draw_cache_.uv_xform_data.size()),
2239 GLC(gl_, 2186 reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front()));
2240 gl_->Uniform4fv(
2241 static_cast<int>(draw_cache_.uv_xform_location),
2242 static_cast<int>(draw_cache_.uv_xform_data.size()),
2243 reinterpret_cast<float*>(&draw_cache_.uv_xform_data.front())));
2244 2187
2245 if (draw_cache_.background_color != SK_ColorTRANSPARENT) { 2188 if (draw_cache_.background_color != SK_ColorTRANSPARENT) {
2246 Float4 background_color = PremultipliedColor(draw_cache_.background_color); 2189 Float4 background_color = PremultipliedColor(draw_cache_.background_color);
2247 GLC(gl_, 2190 gl_->Uniform4fv(draw_cache_.background_color_location, 1,
2248 gl_->Uniform4fv( 2191 background_color.data);
2249 draw_cache_.background_color_location, 1, background_color.data));
2250 } 2192 }
2251 2193
2252 GLC(gl_, 2194 gl_->Uniform1fv(
2253 gl_->Uniform1fv( 2195 static_cast<int>(draw_cache_.vertex_opacity_location),
2254 static_cast<int>(draw_cache_.vertex_opacity_location), 2196 static_cast<int>(draw_cache_.vertex_opacity_data.size()),
2255 static_cast<int>(draw_cache_.vertex_opacity_data.size()), 2197 static_cast<float*>(&draw_cache_.vertex_opacity_data.front()));
2256 static_cast<float*>(&draw_cache_.vertex_opacity_data.front())));
2257 2198
2258 // Draw the quads! 2199 // Draw the quads!
2259 GLC(gl_, 2200 gl_->DrawElements(GL_TRIANGLES, 6 * draw_cache_.matrix_data.size(),
2260 gl_->DrawElements(GL_TRIANGLES, 2201 GL_UNSIGNED_SHORT, 0);
2261 6 * draw_cache_.matrix_data.size(),
2262 GL_UNSIGNED_SHORT,
2263 0));
2264 2202
2265 // Clear the cache. 2203 // Clear the cache.
2266 draw_cache_.program_id = -1; 2204 draw_cache_.program_id = -1;
2267 draw_cache_.uv_xform_data.resize(0); 2205 draw_cache_.uv_xform_data.resize(0);
2268 draw_cache_.vertex_opacity_data.resize(0); 2206 draw_cache_.vertex_opacity_data.resize(0);
2269 draw_cache_.matrix_data.resize(0); 2207 draw_cache_.matrix_data.resize(0);
2270 2208
2271 // If we had a clipped binding, prepare the shared binding for the 2209 // If we had a clipped binding, prepare the shared binding for the
2272 // next inserts. 2210 // next inserts.
2273 if (flush_binding == CLIPPED_BINDING) { 2211 if (flush_binding == CLIPPED_BINDING) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired( 2324 TexCoordPrecision tex_coord_precision = TexCoordPrecisionRequired(
2387 gl_, 2325 gl_,
2388 &highp_threshold_cache_, 2326 &highp_threshold_cache_,
2389 highp_threshold_min_, 2327 highp_threshold_min_,
2390 quad->shared_quad_state->visible_content_rect.bottom_right()); 2328 quad->shared_quad_state->visible_content_rect.bottom_right());
2391 2329
2392 TexTransformTextureProgramBinding binding; 2330 TexTransformTextureProgramBinding binding;
2393 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision)); 2331 binding.Set(GetTextureIOSurfaceProgram(tex_coord_precision));
2394 2332
2395 SetUseProgram(binding.program_id); 2333 SetUseProgram(binding.program_id);
2396 GLC(gl_, gl_->Uniform1i(binding.sampler_location, 0)); 2334 gl_->Uniform1i(binding.sampler_location, 0);
2397 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { 2335 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) {
2398 GLC(gl_, 2336 gl_->Uniform4f(
2399 gl_->Uniform4f(binding.tex_transform_location, 2337 binding.tex_transform_location, 0, quad->io_surface_size.height(),
2400 0, 2338 quad->io_surface_size.width(), quad->io_surface_size.height() * -1.0f);
2401 quad->io_surface_size.height(),
2402 quad->io_surface_size.width(),
2403 quad->io_surface_size.height() * -1.0f));
2404 } else { 2339 } else {
2405 GLC(gl_, 2340 gl_->Uniform4f(binding.tex_transform_location, 0, 0,
2406 gl_->Uniform4f(binding.tex_transform_location, 2341 quad->io_surface_size.width(),
2407 0, 2342 quad->io_surface_size.height());
2408 0,
2409 quad->io_surface_size.width(),
2410 quad->io_surface_size.height()));
2411 } 2343 }
2412 2344
2413 const float vertex_opacity[] = {quad->opacity(), quad->opacity(), 2345 const float vertex_opacity[] = {quad->opacity(), quad->opacity(),
2414 quad->opacity(), quad->opacity()}; 2346 quad->opacity(), quad->opacity()};
2415 GLC(gl_, gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity)); 2347 gl_->Uniform1fv(binding.vertex_opacity_location, 4, vertex_opacity);
2416 2348
2417 ResourceProvider::ScopedReadLockGL lock(resource_provider_, 2349 ResourceProvider::ScopedReadLockGL lock(resource_provider_,
2418 quad->io_surface_resource_id); 2350 quad->io_surface_resource_id);
2419 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); 2351 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_));
2420 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id())); 2352 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, lock.texture_id());
2421 2353
2422 if (!clip_region) { 2354 if (!clip_region) {
2423 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, 2355 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect,
2424 binding.matrix_location); 2356 binding.matrix_location);
2425 } else { 2357 } else {
2426 float uvs[8] = {0}; 2358 float uvs[8] = {0};
2427 GetScaledUVs(quad->visible_rect, clip_region, uvs); 2359 GetScaledUVs(quad->visible_rect, clip_region, uvs);
2428 DrawQuadGeometryClippedByQuadF(frame, quad->quadTransform(), quad->rect, 2360 DrawQuadGeometryClippedByQuadF(frame, quad->quadTransform(), quad->rect,
2429 *clip_region, binding.matrix_location, uvs); 2361 *clip_region, binding.matrix_location, uvs);
2430 } 2362 }
2431 2363
2432 GLC(gl_, gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0)); 2364 gl_->BindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
2433 } 2365 }
2434 2366
2435 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) { 2367 void GLRenderer::FinishDrawingFrame(DrawingFrame* frame) {
2436 if (use_sync_query_) { 2368 if (use_sync_query_) {
2437 DCHECK(current_sync_query_); 2369 DCHECK(current_sync_query_);
2438 current_sync_query_->End(); 2370 current_sync_query_->End();
2439 pending_sync_queries_.push_back(current_sync_query_.Pass()); 2371 pending_sync_queries_.push_back(current_sync_query_.Pass());
2440 } 2372 }
2441 2373
2442 current_framebuffer_lock_ = nullptr; 2374 current_framebuffer_lock_ = nullptr;
2443 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect)); 2375 swap_buffer_rect_.Union(gfx::ToEnclosingRect(frame->root_damage_rect));
2444 2376
2445 GLC(gl_, gl_->Disable(GL_BLEND)); 2377 gl_->Disable(GL_BLEND);
2446 blend_shadow_ = false; 2378 blend_shadow_ = false;
2447 2379
2448 ScheduleOverlays(frame); 2380 ScheduleOverlays(frame);
2449 } 2381 }
2450 2382
2451 void GLRenderer::FinishDrawingQuadList() { 2383 void GLRenderer::FinishDrawingQuadList() {
2452 FlushTextureQuadCache(SHARED_BINDING); 2384 FlushTextureQuadCache(SHARED_BINDING);
2453 } 2385 }
2454 2386
2455 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const { 2387 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const {
2456 if (frame->current_render_pass != frame->root_render_pass) 2388 if (frame->current_render_pass != frame->root_render_pass)
2457 return true; 2389 return true;
2458 return FlippedRootFramebuffer(); 2390 return FlippedRootFramebuffer();
2459 } 2391 }
2460 2392
2461 bool GLRenderer::FlippedRootFramebuffer() const { 2393 bool GLRenderer::FlippedRootFramebuffer() const {
2462 // GL is normally flipped, so a flipped output results in an unflipping. 2394 // GL is normally flipped, so a flipped output results in an unflipping.
2463 return !output_surface_->capabilities().flipped_output_surface; 2395 return !output_surface_->capabilities().flipped_output_surface;
2464 } 2396 }
2465 2397
2466 void GLRenderer::EnsureScissorTestEnabled() { 2398 void GLRenderer::EnsureScissorTestEnabled() {
2467 if (is_scissor_enabled_) 2399 if (is_scissor_enabled_)
2468 return; 2400 return;
2469 2401
2470 FlushTextureQuadCache(SHARED_BINDING); 2402 FlushTextureQuadCache(SHARED_BINDING);
2471 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST)); 2403 gl_->Enable(GL_SCISSOR_TEST);
2472 is_scissor_enabled_ = true; 2404 is_scissor_enabled_ = true;
2473 } 2405 }
2474 2406
2475 void GLRenderer::EnsureScissorTestDisabled() { 2407 void GLRenderer::EnsureScissorTestDisabled() {
2476 if (!is_scissor_enabled_) 2408 if (!is_scissor_enabled_)
2477 return; 2409 return;
2478 2410
2479 FlushTextureQuadCache(SHARED_BINDING); 2411 FlushTextureQuadCache(SHARED_BINDING);
2480 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 2412 gl_->Disable(GL_SCISSOR_TEST);
2481 is_scissor_enabled_ = false; 2413 is_scissor_enabled_ = false;
2482 } 2414 }
2483 2415
2484 void GLRenderer::CopyCurrentRenderPassToBitmap( 2416 void GLRenderer::CopyCurrentRenderPassToBitmap(
2485 DrawingFrame* frame, 2417 DrawingFrame* frame,
2486 scoped_ptr<CopyOutputRequest> request) { 2418 scoped_ptr<CopyOutputRequest> request) {
2487 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap"); 2419 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap");
2488 gfx::Rect copy_rect = frame->current_render_pass->output_rect; 2420 gfx::Rect copy_rect = frame->current_render_pass->output_rect;
2489 if (request->has_area()) 2421 if (request->has_area())
2490 copy_rect.Intersect(request->area()); 2422 copy_rect.Intersect(request->area());
(...skipping 10 matching lines...) Expand all
2501 2433
2502 float gl_quad[8]; 2434 float gl_quad[8];
2503 gl_quad[0] = quad.p1().x(); 2435 gl_quad[0] = quad.p1().x();
2504 gl_quad[1] = quad.p1().y(); 2436 gl_quad[1] = quad.p1().y();
2505 gl_quad[2] = quad.p2().x(); 2437 gl_quad[2] = quad.p2().x();
2506 gl_quad[3] = quad.p2().y(); 2438 gl_quad[3] = quad.p2().y();
2507 gl_quad[4] = quad.p3().x(); 2439 gl_quad[4] = quad.p3().x();
2508 gl_quad[5] = quad.p3().y(); 2440 gl_quad[5] = quad.p3().y();
2509 gl_quad[6] = quad.p4().x(); 2441 gl_quad[6] = quad.p4().x();
2510 gl_quad[7] = quad.p4().y(); 2442 gl_quad[7] = quad.p4().y();
2511 GLC(gl_, gl_->Uniform2fv(quad_location, 4, gl_quad)); 2443 gl_->Uniform2fv(quad_location, 4, gl_quad);
2512 } 2444 }
2513 2445
2514 void GLRenderer::SetShaderOpacity(float opacity, int alpha_location) { 2446 void GLRenderer::SetShaderOpacity(float opacity, int alpha_location) {
2515 if (alpha_location != -1) 2447 if (alpha_location != -1)
2516 GLC(gl_, gl_->Uniform1f(alpha_location, opacity)); 2448 gl_->Uniform1f(alpha_location, opacity);
2517 } 2449 }
2518 2450
2519 void GLRenderer::SetStencilEnabled(bool enabled) { 2451 void GLRenderer::SetStencilEnabled(bool enabled) {
2520 if (enabled == stencil_shadow_) 2452 if (enabled == stencil_shadow_)
2521 return; 2453 return;
2522 2454
2523 if (enabled) 2455 if (enabled)
2524 GLC(gl_, gl_->Enable(GL_STENCIL_TEST)); 2456 gl_->Enable(GL_STENCIL_TEST);
2525 else 2457 else
2526 GLC(gl_, gl_->Disable(GL_STENCIL_TEST)); 2458 gl_->Disable(GL_STENCIL_TEST);
2527 stencil_shadow_ = enabled; 2459 stencil_shadow_ = enabled;
2528 } 2460 }
2529 2461
2530 void GLRenderer::SetBlendEnabled(bool enabled) { 2462 void GLRenderer::SetBlendEnabled(bool enabled) {
2531 if (enabled == blend_shadow_) 2463 if (enabled == blend_shadow_)
2532 return; 2464 return;
2533 2465
2534 if (enabled) 2466 if (enabled)
2535 GLC(gl_, gl_->Enable(GL_BLEND)); 2467 gl_->Enable(GL_BLEND);
2536 else 2468 else
2537 GLC(gl_, gl_->Disable(GL_BLEND)); 2469 gl_->Disable(GL_BLEND);
2538 blend_shadow_ = enabled; 2470 blend_shadow_ = enabled;
2539 } 2471 }
2540 2472
2541 void GLRenderer::SetUseProgram(unsigned program) { 2473 void GLRenderer::SetUseProgram(unsigned program) {
2542 if (program == program_shadow_) 2474 if (program == program_shadow_)
2543 return; 2475 return;
2544 gl_->UseProgram(program); 2476 gl_->UseProgram(program);
2545 program_shadow_ = program; 2477 program_shadow_ = program;
2546 } 2478 }
2547 2479
2548 void GLRenderer::DrawQuadGeometryClippedByQuadF( 2480 void GLRenderer::DrawQuadGeometryClippedByQuadF(
2549 const DrawingFrame* frame, 2481 const DrawingFrame* frame,
2550 const gfx::Transform& draw_transform, 2482 const gfx::Transform& draw_transform,
2551 const gfx::RectF& quad_rect, 2483 const gfx::RectF& quad_rect,
2552 const gfx::QuadF& clipping_region_quad, 2484 const gfx::QuadF& clipping_region_quad,
2553 int matrix_location, 2485 int matrix_location,
2554 const float* uvs) { 2486 const float* uvs) {
2555 PrepareGeometry(CLIPPED_BINDING); 2487 PrepareGeometry(CLIPPED_BINDING);
2556 if (uvs) { 2488 if (uvs) {
2557 clipped_geometry_->InitializeCustomQuadWithUVs(clipping_region_quad, uvs); 2489 clipped_geometry_->InitializeCustomQuadWithUVs(clipping_region_quad, uvs);
2558 } else { 2490 } else {
2559 clipped_geometry_->InitializeCustomQuad(clipping_region_quad); 2491 clipped_geometry_->InitializeCustomQuad(clipping_region_quad);
2560 } 2492 }
2561 gfx::Transform quad_rect_matrix; 2493 gfx::Transform quad_rect_matrix;
2562 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2494 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2563 static float gl_matrix[16]; 2495 static float gl_matrix[16];
2564 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2496 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2565 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); 2497 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]);
2566 2498
2567 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 2499 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,
2568 reinterpret_cast<const void*>(0))); 2500 reinterpret_cast<const void*>(0));
2569 } 2501 }
2570 2502
2571 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame, 2503 void GLRenderer::DrawQuadGeometry(const DrawingFrame* frame,
2572 const gfx::Transform& draw_transform, 2504 const gfx::Transform& draw_transform,
2573 const gfx::RectF& quad_rect, 2505 const gfx::RectF& quad_rect,
2574 int matrix_location) { 2506 int matrix_location) {
2575 PrepareGeometry(SHARED_BINDING); 2507 PrepareGeometry(SHARED_BINDING);
2576 gfx::Transform quad_rect_matrix; 2508 gfx::Transform quad_rect_matrix;
2577 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect); 2509 QuadRectTransform(&quad_rect_matrix, draw_transform, quad_rect);
2578 static float gl_matrix[16]; 2510 static float gl_matrix[16];
2579 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix); 2511 ToGLMatrix(&gl_matrix[0], frame->projection_matrix * quad_rect_matrix);
2580 GLC(gl_, gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); 2512 gl_->UniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0]);
2581 2513
2582 GLC(gl_, gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); 2514 gl_->DrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0);
2583 } 2515 }
2584 2516
2585 void GLRenderer::Finish() { 2517 void GLRenderer::Finish() {
2586 TRACE_EVENT0("cc", "GLRenderer::Finish"); 2518 TRACE_EVENT0("cc", "GLRenderer::Finish");
2587 GLC(gl_, gl_->Finish()); 2519 gl_->Finish();
2588 } 2520 }
2589 2521
2590 void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { 2522 void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) {
2591 DCHECK(!is_backbuffer_discarded_); 2523 DCHECK(!is_backbuffer_discarded_);
2592 2524
2593 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); 2525 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers");
2594 // We're done! Time to swapbuffers! 2526 // We're done! Time to swapbuffers!
2595 2527
2596 gfx::Size surface_size = output_surface_->SurfaceSize(); 2528 gfx::Size surface_size = output_surface_->SurfaceSize();
2597 2529
(...skipping 28 matching lines...) Expand all
2626 swap_buffer_rect_ = gfx::Rect(); 2558 swap_buffer_rect_ = gfx::Rect();
2627 } 2559 }
2628 2560
2629 void GLRenderer::EnforceMemoryPolicy() { 2561 void GLRenderer::EnforceMemoryPolicy() {
2630 if (!visible()) { 2562 if (!visible()) {
2631 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources"); 2563 TRACE_EVENT0("cc", "GLRenderer::EnforceMemoryPolicy dropping resources");
2632 ReleaseRenderPassTextures(); 2564 ReleaseRenderPassTextures();
2633 DiscardBackbuffer(); 2565 DiscardBackbuffer();
2634 resource_provider_->ReleaseCachedData(); 2566 resource_provider_->ReleaseCachedData();
2635 output_surface_->context_provider()->DeleteCachedResources(); 2567 output_surface_->context_provider()->DeleteCachedResources();
2636 GLC(gl_, gl_->Flush()); 2568 gl_->Flush();
2637 } 2569 }
2638 PrepareGeometry(NO_BINDING); 2570 PrepareGeometry(NO_BINDING);
2639 } 2571 }
2640 2572
2641 void GLRenderer::DiscardBackbuffer() { 2573 void GLRenderer::DiscardBackbuffer() {
2642 if (is_backbuffer_discarded_) 2574 if (is_backbuffer_discarded_)
2643 return; 2575 return;
2644 2576
2645 output_surface_->DiscardBackbuffer(); 2577 output_surface_->DiscardBackbuffer();
2646 2578
(...skipping 26 matching lines...) Expand all
2673 DCHECK_GE(window_rect.y(), 0); 2605 DCHECK_GE(window_rect.y(), 0);
2674 DCHECK_LE(window_rect.right(), current_surface_size_.width()); 2606 DCHECK_LE(window_rect.right(), current_surface_size_.width());
2675 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); 2607 DCHECK_LE(window_rect.bottom(), current_surface_size_.height());
2676 2608
2677 if (!request->force_bitmap_result()) { 2609 if (!request->force_bitmap_result()) {
2678 bool own_mailbox = !request->has_texture_mailbox(); 2610 bool own_mailbox = !request->has_texture_mailbox();
2679 2611
2680 GLuint texture_id = 0; 2612 GLuint texture_id = 0;
2681 gpu::Mailbox mailbox; 2613 gpu::Mailbox mailbox;
2682 if (own_mailbox) { 2614 if (own_mailbox) {
2683 GLC(gl_, gl_->GenMailboxCHROMIUM(mailbox.name)); 2615 gl_->GenMailboxCHROMIUM(mailbox.name);
2684 gl_->GenTextures(1, &texture_id); 2616 gl_->GenTextures(1, &texture_id);
2685 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); 2617 gl_->BindTexture(GL_TEXTURE_2D, texture_id);
2686 2618
2687 GLC(gl_, 2619 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2688 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2620 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2689 GLC(gl_, 2621 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2690 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2622 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2691 GLC(gl_, 2623 gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
2692 gl_->TexParameteri(
2693 GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2694 GLC(gl_,
2695 gl_->TexParameteri(
2696 GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2697 GLC(gl_, gl_->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
2698 } else { 2624 } else {
2699 mailbox = request->texture_mailbox().mailbox(); 2625 mailbox = request->texture_mailbox().mailbox();
2700 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D), 2626 DCHECK_EQ(static_cast<unsigned>(GL_TEXTURE_2D),
2701 request->texture_mailbox().target()); 2627 request->texture_mailbox().target());
2702 DCHECK(!mailbox.IsZero()); 2628 DCHECK(!mailbox.IsZero());
2703 unsigned incoming_sync_point = request->texture_mailbox().sync_point(); 2629 unsigned incoming_sync_point = request->texture_mailbox().sync_point();
2704 if (incoming_sync_point) 2630 if (incoming_sync_point)
2705 GLC(gl_, gl_->WaitSyncPointCHROMIUM(incoming_sync_point)); 2631 gl_->WaitSyncPointCHROMIUM(incoming_sync_point);
2706 2632
2707 texture_id = GLC( 2633 texture_id =
2708 gl_, 2634 gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
2709 gl_->CreateAndConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name));
2710 } 2635 }
2711 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); 2636 GetFramebufferTexture(texture_id, RGBA_8888, window_rect);
2712 2637
2713 unsigned sync_point = gl_->InsertSyncPointCHROMIUM(); 2638 unsigned sync_point = gl_->InsertSyncPointCHROMIUM();
2714 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point); 2639 TextureMailbox texture_mailbox(mailbox, GL_TEXTURE_2D, sync_point);
2715 2640
2716 scoped_ptr<SingleReleaseCallback> release_callback; 2641 scoped_ptr<SingleReleaseCallback> release_callback;
2717 if (own_mailbox) { 2642 if (own_mailbox) {
2718 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); 2643 gl_->BindTexture(GL_TEXTURE_2D, 0);
2719 release_callback = texture_mailbox_deleter_->GetReleaseCallback( 2644 release_callback = texture_mailbox_deleter_->GetReleaseCallback(
2720 output_surface_->context_provider(), texture_id); 2645 output_surface_->context_provider(), texture_id);
2721 } else { 2646 } else {
2722 gl_->DeleteTextures(1, &texture_id); 2647 gl_->DeleteTextures(1, &texture_id);
2723 } 2648 }
2724 2649
2725 request->SendTextureResult( 2650 request->SendTextureResult(
2726 window_rect.size(), texture_mailbox, release_callback.Pass()); 2651 window_rect.size(), texture_mailbox, release_callback.Pass());
2727 return; 2652 return;
2728 } 2653 }
(...skipping 11 matching lines...) Expand all
2740 unsigned temporary_fbo = 0; 2665 unsigned temporary_fbo = 0;
2741 2666
2742 if (do_workaround) { 2667 if (do_workaround) {
2743 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment 2668 // On Mac OS X, calling glReadPixels() against an FBO whose color attachment
2744 // is an IOSurface-backed texture causes corruption of future glReadPixels() 2669 // is an IOSurface-backed texture causes corruption of future glReadPixels()
2745 // calls, even those on different OpenGL contexts. It is believed that this 2670 // calls, even those on different OpenGL contexts. It is believed that this
2746 // is the root cause of top crasher 2671 // is the root cause of top crasher
2747 // http://crbug.com/99393. <rdar://problem/10949687> 2672 // http://crbug.com/99393. <rdar://problem/10949687>
2748 2673
2749 gl_->GenTextures(1, &temporary_texture); 2674 gl_->GenTextures(1, &temporary_texture);
2750 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, temporary_texture)); 2675 gl_->BindTexture(GL_TEXTURE_2D, temporary_texture);
2751 GLC(gl_, 2676 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
2752 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); 2677 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
2753 GLC(gl_, 2678 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
2754 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); 2679 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
2755 GLC(gl_,
2756 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
2757 GLC(gl_,
2758 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
2759 // Copy the contents of the current (IOSurface-backed) framebuffer into a 2680 // Copy the contents of the current (IOSurface-backed) framebuffer into a
2760 // temporary texture. 2681 // temporary texture.
2761 GetFramebufferTexture( 2682 GetFramebufferTexture(
2762 temporary_texture, RGBA_8888, gfx::Rect(current_surface_size_)); 2683 temporary_texture, RGBA_8888, gfx::Rect(current_surface_size_));
2763 gl_->GenFramebuffers(1, &temporary_fbo); 2684 gl_->GenFramebuffers(1, &temporary_fbo);
2764 // Attach this texture to an FBO, and perform the readback from that FBO. 2685 // Attach this texture to an FBO, and perform the readback from that FBO.
2765 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, temporary_fbo)); 2686 gl_->BindFramebuffer(GL_FRAMEBUFFER, temporary_fbo);
2766 GLC(gl_, 2687 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
2767 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, 2688 GL_TEXTURE_2D, temporary_texture, 0);
2768 GL_COLOR_ATTACHMENT0,
2769 GL_TEXTURE_2D,
2770 temporary_texture,
2771 0));
2772 2689
2773 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE), 2690 DCHECK_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE),
2774 gl_->CheckFramebufferStatus(GL_FRAMEBUFFER)); 2691 gl_->CheckFramebufferStatus(GL_FRAMEBUFFER));
2775 } 2692 }
2776 2693
2777 GLuint buffer = 0; 2694 GLuint buffer = 0;
2778 gl_->GenBuffers(1, &buffer); 2695 gl_->GenBuffers(1, &buffer);
2779 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer)); 2696 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer);
2780 GLC(gl_, 2697 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
2781 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 2698 4 * window_rect.size().GetArea(), NULL, GL_STREAM_READ);
2782 4 * window_rect.size().GetArea(),
2783 NULL,
2784 GL_STREAM_READ));
2785 2699
2786 GLuint query = 0; 2700 GLuint query = 0;
2787 gl_->GenQueriesEXT(1, &query); 2701 gl_->GenQueriesEXT(1, &query);
2788 GLC(gl_, gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, query)); 2702 gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, query);
2789 2703
2790 GLC(gl_, 2704 gl_->ReadPixels(window_rect.x(), window_rect.y(), window_rect.width(),
2791 gl_->ReadPixels(window_rect.x(), 2705 window_rect.height(), GL_RGBA, GL_UNSIGNED_BYTE, NULL);
2792 window_rect.y(),
2793 window_rect.width(),
2794 window_rect.height(),
2795 GL_RGBA,
2796 GL_UNSIGNED_BYTE,
2797 NULL));
2798 2706
2799 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0)); 2707 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
2800 2708
2801 if (do_workaround) { 2709 if (do_workaround) {
2802 // Clean up. 2710 // Clean up.
2803 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, 0)); 2711 gl_->BindFramebuffer(GL_FRAMEBUFFER, 0);
2804 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0)); 2712 gl_->BindTexture(GL_TEXTURE_2D, 0);
2805 GLC(gl_, gl_->DeleteFramebuffers(1, &temporary_fbo)); 2713 gl_->DeleteFramebuffers(1, &temporary_fbo);
2806 GLC(gl_, gl_->DeleteTextures(1, &temporary_texture)); 2714 gl_->DeleteTextures(1, &temporary_texture);
2807 } 2715 }
2808 2716
2809 base::Closure finished_callback = base::Bind(&GLRenderer::FinishedReadback, 2717 base::Closure finished_callback = base::Bind(&GLRenderer::FinishedReadback,
2810 base::Unretained(this), 2718 base::Unretained(this),
2811 buffer, 2719 buffer,
2812 query, 2720 query,
2813 window_rect.size()); 2721 window_rect.size());
2814 // Save the finished_callback so it can be cancelled. 2722 // Save the finished_callback so it can be cancelled.
2815 pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset( 2723 pending_async_read_pixels_.front()->finished_read_pixels_callback.Reset(
2816 finished_callback); 2724 finished_callback);
2817 base::Closure cancelable_callback = 2725 base::Closure cancelable_callback =
2818 pending_async_read_pixels_.front()-> 2726 pending_async_read_pixels_.front()->
2819 finished_read_pixels_callback.callback(); 2727 finished_read_pixels_callback.callback();
2820 2728
2821 // Save the buffer to verify the callbacks happen in the expected order. 2729 // Save the buffer to verify the callbacks happen in the expected order.
2822 pending_async_read_pixels_.front()->buffer = buffer; 2730 pending_async_read_pixels_.front()->buffer = buffer;
2823 2731
2824 GLC(gl_, gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM)); 2732 gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM);
2825 context_support_->SignalQuery(query, cancelable_callback); 2733 context_support_->SignalQuery(query, cancelable_callback);
2826 2734
2827 EnforceMemoryPolicy(); 2735 EnforceMemoryPolicy();
2828 } 2736 }
2829 2737
2830 void GLRenderer::FinishedReadback(unsigned source_buffer, 2738 void GLRenderer::FinishedReadback(unsigned source_buffer,
2831 unsigned query, 2739 unsigned query,
2832 const gfx::Size& size) { 2740 const gfx::Size& size) {
2833 DCHECK(!pending_async_read_pixels_.empty()); 2741 DCHECK(!pending_async_read_pixels_.empty());
2834 2742
2835 if (query != 0) { 2743 if (query != 0) {
2836 GLC(gl_, gl_->DeleteQueriesEXT(1, &query)); 2744 gl_->DeleteQueriesEXT(1, &query);
2837 } 2745 }
2838 2746
2839 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back(); 2747 PendingAsyncReadPixels* current_read = pending_async_read_pixels_.back();
2840 // Make sure we service the readbacks in order. 2748 // Make sure we service the readbacks in order.
2841 DCHECK_EQ(source_buffer, current_read->buffer); 2749 DCHECK_EQ(source_buffer, current_read->buffer);
2842 2750
2843 uint8* src_pixels = NULL; 2751 uint8* src_pixels = NULL;
2844 scoped_ptr<SkBitmap> bitmap; 2752 scoped_ptr<SkBitmap> bitmap;
2845 2753
2846 if (source_buffer != 0) { 2754 if (source_buffer != 0) {
2847 GLC(gl_, 2755 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer);
2848 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer));
2849 src_pixels = static_cast<uint8*>(gl_->MapBufferCHROMIUM( 2756 src_pixels = static_cast<uint8*>(gl_->MapBufferCHROMIUM(
2850 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY)); 2757 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY));
2851 2758
2852 if (src_pixels) { 2759 if (src_pixels) {
2853 bitmap.reset(new SkBitmap); 2760 bitmap.reset(new SkBitmap);
2854 bitmap->allocN32Pixels(size.width(), size.height()); 2761 bitmap->allocN32Pixels(size.width(), size.height());
2855 scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap)); 2762 scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap));
2856 uint8* dest_pixels = static_cast<uint8*>(bitmap->getPixels()); 2763 uint8* dest_pixels = static_cast<uint8*>(bitmap->getPixels());
2857 2764
2858 size_t row_bytes = size.width() * 4; 2765 size_t row_bytes = size.width() * 4;
2859 int num_rows = size.height(); 2766 int num_rows = size.height();
2860 size_t total_bytes = num_rows * row_bytes; 2767 size_t total_bytes = num_rows * row_bytes;
2861 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { 2768 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) {
2862 // Flip Y axis. 2769 // Flip Y axis.
2863 size_t src_y = total_bytes - dest_y - row_bytes; 2770 size_t src_y = total_bytes - dest_y - row_bytes;
2864 // Swizzle OpenGL -> Skia byte order. 2771 // Swizzle OpenGL -> Skia byte order.
2865 for (size_t x = 0; x < row_bytes; x += 4) { 2772 for (size_t x = 0; x < row_bytes; x += 4) {
2866 dest_pixels[dest_y + x + SK_R32_SHIFT / 8] = 2773 dest_pixels[dest_y + x + SK_R32_SHIFT / 8] =
2867 src_pixels[src_y + x + 0]; 2774 src_pixels[src_y + x + 0];
2868 dest_pixels[dest_y + x + SK_G32_SHIFT / 8] = 2775 dest_pixels[dest_y + x + SK_G32_SHIFT / 8] =
2869 src_pixels[src_y + x + 1]; 2776 src_pixels[src_y + x + 1];
2870 dest_pixels[dest_y + x + SK_B32_SHIFT / 8] = 2777 dest_pixels[dest_y + x + SK_B32_SHIFT / 8] =
2871 src_pixels[src_y + x + 2]; 2778 src_pixels[src_y + x + 2];
2872 dest_pixels[dest_y + x + SK_A32_SHIFT / 8] = 2779 dest_pixels[dest_y + x + SK_A32_SHIFT / 8] =
2873 src_pixels[src_y + x + 3]; 2780 src_pixels[src_y + x + 3];
2874 } 2781 }
2875 } 2782 }
2876 2783
2877 GLC(gl_, 2784 gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM);
2878 gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM));
2879 } 2785 }
2880 GLC(gl_, gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0)); 2786 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
2881 GLC(gl_, gl_->DeleteBuffers(1, &source_buffer)); 2787 gl_->DeleteBuffers(1, &source_buffer);
2882 } 2788 }
2883 2789
2884 if (bitmap) 2790 if (bitmap)
2885 current_read->copy_request->SendBitmapResult(bitmap.Pass()); 2791 current_read->copy_request->SendBitmapResult(bitmap.Pass());
2886 pending_async_read_pixels_.pop_back(); 2792 pending_async_read_pixels_.pop_back();
2887 } 2793 }
2888 2794
2889 void GLRenderer::GetFramebufferTexture(unsigned texture_id, 2795 void GLRenderer::GetFramebufferTexture(unsigned texture_id,
2890 ResourceFormat texture_format, 2796 ResourceFormat texture_format,
2891 const gfx::Rect& window_rect) { 2797 const gfx::Rect& window_rect) {
2892 DCHECK(texture_id); 2798 DCHECK(texture_id);
2893 DCHECK_GE(window_rect.x(), 0); 2799 DCHECK_GE(window_rect.x(), 0);
2894 DCHECK_GE(window_rect.y(), 0); 2800 DCHECK_GE(window_rect.y(), 0);
2895 DCHECK_LE(window_rect.right(), current_surface_size_.width()); 2801 DCHECK_LE(window_rect.right(), current_surface_size_.width());
2896 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); 2802 DCHECK_LE(window_rect.bottom(), current_surface_size_.height());
2897 2803
2898 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, texture_id)); 2804 gl_->BindTexture(GL_TEXTURE_2D, texture_id);
2899 GLC(gl_, 2805 gl_->CopyTexImage2D(GL_TEXTURE_2D, 0, GLDataFormat(texture_format),
2900 gl_->CopyTexImage2D(GL_TEXTURE_2D, 2806 window_rect.x(), window_rect.y(), window_rect.width(),
2901 0, 2807 window_rect.height(), 0);
2902 GLDataFormat(texture_format), 2808 gl_->BindTexture(GL_TEXTURE_2D, 0);
2903 window_rect.x(),
2904 window_rect.y(),
2905 window_rect.width(),
2906 window_rect.height(),
2907 0));
2908 GLC(gl_, gl_->BindTexture(GL_TEXTURE_2D, 0));
2909 } 2809 }
2910 2810
2911 bool GLRenderer::UseScopedTexture(DrawingFrame* frame, 2811 bool GLRenderer::UseScopedTexture(DrawingFrame* frame,
2912 const ScopedResource* texture, 2812 const ScopedResource* texture,
2913 const gfx::Rect& viewport_rect) { 2813 const gfx::Rect& viewport_rect) {
2914 DCHECK(texture->id()); 2814 DCHECK(texture->id());
2915 frame->current_render_pass = NULL; 2815 frame->current_render_pass = NULL;
2916 frame->current_texture = texture; 2816 frame->current_texture = texture;
2917 2817
2918 return BindFramebufferToTexture(frame, texture, viewport_rect); 2818 return BindFramebufferToTexture(frame, texture, viewport_rect);
2919 } 2819 }
2920 2820
2921 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { 2821 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) {
2922 current_framebuffer_lock_ = nullptr; 2822 current_framebuffer_lock_ = nullptr;
2923 output_surface_->BindFramebuffer(); 2823 output_surface_->BindFramebuffer();
2924 2824
2925 if (output_surface_->HasExternalStencilTest()) { 2825 if (output_surface_->HasExternalStencilTest()) {
2926 SetStencilEnabled(true); 2826 SetStencilEnabled(true);
2927 GLC(gl_, gl_->StencilFunc(GL_EQUAL, 1, 1)); 2827 gl_->StencilFunc(GL_EQUAL, 1, 1);
2928 } else { 2828 } else {
2929 SetStencilEnabled(false); 2829 SetStencilEnabled(false);
2930 } 2830 }
2931 } 2831 }
2932 2832
2933 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame, 2833 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame,
2934 const ScopedResource* texture, 2834 const ScopedResource* texture,
2935 const gfx::Rect& target_rect) { 2835 const gfx::Rect& target_rect) {
2936 DCHECK(texture->id()); 2836 DCHECK(texture->id());
2937 2837
2938 // Explicitly release lock, otherwise we can crash when try to lock 2838 // Explicitly release lock, otherwise we can crash when try to lock
2939 // same texture again. 2839 // same texture again.
2940 current_framebuffer_lock_ = nullptr; 2840 current_framebuffer_lock_ = nullptr;
2941 2841
2942 SetStencilEnabled(false); 2842 SetStencilEnabled(false);
2943 GLC(gl_, gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_)); 2843 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_);
2944 current_framebuffer_lock_ = 2844 current_framebuffer_lock_ =
2945 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( 2845 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL(
2946 resource_provider_, texture->id())); 2846 resource_provider_, texture->id()));
2947 unsigned texture_id = current_framebuffer_lock_->texture_id(); 2847 unsigned texture_id = current_framebuffer_lock_->texture_id();
2948 GLC(gl_, 2848 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
2949 gl_->FramebufferTexture2D( 2849 texture_id, 0);
2950 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0));
2951 2850
2952 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == 2851 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) ==
2953 GL_FRAMEBUFFER_COMPLETE || 2852 GL_FRAMEBUFFER_COMPLETE ||
2954 IsContextLost()); 2853 IsContextLost());
2955 return true; 2854 return true;
2956 } 2855 }
2957 2856
2958 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { 2857 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) {
2959 EnsureScissorTestEnabled(); 2858 EnsureScissorTestEnabled();
2960 2859
2961 // Don't unnecessarily ask the context to change the scissor, because it 2860 // Don't unnecessarily ask the context to change the scissor, because it
2962 // may cause undesired GPU pipeline flushes. 2861 // may cause undesired GPU pipeline flushes.
2963 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_) 2862 if (scissor_rect == scissor_rect_ && !scissor_rect_needs_reset_)
2964 return; 2863 return;
2965 2864
2966 scissor_rect_ = scissor_rect; 2865 scissor_rect_ = scissor_rect;
2967 FlushTextureQuadCache(SHARED_BINDING); 2866 FlushTextureQuadCache(SHARED_BINDING);
2968 GLC(gl_, 2867 gl_->Scissor(scissor_rect.x(), scissor_rect.y(), scissor_rect.width(),
2969 gl_->Scissor(scissor_rect.x(), 2868 scissor_rect.height());
2970 scissor_rect.y(),
2971 scissor_rect.width(),
2972 scissor_rect.height()));
2973 2869
2974 scissor_rect_needs_reset_ = false; 2870 scissor_rect_needs_reset_ = false;
2975 } 2871 }
2976 2872
2977 void GLRenderer::SetViewport() { 2873 void GLRenderer::SetViewport() {
2978 GLC(gl_, gl_->Viewport(current_window_space_viewport_.x(), 2874 gl_->Viewport(current_window_space_viewport_.x(),
2979 current_window_space_viewport_.y(), 2875 current_window_space_viewport_.y(),
2980 current_window_space_viewport_.width(), 2876 current_window_space_viewport_.width(),
2981 current_window_space_viewport_.height())); 2877 current_window_space_viewport_.height());
2982 } 2878 }
2983 2879
2984 void GLRenderer::InitializeSharedObjects() { 2880 void GLRenderer::InitializeSharedObjects() {
2985 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); 2881 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects");
2986 2882
2987 // Create an FBO for doing offscreen rendering. 2883 // Create an FBO for doing offscreen rendering.
2988 GLC(gl_, gl_->GenFramebuffers(1, &offscreen_framebuffer_id_)); 2884 gl_->GenFramebuffers(1, &offscreen_framebuffer_id_);
2989 2885
2990 shared_geometry_ = 2886 shared_geometry_ =
2991 make_scoped_ptr(new StaticGeometryBinding(gl_, QuadVertexRect())); 2887 make_scoped_ptr(new StaticGeometryBinding(gl_, QuadVertexRect()));
2992 clipped_geometry_ = make_scoped_ptr(new DynamicGeometryBinding(gl_)); 2888 clipped_geometry_ = make_scoped_ptr(new DynamicGeometryBinding(gl_));
2993 } 2889 }
2994 2890
2995 void GLRenderer::PrepareGeometry(BoundGeometry binding) { 2891 void GLRenderer::PrepareGeometry(BoundGeometry binding) {
2996 if (binding == bound_geometry_) { 2892 if (binding == bound_geometry_) {
2997 return; 2893 return;
2998 } 2894 }
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3460 video_stream_texture_program_[i].Cleanup(gl_); 3356 video_stream_texture_program_[i].Cleanup(gl_);
3461 } 3357 }
3462 3358
3463 tile_checkerboard_program_.Cleanup(gl_); 3359 tile_checkerboard_program_.Cleanup(gl_);
3464 3360
3465 debug_border_program_.Cleanup(gl_); 3361 debug_border_program_.Cleanup(gl_);
3466 solid_color_program_.Cleanup(gl_); 3362 solid_color_program_.Cleanup(gl_);
3467 solid_color_program_aa_.Cleanup(gl_); 3363 solid_color_program_aa_.Cleanup(gl_);
3468 3364
3469 if (offscreen_framebuffer_id_) 3365 if (offscreen_framebuffer_id_)
3470 GLC(gl_, gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_)); 3366 gl_->DeleteFramebuffers(1, &offscreen_framebuffer_id_);
3471 3367
3472 if (on_demand_tile_raster_resource_id_) 3368 if (on_demand_tile_raster_resource_id_)
3473 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); 3369 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_);
3474 3370
3475 ReleaseRenderPassTextures(); 3371 ReleaseRenderPassTextures();
3476 } 3372 }
3477 3373
3478 void GLRenderer::ReinitializeGLState() { 3374 void GLRenderer::ReinitializeGLState() {
3479 is_scissor_enabled_ = false; 3375 is_scissor_enabled_ = false;
3480 scissor_rect_needs_reset_ = true; 3376 scissor_rect_needs_reset_ = true;
3481 stencil_shadow_ = false; 3377 stencil_shadow_ = false;
3482 blend_shadow_ = true; 3378 blend_shadow_ = true;
3483 program_shadow_ = 0; 3379 program_shadow_ = 0;
3484 3380
3485 RestoreGLState(); 3381 RestoreGLState();
3486 } 3382 }
3487 3383
3488 void GLRenderer::RestoreGLState() { 3384 void GLRenderer::RestoreGLState() {
3489 // This restores the current GLRenderer state to the GL context. 3385 // This restores the current GLRenderer state to the GL context.
3490 bound_geometry_ = NO_BINDING; 3386 bound_geometry_ = NO_BINDING;
3491 PrepareGeometry(SHARED_BINDING); 3387 PrepareGeometry(SHARED_BINDING);
3492 3388
3493 GLC(gl_, gl_->Disable(GL_DEPTH_TEST)); 3389 gl_->Disable(GL_DEPTH_TEST);
3494 GLC(gl_, gl_->Disable(GL_CULL_FACE)); 3390 gl_->Disable(GL_CULL_FACE);
3495 GLC(gl_, gl_->ColorMask(true, true, true, true)); 3391 gl_->ColorMask(true, true, true, true);
3496 GLC(gl_, gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); 3392 gl_->BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
3497 GLC(gl_, gl_->ActiveTexture(GL_TEXTURE0)); 3393 gl_->ActiveTexture(GL_TEXTURE0);
3498 3394
3499 if (program_shadow_) 3395 if (program_shadow_)
3500 gl_->UseProgram(program_shadow_); 3396 gl_->UseProgram(program_shadow_);
3501 3397
3502 if (stencil_shadow_) 3398 if (stencil_shadow_)
3503 GLC(gl_, gl_->Enable(GL_STENCIL_TEST)); 3399 gl_->Enable(GL_STENCIL_TEST);
3504 else 3400 else
3505 GLC(gl_, gl_->Disable(GL_STENCIL_TEST)); 3401 gl_->Disable(GL_STENCIL_TEST);
3506 3402
3507 if (blend_shadow_) 3403 if (blend_shadow_)
3508 GLC(gl_, gl_->Enable(GL_BLEND)); 3404 gl_->Enable(GL_BLEND);
3509 else 3405 else
3510 GLC(gl_, gl_->Disable(GL_BLEND)); 3406 gl_->Disable(GL_BLEND);
3511 3407
3512 if (is_scissor_enabled_) { 3408 if (is_scissor_enabled_) {
3513 GLC(gl_, gl_->Enable(GL_SCISSOR_TEST)); 3409 gl_->Enable(GL_SCISSOR_TEST);
3514 GLC(gl_, 3410 gl_->Scissor(scissor_rect_.x(), scissor_rect_.y(), scissor_rect_.width(),
3515 gl_->Scissor(scissor_rect_.x(), 3411 scissor_rect_.height());
3516 scissor_rect_.y(),
3517 scissor_rect_.width(),
3518 scissor_rect_.height()));
3519 } else { 3412 } else {
3520 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); 3413 gl_->Disable(GL_SCISSOR_TEST);
3521 } 3414 }
3522 } 3415 }
3523 3416
3524 void GLRenderer::RestoreFramebuffer(DrawingFrame* frame) { 3417 void GLRenderer::RestoreFramebuffer(DrawingFrame* frame) {
3525 UseRenderPass(frame, frame->current_render_pass); 3418 UseRenderPass(frame, frame->current_render_pass);
3526 3419
3527 // Call SetViewport directly, rather than through PrepareSurfaceForPass. 3420 // Call SetViewport directly, rather than through PrepareSurfaceForPass.
3528 // PrepareSurfaceForPass also clears the surface, which is not desired when 3421 // PrepareSurfaceForPass also clears the surface, which is not desired when
3529 // restoring. 3422 // restoring.
3530 SetViewport(); 3423 SetViewport();
(...skipping 23 matching lines...) Expand all
3554 context_support_->ScheduleOverlayPlane( 3447 context_support_->ScheduleOverlayPlane(
3555 overlay.plane_z_order, 3448 overlay.plane_z_order,
3556 overlay.transform, 3449 overlay.transform,
3557 pending_overlay_resources_.back()->texture_id(), 3450 pending_overlay_resources_.back()->texture_id(),
3558 overlay.display_rect, 3451 overlay.display_rect,
3559 overlay.uv_rect); 3452 overlay.uv_rect);
3560 } 3453 }
3561 } 3454 }
3562 3455
3563 } // namespace cc 3456 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/shader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698