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