| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return true; | 78 return true; |
| 79 #else | 79 #else |
| 80 return false; | 80 return false; |
| 81 #endif | 81 #endif |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // anonymous namespace | 84 } // anonymous namespace |
| 85 | 85 |
| 86 scoped_ptr<GLRenderer> GLRenderer::Create(RendererClient* client, | 86 scoped_ptr<GLRenderer> GLRenderer::Create(RendererClient* client, |
| 87 OutputSurface* output_surface, | 87 OutputSurface* output_surface, |
| 88 ResourceProvider* resource_provider) { | 88 ResourceProvider* resource_provider, |
| 89 scoped_ptr<GLRenderer> renderer( | 89 int highp_threshold_min) { |
| 90 new GLRenderer(client, output_surface, resource_provider)); | 90 scoped_ptr<GLRenderer> renderer(new GLRenderer( |
| 91 client, output_surface, resource_provider, highp_threshold_min)); |
| 91 if (!renderer->Initialize()) | 92 if (!renderer->Initialize()) |
| 92 return scoped_ptr<GLRenderer>(); | 93 return scoped_ptr<GLRenderer>(); |
| 93 | 94 |
| 94 return renderer.Pass(); | 95 return renderer.Pass(); |
| 95 } | 96 } |
| 96 | 97 |
| 97 GLRenderer::GLRenderer(RendererClient* client, | 98 GLRenderer::GLRenderer(RendererClient* client, |
| 98 OutputSurface* output_surface, | 99 OutputSurface* output_surface, |
| 99 ResourceProvider* resource_provider) | 100 ResourceProvider* resource_provider, |
| 101 int highp_threshold_min) |
| 100 : DirectRenderer(client, resource_provider), | 102 : DirectRenderer(client, resource_provider), |
| 101 offscreen_framebuffer_id_(0), | 103 offscreen_framebuffer_id_(0), |
| 102 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), | 104 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), |
| 103 output_surface_(output_surface), | 105 output_surface_(output_surface), |
| 104 context_(output_surface->context3d()), | 106 context_(output_surface->context3d()), |
| 105 is_viewport_changed_(false), | 107 is_viewport_changed_(false), |
| 106 is_backbuffer_discarded_(false), | 108 is_backbuffer_discarded_(false), |
| 107 discard_backbuffer_when_not_visible_(false), | 109 discard_backbuffer_when_not_visible_(false), |
| 108 is_using_bind_uniform_(false), | 110 is_using_bind_uniform_(false), |
| 109 visible_(true), | 111 visible_(true), |
| 110 is_scissor_enabled_(false), | 112 is_scissor_enabled_(false), |
| 113 highp_threshold_min_(highp_threshold_min), |
| 111 on_demand_tile_raster_resource_id_(0) { | 114 on_demand_tile_raster_resource_id_(0) { |
| 112 DCHECK(context_); | 115 DCHECK(context_); |
| 113 } | 116 } |
| 114 | 117 |
| 115 bool GLRenderer::Initialize() { | 118 bool GLRenderer::Initialize() { |
| 116 if (!context_->makeContextCurrent()) | 119 if (!context_->makeContextCurrent()) |
| 117 return false; | 120 return false; |
| 118 | 121 |
| 119 context_->setContextLostCallback(this); | 122 context_->setContextLostCallback(this); |
| 120 context_->pushGroupMarkerEXT("CompositorContext"); | 123 context_->pushGroupMarkerEXT("CompositorContext"); |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); | 743 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); |
| 741 Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 744 Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); |
| 742 } else { | 745 } else { |
| 743 contents_resource_lock = make_scoped_ptr( | 746 contents_resource_lock = make_scoped_ptr( |
| 744 new ResourceProvider::ScopedSamplerGL(resource_provider_, | 747 new ResourceProvider::ScopedSamplerGL(resource_provider_, |
| 745 contents_texture->id(), | 748 contents_texture->id(), |
| 746 GL_TEXTURE_2D, | 749 GL_TEXTURE_2D, |
| 747 GL_LINEAR)); | 750 GL_LINEAR)); |
| 748 } | 751 } |
| 749 | 752 |
| 753 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 754 context_, highp_threshold_min_, |
| 755 quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 756 |
| 750 int shader_quad_location = -1; | 757 int shader_quad_location = -1; |
| 751 int shader_edge_location = -1; | 758 int shader_edge_location = -1; |
| 752 int shader_mask_sampler_location = -1; | 759 int shader_mask_sampler_location = -1; |
| 753 int shader_mask_tex_coord_scale_location = -1; | 760 int shader_mask_tex_coord_scale_location = -1; |
| 754 int shader_mask_tex_coord_offset_location = -1; | 761 int shader_mask_tex_coord_offset_location = -1; |
| 755 int shader_matrix_location = -1; | 762 int shader_matrix_location = -1; |
| 756 int shader_alpha_location = -1; | 763 int shader_alpha_location = -1; |
| 757 int shader_color_matrix_location = -1; | 764 int shader_color_matrix_location = -1; |
| 758 int shader_color_offset_location = -1; | 765 int shader_color_offset_location = -1; |
| 759 int shader_tex_transform_location = -1; | 766 int shader_tex_transform_location = -1; |
| 760 int shader_tex_scale_location = -1; | 767 int shader_tex_scale_location = -1; |
| 761 | 768 |
| 762 if (use_aa && mask_texture_id && !use_color_matrix) { | 769 if (use_aa && mask_texture_id && !use_color_matrix) { |
| 763 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA(); | 770 const RenderPassMaskProgramAA* program = |
| 771 GetRenderPassMaskProgramAA(texCoordPrecision); |
| 764 SetUseProgram(program->program()); | 772 SetUseProgram(program->program()); |
| 765 GLC(Context(), | 773 GLC(Context(), |
| 766 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 774 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 767 | 775 |
| 768 shader_quad_location = program->vertex_shader().point_location(); | 776 shader_quad_location = program->vertex_shader().point_location(); |
| 769 shader_edge_location = program->fragment_shader().edge_location(); | 777 shader_edge_location = program->fragment_shader().edge_location(); |
| 770 shader_mask_sampler_location = | 778 shader_mask_sampler_location = |
| 771 program->fragment_shader().mask_sampler_location(); | 779 program->fragment_shader().mask_sampler_location(); |
| 772 shader_mask_tex_coord_scale_location = | 780 shader_mask_tex_coord_scale_location = |
| 773 program->fragment_shader().mask_tex_coord_scale_location(); | 781 program->fragment_shader().mask_tex_coord_scale_location(); |
| 774 shader_mask_tex_coord_offset_location = | 782 shader_mask_tex_coord_offset_location = |
| 775 program->fragment_shader().mask_tex_coord_offset_location(); | 783 program->fragment_shader().mask_tex_coord_offset_location(); |
| 776 shader_matrix_location = program->vertex_shader().matrix_location(); | 784 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 777 shader_alpha_location = program->fragment_shader().alpha_location(); | 785 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 778 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); | 786 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 779 } else if (!use_aa && mask_texture_id && !use_color_matrix) { | 787 } else if (!use_aa && mask_texture_id && !use_color_matrix) { |
| 780 const RenderPassMaskProgram* program = GetRenderPassMaskProgram(); | 788 const RenderPassMaskProgram* program = |
| 789 GetRenderPassMaskProgram(texCoordPrecision); |
| 781 SetUseProgram(program->program()); | 790 SetUseProgram(program->program()); |
| 782 GLC(Context(), | 791 GLC(Context(), |
| 783 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 792 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 784 | 793 |
| 785 shader_mask_sampler_location = | 794 shader_mask_sampler_location = |
| 786 program->fragment_shader().mask_sampler_location(); | 795 program->fragment_shader().mask_sampler_location(); |
| 787 shader_mask_tex_coord_scale_location = | 796 shader_mask_tex_coord_scale_location = |
| 788 program->fragment_shader().mask_tex_coord_scale_location(); | 797 program->fragment_shader().mask_tex_coord_scale_location(); |
| 789 shader_mask_tex_coord_offset_location = | 798 shader_mask_tex_coord_offset_location = |
| 790 program->fragment_shader().mask_tex_coord_offset_location(); | 799 program->fragment_shader().mask_tex_coord_offset_location(); |
| 791 shader_matrix_location = program->vertex_shader().matrix_location(); | 800 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 792 shader_alpha_location = program->fragment_shader().alpha_location(); | 801 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 793 shader_tex_transform_location = | 802 shader_tex_transform_location = |
| 794 program->vertex_shader().tex_transform_location(); | 803 program->vertex_shader().tex_transform_location(); |
| 795 } else if (use_aa && !mask_texture_id && !use_color_matrix) { | 804 } else if (use_aa && !mask_texture_id && !use_color_matrix) { |
| 796 const RenderPassProgramAA* program = GetRenderPassProgramAA(); | 805 const RenderPassProgramAA* program = |
| 806 GetRenderPassProgramAA(texCoordPrecision); |
| 797 SetUseProgram(program->program()); | 807 SetUseProgram(program->program()); |
| 798 GLC(Context(), | 808 GLC(Context(), |
| 799 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 809 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 800 | 810 |
| 801 shader_quad_location = program->vertex_shader().point_location(); | 811 shader_quad_location = program->vertex_shader().point_location(); |
| 802 shader_edge_location = program->fragment_shader().edge_location(); | 812 shader_edge_location = program->fragment_shader().edge_location(); |
| 803 shader_matrix_location = program->vertex_shader().matrix_location(); | 813 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 804 shader_alpha_location = program->fragment_shader().alpha_location(); | 814 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 805 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); | 815 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 806 } else if (use_aa && mask_texture_id && use_color_matrix) { | 816 } else if (use_aa && mask_texture_id && use_color_matrix) { |
| 807 const RenderPassMaskColorMatrixProgramAA* program = | 817 const RenderPassMaskColorMatrixProgramAA* program = |
| 808 GetRenderPassMaskColorMatrixProgramAA(); | 818 GetRenderPassMaskColorMatrixProgramAA(texCoordPrecision); |
| 809 SetUseProgram(program->program()); | 819 SetUseProgram(program->program()); |
| 810 GLC(Context(), | 820 GLC(Context(), |
| 811 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 821 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 812 | 822 |
| 813 shader_matrix_location = program->vertex_shader().matrix_location(); | 823 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 814 shader_quad_location = program->vertex_shader().point_location(); | 824 shader_quad_location = program->vertex_shader().point_location(); |
| 815 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); | 825 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 816 shader_edge_location = program->fragment_shader().edge_location(); | 826 shader_edge_location = program->fragment_shader().edge_location(); |
| 817 shader_alpha_location = program->fragment_shader().alpha_location(); | 827 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 818 shader_mask_sampler_location = | 828 shader_mask_sampler_location = |
| 819 program->fragment_shader().mask_sampler_location(); | 829 program->fragment_shader().mask_sampler_location(); |
| 820 shader_mask_tex_coord_scale_location = | 830 shader_mask_tex_coord_scale_location = |
| 821 program->fragment_shader().mask_tex_coord_scale_location(); | 831 program->fragment_shader().mask_tex_coord_scale_location(); |
| 822 shader_mask_tex_coord_offset_location = | 832 shader_mask_tex_coord_offset_location = |
| 823 program->fragment_shader().mask_tex_coord_offset_location(); | 833 program->fragment_shader().mask_tex_coord_offset_location(); |
| 824 shader_color_matrix_location = | 834 shader_color_matrix_location = |
| 825 program->fragment_shader().color_matrix_location(); | 835 program->fragment_shader().color_matrix_location(); |
| 826 shader_color_offset_location = | 836 shader_color_offset_location = |
| 827 program->fragment_shader().color_offset_location(); | 837 program->fragment_shader().color_offset_location(); |
| 828 } else if (use_aa && !mask_texture_id && use_color_matrix) { | 838 } else if (use_aa && !mask_texture_id && use_color_matrix) { |
| 829 const RenderPassColorMatrixProgramAA* program = | 839 const RenderPassColorMatrixProgramAA* program = |
| 830 GetRenderPassColorMatrixProgramAA(); | 840 GetRenderPassColorMatrixProgramAA(texCoordPrecision); |
| 831 SetUseProgram(program->program()); | 841 SetUseProgram(program->program()); |
| 832 GLC(Context(), | 842 GLC(Context(), |
| 833 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 843 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 834 | 844 |
| 835 shader_matrix_location = program->vertex_shader().matrix_location(); | 845 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 836 shader_quad_location = program->vertex_shader().point_location(); | 846 shader_quad_location = program->vertex_shader().point_location(); |
| 837 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); | 847 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 838 shader_edge_location = program->fragment_shader().edge_location(); | 848 shader_edge_location = program->fragment_shader().edge_location(); |
| 839 shader_alpha_location = program->fragment_shader().alpha_location(); | 849 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 840 shader_color_matrix_location = | 850 shader_color_matrix_location = |
| 841 program->fragment_shader().color_matrix_location(); | 851 program->fragment_shader().color_matrix_location(); |
| 842 shader_color_offset_location = | 852 shader_color_offset_location = |
| 843 program->fragment_shader().color_offset_location(); | 853 program->fragment_shader().color_offset_location(); |
| 844 } else if (!use_aa && mask_texture_id && use_color_matrix) { | 854 } else if (!use_aa && mask_texture_id && use_color_matrix) { |
| 845 const RenderPassMaskColorMatrixProgram* program = | 855 const RenderPassMaskColorMatrixProgram* program = |
| 846 GetRenderPassMaskColorMatrixProgram(); | 856 GetRenderPassMaskColorMatrixProgram(texCoordPrecision); |
| 847 SetUseProgram(program->program()); | 857 SetUseProgram(program->program()); |
| 848 GLC(Context(), | 858 GLC(Context(), |
| 849 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 859 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 850 | 860 |
| 851 shader_matrix_location = program->vertex_shader().matrix_location(); | 861 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 852 shader_tex_transform_location = | 862 shader_tex_transform_location = |
| 853 program->vertex_shader().tex_transform_location(); | 863 program->vertex_shader().tex_transform_location(); |
| 854 shader_mask_sampler_location = | 864 shader_mask_sampler_location = |
| 855 program->fragment_shader().mask_sampler_location(); | 865 program->fragment_shader().mask_sampler_location(); |
| 856 shader_mask_tex_coord_scale_location = | 866 shader_mask_tex_coord_scale_location = |
| 857 program->fragment_shader().mask_tex_coord_scale_location(); | 867 program->fragment_shader().mask_tex_coord_scale_location(); |
| 858 shader_mask_tex_coord_offset_location = | 868 shader_mask_tex_coord_offset_location = |
| 859 program->fragment_shader().mask_tex_coord_offset_location(); | 869 program->fragment_shader().mask_tex_coord_offset_location(); |
| 860 shader_alpha_location = program->fragment_shader().alpha_location(); | 870 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 861 shader_color_matrix_location = | 871 shader_color_matrix_location = |
| 862 program->fragment_shader().color_matrix_location(); | 872 program->fragment_shader().color_matrix_location(); |
| 863 shader_color_offset_location = | 873 shader_color_offset_location = |
| 864 program->fragment_shader().color_offset_location(); | 874 program->fragment_shader().color_offset_location(); |
| 865 } else if (!use_aa && !mask_texture_id && use_color_matrix) { | 875 } else if (!use_aa && !mask_texture_id && use_color_matrix) { |
| 866 const RenderPassColorMatrixProgram* program = | 876 const RenderPassColorMatrixProgram* program = |
| 867 GetRenderPassColorMatrixProgram(); | 877 GetRenderPassColorMatrixProgram(texCoordPrecision); |
| 868 SetUseProgram(program->program()); | 878 SetUseProgram(program->program()); |
| 869 GLC(Context(), | 879 GLC(Context(), |
| 870 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 880 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 871 | 881 |
| 872 shader_matrix_location = program->vertex_shader().matrix_location(); | 882 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 873 shader_tex_transform_location = | 883 shader_tex_transform_location = |
| 874 program->vertex_shader().tex_transform_location(); | 884 program->vertex_shader().tex_transform_location(); |
| 875 shader_alpha_location = program->fragment_shader().alpha_location(); | 885 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 876 shader_color_matrix_location = | 886 shader_color_matrix_location = |
| 877 program->fragment_shader().color_matrix_location(); | 887 program->fragment_shader().color_matrix_location(); |
| 878 shader_color_offset_location = | 888 shader_color_offset_location = |
| 879 program->fragment_shader().color_offset_location(); | 889 program->fragment_shader().color_offset_location(); |
| 880 } else { | 890 } else { |
| 881 const RenderPassProgram* program = GetRenderPassProgram(); | 891 const RenderPassProgram* program = |
| 892 GetRenderPassProgram(texCoordPrecision); |
| 882 SetUseProgram(program->program()); | 893 SetUseProgram(program->program()); |
| 883 GLC(Context(), | 894 GLC(Context(), |
| 884 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 895 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 885 | 896 |
| 886 shader_matrix_location = program->vertex_shader().matrix_location(); | 897 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 887 shader_alpha_location = program->fragment_shader().alpha_location(); | 898 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 888 shader_tex_transform_location = | 899 shader_tex_transform_location = |
| 889 program->vertex_shader().tex_transform_location(); | 900 program->vertex_shader().tex_transform_location(); |
| 890 } | 901 } |
| 891 float tex_scale_x = | 902 float tex_scale_x = |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 clamp_geom_rect.Inset(geom_clamp_x, geom_clamp_y, geom_clamp_x, geom_clamp_y); | 1215 clamp_geom_rect.Inset(geom_clamp_x, geom_clamp_y, geom_clamp_x, geom_clamp_y); |
| 1205 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y); | 1216 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y); |
| 1206 | 1217 |
| 1207 // Map clamping rectangle to unit square. | 1218 // Map clamping rectangle to unit square. |
| 1208 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); | 1219 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); |
| 1209 float vertex_tex_translate_y = | 1220 float vertex_tex_translate_y = |
| 1210 -clamp_geom_rect.y() / clamp_geom_rect.height(); | 1221 -clamp_geom_rect.y() / clamp_geom_rect.height(); |
| 1211 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); | 1222 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); |
| 1212 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); | 1223 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); |
| 1213 | 1224 |
| 1225 // We assume we do not need highp texture coordinates for tiles. |
| 1226 // Make sure that assumption is correct here. |
| 1227 DCHECK_EQ(TexCoordPrecisionMedium, TexCoordPrecisionRequired( |
| 1228 context_, highp_threshold_min_, quad->texture_size)); |
| 1229 |
| 1214 // Map to normalized texture coordinates. | 1230 // Map to normalized texture coordinates. |
| 1215 gfx::Size texture_size = quad->texture_size; | 1231 gfx::Size texture_size = quad->texture_size; |
| 1216 float fragment_tex_translate_x = clamp_tex_rect.x() / texture_size.width(); | 1232 float fragment_tex_translate_x = clamp_tex_rect.x() / texture_size.width(); |
| 1217 float fragment_tex_translate_y = clamp_tex_rect.y() / texture_size.height(); | 1233 float fragment_tex_translate_y = clamp_tex_rect.y() / texture_size.height(); |
| 1218 float fragment_tex_scale_x = clamp_tex_rect.width() / texture_size.width(); | 1234 float fragment_tex_scale_x = clamp_tex_rect.width() / texture_size.width(); |
| 1219 float fragment_tex_scale_y = clamp_tex_rect.height() / texture_size.height(); | 1235 float fragment_tex_scale_y = clamp_tex_rect.height() / texture_size.height(); |
| 1220 | 1236 |
| 1221 gfx::Transform device_transform = | 1237 gfx::Transform device_transform = |
| 1222 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); | 1238 frame->window_matrix * frame->projection_matrix * quad->quadTransform(); |
| 1223 device_transform.FlattenTo2d(); | 1239 device_transform.FlattenTo2d(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), | 1328 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), |
| 1313 tile_rect.size()); | 1329 tile_rect.size()); |
| 1314 DrawQuadGeometry( | 1330 DrawQuadGeometry( |
| 1315 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); | 1331 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); |
| 1316 } | 1332 } |
| 1317 | 1333 |
| 1318 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, | 1334 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame* frame, |
| 1319 const YUVVideoDrawQuad* quad) { | 1335 const YUVVideoDrawQuad* quad) { |
| 1320 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1336 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1321 | 1337 |
| 1322 const VideoYUVProgram* program = GetVideoYUVProgram(); | 1338 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1339 context_, highp_threshold_min_, |
| 1340 quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1341 |
| 1342 const VideoYUVProgram* program = GetVideoYUVProgram(texCoordPrecision); |
| 1323 DCHECK(program && (program->initialized() || IsContextLost())); | 1343 DCHECK(program && (program->initialized() || IsContextLost())); |
| 1324 | 1344 |
| 1325 const VideoLayerImpl::FramePlane& y_plane = quad->y_plane; | 1345 const VideoLayerImpl::FramePlane& y_plane = quad->y_plane; |
| 1326 const VideoLayerImpl::FramePlane& u_plane = quad->u_plane; | 1346 const VideoLayerImpl::FramePlane& u_plane = quad->u_plane; |
| 1327 const VideoLayerImpl::FramePlane& v_plane = quad->v_plane; | 1347 const VideoLayerImpl::FramePlane& v_plane = quad->v_plane; |
| 1328 | 1348 |
| 1329 GLC(Context(), Context()->activeTexture(GL_TEXTURE1)); | 1349 GLC(Context(), Context()->activeTexture(GL_TEXTURE1)); |
| 1330 ResourceProvider::ScopedSamplerGL y_plane_lock( | 1350 ResourceProvider::ScopedSamplerGL y_plane_lock( |
| 1331 resource_provider_, y_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); | 1351 resource_provider_, y_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); |
| 1332 GLC(Context(), Context()->activeTexture(GL_TEXTURE2)); | 1352 GLC(Context(), Context()->activeTexture(GL_TEXTURE2)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 } | 1404 } |
| 1385 | 1405 |
| 1386 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, | 1406 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, |
| 1387 const StreamVideoDrawQuad* quad) { | 1407 const StreamVideoDrawQuad* quad) { |
| 1388 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1408 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1389 | 1409 |
| 1390 static float gl_matrix[16]; | 1410 static float gl_matrix[16]; |
| 1391 | 1411 |
| 1392 DCHECK(capabilities_.using_egl_image); | 1412 DCHECK(capabilities_.using_egl_image); |
| 1393 | 1413 |
| 1394 const VideoStreamTextureProgram* program = GetVideoStreamTextureProgram(); | 1414 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1415 context_, highp_threshold_min_, |
| 1416 quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1417 |
| 1418 const VideoStreamTextureProgram* program = |
| 1419 GetVideoStreamTextureProgram(texCoordPrecision); |
| 1395 SetUseProgram(program->program()); | 1420 SetUseProgram(program->program()); |
| 1396 | 1421 |
| 1397 ToGLMatrix(&gl_matrix[0], quad->matrix); | 1422 ToGLMatrix(&gl_matrix[0], quad->matrix); |
| 1398 GLC(Context(), | 1423 GLC(Context(), |
| 1399 Context()->uniformMatrix4fv( | 1424 Context()->uniformMatrix4fv( |
| 1400 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); | 1425 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); |
| 1401 | 1426 |
| 1402 GLC(Context(), | 1427 GLC(Context(), |
| 1403 Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture_id)); | 1428 Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture_id)); |
| 1404 | 1429 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 | 1575 |
| 1551 // Clear the cache. | 1576 // Clear the cache. |
| 1552 draw_cache_.program_id = 0; | 1577 draw_cache_.program_id = 0; |
| 1553 draw_cache_.uv_xform_data.resize(0); | 1578 draw_cache_.uv_xform_data.resize(0); |
| 1554 draw_cache_.vertex_opacity_data.resize(0); | 1579 draw_cache_.vertex_opacity_data.resize(0); |
| 1555 draw_cache_.matrix_data.resize(0); | 1580 draw_cache_.matrix_data.resize(0); |
| 1556 } | 1581 } |
| 1557 | 1582 |
| 1558 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame, | 1583 void GLRenderer::EnqueueTextureQuad(const DrawingFrame* frame, |
| 1559 const TextureDrawQuad* quad) { | 1584 const TextureDrawQuad* quad) { |
| 1585 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1586 context_, highp_threshold_min_, |
| 1587 quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1588 |
| 1560 // Choose the correct texture program binding | 1589 // Choose the correct texture program binding |
| 1561 TexTransformTextureProgramBinding binding; | 1590 TexTransformTextureProgramBinding binding; |
| 1562 if (quad->flipped) | 1591 if (quad->flipped) |
| 1563 binding.Set(GetTextureProgramFlip(), Context()); | 1592 binding.Set(GetTextureProgramFlip(texCoordPrecision), Context()); |
| 1564 else | 1593 else |
| 1565 binding.Set(GetTextureProgram(), Context()); | 1594 binding.Set(GetTextureProgram(texCoordPrecision), Context()); |
| 1566 | 1595 |
| 1567 int resource_id = quad->resource_id; | 1596 int resource_id = quad->resource_id; |
| 1568 | 1597 |
| 1569 if (draw_cache_.program_id != binding.program_id || | 1598 if (draw_cache_.program_id != binding.program_id || |
| 1570 draw_cache_.resource_id != resource_id || | 1599 draw_cache_.resource_id != resource_id || |
| 1571 draw_cache_.use_premultiplied_alpha != quad->premultiplied_alpha || | 1600 draw_cache_.use_premultiplied_alpha != quad->premultiplied_alpha || |
| 1572 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || | 1601 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || |
| 1573 draw_cache_.matrix_data.size() >= 8) { | 1602 draw_cache_.matrix_data.size() >= 8) { |
| 1574 FlushTextureQuadCache(); | 1603 FlushTextureQuadCache(); |
| 1575 draw_cache_.program_id = binding.program_id; | 1604 draw_cache_.program_id = binding.program_id; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1601 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); | 1630 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); |
| 1602 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; | 1631 quad_rect_matrix = frame->projection_matrix * quad_rect_matrix; |
| 1603 | 1632 |
| 1604 Float16 m; | 1633 Float16 m; |
| 1605 quad_rect_matrix.matrix().asColMajorf(m.data); | 1634 quad_rect_matrix.matrix().asColMajorf(m.data); |
| 1606 draw_cache_.matrix_data.push_back(m); | 1635 draw_cache_.matrix_data.push_back(m); |
| 1607 } | 1636 } |
| 1608 | 1637 |
| 1609 void GLRenderer::DrawTextureQuad(const DrawingFrame* frame, | 1638 void GLRenderer::DrawTextureQuad(const DrawingFrame* frame, |
| 1610 const TextureDrawQuad* quad) { | 1639 const TextureDrawQuad* quad) { |
| 1640 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1641 context_, highp_threshold_min_, |
| 1642 quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1643 |
| 1611 TexTransformTextureProgramBinding binding; | 1644 TexTransformTextureProgramBinding binding; |
| 1612 if (quad->flipped) | 1645 if (quad->flipped) |
| 1613 binding.Set(GetTextureProgramFlip(), Context()); | 1646 binding.Set(GetTextureProgramFlip(texCoordPrecision), Context()); |
| 1614 else | 1647 else |
| 1615 binding.Set(GetTextureProgram(), Context()); | 1648 binding.Set(GetTextureProgram(texCoordPrecision), Context()); |
| 1616 SetUseProgram(binding.program_id); | 1649 SetUseProgram(binding.program_id); |
| 1617 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); | 1650 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); |
| 1618 gfx::PointF uv0 = quad->uv_top_left; | 1651 gfx::PointF uv0 = quad->uv_top_left; |
| 1619 gfx::PointF uv1 = quad->uv_bottom_right; | 1652 gfx::PointF uv1 = quad->uv_bottom_right; |
| 1620 GLC(Context(), | 1653 GLC(Context(), |
| 1621 Context()->uniform4f(binding.tex_transform_location, | 1654 Context()->uniform4f(binding.tex_transform_location, |
| 1622 uv0.x(), | 1655 uv0.x(), |
| 1623 uv0.y(), | 1656 uv0.y(), |
| 1624 uv1.x() - uv0.x(), | 1657 uv1.x() - uv0.x(), |
| 1625 uv1.y() - uv0.y())); | 1658 uv1.y() - uv0.y())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1651 frame, quad->quadTransform(), quad->rect, binding.matrix_location); | 1684 frame, quad->quadTransform(), quad->rect, binding.matrix_location); |
| 1652 | 1685 |
| 1653 if (!quad->premultiplied_alpha) | 1686 if (!quad->premultiplied_alpha) |
| 1654 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 1687 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| 1655 } | 1688 } |
| 1656 | 1689 |
| 1657 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, | 1690 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame* frame, |
| 1658 const IOSurfaceDrawQuad* quad) { | 1691 const IOSurfaceDrawQuad* quad) { |
| 1659 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1692 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1660 | 1693 |
| 1694 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1695 context_, highp_threshold_min_, |
| 1696 quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1697 |
| 1661 TexTransformTextureProgramBinding binding; | 1698 TexTransformTextureProgramBinding binding; |
| 1662 binding.Set(GetTextureIOSurfaceProgram(), Context()); | 1699 binding.Set(GetTextureIOSurfaceProgram(texCoordPrecision), Context()); |
| 1663 | 1700 |
| 1664 SetUseProgram(binding.program_id); | 1701 SetUseProgram(binding.program_id); |
| 1665 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); | 1702 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); |
| 1666 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { | 1703 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { |
| 1667 GLC(Context(), | 1704 GLC(Context(), |
| 1668 Context()->uniform4f(binding.tex_transform_location, | 1705 Context()->uniform4f(binding.tex_transform_location, |
| 1669 0, | 1706 0, |
| 1670 quad->io_surface_size.height(), | 1707 quad->io_surface_size.height(), |
| 1671 quad->io_surface_size.width(), | 1708 quad->io_surface_size.width(), |
| 1672 quad->io_surface_size.height() * -1.0f)); | 1709 quad->io_surface_size.height() * -1.0f)); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1785 GLC(context_, | 1822 GLC(context_, |
| 1786 context_->uniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); | 1823 context_->uniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); |
| 1787 | 1824 |
| 1788 GLC(context_, context_->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); | 1825 GLC(context_, context_->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); |
| 1789 } | 1826 } |
| 1790 | 1827 |
| 1791 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame, | 1828 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame* frame, |
| 1792 int texture_id, | 1829 int texture_id, |
| 1793 gfx::Rect rect, | 1830 gfx::Rect rect, |
| 1794 const gfx::Transform& draw_matrix) { | 1831 const gfx::Transform& draw_matrix) { |
| 1795 const RenderPassProgram* program = GetRenderPassProgram(); | 1832 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1833 context_, highp_threshold_min_, rect.bottom_right()); |
| 1834 const RenderPassProgram* program = GetRenderPassProgram(texCoordPrecision); |
| 1796 | 1835 |
| 1797 GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id)); | 1836 GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id)); |
| 1798 | 1837 |
| 1799 SetUseProgram(program->program()); | 1838 SetUseProgram(program->program()); |
| 1800 GLC(Context(), | 1839 GLC(Context(), |
| 1801 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 1840 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 1802 GLC(Context(), | 1841 GLC(Context(), |
| 1803 Context()->uniform4f(program->vertex_shader().tex_transform_location(), | 1842 Context()->uniform4f(program->vertex_shader().tex_transform_location(), |
| 1804 0.0f, | 1843 0.0f, |
| 1805 0.0f, | 1844 0.0f, |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2122 bool GLRenderer::InitializeSharedObjects() { | 2161 bool GLRenderer::InitializeSharedObjects() { |
| 2123 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); | 2162 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); |
| 2124 MakeContextCurrent(); | 2163 MakeContextCurrent(); |
| 2125 | 2164 |
| 2126 // Create an FBO for doing offscreen rendering. | 2165 // Create an FBO for doing offscreen rendering. |
| 2127 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); | 2166 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); |
| 2128 | 2167 |
| 2129 // We will always need these programs to render, so create the programs | 2168 // We will always need these programs to render, so create the programs |
| 2130 // eagerly so that the shader compilation can start while we do other work. | 2169 // eagerly so that the shader compilation can start while we do other work. |
| 2131 // Other programs are created lazily on first access. | 2170 // Other programs are created lazily on first access. |
| 2132 shared_geometry_ = | 2171 shared_geometry_ = make_scoped_ptr( |
| 2133 make_scoped_ptr(new GeometryBinding(context_, QuadVertexRect())); | 2172 new GeometryBinding(context_, QuadVertexRect())); |
| 2134 render_pass_program_ = make_scoped_ptr(new RenderPassProgram(context_)); | 2173 render_pass_program_ = make_scoped_ptr( |
| 2135 tile_program_ = make_scoped_ptr(new TileProgram(context_)); | 2174 new RenderPassProgram(context_, TexCoordPrecisionMedium)); |
| 2136 tile_program_opaque_ = make_scoped_ptr(new TileProgramOpaque(context_)); | 2175 render_pass_program_highp_ = make_scoped_ptr( |
| 2176 new RenderPassProgram(context_, TexCoordPrecisionHigh)); |
| 2177 tile_program_ = make_scoped_ptr( |
| 2178 new TileProgram(context_, TexCoordPrecisionMedium)); |
| 2179 tile_program_opaque_ = make_scoped_ptr( |
| 2180 new TileProgramOpaque(context_, TexCoordPrecisionMedium)); |
| 2137 | 2181 |
| 2138 GLC(context_, context_->flush()); | 2182 GLC(context_, context_->flush()); |
| 2139 | 2183 |
| 2140 return true; | 2184 return true; |
| 2141 } | 2185 } |
| 2142 | 2186 |
| 2143 const GLRenderer::TileCheckerboardProgram* | 2187 const GLRenderer::TileCheckerboardProgram* |
| 2144 GLRenderer::GetTileCheckerboardProgram() { | 2188 GLRenderer::GetTileCheckerboardProgram() { |
| 2145 if (!tile_checkerboard_program_) { | 2189 if (!tile_checkerboard_program_) |
| 2146 tile_checkerboard_program_ = | 2190 tile_checkerboard_program_ = make_scoped_ptr( |
| 2147 make_scoped_ptr(new TileCheckerboardProgram(context_)); | 2191 new TileCheckerboardProgram(context_, TexCoordPrecisionNA)); |
| 2148 } | |
| 2149 if (!tile_checkerboard_program_->initialized()) { | 2192 if (!tile_checkerboard_program_->initialized()) { |
| 2150 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); | 2193 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); |
| 2151 tile_checkerboard_program_->Initialize(context_, is_using_bind_uniform_); | 2194 tile_checkerboard_program_->Initialize(context_, is_using_bind_uniform_); |
| 2152 } | 2195 } |
| 2153 return tile_checkerboard_program_.get(); | 2196 return tile_checkerboard_program_.get(); |
| 2154 } | 2197 } |
| 2155 | 2198 |
| 2156 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { | 2199 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { |
| 2157 if (!debug_border_program_) | 2200 if (!debug_border_program_) |
| 2158 debug_border_program_ = make_scoped_ptr(new DebugBorderProgram(context_)); | 2201 debug_border_program_ = make_scoped_ptr( |
| 2202 new DebugBorderProgram(context_, TexCoordPrecisionNA)); |
| 2159 if (!debug_border_program_->initialized()) { | 2203 if (!debug_border_program_->initialized()) { |
| 2160 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); | 2204 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); |
| 2161 debug_border_program_->Initialize(context_, is_using_bind_uniform_); | 2205 debug_border_program_->Initialize(context_, is_using_bind_uniform_); |
| 2162 } | 2206 } |
| 2163 return debug_border_program_.get(); | 2207 return debug_border_program_.get(); |
| 2164 } | 2208 } |
| 2165 | 2209 |
| 2166 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { | 2210 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { |
| 2167 if (!solid_color_program_) | 2211 if (!solid_color_program_) |
| 2168 solid_color_program_ = make_scoped_ptr(new SolidColorProgram(context_)); | 2212 solid_color_program_ = make_scoped_ptr( |
| 2213 new SolidColorProgram(context_, TexCoordPrecisionNA)); |
| 2169 if (!solid_color_program_->initialized()) { | 2214 if (!solid_color_program_->initialized()) { |
| 2170 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); | 2215 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); |
| 2171 solid_color_program_->Initialize(context_, is_using_bind_uniform_); | 2216 solid_color_program_->Initialize(context_, is_using_bind_uniform_); |
| 2172 } | 2217 } |
| 2173 return solid_color_program_.get(); | 2218 return solid_color_program_.get(); |
| 2174 } | 2219 } |
| 2175 | 2220 |
| 2176 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { | 2221 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { |
| 2177 if (!solid_color_program_aa_) { | 2222 if (!solid_color_program_aa_) { |
| 2178 solid_color_program_aa_ = | 2223 solid_color_program_aa_ = |
| 2179 make_scoped_ptr(new SolidColorProgramAA(context_)); | 2224 make_scoped_ptr(new SolidColorProgramAA(context_, TexCoordPrecisionNA)); |
| 2180 } | 2225 } |
| 2181 if (!solid_color_program_aa_->initialized()) { | 2226 if (!solid_color_program_aa_->initialized()) { |
| 2182 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); | 2227 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); |
| 2183 solid_color_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2228 solid_color_program_aa_->Initialize(context_, is_using_bind_uniform_); |
| 2184 } | 2229 } |
| 2185 return solid_color_program_aa_.get(); | 2230 return solid_color_program_aa_.get(); |
| 2186 } | 2231 } |
| 2187 | 2232 |
| 2188 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram() { | 2233 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( |
| 2189 DCHECK(render_pass_program_); | 2234 TexCoordPrecision precision) { |
| 2190 if (!render_pass_program_->initialized()) { | 2235 scoped_ptr<RenderPassProgram> &program = |
| 2236 (precision == TexCoordPrecisionHigh) ? render_pass_program_highp_ |
| 2237 : render_pass_program_; |
| 2238 DCHECK(program); |
| 2239 if (!program->initialized()) { |
| 2191 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); | 2240 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); |
| 2192 render_pass_program_->Initialize(context_, is_using_bind_uniform_); | 2241 program->Initialize(context_, is_using_bind_uniform_); |
| 2193 } | 2242 } |
| 2194 return render_pass_program_.get(); | 2243 return program.get(); |
| 2195 } | 2244 } |
| 2196 | 2245 |
| 2197 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA() { | 2246 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( |
| 2198 if (!render_pass_program_aa_) | 2247 TexCoordPrecision precision) { |
| 2199 render_pass_program_aa_ = | 2248 scoped_ptr<RenderPassProgramAA> &program = |
| 2200 make_scoped_ptr(new RenderPassProgramAA(context_)); | 2249 (precision == TexCoordPrecisionHigh) ? render_pass_program_aa_highp_ |
| 2201 if (!render_pass_program_aa_->initialized()) { | 2250 : render_pass_program_aa_; |
| 2251 if (!program) |
| 2252 program = |
| 2253 make_scoped_ptr(new RenderPassProgramAA(context_, precision)); |
| 2254 if (!program->initialized()) { |
| 2202 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); | 2255 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); |
| 2203 render_pass_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2256 program->Initialize(context_, is_using_bind_uniform_); |
| 2204 } | 2257 } |
| 2205 return render_pass_program_aa_.get(); | 2258 return program.get(); |
| 2206 } | 2259 } |
| 2207 | 2260 |
| 2208 const GLRenderer::RenderPassMaskProgram* | 2261 const GLRenderer::RenderPassMaskProgram* |
| 2209 GLRenderer::GetRenderPassMaskProgram() { | 2262 GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { |
| 2210 if (!render_pass_mask_program_) | 2263 scoped_ptr<RenderPassMaskProgram> &program = |
| 2211 render_pass_mask_program_ = | 2264 (precision == TexCoordPrecisionHigh) ? render_pass_mask_program_highp_ |
| 2212 make_scoped_ptr(new RenderPassMaskProgram(context_)); | 2265 : render_pass_mask_program_; |
| 2213 if (!render_pass_mask_program_->initialized()) { | 2266 if (!program) |
| 2267 program = make_scoped_ptr(new RenderPassMaskProgram(context_, precision)); |
| 2268 if (!program->initialized()) { |
| 2214 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); | 2269 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); |
| 2215 render_pass_mask_program_->Initialize(context_, is_using_bind_uniform_); | 2270 program->Initialize(context_, is_using_bind_uniform_); |
| 2216 } | 2271 } |
| 2217 return render_pass_mask_program_.get(); | 2272 return program.get(); |
| 2218 } | 2273 } |
| 2219 | 2274 |
| 2220 const GLRenderer::RenderPassMaskProgramAA* | 2275 const GLRenderer::RenderPassMaskProgramAA* |
| 2221 GLRenderer::GetRenderPassMaskProgramAA() { | 2276 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { |
| 2222 if (!render_pass_mask_program_aa_) | 2277 scoped_ptr<RenderPassMaskProgramAA> &program = |
| 2223 render_pass_mask_program_aa_ = | 2278 (precision == TexCoordPrecisionHigh) ? render_pass_mask_program_aa_highp_ |
| 2224 make_scoped_ptr(new RenderPassMaskProgramAA(context_)); | 2279 : render_pass_mask_program_aa_; |
| 2225 if (!render_pass_mask_program_aa_->initialized()) { | 2280 if (!program) |
| 2281 program = |
| 2282 make_scoped_ptr(new RenderPassMaskProgramAA(context_, precision)); |
| 2283 if (!program->initialized()) { |
| 2226 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); | 2284 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); |
| 2227 render_pass_mask_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2285 program->Initialize(context_, is_using_bind_uniform_); |
| 2228 } | 2286 } |
| 2229 return render_pass_mask_program_aa_.get(); | 2287 return program.get(); |
| 2230 } | 2288 } |
| 2231 | 2289 |
| 2232 const GLRenderer::RenderPassColorMatrixProgram* | 2290 const GLRenderer::RenderPassColorMatrixProgram* |
| 2233 GLRenderer::GetRenderPassColorMatrixProgram() { | 2291 GLRenderer::GetRenderPassColorMatrixProgram(TexCoordPrecision precision) { |
| 2234 if (!render_pass_color_matrix_program_) | 2292 scoped_ptr<RenderPassColorMatrixProgram> &program = |
| 2235 render_pass_color_matrix_program_ = | 2293 (precision == TexCoordPrecisionHigh) ? |
| 2236 make_scoped_ptr(new RenderPassColorMatrixProgram(context_)); | 2294 render_pass_color_matrix_program_highp_ : |
| 2237 if (!render_pass_color_matrix_program_->initialized()) { | 2295 render_pass_color_matrix_program_; |
| 2296 if (!program) |
| 2297 program = make_scoped_ptr( |
| 2298 new RenderPassColorMatrixProgram(context_, precision)); |
| 2299 if (!program->initialized()) { |
| 2238 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); | 2300 TRACE_EVENT0("cc", "GLRenderer::renderPassColorMatrixProgram::initialize"); |
| 2239 render_pass_color_matrix_program_->Initialize(context_, | 2301 program->Initialize(context_, is_using_bind_uniform_); |
| 2240 is_using_bind_uniform_); | |
| 2241 } | 2302 } |
| 2242 return render_pass_color_matrix_program_.get(); | 2303 return program.get(); |
| 2243 } | 2304 } |
| 2244 | 2305 |
| 2245 const GLRenderer::RenderPassColorMatrixProgramAA* | 2306 const GLRenderer::RenderPassColorMatrixProgramAA* |
| 2246 GLRenderer::GetRenderPassColorMatrixProgramAA() { | 2307 GLRenderer::GetRenderPassColorMatrixProgramAA(TexCoordPrecision precision) { |
| 2247 if (!render_pass_color_matrix_program_aa_) | 2308 scoped_ptr<RenderPassColorMatrixProgramAA> &program = |
| 2248 render_pass_color_matrix_program_aa_ = | 2309 (precision == TexCoordPrecisionHigh) ? |
| 2249 make_scoped_ptr(new RenderPassColorMatrixProgramAA(context_)); | 2310 render_pass_color_matrix_program_aa_highp_ : |
| 2250 if (!render_pass_color_matrix_program_aa_->initialized()) { | 2311 render_pass_color_matrix_program_aa_; |
| 2312 if (!program) |
| 2313 program = make_scoped_ptr( |
| 2314 new RenderPassColorMatrixProgramAA(context_, precision)); |
| 2315 if (!program->initialized()) { |
| 2251 TRACE_EVENT0("cc", | 2316 TRACE_EVENT0("cc", |
| 2252 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); | 2317 "GLRenderer::renderPassColorMatrixProgramAA::initialize"); |
| 2253 render_pass_color_matrix_program_aa_->Initialize(context_, | 2318 program->Initialize(context_, is_using_bind_uniform_); |
| 2254 is_using_bind_uniform_); | |
| 2255 } | 2319 } |
| 2256 return render_pass_color_matrix_program_aa_.get(); | 2320 return program.get(); |
| 2257 } | 2321 } |
| 2258 | 2322 |
| 2259 const GLRenderer::RenderPassMaskColorMatrixProgram* | 2323 const GLRenderer::RenderPassMaskColorMatrixProgram* |
| 2260 GLRenderer::GetRenderPassMaskColorMatrixProgram() { | 2324 GLRenderer::GetRenderPassMaskColorMatrixProgram(TexCoordPrecision precision) { |
| 2261 if (!render_pass_mask_color_matrix_program_) | 2325 scoped_ptr<RenderPassMaskColorMatrixProgram> &program = |
| 2262 render_pass_mask_color_matrix_program_ = | 2326 (precision == TexCoordPrecisionHigh) ? |
| 2263 make_scoped_ptr(new RenderPassMaskColorMatrixProgram(context_)); | 2327 render_pass_mask_color_matrix_program_highp_ : |
| 2264 if (!render_pass_mask_color_matrix_program_->initialized()) { | 2328 render_pass_mask_color_matrix_program_; |
| 2329 if (!program) |
| 2330 program = make_scoped_ptr( |
| 2331 new RenderPassMaskColorMatrixProgram(context_, precision)); |
| 2332 if (!program->initialized()) { |
| 2265 TRACE_EVENT0("cc", | 2333 TRACE_EVENT0("cc", |
| 2266 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); | 2334 "GLRenderer::renderPassMaskColorMatrixProgram::initialize"); |
| 2267 render_pass_mask_color_matrix_program_->Initialize(context_, | 2335 program->Initialize(context_, is_using_bind_uniform_); |
| 2268 is_using_bind_uniform_); | |
| 2269 } | 2336 } |
| 2270 return render_pass_mask_color_matrix_program_.get(); | 2337 return program.get(); |
| 2271 } | 2338 } |
| 2272 | 2339 |
| 2273 const GLRenderer::RenderPassMaskColorMatrixProgramAA* | 2340 const GLRenderer::RenderPassMaskColorMatrixProgramAA* |
| 2274 GLRenderer::GetRenderPassMaskColorMatrixProgramAA() { | 2341 GLRenderer::GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision) { |
| 2275 if (!render_pass_mask_color_matrix_program_aa_) | 2342 scoped_ptr<RenderPassMaskColorMatrixProgramAA> &program = |
| 2276 render_pass_mask_color_matrix_program_aa_ = | 2343 (precision == TexCoordPrecisionHigh) ? |
| 2277 make_scoped_ptr(new RenderPassMaskColorMatrixProgramAA(context_)); | 2344 render_pass_mask_color_matrix_program_aa_highp_ : |
| 2278 if (!render_pass_mask_color_matrix_program_aa_->initialized()) { | 2345 render_pass_mask_color_matrix_program_aa_; |
| 2346 if (!program) |
| 2347 program = make_scoped_ptr( |
| 2348 new RenderPassMaskColorMatrixProgramAA(context_, precision)); |
| 2349 if (!program->initialized()) { |
| 2279 TRACE_EVENT0("cc", | 2350 TRACE_EVENT0("cc", |
| 2280 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); | 2351 "GLRenderer::renderPassMaskColorMatrixProgramAA::initialize"); |
| 2281 render_pass_mask_color_matrix_program_aa_->Initialize( | 2352 program->Initialize(context_, is_using_bind_uniform_); |
| 2282 context_, is_using_bind_uniform_); | |
| 2283 } | 2353 } |
| 2284 return render_pass_mask_color_matrix_program_aa_.get(); | 2354 return program.get(); |
| 2285 } | 2355 } |
| 2286 | 2356 |
| 2287 const GLRenderer::TileProgram* GLRenderer::GetTileProgram() { | 2357 const GLRenderer::TileProgram* GLRenderer::GetTileProgram() { |
| 2288 DCHECK(tile_program_); | 2358 DCHECK(tile_program_); |
| 2289 if (!tile_program_->initialized()) { | 2359 if (!tile_program_->initialized()) { |
| 2290 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); | 2360 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); |
| 2291 tile_program_->Initialize(context_, is_using_bind_uniform_); | 2361 tile_program_->Initialize(context_, is_using_bind_uniform_); |
| 2292 } | 2362 } |
| 2293 return tile_program_.get(); | 2363 return tile_program_.get(); |
| 2294 } | 2364 } |
| 2295 | 2365 |
| 2296 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque() { | 2366 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque() { |
| 2297 DCHECK(tile_program_opaque_); | 2367 DCHECK(tile_program_opaque_); |
| 2298 if (!tile_program_opaque_->initialized()) { | 2368 if (!tile_program_opaque_->initialized()) { |
| 2299 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); | 2369 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); |
| 2300 tile_program_opaque_->Initialize(context_, is_using_bind_uniform_); | 2370 tile_program_opaque_->Initialize(context_, is_using_bind_uniform_); |
| 2301 } | 2371 } |
| 2302 return tile_program_opaque_.get(); | 2372 return tile_program_opaque_.get(); |
| 2303 } | 2373 } |
| 2304 | 2374 |
| 2305 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA() { | 2375 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA() { |
| 2306 if (!tile_program_aa_) | 2376 if (!tile_program_aa_) |
| 2307 tile_program_aa_ = make_scoped_ptr(new TileProgramAA(context_)); | 2377 tile_program_aa_ = make_scoped_ptr( |
| 2378 new TileProgramAA(context_, TexCoordPrecisionMedium)); |
| 2308 if (!tile_program_aa_->initialized()) { | 2379 if (!tile_program_aa_->initialized()) { |
| 2309 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); | 2380 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); |
| 2310 tile_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2381 tile_program_aa_->Initialize(context_, is_using_bind_uniform_); |
| 2311 } | 2382 } |
| 2312 return tile_program_aa_.get(); | 2383 return tile_program_aa_.get(); |
| 2313 } | 2384 } |
| 2314 | 2385 |
| 2315 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle() { | 2386 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle() { |
| 2316 if (!tile_program_swizzle_) | 2387 if (!tile_program_swizzle_) |
| 2317 tile_program_swizzle_ = make_scoped_ptr(new TileProgramSwizzle(context_)); | 2388 tile_program_swizzle_ = make_scoped_ptr( |
| 2389 new TileProgramSwizzle(context_, TexCoordPrecisionMedium)); |
| 2318 if (!tile_program_swizzle_->initialized()) { | 2390 if (!tile_program_swizzle_->initialized()) { |
| 2319 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); | 2391 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); |
| 2320 tile_program_swizzle_->Initialize(context_, is_using_bind_uniform_); | 2392 tile_program_swizzle_->Initialize(context_, is_using_bind_uniform_); |
| 2321 } | 2393 } |
| 2322 return tile_program_swizzle_.get(); | 2394 return tile_program_swizzle_.get(); |
| 2323 } | 2395 } |
| 2324 | 2396 |
| 2325 const GLRenderer::TileProgramSwizzleOpaque* | 2397 const GLRenderer::TileProgramSwizzleOpaque* |
| 2326 GLRenderer::GetTileProgramSwizzleOpaque() { | 2398 GLRenderer::GetTileProgramSwizzleOpaque() { |
| 2327 if (!tile_program_swizzle_opaque_) | 2399 if (!tile_program_swizzle_opaque_) |
| 2328 tile_program_swizzle_opaque_ = | 2400 tile_program_swizzle_opaque_ = make_scoped_ptr( |
| 2329 make_scoped_ptr(new TileProgramSwizzleOpaque(context_)); | 2401 new TileProgramSwizzleOpaque(context_, TexCoordPrecisionMedium)); |
| 2330 if (!tile_program_swizzle_opaque_->initialized()) { | 2402 if (!tile_program_swizzle_opaque_->initialized()) { |
| 2331 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); | 2403 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); |
| 2332 tile_program_swizzle_opaque_->Initialize(context_, is_using_bind_uniform_); | 2404 tile_program_swizzle_opaque_->Initialize(context_, is_using_bind_uniform_); |
| 2333 } | 2405 } |
| 2334 return tile_program_swizzle_opaque_.get(); | 2406 return tile_program_swizzle_opaque_.get(); |
| 2335 } | 2407 } |
| 2336 | 2408 |
| 2337 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA() { | 2409 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA() { |
| 2338 if (!tile_program_swizzle_aa_) | 2410 if (!tile_program_swizzle_aa_) |
| 2339 tile_program_swizzle_aa_ = | 2411 tile_program_swizzle_aa_ = make_scoped_ptr( |
| 2340 make_scoped_ptr(new TileProgramSwizzleAA(context_)); | 2412 new TileProgramSwizzleAA(context_, TexCoordPrecisionMedium)); |
| 2341 if (!tile_program_swizzle_aa_->initialized()) { | 2413 if (!tile_program_swizzle_aa_->initialized()) { |
| 2342 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); | 2414 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); |
| 2343 tile_program_swizzle_aa_->Initialize(context_, is_using_bind_uniform_); | 2415 tile_program_swizzle_aa_->Initialize(context_, is_using_bind_uniform_); |
| 2344 } | 2416 } |
| 2345 return tile_program_swizzle_aa_.get(); | 2417 return tile_program_swizzle_aa_.get(); |
| 2346 } | 2418 } |
| 2347 | 2419 |
| 2348 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram() { | 2420 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( |
| 2349 if (!texture_program_) | 2421 TexCoordPrecision precision) { |
| 2350 texture_program_ = make_scoped_ptr(new TextureProgram(context_)); | 2422 scoped_ptr<TextureProgram> &program = |
| 2351 if (!texture_program_->initialized()) { | 2423 (precision == TexCoordPrecisionHigh) ? texture_program_highp_ |
| 2424 : texture_program_; |
| 2425 if (!program) |
| 2426 program = make_scoped_ptr(new TextureProgram(context_, precision)); |
| 2427 if (!program->initialized()) { |
| 2352 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 2428 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
| 2353 texture_program_->Initialize(context_, is_using_bind_uniform_); | 2429 program->Initialize(context_, is_using_bind_uniform_); |
| 2354 } | 2430 } |
| 2355 return texture_program_.get(); | 2431 return program.get(); |
| 2356 } | 2432 } |
| 2357 | 2433 |
| 2358 const GLRenderer::TextureProgramFlip* GLRenderer::GetTextureProgramFlip() { | 2434 const GLRenderer::TextureProgramFlip* GLRenderer::GetTextureProgramFlip( |
| 2359 if (!texture_program_flip_) | 2435 TexCoordPrecision precision) { |
| 2360 texture_program_flip_ = make_scoped_ptr(new TextureProgramFlip(context_)); | 2436 scoped_ptr<TextureProgramFlip> &program = |
| 2361 if (!texture_program_flip_->initialized()) { | 2437 (precision == TexCoordPrecisionHigh) ? texture_program_flip_highp_ |
| 2438 : texture_program_flip_; |
| 2439 if (!program) |
| 2440 program = make_scoped_ptr(new TextureProgramFlip(context_, precision)); |
| 2441 if (!program->initialized()) { |
| 2362 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); | 2442 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); |
| 2363 texture_program_flip_->Initialize(context_, is_using_bind_uniform_); | 2443 program->Initialize(context_, is_using_bind_uniform_); |
| 2364 } | 2444 } |
| 2365 return texture_program_flip_.get(); | 2445 return program.get(); |
| 2366 } | 2446 } |
| 2367 | 2447 |
| 2368 const GLRenderer::TextureIOSurfaceProgram* | 2448 const GLRenderer::TextureIOSurfaceProgram* |
| 2369 GLRenderer::GetTextureIOSurfaceProgram() { | 2449 GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { |
| 2370 if (!texture_io_surface_program_) | 2450 scoped_ptr<TextureIOSurfaceProgram> &program = |
| 2371 texture_io_surface_program_ = | 2451 (precision == TexCoordPrecisionHigh) ? texture_io_surface_program_highp_ |
| 2372 make_scoped_ptr(new TextureIOSurfaceProgram(context_)); | 2452 : texture_io_surface_program_; |
| 2373 if (!texture_io_surface_program_->initialized()) { | 2453 if (!program) |
| 2454 program = |
| 2455 make_scoped_ptr(new TextureIOSurfaceProgram(context_, precision)); |
| 2456 if (!program->initialized()) { |
| 2374 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); | 2457 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); |
| 2375 texture_io_surface_program_->Initialize(context_, is_using_bind_uniform_); | 2458 program->Initialize(context_, is_using_bind_uniform_); |
| 2376 } | 2459 } |
| 2377 return texture_io_surface_program_.get(); | 2460 return program.get(); |
| 2378 } | 2461 } |
| 2379 | 2462 |
| 2380 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram() { | 2463 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( |
| 2381 if (!video_yuv_program_) | 2464 TexCoordPrecision precision) { |
| 2382 video_yuv_program_ = make_scoped_ptr(new VideoYUVProgram(context_)); | 2465 scoped_ptr<VideoYUVProgram> &program = |
| 2383 if (!video_yuv_program_->initialized()) { | 2466 (precision == TexCoordPrecisionHigh) ? video_yuv_program_highp_ |
| 2467 : video_yuv_program_; |
| 2468 if (!program) |
| 2469 program = make_scoped_ptr(new VideoYUVProgram(context_, precision)); |
| 2470 if (!program->initialized()) { |
| 2384 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | 2471 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); |
| 2385 video_yuv_program_->Initialize(context_, is_using_bind_uniform_); | 2472 program->Initialize(context_, is_using_bind_uniform_); |
| 2386 } | 2473 } |
| 2387 return video_yuv_program_.get(); | 2474 return program.get(); |
| 2388 } | 2475 } |
| 2389 | 2476 |
| 2390 const GLRenderer::VideoStreamTextureProgram* | 2477 const GLRenderer::VideoStreamTextureProgram* |
| 2391 GLRenderer::GetVideoStreamTextureProgram() { | 2478 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { |
| 2392 if (!Capabilities().using_egl_image) | 2479 if (!Capabilities().using_egl_image) |
| 2393 return NULL; | 2480 return NULL; |
| 2394 if (!video_stream_texture_program_) | 2481 scoped_ptr<VideoStreamTextureProgram> &program = |
| 2395 video_stream_texture_program_ = | 2482 (precision == TexCoordPrecisionHigh) ? video_stream_texture_program_highp_ |
| 2396 make_scoped_ptr(new VideoStreamTextureProgram(context_)); | 2483 : video_stream_texture_program_; |
| 2397 if (!video_stream_texture_program_->initialized()) { | 2484 if (!program) |
| 2485 program = |
| 2486 make_scoped_ptr(new VideoStreamTextureProgram(context_, precision)); |
| 2487 if (!program->initialized()) { |
| 2398 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); | 2488 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); |
| 2399 video_stream_texture_program_->Initialize(context_, is_using_bind_uniform_); | 2489 program->Initialize(context_, is_using_bind_uniform_); |
| 2400 } | 2490 } |
| 2401 return video_stream_texture_program_.get(); | 2491 return program.get(); |
| 2402 } | 2492 } |
| 2403 | 2493 |
| 2404 void GLRenderer::CleanupSharedObjects() { | 2494 void GLRenderer::CleanupSharedObjects() { |
| 2405 MakeContextCurrent(); | 2495 MakeContextCurrent(); |
| 2406 | 2496 |
| 2407 shared_geometry_.reset(); | 2497 shared_geometry_.reset(); |
| 2408 | 2498 |
| 2409 if (tile_program_) | 2499 if (tile_program_) |
| 2410 tile_program_->Cleanup(context_); | 2500 tile_program_->Cleanup(context_); |
| 2411 if (tile_program_opaque_) | 2501 if (tile_program_opaque_) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2431 render_pass_program_aa_->Cleanup(context_); | 2521 render_pass_program_aa_->Cleanup(context_); |
| 2432 if (render_pass_color_matrix_program_) | 2522 if (render_pass_color_matrix_program_) |
| 2433 render_pass_color_matrix_program_->Cleanup(context_); | 2523 render_pass_color_matrix_program_->Cleanup(context_); |
| 2434 if (render_pass_mask_color_matrix_program_aa_) | 2524 if (render_pass_mask_color_matrix_program_aa_) |
| 2435 render_pass_mask_color_matrix_program_aa_->Cleanup(context_); | 2525 render_pass_mask_color_matrix_program_aa_->Cleanup(context_); |
| 2436 if (render_pass_color_matrix_program_aa_) | 2526 if (render_pass_color_matrix_program_aa_) |
| 2437 render_pass_color_matrix_program_aa_->Cleanup(context_); | 2527 render_pass_color_matrix_program_aa_->Cleanup(context_); |
| 2438 if (render_pass_mask_color_matrix_program_) | 2528 if (render_pass_mask_color_matrix_program_) |
| 2439 render_pass_mask_color_matrix_program_->Cleanup(context_); | 2529 render_pass_mask_color_matrix_program_->Cleanup(context_); |
| 2440 | 2530 |
| 2531 if (render_pass_mask_program_highp_) |
| 2532 render_pass_mask_program_highp_->Cleanup(context_); |
| 2533 if (render_pass_program_highp_) |
| 2534 render_pass_program_highp_->Cleanup(context_); |
| 2535 if (render_pass_mask_program_aa_highp_) |
| 2536 render_pass_mask_program_aa_highp_->Cleanup(context_); |
| 2537 if (render_pass_program_aa_highp_) |
| 2538 render_pass_program_aa_highp_->Cleanup(context_); |
| 2539 if (render_pass_color_matrix_program_highp_) |
| 2540 render_pass_color_matrix_program_highp_->Cleanup(context_); |
| 2541 if (render_pass_mask_color_matrix_program_aa_highp_) |
| 2542 render_pass_mask_color_matrix_program_aa_highp_->Cleanup(context_); |
| 2543 if (render_pass_color_matrix_program_aa_highp_) |
| 2544 render_pass_color_matrix_program_aa_highp_->Cleanup(context_); |
| 2545 if (render_pass_mask_color_matrix_program_highp_) |
| 2546 render_pass_mask_color_matrix_program_highp_->Cleanup(context_); |
| 2547 |
| 2441 if (texture_program_) | 2548 if (texture_program_) |
| 2442 texture_program_->Cleanup(context_); | 2549 texture_program_->Cleanup(context_); |
| 2443 if (texture_program_flip_) | 2550 if (texture_program_flip_) |
| 2444 texture_program_flip_->Cleanup(context_); | 2551 texture_program_flip_->Cleanup(context_); |
| 2445 if (texture_io_surface_program_) | 2552 if (texture_io_surface_program_) |
| 2446 texture_io_surface_program_->Cleanup(context_); | 2553 texture_io_surface_program_->Cleanup(context_); |
| 2447 | 2554 |
| 2555 if (texture_program_highp_) |
| 2556 texture_program_highp_->Cleanup(context_); |
| 2557 if (texture_program_flip_highp_) |
| 2558 texture_program_flip_highp_->Cleanup(context_); |
| 2559 if (texture_io_surface_program_highp_) |
| 2560 texture_io_surface_program_highp_->Cleanup(context_); |
| 2561 |
| 2448 if (video_yuv_program_) | 2562 if (video_yuv_program_) |
| 2449 video_yuv_program_->Cleanup(context_); | 2563 video_yuv_program_->Cleanup(context_); |
| 2450 if (video_stream_texture_program_) | 2564 if (video_stream_texture_program_) |
| 2451 video_stream_texture_program_->Cleanup(context_); | 2565 video_stream_texture_program_->Cleanup(context_); |
| 2452 | 2566 |
| 2567 if (video_yuv_program_highp_) |
| 2568 video_yuv_program_highp_->Cleanup(context_); |
| 2569 if (video_stream_texture_program_highp_) |
| 2570 video_stream_texture_program_highp_->Cleanup(context_); |
| 2571 |
| 2453 if (debug_border_program_) | 2572 if (debug_border_program_) |
| 2454 debug_border_program_->Cleanup(context_); | 2573 debug_border_program_->Cleanup(context_); |
| 2455 if (solid_color_program_) | 2574 if (solid_color_program_) |
| 2456 solid_color_program_->Cleanup(context_); | 2575 solid_color_program_->Cleanup(context_); |
| 2457 if (solid_color_program_aa_) | 2576 if (solid_color_program_aa_) |
| 2458 solid_color_program_aa_->Cleanup(context_); | 2577 solid_color_program_aa_->Cleanup(context_); |
| 2459 | 2578 |
| 2460 if (offscreen_framebuffer_id_) | 2579 if (offscreen_framebuffer_id_) |
| 2461 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2580 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
| 2462 | 2581 |
| 2463 if (on_demand_tile_raster_resource_id_) | 2582 if (on_demand_tile_raster_resource_id_) |
| 2464 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); | 2583 resource_provider_->DeleteResource(on_demand_tile_raster_resource_id_); |
| 2465 | 2584 |
| 2466 ReleaseRenderPassTextures(); | 2585 ReleaseRenderPassTextures(); |
| 2467 } | 2586 } |
| 2468 | 2587 |
| 2469 bool GLRenderer::IsContextLost() { | 2588 bool GLRenderer::IsContextLost() { |
| 2470 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2589 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2471 } | 2590 } |
| 2472 | 2591 |
| 2473 } // namespace cc | 2592 } // namespace cc |
| OLD | NEW |