Commit b990c07f authored by eseidel's avatar eseidel

Bug #: none

Submitted by: eseidel
Reviewed by: No review, only removing dead code.
        * DumpKCanvasTree/DumpKCanvasTree.m: Removed.
        * DumpKCanvasTree/DumpKCanvasTree.xcodeproj/project.pbxproj: Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@11825 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e79fa87d
2005-12-30 Eric Seidel <eseidel@apple.com>
No review, only removing dead code.
* DumpKCanvasTree/DumpKCanvasTree.m: Removed.
* DumpKCanvasTree/DumpKCanvasTree.xcodeproj/project.pbxproj: Removed.
2005-12-30 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
......
/*
* Copyright (C) 2005 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <getopt.h>
#import <WebCore/DrawDocumentPrivate.h>
#import <WebCore/DrawView.h>
#define COMMON_DIGEST_FOR_OPENSSL
#import <CommonCrypto/CommonDigest.h>
#define maxHeightOption 1
#define maxWidthOption 2
static void dumpRenderTree(const char *filename);
void dumpPixelTests(DrawDocument *document, NSString *svgPath);
static NSBitmapImageRep *getBitmapImageRepForSVGDocument(DrawDocument *document);
NSString *md5HashStringForBitmap(NSBitmapImageRep *bitmap);
/* global variables */
int pixelTests = 0; // run the pixel comparison tests?
NSNumber *maxWidth = nil;
NSNumber *maxHeight = nil;
DrawView *view = nil;
int main(int argc, const char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int ch = 0;
// define the commandline options that this program accepts
static struct option longopts[] = {
{ "pixel-tests", no_argument, &pixelTests, 1 },
{ "max-height", required_argument, NULL, maxHeightOption },
{ "max-width", required_argument, NULL, maxWidthOption },
{ NULL, 0, NULL, 0 }
};
// parse the options that the program receives
while ((ch = getopt_long(argc, (char * const *) argv, "", longopts, NULL)) != -1) {
switch (ch) {
case maxHeightOption:
maxHeight = [NSNumber numberWithInt:[[NSString stringWithUTF8String:optarg] intValue]];
break;
case maxWidthOption:
maxWidth = [NSNumber numberWithInt:[[NSString stringWithUTF8String:optarg] intValue]];
break;
case '?': // unknown or ambiguous option
case ':': // missing argument
exit(1);
break;
}
}
// remove the options that were parsed by getopt_long
argc -= optind;
argv += optind;
// if we are running the pixel comparison tests, instantiate our DrawView
if (pixelTests)
view = [[DrawView alloc] initWithFrame:NSZeroRect];
if (argc == 1 && strcmp(argv[0], "-") == 0) {
char filenameBuffer[2048];
while (fgets(filenameBuffer, sizeof(filenameBuffer), stdin)) {
char *newLineCharacter = strchr(filenameBuffer, '\n');
if (newLineCharacter) {
*newLineCharacter = '\0';
}
dumpRenderTree(filenameBuffer);
puts("#EOF");
fflush(stdout);
}
} else {
int i;
for (i = 1; i != argc; ++i) {
dumpRenderTree(argv[i]);
}
}
[view release];
[pool release];
return 0;
}
static void dumpRenderTree(const char *filename)
{
NSString *svgPath = [NSString stringWithUTF8String:filename];
if (svgPath == nil) {
fprintf(stderr, "can't parse filename as UTF-8\n");
return;
}
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DrawDocument *document = [[DrawDocument alloc] initWithContentsOfFile:svgPath];
NSString *result = [document renderTreeAsExternalRepresentation];
if (!result)
puts("error");
else
fputs([result UTF8String], stdout);
// generate the image and perform pixel tests
if (pixelTests) {
fputs("#EOF\n", stdout);
dumpPixelTests(document, svgPath);
}
[document release];
[pool release];
}
NSString *md5HashStringForBitmap(NSBitmapImageRep *bitmap)
{
MD5_CTX md5Context;
unsigned char hash[16];
MD5_Init(&md5Context);
MD5_Update(&md5Context, [bitmap bitmapData], [bitmap bytesPerPlane]);
MD5_Final(hash, &md5Context);
char hex[33] = "";
for (int i = 0; i < 16; i++) {
snprintf(hex, 33, "%s%02x", hex, hash[i]);
}
return [NSString stringWithUTF8String:hex];
}
void dumpPixelTests(DrawDocument *document, NSString *svgPath)
{
// Creates an image from the document object
NSBitmapImageRep *actualBitmap = getBitmapImageRepForSVGDocument(document);
// lookup the expected hash value for that image
NSString *baseTestPath = [svgPath stringByDeletingPathExtension];
NSString *baselineHashPath = [baseTestPath stringByAppendingString:@"-expected.checksum"];
NSString *baselineHash = [NSString stringWithContentsOfFile:baselineHashPath encoding:NSUTF8StringEncoding error:nil];
// compute the hash for the rendered image, print both.
NSString *actualHash = md5HashStringForBitmap(actualBitmap);
fprintf(stdout,"ActualHash: %s\n", [actualHash UTF8String]);
fprintf(stdout,"BaselineHash: %s\n", [baselineHash UTF8String]);
// if the hashes don't match, then perform more pixel tests
if ([baselineHash isEqualToString:actualHash] == NO) {
// send the PNG compressed data through STDOUT
NSData *svgPNGData = [actualBitmap representationUsingType:NSPNGFileType properties:nil];
fprintf(stdout, "Content-length: %d\n", [svgPNGData length]);
fwrite([svgPNGData bytes], [svgPNGData length], 1, stdout);
}
}
static NSSize constrainSizeToMaximum(NSSize boundsSize)
{
// Limit the maximum size and default the size to 500x500 if not specified
if (maxWidth && boundsSize.width > [maxWidth intValue]) {
// resize the height so that the aspect ratio remains the same
boundsSize.height = (boundsSize.height / boundsSize.width) * [maxWidth intValue];
boundsSize.width = [maxWidth intValue];
}
else if (boundsSize.width <= 0)
boundsSize.width = 500;
if (maxHeight && boundsSize.height > [maxHeight intValue]) {
// resize the width so that the aspect ratio reamins the same
boundsSize.width = (boundsSize.width / boundsSize.height) * [maxHeight intValue];
boundsSize.height = [maxHeight intValue];
}
else if (boundsSize.height <= 0)
boundsSize.height = 500;
return boundsSize;
}
static NSBitmapImageRep *getBitmapImageRepForSVGDocument(DrawDocument *document)
{
[view setDocument:document];
[view sizeToFitViewBox];
NSSize boundsSize = constrainSizeToMaximum([view bounds].size);
[view setFrameSize:boundsSize];
// tell that view to render
NSBitmapImageRep *imageRep = [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
[view cacheDisplayInRect:[view bounds] toBitmapImageRep:imageRep];
return imageRep;
}
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 42;
objects = {
/* Begin PBXBuildFile section */
8DD76F9A0486AA7600D96B5E /* DumpKCanvasTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* DumpKCanvasTree.m */; settings = {ATTRIBUTES = (); }; };
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
A810E4BC08A4462800333D98 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A810E4BB08A4462800333D98 /* WebCore.framework */; };
/* End PBXBuildFile section */
/* Begin PBXBuildStyle section */
014CEA4F0018CE4811CA2923 /* Debug */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
ZERO_LINK = YES;
};
name = Debug;
};
014CEA500018CE4811CA2923 /* Release */ = {
isa = PBXBuildStyle;
buildSettings = {
COPY_PHASE_STRIP = YES;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
ZERO_LINK = NO;
};
name = Release;
};
/* End PBXBuildStyle section */
/* Begin PBXCopyFilesBuildPhase section */
8DD76F9E0486AA7600D96B5E /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 8;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
08FB7796FE84155DC02AAC07 /* DumpKCanvasTree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DumpKCanvasTree.m; sourceTree = "<group>"; };
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
8DD76FA10486AA7600D96B5E /* DumpKCanvasTree */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = DumpKCanvasTree; sourceTree = BUILT_PRODUCTS_DIR; };
A810E4BB08A4462800333D98 /* WebCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8DD76F9B0486AA7600D96B5E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */,
A810E4BC08A4462800333D98 /* WebCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
08FB7794FE84155DC02AAC07 /* DumpKCanvasTree */ = {
isa = PBXGroup;
children = (
08FB7795FE84155DC02AAC07 /* Source */,
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
1AB674ADFE9D54B511CA2CBB /* Products */,
);
name = DumpKCanvasTree;
sourceTree = "<group>";
};
08FB7795FE84155DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
08FB7796FE84155DC02AAC07 /* DumpKCanvasTree.m */,
);
name = Source;
sourceTree = "<group>";
};
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
A810E4BB08A4462800333D98 /* WebCore.framework */,
08FB779EFE84155DC02AAC07 /* Foundation.framework */,
);
name = "External Frameworks and Libraries";
sourceTree = "<group>";
};
1AB674ADFE9D54B511CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8DD76FA10486AA7600D96B5E /* DumpKCanvasTree */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8DD76F960486AA7600D96B5E /* DumpKCanvasTree */ = {
isa = PBXNativeTarget;
buildConfigurationList = A810DED508A40F3100333D98 /* Build configuration list for PBXNativeTarget "DumpKCanvasTree" */;
buildPhases = (
8DD76F990486AA7600D96B5E /* Sources */,
8DD76F9B0486AA7600D96B5E /* Frameworks */,
8DD76F9E0486AA7600D96B5E /* CopyFiles */,
);
buildRules = (
);
buildSettings = {
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = DumpKCanvasTree_Prefix.pch;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "$(HOME)/bin";
PREBINDING = NO;
PRODUCT_NAME = DumpKCanvasTree;
};
dependencies = (
);
name = DumpKCanvasTree;
productInstallPath = "$(HOME)/bin";
productName = DumpKCanvasTree;
productReference = 8DD76FA10486AA7600D96B5E /* DumpKCanvasTree */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = A810DED908A40F3100333D98 /* Build configuration list for PBXProject "DumpKCanvasTree" */;
buildSettings = {
};
buildStyles = (
014CEA4F0018CE4811CA2923 /* Debug */,
014CEA500018CE4811CA2923 /* Release */,
);
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* DumpKCanvasTree */;
projectDirPath = "";
targets = (
8DD76F960486AA7600D96B5E /* DumpKCanvasTree */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
8DD76F990486AA7600D96B5E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8DD76F9A0486AA7600D96B5E /* DumpKCanvasTree.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
A810DED608A40F3100333D98 /* Development */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "$(HOME)/bin";
PREBINDING = NO;
PRODUCT_NAME = DumpKCanvasTree;
ZERO_LINK = YES;
};
name = Development;
};
A810DED708A40F3100333D98 /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = YES;
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "$(HOME)/bin";
PREBINDING = NO;
PRODUCT_NAME = DumpKCanvasTree;
ZERO_LINK = NO;
};
name = Deployment;
};
A810DED808A40F3100333D98 /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "$(HOME)/bin";
PREBINDING = NO;
PRODUCT_NAME = DumpKCanvasTree;
};
name = Default;
};
A810DEDA08A40F3100333D98 /* Development */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
};
name = Development;
};
A810DEDB08A40F3100333D98 /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
};
name = Deployment;
};
A810DEDC08A40F3100333D98 /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
};
name = Default;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
A810DED508A40F3100333D98 /* Build configuration list for PBXNativeTarget "DumpKCanvasTree" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A810DED608A40F3100333D98 /* Development */,
A810DED708A40F3100333D98 /* Deployment */,
A810DED808A40F3100333D98 /* Default */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
};
A810DED908A40F3100333D98 /* Build configuration list for PBXProject "DumpKCanvasTree" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A810DEDA08A40F3100333D98 /* Development */,
A810DEDB08A40F3100333D98 /* Deployment */,
A810DEDC08A40F3100333D98 /* Default */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
};
/* End XCConfigurationList section */
};
rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment