Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1486 int _y = _i / 2; | 1486 int _y = _i / 2; |
| 1487 | 1487 |
| 1488 ivec3 screenPosI = screenPosIBase + ivec3(_x, _y, 0); | 1488 ivec3 screenPosI = screenPosIBase + ivec3(_x, _y, 0); |
| 1489 | 1489 |
| 1490 uint packedEdgesC = packedEdgesArray[(1 + _x) * 4 + (1 + _y)]; | 1490 uint packedEdgesC = packedEdgesArray[(1 + _x) * 4 + (1 + _y)]; |
| 1491 | 1491 |
| 1492 uvec4 edges = UnpackEdge(packedEdgesC); | 1492 uvec4 edges = UnpackEdge(packedEdgesC); |
| 1493 vec4 edgesFlt = vec4(edges); | 1493 vec4 edgesFlt = vec4(edges); |
| 1494 | 1494 |
| 1495 float numberOfEdges = dot(edgesFlt, vec4(1, 1, 1, 1)); | 1495 float numberOfEdges = dot(edgesFlt, vec4(1, 1, 1, 1)); |
| 1496 if (numberOfEdges < 2.0) | 1496 if (numberOfEdges <= 1.0) |
| 1497 continue; | 1497 continue; |
| 1498 | 1498 |
| 1499 float fromRight = edgesFlt.r; | 1499 float fromRight = edgesFlt.r; |
| 1500 float fromAbove = edgesFlt.g; | 1500 float fromAbove = edgesFlt.g; |
| 1501 float fromLeft = edgesFlt.b; | 1501 float fromLeft = edgesFlt.b; |
| 1502 float fromBelow = edgesFlt.a; | 1502 float fromBelow = edgesFlt.a; |
| 1503 | 1503 |
| 1504 vec4 xFroms = vec4(fromBelow, fromAbove, fromRight, fromLeft); | 1504 vec4 xFroms = vec4(fromBelow, fromAbove, fromRight, fromLeft); |
| 1505 | 1505 |
| 1506 float blurCoeff = 0.0; | 1506 float blurCoeff = 0.0; |
| 1507 | 1507 |
| 1508 // These are additional blurs that complement the main line-based | 1508 // These are additional blurs that complement the main line-based |
| 1509 // blurring; Unlike line-based, these do not necessarily preserve | 1509 // blurring; Unlike line-based, these do not necessarily preserve |
| 1510 // the total amount of screen colour as they will take | 1510 // the total amount of screen colour as they will take |
| 1511 // neighbouring pixel colours and apply them to the one currently | 1511 // neighbouring pixel colours and apply them to the one currently |
| 1512 // processed. | 1512 // processed. |
| 1513 | 1513 |
| 1514 // 1.) L-like shape. | 1514 // 1.) L-like shape. |
| 1515 // For this shape, the total amount of screen colour will be | 1515 // For this shape, the total amount of screen colour will be |
| 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 > 1.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.08; |
| 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 | |
| 1533 if (blurCoeff == 0.0) | |
| 1534 continue; | |
| 1535 | |
| 1536 uint packedEdgesL = packedEdgesArray[(0 + _x) * 4 + (1 + _y)]; | |
| 1537 uint packedEdgesB = packedEdgesArray[(1 + _x) * 4 + (0 + _y)]; | |
| 1538 uint packedEdgesR = packedEdgesArray[(2 + _x) * 4 + (1 + _y)]; | |
| 1539 uint packedEdgesT = packedEdgesArray[(1 + _x) * 4 + (2 + _y)]; | |
| 1540 | |
| 1541 // Don't blend large L shape because it would be the intended shape | |
| 1542 // with high probability. e.g. rectangle | |
| 1543 // large_l1 large_l2 large_l3 large_l4 | |
| 1544 // _ _ | | _ _ | |
| 1545 // X| X| |X |X | |
| 1546 // | ¯¯¯¯ ¯¯¯¯ | | |
| 1547 bool large_l1 = (packedEdgesC == (0x01u | 0x02u)) && | |
| 1548 bool(packedEdgesL & 0x02u) && | |
| 1549 bool(packedEdgesB & 0x01u); | |
| 1550 bool large_l2 = (packedEdgesC == (0x01u | 0x08u)) && | |
| 1551 bool(packedEdgesL & 0x08u) && | |
| 1552 bool(packedEdgesT & 0x01u); | |
| 1553 bool large_l3 = (packedEdgesC == (0x04u | 0x08u)) && | |
| 1554 bool(packedEdgesR & 0x08u) && | |
| 1555 bool(packedEdgesT & 0x04u); | |
| 1556 bool large_l4 = (packedEdgesC == (0x02u | 0x04u)) && | |
| 1557 bool(packedEdgesR & 0x02u) && | |
| 1558 bool(packedEdgesB & 0x04u); | |
| 1559 if (large_l1 || large_l2 || large_l3 || large_l4) | |
| 1560 continue; | |
| 1532 } | 1561 } |
| 1533 | 1562 |
| 1534 // 2.) U-like shape (surrounded with edges from 3 sides) | 1563 // 2.) U-like shape (surrounded with edges from 3 sides) |
| 1535 if (numberOfEdges > 2.0) { | 1564 if (numberOfEdges == 3.0) { |
| 1536 // 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 |
| 1537 // colour and the remaining 28% will be picked from its 3 | 1566 // colour and the remaining 28% will be picked from its 3 |
| 1538 // neighbours (which are unlikely to be blurred too but could be) | 1567 // neighbours (which are unlikely to be blurred too but could be) |
| 1539 blurCoeff = 0.11; | 1568 blurCoeff = 0.11; |
| 1540 } | 1569 } |
| 1541 | 1570 |
| 1542 // 3.) Completely surrounded with edges from all 4 sides | 1571 // 3.) Completely surrounded with edges from all 4 sides |
| 1543 if (numberOfEdges > 3.0) { | 1572 if (numberOfEdges == 4.0) { |
| 1544 // 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 |
| 1545 // and the remaining 22% will come from its 4 neighbours (which | 1574 // and the remaining 22% will come from its 4 neighbours (which |
| 1546 // are unlikely to be blurred) | 1575 // are unlikely to be blurred) |
| 1547 blurCoeff = 0.05; | 1576 blurCoeff = 0.05; |
| 1548 } | 1577 } |
| 1549 | 1578 |
| 1550 if (blurCoeff == 0.0) { | 1579 if (blurCoeff == 0.0) { |
|
adrian.belgun
2016/06/29 10:42:27
Nit: this no longer needed. See line 1533.
dshwang
2016/06/29 12:22:10
That's right. Done, with new assertion comment.
| |
| 1551 // 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 |
| 1552 // shape will also always have some blurCoeff | 1581 // shape will also always have some blurCoeff |
| 1553 continue; | 1582 continue; |
| 1554 } | 1583 } |
| 1555 | 1584 |
| 1556 vec4 blurMap = xFroms * blurCoeff; | 1585 vec4 blurMap = xFroms * blurCoeff; |
| 1557 | 1586 |
| 1558 vec4 pixelC = texelFetch(g_screenTexture, screenPosI.xy, 0); | 1587 vec4 pixelC = texelFetch(g_screenTexture, screenPosI.xy, 0); |
| 1559 | 1588 |
| 1560 const float centerWeight = 1.0; | 1589 const float centerWeight = 1.0; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1839 \n#ifdef OUT_FBO\n | 1868 \n#ifdef OUT_FBO\n |
| 1840 outColor = pixel; | 1869 outColor = pixel; |
| 1841 \n#else\n | 1870 \n#else\n |
| 1842 imageStore(outTexture, screenPosI, pixel); | 1871 imageStore(outTexture, screenPosI, pixel); |
| 1843 \n#endif\n | 1872 \n#endif\n |
| 1844 } | 1873 } |
| 1845 ); | 1874 ); |
| 1846 /* clang-format on */ | 1875 /* clang-format on */ |
| 1847 | 1876 |
| 1848 } // namespace gpu | 1877 } // namespace gpu |
| OLD | NEW |