| 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 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 GLC(Context(), Context()->uniform1i(a_texture_location, 4)); | 1716 GLC(Context(), Context()->uniform1i(a_texture_location, 4)); |
| 1717 | 1717 |
| 1718 // These values are magic numbers that are used in the transformation from YUV | 1718 // These values are magic numbers that are used in the transformation from YUV |
| 1719 // to RGB color values. They are taken from the following webpage: | 1719 // to RGB color values. They are taken from the following webpage: |
| 1720 // http://www.fourcc.org/fccyvrgb.php | 1720 // http://www.fourcc.org/fccyvrgb.php |
| 1721 float yuv_to_rgb[9] = { | 1721 float yuv_to_rgb[9] = { |
| 1722 1.164f, 1.164f, 1.164f, | 1722 1.164f, 1.164f, 1.164f, |
| 1723 0.0f, -.391f, 2.018f, | 1723 0.0f, -.391f, 2.018f, |
| 1724 1.596f, -.813f, 0.0f, | 1724 1.596f, -.813f, 0.0f, |
| 1725 }; | 1725 }; |
| 1726 float yuv_to_rgb_jpeg[9] = { |
| 1727 1.f, 1.f, 1.f, |
| 1728 0.0f, -.34414f, 1.772f, |
| 1729 1.402f, -.71414, 0.0f, |
| 1730 }; |
| 1731 |
| 1726 GLC(Context(), | 1732 GLC(Context(), |
| 1727 Context()->uniformMatrix3fv(yuv_matrix_location, 1, 0, yuv_to_rgb)); | 1733 Context()->uniformMatrix3fv( |
| 1734 yuv_matrix_location, |
| 1735 1, |
| 1736 0, |
| 1737 quad->jpeg_color_range ? yuv_to_rgb_jpeg : yuv_to_rgb)); |
| 1728 | 1738 |
| 1729 // These values map to 16, 128, and 128 respectively, and are computed | 1739 // These values map to 16, 128, and 128 respectively, and are computed |
| 1730 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). | 1740 // as a fraction over 256 (e.g. 16 / 256 = 0.0625). |
| 1731 // They are used in the YUV to RGBA conversion formula: | 1741 // They are used in the YUV to RGBA conversion formula: |
| 1732 // Y - 16 : Gives 16 values of head and footroom for overshooting | 1742 // Y - 16 : Gives 16 values of head and footroom for overshooting |
| 1733 // U - 128 : Turns unsigned U into signed U [-128,127] | 1743 // U - 128 : Turns unsigned U into signed U [-128,127] |
| 1734 // V - 128 : Turns unsigned V into signed V [-128,127] | 1744 // V - 128 : Turns unsigned V into signed V [-128,127] |
| 1735 float yuv_adjust[3] = { -0.0625f, -0.5f, -0.5f, }; | 1745 float yuv_adjust[3] = { -0.0625f, -0.5f, -0.5f, }; |
| 1736 GLC(Context(), Context()->uniform3fv(yuv_adj_location, 1, yuv_adjust)); | |
| 1737 | 1746 |
| 1747 // Same as above, but without the head and footroom in Y. |
| 1748 float yuv_adjust_jpeg[3] = { 0.f, -0.5f, -0.5f, }; |
| 1749 |
| 1750 GLC(Context(), |
| 1751 Context()->uniform3fv( |
| 1752 yuv_adj_location, |
| 1753 1, |
| 1754 quad->jpeg_color_range ? yuv_adjust_jpeg : yuv_adjust)); |
| 1738 | 1755 |
| 1739 SetShaderOpacity(quad->opacity(), alpha_location); | 1756 SetShaderOpacity(quad->opacity(), alpha_location); |
| 1740 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); | 1757 DrawQuadGeometry(frame, quad->quadTransform(), quad->rect, matrix_location); |
| 1741 } | 1758 } |
| 1742 | 1759 |
| 1743 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, | 1760 void GLRenderer::DrawStreamVideoQuad(const DrawingFrame* frame, |
| 1744 const StreamVideoDrawQuad* quad) { | 1761 const StreamVideoDrawQuad* quad) { |
| 1745 SetBlendEnabled(quad->ShouldDrawWithBlending()); | 1762 SetBlendEnabled(quad->ShouldDrawWithBlending()); |
| 1746 | 1763 |
| 1747 static float gl_matrix[16]; | 1764 static float gl_matrix[16]; |
| (...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3172 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
| 3156 // implementation. | 3173 // implementation. |
| 3157 return gr_context_ && context_->getContextAttributes().stencil; | 3174 return gr_context_ && context_->getContextAttributes().stencil; |
| 3158 } | 3175 } |
| 3159 | 3176 |
| 3160 bool GLRenderer::IsContextLost() { | 3177 bool GLRenderer::IsContextLost() { |
| 3161 return output_surface_->context_provider()->IsContextLost(); | 3178 return output_surface_->context_provider()->IsContextLost(); |
| 3162 } | 3179 } |
| 3163 | 3180 |
| 3164 } // namespace cc | 3181 } // namespace cc |
| OLD | NEW |