1/*
2 * Copyright (C) 2007, 2008, 2009 Apple Inc.  All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef WebKitSystemInterface_h
27#define WebKitSystemInterface_h
28
29struct CGAffineTransform;
30struct CGPoint;
31struct CGRect;
32struct CGSize;
33struct IDirect3DDevice9;
34struct WKCACFContext;
35struct WKCACFUpdateRectEnumerator;
36
37typedef struct _CACFLayer* CACFLayerRef;
38typedef const struct __CFArray* CFArrayRef;
39typedef const struct __CFData* CFDataRef;
40typedef const struct __CFString* CFStringRef;
41typedef double CFTimeInterval;
42typedef struct CGColor* CGColorRef;
43typedef struct CGContext* CGContextRef;
44typedef unsigned short CGFontIndex;
45typedef struct CGFont* CGFontRef;
46typedef CGFontIndex CGGlyph;
47typedef wchar_t UChar;
48typedef struct _CFURLResponse* CFURLResponseRef;
49typedef struct OpaqueCFHTTPCookieStorage*  CFHTTPCookieStorageRef;
50typedef struct __CFDictionary* CFMutableDictionaryRef;
51typedef struct _CFURLRequest* CFMutableURLRequestRef;
52typedef const struct _CFURLRequest* CFURLRequestRef;
53typedef struct __CFHTTPMessage* CFHTTPMessageRef;
54typedef const struct __CFNumber* CFNumberRef;
55typedef struct __CFReadStream* CFReadStreamRef;
56typedef const struct __CFURL* CFURLRef;
57typedef struct _CFURLProtectionSpace* CFURLProtectionSpaceRef;
58typedef struct tagLOGFONTW LOGFONTW;
59typedef LOGFONTW LOGFONT;
60typedef struct _CACFLayer *CACFLayerRef;
61typedef struct __CVBuffer *CVBufferRef;
62typedef CVBufferRef CVImageBufferRef;
63typedef CVImageBufferRef CVPixelBufferRef;
64typedef struct _CAImageQueue *CAImageQueueRef;
65typedef unsigned long CFTypeID;
66typedef struct _CFURLCredential* WKCFURLCredentialRef;
67typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
68typedef const struct _CFURLCache* CFURLCacheRef;
69
70void wkSetFontSmoothingLevel(int type);
71int wkGetFontSmoothingLevel();
72void wkSetFontSmoothingContrast(CGFloat);
73CGFloat wkGetFontSmoothingContrast();
74void wkSystemFontSmoothingChanged();
75uint32_t wkSetFontSmoothingStyle(CGContextRef cg, bool fontAllowsSmoothing);
76void wkRestoreFontSmoothingStyle(CGContextRef cg, uint32_t oldStyle);
77void wkSetCGContextFontRenderingStyle(CGContextRef, bool isSystemFont, bool isPrinterFont, bool usePlatformNativeGlyphs);
78void wkGetGlyphAdvances(CGFontRef, const CGAffineTransform&, bool isSystemFont, bool isPrinterFont, CGGlyph, CGSize& advance);
79void wkGetGlyphs(CGFontRef, const UChar[], CGGlyph[], size_t count);
80void wkSetUpFontCache(size_t s);
81
82void wkSetPatternBaseCTM(CGContextRef, CGAffineTransform);
83void wkSetPatternPhaseInUserSpace(CGContextRef, CGPoint phasePoint);
84CGAffineTransform wkGetUserToBaseCTM(CGContextRef);
85
86void wkDrawFocusRing(CGContextRef, CGColorRef, float radius);
87
88CFDictionaryRef wkGetSSLCertificateInfo(CFURLResponseRef);
89CFDataRef wkGetSSLPeerCertificateData(CFDictionaryRef);
90void* wkGetSSLPeerCertificateDataBytePtr(CFDictionaryRef);
91void wkSetSSLPeerCertificateData(CFMutableDictionaryRef, CFDataRef);
92void* wkGetSSLCertificateChainContext(CFDictionaryRef);
93CFHTTPCookieStorageRef wkGetDefaultHTTPCookieStorage();
94CFHTTPCookieStorageRef wkCreateInMemoryHTTPCookieStorage();
95void wkSetCFURLRequestShouldContentSniff(CFMutableURLRequestRef, bool);
96CFStringRef wkCopyFoundationCacheDirectory();
97void wkSetClientCertificateInSSLProperties(CFMutableDictionaryRef, CFDataRef);
98
99CFArrayRef wkCFURLRequestCopyHTTPRequestBodyParts(CFURLRequestRef);
100void wkCFURLRequestSetHTTPRequestBodyParts(CFMutableURLRequestRef, CFArrayRef bodyParts);
101
102CFURLStorageSessionRef wkCreatePrivateStorageSession(CFStringRef identifier);
103void wkSetRequestStorageSession(CFURLStorageSessionRef, CFMutableURLRequestRef);
104CFURLCacheRef wkCopyURLCache(CFURLStorageSessionRef);
105CFHTTPCookieStorageRef wkCopyHTTPCookieStorage(CFURLStorageSessionRef);
106
107CFArrayRef wkCFURLCacheCopyAllHostNamesInPersistentStore();
108void wkCFURLCacheDeleteHostNamesInPersistentStore(CFArrayRef hostNames);
109
110unsigned wkInitializeMaximumHTTPConnectionCountPerHost(unsigned preferredConnectionCount);
111
112void wkSetCONNECTProxyForStream(CFReadStreamRef, CFStringRef proxyHost, CFNumberRef proxyPort);
113void wkSetCONNECTProxyAuthorizationForStream(CFReadStreamRef, CFStringRef proxyAuthorizationString);
114CFHTTPMessageRef wkCopyCONNECTProxyResponse(CFReadStreamRef, CFURLRef responseURL);
115
116WKCFURLCredentialRef wkCopyCredentialFromCFPersistentStorage(CFURLProtectionSpaceRef protectionSpace);
117
118CFStringRef wkCFNetworkErrorGetLocalizedDescription(CFIndex errorCode);
119
120
121enum wkCAImageQueueFlags {
122    kWKCAImageQueueAsync = 1U << 0,
123    kWKCAImageQueueFill = 1U << 1,
124    kWKCAImageQueueProtected = 1U << 2,
125    kWKCAImageQueueUseCleanAperture = 1U << 3,
126    kWKCAImageQueueUseAspectRatio = 1U << 4,
127    kWKCAImageQueueLowQualityColor = 1U << 5,
128};
129
130enum wkWKCAImageQueueImageType {
131    kWKCAImageQueueNil = 1,
132    kWKCAImageQueueSurface,
133    kWKCAImageQueueBuffer,
134    kWKCAImageQueueIOSurface,
135};
136
137enum wkWKCAImageQueueImageFlags {
138    kWKCAImageQueueOpaque = 1U << 0,
139    kWKCAImageQueueFlush = 1U << 1,
140    kWKCAImageQueueWillFlush = 1U << 2,
141    kWKCAImageQueueFlipped = 1U << 3,
142    kWKCAImageQueueWaitGPU = 1U << 4,
143};
144
145typedef void (*wkCAImageQueueReleaseCallback)(unsigned int type, uint64_t id, void *info);
146CAImageQueueRef wkCAImageQueueCreate(uint32_t width, uint32_t height, uint32_t capacity);
147void wkCAImageQueueInvalidate(CAImageQueueRef iq);
148size_t wkCAImageQueueCollect(CAImageQueueRef iq);
149bool wkCAImageQueueInsertImage(CAImageQueueRef iq, CFTimeInterval t, unsigned int type, uint64_t id, uint32_t flags, wkCAImageQueueReleaseCallback release, void *info);
150uint64_t wkCAImageQueueRegisterPixelBuffer(CAImageQueueRef iq, void *data, size_t data_size, size_t rowbytes, size_t width, size_t height, OSType pixel_format, CFDictionaryRef attachments, uint32_t flags);
151void wkCAImageQueueSetFlags(CAImageQueueRef iq, uint32_t mask, uint32_t flags);
152uint32_t wkCAImageQueueGetFlags(CAImageQueueRef iq);
153CFTypeID wkCAImageQueueGetTypeID(void);
154
155WKCACFContext* wkCACFContextCreate();
156void wkCACFContextDestroy(WKCACFContext*);
157
158void wkCACFContextSetLayer(WKCACFContext*, CACFLayerRef);
159void wkCACFContextFlush(WKCACFContext*);
160
161CFTimeInterval wkCACFContextGetLastCommitTime(WKCACFContext*);
162CFTimeInterval wkCACFContextGetNextUpdateTime(WKCACFContext*);
163
164void* wkCACFContextGetUserData(WKCACFContext*);
165void wkCACFContextSetUserData(WKCACFContext*, void*);
166
167void* wkCACFLayerGetContextUserData(CACFLayerRef);
168
169void wkCACFContextSetD3DDevice(WKCACFContext*, IDirect3DDevice9*);
170void wkCACFContextReleaseD3DResources(WKCACFContext*);
171
172bool wkCACFContextBeginUpdate(WKCACFContext*, void* buffer, size_t bufferSize, CFTimeInterval time, const CGRect& bounds, const CGRect dirtyRects[], size_t dirtyRectCount);
173void wkCACFContextRenderUpdate(WKCACFContext*);
174void wkCACFContextFinishUpdate(WKCACFContext*);
175void wkCACFContextAddUpdateRect(WKCACFContext*, const CGRect&);
176
177WKCACFUpdateRectEnumerator* wkCACFContextCopyUpdateRectEnumerator(WKCACFContext*);
178const CGRect* wkCACFUpdateRectEnumeratorNextRect(WKCACFUpdateRectEnumerator*);
179void wkCACFUpdateRectEnumeratorRelease(WKCACFUpdateRectEnumerator*);
180
181CFDictionaryRef wkCFURLRequestCreateSerializableRepresentation(CFURLRequestRef cfRequest, CFTypeRef tokenNull);
182CFURLRequestRef wkCFURLRequestCreateFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
183CFDictionaryRef wkCFURLResponseCreateSerializableRepresentation(CFURLResponseRef cfResponse, CFTypeRef tokenNull);
184CFURLResponseRef wkCFURLResponseCreateFromSerializableRepresentation(CFDictionaryRef representation, CFTypeRef tokenNull);
185
186typedef void (*wkQuickTimeMIMETypeCallBack)(const char* mimeType);
187void wkGetQuickTimeMIMETypeList(wkQuickTimeMIMETypeCallBack);
188
189typedef enum {
190    WKMediaUIPartFullscreenButton   = 0,
191    WKMediaUIPartMuteButton,
192    WKMediaUIPartPlayButton,
193    WKMediaUIPartSeekBackButton,
194    WKMediaUIPartSeekForwardButton,
195    WKMediaUIPartTimelineSlider,
196    WKMediaUIPartTimelineSliderThumb,
197    WKMediaUIPartRewindButton,
198    WKMediaUIPartSeekToRealtimeButton,
199    WKMediaUIPartShowClosedCaptionsButton,
200    WKMediaUIPartHideClosedCaptionsButton,
201    WKMediaUIPartUnMuteButton,
202    WKMediaUIPartPauseButton,
203    WKMediaUIPartBackground,
204    WKMediaUIPartCurrentTimeDisplay,
205    WKMediaUIPartTimeRemainingDisplay,
206    WKMediaUIPartStatusDisplay,
207    WKMediaUIPartControlsPanel,
208    WKMediaUIPartVolumeSliderContainer,
209    WKMediaUIPartVolumeSlider,
210    WKMediaUIPartVolumeSliderThumb
211} WKMediaUIPart;
212
213typedef enum {
214    WKMediaControllerThemeClassic   = 1,
215    WKMediaControllerThemeQuickTime = 2
216} WKMediaControllerThemeStyle;
217
218typedef enum {
219    WKMediaControllerFlagDisabled = 1 << 0,
220    WKMediaControllerFlagPressed = 1 << 1,
221    WKMediaControllerFlagDrawEndCaps = 1 << 3,
222    WKMediaControllerFlagFocused = 1 << 4
223} WKMediaControllerThemeState;
224
225#ifdef __cplusplus
226extern "C" {
227#endif
228
229bool WKMediaControllerThemeAvailable(int themeStyle);
230bool WKHitTestMediaUIPart(int part, int themeStyle, CGRect bounds, CGPoint point);
231void WKMeasureMediaUIPart(int part, int themeStyle, CGRect *bounds, CGSize *naturalSize);
232void WKDrawMediaUIPart(int part, int themeStyle, CGContextRef context, CGRect rect, unsigned state);
233void WKDrawMediaSliderTrack(int themeStyle, CGContextRef context, CGRect rect, float timeLoaded, float currentTime, float duration, unsigned state);
234
235#ifdef __cplusplus
236}
237#endif
238
239#endif // WebKitSystemInterface_h
240