| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "platform/graphics/gpu/WebGLImageConversion.h" | 5 #include "platform/graphics/gpu/WebGLImageConversion.h" |
| 6 | 6 |
| 7 #include "platform/CheckedInt.h" | 7 #include "platform/CheckedInt.h" |
| 8 #include "platform/graphics/ImageObserver.h" | 8 #include "platform/graphics/ImageObserver.h" |
| 9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" | 9 #include "platform/graphics/cpu/arm/WebGLImageConversionNEON.h" |
| 10 #include "platform/graphics/cpu/mips/WebGLImageConversionMSA.h" | 10 #include "platform/graphics/cpu/mips/WebGLImageConversionMSA.h" |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 || format == WebGLImageConversion::DataFormatR8_S | 1428 || format == WebGLImageConversion::DataFormatR8_S |
| 1429 || format == WebGLImageConversion::DataFormatR16 | 1429 || format == WebGLImageConversion::DataFormatR16 |
| 1430 || format == WebGLImageConversion::DataFormatR16_S | 1430 || format == WebGLImageConversion::DataFormatR16_S |
| 1431 || format == WebGLImageConversion::DataFormatR32 | 1431 || format == WebGLImageConversion::DataFormatR32 |
| 1432 || format == WebGLImageConversion::DataFormatR32_S; | 1432 || format == WebGLImageConversion::DataFormatR32_S; |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 template<int Format> | 1435 template<int Format> |
| 1436 struct IsInt8Format { | 1436 struct IsInt8Format { |
| 1437 STATIC_ONLY(IsInt8Format); | 1437 STATIC_ONLY(IsInt8Format); |
| 1438 static const bool Value = | 1438 static const bool value = |
| 1439 Format == WebGLImageConversion::DataFormatRGBA8_S | 1439 Format == WebGLImageConversion::DataFormatRGBA8_S |
| 1440 || Format == WebGLImageConversion::DataFormatRGB8_S | 1440 || Format == WebGLImageConversion::DataFormatRGB8_S |
| 1441 || Format == WebGLImageConversion::DataFormatRG8_S | 1441 || Format == WebGLImageConversion::DataFormatRG8_S |
| 1442 || Format == WebGLImageConversion::DataFormatR8_S; | 1442 || Format == WebGLImageConversion::DataFormatR8_S; |
| 1443 }; | 1443 }; |
| 1444 | 1444 |
| 1445 template<int Format> | 1445 template<int Format> |
| 1446 struct IsInt16Format { | 1446 struct IsInt16Format { |
| 1447 STATIC_ONLY(IsInt16Format); | 1447 STATIC_ONLY(IsInt16Format); |
| 1448 static const bool Value = | 1448 static const bool value = |
| 1449 Format == WebGLImageConversion::DataFormatRGBA16_S | 1449 Format == WebGLImageConversion::DataFormatRGBA16_S |
| 1450 || Format == WebGLImageConversion::DataFormatRGB16_S | 1450 || Format == WebGLImageConversion::DataFormatRGB16_S |
| 1451 || Format == WebGLImageConversion::DataFormatRG16_S | 1451 || Format == WebGLImageConversion::DataFormatRG16_S |
| 1452 || Format == WebGLImageConversion::DataFormatR16_S; | 1452 || Format == WebGLImageConversion::DataFormatR16_S; |
| 1453 }; | 1453 }; |
| 1454 | 1454 |
| 1455 template<int Format> | 1455 template<int Format> |
| 1456 struct IsInt32Format { | 1456 struct IsInt32Format { |
| 1457 STATIC_ONLY(IsInt32Format); | 1457 STATIC_ONLY(IsInt32Format); |
| 1458 static const bool Value = | 1458 static const bool value = |
| 1459 Format == WebGLImageConversion::DataFormatRGBA32_S | 1459 Format == WebGLImageConversion::DataFormatRGBA32_S |
| 1460 || Format == WebGLImageConversion::DataFormatRGB32_S | 1460 || Format == WebGLImageConversion::DataFormatRGB32_S |
| 1461 || Format == WebGLImageConversion::DataFormatRG32_S | 1461 || Format == WebGLImageConversion::DataFormatRG32_S |
| 1462 || Format == WebGLImageConversion::DataFormatR32_S; | 1462 || Format == WebGLImageConversion::DataFormatR32_S; |
| 1463 }; | 1463 }; |
| 1464 | 1464 |
| 1465 template<int Format> | 1465 template<int Format> |
| 1466 struct IsUInt8Format { | 1466 struct IsUInt8Format { |
| 1467 STATIC_ONLY(IsUInt8Format); | 1467 STATIC_ONLY(IsUInt8Format); |
| 1468 static const bool Value = | 1468 static const bool value = |
| 1469 Format == WebGLImageConversion::DataFormatRGBA8 | 1469 Format == WebGLImageConversion::DataFormatRGBA8 |
| 1470 || Format == WebGLImageConversion::DataFormatRGB8 | 1470 || Format == WebGLImageConversion::DataFormatRGB8 |
| 1471 || Format == WebGLImageConversion::DataFormatRG8 | 1471 || Format == WebGLImageConversion::DataFormatRG8 |
| 1472 || Format == WebGLImageConversion::DataFormatR8 | 1472 || Format == WebGLImageConversion::DataFormatR8 |
| 1473 || Format == WebGLImageConversion::DataFormatBGRA8 | 1473 || Format == WebGLImageConversion::DataFormatBGRA8 |
| 1474 || Format == WebGLImageConversion::DataFormatBGR8 | 1474 || Format == WebGLImageConversion::DataFormatBGR8 |
| 1475 || Format == WebGLImageConversion::DataFormatARGB8 | 1475 || Format == WebGLImageConversion::DataFormatARGB8 |
| 1476 || Format == WebGLImageConversion::DataFormatABGR8 | 1476 || Format == WebGLImageConversion::DataFormatABGR8 |
| 1477 || Format == WebGLImageConversion::DataFormatRA8 | 1477 || Format == WebGLImageConversion::DataFormatRA8 |
| 1478 || Format == WebGLImageConversion::DataFormatAR8 | 1478 || Format == WebGLImageConversion::DataFormatAR8 |
| 1479 || Format == WebGLImageConversion::DataFormatA8; | 1479 || Format == WebGLImageConversion::DataFormatA8; |
| 1480 }; | 1480 }; |
| 1481 | 1481 |
| 1482 template<int Format> | 1482 template<int Format> |
| 1483 struct IsUInt16Format { | 1483 struct IsUInt16Format { |
| 1484 STATIC_ONLY(IsUInt16Format); | 1484 STATIC_ONLY(IsUInt16Format); |
| 1485 static const bool Value = | 1485 static const bool value = |
| 1486 Format == WebGLImageConversion::DataFormatRGBA16 | 1486 Format == WebGLImageConversion::DataFormatRGBA16 |
| 1487 || Format == WebGLImageConversion::DataFormatRGB16 | 1487 || Format == WebGLImageConversion::DataFormatRGB16 |
| 1488 || Format == WebGLImageConversion::DataFormatRG16 | 1488 || Format == WebGLImageConversion::DataFormatRG16 |
| 1489 || Format == WebGLImageConversion::DataFormatR16; | 1489 || Format == WebGLImageConversion::DataFormatR16; |
| 1490 }; | 1490 }; |
| 1491 | 1491 |
| 1492 template<int Format> | 1492 template<int Format> |
| 1493 struct IsUInt32Format { | 1493 struct IsUInt32Format { |
| 1494 STATIC_ONLY(IsUInt32Format); | 1494 STATIC_ONLY(IsUInt32Format); |
| 1495 static const bool Value = | 1495 static const bool value = |
| 1496 Format == WebGLImageConversion::DataFormatRGBA32 | 1496 Format == WebGLImageConversion::DataFormatRGBA32 |
| 1497 || Format == WebGLImageConversion::DataFormatRGB32 | 1497 || Format == WebGLImageConversion::DataFormatRGB32 |
| 1498 || Format == WebGLImageConversion::DataFormatRG32 | 1498 || Format == WebGLImageConversion::DataFormatRG32 |
| 1499 || Format == WebGLImageConversion::DataFormatR32; | 1499 || Format == WebGLImageConversion::DataFormatR32; |
| 1500 }; | 1500 }; |
| 1501 | 1501 |
| 1502 template<int Format> | 1502 template<int Format> |
| 1503 struct IsFloatFormat { | 1503 struct IsFloatFormat { |
| 1504 STATIC_ONLY(IsFloatFormat); | 1504 STATIC_ONLY(IsFloatFormat); |
| 1505 static const bool Value = | 1505 static const bool value = |
| 1506 Format == WebGLImageConversion::DataFormatRGBA32F | 1506 Format == WebGLImageConversion::DataFormatRGBA32F |
| 1507 || Format == WebGLImageConversion::DataFormatRGB32F | 1507 || Format == WebGLImageConversion::DataFormatRGB32F |
| 1508 || Format == WebGLImageConversion::DataFormatRA32F | 1508 || Format == WebGLImageConversion::DataFormatRA32F |
| 1509 || Format == WebGLImageConversion::DataFormatR32F | 1509 || Format == WebGLImageConversion::DataFormatR32F |
| 1510 || Format == WebGLImageConversion::DataFormatA32F | 1510 || Format == WebGLImageConversion::DataFormatA32F |
| 1511 || Format == WebGLImageConversion::DataFormatRG32F; | 1511 || Format == WebGLImageConversion::DataFormatRG32F; |
| 1512 }; | 1512 }; |
| 1513 | 1513 |
| 1514 template<int Format> | 1514 template<int Format> |
| 1515 struct IsHalfFloatFormat { | 1515 struct IsHalfFloatFormat { |
| 1516 STATIC_ONLY(IsHalfFloatFormat); | 1516 STATIC_ONLY(IsHalfFloatFormat); |
| 1517 static const bool Value = | 1517 static const bool value = |
| 1518 Format == WebGLImageConversion::DataFormatRGBA16F | 1518 Format == WebGLImageConversion::DataFormatRGBA16F |
| 1519 || Format == WebGLImageConversion::DataFormatRGB16F | 1519 || Format == WebGLImageConversion::DataFormatRGB16F |
| 1520 || Format == WebGLImageConversion::DataFormatRA16F | 1520 || Format == WebGLImageConversion::DataFormatRA16F |
| 1521 || Format == WebGLImageConversion::DataFormatR16F | 1521 || Format == WebGLImageConversion::DataFormatR16F |
| 1522 || Format == WebGLImageConversion::DataFormatA16F | 1522 || Format == WebGLImageConversion::DataFormatA16F |
| 1523 || Format == WebGLImageConversion::DataFormatRG16F; | 1523 || Format == WebGLImageConversion::DataFormatRG16F; |
| 1524 }; | 1524 }; |
| 1525 | 1525 |
| 1526 template<int Format> | 1526 template<int Format> |
| 1527 struct Is32bppFormat { | 1527 struct Is32bppFormat { |
| 1528 STATIC_ONLY(Is32bppFormat); | 1528 STATIC_ONLY(Is32bppFormat); |
| 1529 static const bool Value = | 1529 static const bool value = |
| 1530 Format == WebGLImageConversion::DataFormatRGBA2_10_10_10 | 1530 Format == WebGLImageConversion::DataFormatRGBA2_10_10_10 |
| 1531 || Format == WebGLImageConversion::DataFormatRGB5999 | 1531 || Format == WebGLImageConversion::DataFormatRGB5999 |
| 1532 || Format == WebGLImageConversion::DataFormatRGB10F11F11F; | 1532 || Format == WebGLImageConversion::DataFormatRGB10F11F11F; |
| 1533 }; | 1533 }; |
| 1534 | 1534 |
| 1535 template<int Format> | 1535 template<int Format> |
| 1536 struct Is16bppFormat { | 1536 struct Is16bppFormat { |
| 1537 STATIC_ONLY(Is16bppFormat); | 1537 STATIC_ONLY(Is16bppFormat); |
| 1538 static const bool Value = | 1538 static const bool value = |
| 1539 Format == WebGLImageConversion::DataFormatRGBA5551 | 1539 Format == WebGLImageConversion::DataFormatRGBA5551 |
| 1540 || Format == WebGLImageConversion::DataFormatRGBA4444 | 1540 || Format == WebGLImageConversion::DataFormatRGBA4444 |
| 1541 || Format == WebGLImageConversion::DataFormatRGB565; | 1541 || Format == WebGLImageConversion::DataFormatRGB565; |
| 1542 }; | 1542 }; |
| 1543 | 1543 |
| 1544 template<int Format, | 1544 template<int Format, |
| 1545 bool IsInt8Format = IsInt8Format<Format>::Value, | 1545 bool IsInt8Format = IsInt8Format<Format>::value, |
| 1546 bool IsUInt8Format = IsUInt8Format<Format>::Value, | 1546 bool IsUInt8Format = IsUInt8Format<Format>::value, |
| 1547 bool IsInt16Format = IsInt16Format<Format>::Value, | 1547 bool IsInt16Format = IsInt16Format<Format>::value, |
| 1548 bool IsUInt16Format = IsUInt16Format<Format>::Value, | 1548 bool IsUInt16Format = IsUInt16Format<Format>::value, |
| 1549 bool IsInt32Format = IsInt32Format<Format>::Value, | 1549 bool IsInt32Format = IsInt32Format<Format>::value, |
| 1550 bool IsUInt32Format = IsUInt32Format<Format>::Value, | 1550 bool IsUInt32Format = IsUInt32Format<Format>::value, |
| 1551 bool IsFloat = IsFloatFormat<Format>::Value, | 1551 bool IsFloat = IsFloatFormat<Format>::value, |
| 1552 bool IsHalfFloat = IsHalfFloatFormat<Format>::Value, | 1552 bool IsHalfFloat = IsHalfFloatFormat<Format>::value, |
| 1553 bool Is16bpp = Is16bppFormat<Format>::Value, | 1553 bool Is16bpp = Is16bppFormat<Format>::value, |
| 1554 bool Is32bpp = Is32bppFormat<Format>::Value> | 1554 bool Is32bpp = Is32bppFormat<Format>::value> |
| 1555 struct DataTypeForFormat { | 1555 struct DataTypeForFormat { |
| 1556 STATIC_ONLY(DataTypeForFormat); | 1556 STATIC_ONLY(DataTypeForFormat); |
| 1557 typedef double Type; // Use a type that's not used in unpack/pack. | 1557 typedef double Type; // Use a type that's not used in unpack/pack. |
| 1558 }; | 1558 }; |
| 1559 | 1559 |
| 1560 template<int Format> | 1560 template<int Format> |
| 1561 struct DataTypeForFormat<Format, true, false, false, false, false, false, false,
false, false, false> { | 1561 struct DataTypeForFormat<Format, true, false, false, false, false, false, false,
false, false, false> { |
| 1562 STATIC_ONLY(DataTypeForFormat); | 1562 STATIC_ONLY(DataTypeForFormat); |
| 1563 typedef int8_t Type; | 1563 typedef int8_t Type; |
| 1564 }; | 1564 }; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 | 1613 |
| 1614 template<int Format> | 1614 template<int Format> |
| 1615 struct DataTypeForFormat<Format, false, false, false, false, false, false, false
, false, false, true> { | 1615 struct DataTypeForFormat<Format, false, false, false, false, false, false, false
, false, false, true> { |
| 1616 STATIC_ONLY(DataTypeForFormat); | 1616 STATIC_ONLY(DataTypeForFormat); |
| 1617 typedef uint32_t Type; | 1617 typedef uint32_t Type; |
| 1618 }; | 1618 }; |
| 1619 | 1619 |
| 1620 template<int Format> | 1620 template<int Format> |
| 1621 struct UsesFloatIntermediateFormat { | 1621 struct UsesFloatIntermediateFormat { |
| 1622 STATIC_ONLY(UsesFloatIntermediateFormat); | 1622 STATIC_ONLY(UsesFloatIntermediateFormat); |
| 1623 static const bool Value = | 1623 static const bool value = |
| 1624 IsFloatFormat<Format>::Value | 1624 IsFloatFormat<Format>::value |
| 1625 || IsHalfFloatFormat<Format>::Value | 1625 || IsHalfFloatFormat<Format>::value |
| 1626 || Format == WebGLImageConversion::DataFormatRGBA2_10_10_10 | 1626 || Format == WebGLImageConversion::DataFormatRGBA2_10_10_10 |
| 1627 || Format == WebGLImageConversion::DataFormatRGB10F11F11F | 1627 || Format == WebGLImageConversion::DataFormatRGB10F11F11F |
| 1628 || Format == WebGLImageConversion::DataFormatRGB5999; | 1628 || Format == WebGLImageConversion::DataFormatRGB5999; |
| 1629 }; | 1629 }; |
| 1630 | 1630 |
| 1631 template<int Format> | 1631 template<int Format> |
| 1632 struct IntermediateFormat { | 1632 struct IntermediateFormat { |
| 1633 STATIC_ONLY(IntermediateFormat); | 1633 STATIC_ONLY(IntermediateFormat); |
| 1634 static const int Value = | 1634 static const int value = |
| 1635 UsesFloatIntermediateFormat<Format>::Value ? WebGLImageConversion::DataF
ormatRGBA32F | 1635 UsesFloatIntermediateFormat<Format>::value ? WebGLImageConversion::DataF
ormatRGBA32F |
| 1636 : IsInt32Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA32_
S | 1636 : IsInt32Format<Format>::value ? WebGLImageConversion::DataFormatRGBA32_
S |
| 1637 : IsUInt32Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA32 | 1637 : IsUInt32Format<Format>::value ? WebGLImageConversion::DataFormatRGBA32 |
| 1638 : IsInt16Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA16_
S | 1638 : IsInt16Format<Format>::value ? WebGLImageConversion::DataFormatRGBA16_
S |
| 1639 : (IsUInt16Format<Format>::Value || Is32bppFormat<Format>::Value) ? WebG
LImageConversion::DataFormatRGBA16 | 1639 : (IsUInt16Format<Format>::value || Is32bppFormat<Format>::value) ? WebG
LImageConversion::DataFormatRGBA16 |
| 1640 : IsInt8Format<Format>::Value ? WebGLImageConversion::DataFormatRGBA8_S
: WebGLImageConversion::DataFormatRGBA8; | 1640 : IsInt8Format<Format>::value ? WebGLImageConversion::DataFormatRGBA8_S
: WebGLImageConversion::DataFormatRGBA8; |
| 1641 }; | 1641 }; |
| 1642 | 1642 |
| 1643 unsigned TexelBytesForFormat(WebGLImageConversion::DataFormat format) | 1643 unsigned TexelBytesForFormat(WebGLImageConversion::DataFormat format) |
| 1644 { | 1644 { |
| 1645 switch (format) { | 1645 switch (format) { |
| 1646 case WebGLImageConversion::DataFormatR8: | 1646 case WebGLImageConversion::DataFormatR8: |
| 1647 case WebGLImageConversion::DataFormatR8_S: | 1647 case WebGLImageConversion::DataFormatR8_S: |
| 1648 case WebGLImageConversion::DataFormatA8: | 1648 case WebGLImageConversion::DataFormatA8: |
| 1649 return 1; | 1649 return 1; |
| 1650 case WebGLImageConversion::DataFormatRG8: | 1650 case WebGLImageConversion::DataFormatRG8: |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 FORMATCONVERTER_CASE_ALPHAOP(WebGLImageConversion::AlphaDoUnmultiply
) | 1824 FORMATCONVERTER_CASE_ALPHAOP(WebGLImageConversion::AlphaDoUnmultiply
) |
| 1825 default: | 1825 default: |
| 1826 ASSERT_NOT_REACHED(); | 1826 ASSERT_NOT_REACHED(); |
| 1827 } | 1827 } |
| 1828 #undef FORMATCONVERTER_CASE_ALPHAOP | 1828 #undef FORMATCONVERTER_CASE_ALPHAOP |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 template<int Format> | 1831 template<int Format> |
| 1832 struct SupportsConversionFromDomElements { | 1832 struct SupportsConversionFromDomElements { |
| 1833 STATIC_ONLY(SupportsConversionFromDomElements); | 1833 STATIC_ONLY(SupportsConversionFromDomElements); |
| 1834 static const bool Value = | 1834 static const bool value = |
| 1835 Format == WebGLImageConversion::DataFormatRGBA8 | 1835 Format == WebGLImageConversion::DataFormatRGBA8 |
| 1836 || Format == WebGLImageConversion::DataFormatRGB8 | 1836 || Format == WebGLImageConversion::DataFormatRGB8 |
| 1837 || Format == WebGLImageConversion::DataFormatRG8 | 1837 || Format == WebGLImageConversion::DataFormatRG8 |
| 1838 || Format == WebGLImageConversion::DataFormatRA8 | 1838 || Format == WebGLImageConversion::DataFormatRA8 |
| 1839 || Format == WebGLImageConversion::DataFormatR8 | 1839 || Format == WebGLImageConversion::DataFormatR8 |
| 1840 || Format == WebGLImageConversion::DataFormatRGBA32F | 1840 || Format == WebGLImageConversion::DataFormatRGBA32F |
| 1841 || Format == WebGLImageConversion::DataFormatRGB32F | 1841 || Format == WebGLImageConversion::DataFormatRGB32F |
| 1842 || Format == WebGLImageConversion::DataFormatRG32F | 1842 || Format == WebGLImageConversion::DataFormatRG32F |
| 1843 || Format == WebGLImageConversion::DataFormatRA32F | 1843 || Format == WebGLImageConversion::DataFormatRA32F |
| 1844 || Format == WebGLImageConversion::DataFormatR32F | 1844 || Format == WebGLImageConversion::DataFormatR32F |
| 1845 || Format == WebGLImageConversion::DataFormatRGBA16F | 1845 || Format == WebGLImageConversion::DataFormatRGBA16F |
| 1846 || Format == WebGLImageConversion::DataFormatRGB16F | 1846 || Format == WebGLImageConversion::DataFormatRGB16F |
| 1847 || Format == WebGLImageConversion::DataFormatRG16F | 1847 || Format == WebGLImageConversion::DataFormatRG16F |
| 1848 || Format == WebGLImageConversion::DataFormatRA16F | 1848 || Format == WebGLImageConversion::DataFormatRA16F |
| 1849 || Format == WebGLImageConversion::DataFormatR16F | 1849 || Format == WebGLImageConversion::DataFormatR16F |
| 1850 || Format == WebGLImageConversion::DataFormatRGBA5551 | 1850 || Format == WebGLImageConversion::DataFormatRGBA5551 |
| 1851 || Format == WebGLImageConversion::DataFormatRGBA4444 | 1851 || Format == WebGLImageConversion::DataFormatRGBA4444 |
| 1852 || Format == WebGLImageConversion::DataFormatRGB565; | 1852 || Format == WebGLImageConversion::DataFormatRGB565; |
| 1853 }; | 1853 }; |
| 1854 | 1854 |
| 1855 template<WebGLImageConversion::DataFormat SrcFormat, WebGLImageConversion::DataF
ormat DstFormat, WebGLImageConversion::AlphaOp alphaOp> | 1855 template<WebGLImageConversion::DataFormat SrcFormat, WebGLImageConversion::DataF
ormat DstFormat, WebGLImageConversion::AlphaOp alphaOp> |
| 1856 void FormatConverter::convert() | 1856 void FormatConverter::convert() |
| 1857 { | 1857 { |
| 1858 // Many instantiations of this template function will never be entered, so w
e try | 1858 // Many instantiations of this template function will never be entered, so w
e try |
| 1859 // to return immediately in these cases to avoid the compiler to generate us
eless code. | 1859 // to return immediately in these cases to avoid the compiler to generate us
eless code. |
| 1860 if (SrcFormat == DstFormat && alphaOp == WebGLImageConversion::AlphaDoNothin
g) { | 1860 if (SrcFormat == DstFormat && alphaOp == WebGLImageConversion::AlphaDoNothin
g) { |
| 1861 ASSERT_NOT_REACHED(); | 1861 ASSERT_NOT_REACHED(); |
| 1862 return; | 1862 return; |
| 1863 } | 1863 } |
| 1864 if (!IsFloatFormat<DstFormat>::Value && IsFloatFormat<SrcFormat>::Value) { | 1864 if (!IsFloatFormat<DstFormat>::value && IsFloatFormat<SrcFormat>::value) { |
| 1865 ASSERT_NOT_REACHED(); | 1865 ASSERT_NOT_REACHED(); |
| 1866 return; | 1866 return; |
| 1867 } | 1867 } |
| 1868 | 1868 |
| 1869 // Only textures uploaded from DOM elements or ImageData can allow DstFormat
!= SrcFormat. | 1869 // Only textures uploaded from DOM elements or ImageData can allow DstFormat
!= SrcFormat. |
| 1870 const bool srcFormatComesFromDOMElementOrImageData = WebGLImageConversion::s
rcFormatComeFromDOMElementOrImageData(SrcFormat); | 1870 const bool srcFormatComesFromDOMElementOrImageData = WebGLImageConversion::s
rcFormatComeFromDOMElementOrImageData(SrcFormat); |
| 1871 if (!srcFormatComesFromDOMElementOrImageData && SrcFormat != DstFormat) { | 1871 if (!srcFormatComesFromDOMElementOrImageData && SrcFormat != DstFormat) { |
| 1872 ASSERT_NOT_REACHED(); | 1872 ASSERT_NOT_REACHED(); |
| 1873 return; | 1873 return; |
| 1874 } | 1874 } |
| 1875 // Likewise, only textures uploaded from DOM elements or ImageData can possi
bly have to be unpremultiplied. | 1875 // Likewise, only textures uploaded from DOM elements or ImageData can possi
bly have to be unpremultiplied. |
| 1876 if (!srcFormatComesFromDOMElementOrImageData && alphaOp == WebGLImageConvers
ion::AlphaDoUnmultiply) { | 1876 if (!srcFormatComesFromDOMElementOrImageData && alphaOp == WebGLImageConvers
ion::AlphaDoUnmultiply) { |
| 1877 ASSERT_NOT_REACHED(); | 1877 ASSERT_NOT_REACHED(); |
| 1878 return; | 1878 return; |
| 1879 } | 1879 } |
| 1880 if (srcFormatComesFromDOMElementOrImageData && alphaOp == WebGLImageConversi
on::AlphaDoUnmultiply && !SupportsConversionFromDomElements<DstFormat>::Value) { | 1880 if (srcFormatComesFromDOMElementOrImageData && alphaOp == WebGLImageConversi
on::AlphaDoUnmultiply && !SupportsConversionFromDomElements<DstFormat>::value) { |
| 1881 ASSERT_NOT_REACHED(); | 1881 ASSERT_NOT_REACHED(); |
| 1882 return; | 1882 return; |
| 1883 } | 1883 } |
| 1884 if ((!HasAlpha(SrcFormat) || !HasColor(SrcFormat) || !HasColor(DstFormat)) &
& alphaOp != WebGLImageConversion::AlphaDoNothing) { | 1884 if ((!HasAlpha(SrcFormat) || !HasColor(SrcFormat) || !HasColor(DstFormat)) &
& alphaOp != WebGLImageConversion::AlphaDoNothing) { |
| 1885 ASSERT_NOT_REACHED(); | 1885 ASSERT_NOT_REACHED(); |
| 1886 return; | 1886 return; |
| 1887 } | 1887 } |
| 1888 // If converting DOM element data to UNSIGNED_INT_5_9_9_9_REV or UNSIGNED_IN
T_10F_11F_11F_REV, | 1888 // If converting DOM element data to UNSIGNED_INT_5_9_9_9_REV or UNSIGNED_IN
T_10F_11F_11F_REV, |
| 1889 // we should always switch to FLOAT instead to avoid unpack/pack to these tw
o types. | 1889 // we should always switch to FLOAT instead to avoid unpack/pack to these tw
o types. |
| 1890 if (srcFormatComesFromDOMElementOrImageData && SrcFormat != DstFormat | 1890 if (srcFormatComesFromDOMElementOrImageData && SrcFormat != DstFormat |
| 1891 && (DstFormat == WebGLImageConversion::DataFormatRGB5999 || DstFormat ==
WebGLImageConversion::DataFormatRGB10F11F11F)) { | 1891 && (DstFormat == WebGLImageConversion::DataFormatRGB5999 || DstFormat ==
WebGLImageConversion::DataFormatRGB10F11F11F)) { |
| 1892 ASSERT_NOT_REACHED(); | 1892 ASSERT_NOT_REACHED(); |
| 1893 return; | 1893 return; |
| 1894 } | 1894 } |
| 1895 | 1895 |
| 1896 typedef typename DataTypeForFormat<SrcFormat>::Type SrcType; | 1896 typedef typename DataTypeForFormat<SrcFormat>::Type SrcType; |
| 1897 typedef typename DataTypeForFormat<DstFormat>::Type DstType; | 1897 typedef typename DataTypeForFormat<DstFormat>::Type DstType; |
| 1898 const int IntermFormat = IntermediateFormat<DstFormat>::Value; | 1898 const int IntermFormat = IntermediateFormat<DstFormat>::value; |
| 1899 typedef typename DataTypeForFormat<IntermFormat>::Type IntermType; | 1899 typedef typename DataTypeForFormat<IntermFormat>::Type IntermType; |
| 1900 const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType); | 1900 const ptrdiff_t srcStrideInElements = m_srcStride / sizeof(SrcType); |
| 1901 const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType); | 1901 const ptrdiff_t dstStrideInElements = m_dstStride / sizeof(DstType); |
| 1902 const bool trivialUnpack = SrcFormat == IntermFormat; | 1902 const bool trivialUnpack = SrcFormat == IntermFormat; |
| 1903 const bool trivialPack = DstFormat == IntermFormat && alphaOp == WebGLImageC
onversion::AlphaDoNothing; | 1903 const bool trivialPack = DstFormat == IntermFormat && alphaOp == WebGLImageC
onversion::AlphaDoNothing; |
| 1904 ASSERT(!trivialUnpack || !trivialPack); | 1904 ASSERT(!trivialUnpack || !trivialPack); |
| 1905 | 1905 |
| 1906 const SrcType *srcRowStart = static_cast<const SrcType*>(m_srcStart); | 1906 const SrcType *srcRowStart = static_cast<const SrcType*>(m_srcStart); |
| 1907 DstType* dstRowStart = static_cast<DstType*>(m_dstStart); | 1907 DstType* dstRowStart = static_cast<DstType*>(m_dstStart); |
| 1908 if (trivialUnpack) { | 1908 if (trivialUnpack) { |
| (...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 } | 2407 } |
| 2408 | 2408 |
| 2409 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); | 2409 FormatConverter converter(width, height, sourceData, destinationData, srcStr
ide, dstStride); |
| 2410 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); | 2410 converter.convert(sourceDataFormat, dstDataFormat, alphaOp); |
| 2411 if (!converter.Success()) | 2411 if (!converter.Success()) |
| 2412 return false; | 2412 return false; |
| 2413 return true; | 2413 return true; |
| 2414 } | 2414 } |
| 2415 | 2415 |
| 2416 } // namespace blink | 2416 } // namespace blink |
| OLD | NEW |