[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:22:13 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c0fc314a43e5f99be4048768a1e29e0fa8b41e7d
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jun 28 23:53:46 2002 +0000

            * WebCoreSupport.subproj/IFImageRenderer.h: Renamed statusOfCache to
    	patternColorLoadStatus for clarity.
            * WebCoreSupport.subproj/IFImageRenderer.m:
            (-[IFImageRenderer copyWithZone:]): Add FIXME.
            (-[IFImageRenderer tileInRect:fromPoint:]): Add optimization for the
    	case where a single draw of the image will cover the entire area to be
    	tiled. Also add comments and make other small improvements.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1475 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index d7f11ab..cfcabda 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,13 @@
+2002-06-28  Darin Adler  <darin at apple.com>
+
+        * WebCoreSupport.subproj/IFImageRenderer.h: Renamed statusOfCache to
+	patternColorLoadStatus for clarity.
+        * WebCoreSupport.subproj/IFImageRenderer.m:
+        (-[IFImageRenderer copyWithZone:]): Add FIXME.
+        (-[IFImageRenderer tileInRect:fromPoint:]): Add optimization for the
+	case where a single draw of the image will cover the entire area to be
+	tiled. Also add comments and make other small improvements.
+
 2002-06-28  Richard Williamson  <rjw at apple.com>
 
         Use float character measurement to determine selection
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index d7f11ab..cfcabda 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,13 @@
+2002-06-28  Darin Adler  <darin at apple.com>
+
+        * WebCoreSupport.subproj/IFImageRenderer.h: Renamed statusOfCache to
+	patternColorLoadStatus for clarity.
+        * WebCoreSupport.subproj/IFImageRenderer.m:
+        (-[IFImageRenderer copyWithZone:]): Add FIXME.
+        (-[IFImageRenderer tileInRect:fromPoint:]): Add optimization for the
+	case where a single draw of the image will cover the entire area to be
+	tiled. Also add comments and make other small improvements.
+
 2002-06-28  Richard Williamson  <rjw at apple.com>
 
         Use float character measurement to determine selection
diff --git a/WebKit/WebCoreSupport.subproj/IFImageRenderer.h b/WebKit/WebCoreSupport.subproj/IFImageRenderer.h
index ebd86bc..7779d23 100644
--- a/WebKit/WebCoreSupport.subproj/IFImageRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/IFImageRenderer.h
@@ -11,9 +11,9 @@
     NSView *frameView;
     NSRect imageRect;
     NSRect targetRect;
-    NSColor *patternColor;
     int loadStatus;
-    int statusOfCache;
+    NSColor *patternColor;
+    int patternColorLoadStatus;
 }
 
 + (void)stopAnimationsInView: (NSView *)aView;
diff --git a/WebKit/WebCoreSupport.subproj/IFImageRenderer.m b/WebKit/WebCoreSupport.subproj/IFImageRenderer.m
index cdc6385..d5e867b 100644
--- a/WebKit/WebCoreSupport.subproj/IFImageRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/IFImageRenderer.m
@@ -25,20 +25,12 @@ static NSMutableArray *activeImageRenderers;
     
 }
 
-- initWithSize:(NSSize)size
-{
-    self = [super initWithSize:size];
-    
-    statusOfCache = NSImageRepLoadStatusUnknownType;
-    
-    return self;
-}
-
-
 - copyWithZone:(NSZone *)zone
 {
     IFImageRenderer *copy = [super copyWithZone:zone];
     
+    // FIXME: If we copy while doing an incremental load, it won't work.
+    
     copy->frameTimer = nil;
     copy->frameView = nil;
     copy->patternColor = nil;
@@ -84,12 +76,6 @@ static NSMutableArray *activeImageRenderers;
 }
 
 
-- (int)loadStatus
-{
-    return loadStatus;
-}
-
-
 - (void)dealloc
 {
     [self stopAnimation];
@@ -206,7 +192,7 @@ static NSMutableArray *activeImageRenderers;
         [activeImageRenderers addObject: self];
     }
 
-    [self drawInRect: ir 
+    [self drawInRect: ir
             fromRect: fr
            operation: NSCompositeSourceOver	// Renders transparency correctly
             fraction: 1.0];
@@ -232,33 +218,61 @@ static NSMutableArray *activeImageRenderers;
 
 - (void)tileInRect:(NSRect)rect fromPoint:(NSPoint)point
 {
-    int currentStatus = [self loadStatus];
+    // If it's too early to draw, just do nothing.
+    if (loadStatus <= 0 && loadStatus != NSImageRepLoadStatusCompleted) {
+        return;
+    }
     
-    if (currentStatus > 0 || currentStatus == NSImageRepLoadStatusCompleted){
-        if (statusOfCache != currentStatus){
-            [patternColor release];
-            patternColor = [[NSColor colorWithPatternImage:self] retain];
-            statusOfCache = currentStatus;
-        }
-        
-        // FIXME: This doesn't use the passed in point to determine the pattern phase.
-        // It might be OK to do what we're doing, but I'm not 100% sure.
-        // This code uses the coordinate system of whatever converting toView:nil
-        // does, which may be OK.
-        NSPoint p = [[NSView focusView] convertPoint:rect.origin toView:nil];
-        NSSize size = [self size];
-        CGSize phase = { (int)p.x % (int)size.width, (int)p.y % (int)size.height };
-        
-        [NSGraphicsContext saveGraphicsState];
-        
-        CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-        CGContextSetPatternPhase(cgContext, phase);
-        [patternColor set];
+    NSSize size = [self size];
+
+    // Check and see if a single draw of the image can convert the entire area we are supposed to tile.
+    WEBKIT_ASSERT([[NSView focusView] isFlipped]);
+    NSRect oneTileRect;
+    oneTileRect.origin.x = fmodf(rect.origin.x - point.x, size.width);
+    if (oneTileRect.origin.x > 0)
+        oneTileRect.origin.x -= size.width;
+    oneTileRect.origin.y = fmodf(rect.origin.y - point.y, size.height);
+    if (oneTileRect.origin.y > 0)
+        oneTileRect.origin.y -= size.height;
+    oneTileRect.size = size;
+    
+    // If the single image draw covers the whole area, then just draw once.
+    if (NSContainsRect(oneTileRect, rect)) {
+        NSRect fromRect;
+        fromRect.origin.x = rect.origin.x - oneTileRect.origin.x;
+        fromRect.origin.y = (oneTileRect.origin.y + oneTileRect.size.height) - (rect.origin.y + rect.size.height);
+        fromRect.size = rect.size;
         
-        [NSBezierPath fillRect:rect];
+        [self drawInRect:rect
+                fromRect:fromRect
+               operation:NSCompositeSourceOver
+                fraction:1.0];
         
-        [NSGraphicsContext restoreGraphicsState];
+        return;
+    }
+    
+    // Since we need to tile, construct an NSColor so we can get CoreGraphics to do it for us.
+    if (patternColorLoadStatus != loadStatus) {
+        [patternColor release];
+        patternColor = nil;
+    }
+    if (patternColor == nil) {
+        patternColor = [[NSColor colorWithPatternImage:self] retain];
+        patternColorLoadStatus = loadStatus;
     }
+    
+    // Compute the appropriate phase relative to the top level view in the window.
+    // Conveniently, the oneTileRect we computed above has the appropriate origin.
+    NSPoint originInWindow = [[NSView focusView] convertPoint:oneTileRect.origin toView:nil];
+    CGSize phase = CGSizeMake(fmodf(originInWindow.x, size.width), fmodf(originInWindow.y, size.height));
+    
+    [NSGraphicsContext saveGraphicsState];
+    
+    CGContextSetPatternPhase((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort], phase);    
+    [patternColor set];
+    [NSBezierPath fillRect:rect];
+    
+    [NSGraphicsContext restoreGraphicsState];
 }
 
 // required by protocol -- apparently inherited methods don't count
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
index ebd86bc..7779d23 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.h
@@ -11,9 +11,9 @@
     NSView *frameView;
     NSRect imageRect;
     NSRect targetRect;
-    NSColor *patternColor;
     int loadStatus;
-    int statusOfCache;
+    NSColor *patternColor;
+    int patternColorLoadStatus;
 }
 
 + (void)stopAnimationsInView: (NSView *)aView;
diff --git a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
index cdc6385..d5e867b 100644
--- a/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
+++ b/WebKit/WebCoreSupport.subproj/WebImageRenderer.m
@@ -25,20 +25,12 @@ static NSMutableArray *activeImageRenderers;
     
 }
 
-- initWithSize:(NSSize)size
-{
-    self = [super initWithSize:size];
-    
-    statusOfCache = NSImageRepLoadStatusUnknownType;
-    
-    return self;
-}
-
-
 - copyWithZone:(NSZone *)zone
 {
     IFImageRenderer *copy = [super copyWithZone:zone];
     
+    // FIXME: If we copy while doing an incremental load, it won't work.
+    
     copy->frameTimer = nil;
     copy->frameView = nil;
     copy->patternColor = nil;
@@ -84,12 +76,6 @@ static NSMutableArray *activeImageRenderers;
 }
 
 
-- (int)loadStatus
-{
-    return loadStatus;
-}
-
-
 - (void)dealloc
 {
     [self stopAnimation];
@@ -206,7 +192,7 @@ static NSMutableArray *activeImageRenderers;
         [activeImageRenderers addObject: self];
     }
 
-    [self drawInRect: ir 
+    [self drawInRect: ir
             fromRect: fr
            operation: NSCompositeSourceOver	// Renders transparency correctly
             fraction: 1.0];
@@ -232,33 +218,61 @@ static NSMutableArray *activeImageRenderers;
 
 - (void)tileInRect:(NSRect)rect fromPoint:(NSPoint)point
 {
-    int currentStatus = [self loadStatus];
+    // If it's too early to draw, just do nothing.
+    if (loadStatus <= 0 && loadStatus != NSImageRepLoadStatusCompleted) {
+        return;
+    }
     
-    if (currentStatus > 0 || currentStatus == NSImageRepLoadStatusCompleted){
-        if (statusOfCache != currentStatus){
-            [patternColor release];
-            patternColor = [[NSColor colorWithPatternImage:self] retain];
-            statusOfCache = currentStatus;
-        }
-        
-        // FIXME: This doesn't use the passed in point to determine the pattern phase.
-        // It might be OK to do what we're doing, but I'm not 100% sure.
-        // This code uses the coordinate system of whatever converting toView:nil
-        // does, which may be OK.
-        NSPoint p = [[NSView focusView] convertPoint:rect.origin toView:nil];
-        NSSize size = [self size];
-        CGSize phase = { (int)p.x % (int)size.width, (int)p.y % (int)size.height };
-        
-        [NSGraphicsContext saveGraphicsState];
-        
-        CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-        CGContextSetPatternPhase(cgContext, phase);
-        [patternColor set];
+    NSSize size = [self size];
+
+    // Check and see if a single draw of the image can convert the entire area we are supposed to tile.
+    WEBKIT_ASSERT([[NSView focusView] isFlipped]);
+    NSRect oneTileRect;
+    oneTileRect.origin.x = fmodf(rect.origin.x - point.x, size.width);
+    if (oneTileRect.origin.x > 0)
+        oneTileRect.origin.x -= size.width;
+    oneTileRect.origin.y = fmodf(rect.origin.y - point.y, size.height);
+    if (oneTileRect.origin.y > 0)
+        oneTileRect.origin.y -= size.height;
+    oneTileRect.size = size;
+    
+    // If the single image draw covers the whole area, then just draw once.
+    if (NSContainsRect(oneTileRect, rect)) {
+        NSRect fromRect;
+        fromRect.origin.x = rect.origin.x - oneTileRect.origin.x;
+        fromRect.origin.y = (oneTileRect.origin.y + oneTileRect.size.height) - (rect.origin.y + rect.size.height);
+        fromRect.size = rect.size;
         
-        [NSBezierPath fillRect:rect];
+        [self drawInRect:rect
+                fromRect:fromRect
+               operation:NSCompositeSourceOver
+                fraction:1.0];
         
-        [NSGraphicsContext restoreGraphicsState];
+        return;
+    }
+    
+    // Since we need to tile, construct an NSColor so we can get CoreGraphics to do it for us.
+    if (patternColorLoadStatus != loadStatus) {
+        [patternColor release];
+        patternColor = nil;
+    }
+    if (patternColor == nil) {
+        patternColor = [[NSColor colorWithPatternImage:self] retain];
+        patternColorLoadStatus = loadStatus;
     }
+    
+    // Compute the appropriate phase relative to the top level view in the window.
+    // Conveniently, the oneTileRect we computed above has the appropriate origin.
+    NSPoint originInWindow = [[NSView focusView] convertPoint:oneTileRect.origin toView:nil];
+    CGSize phase = CGSizeMake(fmodf(originInWindow.x, size.width), fmodf(originInWindow.y, size.height));
+    
+    [NSGraphicsContext saveGraphicsState];
+    
+    CGContextSetPatternPhase((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort], phase);    
+    [patternColor set];
+    [NSBezierPath fillRect:rect];
+    
+    [NSGraphicsContext restoreGraphicsState];
 }
 
 // required by protocol -- apparently inherited methods don't count

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list