summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/Shared/mac
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/Shared/mac')
-rw-r--r--Source/WebKit2/Shared/mac/CommandLineMac.cpp1
-rw-r--r--Source/WebKit2/Shared/mac/CoreAnimationRenderer.h69
-rw-r--r--Source/WebKit2/Shared/mac/CoreAnimationRenderer.mm100
-rw-r--r--Source/WebKit2/Shared/mac/LayerTreeContextMac.mm66
-rw-r--r--Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm1
-rw-r--r--Source/WebKit2/Shared/mac/PasteboardTypes.mm2
-rw-r--r--Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm11
-rw-r--r--Source/WebKit2/Shared/mac/PrintInfoMac.mm1
-rw-r--r--Source/WebKit2/Shared/mac/SandboxExtensionMac.mm17
-rw-r--r--Source/WebKit2/Shared/mac/ShareableSurface.cpp215
-rw-r--r--Source/WebKit2/Shared/mac/ShareableSurface.h98
-rw-r--r--Source/WebKit2/Shared/mac/UpdateChunk.cpp1
-rw-r--r--Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm7
-rw-r--r--Source/WebKit2/Shared/mac/WebEventFactory.h4
-rw-r--r--Source/WebKit2/Shared/mac/WebEventFactory.mm34
-rw-r--r--Source/WebKit2/Shared/mac/WebMemorySampler.mac.mm26
-rw-r--r--Source/WebKit2/Shared/mac/WebURLRequestMac.mm3
-rw-r--r--Source/WebKit2/Shared/mac/WebURLResponseMac.mm3
18 files changed, 626 insertions, 33 deletions
diff --git a/Source/WebKit2/Shared/mac/CommandLineMac.cpp b/Source/WebKit2/Shared/mac/CommandLineMac.cpp
index 185aaea..d48a401 100644
--- a/Source/WebKit2/Shared/mac/CommandLineMac.cpp
+++ b/Source/WebKit2/Shared/mac/CommandLineMac.cpp
@@ -23,6 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "config.h"
#include "CommandLine.h"
namespace WebKit {
diff --git a/Source/WebKit2/Shared/mac/CoreAnimationRenderer.h b/Source/WebKit2/Shared/mac/CoreAnimationRenderer.h
new file mode 100644
index 0000000..482f579
--- /dev/null
+++ b/Source/WebKit2/Shared/mac/CoreAnimationRenderer.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2011 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CoreAnimationRenderer_h
+#define CoreAnimationRenderer_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS CALayer;
+OBJC_CLASS CARenderer;
+
+typedef struct _CGLContextObject* CGLContextObj;
+
+namespace WebKit {
+
+class CoreAnimationRenderer : public RefCounted<CoreAnimationRenderer> {
+public:
+ class Client {
+ public:
+ virtual ~Client() { }
+ virtual void rendererDidChange(CoreAnimationRenderer*) = 0;
+ };
+
+ static PassRefPtr<CoreAnimationRenderer> create(Client*, CGLContextObj, CALayer *);
+ ~CoreAnimationRenderer();
+
+ void invalidate();
+
+ void setBounds(CGRect);
+ void render(CFTimeInterval frameTime, CVTimeStamp*, CFTimeInterval& nextFrameTime);
+
+private:
+ CoreAnimationRenderer(Client*, CGLContextObj, CALayer *);
+
+ static void rendererDidChange(void*);
+ void rendererDidChange();
+
+ Client* m_client;
+ CGLContextObj m_cglContext;
+ RetainPtr<CARenderer> m_renderer;
+};
+
+} // namespace WebKit
+
+#endif // CoreAnimationRenderer_h
diff --git a/Source/WebKit2/Shared/mac/CoreAnimationRenderer.mm b/Source/WebKit2/Shared/mac/CoreAnimationRenderer.mm
new file mode 100644
index 0000000..97276f6
--- /dev/null
+++ b/Source/WebKit2/Shared/mac/CoreAnimationRenderer.mm
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2011 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "CoreAnimationRenderer.h"
+
+#import <WebKitSystemInterface.h>
+#import <QuartzCore/QuartzCore.h>
+#import <OpenGL/CGLMacro.h>
+
+// The CGLMacro.h header adds an implicit CGLContextObj parameter to all OpenGL calls,
+// which is good because it allows us to make OpenGL calls without saving and restoring the
+// current context. The context argument is named "cgl_ctx" by default, so we use the macro
+// below to declare this variable.
+#define DECLARE_GL_CONTEXT_VARIABLE(name) \
+ CGLContextObj cgl_ctx = (name)
+
+namespace WebKit {
+
+PassRefPtr<CoreAnimationRenderer> CoreAnimationRenderer::create(Client* client, CGLContextObj cglContextObj, CALayer *layer)
+{
+ return adoptRef(new CoreAnimationRenderer(client, cglContextObj, layer));
+}
+
+CoreAnimationRenderer::CoreAnimationRenderer(Client* client, CGLContextObj cglContextObj, CALayer *layer)
+ : m_client(client)
+ , m_cglContext(cglContextObj)
+ , m_renderer([CARenderer rendererWithCGLContext:m_cglContext options:nil])
+{
+ [m_renderer.get() setLayer:layer];
+
+ WKCARendererAddChangeNotificationObserver(m_renderer.get(), rendererDidChange, this);
+}
+
+CoreAnimationRenderer::~CoreAnimationRenderer()
+{
+ ASSERT(!m_client);
+}
+
+void CoreAnimationRenderer::setBounds(CGRect bounds)
+{
+ [m_renderer.get() setBounds:bounds];
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [[m_renderer.get() layer] setFrame:bounds];
+ [CATransaction commit];
+}
+
+void CoreAnimationRenderer::render(CFTimeInterval frameTime, CVTimeStamp* timeStamp, CFTimeInterval& nextFrameTime)
+{
+ [m_renderer.get() beginFrameAtTime:frameTime timeStamp:timeStamp];
+ [m_renderer.get() render];
+ nextFrameTime = [m_renderer.get() nextFrameTime];
+ [m_renderer.get() endFrame];
+}
+
+void CoreAnimationRenderer::invalidate()
+{
+ ASSERT(m_client);
+
+ WKCARendererRemoveChangeNotificationObserver(m_renderer.get(), rendererDidChange, this);
+ m_client = 0;
+}
+
+void CoreAnimationRenderer::rendererDidChange(void* context)
+{
+ static_cast<CoreAnimationRenderer*>(context)->rendererDidChange();
+}
+
+void CoreAnimationRenderer::rendererDidChange()
+{
+ ASSERT(m_client);
+
+ m_client->rendererDidChange(this);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/mac/LayerTreeContextMac.mm b/Source/WebKit2/Shared/mac/LayerTreeContextMac.mm
new file mode 100644
index 0000000..e4ad1ce
--- /dev/null
+++ b/Source/WebKit2/Shared/mac/LayerTreeContextMac.mm
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LayerTreeContext.h"
+
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+
+namespace WebKit {
+
+LayerTreeContext::LayerTreeContext()
+ : contextID(0)
+{
+}
+
+LayerTreeContext::~LayerTreeContext()
+{
+}
+
+void LayerTreeContext::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+ encoder->encode(contextID);
+}
+
+bool LayerTreeContext::decode(CoreIPC::ArgumentDecoder* decoder, LayerTreeContext& result)
+{
+ if (!decoder->decode(result.contextID))
+ return false;
+
+ return true;
+}
+
+bool LayerTreeContext::isEmpty() const
+{
+ return !contextID;
+}
+
+bool operator==(const LayerTreeContext& a, const LayerTreeContext& b)
+{
+ return a.contextID == b.contextID;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm b/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm
index d69082d..c9f2a0a 100644
--- a/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm
+++ b/Source/WebKit2/Shared/mac/NativeWebKeyboardEventMac.mm
@@ -23,6 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#import "config.h"
#import "NativeWebKeyboardEvent.h"
#import "WebEventFactory.h"
diff --git a/Source/WebKit2/Shared/mac/PasteboardTypes.mm b/Source/WebKit2/Shared/mac/PasteboardTypes.mm
index 380e24c..0d48464 100644
--- a/Source/WebKit2/Shared/mac/PasteboardTypes.mm
+++ b/Source/WebKit2/Shared/mac/PasteboardTypes.mm
@@ -23,7 +23,9 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#import "config.h"
#import "PasteboardTypes.h"
+
#import <wtf/RetainPtr.h>
namespace WebKit {
diff --git a/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm b/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
index 0f3fee7..0c0b737 100644
--- a/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
+++ b/Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
@@ -23,12 +23,13 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "PlatformCertificateInfo.h"
+#import "config.h"
+#import "PlatformCertificateInfo.h"
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include <WebKitSystemInterface.h>
-#include <Security/Security.h>
+#import "ArgumentDecoder.h"
+#import "ArgumentEncoder.h"
+#import <WebKitSystemInterface.h>
+#import <Security/Security.h>
using namespace WebCore;
diff --git a/Source/WebKit2/Shared/mac/PrintInfoMac.mm b/Source/WebKit2/Shared/mac/PrintInfoMac.mm
index 78cf9df..bb7792c 100644
--- a/Source/WebKit2/Shared/mac/PrintInfoMac.mm
+++ b/Source/WebKit2/Shared/mac/PrintInfoMac.mm
@@ -23,6 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#import "config.h"
#import "PrintInfo.h"
namespace WebKit {
diff --git a/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm b/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm
index 68b5849..54cf5d3 100644
--- a/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm
+++ b/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm
@@ -23,16 +23,17 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#if ENABLE(WEB_PROCESS_SANDBOX)
+#import "config.h"
+#import "SandboxExtension.h"
-#include "SandboxExtension.h"
+#if ENABLE(WEB_PROCESS_SANDBOX)
-#include "ArgumentDecoder.h"
-#include "ArgumentEncoder.h"
-#include "DataReference.h"
-#include "WebKitSystemInterface.h"
-#include <WebCore/FileSystem.h>
-#include <wtf/text/CString.h>
+#import "ArgumentDecoder.h"
+#import "ArgumentEncoder.h"
+#import "DataReference.h"
+#import "WebKitSystemInterface.h"
+#import <WebCore/FileSystem.h>
+#import <wtf/text/CString.h>
using namespace WebCore;
diff --git a/Source/WebKit2/Shared/mac/ShareableSurface.cpp b/Source/WebKit2/Shared/mac/ShareableSurface.cpp
new file mode 100644
index 0000000..4c15f5e
--- /dev/null
+++ b/Source/WebKit2/Shared/mac/ShareableSurface.cpp
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2011 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ShareableSurface.h"
+
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+#include "MachPort.h"
+#include <IOSurface/IOSurface.h>
+#include <OpenGL/CGLIOSurface.h>
+#include <OpenGL/CGLMacro.h>
+#include <OpenGL/OpenGL.h>
+#include <mach/mach_port.h>
+
+// The CGLMacro.h header adds an implicit CGLContextObj parameter to all OpenGL calls,
+// which is good because it allows us to make OpenGL calls without saving and restoring the
+// current context. The context argument is named "cgl_ctx" by default, so we the macro
+// below to declare this variable.
+#define DECLARE_GL_CONTEXT_VARIABLE(name) \
+ CGLContextObj cgl_ctx = (name)
+
+// It expects a context named "
+using namespace WebCore;
+
+namespace WebKit {
+
+ShareableSurface::Handle::Handle()
+ : m_port(MACH_PORT_NULL)
+{
+}
+
+ShareableSurface::Handle::~Handle()
+{
+ if (m_port != MACH_PORT_NULL)
+ mach_port_deallocate(mach_task_self(), m_port);
+}
+
+void ShareableSurface::Handle::encode(CoreIPC::ArgumentEncoder* encoder) const
+{
+ encoder->encode(CoreIPC::MachPort(m_port, MACH_MSG_TYPE_MOVE_SEND));
+ m_port = MACH_PORT_NULL;
+}
+
+bool ShareableSurface::Handle::decode(CoreIPC::ArgumentDecoder* decoder, Handle& handle)
+{
+ ASSERT_ARG(handle, handle.m_port == MACH_PORT_NULL);
+
+ CoreIPC::MachPort machPort;
+ if (!decoder->decode(machPort))
+ return false;
+
+ handle.m_port = machPort.port();
+ return false;
+}
+
+static RetainPtr<IOSurfaceRef> createIOSurface(const IntSize& size)
+{
+ int width = size.width();
+ int height = size.height();
+
+ unsigned bytesPerElement = 4;
+ unsigned long bytesPerRow = IOSurfaceAlignProperty(kIOSurfaceBytesPerRow, width * bytesPerElement);
+ if (!bytesPerRow)
+ return 0;
+
+ unsigned long allocSize = IOSurfaceAlignProperty(kIOSurfaceAllocSize, height * bytesPerRow);
+ if (!allocSize)
+ return 0;
+
+ unsigned pixelFormat = 'BGRA';
+
+ static const size_t numKeys = 6;
+ const void *keys[numKeys];
+ const void *values[numKeys];
+ keys[0] = kIOSurfaceWidth;
+ values[0] = CFNumberCreate(0, kCFNumberIntType, &width);
+ keys[1] = kIOSurfaceHeight;
+ values[1] = CFNumberCreate(0, kCFNumberIntType, &height);
+ keys[2] = kIOSurfacePixelFormat;
+ values[2] = CFNumberCreate(0, kCFNumberIntType, &pixelFormat);
+ keys[3] = kIOSurfaceBytesPerElement;
+ values[3] = CFNumberCreate(0, kCFNumberIntType, &bytesPerElement);
+ keys[4] = kIOSurfaceBytesPerRow;
+ values[4] = CFNumberCreate(0, kCFNumberLongType, &bytesPerRow);
+ keys[5] = kIOSurfaceAllocSize;
+ values[5] = CFNumberCreate(0, kCFNumberLongType, &allocSize);
+
+ RetainPtr<CFDictionaryRef> dictionary(AdoptCF, CFDictionaryCreate(0, keys, values, numKeys, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ for (unsigned i = 0; i < numKeys; i++)
+ CFRelease(values[i]);
+
+ return RetainPtr<IOSurfaceRef>(AdoptCF, IOSurfaceCreate(dictionary.get()));
+}
+
+PassRefPtr<ShareableSurface> ShareableSurface::create(CGLContextObj cglContextObj, const IntSize& size)
+{
+ RetainPtr<IOSurfaceRef> ioSurface = createIOSurface(size);
+ if (!ioSurface)
+ return 0;
+
+ return adoptRef(new ShareableSurface(cglContextObj, size, ioSurface.get()));
+}
+
+PassRefPtr<ShareableSurface> ShareableSurface::create(CGLContextObj cglContextObj, const Handle& handle)
+{
+ ASSERT_ARG(handle, handle.m_port != MACH_PORT_NULL);
+
+ RetainPtr<IOSurfaceRef> ioSurface(AdoptCF, IOSurfaceLookupFromMachPort(handle.m_port));
+ if (!ioSurface)
+ return 0;
+
+ IntSize size = IntSize(IOSurfaceGetWidth(ioSurface.get()), IOSurfaceGetHeight(ioSurface.get()));
+
+ return adoptRef(new ShareableSurface(cglContextObj, size, ioSurface.get()));
+}
+
+ShareableSurface::ShareableSurface(CGLContextObj cglContextObj, const IntSize& size, IOSurfaceRef ioSurface)
+ : m_cglContextObj(CGLRetainContext(cglContextObj))
+ , m_size(size)
+ , m_textureID(0)
+ , m_frameBufferObjectID(0)
+ , m_ioSurface(ioSurface)
+{
+}
+
+ShareableSurface::~ShareableSurface()
+{
+ DECLARE_GL_CONTEXT_VARIABLE(m_cglContextObj);
+
+ if (m_textureID)
+ glDeleteTextures(1, &m_textureID);
+
+ if (m_frameBufferObjectID)
+ glDeleteFramebuffersEXT(1, &m_frameBufferObjectID);
+
+ CGLReleaseContext(m_cglContextObj);
+}
+
+bool ShareableSurface::createHandle(Handle& handle)
+{
+ ASSERT_ARG(handle, handle.m_port == MACH_PORT_NULL);
+
+ mach_port_t port = IOSurfaceCreateMachPort(m_ioSurface.get());
+ if (port == MACH_PORT_NULL)
+ return false;
+
+ handle.m_port = port;
+ return true;
+}
+
+void ShareableSurface::attach()
+{
+ DECLARE_GL_CONTEXT_VARIABLE(m_cglContextObj);
+
+ if (!m_frameBufferObjectID) {
+ // Generate a frame buffer object.
+ glGenFramebuffersEXT(1, &m_frameBufferObjectID);
+
+ // Associate it with the texture.
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameBufferObjectID);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_EXT, textureID(), 0);
+ } else
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_frameBufferObjectID);
+}
+
+void ShareableSurface::detach()
+{
+ DECLARE_GL_CONTEXT_VARIABLE(m_cglContextObj);
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+}
+
+unsigned ShareableSurface::textureID()
+{
+ if (m_textureID)
+ return m_textureID;
+
+ DECLARE_GL_CONTEXT_VARIABLE(m_cglContextObj);
+
+ // Generate a texture.
+ glGenTextures(1, &m_textureID);
+
+ // Associate it with our IOSurface.
+ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, m_textureID);
+ CGLTexImageIOSurface2D(cgl_ctx, GL_TEXTURE_RECTANGLE_EXT, GL_RGBA8, m_size.width(), m_size.height(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, m_ioSurface.get(), 0);
+ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0);
+
+ return m_textureID;
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/Shared/mac/ShareableSurface.h b/Source/WebKit2/Shared/mac/ShareableSurface.h
new file mode 100644
index 0000000..dda1364
--- /dev/null
+++ b/Source/WebKit2/Shared/mac/ShareableSurface.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2011 Apple 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 INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ShareableSurface_h
+#define ShareableSurface_h
+
+#include <WebCore/IntSize.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+
+typedef struct _CGLContextObject* CGLContextObj;
+typedef struct __IOSurface* IOSurfaceRef;
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class ShareableSurface : public RefCounted<ShareableSurface> {
+public:
+ class Handle {
+ WTF_MAKE_NONCOPYABLE(Handle);
+
+ public:
+ Handle();
+ ~Handle();
+
+ void encode(CoreIPC::ArgumentEncoder*) const;
+ static bool decode(CoreIPC::ArgumentDecoder*, Handle&);
+
+ private:
+ friend class ShareableSurface;
+
+ mutable mach_port_t m_port;
+ };
+
+ // Create a shareable surface with the given size. Returns 0 on failure.
+ static PassRefPtr<ShareableSurface> create(CGLContextObj, const WebCore::IntSize&);
+
+ // Create a shareable surface from a handle. Returns 0 on failure.
+ static PassRefPtr<ShareableSurface> create(CGLContextObj, const Handle&);
+
+ ~ShareableSurface();
+
+ bool createHandle(Handle&);
+
+ unsigned textureID();
+
+ void attach();
+ void detach();
+
+private:
+ ShareableSurface(CGLContextObj, const WebCore::IntSize&, IOSurfaceRef);
+
+ // The OpenGL context.
+ CGLContextObj m_cglContextObj;
+
+ // The size of the surface.
+ WebCore::IntSize m_size;
+
+ // The ID of the texture.
+ unsigned m_textureID;
+
+ // The frame buffer object ID of the texture; used when the surface is used as a render destination.
+ unsigned m_frameBufferObjectID;
+
+ RetainPtr<IOSurfaceRef> m_ioSurface;
+};
+
+} // namespace WebKit
+
+#endif // ShareableSurface_h
diff --git a/Source/WebKit2/Shared/mac/UpdateChunk.cpp b/Source/WebKit2/Shared/mac/UpdateChunk.cpp
index a9376db..76206fb 100644
--- a/Source/WebKit2/Shared/mac/UpdateChunk.cpp
+++ b/Source/WebKit2/Shared/mac/UpdateChunk.cpp
@@ -23,6 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "config.h"
#include "UpdateChunk.h"
#include "ArgumentDecoder.h"
diff --git a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm b/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
index 8ffba8a..63dd20d 100644
--- a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
+++ b/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm
@@ -23,10 +23,11 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "WebCoreArgumentCoders.h"
+#import "config.h"
+#import "WebCoreArgumentCoders.h"
-#include "ArgumentCodersCF.h"
-#include "WebKitSystemInterface.h"
+#import "ArgumentCodersCF.h"
+#import "WebKitSystemInterface.h"
namespace CoreIPC {
diff --git a/Source/WebKit2/Shared/mac/WebEventFactory.h b/Source/WebKit2/Shared/mac/WebEventFactory.h
index 7bc8d97..73fbed0 100644
--- a/Source/WebKit2/Shared/mac/WebEventFactory.h
+++ b/Source/WebKit2/Shared/mac/WebEventFactory.h
@@ -38,6 +38,10 @@ public:
static WebMouseEvent createWebMouseEvent(NSEvent *event, NSView *windowView);
static WebWheelEvent createWebWheelEvent(NSEvent *event, NSView *windowView);
static WebKeyboardEvent createWebKeyboardEvent(NSEvent *event, NSView *windowView);
+
+#if ENABLE(GESTURE_EVENTS)
+ static WebGestureEvent createWebGestureEvent(NSEvent *event, NSView *windowView);
+#endif
};
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/mac/WebEventFactory.mm b/Source/WebKit2/Shared/mac/WebEventFactory.mm
index 46ff906..e31c62e 100644
--- a/Source/WebKit2/Shared/mac/WebEventFactory.mm
+++ b/Source/WebKit2/Shared/mac/WebEventFactory.mm
@@ -23,6 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#import "config.h"
#import "WebEventFactory.h"
#import "WebKitSystemInterface.h"
@@ -188,7 +189,22 @@ static WebWheelEvent::Phase phaseForEvent(NSEvent *event)
return WebWheelEvent::PhaseNone;
#endif
}
-
+
+#if ENABLE(GESTURE_EVENTS)
+static WebEvent::Type gestureEventTypeForEvent(NSEvent *event)
+{
+ switch ([event type]) {
+ case NSEventTypeBeginGesture:
+ return WebEvent::GestureScrollBegin;
+ case NSEventTypeEndGesture:
+ return WebEvent::GestureScrollEnd;
+ default:
+ ASSERT_NOT_REACHED();
+ return WebEvent::GestureScrollEnd;
+ }
+}
+#endif
+
static inline String textFromEvent(NSEvent* event)
{
if ([event type] == NSFlagsChanged)
@@ -1020,10 +1036,11 @@ WebWheelEvent WebEventFactory::createWebWheelEvent(NSEvent *event, NSView *windo
}
WebWheelEvent::Phase phase = phaseForEvent(event);
+ bool hasPreciseScrollingDeltas = continuous;
WebEvent::Modifiers modifiers = modifiersForEvent(event);
double timestamp = [event timestamp];
- return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, modifiers, timestamp);
+ return WebWheelEvent(WebEvent::Wheel, IntPoint(position), IntPoint(globalPosition), FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, phase, hasPreciseScrollingDeltas, modifiers, timestamp);
}
WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, NSView *)
@@ -1044,4 +1061,17 @@ WebKeyboardEvent WebEventFactory::createWebKeyboardEvent(NSEvent *event, NSView
return WebKeyboardEvent(type, text, unmodifiedText, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, timestamp);
}
+#if ENABLE(GESTURE_EVENTS)
+WebGestureEvent WebEventFactory::createWebGestureEvent(NSEvent *event, NSView *windowView)
+{
+ WebEvent::Type type = gestureEventTypeForEvent(event);
+ NSPoint position = pointForEvent(event, windowView);
+ NSPoint globalPosition = globalPointForEvent(event);
+ WebEvent::Modifiers modifiers = modifiersForEvent(event);
+ double timestamp = [event timestamp];
+
+ return WebGestureEvent(type, IntPoint(position), IntPoint(globalPosition), modifiers, timestamp);
+}
+#endif
+
} // namespace WebKit
diff --git a/Source/WebKit2/Shared/mac/WebMemorySampler.mac.mm b/Source/WebKit2/Shared/mac/WebMemorySampler.mac.mm
index 5be52d4..ed12cc4 100644
--- a/Source/WebKit2/Shared/mac/WebMemorySampler.mac.mm
+++ b/Source/WebKit2/Shared/mac/WebMemorySampler.mac.mm
@@ -23,18 +23,19 @@
*
*/
-#if ENABLE(MEMORY_SAMPLER)
+#import "config.h"
+#import "WebMemorySampler.h"
-#include "WebMemorySampler.h"
+#if ENABLE(MEMORY_SAMPLER)
-#include <JavaScriptCore/MemoryStatistics.h>
-#include <mach/mach.h>
-#include <mach/task.h>
-#include <mach/mach_types.h>
-#include <malloc/malloc.h>
-#include <runtime/JSLock.h>
-#include <WebCore/JSDOMWindow.h>
-#include <wtf/CurrentTime.h>
+#import <JavaScriptCore/MemoryStatistics.h>
+#import <mach/mach.h>
+#import <mach/task.h>
+#import <mach/mach_types.h>
+#import <malloc/malloc.h>
+#import <runtime/JSLock.h>
+#import <WebCore/JSDOMWindow.h>
+#import <wtf/CurrentTime.h>
using namespace WebCore;
using namespace JSC;
@@ -115,9 +116,8 @@ WebMemoryStatistics WebMemorySampler::sampleWebKit() const
totalBytesCommitted += fastMallocBytesCommitted;
JSLock lock(SilenceAssertionsOnly);
- MarkedSpace::Statistics heapMemoryStats = heapStatistics(JSDOMWindow::commonJSGlobalData());
- size_t jscHeapBytesInUse = heapMemoryStats.size - heapMemoryStats.free;
- size_t jscHeapBytesCommitted = heapMemoryStats.size;
+ size_t jscHeapBytesInUse = JSDOMWindow::commonJSGlobalData()->heap.size();
+ size_t jscHeapBytesCommitted = JSDOMWindow::commonJSGlobalData()->heap.capacity();
totalBytesInUse += jscHeapBytesInUse;
totalBytesCommitted += jscHeapBytesCommitted;
diff --git a/Source/WebKit2/Shared/mac/WebURLRequestMac.mm b/Source/WebKit2/Shared/mac/WebURLRequestMac.mm
index a7196f7..4eda378 100644
--- a/Source/WebKit2/Shared/mac/WebURLRequestMac.mm
+++ b/Source/WebKit2/Shared/mac/WebURLRequestMac.mm
@@ -23,7 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "WebURLRequest.h"
+#import "config.h"
+#import "WebURLRequest.h"
namespace WebKit {
diff --git a/Source/WebKit2/Shared/mac/WebURLResponseMac.mm b/Source/WebKit2/Shared/mac/WebURLResponseMac.mm
index ff5b6e6..6f44afc 100644
--- a/Source/WebKit2/Shared/mac/WebURLResponseMac.mm
+++ b/Source/WebKit2/Shared/mac/WebURLResponseMac.mm
@@ -23,7 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "WebURLResponse.h"
+#import "config.h"
+#import "WebURLResponse.h"
namespace WebKit {