Changeset 94026 in webkit
- Timestamp:
- Aug 29, 2011, 3:54:06 PM (15 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/GraphicsContext3D.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r94024 r94026 1 2011-08-29 John Bauman <jbauman@chromium.org> 2 3 Speed up texImage from BGRA 4 https://bugs.webkit.org/show_bug.cgi?id=66884 5 6 Reviewed by Kenneth Russell. 7 8 BGRA input is common coming from skia, so optimize BGRA->RGBA 9 conversion and also avoid the pointless RGBA to RGBA conversion. 10 11 * platform/graphics/GraphicsContext3D.cpp: 12 (WebCore::doUnpackingAndPacking): 13 1 14 2011-08-29 Matthew Delaney <mdelaney@apple.com> 2 15 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp
r93564 r94026 475 475 void unpackOneRowOfBGRA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow) 476 476 { 477 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 478 destination[0] = source[2]; 479 destination[1] = source[1]; 480 destination[2] = source[0]; 481 destination[3] = source[3]; 482 source += 4; 483 destination += 4; 477 const uint32_t* source32 = reinterpret_cast<const uint32_t*>(source); 478 uint32_t* destination32 = reinterpret_cast<uint32_t*>(destination); 479 for (unsigned int i = 0; i < pixelsPerRow; ++i) { 480 uint32_t bgra = source32[i]; 481 #if CPU(BIG_ENDIAN) 482 uint32_t brMask = 0xff00ff00; 483 uint32_t gaMask = 0x00ff00ff; 484 #else 485 uint32_t brMask = 0x00ff00ff; 486 uint32_t gaMask = 0xff00ff00; 487 #endif 488 uint32_t rgba = (((bgra >> 16) | (bgra << 16)) & brMask) | (bgra & gaMask); 489 destination32[i] = rgba; 484 490 } 485 491 } … … 869 875 source += 4; 870 876 destination += 3; 871 }872 }873 874 // This is only used when the source format is different than SourceFormatRGBA8.875 void packOneRowOfRGBA8ToRGBA8(const uint8_t* source, uint8_t* destination, unsigned int pixelsPerRow)876 {877 for (unsigned int i = 0; i < pixelsPerRow; ++i) {878 destination[0] = source[0];879 destination[1] = source[1];880 destination[2] = source[2];881 destination[3] = source[3];882 source += 4;883 destination += 4;884 877 } 885 878 } … … 1151 1144 unsigned int destinationElementsPerPixel) 1152 1145 { 1153 OwnArrayPtr<IntermediateType> temporaryRGBAData = adoptArrayPtr(new IntermediateType[width * 4]); 1154 const SourceType* endPointer = sourceData + height * sourceElementsPerRow; 1155 unsigned int destinationElementsPerRow = width * destinationElementsPerPixel; 1156 while (sourceData < endPointer) { 1157 rowUnpackingFunc(sourceData, temporaryRGBAData.get(), width); 1158 rowPackingFunc(temporaryRGBAData.get(), destinationData, width); 1159 sourceData += sourceElementsPerRow; 1160 destinationData += destinationElementsPerRow; 1146 if (!rowPackingFunc) { 1147 // The row packing is trivial, so don't bother with a temporary buffer. 1148 const SourceType* endPointer = sourceData + height * sourceElementsPerRow; 1149 unsigned int destinationElementsPerRow = width * destinationElementsPerPixel; 1150 while (sourceData < endPointer) { 1151 rowUnpackingFunc(sourceData, reinterpret_cast<IntermediateType*>(destinationData), width); 1152 sourceData += sourceElementsPerRow; 1153 destinationData += destinationElementsPerRow; 1154 } 1155 } else { 1156 OwnArrayPtr<IntermediateType> temporaryRGBAData = adoptArrayPtr(new IntermediateType[width * 4]); 1157 const SourceType* endPointer = sourceData + height * sourceElementsPerRow; 1158 unsigned int destinationElementsPerRow = width * destinationElementsPerPixel; 1159 while (sourceData < endPointer) { 1160 rowUnpackingFunc(sourceData, temporaryRGBAData.get(), width); 1161 rowPackingFunc(temporaryRGBAData.get(), destinationData, width); 1162 sourceData += sourceElementsPerRow; 1163 destinationData += destinationElementsPerRow; 1164 } 1161 1165 } 1162 1166 } … … 1198 1202 unsigned int destinationElementsPerRow = width * destinationElementsPerPixel; 1199 1203 while (source < endPointer) { 1200 rowPackingFunc(source, destinationData, width); 1204 if (rowPackingFunc) 1205 rowPackingFunc(source, destinationData, width); 1206 else 1207 memcpy(destinationData, source, width * 4); 1201 1208 source += sourceElementsPerRow; 1202 1209 destinationData += destinationElementsPerRow; … … 1436 1443 case AlphaDoNothing: 1437 1444 ASSERT(sourceDataFormat != SourceFormatRGBA8 || sourceUnpackAlignment > 4); // Handled above with fast case. 1438 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, packOneRowOfRGBA8ToRGBA8, 4);1445 doPacking<uint8_t>(sourceData, sourceDataFormat, width, height, sourceUnpackAlignment, destination, 0, 4); 1439 1446 break; 1440 1447 case AlphaDoPremultiply:
Note:
See TracChangeset
for help on using the changeset viewer.