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 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; | 1825 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; |
1826 if (use_alpha_plane) { | 1826 if (use_alpha_plane) { |
1827 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( | 1827 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( |
1828 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR)); | 1828 resource_provider_, quad->a_plane_resource_id, GL_TEXTURE4, GL_LINEAR)); |
1829 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); | 1829 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), a_plane_lock->target()); |
1830 } | 1830 } |
1831 | 1831 |
1832 int matrix_location = -1; | 1832 int matrix_location = -1; |
1833 int tex_scale_location = -1; | 1833 int tex_scale_location = -1; |
1834 int tex_offset_location = -1; | 1834 int tex_offset_location = -1; |
| 1835 int clamp_rect_location = -1; |
1835 int y_texture_location = -1; | 1836 int y_texture_location = -1; |
1836 int u_texture_location = -1; | 1837 int u_texture_location = -1; |
1837 int v_texture_location = -1; | 1838 int v_texture_location = -1; |
1838 int a_texture_location = -1; | 1839 int a_texture_location = -1; |
1839 int yuv_matrix_location = -1; | 1840 int yuv_matrix_location = -1; |
1840 int yuv_adj_location = -1; | 1841 int yuv_adj_location = -1; |
1841 int alpha_location = -1; | 1842 int alpha_location = -1; |
1842 if (use_alpha_plane) { | 1843 if (use_alpha_plane) { |
1843 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision); | 1844 const VideoYUVAProgram* program = GetVideoYUVAProgram(tex_coord_precision); |
1844 DCHECK(program && (program->initialized() || IsContextLost())); | 1845 DCHECK(program && (program->initialized() || IsContextLost())); |
1845 SetUseProgram(program->program()); | 1846 SetUseProgram(program->program()); |
1846 matrix_location = program->vertex_shader().matrix_location(); | 1847 matrix_location = program->vertex_shader().matrix_location(); |
1847 tex_scale_location = program->vertex_shader().tex_scale_location(); | 1848 tex_scale_location = program->vertex_shader().tex_scale_location(); |
1848 tex_offset_location = program->vertex_shader().tex_offset_location(); | 1849 tex_offset_location = program->vertex_shader().tex_offset_location(); |
1849 y_texture_location = program->fragment_shader().y_texture_location(); | 1850 y_texture_location = program->fragment_shader().y_texture_location(); |
1850 u_texture_location = program->fragment_shader().u_texture_location(); | 1851 u_texture_location = program->fragment_shader().u_texture_location(); |
1851 v_texture_location = program->fragment_shader().v_texture_location(); | 1852 v_texture_location = program->fragment_shader().v_texture_location(); |
1852 a_texture_location = program->fragment_shader().a_texture_location(); | 1853 a_texture_location = program->fragment_shader().a_texture_location(); |
1853 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); | 1854 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); |
1854 yuv_adj_location = program->fragment_shader().yuv_adj_location(); | 1855 yuv_adj_location = program->fragment_shader().yuv_adj_location(); |
| 1856 clamp_rect_location = program->fragment_shader().clamp_rect_location(); |
1855 alpha_location = program->fragment_shader().alpha_location(); | 1857 alpha_location = program->fragment_shader().alpha_location(); |
1856 } else { | 1858 } else { |
1857 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision); | 1859 const VideoYUVProgram* program = GetVideoYUVProgram(tex_coord_precision); |
1858 DCHECK(program && (program->initialized() || IsContextLost())); | 1860 DCHECK(program && (program->initialized() || IsContextLost())); |
1859 SetUseProgram(program->program()); | 1861 SetUseProgram(program->program()); |
1860 matrix_location = program->vertex_shader().matrix_location(); | 1862 matrix_location = program->vertex_shader().matrix_location(); |
1861 tex_scale_location = program->vertex_shader().tex_scale_location(); | 1863 tex_scale_location = program->vertex_shader().tex_scale_location(); |
1862 tex_offset_location = program->vertex_shader().tex_offset_location(); | 1864 tex_offset_location = program->vertex_shader().tex_offset_location(); |
1863 y_texture_location = program->fragment_shader().y_texture_location(); | 1865 y_texture_location = program->fragment_shader().y_texture_location(); |
1864 u_texture_location = program->fragment_shader().u_texture_location(); | 1866 u_texture_location = program->fragment_shader().u_texture_location(); |
1865 v_texture_location = program->fragment_shader().v_texture_location(); | 1867 v_texture_location = program->fragment_shader().v_texture_location(); |
1866 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); | 1868 yuv_matrix_location = program->fragment_shader().yuv_matrix_location(); |
1867 yuv_adj_location = program->fragment_shader().yuv_adj_location(); | 1869 yuv_adj_location = program->fragment_shader().yuv_adj_location(); |
| 1870 clamp_rect_location = program->fragment_shader().clamp_rect_location(); |
1868 alpha_location = program->fragment_shader().alpha_location(); | 1871 alpha_location = program->fragment_shader().alpha_location(); |
1869 } | 1872 } |
1870 | 1873 |
1871 GLC(gl_, | 1874 GLC(gl_, |
1872 gl_->Uniform2f(tex_scale_location, | 1875 gl_->Uniform2f(tex_scale_location, |
1873 quad->tex_coord_rect.width(), | 1876 quad->tex_coord_rect.width(), |
1874 quad->tex_coord_rect.height())); | 1877 quad->tex_coord_rect.height())); |
1875 GLC(gl_, | 1878 GLC(gl_, |
1876 gl_->Uniform2f(tex_offset_location, | 1879 gl_->Uniform2f(tex_offset_location, |
1877 quad->tex_coord_rect.x(), | 1880 quad->tex_coord_rect.x(), |
1878 quad->tex_coord_rect.y())); | 1881 quad->tex_coord_rect.y())); |
| 1882 // Clamping to half a texel inside the tex coord rect prevents bilinear |
| 1883 // filtering from filtering outside the tex coord rect. |
| 1884 gfx::RectF clamp_rect(quad->tex_coord_rect); |
| 1885 // Special case: empty texture size implies no clamping. |
| 1886 if (!quad->tex_size.IsEmpty()) { |
| 1887 clamp_rect.Inset(0.5f / quad->tex_size.width(), |
| 1888 0.5f / quad->tex_size.height()); |
| 1889 } |
| 1890 GLC(gl_, gl_->Uniform4f(clamp_rect_location, clamp_rect.x(), clamp_rect.y(), |
| 1891 clamp_rect.right(), clamp_rect.bottom())); |
| 1892 |
1879 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); | 1893 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); |
1880 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); | 1894 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); |
1881 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); | 1895 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); |
1882 if (use_alpha_plane) | 1896 if (use_alpha_plane) |
1883 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); | 1897 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); |
1884 | 1898 |
1885 // These values are magic numbers that are used in the transformation from YUV | 1899 // These values are magic numbers that are used in the transformation from YUV |
1886 // to RGB color values. They are taken from the following webpage: | 1900 // to RGB color values. They are taken from the following webpage: |
1887 // http://www.fourcc.org/fccyvrgb.php | 1901 // http://www.fourcc.org/fccyvrgb.php |
1888 float yuv_to_rgb_rec601[9] = { | 1902 float yuv_to_rgb_rec601[9] = { |
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3292 context_support_->ScheduleOverlayPlane( | 3306 context_support_->ScheduleOverlayPlane( |
3293 overlay.plane_z_order, | 3307 overlay.plane_z_order, |
3294 overlay.transform, | 3308 overlay.transform, |
3295 pending_overlay_resources_.back()->texture_id(), | 3309 pending_overlay_resources_.back()->texture_id(), |
3296 overlay.display_rect, | 3310 overlay.display_rect, |
3297 overlay.uv_rect); | 3311 overlay.uv_rect); |
3298 } | 3312 } |
3299 } | 3313 } |
3300 | 3314 |
3301 } // namespace cc | 3315 } // namespace cc |
OLD | NEW |