| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/shader.h" | 5 #include "cc/output/shader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return shader_string; | 137 return shader_string; |
| 138 default: | 138 default: |
| 139 NOTREACHED(); | 139 NOTREACHED(); |
| 140 break; | 140 break; |
| 141 } | 141 } |
| 142 return shader_string; | 142 return shader_string; |
| 143 } | 143 } |
| 144 | 144 |
| 145 } // namespace | 145 } // namespace |
| 146 | 146 |
| 147 ShaderLocations::ShaderLocations() { |
| 148 } |
| 149 |
| 147 TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context, | 150 TexCoordPrecision TexCoordPrecisionRequired(GLES2Interface* context, |
| 148 int* highp_threshold_cache, | 151 int* highp_threshold_cache, |
| 149 int highp_threshold_min, | 152 int highp_threshold_min, |
| 150 const gfx::Point& max_coordinate) { | 153 const gfx::Point& max_coordinate) { |
| 151 return TexCoordPrecisionRequired(context, | 154 return TexCoordPrecisionRequired(context, |
| 152 highp_threshold_cache, | 155 highp_threshold_cache, |
| 153 highp_threshold_min, | 156 highp_threshold_min, |
| 154 max_coordinate.x(), | 157 max_coordinate.x(), |
| 155 max_coordinate.y()); | 158 max_coordinate.y()); |
| 156 } | 159 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 void main() { | 343 void main() { |
| 341 int quad_index = int(a_index * 0.25); // NOLINT | 344 int quad_index = int(a_index * 0.25); // NOLINT |
| 342 gl_Position = matrix[quad_index] * a_position; | 345 gl_Position = matrix[quad_index] * a_position; |
| 343 TexCoordPrecision vec4 texTrans = texTransform[quad_index]; | 346 TexCoordPrecision vec4 texTrans = texTransform[quad_index]; |
| 344 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; | 347 v_texCoord = a_texCoord * texTrans.zw + texTrans.xy; |
| 345 v_alpha = opacity[int(a_index)]; // NOLINT | 348 v_alpha = opacity[int(a_index)]; // NOLINT |
| 346 } | 349 } |
| 347 }); | 350 }); |
| 348 } | 351 } |
| 349 | 352 |
| 353 void VertexShaderPosTexTransform::FillLocations( |
| 354 ShaderLocations* locations) const { |
| 355 locations->matrix = matrix_location(); |
| 356 locations->tex_transform = tex_transform_location(); |
| 357 } |
| 358 |
| 350 std::string VertexShaderPosTexIdentity::GetShaderString() const { | 359 std::string VertexShaderPosTexIdentity::GetShaderString() const { |
| 351 return VERTEX_SHADER(GetShaderHead(), GetShaderBody()); | 360 return VERTEX_SHADER(GetShaderHead(), GetShaderBody()); |
| 352 } | 361 } |
| 353 | 362 |
| 354 std::string VertexShaderPosTexIdentity::GetShaderHead() { | 363 std::string VertexShaderPosTexIdentity::GetShaderHead() { |
| 355 return SHADER0([]() { | 364 return SHADER0([]() { |
| 356 attribute vec4 a_position; | 365 attribute vec4 a_position; |
| 357 varying TexCoordPrecision vec2 v_texCoord; | 366 varying TexCoordPrecision vec2 v_texCoord; |
| 358 }); | 367 }); |
| 359 } | 368 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 dot(edge[2], screen_pos), dot(edge[3], screen_pos)) * | 562 dot(edge[2], screen_pos), dot(edge[3], screen_pos)) * |
| 554 gl_Position.w; | 563 gl_Position.w; |
| 555 edge_dist[1] = vec4(dot(edge[4], screen_pos), dot(edge[5], screen_pos), | 564 edge_dist[1] = vec4(dot(edge[4], screen_pos), dot(edge[5], screen_pos), |
| 556 dot(edge[6], screen_pos), dot(edge[7], screen_pos)) * | 565 dot(edge[6], screen_pos), dot(edge[7], screen_pos)) * |
| 557 gl_Position.w; | 566 gl_Position.w; |
| 558 v_texCoord = (pos.xy + vec2(0.5)) * texTrans.zw + texTrans.xy; | 567 v_texCoord = (pos.xy + vec2(0.5)) * texTrans.zw + texTrans.xy; |
| 559 } | 568 } |
| 560 }); | 569 }); |
| 561 } | 570 } |
| 562 | 571 |
| 572 void VertexShaderQuadTexTransformAA::FillLocations( |
| 573 ShaderLocations* locations) const { |
| 574 locations->quad = quad_location(); |
| 575 locations->edge = edge_location(); |
| 576 locations->viewport = viewport_location(); |
| 577 locations->matrix = matrix_location(); |
| 578 locations->tex_transform = tex_transform_location(); |
| 579 } |
| 580 |
| 581 |
| 563 VertexShaderTile::VertexShaderTile() | 582 VertexShaderTile::VertexShaderTile() |
| 564 : matrix_location_(-1), | 583 : matrix_location_(-1), |
| 565 quad_location_(-1), | 584 quad_location_(-1), |
| 566 vertex_tex_transform_location_(-1) { | 585 vertex_tex_transform_location_(-1) { |
| 567 } | 586 } |
| 568 | 587 |
| 569 void VertexShaderTile::Init(GLES2Interface* context, | 588 void VertexShaderTile::Init(GLES2Interface* context, |
| 570 unsigned program, | 589 unsigned program, |
| 571 int* base_uniform_index) { | 590 int* base_uniform_index) { |
| 572 static const char* uniforms[] = { | 591 static const char* uniforms[] = { |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 | 1117 |
| 1099 std::string FragmentShaderRGBATexAlpha::GetShaderBody() { | 1118 std::string FragmentShaderRGBATexAlpha::GetShaderBody() { |
| 1100 return SHADER0([]() { | 1119 return SHADER0([]() { |
| 1101 void main() { | 1120 void main() { |
| 1102 vec4 texColor = TextureLookup(s_texture, v_texCoord); | 1121 vec4 texColor = TextureLookup(s_texture, v_texCoord); |
| 1103 gl_FragColor = ApplyBlendMode(texColor * alpha); | 1122 gl_FragColor = ApplyBlendMode(texColor * alpha); |
| 1104 } | 1123 } |
| 1105 }); | 1124 }); |
| 1106 } | 1125 } |
| 1107 | 1126 |
| 1127 void FragmentShaderRGBATexAlpha::FillLocations( |
| 1128 ShaderLocations* locations) const { |
| 1129 locations->sampler = sampler_location(); |
| 1130 locations->alpha = alpha_location(); |
| 1131 locations->backdrop = backdrop_location(); |
| 1132 locations->backdrop_rect = backdrop_rect_location(); |
| 1133 } |
| 1134 |
| 1108 std::string FragmentShaderRGBATexColorMatrixAlpha::GetShaderString( | 1135 std::string FragmentShaderRGBATexColorMatrixAlpha::GetShaderString( |
| 1109 TexCoordPrecision precision, | 1136 TexCoordPrecision precision, |
| 1110 SamplerType sampler) const { | 1137 SamplerType sampler) const { |
| 1111 return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody()); | 1138 return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody()); |
| 1112 } | 1139 } |
| 1113 | 1140 |
| 1114 std::string FragmentShaderRGBATexColorMatrixAlpha::GetShaderHead() { | 1141 std::string FragmentShaderRGBATexColorMatrixAlpha::GetShaderHead() { |
| 1115 return SHADER0([]() { | 1142 return SHADER0([]() { |
| 1116 precision mediump float; | 1143 precision mediump float; |
| 1117 varying TexCoordPrecision vec2 v_texCoord; | 1144 varying TexCoordPrecision vec2 v_texCoord; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1129 float nonZeroAlpha = max(texColor.a, 0.00001); | 1156 float nonZeroAlpha = max(texColor.a, 0.00001); |
| 1130 texColor = vec4(texColor.rgb / nonZeroAlpha, nonZeroAlpha); | 1157 texColor = vec4(texColor.rgb / nonZeroAlpha, nonZeroAlpha); |
| 1131 texColor = colorMatrix * texColor + colorOffset; | 1158 texColor = colorMatrix * texColor + colorOffset; |
| 1132 texColor.rgb *= texColor.a; | 1159 texColor.rgb *= texColor.a; |
| 1133 texColor = clamp(texColor, 0.0, 1.0); | 1160 texColor = clamp(texColor, 0.0, 1.0); |
| 1134 gl_FragColor = ApplyBlendMode(texColor * alpha); | 1161 gl_FragColor = ApplyBlendMode(texColor * alpha); |
| 1135 } | 1162 } |
| 1136 }); | 1163 }); |
| 1137 } | 1164 } |
| 1138 | 1165 |
| 1166 void FragmentShaderRGBATexColorMatrixAlpha::FillLocations( |
| 1167 ShaderLocations* locations) const { |
| 1168 locations->sampler = sampler_location(); |
| 1169 locations->alpha = alpha_location(); |
| 1170 locations->color_matrix = color_matrix_location(); |
| 1171 locations->color_offset = color_offset_location(); |
| 1172 locations->backdrop = backdrop_location(); |
| 1173 locations->backdrop_rect = backdrop_rect_location(); |
| 1174 } |
| 1175 |
| 1139 std::string FragmentShaderRGBATexVaryingAlpha::GetShaderString( | 1176 std::string FragmentShaderRGBATexVaryingAlpha::GetShaderString( |
| 1140 TexCoordPrecision precision, | 1177 TexCoordPrecision precision, |
| 1141 SamplerType sampler) const { | 1178 SamplerType sampler) const { |
| 1142 return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody()); | 1179 return FRAGMENT_SHADER(GetShaderHead(), GetShaderBody()); |
| 1143 } | 1180 } |
| 1144 | 1181 |
| 1145 std::string FragmentShaderRGBATexVaryingAlpha::GetShaderHead() { | 1182 std::string FragmentShaderRGBATexVaryingAlpha::GetShaderHead() { |
| 1146 return SHADER0([]() { | 1183 return SHADER0([]() { |
| 1147 precision mediump float; | 1184 precision mediump float; |
| 1148 varying TexCoordPrecision vec2 v_texCoord; | 1185 varying TexCoordPrecision vec2 v_texCoord; |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1398 void main() { | 1435 void main() { |
| 1399 vec4 texColor = TextureLookup(s_texture, v_texCoord); | 1436 vec4 texColor = TextureLookup(s_texture, v_texCoord); |
| 1400 vec4 d4 = min(edge_dist[0], edge_dist[1]); | 1437 vec4 d4 = min(edge_dist[0], edge_dist[1]); |
| 1401 vec2 d2 = min(d4.xz, d4.yw); | 1438 vec2 d2 = min(d4.xz, d4.yw); |
| 1402 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); | 1439 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); |
| 1403 gl_FragColor = ApplyBlendMode(texColor * alpha * aa); | 1440 gl_FragColor = ApplyBlendMode(texColor * alpha * aa); |
| 1404 } | 1441 } |
| 1405 }); | 1442 }); |
| 1406 } | 1443 } |
| 1407 | 1444 |
| 1445 void FragmentShaderRGBATexAlphaAA::FillLocations( |
| 1446 ShaderLocations* locations) const { |
| 1447 locations->sampler = sampler_location(); |
| 1448 locations->alpha = alpha_location(); |
| 1449 locations->backdrop = backdrop_location(); |
| 1450 locations->backdrop_rect = backdrop_rect_location(); |
| 1451 } |
| 1452 |
| 1408 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() | 1453 FragmentTexClampAlphaAABinding::FragmentTexClampAlphaAABinding() |
| 1409 : sampler_location_(-1), | 1454 : sampler_location_(-1), |
| 1410 alpha_location_(-1), | 1455 alpha_location_(-1), |
| 1411 fragment_tex_transform_location_(-1) { | 1456 fragment_tex_transform_location_(-1) { |
| 1412 } | 1457 } |
| 1413 | 1458 |
| 1414 void FragmentTexClampAlphaAABinding::Init(GLES2Interface* context, | 1459 void FragmentTexClampAlphaAABinding::Init(GLES2Interface* context, |
| 1415 unsigned program, | 1460 unsigned program, |
| 1416 int* base_uniform_index) { | 1461 int* base_uniform_index) { |
| 1417 static const char* uniforms[] = { | 1462 static const char* uniforms[] = { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 vec4 texColor = texture2D(s_texture, v_texCoord); | 1598 vec4 texColor = texture2D(s_texture, v_texCoord); |
| 1554 TexCoordPrecision vec2 maskTexCoord = | 1599 TexCoordPrecision vec2 maskTexCoord = |
| 1555 vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, | 1600 vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, |
| 1556 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); | 1601 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| 1557 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); | 1602 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); |
| 1558 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w); | 1603 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w); |
| 1559 } | 1604 } |
| 1560 }); | 1605 }); |
| 1561 } | 1606 } |
| 1562 | 1607 |
| 1608 void FragmentShaderRGBATexAlphaMask::FillLocations( |
| 1609 ShaderLocations* locations) const { |
| 1610 locations->sampler = sampler_location(); |
| 1611 locations->mask_sampler = mask_sampler_location(); |
| 1612 locations->mask_tex_coord_scale = mask_tex_coord_scale_location(); |
| 1613 locations->mask_tex_coord_offset = mask_tex_coord_offset_location(); |
| 1614 locations->alpha = alpha_location(); |
| 1615 locations->backdrop = backdrop_location(); |
| 1616 locations->backdrop_rect = backdrop_rect_location(); |
| 1617 } |
| 1618 |
| 1563 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() | 1619 FragmentShaderRGBATexAlphaMaskAA::FragmentShaderRGBATexAlphaMaskAA() |
| 1564 : sampler_location_(-1), | 1620 : sampler_location_(-1), |
| 1565 mask_sampler_location_(-1), | 1621 mask_sampler_location_(-1), |
| 1566 alpha_location_(-1), | 1622 alpha_location_(-1), |
| 1567 mask_tex_coord_scale_location_(-1), | 1623 mask_tex_coord_scale_location_(-1), |
| 1568 mask_tex_coord_offset_location_(-1) { | 1624 mask_tex_coord_offset_location_(-1) { |
| 1569 } | 1625 } |
| 1570 | 1626 |
| 1571 void FragmentShaderRGBATexAlphaMaskAA::Init(GLES2Interface* context, | 1627 void FragmentShaderRGBATexAlphaMaskAA::Init(GLES2Interface* context, |
| 1572 unsigned program, | 1628 unsigned program, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); | 1679 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| 1624 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); | 1680 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); |
| 1625 vec4 d4 = min(edge_dist[0], edge_dist[1]); | 1681 vec4 d4 = min(edge_dist[0], edge_dist[1]); |
| 1626 vec2 d2 = min(d4.xz, d4.yw); | 1682 vec2 d2 = min(d4.xz, d4.yw); |
| 1627 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); | 1683 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); |
| 1628 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w * aa); | 1684 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w * aa); |
| 1629 } | 1685 } |
| 1630 }); | 1686 }); |
| 1631 } | 1687 } |
| 1632 | 1688 |
| 1689 void FragmentShaderRGBATexAlphaMaskAA::FillLocations( |
| 1690 ShaderLocations* locations) const { |
| 1691 locations->sampler = sampler_location(); |
| 1692 locations->mask_sampler = mask_sampler_location(); |
| 1693 locations->mask_tex_coord_scale = mask_tex_coord_scale_location(); |
| 1694 locations->mask_tex_coord_offset = mask_tex_coord_offset_location(); |
| 1695 locations->alpha = alpha_location(); |
| 1696 locations->backdrop = backdrop_location(); |
| 1697 locations->backdrop_rect = backdrop_rect_location(); |
| 1698 } |
| 1699 |
| 1633 FragmentShaderRGBATexAlphaMaskColorMatrixAA:: | 1700 FragmentShaderRGBATexAlphaMaskColorMatrixAA:: |
| 1634 FragmentShaderRGBATexAlphaMaskColorMatrixAA() | 1701 FragmentShaderRGBATexAlphaMaskColorMatrixAA() |
| 1635 : sampler_location_(-1), | 1702 : sampler_location_(-1), |
| 1636 mask_sampler_location_(-1), | 1703 mask_sampler_location_(-1), |
| 1637 alpha_location_(-1), | 1704 alpha_location_(-1), |
| 1638 mask_tex_coord_scale_location_(-1), | 1705 mask_tex_coord_scale_location_(-1), |
| 1639 color_matrix_location_(-1), | 1706 color_matrix_location_(-1), |
| 1640 color_offset_location_(-1) { | 1707 color_offset_location_(-1) { |
| 1641 } | 1708 } |
| 1642 | 1709 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); | 1774 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| 1708 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); | 1775 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); |
| 1709 vec4 d4 = min(edge_dist[0], edge_dist[1]); | 1776 vec4 d4 = min(edge_dist[0], edge_dist[1]); |
| 1710 vec2 d2 = min(d4.xz, d4.yw); | 1777 vec2 d2 = min(d4.xz, d4.yw); |
| 1711 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); | 1778 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); |
| 1712 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w * aa); | 1779 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w * aa); |
| 1713 } | 1780 } |
| 1714 }); | 1781 }); |
| 1715 } | 1782 } |
| 1716 | 1783 |
| 1784 void FragmentShaderRGBATexAlphaMaskColorMatrixAA::FillLocations( |
| 1785 ShaderLocations* locations) const { |
| 1786 locations->sampler = sampler_location(); |
| 1787 locations->alpha = alpha_location(); |
| 1788 locations->mask_sampler = mask_sampler_location(); |
| 1789 locations->mask_tex_coord_scale = mask_tex_coord_scale_location(); |
| 1790 locations->mask_tex_coord_offset = mask_tex_coord_offset_location(); |
| 1791 locations->color_matrix = color_matrix_location(); |
| 1792 locations->color_offset = color_offset_location(); |
| 1793 locations->backdrop = backdrop_location(); |
| 1794 locations->backdrop_rect = backdrop_rect_location(); |
| 1795 } |
| 1796 |
| 1717 FragmentShaderRGBATexAlphaColorMatrixAA:: | 1797 FragmentShaderRGBATexAlphaColorMatrixAA:: |
| 1718 FragmentShaderRGBATexAlphaColorMatrixAA() | 1798 FragmentShaderRGBATexAlphaColorMatrixAA() |
| 1719 : sampler_location_(-1), | 1799 : sampler_location_(-1), |
| 1720 alpha_location_(-1), | 1800 alpha_location_(-1), |
| 1721 color_matrix_location_(-1), | 1801 color_matrix_location_(-1), |
| 1722 color_offset_location_(-1) { | 1802 color_offset_location_(-1) { |
| 1723 } | 1803 } |
| 1724 | 1804 |
| 1725 void FragmentShaderRGBATexAlphaColorMatrixAA::Init(GLES2Interface* context, | 1805 void FragmentShaderRGBATexAlphaColorMatrixAA::Init(GLES2Interface* context, |
| 1726 unsigned program, | 1806 unsigned program, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 texColor.rgb *= texColor.a; | 1851 texColor.rgb *= texColor.a; |
| 1772 texColor = clamp(texColor, 0.0, 1.0); | 1852 texColor = clamp(texColor, 0.0, 1.0); |
| 1773 vec4 d4 = min(edge_dist[0], edge_dist[1]); | 1853 vec4 d4 = min(edge_dist[0], edge_dist[1]); |
| 1774 vec2 d2 = min(d4.xz, d4.yw); | 1854 vec2 d2 = min(d4.xz, d4.yw); |
| 1775 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); | 1855 float aa = clamp(gl_FragCoord.w * min(d2.x, d2.y), 0.0, 1.0); |
| 1776 gl_FragColor = ApplyBlendMode(texColor * alpha * aa); | 1856 gl_FragColor = ApplyBlendMode(texColor * alpha * aa); |
| 1777 } | 1857 } |
| 1778 }); | 1858 }); |
| 1779 } | 1859 } |
| 1780 | 1860 |
| 1861 void FragmentShaderRGBATexAlphaColorMatrixAA::FillLocations( |
| 1862 ShaderLocations* locations) const { |
| 1863 locations->sampler = sampler_location(); |
| 1864 locations->alpha = alpha_location(); |
| 1865 locations->color_matrix = color_matrix_location(); |
| 1866 locations->color_offset = color_offset_location(); |
| 1867 locations->backdrop = backdrop_location(); |
| 1868 locations->backdrop_rect = backdrop_rect_location(); |
| 1869 } |
| 1870 |
| 1781 FragmentShaderRGBATexAlphaMaskColorMatrix:: | 1871 FragmentShaderRGBATexAlphaMaskColorMatrix:: |
| 1782 FragmentShaderRGBATexAlphaMaskColorMatrix() | 1872 FragmentShaderRGBATexAlphaMaskColorMatrix() |
| 1783 : sampler_location_(-1), | 1873 : sampler_location_(-1), |
| 1784 mask_sampler_location_(-1), | 1874 mask_sampler_location_(-1), |
| 1785 alpha_location_(-1), | 1875 alpha_location_(-1), |
| 1786 mask_tex_coord_scale_location_(-1) { | 1876 mask_tex_coord_scale_location_(-1) { |
| 1787 } | 1877 } |
| 1788 | 1878 |
| 1789 void FragmentShaderRGBATexAlphaMaskColorMatrix::Init(GLES2Interface* context, | 1879 void FragmentShaderRGBATexAlphaMaskColorMatrix::Init(GLES2Interface* context, |
| 1790 unsigned program, | 1880 unsigned program, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 texColor = clamp(texColor, 0.0, 1.0); | 1938 texColor = clamp(texColor, 0.0, 1.0); |
| 1849 TexCoordPrecision vec2 maskTexCoord = | 1939 TexCoordPrecision vec2 maskTexCoord = |
| 1850 vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, | 1940 vec2(maskTexCoordOffset.x + v_texCoord.x * maskTexCoordScale.x, |
| 1851 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); | 1941 maskTexCoordOffset.y + v_texCoord.y * maskTexCoordScale.y); |
| 1852 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); | 1942 vec4 maskColor = TextureLookup(s_mask, maskTexCoord); |
| 1853 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w); | 1943 gl_FragColor = ApplyBlendMode(texColor * alpha * maskColor.w); |
| 1854 } | 1944 } |
| 1855 }); | 1945 }); |
| 1856 } | 1946 } |
| 1857 | 1947 |
| 1948 void FragmentShaderRGBATexAlphaMaskColorMatrix::FillLocations( |
| 1949 ShaderLocations* locations) const { |
| 1950 locations->sampler = sampler_location(); |
| 1951 locations->mask_sampler = mask_sampler_location(); |
| 1952 locations->mask_tex_coord_scale = mask_tex_coord_scale_location(); |
| 1953 locations->mask_tex_coord_offset = mask_tex_coord_offset_location(); |
| 1954 locations->alpha = alpha_location(); |
| 1955 locations->color_matrix = color_matrix_location(); |
| 1956 locations->color_offset = color_offset_location(); |
| 1957 locations->backdrop = backdrop_location(); |
| 1958 locations->backdrop_rect = backdrop_rect_location(); |
| 1959 } |
| 1960 |
| 1858 FragmentShaderYUVVideo::FragmentShaderYUVVideo() | 1961 FragmentShaderYUVVideo::FragmentShaderYUVVideo() |
| 1859 : y_texture_location_(-1), | 1962 : y_texture_location_(-1), |
| 1860 u_texture_location_(-1), | 1963 u_texture_location_(-1), |
| 1861 v_texture_location_(-1), | 1964 v_texture_location_(-1), |
| 1862 alpha_location_(-1), | 1965 alpha_location_(-1), |
| 1863 yuv_matrix_location_(-1), | 1966 yuv_matrix_location_(-1), |
| 1864 yuv_adj_location_(-1), | 1967 yuv_adj_location_(-1), |
| 1865 clamp_rect_location_(-1) { | 1968 clamp_rect_location_(-1) { |
| 1866 } | 1969 } |
| 1867 | 1970 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2140 vec2 texCoord = | 2243 vec2 texCoord = |
| 2141 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; | 2244 clamp(v_texCoord, 0.0, 1.0) * texTransform.zw + texTransform.xy; |
| 2142 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); | 2245 vec2 coord = mod(floor(texCoord * frequency * 2.0), 2.0); |
| 2143 float picker = abs(coord.x - coord.y); // NOLINT | 2246 float picker = abs(coord.x - coord.y); // NOLINT |
| 2144 gl_FragColor = mix(color1, color2, picker) * alpha; | 2247 gl_FragColor = mix(color1, color2, picker) * alpha; |
| 2145 } | 2248 } |
| 2146 }); | 2249 }); |
| 2147 } | 2250 } |
| 2148 | 2251 |
| 2149 } // namespace cc | 2252 } // namespace cc |
| OLD | NEW |