Changeset 83219 in webkit
- Timestamp:
- Apr 7, 2011 3:21:53 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r83198 r83219 1 2011-04-07 Tony Chang <tony@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 update DRT to embed checksums in png files 6 https://bugs.webkit.org/show_bug.cgi?id=57871 7 8 We insert the bytes for the comment in printPNG rather than at encode 9 time because each platform does its own PNG encoding (either using CG 10 or cairo). Putting this in pringPNG avoids having to duplicate this 11 code, although it's not as clean as doing it at encoding time. 12 13 We insert the comment right after the IHDR chunk of the PNG. 14 15 * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: 16 * DumpRenderTree/CyclicRedundancyCheck.cpp: Added. 17 (makeCrcTable): Ported from LayoutTests/fast/canvas/webgl/resources/pnglib.js 18 (computeCrc): Ported from LayoutTests/fast/canvas/webgl/resources/pnglib.js 19 * DumpRenderTree/CyclicRedundancyCheck.h: Added. 20 * DumpRenderTree/PixelDumpSupport.cpp: 21 (dumpWebViewAsPixelsAndCompareWithExpected): 22 (convertChecksumToPNGComment): Generate the bytes to insert. 23 (printPNG): Insert the png comment before the first IDAT section. 24 * DumpRenderTree/PixelDumpSupport.h: 25 * DumpRenderTree/cairo/PixelDumpSupportCairo.cpp: 26 (printPNG): 27 (dumpBitmap): 28 * DumpRenderTree/cg/PixelDumpSupportCG.cpp: 29 (printPNG): 30 (dumpBitmap): 31 * DumpRenderTree/win/DumpRenderTree.vcproj: 32 * GNUmakefile.am: 33 1 34 2011-04-07 Jeff Miller <jeffm@apple.com> 2 35 -
trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
r82723 r83219 60 60 5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F69F10714A57007AA393 /* HistoryDelegate.mm */; }; 61 61 5185F6B310714E12007AA393 /* HistoryDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5185F69E10714A57007AA393 /* HistoryDelegate.h */; }; 62 53CBB832134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */; }; 63 53CBB833134E42F3001CE6A4 /* CyclicRedundancyCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBB831134E42F3001CE6A4 /* CyclicRedundancyCheck.h */; }; 62 64 5DB9AC970F722C3600684641 /* AHEM____.TTF in Copy Font Files */ = {isa = PBXBuildFile; fileRef = AA7F10C20CB3C1030003BDC9 /* AHEM____.TTF */; }; 63 65 5DB9AC980F722C3600684641 /* WebKitWeightWatcher100.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 375F09710DAC3CB600C8B4E5 /* WebKitWeightWatcher100.ttf */; }; … … 244 246 5185F69E10714A57007AA393 /* HistoryDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HistoryDelegate.h; path = mac/HistoryDelegate.h; sourceTree = "<group>"; }; 245 247 5185F69F10714A57007AA393 /* HistoryDelegate.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = HistoryDelegate.mm; path = mac/HistoryDelegate.mm; sourceTree = "<group>"; }; 248 53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; }; 249 53CBB831134E42F3001CE6A4 /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; }; 246 250 8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; }; 247 251 9335435F03D75502008635CE /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; … … 582 586 isa = PBXGroup; 583 587 children = ( 588 53CBB830134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp */, 589 53CBB831134E42F3001CE6A4 /* CyclicRedundancyCheck.h */, 584 590 BCB284F30CFA84F2007E533E /* ImageDiffCG.cpp */, 585 591 8465E2C60FFA8DF2003B8342 /* PixelDumpSupport.cpp */, … … 612 618 BCA18B380C9B021900114369 /* AppleScriptController.h in Headers */, 613 619 A8B91BFF0CF522B4008F91FF /* CheckedMalloc.h in Headers */, 620 53CBB833134E42F3001CE6A4 /* CyclicRedundancyCheck.h in Headers */, 614 621 BCA18B7A0C9B08F100114369 /* DumpRenderTreeDraggingInfo.h in Headers */, 615 622 A8D79CEA0FC28B2C004AC8FE /* DumpRenderTreeFileDraggingSource.h in Headers */, … … 800 807 BCA18B390C9B021900114369 /* AppleScriptController.m in Sources */, 801 808 A8B91BFD0CF522B4008F91FF /* CheckedMalloc.cpp in Sources */, 809 53CBB832134E42F3001CE6A4 /* CyclicRedundancyCheck.cpp in Sources */, 802 810 BCA18C470C9B5B9400114369 /* DumpRenderTree.mm in Sources */, 803 811 BCA18B7B0C9B08F100114369 /* DumpRenderTreeDraggingInfo.mm in Sources */, -
trunk/Tools/DumpRenderTree/PixelDumpSupport.cpp
r70239 r83219 30 30 #include "PixelDumpSupport.h" 31 31 32 #include "CyclicRedundancyCheck.h" 32 33 #include "DumpRenderTree.h" 33 34 #include "LayoutTestController.h" … … 35 36 #include <wtf/Assertions.h> 36 37 #include <wtf/RefPtr.h> 38 #include <wtf/Vector.h> 37 39 38 40 #if PLATFORM(CG) … … 70 72 71 73 if (dumpImage) 72 dumpBitmap(context.get() );74 dumpBitmap(context.get(), actualHash); 73 75 } 74 76 75 void printPNG(const unsigned char* data, const size_t dataLength)77 static void appendIntToVector(int number, Vector<unsigned char>& vector) 76 78 { 79 size_t offset = vector.size(); 80 vector.grow(offset + 4); 81 vector[offset] = ((number >> 24) & 0xff); 82 vector[offset + 1] = ((number >> 16) & 0xff); 83 vector[offset + 2] = ((number >> 8) & 0xff); 84 vector[offset + 3] = (number & 0xff); 85 } 86 87 static void convertChecksumToPNGComment(const char* checksum, Vector<unsigned char>& bytesToAdd) 88 { 89 // Chunks of PNG files are <length>, <type>, <data>, <crc>. 90 static const char textCommentPrefix[] = "\x00\x00\x00\x29tEXtchecksum\x00"; 91 static const size_t prefixLength = sizeof(textCommentPrefix) - 1; // The -1 is for the null at the end of the char[]. 92 static const size_t checksumLength = 32; 93 94 bytesToAdd.append(textCommentPrefix, prefixLength); 95 bytesToAdd.append(checksum, checksumLength); 96 97 Vector<unsigned char> dataToCrc; 98 dataToCrc.append(textCommentPrefix + 4, prefixLength - 4); // Don't include the chunk length in the crc. 99 dataToCrc.append(checksum, checksumLength); 100 unsigned long crc32 = computeCrc(dataToCrc); 101 102 appendIntToVector(crc32, bytesToAdd); 103 } 104 105 static size_t offsetAfterIHDRChunk(const unsigned char* data, const size_t dataLength) 106 { 107 const int pngHeaderLength = 8; 108 const int pngIHDRChunkLength = 25; // chunk length + "IHDR" + 13 bytes of data + checksum 109 return pngHeaderLength + pngIHDRChunkLength; 110 } 111 112 void printPNG(const unsigned char* data, const size_t dataLength, const char* checksum) 113 { 114 Vector<unsigned char> bytesToAdd; 115 convertChecksumToPNGComment(checksum, bytesToAdd); 116 77 117 printf("Content-Type: %s\n", "image/png"); 78 printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength)); 118 printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength + bytesToAdd.size())); 119 120 size_t insertOffset = offsetAfterIHDRChunk(data, dataLength); 121 122 fwrite(data, 1, insertOffset, stdout); 123 fwrite(bytesToAdd.data(), 1, bytesToAdd.size(), stdout); 79 124 80 125 const size_t bytesToWriteInOneChunk = 1 << 15; 81 size_t dataRemainingToWrite = dataLength; 126 data += insertOffset; 127 size_t dataRemainingToWrite = dataLength - insertOffset; 82 128 while (dataRemainingToWrite) { 83 129 size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk); -
trunk/Tools/DumpRenderTree/PixelDumpSupport.h
r63521 r83219 39 39 PassRefPtr<BitmapContext> createPagedBitmapContext(); 40 40 PassRefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect); 41 void dumpBitmap(BitmapContext* );41 void dumpBitmap(BitmapContext*, const char* checksum); 42 42 void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash); 43 void printPNG(const unsigned char* data, const size_t dataLength );43 void printPNG(const unsigned char* data, const size_t dataLength, const char* checksum); 44 44 45 45 #if PLATFORM(MAC) -
trunk/Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp
r63130 r83219 50 50 } 51 51 52 static void printPNG(cairo_surface_t* image )52 static void printPNG(cairo_surface_t* image, const char* checksum) 53 53 { 54 54 Vector<unsigned char> pixelData; … … 59 59 const unsigned char* data = pixelData.data(); 60 60 61 printPNG(data, dataLength );61 printPNG(data, dataLength, checksum); 62 62 } 63 63 … … 87 87 } 88 88 89 void dumpBitmap(BitmapContext* context )89 void dumpBitmap(BitmapContext* context, const char* checksum) 90 90 { 91 91 cairo_surface_t* surface = cairo_get_target(context->cairoContext()); 92 printPNG(surface );92 printPNG(surface, checksum); 93 93 } -
trunk/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp
r45505 r83219 56 56 #endif 57 57 58 static void printPNG(CGImageRef image )58 static void printPNG(CGImageRef image, const char* checksum) 59 59 { 60 60 RetainPtr<CFMutableDataRef> imageData(AdoptCF, CFDataCreateMutable(0, 0)); … … 66 66 CFIndex dataLength = CFDataGetLength(imageData.get()); 67 67 68 printPNG(static_cast<const unsigned char*>(data), static_cast<size_t>(dataLength) );68 printPNG(static_cast<const unsigned char*>(data), static_cast<size_t>(dataLength), checksum); 69 69 } 70 70 … … 107 107 } 108 108 109 void dumpBitmap(BitmapContext* context )109 void dumpBitmap(BitmapContext* context, const char* checksum) 110 110 { 111 111 RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(context->cgContext())); 112 printPNG(image.get() );112 printPNG(image.get(), checksum); 113 113 } -
trunk/Tools/DumpRenderTree/win/DumpRenderTree.vcproj
r82477 r83219 516 516 </File> 517 517 <File 518 RelativePath="..\CyclicRedundancyCheck.cpp" 519 > 520 </File> 521 <File 522 RelativePath="..\CyclicRedundancyCheck.h" 523 > 524 </File> 525 <File 518 526 RelativePath=".\DraggingInfo.h" 519 527 > -
trunk/Tools/GNUmakefile.am
r81157 r83219 57 57 Tools/DumpRenderTree/AccessibilityUIElement.cpp \ 58 58 Tools/DumpRenderTree/AccessibilityUIElement.h \ 59 Tools/DumpRenderTree/CyclicRedundancyCheck.cpp \ 60 Tools/DumpRenderTree/CyclicRedundancyCheck.h \ 59 61 Tools/DumpRenderTree/GCController.cpp \ 60 62 Tools/DumpRenderTree/GCController.h \
Note: See TracChangeset
for help on using the changeset viewer.