OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 ResourceProvider::ScopedSamplerGL v_plane_lock( | 1624 ResourceProvider::ScopedSamplerGL v_plane_lock( |
1625 resource_provider_, quad->v_plane_resource_id, GL_TEXTURE3, GL_LINEAR); | 1625 resource_provider_, quad->v_plane_resource_id, GL_TEXTURE3, GL_LINEAR); |
1626 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), v_plane_lock.target()); | 1626 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), v_plane_lock.target()); |
1627 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; | 1627 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; |
1628 if (use_alpha_plane) { | 1628 if (use_alpha_plane) { |
1629 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( | 1629 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( |
1630 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR)); | 1630 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR)); |
1631 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); | 1631 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); |
1632 } | 1632 } |
1633 | 1633 |
| 1634 int matrix_location = -1; |
1634 int tex_scale_location = -1; | 1635 int tex_scale_location = -1; |
1635 int matrix_location = -1; | 1636 int tex_offset_location = -1; |
1636 int y_texture_location = -1; | 1637 int y_texture_location = -1; |
1637 int u_texture_location = -1; | 1638 int u_texture_location = -1; |
1638 int v_texture_location = -1; | 1639 int v_texture_location = -1; |
1639 int a_texture_location = -1; | 1640 int a_texture_location = -1; |
1640 int yuv_matrix_location = -1; | 1641 int yuv_matrix_location = -1; |
1641 int yuv_adj_location = -1; | 1642 int yuv_adj_location = -1; |
1642 int alpha_location = -1; | 1643 int alpha_location = -1; |
1643 if (use_alpha_plane) { | 1644 if (use_alpha_plane) { |
1644 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision); | 1645 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision); |
1645 DCHECK(program && (program->initialized() || IsContextLost())); | 1646 DCHECK(program && (program->initialized() || IsContextLost())); |
1646 SetUseProgram(program->program()); | 1647 SetUseProgram(program->program()); |
| 1648 matrix_location = program->vertex_shader().matrix_location(); |
1647 tex_scale_location = program->vertex_shader().tex_scale_location(); | 1649 tex_scale_location = program->vertex_shader().tex_scale_location(); |
1648 matrix_location = program->vertex_shader().matrix_location(); | 1650 tex_offset_location = program->vertex_shader().tex_offset_location(); |
1649 y_texture_location = program->fragment_shader().y_texture_location(); | 1651 y_texture_location = program->fragment_shader().y_texture_location(); |
1650 u_texture_location = program->fragment_shader().u_texture_location(); | 1652 u_texture_location = program->fragment_shader().u_texture_location(); |
1651 v_texture_location = program->fragment_shader().v_texture_location(); | 1653 v_texture_location = program->fragment_shader().v_texture_location(); |
1652 a_texture_location = program->fragment_shader().a_texture_location(); | 1654 a_texture_location = program->fragment_shader().a_texture_location(); |
1653 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); | 1655 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); |
1654 yuv_adj_location = program->fragment_shader().yuv_adj_location(); | 1656 yuv_adj_location = program->fragment_shader().yuv_adj_location(); |
1655 alpha_location = program->fragment_shader().alpha_location(); | 1657 alpha_location = program->fragment_shader().alpha_location(); |
1656 } else { | 1658 } else { |
1657 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision); | 1659 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision); |
1658 DCHECK(program && (program->initialized() || IsContextLost())); | 1660 DCHECK(program && (program->initialized() || IsContextLost())); |
1659 SetUseProgram(program->program()); | 1661 SetUseProgram(program->program()); |
| 1662 matrix_location = program->vertex_shader().matrix_location(); |
1660 tex_scale_location = program->vertex_shader().tex_scale_location(); | 1663 tex_scale_location = program->vertex_shader().tex_scale_location(); |
1661 matrix_location = program->vertex_shader().matrix_location(); | 1664 tex_offset_location = program->vertex_shader().tex_offset_location(); |
1662 y_texture_location = program->fragment_shader().y_texture_location(); | 1665 y_texture_location = program->fragment_shader().y_texture_location(); |
1663 u_texture_location = program->fragment_shader().u_texture_location(); | 1666 u_texture_location = program->fragment_shader().u_texture_location(); |
1664 v_texture_location = program->fragment_shader().v_texture_location(); | 1667 v_texture_location = program->fragment_shader().v_texture_location(); |
1665 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); | 1668 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); |
1666 yuv_adj_location = program->fragment_shader().yuv_adj_location(); | 1669 yuv_adj_location = program->fragment_shader().yuv_adj_location(); |
1667 alpha_location = program->fragment_shader().alpha_location(); | 1670 alpha_location = program->fragment_shader().alpha_location(); |
1668 } | 1671 } |
1669 | 1672 |
1670 GLC(gl_, | 1673 GLC(gl_, |
1671 gl_->Uniform2f(tex_scale_location, | 1674 gl_->Uniform2f(tex_scale_location, |
1672 quad->tex_scale.width(), | 1675 quad->tex_coord_rect.width(), |
1673 quad->tex_scale.height())); | 1676 quad->tex_coord_rect.height())); |
| 1677 GLC(gl_, |
| 1678 gl_->Uniform2f(tex_offset_location, |
| 1679 quad->tex_coord_rect.x(), |
| 1680 quad->tex_coord_rect.y())); |
1674 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); | 1681 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); |
1675 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); | 1682 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); |
1676 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); | 1683 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); |
1677 if (use_alpha_plane) | 1684 if (use_alpha_plane) |
1678 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); | 1685 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); |
1679 | 1686 |
1680 // These values are magic numbers that are used in the transformation from YUV | 1687 // These values are magic numbers that are used in the transformation from YUV |
1681 // to RGB color values. They are taken from the following webpage: | 1688 // to RGB color values. They are taken from the following webpage: |
1682 // http://www.fourcc.org/fccyvrgb.php | 1689 // http://www.fourcc.org/fccyvrgb.php |
1683 float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f, | 1690 float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f, |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3041 is_scissor_enabled_ = false; | 3048 is_scissor_enabled_ = false; |
3042 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); | 3049 GLC(gl_, gl_->Disable(GL_SCISSOR_TEST)); |
3043 scissor_rect_needs_reset_ = true; | 3050 scissor_rect_needs_reset_ = true; |
3044 } | 3051 } |
3045 | 3052 |
3046 bool GLRenderer::IsContextLost() { | 3053 bool GLRenderer::IsContextLost() { |
3047 return output_surface_->context_provider()->IsContextLost(); | 3054 return output_surface_->context_provider()->IsContextLost(); |
3048 } | 3055 } |
3049 | 3056 |
3050 } // namespace cc | 3057 } // namespace cc |
OLD | NEW |