[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
andersca at apple.com
andersca at apple.com
Wed Dec 22 17:59:24 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit d69bdc9090b89603e2e0bfa8ef20e0fa40ae4b4b
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Dec 4 00:04:49 2010 +0000
Clean up the BackingStore implementation
https://bugs.webkit.org/show_bug.cgi?id=50498
Reviewed by Sam Weinig and Dan Bernstein.
* Shared/BackingStore.cpp:
(WebKit::BackingStore::create):
(WebKit::BackingStore::createSharable):
(WebKit::BackingStore::resize):
Use new numBytesForSize helper function.
(WebKit::BackingStore::createFlippedGraphicsContext):
Make this function platform independent.
* Shared/BackingStore.h:
(WebKit::BackingStore::numBytesForSize):
Given a size, return the number of bytes needed for it.
(WebKit::BackingStore::sizeInBytes):
Implement.
* Shared/cg/BackingStoreCG.cpp:
(WebKit::BackingStore::paint):
Don't use CGBitmapContextCreateImage; it creates an extra copy of the image data.
* Shared/qt/BackingStoreQt.cpp:
Remove createFlippedGraphicsContext.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73318 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index e86e1f2..787a56f 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,33 @@
+2010-12-03 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig and Dan Bernstein.
+
+ Clean up the BackingStore implementation
+ https://bugs.webkit.org/show_bug.cgi?id=50498
+
+ * Shared/BackingStore.cpp:
+ (WebKit::BackingStore::create):
+ (WebKit::BackingStore::createSharable):
+ (WebKit::BackingStore::resize):
+ Use new numBytesForSize helper function.
+
+ (WebKit::BackingStore::createFlippedGraphicsContext):
+ Make this function platform independent.
+
+ * Shared/BackingStore.h:
+ (WebKit::BackingStore::numBytesForSize):
+ Given a size, return the number of bytes needed for it.
+
+ (WebKit::BackingStore::sizeInBytes):
+ Implement.
+
+ * Shared/cg/BackingStoreCG.cpp:
+ (WebKit::BackingStore::paint):
+ Don't use CGBitmapContextCreateImage; it creates an extra copy of the image data.
+
+ * Shared/qt/BackingStoreQt.cpp:
+ Remove createFlippedGraphicsContext.
+
2010-12-03 Siddharth Mathur <siddharth.mathur at nokia.com>
Reviewed by Laszlo Gombos.
diff --git a/WebKit2/Shared/BackingStore.cpp b/WebKit2/Shared/BackingStore.cpp
index 7c95758..f64c0a7 100644
--- a/WebKit2/Shared/BackingStore.cpp
+++ b/WebKit2/Shared/BackingStore.cpp
@@ -26,6 +26,7 @@
#include "BackingStore.h"
#include "SharedMemory.h"
+#include <WebCore/GraphicsContext.h>
using namespace WebCore;
@@ -33,7 +34,7 @@ namespace WebKit {
PassRefPtr<BackingStore> BackingStore::create(const WebCore::IntSize& size)
{
- size_t numBytes = size.width() * size.height() * 4;
+ size_t numBytes = numBytesForSize(size);
void* data = 0;
if (!tryFastMalloc(numBytes).getValue(data))
@@ -44,7 +45,7 @@ PassRefPtr<BackingStore> BackingStore::create(const WebCore::IntSize& size)
PassRefPtr<BackingStore> BackingStore::createSharable(const IntSize& size)
{
- size_t numBytes = size.width() * size.height() * 4;
+ size_t numBytes = numBytesForSize(size);
RefPtr<SharedMemory> sharedMemory = SharedMemory::create(numBytes);
if (!sharedMemory)
@@ -60,7 +61,7 @@ PassRefPtr<BackingStore> BackingStore::create(const WebCore::IntSize& size, cons
if (!sharedMemory)
return 0;
- size_t numBytes = size.width() * size.height() * 4;
+ size_t numBytes = numBytesForSize(size);
ASSERT_UNUSED(numBytes, sharedMemory->size() >= numBytes);
return adoptRef(new BackingStore(size, sharedMemory));
@@ -100,7 +101,7 @@ bool BackingStore::resize(const IntSize& size)
if (size == m_size)
return true;
- size_t newNumBytes = size.width() * size.height() * 4;
+ size_t newNumBytes = numBytesForSize(size);
// Try to resize.
char* newData = 0;
@@ -124,4 +125,15 @@ void* BackingStore::data() const
return m_data;
}
+PassOwnPtr<GraphicsContext> BackingStore::createFlippedGraphicsContext()
+{
+ OwnPtr<GraphicsContext> graphicsContext = createGraphicsContext();
+
+ // Flip the coordinate system.
+ graphicsContext->translate(0, m_size.height());
+ graphicsContext->scale(FloatSize(1, -1));
+
+ return graphicsContext.release();
+}
+
} // namespace WebKit
diff --git a/WebKit2/Shared/BackingStore.h b/WebKit2/Shared/BackingStore.h
index 435cfd3..ee90d3a 100644
--- a/WebKit2/Shared/BackingStore.h
+++ b/WebKit2/Shared/BackingStore.h
@@ -72,7 +72,10 @@ private:
BackingStore(const WebCore::IntSize&, PassRefPtr<SharedMemory>);
bool isBackedBySharedMemory() const { return m_sharedMemory; }
+ static size_t numBytesForSize(const WebCore::IntSize& size) { return size.width() * size.height() * 4; }
+
void* data() const;
+ size_t sizeInBytes() const { return numBytesForSize(m_size); }
WebCore::IntSize m_size;
diff --git a/WebKit2/Shared/cg/BackingStoreCG.cpp b/WebKit2/Shared/cg/BackingStoreCG.cpp
index d56302b..97c6a00 100644
--- a/WebKit2/Shared/cg/BackingStoreCG.cpp
+++ b/WebKit2/Shared/cg/BackingStoreCG.cpp
@@ -45,21 +45,21 @@ PassOwnPtr<GraphicsContext> BackingStore::createGraphicsContext()
return adoptPtr(new GraphicsContext(bitmapContext.get()));
}
-PassOwnPtr<GraphicsContext> BackingStore::createFlippedGraphicsContext()
-{
- 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));
-
- return adoptPtr(new GraphicsContext(bitmapContext.get()));
-}
-
void BackingStore::paint(WebCore::GraphicsContext& context, const WebCore::IntPoint& dstPoint, const WebCore::IntRect& srcRect)
{
OwnPtr<GraphicsContext> sourceContext(createGraphicsContext());
- // FIXME: This creates an extra copy.
- RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(sourceContext->platformContext()));
+ CGContextRef sourceCGContext = sourceContext->platformContext();
+
+ RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithData(0, data(), sizeInBytes(), 0));
+ RetainPtr<CGImageRef> image(AdoptCF, CGImageCreate(CGBitmapContextGetWidth(sourceCGContext),
+ CGBitmapContextGetHeight(sourceCGContext),
+ CGBitmapContextGetBitsPerComponent(sourceCGContext),
+ CGBitmapContextGetBitsPerPixel(sourceCGContext),
+ CGBitmapContextGetBytesPerRow(sourceCGContext),
+ CGBitmapContextGetColorSpace(sourceCGContext),
+ CGBitmapContextGetBitmapInfo(sourceCGContext),
+ dataProvider.get(), 0, false, kCGRenderingIntentDefault));
CGContextRef cgContext = context.platformContext();
diff --git a/WebKit2/Shared/qt/BackingStoreQt.cpp b/WebKit2/Shared/qt/BackingStoreQt.cpp
index afec4f2..b2f766c 100644
--- a/WebKit2/Shared/qt/BackingStoreQt.cpp
+++ b/WebKit2/Shared/qt/BackingStoreQt.cpp
@@ -46,13 +46,6 @@ PassOwnPtr<GraphicsContext> BackingStore::createGraphicsContext()
return context;
}
-PassOwnPtr<GraphicsContext> BackingStore::createFlippedGraphicsContext()
-{
- // This is CG specific so we should not use it.
- ASSERT_NOT_REACHED();
- return 0;
-}
-
void BackingStore::paint(GraphicsContext& context, const IntPoint& dstPoint, const IntRect& srcRect)
{
QImage image = createQImage(data(), m_size.width(), m_size.height());
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list