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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/WebGLImageConversion.cpp

Issue 2821363003: WebGL: tex(Sub)Image(2D|3D) texImageSource support for RGB10_A2 textures. (Closed)
Patch Set: Created 3 years, 8 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 | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp ('k') | 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 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 <memory> 7 #include <memory>
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 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 static_cast<double>(ClampMin(source[1])) * scale_factor); 1611 static_cast<double>(ClampMin(source[1])) * scale_factor);
1612 destination[2] = static_cast<int32_t>( 1612 destination[2] = static_cast<int32_t>(
1613 static_cast<double>(ClampMin(source[2])) * scale_factor); 1613 static_cast<double>(ClampMin(source[2])) * scale_factor);
1614 source += 4; 1614 source += 4;
1615 destination += 4; 1615 destination += 4;
1616 } 1616 }
1617 } 1617 }
1618 1618
1619 template <> 1619 template <>
1620 void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10, 1620 void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10,
1621 WebGLImageConversion::kAlphaDoNothing,
1622 float,
1623 uint32_t>(const float* source,
1624 uint32_t* destination,
1625 unsigned pixels_per_row) {
1626 for (unsigned i = 0; i < pixels_per_row; ++i) {
1627 uint32_t r = static_cast<uint32_t>(source[0] * 1023.0f);
1628 uint32_t g = static_cast<uint32_t>(source[1] * 1023.0f);
1629 uint32_t b = static_cast<uint32_t>(source[2] * 1023.0f);
1630 uint32_t a = static_cast<uint32_t>(source[3] * 3.0f);
1631 destination[0] = (a << 30) | (b << 20) | (g << 10) | r;
1632 source += 4;
1633 destination += 1;
1634 }
1635 }
1636
1637 template <>
1638 void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10,
1621 WebGLImageConversion::kAlphaDoPremultiply, 1639 WebGLImageConversion::kAlphaDoPremultiply,
1622 float, 1640 float,
1623 uint32_t>(const float* source, 1641 uint32_t>(const float* source,
1624 uint32_t* destination, 1642 uint32_t* destination,
1625 unsigned pixels_per_row) { 1643 unsigned pixels_per_row) {
1626 for (unsigned i = 0; i < pixels_per_row; ++i) { 1644 for (unsigned i = 0; i < pixels_per_row; ++i) {
1627 uint32_t r = static_cast<uint32_t>(source[0] * source[3] * 1023.0f); 1645 uint32_t r = static_cast<uint32_t>(source[0] * source[3] * 1023.0f);
1628 uint32_t g = static_cast<uint32_t>(source[1] * source[3] * 1023.0f); 1646 uint32_t g = static_cast<uint32_t>(source[1] * source[3] * 1023.0f);
1629 uint32_t b = static_cast<uint32_t>(source[2] * source[3] * 1023.0f); 1647 uint32_t b = static_cast<uint32_t>(source[2] * source[3] * 1023.0f);
1630 uint32_t a = static_cast<uint32_t>(source[3] * 3.0f); 1648 uint32_t a = static_cast<uint32_t>(source[3] * 3.0f);
1631 destination[0] = (a << 30) | (b << 20) | (g << 10) | r; 1649 destination[0] = (a << 30) | (b << 20) | (g << 10) | r;
1632 source += 4; 1650 source += 4;
1633 destination += 1; 1651 destination += 1;
1634 } 1652 }
1635 } 1653 }
1636 1654
1637 template <> 1655 template <>
1656 void Pack<WebGLImageConversion::kDataFormatRGBA2_10_10_10,
1657 WebGLImageConversion::kAlphaDoUnmultiply,
1658 float,
1659 uint32_t>(const float* source,
1660 uint32_t* destination,
1661 unsigned pixels_per_row) {
1662 for (unsigned i = 0; i < pixels_per_row; ++i) {
1663 float scale_factor = source[3] ? 1023.0f / source[3] : 1023.0f;
1664 uint32_t r = static_cast<uint32_t>(source[0] * scale_factor);
1665 uint32_t g = static_cast<uint32_t>(source[1] * scale_factor);
1666 uint32_t b = static_cast<uint32_t>(source[2] * scale_factor);
1667 uint32_t a = static_cast<uint32_t>(source[3] * 3.0f);
1668 destination[0] = (a << 30) | (b << 20) | (g << 10) | r;
1669 source += 4;
1670 destination += 1;
1671 }
1672 }
1673
1674 template <>
1638 void Pack<WebGLImageConversion::kDataFormatRG8, 1675 void Pack<WebGLImageConversion::kDataFormatRG8,
1639 WebGLImageConversion::kAlphaDoNothing, 1676 WebGLImageConversion::kAlphaDoNothing,
1640 uint8_t, 1677 uint8_t,
1641 uint8_t>(const uint8_t* source, 1678 uint8_t>(const uint8_t* source,
1642 uint8_t* destination, 1679 uint8_t* destination,
1643 unsigned pixels_per_row) { 1680 unsigned pixels_per_row) {
1644 for (unsigned i = 0; i < pixels_per_row; ++i) { 1681 for (unsigned i = 0; i < pixels_per_row; ++i) {
1645 destination[0] = source[0]; 1682 destination[0] = source[0];
1646 destination[1] = source[1]; 1683 destination[1] = source[1];
1647 source += 4; 1684 source += 4;
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
2398 Format == WebGLImageConversion::kDataFormatRG32F || 2435 Format == WebGLImageConversion::kDataFormatRG32F ||
2399 Format == WebGLImageConversion::kDataFormatRA32F || 2436 Format == WebGLImageConversion::kDataFormatRA32F ||
2400 Format == WebGLImageConversion::kDataFormatR32F || 2437 Format == WebGLImageConversion::kDataFormatR32F ||
2401 Format == WebGLImageConversion::kDataFormatRGBA16F || 2438 Format == WebGLImageConversion::kDataFormatRGBA16F ||
2402 Format == WebGLImageConversion::kDataFormatRGB16F || 2439 Format == WebGLImageConversion::kDataFormatRGB16F ||
2403 Format == WebGLImageConversion::kDataFormatRG16F || 2440 Format == WebGLImageConversion::kDataFormatRG16F ||
2404 Format == WebGLImageConversion::kDataFormatRA16F || 2441 Format == WebGLImageConversion::kDataFormatRA16F ||
2405 Format == WebGLImageConversion::kDataFormatR16F || 2442 Format == WebGLImageConversion::kDataFormatR16F ||
2406 Format == WebGLImageConversion::kDataFormatRGBA5551 || 2443 Format == WebGLImageConversion::kDataFormatRGBA5551 ||
2407 Format == WebGLImageConversion::kDataFormatRGBA4444 || 2444 Format == WebGLImageConversion::kDataFormatRGBA4444 ||
2408 Format == WebGLImageConversion::kDataFormatRGB565; 2445 Format == WebGLImageConversion::kDataFormatRGB565 ||
2446 Format == WebGLImageConversion::kDataFormatRGBA2_10_10_10;
2409 }; 2447 };
2410 2448
2411 template <WebGLImageConversion::DataFormat SrcFormat, 2449 template <WebGLImageConversion::DataFormat SrcFormat,
2412 WebGLImageConversion::DataFormat DstFormat, 2450 WebGLImageConversion::DataFormat DstFormat,
2413 WebGLImageConversion::AlphaOp alphaOp> 2451 WebGLImageConversion::AlphaOp alphaOp>
2414 void FormatConverter::Convert() { 2452 void FormatConverter::Convert() {
2415 // Many instantiations of this template function will never be entered, so we 2453 // Many instantiations of this template function will never be entered, so we
2416 // try to return immediately in these cases to avoid generating useless code. 2454 // try to return immediately in these cases to avoid generating useless code.
2417 if (SrcFormat == DstFormat && 2455 if (SrcFormat == DstFormat &&
2418 alphaOp == WebGLImageConversion::kAlphaDoNothing) { 2456 alphaOp == WebGLImageConversion::kAlphaDoNothing) {
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
3194 Pack<WebGLImageConversion::kDataFormatRGB565, 3232 Pack<WebGLImageConversion::kDataFormatRGB565,
3195 WebGLImageConversion::kAlphaDoNothing>(src_row_start, dst_row_start, 3233 WebGLImageConversion::kAlphaDoNothing>(src_row_start, dst_row_start,
3196 pixels_per_row); 3234 pixels_per_row);
3197 } break; 3235 } break;
3198 default: 3236 default:
3199 break; 3237 break;
3200 } 3238 }
3201 } 3239 }
3202 3240
3203 } // namespace blink 3241 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698