Changeset 141706 in webkit
- Timestamp:
- Feb 2, 2013 2:32:34 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r141704 r141706 1 2013-02-02 Jun Jiang <jun.a.jiang@intel.com> 2 3 Optimize some operations for float type in texture format conversions of WebGL 4 https://bugs.webkit.org/show_bug.cgi?id=107526 5 6 Reviewed by Darin Adler. 7 8 Some small changes are made to optimize the operations for float type in the texture format conversion of WebGL to improve performance. 9 10 Already covered by current tests. 11 12 * platform/graphics/GraphicsContext3D.cpp: 13 (WebCore): 14 1 15 2013-02-02 Simon Fraser <simon.fraser@apple.com> 2 16 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp
r140497 r141706 825 825 { 826 826 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 827 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);827 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; 828 828 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 829 829 destination[0] = sourceR; … … 859 859 { 860 860 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 861 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);861 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; 862 862 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 863 863 destination[0] = sourceR; … … 898 898 { 899 899 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 900 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);900 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; 901 901 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 902 902 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); … … 936 936 { 937 937 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 938 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);938 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; 939 939 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 940 940 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); … … 984 984 { 985 985 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 986 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);986 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; 987 987 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 988 988 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); … … 1032 1032 { 1033 1033 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1034 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);1034 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; 1035 1035 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 1036 1036 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); … … 1078 1078 { 1079 1079 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1080 float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);1080 float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f; 1081 1081 uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor); 1082 1082 uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor); … … 1128 1128 template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow) 1129 1129 { 1130 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 1131 destination[0] = source[0]; 1132 destination[1] = source[1]; 1133 destination[2] = source[2]; 1134 destination[3] = source[3]; 1135 source += 4; 1136 destination += 4; 1137 } 1130 memcpy(destination, source, pixelsPerRow * 4 * sizeof(float)); 1138 1131 } 1139 1132
Note: See TracChangeset
for help on using the changeset viewer.