Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc

Issue 2104003002: gpu, cmaa: blend color like bilinear filter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h" 5 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/service/framebuffer_manager.h" 8 #include "gpu/command_buffer/service/framebuffer_manager.h"
9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
10 #include "ui/gl/gl_context.h" 10 #include "ui/gl/gl_context.h"
(...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 // preserved when this is a part of a (zigzag) diagonal line as the 1516 // preserved when this is a part of a (zigzag) diagonal line as the
1517 // corners from the other side will do the same and take some of 1517 // corners from the other side will do the same and take some of
1518 // the current pixel's colour in return. 1518 // the current pixel's colour in return.
1519 // However, in the case when this is an actual corner, the pixel's 1519 // However, in the case when this is an actual corner, the pixel's
1520 // colour will be partially overwritten by it's 2 neighbours. 1520 // colour will be partially overwritten by it's 2 neighbours.
1521 if( numberOfEdges == 2.0 ) 1521 if( numberOfEdges == 2.0 )
1522 { 1522 {
1523 // with value of 0.15, the pixel will retain approx 77% of its 1523 // with value of 0.15, the pixel will retain approx 77% of its
1524 // colour and the remaining 23% will come from its 2 neighbours 1524 // colour and the remaining 23% will come from its 2 neighbours
1525 // (which are likely to be blurred too in the opposite direction) 1525 // (which are likely to be blurred too in the opposite direction)
1526 blurCoeff = 0.08; 1526 blurCoeff = 0.15;
1527 1527
1528 // Only do blending if it's L shape - if we're between two 1528 // Only do blending if it's L shape - if we're between two
1529 // parallel edges, don't do anything 1529 // parallel edges, don't do anything
1530 blurCoeff *= (1.0 - fromBelow * fromAbove) * 1530 blurCoeff *= (1.0 - fromBelow * fromAbove) *
1531 (1.0 - fromRight * fromLeft); 1531 (1.0 - fromRight * fromLeft);
1532 1532
1533 if (blurCoeff == 0.0) 1533 if (blurCoeff == 0.0)
1534 continue; 1534 continue;
1535 1535
1536 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)]; 1536 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)];
(...skipping 21 matching lines...) Expand all
1558 bool(packedEdgesB & 0x04u); 1558 bool(packedEdgesB & 0x04u);
1559 if (large_l1 || large_l2 || large_l3 || large_l4) 1559 if (large_l1 || large_l2 || large_l3 || large_l4)
1560 continue; 1560 continue;
1561 } 1561 }
1562 1562
1563 // 2.) U-like shape (surrounded with edges from 3 sides) 1563 // 2.) U-like shape (surrounded with edges from 3 sides)
1564 if (numberOfEdges == 3.0) { 1564 if (numberOfEdges == 3.0) {
1565 // with value of 0.13, the pixel will retain approx 72% of its 1565 // with value of 0.13, the pixel will retain approx 72% of its
1566 // colour and the remaining 28% will be picked from its 3 1566 // colour and the remaining 28% will be picked from its 3
1567 // neighbours (which are unlikely to be blurred too but could be) 1567 // neighbours (which are unlikely to be blurred too but could be)
1568 blurCoeff = 0.11; 1568 blurCoeff = 0.13;
1569 } 1569 }
1570 1570
1571 // 3.) Completely surrounded with edges from all 4 sides 1571 // 3.) Completely surrounded with edges from all 4 sides
1572 if (numberOfEdges == 4.0) { 1572 if (numberOfEdges == 4.0) {
1573 // with value of 0.07, the pixel will retain 78% of its colour 1573 // with value of 0.07, the pixel will retain 78% of its colour
1574 // and the remaining 22% will come from its 4 neighbours (which 1574 // and the remaining 22% will come from its 4 neighbours (which
1575 // are unlikely to be blurred) 1575 // are unlikely to be blurred)
1576 blurCoeff = 0.05; 1576 blurCoeff = 0.07;
1577 } 1577 }
1578 1578
1579 if (blurCoeff == 0.0) { 1579 if (blurCoeff == 0.0) {
1580 // this avoids Z search below as well but that's ok because a Z 1580 // this avoids Z search below as well but that's ok because a Z
1581 // shape will also always have some blurCoeff 1581 // shape will also always have some blurCoeff
1582 continue; 1582 continue;
1583 } 1583 }
1584 1584
1585 vec4 blurMap = xFroms * blurCoeff; 1585 vec4 blurMap = xFroms * blurCoeff;
1586 1586
(...skipping 11 matching lines...) Expand all
1598 // float fromBelowWeight = (1.0 / (1.0 - blurMap.x)) - 1.0; 1598 // float fromBelowWeight = (1.0 / (1.0 - blurMap.x)) - 1.0;
1599 // float fromAboveWeight = (1.0 / (1.0 - blurMap.y)) - 1.0; 1599 // float fromAboveWeight = (1.0 / (1.0 - blurMap.y)) - 1.0;
1600 // float fromRightWeight = (1.0 / (1.0 - blurMap.z)) - 1.0; 1600 // float fromRightWeight = (1.0 / (1.0 - blurMap.z)) - 1.0;
1601 // float fromLeftWeight = (1.0 / (1.0 - blurMap.w)) - 1.0; 1601 // float fromLeftWeight = (1.0 / (1.0 - blurMap.w)) - 1.0;
1602 1602
1603 float fourWeightSum = dot(blurMap, vec4(1, 1, 1, 1)); 1603 float fourWeightSum = dot(blurMap, vec4(1, 1, 1, 1));
1604 float allWeightSum = centerWeight + fourWeightSum; 1604 float allWeightSum = centerWeight + fourWeightSum;
1605 1605
1606 vec4 color = vec4(0, 0, 0, 0); 1606 vec4 color = vec4(0, 0, 0, 0);
1607 if (fromLeftWeight > 0.0) { 1607 if (fromLeftWeight > 0.0) {
1608 vec3 pixelL = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1608 vec4 pixelL = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1609 ivec2(-1, 0)).rgb; 1609 ivec2(-1, 0));
1610 color.rgb += fromLeftWeight * pixelL; 1610 color += fromLeftWeight * pixelL;
1611 } 1611 }
1612 if (fromAboveWeight > 0.0) { 1612 if (fromAboveWeight > 0.0) {
1613 vec3 pixelT = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1613 vec4 pixelT = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1614 ivec2(0, 1)).rgb; 1614 ivec2(0, 1));
1615 color.rgb += fromAboveWeight * pixelT; 1615 color += fromAboveWeight * pixelT;
1616 } 1616 }
1617 if (fromRightWeight > 0.0) { 1617 if (fromRightWeight > 0.0) {
1618 vec3 pixelR = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1618 vec4 pixelR = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1619 ivec2(1, 0)).rgb; 1619 ivec2(1, 0));
1620 color.rgb += fromRightWeight * pixelR; 1620 color += fromRightWeight * pixelR;
1621 } 1621 }
1622 if (fromBelowWeight > 0.0) { 1622 if (fromBelowWeight > 0.0) {
1623 vec3 pixelB = texelFetchOffset(g_screenTexture, screenPosI.xy, 0, 1623 vec4 pixelB = texelFetchOffset(g_screenTexture, screenPosI.xy, 0,
1624 ivec2(0, -1)).rgb; 1624 ivec2(0, -1));
1625 color.rgb += fromBelowWeight * pixelB; 1625 color += fromBelowWeight * pixelB;
1626 } 1626 }
1627 1627
1628 color /= fourWeightSum + 0.0001; 1628 color /= fourWeightSum + 0.0001;
1629 color.a = 1.0 - centerWeight / allWeightSum;
1630 1629
1631 color.rgb = mix(pixelC.rgb, color.rgb, color.a).rgb; 1630 color = mix(color, pixelC, centerWeight / allWeightSum);
1632 \n#ifdef IN_GAMMA_CORRECT_MODE\n 1631 \n#ifdef IN_GAMMA_CORRECT_MODE\n
1633 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb); 1632 color.rgb = D3DX_FLOAT3_to_SRGB(color.rgb);
1634 \n#endif\n 1633 \n#endif\n
1635 1634
1636 \n#ifdef DEBUG_OUTPUT_AAINFO\n 1635 \n#ifdef DEBUG_OUTPUT_AAINFO\n
1637 imageStore(g_resultTextureSlot2, screenPosI.xy, 1636 imageStore(g_resultTextureSlot2, screenPosI.xy,
1638 PackBlurAAInfo(screenPosI.xy, uint(numberOfEdges))); 1637 PackBlurAAInfo(screenPosI.xy, uint(numberOfEdges)));
1639 \n#endif\n 1638 \n#endif\n
1640 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy, 1639 imageStore(g_resultTextureFlt4Slot1, screenPosI.xy, color);
1641 vec4(color.rgb, pixelC.a));
1642 1640
1643 if (numberOfEdges == 2.0) { 1641 if (numberOfEdges == 2.0) {
1644 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)]; 1642 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)];
1645 uint packedEdgesB = packedEdgesArray[(1 + _x) * 4 + (0 + _y)]; 1643 uint packedEdgesB = packedEdgesArray[(1 + _x) * 4 + (0 + _y)];
1646 uint packedEdgesR = packedEdgesArray[(2 + _x) * 4 + (1 + _y)]; 1644 uint packedEdgesR = packedEdgesArray[(2 + _x) * 4 + (1 + _y)];
1647 uint packedEdgesT = packedEdgesArray[(1 + _x) * 4 + (2 + _y)]; 1645 uint packedEdgesT = packedEdgesArray[(1 + _x) * 4 + (2 + _y)];
1648 1646
1649 bool isHorizontalA = ((packedEdgesC) == (0x01u | 0x02u)) && 1647 bool isHorizontalA = ((packedEdgesC) == (0x01u | 0x02u)) &&
1650 ((packedEdgesR & 0x08u) == 0x08u); 1648 ((packedEdgesR & 0x08u) == 0x08u);
1651 bool isHorizontalB = ((packedEdgesC) == (0x01u | 0x08u)) && 1649 bool isHorizontalB = ((packedEdgesC) == (0x01u | 0x08u)) &&
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 \n#ifdef OUT_FBO\n 1866 \n#ifdef OUT_FBO\n
1869 outColor = pixel; 1867 outColor = pixel;
1870 \n#else\n 1868 \n#else\n
1871 imageStore(outTexture, screenPosI, pixel); 1869 imageStore(outTexture, screenPosI, pixel);
1872 \n#endif\n 1870 \n#endif\n
1873 } 1871 }
1874 ); 1872 );
1875 /* clang-format on */ 1873 /* clang-format on */
1876 1874
1877 } // namespace gpu 1875 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698