+2006-08-23 David Hyatt <hyatt@apple.com>
+
+ Refactor Cairo and CoreGraphics to use platform ifdefs. This patch
+ separates the graphics engines from their respective platforms and replaces
+ #ifdef PLATFORM(MAC) and PLATFORM(WIN) with PLATFORM(CG) and PLATFORM(CAIRO).
+
+ Reviewed by darin
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/AffineTransform.h:
+ * platform/Color.h:
+ * platform/Cursor.h:
+ * platform/FloatPoint.h:
+ * platform/FloatRect.h:
+ * platform/FloatSize.h:
+ * platform/Font.h:
+ * platform/FontData.h:
+ * platform/GlyphBuffer.h:
+ (WebCore::GlyphBuffer::glyphAt):
+ (WebCore::GlyphBuffer::advanceAt):
+ (WebCore::GlyphBuffer::add):
+ * platform/GraphicsContext.h:
+ * platform/Image.h:
+ * platform/ImageSource.h:
+ * platform/IntPoint.h:
+ * platform/IntRect.h:
+ * platform/IntSize.h:
+ * platform/ResourceLoader.h:
+ * platform/ResourceLoaderClient.h:
+ * platform/Widget.h:
+ * platform/cairo/GraphicsContextCairo.cpp:
+ * platform/cairo/ImageCairo.cpp:
+ * platform/cairo/ImageSourceCairo.cpp:
+ * platform/cg/AffineTransformCG.cpp:
+ * platform/cg/FloatPointCG.cpp: Added.
+ * platform/cg/FloatRectCG.cpp: Added.
+ * platform/cg/FloatSizeCG.cpp: Added.
+ * platform/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::GraphicsContext):
+ (WebCore::GraphicsContext::~GraphicsContext):
+ (WebCore::GraphicsContext::setFocusRingClip):
+ (WebCore::GraphicsContext::clearFocusRingClip):
+ (WebCore::GraphicsContext::platformContext):
+ (WebCore::GraphicsContext::drawRect):
+ (WebCore::GraphicsContext::drawLine):
+ * platform/cg/GraphicsContextPlatformPrivate.h: Added.
+ (WebCore::GraphicsContextPlatformPrivate:::m_cgContext):
+ (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
+ * platform/cg/ImageCG.cpp: Added.
+ (WebCore::Image::drawTiled):
+ * platform/cg/ImageSourceCG.cpp: Added.
+ * platform/cg/IntPointCG.cpp: Added.
+ * platform/cg/IntRectCG.cpp: Added.
+ * platform/cg/IntSizeCG.cpp: Added.
+ * platform/cg/PDFDocumentImage.cpp: Added.
+ (WebCore::PDFDocumentImage::adjustCTM):
+ * platform/cg/PDFDocumentImage.h: Added.
+ * platform/cg/PathCG.cpp:
+ * platform/image-decoders/bmp/BMPImageDecoder.cpp:
+ * platform/image-decoders/gif/GIFImageDecoder.cpp:
+ * platform/image-decoders/gif/GIFImageReader.cpp:
+ * platform/image-decoders/ico/ICOImageDecoder.cpp:
+ * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+ * platform/image-decoders/png/PNGImageDecoder.cpp:
+ * platform/image-decoders/xbm/XBMImageDecoder.cpp:
+ * platform/mac/FloatPointMac.mm:
+ * platform/mac/FloatRectMac.mm:
+ * platform/mac/FloatSizeMac.mm:
+ * platform/mac/GraphicsContextMac.mm:
+ * platform/mac/ImageMac.mm:
+ * platform/mac/ImageSourceMac.cpp: Removed.
+ * platform/mac/IntPointMac.mm:
+ * platform/mac/IntRectMac.mm:
+ * platform/mac/IntSizeMac.mm:
+ * platform/mac/PDFDocumentImage.h: Removed.
+ * platform/mac/PDFDocumentImage.mm: Removed.
+
2006-08-23 David Hyatt <hyatt@apple.com>
Remove the ifdef for platform scrollbars vs. engine scrollbars until
6582A15909999D6D00BEEB6D /* FloatRectMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A14B09999D6C00BEEB6D /* FloatRectMac.mm */; };
6582A15A09999D6D00BEEB6D /* FloatSizeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A14C09999D6C00BEEB6D /* FloatSizeMac.mm */; };
6582A15B09999D6D00BEEB6D /* ImageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A14D09999D6C00BEEB6D /* ImageMac.mm */; };
- 6582A15C09999D6D00BEEB6D /* ImageSourceMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6582A14E09999D6D00BEEB6D /* ImageSourceMac.cpp */; };
6582A15D09999D6D00BEEB6D /* IntPointMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A14F09999D6D00BEEB6D /* IntPointMac.mm */; };
6582A15E09999D6D00BEEB6D /* IntRectMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15009999D6D00BEEB6D /* IntRectMac.mm */; };
6582A15F09999D6D00BEEB6D /* IntSizeMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15109999D6D00BEEB6D /* IntSizeMac.mm */; };
- 6582A16009999D6D00BEEB6D /* PDFDocumentImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6582A15209999D6D00BEEB6D /* PDFDocumentImage.h */; };
- 6582A16109999D6D00BEEB6D /* PDFDocumentImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15309999D6D00BEEB6D /* PDFDocumentImage.mm */; };
6582A16209999D6D00BEEB6D /* ScreenMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15409999D6D00BEEB6D /* ScreenMac.mm */; };
6582A16309999D6D00BEEB6D /* SystemTimeMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */; };
6582A17809999EA000BEEB6D /* DeprecatedStringMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6582A17709999EA000BEEB6D /* DeprecatedStringMac.mm */; };
BC73E3190978AFFC00EDFF8A /* IntPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = BC73E3180978AFFB00EDFF8A /* IntPoint.h */; };
BC73E3920978CED700EDFF8A /* FloatPoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC73E3900978CED700EDFF8A /* FloatPoint.cpp */; };
BC73E3930978CED700EDFF8A /* FloatPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = BC73E3910978CED700EDFF8A /* FloatPoint.h */; };
+ BC837C720A9D0D1A006B186A /* FloatPointCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C670A9D0D1A006B186A /* FloatPointCG.cpp */; };
+ BC837C730A9D0D1A006B186A /* FloatRectCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C680A9D0D1A006B186A /* FloatRectCG.cpp */; };
+ BC837C740A9D0D1A006B186A /* FloatSizeCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C690A9D0D1A006B186A /* FloatSizeCG.cpp */; };
+ BC837C750A9D0D1A006B186A /* ImageCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C6A0A9D0D1A006B186A /* ImageCG.cpp */; };
+ BC837C760A9D0D1A006B186A /* ImageCG.cpp.orig in Resources */ = {isa = PBXBuildFile; fileRef = BC837C6B0A9D0D1A006B186A /* ImageCG.cpp.orig */; };
+ BC837C770A9D0D1A006B186A /* ImageSourceCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C6C0A9D0D1A006B186A /* ImageSourceCG.cpp */; };
+ BC837C780A9D0D1A006B186A /* IntPointCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C6D0A9D0D1A006B186A /* IntPointCG.cpp */; };
+ BC837C790A9D0D1A006B186A /* IntRectCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C6E0A9D0D1A006B186A /* IntRectCG.cpp */; };
+ BC837C7A0A9D0D1A006B186A /* IntSizeCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C6F0A9D0D1A006B186A /* IntSizeCG.cpp */; };
+ BC837C7B0A9D0D1A006B186A /* PDFDocumentImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC837C700A9D0D1A006B186A /* PDFDocumentImage.cpp */; };
+ BC837C7C0A9D0D1A006B186A /* PDFDocumentImage.h in Headers */ = {isa = PBXBuildFile; fileRef = BC837C710A9D0D1A006B186A /* PDFDocumentImage.h */; };
+ BC837CB60A9D10FE006B186A /* GraphicsContextPlatformPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC837CB50A9D10FE006B186A /* GraphicsContextPlatformPrivate.h */; };
BC92F1DD0A40AEA300AC0746 /* DeprecatedSlider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC92F1DB0A40AEA300AC0746 /* DeprecatedSlider.cpp */; };
BC92F1DE0A40AEA300AC0746 /* DeprecatedSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = BC92F1DC0A40AEA300AC0746 /* DeprecatedSlider.h */; };
BC9C328B09933A6E001D6924 /* ImageAnimationObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9C328A09933A6D001D6924 /* ImageAnimationObserver.h */; };
FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
/* End PBXBuildFile section */
+/* Begin PBXBuildStyle section */
+ BC837C570A9D0AA0006B186A /* Development */ = {
+ isa = PBXBuildStyle;
+ buildSettings = {
+ COPY_PHASE_STRIP = NO;
+ };
+ name = Development;
+ };
+ BC837C580A9D0AA0006B186A /* Deployment */ = {
+ isa = PBXBuildStyle;
+ buildSettings = {
+ COPY_PHASE_STRIP = YES;
+ };
+ name = Deployment;
+ };
+/* End PBXBuildStyle section */
+
/* Begin PBXContainerItemProxy section */
DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
6582A14B09999D6C00BEEB6D /* FloatRectMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FloatRectMac.mm; sourceTree = "<group>"; };
6582A14C09999D6C00BEEB6D /* FloatSizeMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FloatSizeMac.mm; sourceTree = "<group>"; };
6582A14D09999D6C00BEEB6D /* ImageMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ImageMac.mm; sourceTree = "<group>"; };
- 6582A14E09999D6D00BEEB6D /* ImageSourceMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageSourceMac.cpp; sourceTree = "<group>"; };
6582A14F09999D6D00BEEB6D /* IntPointMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntPointMac.mm; sourceTree = "<group>"; };
6582A15009999D6D00BEEB6D /* IntRectMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntRectMac.mm; sourceTree = "<group>"; };
6582A15109999D6D00BEEB6D /* IntSizeMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = IntSizeMac.mm; sourceTree = "<group>"; };
- 6582A15209999D6D00BEEB6D /* PDFDocumentImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PDFDocumentImage.h; sourceTree = "<group>"; };
- 6582A15309999D6D00BEEB6D /* PDFDocumentImage.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PDFDocumentImage.mm; sourceTree = "<group>"; };
6582A15409999D6D00BEEB6D /* ScreenMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ScreenMac.mm; sourceTree = "<group>"; };
6582A15509999D6D00BEEB6D /* SystemTimeMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SystemTimeMac.cpp; sourceTree = "<group>"; };
6582A17709999EA000BEEB6D /* DeprecatedStringMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = DeprecatedStringMac.mm; sourceTree = "<group>"; };
BC73E3910978CED700EDFF8A /* FloatPoint.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FloatPoint.h; sourceTree = "<group>"; };
BC7B2AF80450824100A8000F /* ScrollBar.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ScrollBar.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
BC7B2AF90450824100A8000F /* PlatformScrollBarMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformScrollBarMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
+ BC837C670A9D0D1A006B186A /* FloatPointCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatPointCG.cpp; sourceTree = "<group>"; };
+ BC837C680A9D0D1A006B186A /* FloatRectCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatRectCG.cpp; sourceTree = "<group>"; };
+ BC837C690A9D0D1A006B186A /* FloatSizeCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FloatSizeCG.cpp; sourceTree = "<group>"; };
+ BC837C6A0A9D0D1A006B186A /* ImageCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageCG.cpp; sourceTree = "<group>"; };
+ BC837C6B0A9D0D1A006B186A /* ImageCG.cpp.orig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ImageCG.cpp.orig; sourceTree = "<group>"; };
+ BC837C6C0A9D0D1A006B186A /* ImageSourceCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ImageSourceCG.cpp; sourceTree = "<group>"; };
+ BC837C6D0A9D0D1A006B186A /* IntPointCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IntPointCG.cpp; sourceTree = "<group>"; };
+ BC837C6E0A9D0D1A006B186A /* IntRectCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IntRectCG.cpp; sourceTree = "<group>"; };
+ BC837C6F0A9D0D1A006B186A /* IntSizeCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IntSizeCG.cpp; sourceTree = "<group>"; };
+ BC837C700A9D0D1A006B186A /* PDFDocumentImage.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PDFDocumentImage.cpp; sourceTree = "<group>"; };
+ BC837C710A9D0D1A006B186A /* PDFDocumentImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PDFDocumentImage.h; sourceTree = "<group>"; };
+ BC837CB50A9D10FE006B186A /* GraphicsContextPlatformPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GraphicsContextPlatformPrivate.h; sourceTree = "<group>"; };
BC86FB8D061F5C23006BB822 /* Slider.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Slider.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
BC86FB8E061F5C23006BB822 /* SliderMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SliderMac.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
BC92F1DB0A40AEA300AC0746 /* DeprecatedSlider.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DeprecatedSlider.cpp; sourceTree = "<group>"; };
BC6DB4D30A1AFEEF00E5CD14 /* GlyphMapMac.cpp */,
935367E809AF77EF00D35CD6 /* GraphicsContextMac.mm */,
6582A14D09999D6C00BEEB6D /* ImageMac.mm */,
- 6582A14E09999D6D00BEEB6D /* ImageSourceMac.cpp */,
6582A14F09999D6D00BEEB6D /* IntPointMac.mm */,
6582A15009999D6D00BEEB6D /* IntRectMac.mm */,
6582A15109999D6D00BEEB6D /* IntSizeMac.mm */,
F587851402DE375901EA4122 /* ListBoxMac.mm */,
935207BF09BD412000F2038D /* LocalizedStringsMac.mm */,
65F5382409B2B57500F3DC4A /* mac-encodings.txt */,
- 6582A15209999D6D00BEEB6D /* PDFDocumentImage.h */,
- 6582A15309999D6D00BEEB6D /* PDFDocumentImage.mm */,
935C476F09AC4D7300A6AAB4 /* PlatformMouseEventMac.mm */,
A82398A709B3ACF500B60641 /* PlugInInfoStoreMac.mm */,
F58784D202DE375901EA4122 /* PopUpButtonMac.mm */,
isa = PBXGroup;
children = (
93CF35A90A6169F700543E52 /* AffineTransformCG.cpp */,
+ BC837C670A9D0D1A006B186A /* FloatPointCG.cpp */,
+ BC837C680A9D0D1A006B186A /* FloatRectCG.cpp */,
+ BC837C690A9D0D1A006B186A /* FloatSizeCG.cpp */,
936BDD1C0A031AEB004DF4AB /* GraphicsContextCG.cpp */,
+ BC837C6A0A9D0D1A006B186A /* ImageCG.cpp */,
+ BC837C6B0A9D0D1A006B186A /* ImageCG.cpp.orig */,
+ BC837C6C0A9D0D1A006B186A /* ImageSourceCG.cpp */,
+ BC837C6D0A9D0D1A006B186A /* IntPointCG.cpp */,
+ BC837C6E0A9D0D1A006B186A /* IntRectCG.cpp */,
+ BC837C6F0A9D0D1A006B186A /* IntSizeCG.cpp */,
93032CC709AEC34300F82A18 /* PathCG.cpp */,
+ BC837CB50A9D10FE006B186A /* GraphicsContextPlatformPrivate.h */,
+ BC837C700A9D0D1A006B186A /* PDFDocumentImage.cpp */,
+ BC837C710A9D0D1A006B186A /* PDFDocumentImage.h */,
);
path = cg;
sourceTree = "<group>";
93CD4FEC0995FD2A007ECC97 /* PlatformString.h in Headers */,
BC6B7ECF0998AC7F0052867B /* ImageSource.h in Headers */,
6582A14009999CD600BEEB6D /* DeprecatedString.h in Headers */,
- 6582A16009999D6D00BEEB6D /* PDFDocumentImage.h in Headers */,
A7638A8B09958EA50007E14F /* WKDisplacementMapFilter.h in Headers */,
A7638A970995965D0007E14F /* SVGFEDisplacementMapElement.h in Headers */,
93309DD7099E64920056E581 /* AppendNodeCommand.h in Headers */,
657429170A9C2D0B00C52C97 /* IconDataCache.h in Headers */,
657429180A9C2D0B00C52C97 /* SQLStatement.h in Headers */,
657429190A9C2D0B00C52C97 /* SQLTransaction.h in Headers */,
+ BC837C7C0A9D0D1A006B186A /* PDFDocumentImage.h in Headers */,
+ BC837CB60A9D10FE006B186A /* GraphicsContextPlatformPrivate.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+ buildSettings = {
+ };
+ buildStyles = (
+ BC837C570A9D0AA0006B186A /* Development */,
+ BC837C580A9D0AA0006B186A /* Deployment */,
+ );
hasScannedForEncodings = 1;
knownRegions = (
English,
1CD441900A4CE76F00A007AB /* northWestSouthEastResizeCursor.tiff in Resources */,
1A750D880A90E394000FF215 /* NodeIterator.idl in Resources */,
5115095C0A9CE04700901013 /* urlIcon.tiff in Resources */,
+ BC837C760A9D0D1A006B186A /* ImageCG.cpp.orig in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
6582A15909999D6D00BEEB6D /* FloatRectMac.mm in Sources */,
6582A15A09999D6D00BEEB6D /* FloatSizeMac.mm in Sources */,
6582A15B09999D6D00BEEB6D /* ImageMac.mm in Sources */,
- 6582A15C09999D6D00BEEB6D /* ImageSourceMac.cpp in Sources */,
6582A15D09999D6D00BEEB6D /* IntPointMac.mm in Sources */,
6582A15E09999D6D00BEEB6D /* IntRectMac.mm in Sources */,
6582A15F09999D6D00BEEB6D /* IntSizeMac.mm in Sources */,
- 6582A16109999D6D00BEEB6D /* PDFDocumentImage.mm in Sources */,
6582A16209999D6D00BEEB6D /* ScreenMac.mm in Sources */,
6582A16309999D6D00BEEB6D /* SystemTimeMac.cpp in Sources */,
6582A17809999EA000BEEB6D /* DeprecatedStringMac.mm in Sources */,
1A750DD40A90E729000FF215 /* JSNodeIteratorCustom.cpp in Sources */,
1A750E340A90F89F000FF215 /* JSTreeWalkerCustom.cpp in Sources */,
5186C0560A9C21470034FE94 /* IconDataCache.cpp in Sources */,
+ BC837C720A9D0D1A006B186A /* FloatPointCG.cpp in Sources */,
+ BC837C730A9D0D1A006B186A /* FloatRectCG.cpp in Sources */,
+ BC837C740A9D0D1A006B186A /* FloatSizeCG.cpp in Sources */,
+ BC837C750A9D0D1A006B186A /* ImageCG.cpp in Sources */,
+ BC837C770A9D0D1A006B186A /* ImageSourceCG.cpp in Sources */,
+ BC837C780A9D0D1A006B186A /* IntPointCG.cpp in Sources */,
+ BC837C790A9D0D1A006B186A /* IntRectCG.cpp in Sources */,
+ BC837C7A0A9D0D1A006B186A /* IntSizeCG.cpp in Sources */,
+ BC837C7B0A9D0D1A006B186A /* PDFDocumentImage.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#ifndef AffineTransform_h
#define AffineTransform_h
-#if __APPLE__
+#include "config.h"
+
+#if PLATFORM(CG)
#include <ApplicationServices/ApplicationServices.h>
#elif PLATFORM(QT)
#include <QMatrix>
public:
AffineTransform();
AffineTransform(double a, double b, double c, double d, double tx, double ty);
-#if __APPLE__
+#if PLATFORM(CG)
AffineTransform(CGAffineTransform transform);
#elif PLATFORM(QT)
AffineTransform(const QMatrix &matrix);
bool isInvertible() const;
AffineTransform invert() const;
-#if __APPLE__
+#if PLATFORM(CG)
operator CGAffineTransform() const;
#elif PLATFORM(QT)
operator QMatrix() const;
AffineTransform operator*(const AffineTransform&);
private:
-#if __APPLE__
+#if PLATFORM(CG)
CGAffineTransform m_transform;
#elif PLATFORM(QT)
QMatrix m_transform;
#include <wtf/Platform.h>
-#if __APPLE__
-
+#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSColor;
#else
class NSColor;
#endif
+#endif
+#if PLATFORM(CG)
typedef struct CGColor* CGColorRef;
-
-#endif // __APPLE__
+#endif
#if PLATFORM(QT)
class QColor;
Color focusRingColor();
void setFocusRingColorChangeFunction(void (*)());
-#if __APPLE__
+#if PLATFORM(MAC)
NSColor* nsColor(const Color&);
+#endif
+
+#if PLATFORM(CG)
CGColorRef cgColor(const Color&);
#endif
#include <QCursor>
#endif
-#ifdef __APPLE__
+#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSCursor;
#else
#if PLATFORM(WIN)
typedef HCURSOR PlatformCursor;
-#elif defined(__APPLE__)
+#elif PLATFORM(MAC)
typedef NSCursor* PlatformCursor;
#elif PLATFORM(GDK)
typedef GdkCursor* PlatformCursor;
#include "FloatSize.h"
#include <wtf/Platform.h>
-#if __APPLE__
-
+#if PLATFORM(CG)
typedef struct CGPoint CGPoint;
+#endif
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGPoint NSPoint;
#else
typedef struct _NSPoint NSPoint;
#endif
-
#endif
#if PLATFORM(QT)
void setY(float y) { m_y = y; }
void move(float dx, float dy) { m_x += dx; m_y += dy; }
-#if __APPLE__
-
+#if PLATFORM(CG)
FloatPoint(const CGPoint&);
operator CGPoint() const;
+#endif
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
FloatPoint(const NSPoint&);
operator NSPoint() const;
#endif
-#endif
-
#if PLATFORM(QT)
FloatPoint(const QPointF&);
operator QPointF() const;
#include "FloatPoint.h"
-#if __APPLE__
-
+#if PLATFORM(CG)
typedef struct CGRect CGRect;
+#endif
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#endif
-
-#endif // __APPLE__
+#endif
#if PLATFORM(QT)
class QRectF;
void inflate(float d) { inflateX(d); inflateY(d); }
void scale(float s);
-#if __APPLE__
-
+#if PLATFORM(CG)
FloatRect(const CGRect&);
operator CGRect() const;
+#endif
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
FloatRect(const NSRect&);
operator NSRect() const;
#endif
-#elif PLATFORM(QT)
+#if PLATFORM(QT)
FloatRect(const QRectF&);
operator QRectF() const;
#endif
#ifndef FloatSize_h
#define FloatSize_h
-#if __APPLE__
-
+#if PLATFORM(CG)
typedef struct CGSize CGSize;
+#endif
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
typedef struct _NSSize NSSize;
#endif
-
#endif
namespace WebCore {
m_height > other.m_height ? m_height : other.m_height);
}
-#if __APPLE__
-
+#if PLATFORM(CG)
explicit FloatSize(const CGSize&); // don't do this implicitly since it's lossy
operator CGSize() const;
+#endif
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
explicit FloatSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
-#endif
-
private:
float m_width, m_height;
};
public:
Font();
Font(const FontDescription&, short letterSpacing, short wordSpacing);
-#if __APPLE__
+#if PLATFORM(MAC)
Font(const FontPlatformData& fontPlatformData); // This constructor is only used by Mac-specific code that already has a native font.
#endif
~Font();
unsigned weight() const { return m_fontDescription.weight(); }
bool bold() const { return m_fontDescription.bold(); }
-#if __APPLE__
+#if PLATFORM(MAC)
NSFont* getNSFont() const { return primaryFont()->getNSFont(); }
#endif
GlyphData glyphDataForCharacter(UChar32 c) const { return m_characterToGlyphMap.glyphDataForCharacter(c, this); }
void setGlyphDataForCharacter(UChar32 c, Glyph glyph, const FontData* fontData) const { m_characterToGlyphMap.setGlyphDataForCharacter(c, glyph, fontData); }
-#if __APPLE__
+#if PLATFORM(MAC)
NSFont* getNSFont() const { return m_font.font; }
#endif
mutable FontData* m_smallCapsFontData;
-#if __APPLE__
+#if PLATFORM(MAC)
void* m_styleGroup;
float m_syntheticBoldOffset;
mutable ATSUStyle m_ATSUStyle;
#define MAX_GLYPH_EXPANSION 4
#define GLYPH_BUFFER_SIZE 2048
-#if __APPLE__
+#if PLATFORM(CG)
#include <ApplicationServices/ApplicationServices.h>
-#elif PLATFORM(WIN) || PLATFORM(GDK)
+#elif PLATFORM(CAIRO)
#include <cairo.h>
#include "FloatSize.h"
#elif PLATFORM(QT)
typedef unsigned short Glyph;
class FontData;
-#if __APPLE__
+#if PLATFORM(CG)
typedef Glyph GlyphBufferGlyph;
typedef CGSize GlyphBufferAdvance;
-#elif PLATFORM(WIN) || PLATFORM(GDK)
+#elif PLATFORM(CAIRO)
typedef cairo_glyph_t GlyphBufferGlyph;
typedef FloatSize GlyphBufferAdvance;
#elif PLATFORM(QT)
Glyph glyphAt(int index) const
{
-#if __APPLE__ || PLATFORM(QT)
+#if PLATFORM(CG) || PLATFORM(QT)
return m_glyphs[index];
-#elif PLATFORM(WIN) || PLATFORM(GDK)
+#elif PLATFORM(CAIRO)
return m_glyphs[index].index;
#endif
}
float advanceAt(int index) const
{
-#if __APPLE__
+#if PLATFORM(CG)
return m_advances[index].width;
-#elif PLATFORM(WIN) || PLATFORM(GDK) || PLATFORM(QT)
+#elif PLATFORM(CAIRO) || PLATFORM(QT)
return m_advances[index].width();
#endif
}
void add(Glyph glyph, const FontData* font, float width)
{
m_fontData.append(font);
-#if __APPLE__
+#if PLATFORM(CG)
m_glyphs.append(glyph);
CGSize advance;
advance.width = width;
advance.height = 0;
m_advances.append(advance);
-#elif PLATFORM(WIN) || PLATFORM(GDK)
+#elif PLATFORM(CAIRO)
cairo_glyph_t cairoGlyph;
cairoGlyph.index = glyph;
cairoGlyph.y = 0;
#include <wtf/Noncopyable.h>
#include <wtf/Platform.h>
-// FIXME: how should Cairo figure into the platform macros?
-#if __APPLE__
+#if PLATFORM(CG)
typedef struct CGContext PlatformGraphicsContext;
-#elif PLATFORM(WIN)
-typedef struct HDC__* HDC;
-typedef struct _cairo PlatformGraphicsContext;
-#elif PLATFORM(GDK)
+#elif PLATFORM(CAIRO)
typedef struct _cairo PlatformGraphicsContext;
#elif PLATFORM(QT)
class QPainter;
typedef void PlatformGraphicsContext;
#endif
+#if PLATFORM(WIN)
+typedef struct HDC__* HDC;
+#endif
+
namespace WebCore {
const int cMisspellingLineThickness = 3;
#include "IntSize.h"
#include "FloatSize.h"
-#if __APPLE__
+#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSImage;
#else
enum TileRule { StretchTile, RoundTile, RepeatTile };
-#if __APPLE__
+#if PLATFORM(MAC)
// Accessors for native image formats.
CGImageRef getCGImageRef();
NSImage* getNSImage();
int m_repetitionCount; // How many total animation loops we should do.
int m_repetitionsComplete; // How many repetitions we've finished.
-#if __APPLE__
+#if PLATFORM(MAC)
mutable NSImage* m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
mutable CFDataRef m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
PDFDocumentImage* m_PDFDoc;
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
-#if __APPLE__
+#if PLATFORM(CG)
#include <ApplicationServices/ApplicationServices.h>
#elif PLATFORM(QT)
class QImage;
-#else
+#elif PLATFORM(CAIRO)
struct _cairo_surface;
typedef struct _cairo_surface cairo_surface_t;
#endif
class IntSize;
-#if __APPLE__
+#if PLATFORM(CG)
typedef CGImageSourceRef NativeImageSourcePtr;
typedef CGImageRef NativeImagePtr;
typedef CFDataRef NativeBytePtr;
#include "IntSize.h"
#include <wtf/Platform.h>
-#if __APPLE__
-
+#if PLATFORM(CG)
typedef struct CGPoint CGPoint;
+#endif
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGPoint NSPoint;
#else
typedef struct _NSPoint NSPoint;
#endif
-
-#endif // __APPLE__
+#endif
#if PLATFORM(WIN)
typedef struct tagPOINT POINT;
void move(int dx, int dy) { m_x += dx; m_y += dy; }
-#if __APPLE__
-
+#if PLATFORM(CG)
explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
operator CGPoint() const;
+#endif
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
explicit IntPoint(const NSPoint&); // don't do this implicitly since it's lossy
operator NSPoint() const;
#endif
-#endif
-
#if PLATFORM(WIN)
IntPoint(const POINT&);
operator POINT() const;
#include "IntPoint.h"
#include <wtf/Platform.h>
-#if __APPLE__
-
+#if PLATFORM(CG)
typedef struct CGRect CGRect;
+#endif
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#endif
-
-#endif // __APPLE__
+#endif
#if PLATFORM(WIN)
typedef struct tagRECT RECT;
operator QRect() const;
#endif
-#if __APPLE__
-
+#if PLATFORM(CG)
operator CGRect() const;
-
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
- operator NSRect() const;
#endif
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+ operator NSRect() const;
#endif
private:
return a.location() != b.location() || a.size() != b.size();
}
-#if __APPLE__
-
+#if PLATFORM(CG)
IntRect enclosingIntRect(const CGRect&);
-
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-
-IntRect enclosingIntRect(const NSRect&);
-
#endif
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+IntRect enclosingIntRect(const NSRect&);
#endif
} // namespace WebCore
#include <wtf/Platform.h>
-#if __APPLE__
-
+#if PLATFORM(CG)
typedef struct CGSize CGSize;
+#endif
+#if PLATFORM(MAC)
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
typedef struct _NSSize NSSize;
#endif
-
-#endif // __APPLE__
+#endif
#if PLATFORM(WIN)
typedef struct tagSIZE SIZE;
*this = expandedTo(IntSize());
}
-#if __APPLE__
-
+#if PLATFORM(CG)
explicit IntSize(const CGSize&); // don't do this implicitly since it's lossy
operator CGSize() const;
+#endif
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
explicit IntSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
-#endif
-
#if PLATFORM(WIN)
IntSize(const SIZE&);
operator SIZE() const;
typedef LONG_PTR LRESULT;
#endif
-#if __APPLE__
+#if PLATFORM(MAC)
#ifdef __OBJC__
@class WebCoreResourceLoaderImp;
#else
String method() const;
FormData postData() const;
-#if __APPLE__
+#if PLATFORM(MAC)
void setLoader(WebCoreResourceLoaderImp*);
#endif
#if PLATFORM(WIN)
#ifndef ResourceLoaderClient_h
#define ResourceLoaderClient_h
-#ifdef __APPLE__
+#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSData;
@class NSURLResponse;
namespace WebCore {
-#ifdef __APPLE__
+#if PLATFORM(MAC)
typedef NSData* PlatformData;
typedef NSURLResponse* PlatformResponse;
#elif PLATFORM(QT)
#include <wtf/Platform.h>
-#if __APPLE__
+#if PLATFORM(MAC)
#ifdef __OBJC__
@class NSView;
#else
#endif
-#if __APPLE__
+#if PLATFORM(MAC)
Widget(NSView* view);
NSView* getView() const;
#include "config.h"
#include "GraphicsContext.h"
+#if PLATFORM(CAIRO)
+
#include "FloatRect.h"
#include "Font.h"
#include "IntRect.h"
}
}
+
+#endif // PLATFORM(CAIRO)
#include "config.h"
#include "Image.h"
+#if PLATFORM(CAIRO)
+
#include "FloatRect.h"
#include "GraphicsContext.h"
#include <cairo.h>
}
}
+
+#endif // PLATFORM(CAIRO)
#include "config.h"
#include "ImageSource.h"
+#if PLATFORM(CAIRO)
+
#include "GIFImageDecoder.h"
#include "JPEGImageDecoder.h"
#include "PNGImageDecoder.h"
}
}
+
+#endif // PLATFORM(CAIRO)
#include "config.h"
#include "AffineTransform.h"
+#if PLATFORM(CG)
+
#include "FloatRect.h"
#include "IntRect.h"
}
}
+
+#endif // PLATFORM(CG)
--- /dev/null
+/*
+ * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005 Nokia. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+#include "config.h"
+#include "FloatPoint.h"
+
+#if PLATFORM(CG)
+
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace WebCore {
+
+FloatPoint::FloatPoint(const CGPoint& p) : m_x(p.x), m_y(p.y)
+{
+}
+
+FloatPoint::operator CGPoint() const
+{
+ return CGPointMake(m_x, m_y);
+}
+
+}
+
+#endif // PLATFORM(CG)
--- /dev/null
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005 Nokia. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+#include "config.h"
+#include "FloatRect.h"
+
+#if PLATFORM(CG)
+
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace WebCore {
+
+FloatRect::FloatRect(const CGRect& r) : m_location(r.origin), m_size(r.size)
+{
+}
+
+FloatRect::operator CGRect() const
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+}
+
+#endif // PLATFORM(CG)
--- /dev/null
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2005 Nokia. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+#include "config.h"
+#include "FloatSize.h"
+
+#if PLATFORM(CG)
+
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace WebCore {
+
+FloatSize::FloatSize(const CGSize& s) : m_width(s.width), m_height(s.height)
+{
+}
+
+FloatSize::operator CGSize() const
+{
+ return CGSizeMake(m_width, m_height);
+}
+
+}
+
+#endif // PLATFORM(CG)
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define _USE_MATH_DEFINES 1
#include "config.h"
#include "GraphicsContext.h"
+#if PLATFORM(CG)
+
#include "AffineTransform.h"
-#include "KRenderingDeviceQuartz.h"
#include "Path.h"
+#include "wtf/mathextras.h"
+
+#ifdef SVG_SUPPORT
+#include "KRenderingDeviceQuartz.h"
+#endif
+
+#include "GraphicsContextPlatformPrivate.h"
using namespace std;
namespace WebCore {
-// NSColor, NSBezierPath, and NSGraphicsContext
-// calls in this file are all exception-safe, so we don't block
-// exceptions for those.
+GraphicsContext::GraphicsContext(CGContextRef cgContext)
+ : m_common(createGraphicsContextPrivate())
+ , m_data(new GraphicsContextPlatformPrivate(cgContext))
+{
+ setPaintingDisabled(!cgContext);
+}
+
+GraphicsContext::~GraphicsContext()
+{
+ destroyGraphicsContextPrivate(m_common);
+ delete m_data;
+}
+
+void GraphicsContext::setFocusRingClip(const IntRect& r)
+{
+ // This method only exists to work around bugs in Mac focus ring clipping.
+ m_data->m_focusRingClip = r;
+}
+
+void GraphicsContext::clearFocusRingClip()
+{
+ // This method only exists to work around bugs in Mac focus ring clipping.
+ m_data->m_focusRingClip = IntRect();
+}
+
+CGContextRef GraphicsContext::platformContext() const
+{
+ ASSERT(!paintingDisabled());
+ ASSERT(m_data->m_cgContext);
+ return m_data->m_cgContext;
+}
static void setCGFillColor(CGContextRef context, const Color& color)
{
CGContextFillRect(context, rect);
}
- if (pen().style() != Pen::Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
setCGFillColor(context, pen().color());
CGRect rects[4] = {
FloatRect(rect.x(), rect.y(), rect.width(), 1),
return;
Pen::PenStyle penStyle = pen().style();
- if (penStyle == Pen::Pen::NoPen)
+ if (penStyle == Pen::NoPen)
return;
float width = pen().width();
if (width < 1)
}
}
+
+#endif // PLATFORM(CG)
--- /dev/null
+/*
+ * Copyright (C) 2006 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+namespace WebCore
+{
+
+class GraphicsContextPlatformPrivate {
+public:
+ GraphicsContextPlatformPrivate(CGContextRef cgContext)
+ :m_cgContext(cgContext)
+ {
+ CGContextRetain(m_cgContext);
+ }
+
+ ~GraphicsContextPlatformPrivate()
+ {
+ CGContextRelease(m_cgContext);
+ }
+
+ CGContextRef m_cgContext;
+ IntRect m_focusRingClip; // Work around CG bug in focus ring clipping.
+};
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2004, 2005, 2006 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+#include "config.h"
+#include "Image.h"
+
+#if PLATFORM(CG)
+
+#include <ApplicationServices/ApplicationServices.h>
+#include "FloatRect.h"
+#include "GraphicsContext.h"
+#include "PDFDocumentImage.h"
+#include "PlatformString.h"
+#include "WebCoreSystemInterface.h"
+
+namespace WebCore {
+
+void FrameData::clear()
+{
+ if (m_frame) {
+ CFRelease(m_frame);
+ m_frame = 0;
+ m_duration = 0.;
+ m_hasAlpha = true;
+ }
+}
+
+// ================================================
+// Image Class
+// ================================================
+
+void Image::initNativeData()
+{
+ m_nsImage = 0;
+ m_tiffRep = 0;
+ m_isPDF = false;
+ m_PDFDoc = 0;
+}
+
+void Image::destroyNativeData()
+{
+ delete m_PDFDoc;
+}
+
+void Image::invalidateNativeData()
+{
+ if (m_frames.size() != 1)
+ return;
+
+ if (m_nsImage) {
+ CFRelease(m_nsImage);
+ m_nsImage = 0;
+ }
+
+ if (m_tiffRep) {
+ CFRelease(m_tiffRep);
+ m_tiffRep = 0;
+ }
+}
+
+// Drawing Routines
+
+void Image::checkForSolidColor()
+{
+ if (frameCount() > 1)
+ m_isSolidColor = false;
+ else {
+ CGImageRef image = frameAtIndex(0);
+
+ // Currently we only check for solid color in the important special case of a 1x1 image.
+ if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) {
+ CGFloat pixel[4]; // RGBA
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+ CGContextRef bmap = CGBitmapContextCreate(&pixel, 1, 1, 8*sizeof(float), sizeof(pixel), space,
+ kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents | kCGBitmapByteOrder32Host);
+ if (bmap) {
+ GraphicsContext(bmap).setCompositeOperation(CompositeCopy);
+ CGRect dst = { {0, 0}, {1, 1} };
+ CGContextDrawImage(bmap, dst, image);
+ if (pixel[3] == 0)
+ m_solidColor = Color(0, 0, 0, 0);
+ else
+ m_solidColor = Color(int(pixel[0] / pixel[3] * 255), int(pixel[1] / pixel[3] * 255), int(pixel[2] / pixel[3] * 255), int(pixel[3] * 255));
+ m_isSolidColor = true;
+ CFRelease(bmap);
+ }
+ CFRelease(space);
+ }
+ }
+}
+
+CFDataRef Image::getTIFFRepresentation()
+{
+ if (m_tiffRep)
+ return m_tiffRep;
+
+ unsigned numFrames = frameCount();
+
+ // If numFrames is zero, we know for certain this image doesn't have valid data
+ // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
+ // in certain circumstances that call will spam the console with an error message
+ if (!numFrames)
+ return 0;
+ CFMutableDataRef data = CFDataCreateMutable(0, 0);
+ // FIXME: Use type kCGImageTypeIdentifierTIFF constant once is becomes available in the API
+ CGImageDestinationRef destination = CGImageDestinationCreateWithData(data, CFSTR("public.tiff"), numFrames, 0);
+ if (!destination)
+ return 0;
+
+ for (unsigned i = 0; i < numFrames; ++i ) {
+ CGImageRef cgImage = frameAtIndex(i);
+ if (!cgImage) {
+ CFRelease(destination);
+ return 0;
+ }
+ CGImageDestinationAddImage(destination, cgImage, 0);
+ }
+ CGImageDestinationFinalize(destination);
+ CFRelease(destination);
+
+ m_tiffRep = data;
+ return m_tiffRep;
+}
+
+CGImageRef Image::getCGImageRef()
+{
+ return frameAtIndex(0);
+}
+
+void Image::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp)
+{
+ if (m_isPDF) {
+ if (m_PDFDoc)
+ m_PDFDoc->draw(ctxt, srcRect, dstRect, compositeOp);
+ return;
+ }
+
+ if (!m_source.initialized())
+ return;
+
+ CGRect fr = ctxt->roundToDevicePixels(srcRect);
+ CGRect ir = ctxt->roundToDevicePixels(dstRect);
+
+ CGImageRef image = frameAtIndex(m_currentFrame);
+ if (!image) // If it's too early we won't have an image yet.
+ return;
+
+ if (m_isSolidColor && m_currentFrame == 0) {
+ if (m_solidColor.alpha() > 0) {
+ ctxt->save();
+ ctxt->setCompositeOperation(!m_solidColor.hasAlpha() && compositeOp == CompositeSourceOver ? CompositeCopy : compositeOp);
+ ctxt->fillRect(ir, m_solidColor);
+ ctxt->restore();
+ }
+ return;
+ }
+
+ CGContextRef context = ctxt->platformContext();
+ ctxt->save();
+
+ // Get the height (in adjusted, i.e. scaled, coords) of the portion of the image
+ // that is currently decoded. This could be less that the actual height.
+ CGSize selfSize = size(); // full image size, in pixels
+ float curHeight = CGImageGetHeight(image); // height of loaded portion, in pixels
+
+ CGSize adjustedSize = selfSize;
+ if (curHeight < selfSize.height) {
+ adjustedSize.height *= curHeight / selfSize.height;
+
+ // Is the amount of available bands less than what we need to draw? If so,
+ // we may have to clip 'fr' if it goes outside the available bounds.
+ if (CGRectGetMaxY(fr) > adjustedSize.height) {
+ float frHeight = adjustedSize.height - fr.origin.y; // clip fr to available bounds
+ if (frHeight <= 0)
+ return; // clipped out entirely
+ ir.size.height *= (frHeight / fr.size.height); // scale ir proportionally to fr
+ fr.size.height = frHeight;
+ }
+ }
+
+ // Flip the coords.
+ ctxt->setCompositeOperation(compositeOp);
+ CGContextTranslateCTM(context, ir.origin.x, ir.origin.y);
+ CGContextScaleCTM(context, 1, -1);
+ CGContextTranslateCTM(context, 0, -ir.size.height);
+
+ // Translated to origin, now draw at 0,0.
+ ir.origin.x = ir.origin.y = 0;
+
+ // If we're drawing a sub portion of the image then create
+ // a image for the sub portion and draw that.
+ // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
+ if (fr.size.width != adjustedSize.width || fr.size.height != adjustedSize.height) {
+ // Convert ft to image pixel coords:
+ float xscale = adjustedSize.width / selfSize.width;
+ float yscale = adjustedSize.height / curHeight; // yes, curHeight, not selfSize.height!
+ fr.origin.x /= xscale;
+ fr.origin.y /= yscale;
+ fr.size.width /= xscale;
+ fr.size.height /= yscale;
+
+ image = CGImageCreateWithImageInRect(image, fr);
+ if (image) {
+ CGContextDrawImage(context, ir, image);
+ CFRelease(image);
+ }
+ } else // Draw the whole image.
+ CGContextDrawImage(context, ir, image);
+
+ ctxt->restore();
+
+ startAnimation();
+
+}
+
+static void drawPattern(void* info, CGContextRef context)
+{
+ Image* data = (Image*)info;
+ CGImageRef image = data->frameAtIndex(data->currentFrame());
+ float w = CGImageGetWidth(image);
+ float h = CGImageGetHeight(image);
+ CGContextDrawImage(context, GraphicsContext(context).roundToDevicePixels(FloatRect
+ (0, data->size().height() - h, w, h)), image);
+}
+
+static const CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
+
+void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint,
+ const FloatSize& tileSize, CompositeOperator op)
+{
+ CGImageRef image = frameAtIndex(m_currentFrame);
+ if (!image)
+ return;
+
+ if (m_isSolidColor && m_currentFrame == 0) {
+ if (m_solidColor.alpha() > 0) {
+ ctxt->save();
+ ctxt->setCompositeOperation(!m_solidColor.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
+ ctxt->fillRect(destRect, m_solidColor);
+ ctxt->restore();
+ }
+ return;
+ }
+
+ CGPoint scaledPoint = srcPoint;
+ CGSize intrinsicTileSize = size();
+ CGSize scaledTileSize = intrinsicTileSize;
+
+ // If tileSize is not equal to the intrinsic size of the image, set patternTransform
+ // to the appropriate scalar matrix, scale the source point, and set the size of the
+ // scaled tile.
+ float scaleX = 1.0;
+ float scaleY = 1.0;
+ CGAffineTransform patternTransform = CGAffineTransformIdentity;
+ if (tileSize.width() != intrinsicTileSize.width || tileSize.height() != intrinsicTileSize.height) {
+ scaleX = tileSize.width() / intrinsicTileSize.width;
+ scaleY = tileSize.height() / intrinsicTileSize.height;
+ patternTransform = CGAffineTransformMakeScale(scaleX, scaleY);
+ scaledTileSize = tileSize;
+ }
+
+ // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
+ CGRect oneTileRect;
+ oneTileRect.origin.x = destRect.x() + fmodf(fmodf(-scaledPoint.x, scaledTileSize.width) -
+ scaledTileSize.width, scaledTileSize.width);
+ oneTileRect.origin.y = destRect.y() + fmodf(fmodf(-scaledPoint.y, scaledTileSize.height) -
+ scaledTileSize.height, scaledTileSize.height);
+ oneTileRect.size.width = scaledTileSize.width;
+ oneTileRect.size.height = scaledTileSize.height;
+
+ // If the single image draw covers the whole area, then just draw once.
+ if (CGRectContainsRect(oneTileRect, destRect)) {
+ CGRect fromRect;
+ fromRect.origin.x = (destRect.x() - oneTileRect.origin.x) / scaleX;
+ fromRect.origin.y = (destRect.y() - oneTileRect.origin.y) / scaleY;
+ fromRect.size.width = destRect.width() / scaleX;
+ fromRect.size.height = destRect.height() / scaleY;
+
+ draw(ctxt, destRect, fromRect, op);
+ return;
+ }
+
+ CGPatternRef pattern = CGPatternCreate(this, CGRectMake(0, 0, intrinsicTileSize.width, intrinsicTileSize.height),
+ patternTransform, intrinsicTileSize.width, intrinsicTileSize.height,
+ kCGPatternTilingConstantSpacing, true, &patternCallbacks);
+
+ if (pattern) {
+ CGContextRef context = ctxt->platformContext();
+
+ ctxt->save();
+
+ wkSetPatternPhaseInUserSpace(context, CGPointMake(oneTileRect.origin.x, oneTileRect.origin.y));
+
+ CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);
+ CGContextSetFillColorSpace(context, patternSpace);
+ CGColorSpaceRelease(patternSpace);
+
+ CGFloat patternAlpha = 1;
+ CGContextSetFillPattern(context, pattern, &patternAlpha);
+
+ ctxt->setCompositeOperation(op);
+
+ CGContextFillRect(context, destRect);
+
+ ctxt->restore();
+
+ CGPatternRelease(pattern);
+ }
+
+ startAnimation();
+}
+
+// FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.
+void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule,
+ TileRule vRule, CompositeOperator op)
+{
+ CGImageRef image = frameAtIndex(m_currentFrame);
+ if (!image)
+ return;
+
+ if (m_isSolidColor && m_currentFrame == 0) {
+ if (m_solidColor.alpha() > 0) {
+ ctxt->save();
+ ctxt->setCompositeOperation(!m_solidColor.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
+ ctxt->fillRect(dstRect, m_solidColor);
+ ctxt->restore();
+ }
+ return;
+ }
+
+ ctxt->save();
+
+ CGSize tileSize = srcRect.size();
+ CGRect ir = dstRect;
+ CGRect fr = srcRect;
+
+ // Now scale the slice in the appropriate direction using an affine transform that we will pass into
+ // the pattern.
+ float scaleX = 1.0f, scaleY = 1.0f;
+
+ if (hRule == Image::StretchTile)
+ scaleX = ir.size.width / fr.size.width;
+ if (vRule == Image::StretchTile)
+ scaleY = ir.size.height / fr.size.height;
+
+ if (hRule == Image::RepeatTile)
+ scaleX = scaleY;
+ if (vRule == Image::RepeatTile)
+ scaleY = scaleX;
+
+ if (hRule == Image::RoundTile) {
+ // Complicated math ensues.
+ float imageWidth = fr.size.width * scaleY;
+ float newWidth = ir.size.width / ceilf(ir.size.width / imageWidth);
+ scaleX = newWidth / fr.size.width;
+ }
+
+ if (vRule == Image::RoundTile) {
+ // More complicated math ensues.
+ float imageHeight = fr.size.height * scaleX;
+ float newHeight = ir.size.height / ceilf(ir.size.height / imageHeight);
+ scaleY = newHeight / fr.size.height;
+ }
+
+ CGAffineTransform patternTransform = CGAffineTransformMakeScale(scaleX, scaleY);
+
+ // Possible optimization: We may want to cache the CGPatternRef
+ CGPatternRef pattern = CGPatternCreate(this, CGRectMake(fr.origin.x, fr.origin.y, tileSize.width, tileSize.height),
+ patternTransform, tileSize.width, tileSize.height,
+ kCGPatternTilingConstantSpacing, true, &patternCallbacks);
+ if (pattern) {
+ CGContextRef context = ctxt->platformContext();
+
+ // We want to construct the phase such that the pattern is centered (when stretch is not
+ // set for a particular rule).
+ float hPhase = scaleX * fr.origin.x;
+ float vPhase = scaleY * (tileSize.height - fr.origin.y);
+ if (hRule == Image::RepeatTile)
+ hPhase -= fmodf(ir.size.width, scaleX * tileSize.width) / 2.0f;
+ if (vRule == Image::RepeatTile)
+ vPhase -= fmodf(ir.size.height, scaleY * tileSize.height) / 2.0f;
+
+ wkSetPatternPhaseInUserSpace(context, CGPointMake(ir.origin.x - hPhase, ir.origin.y - vPhase));
+
+ CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);
+ CGContextSetFillColorSpace(context, patternSpace);
+ CGColorSpaceRelease(patternSpace);
+
+ CGFloat patternAlpha = 1;
+ CGContextSetFillPattern(context, pattern, &patternAlpha);
+
+ ctxt->setCompositeOperation(op);
+
+ CGContextFillRect(context, ir);
+
+ CGPatternRelease(pattern);
+ }
+
+ ctxt->restore();
+
+ startAnimation();
+}
+
+}
+
+#endif // PLATFORM(CG)
#include "config.h"
#include "ImageSource.h"
+#if PLATFORM(CG)
+
#include "IntSize.h"
+#include <ApplicationServices/ApplicationServices.h>
namespace WebCore {
return true;
}
-
}
+
+#endif // PLATFORM(CG)
--- /dev/null
+/*
+ * Copyright (C) 2004, 2005, 2006 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+#include "config.h"
+#include "IntPoint.h"
+
+#if PLATFORM(CG)
+
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace WebCore {
+
+IntPoint::IntPoint(const CGPoint& p) : m_x(static_cast<int>(p.x)), m_y(static_cast<int>(p.y))
+{
+}
+
+IntPoint::operator CGPoint() const
+{
+ return CGPointMake(m_x, m_y);
+}
+
+}
+
+#endif // PLATFORM(CG)
--- /dev/null
+/*
+ * Copyright (C) 2003, 2006 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+#include "config.h"
+#include "IntRect.h"
+
+#if PLATFORM(CG)
+
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace WebCore {
+
+IntRect::operator CGRect() const
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+IntRect enclosingIntRect(const CGRect& rect)
+{
+ int l = static_cast<int>(floorf(rect.origin.x));
+ int t = static_cast<int>(floorf(rect.origin.y));
+ int r = static_cast<int>(ceilf(CGRectGetMaxX(rect)));
+ int b = static_cast<int>(ceilf(CGRectGetMaxY(rect)));
+ return IntRect(l, t, r - l, b - t);
+}
+
+}
+
+#endif // PLATFORM(CG)
--- /dev/null
+/*
+ * Copyright (C) 2003, 2004, 2005, 2006 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
+ * 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.
+ */
+
+#include "config.h"
+#include "IntSize.h"
+
+#if PLATFORM(CG)
+
+#include <ApplicationServices/ApplicationServices.h>
+
+namespace WebCore {
+
+IntSize::IntSize(const CGSize& s) : m_width(static_cast<int>(s.width)), m_height(static_cast<int>(s.height))
+{
+}
+
+IntSize::operator CGSize() const
+{
+ return CGSizeMake(m_width, m_height);
+}
+
+}
+
+#endif // PLATFORM(CG)
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import "config.h"
-#import "PDFDocumentImage.h"
+#define _USE_MATH_DEFINES 1
+#include "config.h"
+#include "PDFDocumentImage.h"
+
+#if PLATFORM(CG)
#import "GraphicsContext.h"
// calculate rotated x and y edges of the corp box. if they're negative, it means part of the image has
// been rotated outside of the bounds and we need to shift over the image so it lies inside the bounds again
- NSPoint rx = NSMakePoint(width * cosa, width * sina);
- NSPoint ry = NSMakePoint(-height * sina, height * cosa);
+ CGPoint rx = CGPointMake(width * cosa, width * sina);
+ CGPoint ry = CGPointMake(-height * sina, height * cosa);
// adjust so we are at the crop box origin
const CGFloat zero = 0;
}
}
+
+#endif // PLATFORM(CG)
#include "FloatRect.h"
#include "GraphicsTypes.h"
+#if PLATFORM(CG)
+
#include <ApplicationServices/ApplicationServices.h>
namespace WebCore {
};
}
+
+#endif // PLATFORM(CG)
#include "config.h"
#include "Path.h"
+#if PLATFORM(CG)
+
#include "FloatRect.h"
#include <ApplicationServices/ApplicationServices.h>
}
}
+
+#endif // PLATFORM(CG)
#include "config.h"
#include "BMPImageDecoder.h"
-
+
+#if PLATFORM(CAIRO)
+
namespace WebCore
{
}
}
-
\ No newline at end of file
+
+#endif // PLATFORM(CAIRO)
#include "GIFImageDecoder.h"
#include "GIFImageReader.h"
+#if PLATFORM(CAIRO)
+
namespace WebCore {
class GIFImageDecoderPrivate
}
}
+
+#endif // PLATFORM(CAIRO)
#include <string.h>
#include "GIFImageDecoder.h"
+#if PLATFORM(CAIRO)
+
using WebCore::GIFImageDecoder;
// Define the Mozilla macro setup so that we can leave the macros alone.
return true;
}
+#endif // PLATFORM(CAIRO)
#include "config.h"
#include "ICOImageDecoder.h"
-
+
+#if PLATFORM(CAIRO)
+
namespace WebCore
{
}
}
-
\ No newline at end of file
+
+#endif // PLATFORM(CAIRO)
#include "JPEGImageDecoder.h"
#include <assert.h>
+#if PLATFORM(CAIRO)
+
extern "C" {
#include "jpeglib.h"
}
}
}
+
+#endif // PLATFORM(CAIRO)
#include "png.h"
#include "assert.h"
+#if PLATFORM(CAIRO)
+
namespace WebCore {
// Gamma constants.
}
}
+
+#endif // PLATFORM(CAIRO)
#include "config.h"
#include "XBMImageDecoder.h"
+#if PLATFORM(CAIRO)
+
namespace WebCore
{
}
}
-
\ No newline at end of file
+
+#endif // PLATFORM(CAIRO)
namespace WebCore {
-FloatPoint::FloatPoint(const CGPoint& p) : m_x(p.x), m_y(p.y)
-{
-}
-
-FloatPoint::operator CGPoint() const
-{
- return CGPointMake(m_x, m_y);
-}
-
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
FloatPoint::FloatPoint(const NSPoint& p) : m_x(p.x), m_y(p.y)
namespace WebCore {
-FloatRect::FloatRect(const CGRect& r) : m_location(r.origin), m_size(r.size)
-{
-}
-
-FloatRect::operator CGRect() const
-{
- return CGRectMake(x(), y(), width(), height());
-}
-
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
FloatRect::FloatRect(const NSRect& r) : m_location(r.origin), m_size(r.size)
namespace WebCore {
-FloatSize::FloatSize(const CGSize& s) : m_width(s.width), m_height(s.height)
-{
-}
-
-FloatSize::operator CGSize() const
-{
- return CGSizeMake(m_width, m_height);
-}
-
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
FloatSize::FloatSize(const NSSize& s) : m_width(s.width), m_height(s.height)
#import "config.h"
#import "GraphicsContext.h"
+#import "../cg/GraphicsContextPlatformPrivate.h"
+
#import "WebCoreSystemInterface.h"
// FIXME: More of this should use CoreGraphics instead of AppKit.
// calls in this file are all exception-safe, so we don't block
// exceptions for those.
-class GraphicsContextPlatformPrivate {
-public:
- GraphicsContextPlatformPrivate(CGContextRef);
- ~GraphicsContextPlatformPrivate();
-
- CGContextRef m_cgContext;
- IntRect m_focusRingClip; // Work around CG bug in focus ring clipping.
-};
-
-GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate(CGContextRef cgContext)
-{
- m_cgContext = cgContext;
- CGContextRetain(m_cgContext);
-}
-
-GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
-{
- CGContextRelease(m_cgContext);
-}
-
-GraphicsContext::GraphicsContext(CGContextRef cgContext)
- : m_common(createGraphicsContextPrivate())
- , m_data(new GraphicsContextPlatformPrivate(cgContext))
-{
- setPaintingDisabled(!cgContext);
-}
-
-GraphicsContext::~GraphicsContext()
-{
- destroyGraphicsContextPrivate(m_common);
- delete m_data;
-}
-
-void GraphicsContext::setFocusRingClip(const IntRect& r)
-{
- // This method only exists to work around bugs in Mac focus ring clipping.
- m_data->m_focusRingClip = r;
-}
-
-void GraphicsContext::clearFocusRingClip()
-{
- // This method only exists to work around bugs in Mac focus ring clipping.
- m_data->m_focusRingClip = IntRect();
-}
-
void GraphicsContext::drawFocusRing(const Color& color)
{
if (paintingDisabled())
CGPathRelease(focusRingPath);
}
-CGContextRef GraphicsContext::platformContext() const
-{
- ASSERT(!paintingDisabled());
- ASSERT(m_data->m_cgContext);
- return m_data->m_cgContext;
-}
-
void GraphicsContext::setCompositeOperation(CompositeOperator op)
{
if (paintingDisabled())
namespace WebCore {
-void FrameData::clear()
-{
- if (m_frame) {
- CFRelease(m_frame);
- m_frame = 0;
- m_duration = 0.;
- m_hasAlpha = true;
- }
-}
-
// ================================================
// Image Class
// ================================================
-void Image::initNativeData()
-{
- m_nsImage = 0;
- m_tiffRep = 0;
- m_isPDF = false;
- m_PDFDoc = 0;
-}
-
-void Image::destroyNativeData()
-{
- delete m_PDFDoc;
-}
-
-void Image::invalidateNativeData()
-{
- if (m_frames.size() != 1)
- return;
-
- if (m_nsImage) {
- CFRelease(m_nsImage);
- m_nsImage = 0;
- }
-
- if (m_tiffRep) {
- CFRelease(m_tiffRep);
- m_tiffRep = 0;
- }
-}
-
Image* Image::loadResource(const char *name)
{
NSBundle *bundle = [NSBundle bundleForClass:[WebCoreFrameBridge class]];
return [[WebCoreFrameBridge supportedImageResourceMIMETypes] containsObject:type];
}
-// Drawing Routines
-
-void Image::checkForSolidColor()
-{
- if (frameCount() > 1)
- m_isSolidColor = false;
- else {
- CGImageRef image = frameAtIndex(0);
-
- // Currently we only check for solid color in the important special case of a 1x1 image.
- if (image && CGImageGetWidth(image) == 1 && CGImageGetHeight(image) == 1) {
- CGFloat pixel[4]; // RGBA
- CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
- CGContextRef bmap = CGBitmapContextCreate(&pixel, 1, 1, 8*sizeof(float), sizeof(pixel), space,
- kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents | kCGBitmapByteOrder32Host);
- if (bmap) {
- GraphicsContext(bmap).setCompositeOperation(CompositeCopy);
- CGRect dst = { {0, 0}, {1, 1} };
- CGContextDrawImage(bmap, dst, image);
- if (pixel[3] == 0)
- m_solidColor = Color(0, 0, 0, 0);
- else
- m_solidColor = Color(int(pixel[0] / pixel[3] * 255), int(pixel[1] / pixel[3] * 255), int(pixel[2] / pixel[3] * 255), int(pixel[3] * 255));
- m_isSolidColor = true;
- CFRelease(bmap);
- }
- CFRelease(space);
- }
- }
-}
-
-CFDataRef Image::getTIFFRepresentation()
-{
- if (m_tiffRep)
- return m_tiffRep;
-
- unsigned numFrames = frameCount();
-
- // If numFrames is zero, we know for certain this image doesn't have valid data
- // Even though the call to CGImageDestinationCreateWithData will fail and we'll handle it gracefully,
- // in certain circumstances that call will spam the console with an error message
- if (!numFrames)
- return 0;
- CFMutableDataRef data = CFDataCreateMutable(0, 0);
- // FIXME: Use type kCGImageTypeIdentifierTIFF constant once is becomes available in the API
- CGImageDestinationRef destination = CGImageDestinationCreateWithData(data, CFSTR("public.tiff"), numFrames, 0);
- if (!destination)
- return 0;
-
- for (unsigned i = 0; i < numFrames; ++i ) {
- CGImageRef cgImage = frameAtIndex(i);
- if (!cgImage) {
- CFRelease(destination);
- return 0;
- }
- CGImageDestinationAddImage(destination, cgImage, 0);
- }
- CGImageDestinationFinalize(destination);
- CFRelease(destination);
-
- m_tiffRep = data;
- return m_tiffRep;
-}
-
NSImage* Image::getNSImage()
{
if (m_nsImage)
return m_nsImage;
}
-CGImageRef Image::getCGImageRef()
-{
- return frameAtIndex(0);
-}
-
-void Image::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator compositeOp)
-{
- if (m_isPDF) {
- if (m_PDFDoc)
- m_PDFDoc->draw(ctxt, srcRect, dstRect, compositeOp);
- return;
- }
-
- if (!m_source.initialized())
- return;
-
- CGRect fr = ctxt->roundToDevicePixels(srcRect);
- CGRect ir = ctxt->roundToDevicePixels(dstRect);
-
- CGImageRef image = frameAtIndex(m_currentFrame);
- if (!image) // If it's too early we won't have an image yet.
- return;
-
- if (m_isSolidColor && m_currentFrame == 0) {
- if (m_solidColor.alpha() > 0) {
- ctxt->save();
- ctxt->setCompositeOperation(!m_solidColor.hasAlpha() && compositeOp == CompositeSourceOver ? CompositeCopy : compositeOp);
- ctxt->fillRect(ir, m_solidColor);
- ctxt->restore();
- }
- return;
- }
-
- CGContextRef context = ctxt->platformContext();
- ctxt->save();
-
- // Get the height (in adjusted, i.e. scaled, coords) of the portion of the image
- // that is currently decoded. This could be less that the actual height.
- CGSize selfSize = size(); // full image size, in pixels
- float curHeight = CGImageGetHeight(image); // height of loaded portion, in pixels
-
- CGSize adjustedSize = selfSize;
- if (curHeight < selfSize.height) {
- adjustedSize.height *= curHeight / selfSize.height;
-
- // Is the amount of available bands less than what we need to draw? If so,
- // we may have to clip 'fr' if it goes outside the available bounds.
- if (CGRectGetMaxY(fr) > adjustedSize.height) {
- float frHeight = adjustedSize.height - fr.origin.y; // clip fr to available bounds
- if (frHeight <= 0)
- return; // clipped out entirely
- ir.size.height *= (frHeight / fr.size.height); // scale ir proportionally to fr
- fr.size.height = frHeight;
- }
- }
-
- // Flip the coords.
- ctxt->setCompositeOperation(compositeOp);
- CGContextTranslateCTM(context, ir.origin.x, ir.origin.y);
- CGContextScaleCTM(context, 1, -1);
- CGContextTranslateCTM(context, 0, -ir.size.height);
-
- // Translated to origin, now draw at 0,0.
- ir.origin.x = ir.origin.y = 0;
-
- // If we're drawing a sub portion of the image then create
- // a image for the sub portion and draw that.
- // Test using example site at http://www.meyerweb.com/eric/css/edge/complexspiral/demo.html
- if (fr.size.width != adjustedSize.width || fr.size.height != adjustedSize.height) {
- // Convert ft to image pixel coords:
- float xscale = adjustedSize.width / selfSize.width;
- float yscale = adjustedSize.height / curHeight; // yes, curHeight, not selfSize.height!
- fr.origin.x /= xscale;
- fr.origin.y /= yscale;
- fr.size.width /= xscale;
- fr.size.height /= yscale;
-
- image = CGImageCreateWithImageInRect(image, fr);
- if (image) {
- CGContextDrawImage(context, ir, image);
- CFRelease(image);
- }
- } else // Draw the whole image.
- CGContextDrawImage(context, ir, image);
-
- ctxt->restore();
-
- startAnimation();
-
-}
-
-static void drawPattern(void* info, CGContextRef context)
-{
- Image* data = (Image*)info;
- CGImageRef image = data->frameAtIndex(data->currentFrame());
- float w = CGImageGetWidth(image);
- float h = CGImageGetHeight(image);
- CGContextDrawImage(context, GraphicsContext(context).roundToDevicePixels(FloatRect
- (0, data->size().height() - h, w, h)), image);
-}
-
-static const CGPatternCallbacks patternCallbacks = { 0, drawPattern, NULL };
-
-void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& destRect, const FloatPoint& srcPoint,
- const FloatSize& tileSize, CompositeOperator op)
-{
- CGImageRef image = frameAtIndex(m_currentFrame);
- if (!image)
- return;
-
- if (m_isSolidColor && m_currentFrame == 0) {
- if (m_solidColor.alpha() > 0) {
- ctxt->save();
- ctxt->setCompositeOperation(!m_solidColor.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
- ctxt->fillRect(destRect, m_solidColor);
- ctxt->restore();
- }
- return;
- }
-
- CGPoint scaledPoint = srcPoint;
- CGSize intrinsicTileSize = size();
- CGSize scaledTileSize = intrinsicTileSize;
-
- // If tileSize is not equal to the intrinsic size of the image, set patternTransform
- // to the appropriate scalar matrix, scale the source point, and set the size of the
- // scaled tile.
- float scaleX = 1.0;
- float scaleY = 1.0;
- CGAffineTransform patternTransform = CGAffineTransformIdentity;
- if (tileSize.width() != intrinsicTileSize.width || tileSize.height() != intrinsicTileSize.height) {
- scaleX = tileSize.width() / intrinsicTileSize.width;
- scaleY = tileSize.height() / intrinsicTileSize.height;
- patternTransform = CGAffineTransformMakeScale(scaleX, scaleY);
- scaledTileSize = tileSize;
- }
-
- // Check and see if a single draw of the image can cover the entire area we are supposed to tile.
- NSRect oneTileRect;
- oneTileRect.origin.x = destRect.x() + fmodf(fmodf(-scaledPoint.x, scaledTileSize.width) -
- scaledTileSize.width, scaledTileSize.width);
- oneTileRect.origin.y = destRect.y() + fmodf(fmodf(-scaledPoint.y, scaledTileSize.height) -
- scaledTileSize.height, scaledTileSize.height);
- oneTileRect.size.width = scaledTileSize.width;
- oneTileRect.size.height = scaledTileSize.height;
-
- // If the single image draw covers the whole area, then just draw once.
- if (NSContainsRect(oneTileRect, destRect)) {
- CGRect fromRect;
- fromRect.origin.x = (destRect.x() - oneTileRect.origin.x) / scaleX;
- fromRect.origin.y = (destRect.y() - oneTileRect.origin.y) / scaleY;
- fromRect.size.width = destRect.width() / scaleX;
- fromRect.size.height = destRect.height() / scaleY;
-
- draw(ctxt, destRect, fromRect, op);
- return;
- }
-
- CGPatternRef pattern = CGPatternCreate(this, CGRectMake(0, 0, intrinsicTileSize.width, intrinsicTileSize.height),
- patternTransform, intrinsicTileSize.width, intrinsicTileSize.height,
- kCGPatternTilingConstantSpacing, true, &patternCallbacks);
-
- if (pattern) {
- CGContextRef context = ctxt->platformContext();
-
- ctxt->save();
-
- wkSetPatternPhaseInUserSpace(context, CGPointMake(oneTileRect.origin.x, oneTileRect.origin.y));
-
- CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);
- CGContextSetFillColorSpace(context, patternSpace);
- CGColorSpaceRelease(patternSpace);
-
- CGFloat patternAlpha = 1;
- CGContextSetFillPattern(context, pattern, &patternAlpha);
-
- ctxt->setCompositeOperation(op);
-
- CGContextFillRect(context, destRect);
-
- ctxt->restore();
-
- CGPatternRelease(pattern);
- }
-
- startAnimation();
-}
-
-// FIXME: Merge with the other drawTiled eventually, since we need a combination of both for some things.
-void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, TileRule hRule,
- TileRule vRule, CompositeOperator op)
-{
- CGImageRef image = frameAtIndex(m_currentFrame);
- if (!image)
- return;
-
- if (m_isSolidColor && m_currentFrame == 0) {
- if (m_solidColor.alpha() > 0) {
- ctxt->save();
- ctxt->setCompositeOperation(!m_solidColor.hasAlpha() && op == CompositeSourceOver ? CompositeCopy : op);
- ctxt->fillRect(dstRect, m_solidColor);
- ctxt->restore();
- }
- return;
- }
-
- ctxt->save();
-
- CGSize tileSize = srcRect.size();
- CGRect ir = dstRect;
- CGRect fr = srcRect;
-
- // Now scale the slice in the appropriate direction using an affine transform that we will pass into
- // the pattern.
- float scaleX = 1.0f, scaleY = 1.0f;
-
- if (hRule == Image::StretchTile)
- scaleX = ir.size.width / fr.size.width;
- if (vRule == Image::StretchTile)
- scaleY = ir.size.height / fr.size.height;
-
- if (hRule == Image::RepeatTile)
- scaleX = scaleY;
- if (vRule == Image::RepeatTile)
- scaleY = scaleX;
-
- if (hRule == Image::RoundTile) {
- // Complicated math ensues.
- float imageWidth = fr.size.width * scaleY;
- float newWidth = ir.size.width / ceilf(ir.size.width / imageWidth);
- scaleX = newWidth / fr.size.width;
- }
-
- if (vRule == Image::RoundTile) {
- // More complicated math ensues.
- float imageHeight = fr.size.height * scaleX;
- float newHeight = ir.size.height / ceilf(ir.size.height / imageHeight);
- scaleY = newHeight / fr.size.height;
- }
-
- CGAffineTransform patternTransform = CGAffineTransformMakeScale(scaleX, scaleY);
-
- // Possible optimization: We may want to cache the CGPatternRef
- CGPatternRef pattern = CGPatternCreate(this, CGRectMake(fr.origin.x, fr.origin.y, tileSize.width, tileSize.height),
- patternTransform, tileSize.width, tileSize.height,
- kCGPatternTilingConstantSpacing, true, &patternCallbacks);
- if (pattern) {
- CGContextRef context = ctxt->platformContext();
-
- // We want to construct the phase such that the pattern is centered (when stretch is not
- // set for a particular rule).
- float hPhase = scaleX * fr.origin.x;
- float vPhase = scaleY * (tileSize.height - fr.origin.y);
- if (hRule == Image::RepeatTile)
- hPhase -= fmodf(ir.size.width, scaleX * tileSize.width) / 2.0f;
- if (vRule == Image::RepeatTile)
- vPhase -= fmodf(ir.size.height, scaleY * tileSize.height) / 2.0f;
-
- wkSetPatternPhaseInUserSpace(context, CGPointMake(ir.origin.x - hPhase, ir.origin.y - vPhase));
-
- CGColorSpaceRef patternSpace = CGColorSpaceCreatePattern(NULL);
- CGContextSetFillColorSpace(context, patternSpace);
- CGColorSpaceRelease(patternSpace);
-
- CGFloat patternAlpha = 1;
- CGContextSetFillPattern(context, pattern, &patternAlpha);
-
- ctxt->setCompositeOperation(op);
-
- CGContextFillRect(context, ir);
-
- CGPatternRelease(pattern);
- }
-
- ctxt->restore();
-
- startAnimation();
-}
-
}
namespace WebCore {
-IntPoint::IntPoint(const CGPoint& p) : m_x(static_cast<int>(p.x)), m_y(static_cast<int>(p.y))
-{
-}
-
-IntPoint::operator CGPoint() const
-{
- return CGPointMake(m_x, m_y);
-}
-
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
IntPoint::IntPoint(const NSPoint& p) : m_x(static_cast<int>(p.x)), m_y(static_cast<int>(p.y))
namespace WebCore {
-IntRect::operator CGRect() const
-{
- return CGRectMake(x(), y(), width(), height());
-}
-
-IntRect enclosingIntRect(const CGRect& rect)
-{
- int l = static_cast<int>(floorf(rect.origin.x));
- int t = static_cast<int>(floorf(rect.origin.y));
- int r = static_cast<int>(ceilf(CGRectGetMaxX(rect)));
- int b = static_cast<int>(ceilf(CGRectGetMaxY(rect)));
- return IntRect(l, t, r - l, b - t);
-}
-
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
IntRect::operator NSRect() const
namespace WebCore {
-IntSize::IntSize(const CGSize& s) : m_width(static_cast<int>(s.width)), m_height(static_cast<int>(s.height))
-{
-}
-
-IntSize::operator CGSize() const
-{
- return CGSizeMake(m_width, m_height);
-}
-
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
IntSize::IntSize(const NSSize& s) : m_width(static_cast<int>(s.width)), m_height(static_cast<int>(s.height))