+2005-06-03 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by NOBODY (OOPS!).
+
+ - replace use of CGCompositeOperation SPI with NSCompositingOperation API
+
+ * WebCoreSupport.subproj/WebImageData.h:
+ * WebCoreSupport.subproj/WebImageData.m:
+ (-[WebImageData _fillSolidColorInRect:compositeOperation:context:]):
+ (-[WebImageData _PDFDrawFromRect:toRect:operation:alpha:flipped:context:]):
+ * WebCoreSupport.subproj/WebImageRenderer.m:
+ (-[WebImageRenderer drawImageInRect:fromRect:]):
+ (-[WebImageRenderer drawImageInRect:fromRect:compositeOperator:context:]):
+ * WebCoreSupport.subproj/WebImageRendererFactory.m:
+ (-[WebImageRendererFactory CGCompositeOperationInContext:]):
+ (-[WebImageRendererFactory setCGCompositeOperation:inContext:]):
+ (-[WebImageRendererFactory setCGCompositeOperationFromString:inContext:]):
+
2005-06-02 Maciej Stachowiak <mjs@apple.com>
Reviewed by Kevin.
#import <WebCore/WebCoreImageRenderer.h>
-#import <CoreGraphics/CGContextPrivate.h>
#import <CoreGraphics/CGContextGState.h>
#import <CoreGraphics/CGColorSpacePrivate.h>
- (CFDictionaryRef)_imageSourceOptions;
-(void)_createPDFWithData:(NSData *)data;
- (CGPDFDocumentRef)_PDFDocumentRef;
-- (BOOL)_PDFDrawFromRect:(NSRect)srcRect toRect:(NSRect)dstRect operation:(CGCompositeOperation)op alpha:(float)alpha flipped:(BOOL)flipped context:(CGContextRef)context;
+- (BOOL)_PDFDrawFromRect:(NSRect)srcRect toRect:(NSRect)dstRect operation:(NSCompositingOperation)op alpha:(float)alpha flipped:(BOOL)flipped context:(CGContextRef)context;
- (void)_cacheImages:(size_t)optionalIndex allImages:(BOOL)allImages;
@end
return YES;
}
-- (void)_fillSolidColorInRect:(CGRect)rect compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext
+- (void)_fillSolidColorInRect:(CGRect)rect compositeOperation:(NSCompositingOperation)op context:(CGContextRef)aContext
{
/*NSLog(@"WebImageData %p: filling with color %p, in {%.0f,%.0f, %.0f x %.0f}",
self,solidColor,rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);*/
}
}
-- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr adjustedSize:(CGSize)adjustedSize compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr adjustedSize:(CGSize)adjustedSize compositeOperation:(NSCompositingOperation)op context:(CGContextRef)aContext;
{
if (isPDF) {
[self _PDFDrawFromRect:NSMakeRect(fr.origin.x, fr.origin.y, fr.size.width, fr.size.height)
}
}
-- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(CGCompositeOperation)op context:(CGContextRef)aContext;
+- (void)drawImageAtIndex:(size_t)index inRect:(CGRect)ir fromRect:(CGRect)fr compositeOperation:(NSCompositingOperation)op context:(CGContextRef)aContext;
{
[self drawImageAtIndex:index inRect:ir fromRect:fr adjustedSize:[self size] compositeOperation:op context:aContext];
}
}
}
-- (BOOL)_PDFDrawFromRect:(NSRect)srcRect toRect:(NSRect)dstRect operation:(CGCompositeOperation)op alpha:(float)alpha flipped:(BOOL)flipped context:(CGContextRef)context
+- (BOOL)_PDFDrawFromRect:(NSRect)srcRect toRect:(NSRect)dstRect operation:(NSCompositingOperation)op alpha:(float)alpha flipped:(BOOL)flipped context:(CGContextRef)context
{
float hScale, vScale;
#import <WebCore/WebCoreImageRenderer.h>
#import <CoreGraphics/CGContextPrivate.h>
-#import <CoreGraphics/CGContextGState.h>
-#import <CoreGraphics/CGColorSpacePrivate.h>
#ifdef USE_CGIMAGEREF
- (void)drawImageInRect:(NSRect)ir fromRect:(NSRect)fr
{
CGContextRef aContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
- CGCompositeOperation op = kCGCompositeSover;
+ NSCompositingOperation op = NSCompositeSourceOver;
[self drawImageInRect:ir fromRect:fr compositeOperator:op context:aContext];
}
if (aContext == 0)
aContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
- CGCompositeOperation op = (CGCompositeOperation)operator;
- if (op == kCGCompositeUnknown)
- op = kCGCompositeSover;
+ NSCompositingOperation op = (NSCompositingOperation)operator;
if (isSizeAdjusted) {
[imageData drawImageAtIndex:[imageData currentFrame] inRect:CGRectMake(ir.origin.x, ir.origin.y, ir.size.width, ir.size.height)
#import <WebKit/WebAssertions.h>
#import <Foundation/NSURLFileTypeMappings.h>
-#import <CoreGraphics/CGContextPrivate.h>
-
@implementation WebImageRendererFactory
+ (void)createSharedFactory
struct CompositeOperator
{
NSString *name;
- CGCompositeOperation value;
+ NSCompositingOperation value;
};
#define NUM_COMPOSITE_OPERATORS 14
-struct CompositeOperator CGCompositeOperations[NUM_COMPOSITE_OPERATORS] = {
- { @"clear", kCGCompositeClear },
- { @"copy", kCGCompositeCopy },
- { @"source-over", kCGCompositeSover },
- { @"source-in", kCGCompositeSin },
- { @"source-out", kCGCompositeSout },
- { @"source-atop", kCGCompositeSatop },
- { @"destination-over", kCGCompositeDover },
- { @"destination-in", kCGCompositeDin },
- { @"destination-out", kCGCompositeDout },
- { @"destination-atop", kCGCompositeDatop },
- { @"xor", kCGCompositeXor },
- { @"darker", kCGCompositePlusd },
- { @"highlight", kCGCompositePlusl },
- { @"lighter", kCGCompositePlusl } // Per AppKit
+struct CompositeOperator NSCompositingOperations[NUM_COMPOSITE_OPERATORS] = {
+ { @"clear", NSCompositeClear },
+ { @"copy", NSCompositeCopy },
+ { @"source-over", NSCompositeSourceOver },
+ { @"source-in", NSCompositeSourceIn },
+ { @"source-out", NSCompositeSourceOut },
+ { @"source-atop", NSCompositeSourceAtop },
+ { @"destination-over", NSCompositeDestinationOver },
+ { @"destination-in", NSCompositeDestinationIn },
+ { @"destination-out", NSCompositeDestinationOut },
+ { @"destination-atop", NSCompositeDestinationAtop },
+ { @"xor", NSCompositeXOR },
+ { @"darker", NSCompositePlusDarker },
+ { @"highlight", NSCompositeHighlight },
+ { @"lighter", NSCompositeHighlight } // Per AppKit
};
- (int)CGCompositeOperationInContext:(CGContextRef)context
{
- CGCompositeOperation op = CGContextGetCompositeOperation (context);
- return (int)op;
+ return [[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO] compositingOperation];
}
- (void)setCGCompositeOperation:(int)op inContext:(CGContextRef)context
{
- CGContextSetCompositeOperation(context, (CGCompositeOperation)op);
+ [[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO] setCompositingOperation:op];
}
- (void)setCGCompositeOperationFromString:(NSString *)operatorString inContext:(CGContextRef)context
{
- CGCompositeOperation op = kCGCompositeSover;
+ NSCompositingOperation op = NSCompositeSourceOver;
if (operatorString) {
int i;
for (i = 0; i < NUM_COMPOSITE_OPERATORS; i++) {
- if ([operatorString caseInsensitiveCompare:CGCompositeOperations[i].name] == NSOrderedSame) {
- op = CGCompositeOperations[i].value;
+ if ([operatorString caseInsensitiveCompare:NSCompositingOperations[i].name] == NSOrderedSame) {
+ op = NSCompositingOperations[i].value;
break;
}
}
}
- CGContextSetCompositeOperation(context, op);
+ [[NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO] setCompositingOperation:op];
}