[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andersca at apple.com
andersca at apple.com
Wed Dec 22 13:46:36 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit abe95ebc8b565e65dd6ee206c5965e94400d6646
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Sep 26 21:48:12 2010 +0000
Add BackingStore class
https://bugs.webkit.org/show_bug.cgi?id=46584
Reviewed by Sam Weinig.
* Shared/BackingStore.cpp: Added.
(WebKit::BackingStore::create):
Create a backing store backed by fastMalloc memory.
(WebKit::BackingStore::createSharable):
Create a backing store backed by shared memory.
(WebKit::BackingStore::createHandle):
Create a handle that can be sent over the wire.
(WebKit::BackingStore::resize):
Resize the backing store memory.
(WebKit::BackingStore::data):
Return the backing store data.
* Shared/mac/BackingStoreMac.mm: Added.
(WebKit::BackingStore::createGraphicsContext):
Create a graphics context that will paint into the backing store.
(WebKit::BackingStore::paint):
Paint the backing store in a graphics context.
* WebKit2.xcodeproj/project.pbxproj:
Add files.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index beef717..0ce665c 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -2,6 +2,39 @@
Reviewed by Sam Weinig.
+ Add BackingStore class
+ https://bugs.webkit.org/show_bug.cgi?id=46584
+
+ * Shared/BackingStore.cpp: Added.
+ (WebKit::BackingStore::create):
+ Create a backing store backed by fastMalloc memory.
+
+ (WebKit::BackingStore::createSharable):
+ Create a backing store backed by shared memory.
+
+ (WebKit::BackingStore::createHandle):
+ Create a handle that can be sent over the wire.
+
+ (WebKit::BackingStore::resize):
+ Resize the backing store memory.
+
+ (WebKit::BackingStore::data):
+ Return the backing store data.
+
+ * Shared/mac/BackingStoreMac.mm: Added.
+ (WebKit::BackingStore::createGraphicsContext):
+ Create a graphics context that will paint into the backing store.
+
+ (WebKit::BackingStore::paint):
+ Paint the backing store in a graphics context.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add files.
+
+2010-09-26 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
Establish a connection between the plug-in process and the web process
https://bugs.webkit.org/show_bug.cgi?id=46583
diff --git a/WebKit2/Shared/BackingStore.cpp b/WebKit2/Shared/BackingStore.cpp
new file mode 100644
index 0000000..7c95758
--- /dev/null
+++ b/WebKit2/Shared/BackingStore.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2010 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 "BackingStore.h"
+
+#include "SharedMemory.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<BackingStore> BackingStore::create(const WebCore::IntSize& size)
+{
+ size_t numBytes = size.width() * size.height() * 4;
+
+ void* data = 0;
+ if (!tryFastMalloc(numBytes).getValue(data))
+ return 0;
+
+ return adoptRef(new BackingStore(size, data));
+}
+
+PassRefPtr<BackingStore> BackingStore::createSharable(const IntSize& size)
+{
+ size_t numBytes = size.width() * size.height() * 4;
+
+ RefPtr<SharedMemory> sharedMemory = SharedMemory::create(numBytes);
+ if (!sharedMemory)
+ return 0;
+
+ return adoptRef(new BackingStore(size, sharedMemory));
+}
+
+PassRefPtr<BackingStore> BackingStore::create(const WebCore::IntSize& size, const SharedMemory::Handle& handle)
+{
+ // Create the shared memory.
+ RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle, SharedMemory::ReadWrite);
+ if (!sharedMemory)
+ return 0;
+
+ size_t numBytes = size.width() * size.height() * 4;
+ ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes);
+
+ return adoptRef(new BackingStore(size, sharedMemory));
+}
+
+bool BackingStore::createHandle(SharedMemory::Handle& handle)
+{
+ ASSERT(isBackedBySharedMemory());
+
+ return m_sharedMemory->createHandle(handle, SharedMemory::ReadWrite);
+}
+
+BackingStore::BackingStore(const IntSize& size, void* data)
+ : m_size(size)
+ , m_data(data)
+{
+}
+
+BackingStore::BackingStore(const IntSize& size, PassRefPtr<SharedMemory> sharedMemory)
+ : m_size(size)
+ , m_sharedMemory(sharedMemory)
+ , m_data(0)
+{
+}
+
+BackingStore::~BackingStore()
+{
+ if (!isBackedBySharedMemory())
+ fastFree(m_data);
+}
+
+bool BackingStore::resize(const IntSize& size)
+{
+ // We can't resize backing stores that are backed by shared memory.
+ ASSERT(!isBackedBySharedMemory());
+
+ if (size == m_size)
+ return true;
+
+ size_t newNumBytes = size.width() * size.height() * 4;
+
+ // Try to resize.
+ char* newData = 0;
+ if (!tryFastRealloc(m_data, newNumBytes).getValue(newData)) {
+ // We failed, but the backing store is still kept in a consistent state.
+ return false;
+ }
+
+ m_size = size;
+ m_data = newData;
+
+ return true;
+}
+
+void* BackingStore::data() const
+{
+ if (isBackedBySharedMemory())
+ return m_sharedMemory->data();
+
+ ASSERT(m_data);
+ return m_data;
+}
+
+} // namespace WebKit
diff --git a/WebKit2/Shared/BackingStore.h b/WebKit2/Shared/BackingStore.h
new file mode 100644
index 0000000..e2570d4
--- /dev/null
+++ b/WebKit2/Shared/BackingStore.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2010 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 BackingStore_h
+#define BackingStore_h
+
+#include "SharedMemory.h"
+#include <WebCore/IntSize.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+ class GraphicsContext;
+ class IntRect;
+}
+
+namespace WebKit {
+
+class BackingStore : public RefCounted<BackingStore> {
+public:
+ // Create a backing store that uses malloced memory.
+ static PassRefPtr<BackingStore> create(const WebCore::IntSize&);
+
+ // Create a backing store whose backing memory can be shared with another process.
+ static PassRefPtr<BackingStore> createSharable(const WebCore::IntSize&);
+
+ // Create a backing store from a shared memory handle.
+ static PassRefPtr<BackingStore> create(const WebCore::IntSize&, const SharedMemory::Handle&);
+
+ // Create a shared memory handle.
+ bool createHandle(SharedMemory::Handle&);
+
+ ~BackingStore();
+
+ const WebCore::IntSize& size() const { return m_size; }
+ bool resize(const WebCore::IntSize& size);
+
+ // Create a graphics context that can be used to paint into the backing store.
+ PassOwnPtr<WebCore::GraphicsContext> createGraphicsContext();
+
+ // Paint the backing store into the given context.
+ void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
+
+private:
+ BackingStore(const WebCore::IntSize&, void*);
+ BackingStore(const WebCore::IntSize&, PassRefPtr<SharedMemory>);
+
+ bool isBackedBySharedMemory() const { return m_sharedMemory; }
+ void* data() const;
+
+ WebCore::IntSize m_size;
+
+ // If the backing store is backed by shared memory, this points to the shared memory object.
+ RefPtr<SharedMemory> m_sharedMemory;
+
+ // If the backing store is backed by fastMalloced memory, this points to the data.
+ void* m_data;
+};
+
+} // namespace WebKit
+
+#endif // BackingStore_h
diff --git a/WebKit2/Shared/mac/BackingStoreMac.mm b/WebKit2/Shared/mac/BackingStoreMac.mm
new file mode 100644
index 0000000..daa7dc0
--- /dev/null
+++ b/WebKit2/Shared/mac/BackingStoreMac.mm
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010 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 "BackingStore.h"
+
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<GraphicsContext> BackingStore::createGraphicsContext()
+{
+ RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+ RetainPtr<CGContextRef> bitmapContext(AdoptCF, CGBitmapContextCreate(data(), m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(),
+ kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
+
+ // We want the origin to be in the top left corner so flip the backing store context.
+ CGContextTranslateCTM(bitmapContext.get(), 0, m_size.height());
+ CGContextScaleCTM(bitmapContext.get(), 1, -1);
+
+ return adoptPtr(new GraphicsContext(bitmapContext.get()));
+}
+
+void BackingStore::paint(WebCore::GraphicsContext* context, const WebCore::IntRect& clipRect)
+{
+ // FIXME: Honor the clip rect!
+ OwnPtr<GraphicsContext> sourceContext(createGraphicsContext());
+
+ // FIXME: This creates an extra copy.
+ RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(sourceContext->platformContext()));
+
+ CGContextRef cgContext = context->platformContext();
+
+ CGContextSaveGState(cgContext);
+ CGContextDrawImage(context->platformContext(), CGRectMake(0, 0, CGImageGetWidth(image.get()), CGImageGetHeight(image.get())), image.get());
+ CGContextRestoreGState(cgContext);
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 2788dd5..c845b18 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -51,6 +51,9 @@
1A043B5D124D5E9D00FFBFB5 /* PluginProcessProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A043B5B124D5E9D00FFBFB5 /* PluginProcessProxyMessageReceiver.cpp */; };
1A043B5E124D5E9D00FFBFB5 /* PluginProcessProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A043B5C124D5E9D00FFBFB5 /* PluginProcessProxyMessages.h */; };
1A043CEB124FE38F00FFBFB5 /* PluginProcessMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0EC6BD124BBD9B007EF4A5 /* PluginProcessMessageReceiver.cpp */; };
+ 1A043D7A124FEFC100FFBFB5 /* BackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A043D78124FEFC100FFBFB5 /* BackingStore.h */; };
+ 1A043D7B124FEFC100FFBFB5 /* BackingStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A043D79124FEFC100FFBFB5 /* BackingStore.cpp */; };
+ 1A043D92124FF02B00FFBFB5 /* BackingStoreMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A043D90124FF02B00FFBFB5 /* BackingStoreMac.mm */; };
1A0EC603124A9F2C007EF4A5 /* PluginProcessManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0EC601124A9F2C007EF4A5 /* PluginProcessManager.h */; };
1A0EC604124A9F2C007EF4A5 /* PluginProcessManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0EC602124A9F2C007EF4A5 /* PluginProcessManager.cpp */; };
1A0EC6C0124BBD9B007EF4A5 /* PluginProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0EC6BE124BBD9B007EF4A5 /* PluginProcessMessages.h */; };
@@ -464,6 +467,9 @@
1A043B4C124D5E3600FFBFB5 /* PluginProcessProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PluginProcessProxy.messages.in; sourceTree = "<group>"; };
1A043B5B124D5E9D00FFBFB5 /* PluginProcessProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProcessProxyMessageReceiver.cpp; sourceTree = "<group>"; };
1A043B5C124D5E9D00FFBFB5 /* PluginProcessProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProcessProxyMessages.h; sourceTree = "<group>"; };
+ 1A043D78124FEFC100FFBFB5 /* BackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BackingStore.h; sourceTree = "<group>"; };
+ 1A043D79124FEFC100FFBFB5 /* BackingStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackingStore.cpp; sourceTree = "<group>"; };
+ 1A043D90124FF02B00FFBFB5 /* BackingStoreMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BackingStoreMac.mm; sourceTree = "<group>"; };
1A0EC601124A9F2C007EF4A5 /* PluginProcessManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProcessManager.h; sourceTree = "<group>"; };
1A0EC602124A9F2C007EF4A5 /* PluginProcessManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProcessManager.cpp; sourceTree = "<group>"; };
1A0EC6B1124BBD36007EF4A5 /* PluginProcess.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PluginProcess.messages.in; sourceTree = "<group>"; };
@@ -1044,6 +1050,8 @@
BC111B5F112F635E00337BAB /* CoreIPCSupport */,
BC111B5A112F628200337BAB /* mac */,
BCF04C8C11FF9B7D00F86A58 /* APIObject.h */,
+ 1A043D79124FEFC100FFBFB5 /* BackingStore.cpp */,
+ 1A043D78124FEFC100FFBFB5 /* BackingStore.h */,
1A6F9F8E11E13EFC00DB1371 /* CommandLine.h */,
0FB659221208B4DB0044816C /* DrawingAreaBase.h */,
762B7481120BBA0100819339 /* FontSmoothingLevel.h */,
@@ -1393,6 +1401,7 @@
BC111B5A112F628200337BAB /* mac */ = {
isa = PBXGroup;
children = (
+ 1A043D90124FF02B00FFBFB5 /* BackingStoreMac.mm */,
1A6F9FB611E1408500DB1371 /* CommandLineMac.cpp */,
BCF505E61243047B005955AE /* PlatformCertificateInfo.mm */,
BCF505E51243047B005955AE /* PlatformCertificateInfo.h */,
@@ -1824,6 +1833,7 @@
1A043976124D034800FFBFB5 /* PluginProcess.h in Headers */,
1A043A09124D11A900FFBFB5 /* WebProcessConnection.h in Headers */,
1A043B5E124D5E9D00FFBFB5 /* PluginProcessProxyMessages.h in Headers */,
+ 1A043D7A124FEFC100FFBFB5 /* BackingStore.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2107,6 +2117,8 @@
C06C6095124C144B0001682F /* WebPageCreationParameters.cpp in Sources */,
1A043B5D124D5E9D00FFBFB5 /* PluginProcessProxyMessageReceiver.cpp in Sources */,
1A043CEB124FE38F00FFBFB5 /* PluginProcessMessageReceiver.cpp in Sources */,
+ 1A043D7B124FEFC100FFBFB5 /* BackingStore.cpp in Sources */,
+ 1A043D92124FF02B00FFBFB5 /* BackingStoreMac.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list