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