| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 GrTexture* texture = | 710 GrTexture* texture = |
| 711 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); | 711 reinterpret_cast<GrTexture*>(filter_bitmap.getTexture()); |
| 712 Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); | 712 Context()->bindTexture(GL_TEXTURE_2D, texture->getTextureHandle()); |
| 713 } else | 713 } else |
| 714 contents_resource_lock = make_scoped_ptr( | 714 contents_resource_lock = make_scoped_ptr( |
| 715 new ResourceProvider::ScopedSamplerGL(resource_provider_, | 715 new ResourceProvider::ScopedSamplerGL(resource_provider_, |
| 716 contents_texture->id(), | 716 contents_texture->id(), |
| 717 GL_TEXTURE_2D, | 717 GL_TEXTURE_2D, |
| 718 GL_LINEAR)); | 718 GL_LINEAR)); |
| 719 | 719 |
| 720 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 721 context_, quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 722 |
| 720 int shader_quad_location = -1; | 723 int shader_quad_location = -1; |
| 721 int shader_edge_location = -1; | 724 int shader_edge_location = -1; |
| 722 int shader_mask_sampler_location = -1; | 725 int shader_mask_sampler_location = -1; |
| 723 int shader_mask_tex_coord_scale_location = -1; | 726 int shader_mask_tex_coord_scale_location = -1; |
| 724 int shader_mask_tex_coord_offset_location = -1; | 727 int shader_mask_tex_coord_offset_location = -1; |
| 725 int shader_matrix_location = -1; | 728 int shader_matrix_location = -1; |
| 726 int shader_alpha_location = -1; | 729 int shader_alpha_location = -1; |
| 727 int shader_tex_transform_location = -1; | 730 int shader_tex_transform_location = -1; |
| 728 int shader_tex_scale_location = -1; | 731 int shader_tex_scale_location = -1; |
| 729 | 732 |
| 730 if (use_aa && mask_texture_id) { | 733 if (use_aa && mask_texture_id) { |
| 731 const RenderPassMaskProgramAA* program = GetRenderPassMaskProgramAA(); | 734 const RenderPassMaskProgramAA* program = |
| 735 GetRenderPassMaskProgramAA(texCoordPrecision); |
| 732 SetUseProgram(program->program()); | 736 SetUseProgram(program->program()); |
| 733 GLC(Context(), | 737 GLC(Context(), |
| 734 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 738 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 735 | 739 |
| 736 shader_quad_location = program->vertex_shader().point_location(); | 740 shader_quad_location = program->vertex_shader().point_location(); |
| 737 shader_edge_location = program->fragment_shader().edge_location(); | 741 shader_edge_location = program->fragment_shader().edge_location(); |
| 738 shader_mask_sampler_location = | 742 shader_mask_sampler_location = |
| 739 program->fragment_shader().mask_sampler_location(); | 743 program->fragment_shader().mask_sampler_location(); |
| 740 shader_mask_tex_coord_scale_location = | 744 shader_mask_tex_coord_scale_location = |
| 741 program->fragment_shader().mask_tex_coord_scale_location(); | 745 program->fragment_shader().mask_tex_coord_scale_location(); |
| 742 shader_mask_tex_coord_offset_location = | 746 shader_mask_tex_coord_offset_location = |
| 743 program->fragment_shader().mask_tex_coord_offset_location(); | 747 program->fragment_shader().mask_tex_coord_offset_location(); |
| 744 shader_matrix_location = program->vertex_shader().matrix_location(); | 748 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 745 shader_alpha_location = program->fragment_shader().alpha_location(); | 749 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 746 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); | 750 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 747 } else if (!use_aa && mask_texture_id) { | 751 } else if (!use_aa && mask_texture_id) { |
| 748 const RenderPassMaskProgram* program = GetRenderPassMaskProgram(); | 752 const RenderPassMaskProgram* program = |
| 753 GetRenderPassMaskProgram(texCoordPrecision); |
| 749 SetUseProgram(program->program()); | 754 SetUseProgram(program->program()); |
| 750 GLC(Context(), | 755 GLC(Context(), |
| 751 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 756 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 752 | 757 |
| 753 shader_mask_sampler_location = | 758 shader_mask_sampler_location = |
| 754 program->fragment_shader().mask_sampler_location(); | 759 program->fragment_shader().mask_sampler_location(); |
| 755 shader_mask_tex_coord_scale_location = | 760 shader_mask_tex_coord_scale_location = |
| 756 program->fragment_shader().mask_tex_coord_scale_location(); | 761 program->fragment_shader().mask_tex_coord_scale_location(); |
| 757 shader_mask_tex_coord_offset_location = | 762 shader_mask_tex_coord_offset_location = |
| 758 program->fragment_shader().mask_tex_coord_offset_location(); | 763 program->fragment_shader().mask_tex_coord_offset_location(); |
| 759 shader_matrix_location = program->vertex_shader().matrix_location(); | 764 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 760 shader_alpha_location = program->fragment_shader().alpha_location(); | 765 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 761 shader_tex_transform_location = | 766 shader_tex_transform_location = |
| 762 program->vertex_shader().tex_transform_location(); | 767 program->vertex_shader().tex_transform_location(); |
| 763 } else if (use_aa && !mask_texture_id) { | 768 } else if (use_aa && !mask_texture_id) { |
| 764 const RenderPassProgramAA* program = GetRenderPassProgramAA(); | 769 const RenderPassProgramAA* program = |
| 770 GetRenderPassProgramAA(texCoordPrecision); |
| 765 SetUseProgram(program->program()); | 771 SetUseProgram(program->program()); |
| 766 GLC(Context(), | 772 GLC(Context(), |
| 767 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 773 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 768 | 774 |
| 769 shader_quad_location = program->vertex_shader().point_location(); | 775 shader_quad_location = program->vertex_shader().point_location(); |
| 770 shader_edge_location = program->fragment_shader().edge_location(); | 776 shader_edge_location = program->fragment_shader().edge_location(); |
| 771 shader_matrix_location = program->vertex_shader().matrix_location(); | 777 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 772 shader_alpha_location = program->fragment_shader().alpha_location(); | 778 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 773 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); | 779 shader_tex_scale_location = program->vertex_shader().tex_scale_location(); |
| 774 } else { | 780 } else { |
| 775 const RenderPassProgram* program = GetRenderPassProgram(); | 781 const RenderPassProgram* program = |
| 782 GetRenderPassProgram(texCoordPrecision); |
| 776 SetUseProgram(program->program()); | 783 SetUseProgram(program->program()); |
| 777 GLC(Context(), | 784 GLC(Context(), |
| 778 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 785 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 779 | 786 |
| 780 shader_matrix_location = program->vertex_shader().matrix_location(); | 787 shader_matrix_location = program->vertex_shader().matrix_location(); |
| 781 shader_alpha_location = program->fragment_shader().alpha_location(); | 788 shader_alpha_location = program->fragment_shader().alpha_location(); |
| 782 shader_tex_transform_location = | 789 shader_tex_transform_location = |
| 783 program->vertex_shader().tex_transform_location(); | 790 program->vertex_shader().tex_transform_location(); |
| 784 } | 791 } |
| 785 | 792 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 clamp_geom_rect.Inset(geom_clamp_x, geom_clamp_y, geom_clamp_x, geom_clamp_y); | 1080 clamp_geom_rect.Inset(geom_clamp_x, geom_clamp_y, geom_clamp_x, geom_clamp_y); |
| 1074 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y); | 1081 clamp_tex_rect.Inset(tex_clamp_x, tex_clamp_y, tex_clamp_x, tex_clamp_y); |
| 1075 | 1082 |
| 1076 // Map clamping rectangle to unit square. | 1083 // Map clamping rectangle to unit square. |
| 1077 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); | 1084 float vertex_tex_translate_x = -clamp_geom_rect.x() / clamp_geom_rect.width(); |
| 1078 float vertex_tex_translate_y = | 1085 float vertex_tex_translate_y = |
| 1079 -clamp_geom_rect.y() / clamp_geom_rect.height(); | 1086 -clamp_geom_rect.y() / clamp_geom_rect.height(); |
| 1080 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); | 1087 float vertex_tex_scale_x = tile_rect.width() / clamp_geom_rect.width(); |
| 1081 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); | 1088 float vertex_tex_scale_y = tile_rect.height() / clamp_geom_rect.height(); |
| 1082 | 1089 |
| 1090 // We assume we do not need highp texture coordinates for tiles. |
| 1091 // Make sure that assumption is correct here. |
| 1092 DCHECK_LE(quad->texture_size.width(), TexCoordHighpThreshold(context_)); |
| 1093 DCHECK_LE(quad->texture_size.height(), TexCoordHighpThreshold(context_)); |
| 1094 |
| 1083 // Map to normalized texture coordinates. | 1095 // Map to normalized texture coordinates. |
| 1084 gfx::Size texture_size = quad->texture_size; | 1096 gfx::Size texture_size = quad->texture_size; |
| 1085 float fragment_tex_translate_x = clamp_tex_rect.x() / texture_size.width(); | 1097 float fragment_tex_translate_x = clamp_tex_rect.x() / texture_size.width(); |
| 1086 float fragment_tex_translate_y = clamp_tex_rect.y() / texture_size.height(); | 1098 float fragment_tex_translate_y = clamp_tex_rect.y() / texture_size.height(); |
| 1087 float fragment_tex_scale_x = clamp_tex_rect.width() / texture_size.width(); | 1099 float fragment_tex_scale_x = clamp_tex_rect.width() / texture_size.width(); |
| 1088 float fragment_tex_scale_y = clamp_tex_rect.height() / texture_size.height(); | 1100 float fragment_tex_scale_y = clamp_tex_rect.height() / texture_size.height(); |
| 1089 | 1101 |
| 1090 gfx::Transform device_transform = | 1102 gfx::Transform device_transform = |
| 1091 frame.window_matrix * frame.projection_matrix * quad->quadTransform(); | 1103 frame.window_matrix * frame.projection_matrix * quad->quadTransform(); |
| 1092 device_transform.FlattenTo2d(); | 1104 device_transform.FlattenTo2d(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), | 1193 gfx::PointF(-0.5f * tile_rect.width(), -0.5f * tile_rect.height()), |
| 1182 tile_rect.size()); | 1194 tile_rect.size()); |
| 1183 DrawQuadGeometry( | 1195 DrawQuadGeometry( |
| 1184 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); | 1196 frame, quad->quadTransform(), centered_rect, uniforms.matrix_location); |
| 1185 } | 1197 } |
| 1186 | 1198 |
| 1187 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame& frame, | 1199 void GLRenderer::DrawYUVVideoQuad(const DrawingFrame& frame, |
| 1188 const YUVVideoDrawQuad* quad) { | 1200 const YUVVideoDrawQuad* quad) { |
| 1189 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1201 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1190 | 1202 |
| 1191 const VideoYUVProgram* program = GetVideoYUVProgram(); | 1203 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1204 context_, quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1205 |
| 1206 const VideoYUVProgram* program = GetVideoYUVProgram(texCoordPrecision); |
| 1192 DCHECK(program && (program->initialized() || IsContextLost())); | 1207 DCHECK(program && (program->initialized() || IsContextLost())); |
| 1193 | 1208 |
| 1194 const VideoLayerImpl::FramePlane& y_plane = quad->y_plane; | 1209 const VideoLayerImpl::FramePlane& y_plane = quad->y_plane; |
| 1195 const VideoLayerImpl::FramePlane& u_plane = quad->u_plane; | 1210 const VideoLayerImpl::FramePlane& u_plane = quad->u_plane; |
| 1196 const VideoLayerImpl::FramePlane& v_plane = quad->v_plane; | 1211 const VideoLayerImpl::FramePlane& v_plane = quad->v_plane; |
| 1197 | 1212 |
| 1198 GLC(Context(), Context()->activeTexture(GL_TEXTURE1)); | 1213 GLC(Context(), Context()->activeTexture(GL_TEXTURE1)); |
| 1199 ResourceProvider::ScopedSamplerGL y_plane_lock( | 1214 ResourceProvider::ScopedSamplerGL y_plane_lock( |
| 1200 resource_provider_, y_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); | 1215 resource_provider_, y_plane.resource_id, GL_TEXTURE_2D, GL_LINEAR); |
| 1201 GLC(Context(), Context()->activeTexture(GL_TEXTURE2)); | 1216 GLC(Context(), Context()->activeTexture(GL_TEXTURE2)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 } | 1268 } |
| 1254 | 1269 |
| 1255 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame& frame, | 1270 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame& frame, |
| 1256 const StreamVideoDrawQuad* quad) { | 1271 const StreamVideoDrawQuad* quad) { |
| 1257 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1272 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1258 | 1273 |
| 1259 static float gl_matrix[16]; | 1274 static float gl_matrix[16]; |
| 1260 | 1275 |
| 1261 DCHECK(capabilities_.using_egl_image); | 1276 DCHECK(capabilities_.using_egl_image); |
| 1262 | 1277 |
| 1263 const VideoStreamTextureProgram* program = GetVideoStreamTextureProgram(); | 1278 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1279 context_, quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1280 |
| 1281 const VideoStreamTextureProgram* program = GetVideoStreamTextureProgram(texCoo
rdPrecision); |
| 1264 SetUseProgram(program->program()); | 1282 SetUseProgram(program->program()); |
| 1265 | 1283 |
| 1266 ToGLMatrix(&gl_matrix[0], quad->matrix); | 1284 ToGLMatrix(&gl_matrix[0], quad->matrix); |
| 1267 GLC(Context(), | 1285 GLC(Context(), |
| 1268 Context()->uniformMatrix4fv( | 1286 Context()->uniformMatrix4fv( |
| 1269 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); | 1287 program->vertex_shader().tex_matrix_location(), 1, false, gl_matrix)); |
| 1270 | 1288 |
| 1271 GLC(Context(), | 1289 GLC(Context(), |
| 1272 Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture_id)); | 1290 Context()->bindTexture(GL_TEXTURE_EXTERNAL_OES, quad->texture_id)); |
| 1273 | 1291 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 | 1399 |
| 1382 // Clear the cache. | 1400 // Clear the cache. |
| 1383 draw_cache_.program_id = 0; | 1401 draw_cache_.program_id = 0; |
| 1384 draw_cache_.uv_xform_data.resize(0); | 1402 draw_cache_.uv_xform_data.resize(0); |
| 1385 draw_cache_.vertex_opacity_data.resize(0); | 1403 draw_cache_.vertex_opacity_data.resize(0); |
| 1386 draw_cache_.matrix_data.resize(0); | 1404 draw_cache_.matrix_data.resize(0); |
| 1387 } | 1405 } |
| 1388 | 1406 |
| 1389 void GLRenderer::EnqueueTextureQuad(const DrawingFrame& frame, | 1407 void GLRenderer::EnqueueTextureQuad(const DrawingFrame& frame, |
| 1390 const TextureDrawQuad* quad) { | 1408 const TextureDrawQuad* quad) { |
| 1409 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1410 context_, quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1411 |
| 1391 // Choose the correct texture program binding | 1412 // Choose the correct texture program binding |
| 1392 TexTransformTextureProgramBinding binding; | 1413 TexTransformTextureProgramBinding binding; |
| 1393 if (quad->flipped) | 1414 if (quad->flipped) |
| 1394 binding.Set(GetTextureProgramFlip(), Context()); | 1415 binding.Set(GetTextureProgramFlip(texCoordPrecision), Context()); |
| 1395 else | 1416 else |
| 1396 binding.Set(GetTextureProgram(), Context()); | 1417 binding.Set(GetTextureProgram(texCoordPrecision), Context()); |
| 1397 | 1418 |
| 1398 int resource_id = quad->resource_id; | 1419 int resource_id = quad->resource_id; |
| 1399 | 1420 |
| 1400 if (draw_cache_.program_id != binding.program_id || | 1421 if (draw_cache_.program_id != binding.program_id || |
| 1401 draw_cache_.resource_id != resource_id || | 1422 draw_cache_.resource_id != resource_id || |
| 1402 draw_cache_.use_premultiplied_alpha != quad->premultiplied_alpha || | 1423 draw_cache_.use_premultiplied_alpha != quad->premultiplied_alpha || |
| 1403 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || | 1424 draw_cache_.needs_blending != quad->ShouldDrawWithBlending() || |
| 1404 draw_cache_.matrix_data.size() >= 8) { | 1425 draw_cache_.matrix_data.size() >= 8) { |
| 1405 FlushTextureQuadCache(); | 1426 FlushTextureQuadCache(); |
| 1406 draw_cache_.program_id = binding.program_id; | 1427 draw_cache_.program_id = binding.program_id; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1432 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); | 1453 QuadRectTransform(&quad_rect_matrix, quad->quadTransform(), quad->rect); |
| 1433 quad_rect_matrix = frame.projection_matrix * quad_rect_matrix; | 1454 quad_rect_matrix = frame.projection_matrix * quad_rect_matrix; |
| 1434 | 1455 |
| 1435 Float16 m; | 1456 Float16 m; |
| 1436 quad_rect_matrix.matrix().asColMajorf(m.data); | 1457 quad_rect_matrix.matrix().asColMajorf(m.data); |
| 1437 draw_cache_.matrix_data.push_back(m); | 1458 draw_cache_.matrix_data.push_back(m); |
| 1438 } | 1459 } |
| 1439 | 1460 |
| 1440 void GLRenderer::DrawTextureQuad(const DrawingFrame& frame, | 1461 void GLRenderer::DrawTextureQuad(const DrawingFrame& frame, |
| 1441 const TextureDrawQuad* quad) { | 1462 const TextureDrawQuad* quad) { |
| 1463 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1464 context_, quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1465 |
| 1442 TexTransformTextureProgramBinding binding; | 1466 TexTransformTextureProgramBinding binding; |
| 1443 if (quad->flipped) | 1467 if (quad->flipped) |
| 1444 binding.Set(GetTextureProgramFlip(), Context()); | 1468 binding.Set(GetTextureProgramFlip(texCoordPrecision), Context()); |
| 1445 else | 1469 else |
| 1446 binding.Set(GetTextureProgram(), Context()); | 1470 binding.Set(GetTextureProgram(texCoordPrecision), Context()); |
| 1447 SetUseProgram(binding.program_id); | 1471 SetUseProgram(binding.program_id); |
| 1448 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); | 1472 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); |
| 1449 gfx::PointF uv0 = quad->uv_top_left; | 1473 gfx::PointF uv0 = quad->uv_top_left; |
| 1450 gfx::PointF uv1 = quad->uv_bottom_right; | 1474 gfx::PointF uv1 = quad->uv_bottom_right; |
| 1451 GLC(Context(), | 1475 GLC(Context(), |
| 1452 Context()->uniform4f(binding.tex_transform_location, | 1476 Context()->uniform4f(binding.tex_transform_location, |
| 1453 uv0.x(), | 1477 uv0.x(), |
| 1454 uv0.y(), | 1478 uv0.y(), |
| 1455 uv1.x() - uv0.x(), | 1479 uv1.x() - uv0.x(), |
| 1456 uv1.y() - uv0.y())); | 1480 uv1.y() - uv0.y())); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1482 frame, quad->quadTransform(), quad->rect, binding.matrix_location); | 1506 frame, quad->quadTransform(), quad->rect, binding.matrix_location); |
| 1483 | 1507 |
| 1484 if (!quad->premultiplied_alpha) | 1508 if (!quad->premultiplied_alpha) |
| 1485 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); | 1509 GLC(context_, context_->blendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)); |
| 1486 } | 1510 } |
| 1487 | 1511 |
| 1488 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame& frame, | 1512 void GLRenderer::DrawIOSurfaceQuad(const DrawingFrame& frame, |
| 1489 const IOSurfaceDrawQuad* quad) { | 1513 const IOSurfaceDrawQuad* quad) { |
| 1490 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1514 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1491 | 1515 |
| 1516 TexCoordPrecision texCoordPrecision = TexCoordPrecisionRequired( |
| 1517 context_, quad->shared_quad_state->visible_content_rect.bottom_right()); |
| 1518 |
| 1492 TexTransformTextureProgramBinding binding; | 1519 TexTransformTextureProgramBinding binding; |
| 1493 binding.Set(GetTextureIOSurfaceProgram(), Context()); | 1520 binding.Set(GetTextureIOSurfaceProgram(texCoordPrecision), Context()); |
| 1494 | 1521 |
| 1495 SetUseProgram(binding.program_id); | 1522 SetUseProgram(binding.program_id); |
| 1496 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); | 1523 GLC(Context(), Context()->uniform1i(binding.sampler_location, 0)); |
| 1497 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { | 1524 if (quad->orientation == IOSurfaceDrawQuad::FLIPPED) { |
| 1498 GLC(Context(), | 1525 GLC(Context(), |
| 1499 Context()->uniform4f(binding.tex_transform_location, | 1526 Context()->uniform4f(binding.tex_transform_location, |
| 1500 0, | 1527 0, |
| 1501 quad->io_surface_size.height(), | 1528 quad->io_surface_size.height(), |
| 1502 quad->io_surface_size.width(), | 1529 quad->io_surface_size.width(), |
| 1503 quad->io_surface_size.height() * -1.0f)); | 1530 quad->io_surface_size.height() * -1.0f)); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1616 GLC(context_, | 1643 GLC(context_, |
| 1617 context_->uniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); | 1644 context_->uniformMatrix4fv(matrix_location, 1, false, &gl_matrix[0])); |
| 1618 | 1645 |
| 1619 GLC(context_, context_->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); | 1646 GLC(context_, context_->drawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0)); |
| 1620 } | 1647 } |
| 1621 | 1648 |
| 1622 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame& frame, | 1649 void GLRenderer::CopyTextureToFramebuffer(const DrawingFrame& frame, |
| 1623 int texture_id, | 1650 int texture_id, |
| 1624 gfx::Rect rect, | 1651 gfx::Rect rect, |
| 1625 const gfx::Transform& draw_matrix) { | 1652 const gfx::Transform& draw_matrix) { |
| 1626 const RenderPassProgram* program = GetRenderPassProgram(); | 1653 TexCoordPrecision texCoordPrecision = |
| 1654 TexCoordPrecisionRequired(context_, rect.bottom_right()); |
| 1655 const RenderPassProgram* program = GetRenderPassProgram(texCoordPrecision); |
| 1627 | 1656 |
| 1628 GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id)); | 1657 GLC(Context(), Context()->bindTexture(GL_TEXTURE_2D, texture_id)); |
| 1629 | 1658 |
| 1630 SetUseProgram(program->program()); | 1659 SetUseProgram(program->program()); |
| 1631 GLC(Context(), | 1660 GLC(Context(), |
| 1632 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); | 1661 Context()->uniform1i(program->fragment_shader().sampler_location(), 0)); |
| 1633 GLC(Context(), | 1662 GLC(Context(), |
| 1634 Context()->uniform4f(program->vertex_shader().tex_transform_location(), | 1663 Context()->uniform4f(program->vertex_shader().tex_transform_location(), |
| 1635 0.0f, | 1664 0.0f, |
| 1636 0.0f, | 1665 0.0f, |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 bool GLRenderer::InitializeSharedObjects() { | 1982 bool GLRenderer::InitializeSharedObjects() { |
| 1954 TRACE_EVENT0("cc", "GLRenderer::initializeSharedObjects"); | 1983 TRACE_EVENT0("cc", "GLRenderer::initializeSharedObjects"); |
| 1955 MakeContextCurrent(); | 1984 MakeContextCurrent(); |
| 1956 | 1985 |
| 1957 // Create an FBO for doing offscreen rendering. | 1986 // Create an FBO for doing offscreen rendering. |
| 1958 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); | 1987 GLC(context_, offscreen_framebuffer_id_ = context_->createFramebuffer()); |
| 1959 | 1988 |
| 1960 // We will always need these programs to render, so create the programs | 1989 // We will always need these programs to render, so create the programs |
| 1961 // eagerly so that the shader compilation can start while we do other work. | 1990 // eagerly so that the shader compilation can start while we do other work. |
| 1962 // Other programs are created lazily on first access. | 1991 // Other programs are created lazily on first access. |
| 1963 shared_geometry_ = | 1992 shared_geometry_ = make_scoped_ptr( |
| 1964 make_scoped_ptr(new GeometryBinding(context_, QuadVertexRect())); | 1993 new GeometryBinding(context_, QuadVertexRect())); |
| 1965 render_pass_program_ = make_scoped_ptr(new RenderPassProgram(context_)); | 1994 render_pass_program_ = make_scoped_ptr( |
| 1966 tile_program_ = make_scoped_ptr(new TileProgram(context_)); | 1995 new RenderPassProgram(context_, TexCoordPrecisionMedium)); |
| 1967 tile_program_opaque_ = make_scoped_ptr(new TileProgramOpaque(context_)); | 1996 render_pass_program_highp_ = make_scoped_ptr( |
| 1997 new RenderPassProgram(context_, TexCoordPrecisionHigh)); |
| 1998 tile_program_ = make_scoped_ptr( |
| 1999 new TileProgram(context_, TexCoordPrecisionMedium)); |
| 2000 tile_program_opaque_ = make_scoped_ptr( |
| 2001 new TileProgramOpaque(context_, TexCoordPrecisionMedium)); |
| 1968 | 2002 |
| 1969 GLC(context_, context_->flush()); | 2003 GLC(context_, context_->flush()); |
| 1970 | 2004 |
| 1971 return true; | 2005 return true; |
| 1972 } | 2006 } |
| 1973 | 2007 |
| 1974 const GLRenderer::TileCheckerboardProgram* | 2008 const GLRenderer::TileCheckerboardProgram* |
| 1975 GLRenderer::GetTileCheckerboardProgram() { | 2009 GLRenderer::GetTileCheckerboardProgram() { |
| 1976 if (!tile_checkerboard_program_) { | 2010 if (!tile_checkerboard_program_) |
| 1977 tile_checkerboard_program_ = | 2011 tile_checkerboard_program_ = make_scoped_ptr( |
| 1978 make_scoped_ptr(new TileCheckerboardProgram(context_)); | 2012 new TileCheckerboardProgram(context_, TexCoordPrecisionMedium)); |
| 1979 } | |
| 1980 if (!tile_checkerboard_program_->initialized()) { | 2013 if (!tile_checkerboard_program_->initialized()) { |
| 1981 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); | 2014 TRACE_EVENT0("cc", "GLRenderer::checkerboardProgram::initalize"); |
| 1982 tile_checkerboard_program_->Initialize(context_, is_using_bind_uniform_); | 2015 tile_checkerboard_program_->Initialize(context_, is_using_bind_uniform_); |
| 1983 } | 2016 } |
| 1984 return tile_checkerboard_program_.get(); | 2017 return tile_checkerboard_program_.get(); |
| 1985 } | 2018 } |
| 1986 | 2019 |
| 1987 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { | 2020 const GLRenderer::DebugBorderProgram* GLRenderer::GetDebugBorderProgram() { |
| 1988 if (!debug_border_program_) | 2021 if (!debug_border_program_) |
| 1989 debug_border_program_ = make_scoped_ptr(new DebugBorderProgram(context_)); | 2022 debug_border_program_ = make_scoped_ptr( |
| 2023 new DebugBorderProgram(context_, TexCoordPrecisionNA)); |
| 1990 if (!debug_border_program_->initialized()) { | 2024 if (!debug_border_program_->initialized()) { |
| 1991 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); | 2025 TRACE_EVENT0("cc", "GLRenderer::debugBorderProgram::initialize"); |
| 1992 debug_border_program_->Initialize(context_, is_using_bind_uniform_); | 2026 debug_border_program_->Initialize(context_, is_using_bind_uniform_); |
| 1993 } | 2027 } |
| 1994 return debug_border_program_.get(); | 2028 return debug_border_program_.get(); |
| 1995 } | 2029 } |
| 1996 | 2030 |
| 1997 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { | 2031 const GLRenderer::SolidColorProgram* GLRenderer::GetSolidColorProgram() { |
| 1998 if (!solid_color_program_) | 2032 if (!solid_color_program_) |
| 1999 solid_color_program_ = make_scoped_ptr(new SolidColorProgram(context_)); | 2033 solid_color_program_ = make_scoped_ptr( |
| 2034 new SolidColorProgram(context_, TexCoordPrecisionNA)); |
| 2000 if (!solid_color_program_->initialized()) { | 2035 if (!solid_color_program_->initialized()) { |
| 2001 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); | 2036 TRACE_EVENT0("cc", "GLRenderer::solidColorProgram::initialize"); |
| 2002 solid_color_program_->Initialize(context_, is_using_bind_uniform_); | 2037 solid_color_program_->Initialize(context_, is_using_bind_uniform_); |
| 2003 } | 2038 } |
| 2004 return solid_color_program_.get(); | 2039 return solid_color_program_.get(); |
| 2005 } | 2040 } |
| 2006 | 2041 |
| 2007 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { | 2042 const GLRenderer::SolidColorProgramAA* GLRenderer::GetSolidColorProgramAA() { |
| 2008 if (!solid_color_program_aa_) { | 2043 if (!solid_color_program_aa_) { |
| 2009 solid_color_program_aa_ = | 2044 solid_color_program_aa_ = |
| 2010 make_scoped_ptr(new SolidColorProgramAA(context_)); | 2045 make_scoped_ptr(new SolidColorProgramAA(context_, TexCoordPrecisionNA)); |
| 2011 } | 2046 } |
| 2012 if (!solid_color_program_aa_->initialized()) { | 2047 if (!solid_color_program_aa_->initialized()) { |
| 2013 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); | 2048 TRACE_EVENT0("cc", "GLRenderer::solidColorProgramAA::initialize"); |
| 2014 solid_color_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2049 solid_color_program_aa_->Initialize(context_, is_using_bind_uniform_); |
| 2015 } | 2050 } |
| 2016 return solid_color_program_aa_.get(); | 2051 return solid_color_program_aa_.get(); |
| 2017 } | 2052 } |
| 2018 | 2053 |
| 2019 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram() { | 2054 const GLRenderer::RenderPassProgram* GLRenderer::GetRenderPassProgram( |
| 2020 DCHECK(render_pass_program_); | 2055 TexCoordPrecision precision) { |
| 2021 if (!render_pass_program_->initialized()) { | 2056 scoped_ptr<RenderPassProgram> &program = |
| 2057 (precision == TexCoordPrecisionHigh) ? render_pass_program_highp_ |
| 2058 : render_pass_program_; |
| 2059 DCHECK(program); |
| 2060 if (!program->initialized()) { |
| 2022 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); | 2061 TRACE_EVENT0("cc", "GLRenderer::renderPassProgram::initialize"); |
| 2023 render_pass_program_->Initialize(context_, is_using_bind_uniform_); | 2062 program->Initialize(context_, is_using_bind_uniform_); |
| 2024 } | 2063 } |
| 2025 return render_pass_program_.get(); | 2064 return program.get(); |
| 2026 } | 2065 } |
| 2027 | 2066 |
| 2028 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA() { | 2067 const GLRenderer::RenderPassProgramAA* GLRenderer::GetRenderPassProgramAA( |
| 2029 if (!render_pass_program_aa_) | 2068 TexCoordPrecision precision) { |
| 2030 render_pass_program_aa_ = | 2069 scoped_ptr<RenderPassProgramAA> &program = |
| 2031 make_scoped_ptr(new RenderPassProgramAA(context_)); | 2070 (precision == TexCoordPrecisionHigh) ? render_pass_program_aa_highp_ |
| 2032 if (!render_pass_program_aa_->initialized()) { | 2071 : render_pass_program_aa_; |
| 2072 if (!program) |
| 2073 program = |
| 2074 make_scoped_ptr(new RenderPassProgramAA(context_, precision)); |
| 2075 if (!program->initialized()) { |
| 2033 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); | 2076 TRACE_EVENT0("cc", "GLRenderer::renderPassProgramAA::initialize"); |
| 2034 render_pass_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2077 program->Initialize(context_, is_using_bind_uniform_); |
| 2035 } | 2078 } |
| 2036 return render_pass_program_aa_.get(); | 2079 return program.get(); |
| 2037 } | 2080 } |
| 2038 | 2081 |
| 2039 const GLRenderer::RenderPassMaskProgram* | 2082 const GLRenderer::RenderPassMaskProgram* |
| 2040 GLRenderer::GetRenderPassMaskProgram() { | 2083 GLRenderer::GetRenderPassMaskProgram(TexCoordPrecision precision) { |
| 2041 if (!render_pass_mask_program_) | 2084 scoped_ptr<RenderPassMaskProgram> &program = |
| 2042 render_pass_mask_program_ = | 2085 (precision == TexCoordPrecisionHigh) ? render_pass_mask_program_highp_ |
| 2043 make_scoped_ptr(new RenderPassMaskProgram(context_)); | 2086 : render_pass_mask_program_; |
| 2044 if (!render_pass_mask_program_->initialized()) { | 2087 if (!program) |
| 2088 program = make_scoped_ptr(new RenderPassMaskProgram(context_, precision)); |
| 2089 if (!program->initialized()) { |
| 2045 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); | 2090 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgram::initialize"); |
| 2046 render_pass_mask_program_->Initialize(context_, is_using_bind_uniform_); | 2091 program->Initialize(context_, is_using_bind_uniform_); |
| 2047 } | 2092 } |
| 2048 return render_pass_mask_program_.get(); | 2093 return program.get(); |
| 2049 } | 2094 } |
| 2050 | 2095 |
| 2051 const GLRenderer::RenderPassMaskProgramAA* | 2096 const GLRenderer::RenderPassMaskProgramAA* |
| 2052 GLRenderer::GetRenderPassMaskProgramAA() { | 2097 GLRenderer::GetRenderPassMaskProgramAA(TexCoordPrecision precision) { |
| 2053 if (!render_pass_mask_program_aa_) | 2098 scoped_ptr<RenderPassMaskProgramAA> &program = |
| 2054 render_pass_mask_program_aa_ = | 2099 (precision == TexCoordPrecisionHigh) ? render_pass_mask_program_aa_highp_ |
| 2055 make_scoped_ptr(new RenderPassMaskProgramAA(context_)); | 2100 : render_pass_mask_program_aa_; |
| 2056 if (!render_pass_mask_program_aa_->initialized()) { | 2101 if (!program) |
| 2102 program = |
| 2103 make_scoped_ptr(new RenderPassMaskProgramAA(context_, precision)); |
| 2104 if (!program->initialized()) { |
| 2057 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); | 2105 TRACE_EVENT0("cc", "GLRenderer::renderPassMaskProgramAA::initialize"); |
| 2058 render_pass_mask_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2106 program->Initialize(context_, is_using_bind_uniform_); |
| 2059 } | 2107 } |
| 2060 return render_pass_mask_program_aa_.get(); | 2108 return program.get(); |
| 2061 } | 2109 } |
| 2062 | 2110 |
| 2063 const GLRenderer::TileProgram* GLRenderer::GetTileProgram() { | 2111 const GLRenderer::TileProgram* GLRenderer::GetTileProgram() { |
| 2064 DCHECK(tile_program_); | 2112 DCHECK(tile_program_); |
| 2065 if (!tile_program_->initialized()) { | 2113 if (!tile_program_->initialized()) { |
| 2066 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); | 2114 TRACE_EVENT0("cc", "GLRenderer::tileProgram::initialize"); |
| 2067 tile_program_->Initialize(context_, is_using_bind_uniform_); | 2115 tile_program_->Initialize(context_, is_using_bind_uniform_); |
| 2068 } | 2116 } |
| 2069 return tile_program_.get(); | 2117 return tile_program_.get(); |
| 2070 } | 2118 } |
| 2071 | 2119 |
| 2072 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque() { | 2120 const GLRenderer::TileProgramOpaque* GLRenderer::GetTileProgramOpaque() { |
| 2073 DCHECK(tile_program_opaque_); | 2121 DCHECK(tile_program_opaque_); |
| 2074 if (!tile_program_opaque_->initialized()) { | 2122 if (!tile_program_opaque_->initialized()) { |
| 2075 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); | 2123 TRACE_EVENT0("cc", "GLRenderer::tileProgramOpaque::initialize"); |
| 2076 tile_program_opaque_->Initialize(context_, is_using_bind_uniform_); | 2124 tile_program_opaque_->Initialize(context_, is_using_bind_uniform_); |
| 2077 } | 2125 } |
| 2078 return tile_program_opaque_.get(); | 2126 return tile_program_opaque_.get(); |
| 2079 } | 2127 } |
| 2080 | 2128 |
| 2081 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA() { | 2129 const GLRenderer::TileProgramAA* GLRenderer::GetTileProgramAA() { |
| 2082 if (!tile_program_aa_) | 2130 if (!tile_program_aa_) |
| 2083 tile_program_aa_ = make_scoped_ptr(new TileProgramAA(context_)); | 2131 tile_program_aa_ = make_scoped_ptr( |
| 2132 new TileProgramAA(context_, TexCoordPrecisionMedium)); |
| 2084 if (!tile_program_aa_->initialized()) { | 2133 if (!tile_program_aa_->initialized()) { |
| 2085 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); | 2134 TRACE_EVENT0("cc", "GLRenderer::tileProgramAA::initialize"); |
| 2086 tile_program_aa_->Initialize(context_, is_using_bind_uniform_); | 2135 tile_program_aa_->Initialize(context_, is_using_bind_uniform_); |
| 2087 } | 2136 } |
| 2088 return tile_program_aa_.get(); | 2137 return tile_program_aa_.get(); |
| 2089 } | 2138 } |
| 2090 | 2139 |
| 2091 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle() { | 2140 const GLRenderer::TileProgramSwizzle* GLRenderer::GetTileProgramSwizzle() { |
| 2092 if (!tile_program_swizzle_) | 2141 if (!tile_program_swizzle_) |
| 2093 tile_program_swizzle_ = make_scoped_ptr(new TileProgramSwizzle(context_)); | 2142 tile_program_swizzle_ = make_scoped_ptr( |
| 2143 new TileProgramSwizzle(context_, TexCoordPrecisionMedium)); |
| 2094 if (!tile_program_swizzle_->initialized()) { | 2144 if (!tile_program_swizzle_->initialized()) { |
| 2095 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); | 2145 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzle::initialize"); |
| 2096 tile_program_swizzle_->Initialize(context_, is_using_bind_uniform_); | 2146 tile_program_swizzle_->Initialize(context_, is_using_bind_uniform_); |
| 2097 } | 2147 } |
| 2098 return tile_program_swizzle_.get(); | 2148 return tile_program_swizzle_.get(); |
| 2099 } | 2149 } |
| 2100 | 2150 |
| 2101 const GLRenderer::TileProgramSwizzleOpaque* | 2151 const GLRenderer::TileProgramSwizzleOpaque* |
| 2102 GLRenderer::GetTileProgramSwizzleOpaque() { | 2152 GLRenderer::GetTileProgramSwizzleOpaque() { |
| 2103 if (!tile_program_swizzle_opaque_) | 2153 if (!tile_program_swizzle_opaque_) |
| 2104 tile_program_swizzle_opaque_ = | 2154 tile_program_swizzle_opaque_ = make_scoped_ptr( |
| 2105 make_scoped_ptr(new TileProgramSwizzleOpaque(context_)); | 2155 new TileProgramSwizzleOpaque(context_, TexCoordPrecisionMedium)); |
| 2106 if (!tile_program_swizzle_opaque_->initialized()) { | 2156 if (!tile_program_swizzle_opaque_->initialized()) { |
| 2107 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); | 2157 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleOpaque::initialize"); |
| 2108 tile_program_swizzle_opaque_->Initialize(context_, is_using_bind_uniform_); | 2158 tile_program_swizzle_opaque_->Initialize(context_, is_using_bind_uniform_); |
| 2109 } | 2159 } |
| 2110 return tile_program_swizzle_opaque_.get(); | 2160 return tile_program_swizzle_opaque_.get(); |
| 2111 } | 2161 } |
| 2112 | 2162 |
| 2113 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA() { | 2163 const GLRenderer::TileProgramSwizzleAA* GLRenderer::GetTileProgramSwizzleAA() { |
| 2114 if (!tile_program_swizzle_aa_) | 2164 if (!tile_program_swizzle_aa_) |
| 2115 tile_program_swizzle_aa_ = | 2165 tile_program_swizzle_aa_ = make_scoped_ptr( |
| 2116 make_scoped_ptr(new TileProgramSwizzleAA(context_)); | 2166 new TileProgramSwizzleAA(context_, TexCoordPrecisionMedium)); |
| 2117 if (!tile_program_swizzle_aa_->initialized()) { | 2167 if (!tile_program_swizzle_aa_->initialized()) { |
| 2118 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); | 2168 TRACE_EVENT0("cc", "GLRenderer::tileProgramSwizzleAA::initialize"); |
| 2119 tile_program_swizzle_aa_->Initialize(context_, is_using_bind_uniform_); | 2169 tile_program_swizzle_aa_->Initialize(context_, is_using_bind_uniform_); |
| 2120 } | 2170 } |
| 2121 return tile_program_swizzle_aa_.get(); | 2171 return tile_program_swizzle_aa_.get(); |
| 2122 } | 2172 } |
| 2123 | 2173 |
| 2124 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram() { | 2174 const GLRenderer::TextureProgram* GLRenderer::GetTextureProgram( |
| 2125 if (!texture_program_) | 2175 TexCoordPrecision precision) { |
| 2126 texture_program_ = make_scoped_ptr(new TextureProgram(context_)); | 2176 scoped_ptr<TextureProgram> &program = |
| 2127 if (!texture_program_->initialized()) { | 2177 (precision == TexCoordPrecisionHigh) ? texture_program_highp_ |
| 2178 : texture_program_; |
| 2179 if (!program) |
| 2180 program = make_scoped_ptr(new TextureProgram(context_, precision)); |
| 2181 if (!program->initialized()) { |
| 2128 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); | 2182 TRACE_EVENT0("cc", "GLRenderer::textureProgram::initialize"); |
| 2129 texture_program_->Initialize(context_, is_using_bind_uniform_); | 2183 program->Initialize(context_, is_using_bind_uniform_); |
| 2130 } | 2184 } |
| 2131 return texture_program_.get(); | 2185 return program.get(); |
| 2132 } | 2186 } |
| 2133 | 2187 |
| 2134 const GLRenderer::TextureProgramFlip* GLRenderer::GetTextureProgramFlip() { | 2188 const GLRenderer::TextureProgramFlip* GLRenderer::GetTextureProgramFlip( |
| 2135 if (!texture_program_flip_) | 2189 TexCoordPrecision precision) { |
| 2136 texture_program_flip_ = make_scoped_ptr(new TextureProgramFlip(context_)); | 2190 scoped_ptr<TextureProgramFlip> &program = |
| 2137 if (!texture_program_flip_->initialized()) { | 2191 (precision == TexCoordPrecisionHigh) ? texture_program_flip_highp_ |
| 2192 : texture_program_flip_; |
| 2193 if (!program) |
| 2194 program = make_scoped_ptr(new TextureProgramFlip(context_, precision)); |
| 2195 if (!program->initialized()) { |
| 2138 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); | 2196 TRACE_EVENT0("cc", "GLRenderer::textureProgramFlip::initialize"); |
| 2139 texture_program_flip_->Initialize(context_, is_using_bind_uniform_); | 2197 program->Initialize(context_, is_using_bind_uniform_); |
| 2140 } | 2198 } |
| 2141 return texture_program_flip_.get(); | 2199 return program.get(); |
| 2142 } | 2200 } |
| 2143 | 2201 |
| 2144 const GLRenderer::TextureIOSurfaceProgram* | 2202 const GLRenderer::TextureIOSurfaceProgram* |
| 2145 GLRenderer::GetTextureIOSurfaceProgram() { | 2203 GLRenderer::GetTextureIOSurfaceProgram(TexCoordPrecision precision) { |
| 2146 if (!texture_io_surface_program_) | 2204 scoped_ptr<TextureIOSurfaceProgram> &program = |
| 2147 texture_io_surface_program_ = | 2205 (precision == TexCoordPrecisionHigh) ? texture_io_surface_program_highp_ |
| 2148 make_scoped_ptr(new TextureIOSurfaceProgram(context_)); | 2206 : texture_io_surface_program_; |
| 2149 if (!texture_io_surface_program_->initialized()) { | 2207 if (!program) |
| 2208 program = |
| 2209 make_scoped_ptr(new TextureIOSurfaceProgram(context_, precision)); |
| 2210 if (!program->initialized()) { |
| 2150 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); | 2211 TRACE_EVENT0("cc", "GLRenderer::textureIOSurfaceProgram::initialize"); |
| 2151 texture_io_surface_program_->Initialize(context_, is_using_bind_uniform_); | 2212 program->Initialize(context_, is_using_bind_uniform_); |
| 2152 } | 2213 } |
| 2153 return texture_io_surface_program_.get(); | 2214 return program.get(); |
| 2154 } | 2215 } |
| 2155 | 2216 |
| 2156 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram() { | 2217 const GLRenderer::VideoYUVProgram* GLRenderer::GetVideoYUVProgram( |
| 2157 if (!video_yuv_program_) | 2218 TexCoordPrecision precision) { |
| 2158 video_yuv_program_ = make_scoped_ptr(new VideoYUVProgram(context_)); | 2219 scoped_ptr<VideoYUVProgram> &program = |
| 2159 if (!video_yuv_program_->initialized()) { | 2220 (precision == TexCoordPrecisionHigh) ? video_yuv_program_highp_ |
| 2221 : video_yuv_program_; |
| 2222 if (!program) |
| 2223 program = make_scoped_ptr(new VideoYUVProgram(context_, precision)); |
| 2224 if (!program->initialized()) { |
| 2160 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); | 2225 TRACE_EVENT0("cc", "GLRenderer::videoYUVProgram::initialize"); |
| 2161 video_yuv_program_->Initialize(context_, is_using_bind_uniform_); | 2226 program->Initialize(context_, is_using_bind_uniform_); |
| 2162 } | 2227 } |
| 2163 return video_yuv_program_.get(); | 2228 return program.get(); |
| 2164 } | 2229 } |
| 2165 | 2230 |
| 2166 const GLRenderer::VideoStreamTextureProgram* | 2231 const GLRenderer::VideoStreamTextureProgram* |
| 2167 GLRenderer::GetVideoStreamTextureProgram() { | 2232 GLRenderer::GetVideoStreamTextureProgram(TexCoordPrecision precision) { |
| 2168 if (!Capabilities().using_egl_image) | 2233 if (!Capabilities().using_egl_image) |
| 2169 return NULL; | 2234 return NULL; |
| 2170 if (!video_stream_texture_program_) | 2235 scoped_ptr<VideoStreamTextureProgram> &program = |
| 2171 video_stream_texture_program_ = | 2236 (precision == TexCoordPrecisionHigh) ? video_stream_texture_program_highp_ |
| 2172 make_scoped_ptr(new VideoStreamTextureProgram(context_)); | 2237 : video_stream_texture_program_; |
| 2173 if (!video_stream_texture_program_->initialized()) { | 2238 if (!program) |
| 2239 program = |
| 2240 make_scoped_ptr(new VideoStreamTextureProgram(context_, precision)); |
| 2241 if (!program->initialized()) { |
| 2174 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); | 2242 TRACE_EVENT0("cc", "GLRenderer::streamTextureProgram::initialize"); |
| 2175 video_stream_texture_program_->Initialize(context_, is_using_bind_uniform_); | 2243 program->Initialize(context_, is_using_bind_uniform_); |
| 2176 } | 2244 } |
| 2177 return video_stream_texture_program_.get(); | 2245 return program.get(); |
| 2178 } | 2246 } |
| 2179 | 2247 |
| 2180 void GLRenderer::CleanupSharedObjects() { | 2248 void GLRenderer::CleanupSharedObjects() { |
| 2181 MakeContextCurrent(); | 2249 MakeContextCurrent(); |
| 2182 | 2250 |
| 2183 shared_geometry_.reset(); | 2251 shared_geometry_.reset(); |
| 2184 | 2252 |
| 2185 if (tile_program_) | 2253 if (tile_program_) |
| 2186 tile_program_->Cleanup(context_); | 2254 tile_program_->Cleanup(context_); |
| 2187 if (tile_program_opaque_) | 2255 if (tile_program_opaque_) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2199 | 2267 |
| 2200 if (render_pass_mask_program_) | 2268 if (render_pass_mask_program_) |
| 2201 render_pass_mask_program_->Cleanup(context_); | 2269 render_pass_mask_program_->Cleanup(context_); |
| 2202 if (render_pass_program_) | 2270 if (render_pass_program_) |
| 2203 render_pass_program_->Cleanup(context_); | 2271 render_pass_program_->Cleanup(context_); |
| 2204 if (render_pass_mask_program_aa_) | 2272 if (render_pass_mask_program_aa_) |
| 2205 render_pass_mask_program_aa_->Cleanup(context_); | 2273 render_pass_mask_program_aa_->Cleanup(context_); |
| 2206 if (render_pass_program_aa_) | 2274 if (render_pass_program_aa_) |
| 2207 render_pass_program_aa_->Cleanup(context_); | 2275 render_pass_program_aa_->Cleanup(context_); |
| 2208 | 2276 |
| 2277 if (render_pass_mask_program_highp_) |
| 2278 render_pass_mask_program_highp_->Cleanup(context_); |
| 2279 if (render_pass_program_highp_) |
| 2280 render_pass_program_highp_->Cleanup(context_); |
| 2281 if (render_pass_mask_program_aa_highp_) |
| 2282 render_pass_mask_program_aa_highp_->Cleanup(context_); |
| 2283 if (render_pass_program_aa_highp_) |
| 2284 render_pass_program_aa_highp_->Cleanup(context_); |
| 2285 |
| 2209 if (texture_program_) | 2286 if (texture_program_) |
| 2210 texture_program_->Cleanup(context_); | 2287 texture_program_->Cleanup(context_); |
| 2211 if (texture_program_flip_) | 2288 if (texture_program_flip_) |
| 2212 texture_program_flip_->Cleanup(context_); | 2289 texture_program_flip_->Cleanup(context_); |
| 2213 if (texture_io_surface_program_) | 2290 if (texture_io_surface_program_) |
| 2214 texture_io_surface_program_->Cleanup(context_); | 2291 texture_io_surface_program_->Cleanup(context_); |
| 2215 | 2292 |
| 2293 if (texture_program_highp_) |
| 2294 texture_program_highp_->Cleanup(context_); |
| 2295 if (texture_program_flip_highp_) |
| 2296 texture_program_flip_highp_->Cleanup(context_); |
| 2297 if (texture_io_surface_program_highp_) |
| 2298 texture_io_surface_program_highp_->Cleanup(context_); |
| 2299 |
| 2216 if (video_yuv_program_) | 2300 if (video_yuv_program_) |
| 2217 video_yuv_program_->Cleanup(context_); | 2301 video_yuv_program_->Cleanup(context_); |
| 2218 if (video_stream_texture_program_) | 2302 if (video_stream_texture_program_) |
| 2219 video_stream_texture_program_->Cleanup(context_); | 2303 video_stream_texture_program_->Cleanup(context_); |
| 2220 | 2304 |
| 2305 if (video_yuv_program_highp_) |
| 2306 video_yuv_program_highp_->Cleanup(context_); |
| 2307 if (video_stream_texture_program_highp_) |
| 2308 video_stream_texture_program_highp_->Cleanup(context_); |
| 2309 |
| 2221 if (debug_border_program_) | 2310 if (debug_border_program_) |
| 2222 debug_border_program_->Cleanup(context_); | 2311 debug_border_program_->Cleanup(context_); |
| 2223 if (solid_color_program_) | 2312 if (solid_color_program_) |
| 2224 solid_color_program_->Cleanup(context_); | 2313 solid_color_program_->Cleanup(context_); |
| 2225 if (solid_color_program_aa_) | 2314 if (solid_color_program_aa_) |
| 2226 solid_color_program_aa_->Cleanup(context_); | 2315 solid_color_program_aa_->Cleanup(context_); |
| 2227 | 2316 |
| 2228 if (offscreen_framebuffer_id_) | 2317 if (offscreen_framebuffer_id_) |
| 2229 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); | 2318 GLC(context_, context_->deleteFramebuffer(offscreen_framebuffer_id_)); |
| 2230 | 2319 |
| 2231 ReleaseRenderPassTextures(); | 2320 ReleaseRenderPassTextures(); |
| 2232 } | 2321 } |
| 2233 | 2322 |
| 2234 bool GLRenderer::IsContextLost() { | 2323 bool GLRenderer::IsContextLost() { |
| 2235 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 2324 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
| 2236 } | 2325 } |
| 2237 | 2326 |
| 2238 } // namespace cc | 2327 } // namespace cc |
| OLD | NEW |