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 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1770 quad->tex_coord_rect.y())); | 1770 quad->tex_coord_rect.y())); |
1771 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); | 1771 GLC(gl_, gl_->Uniform1i(y_texture_location, 1)); |
1772 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); | 1772 GLC(gl_, gl_->Uniform1i(u_texture_location, 2)); |
1773 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); | 1773 GLC(gl_, gl_->Uniform1i(v_texture_location, 3)); |
1774 if (use_alpha_plane) | 1774 if (use_alpha_plane) |
1775 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); | 1775 GLC(gl_, gl_->Uniform1i(a_texture_location, 4)); |
1776 | 1776 |
1777 // These values are magic numbers that are used in the transformation from YUV | 1777 // These values are magic numbers that are used in the transformation from YUV |
1778 // to RGB color values. They are taken from the following webpage: | 1778 // to RGB color values. They are taken from the following webpage: |
1779 // http://www.fourcc.org/fccyvrgb.php | 1779 // http://www.fourcc.org/fccyvrgb.php |
1780 float yuv_to_rgb[9] = {1.164f, 1.164f, 1.164f, 0.0f, -.391f, | 1780 float yuv_to_rgb_rec601[9] = { |
rileya (GONE FROM CHROMIUM)
2014/05/01 23:25:09
Is there a header these might be better off being
piman
2014/05/02 00:37:28
I don't think one exists. We could create one, pos
| |
1781 2.018f, 1.596f, -.813f, 0.0f, }; | 1781 1.164f, 1.164f, 1.164f, 0.0f, -.391f, 2.018f, 1.596f, -.813f, 0.0f, |
1782 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); | 1782 }; |
1783 float yuv_to_rgb_rec601_jpeg[9] = { | |
1784 1.f, 1.f, 1.f, 0.0f, -.34414f, 1.772f, 1.402f, -.71414, 0.0f, | |
fbarchard
2014/05/02 02:39:29
FYI I found fourcc sometimes inconsistent with oth
| |
1785 }; | |
1783 | 1786 |
1784 // These values map to 16, 128, and 128 respectively, and are computed | 1787 // These values map to 16, 128, and 128 respectively, and are computed |
1785 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). | 1788 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). |
1786 // They are used in the YUV to RGBA conversion formula: | 1789 // They are used in the YUV to RGBA conversion formula: |
1787 // Y - 16 : Gives 16 values of head and footroom for overshooting | 1790 // Y - 16 : Gives 16 values of head and footroom for overshooting |
1788 // U - 128 : Turns unsigned U into signed U [-128,127] | 1791 // U - 128 : Turns unsigned U into signed U [-128,127] |
1789 // V - 128 : Turns unsigned V into signed V [-128,127] | 1792 // V - 128 : Turns unsigned V into signed V [-128,127] |
1790 float yuv_adjust[3] = {-0.0625f, -0.5f, -0.5f, }; | 1793 float yuv_adjust_rec601[3] = { |
1794 -0.0625f, -0.5f, -0.5f, | |
1795 }; | |
1796 | |
1797 // Same as above, but without the head and footroom. | |
1798 float yuv_adjust_rec601_jpeg[3] = { | |
1799 0.0f, -0.5f, -0.5f, | |
1800 }; | |
1801 | |
1802 float* yuv_to_rgb; | |
1803 float* yuv_adjust; | |
piman
2014/05/02 00:37:28
nit: initialize both.
| |
1804 | |
1805 switch (quad->color_space) { | |
1806 case YUVVideoDrawQuad::kRec601: | |
1807 yuv_to_rgb = yuv_to_rgb_rec601; | |
1808 yuv_adjust = yuv_adjust_rec601; | |
1809 break; | |
1810 case YUVVideoDrawQuad::kRec601_Jpeg: | |
1811 yuv_to_rgb = yuv_to_rgb_rec601_jpeg; | |
1812 yuv_adjust = yuv_adjust_rec601_jpeg; | |
1813 break; | |
1814 default: | |
piman
2014/05/02 00:37:28
nit: skip the default case, relying instead on com
| |
1815 NOTREACHED(); | |
1816 } | |
1817 | |
1818 GLC(gl_, gl_->UniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); | |
1791 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); | 1819 GLC(gl_, gl_->Uniform3fv(yuv_adj_location, 1, yuv_adjust)); |
1792 | 1820 |
1793 SetShaderOpacity(quad->opacity(), alpha_location); | 1821 SetShaderOpacity(quad->opacity(), alpha_location); |
1794 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); | 1822 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); |
1795 } | 1823 } |
1796 | 1824 |
1797 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, | 1825 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, |
1798 const StreamVideoDrawQuad* quad) { | 1826 const StreamVideoDrawQuad* quad) { |
1799 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1827 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
1800 | 1828 |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3195 context_support_->ScheduleOverlayPlane( | 3223 context_support_->ScheduleOverlayPlane( |
3196 overlay.plane_z_order, | 3224 overlay.plane_z_order, |
3197 overlay.transform, | 3225 overlay.transform, |
3198 pending_overlay_resources_.back()->texture_id(), | 3226 pending_overlay_resources_.back()->texture_id(), |
3199 overlay.display_rect, | 3227 overlay.display_rect, |
3200 overlay.uv_rect); | 3228 overlay.uv_rect); |
3201 } | 3229 } |
3202 } | 3230 } |
3203 | 3231 |
3204 } // namespace cc | 3232 } // namespace cc |
OLD | NEW |