[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
andreas.kling at nokia.com
andreas.kling at nokia.com
Wed Dec 22 15:29:01 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 98cdfcd3fce7670020a6377dd4bf5035087a0b08
Author: andreas.kling at nokia.com <andreas.kling at nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Nov 4 17:25:03 2010 +0000
2010-11-04 Balazs Kelemen <kbalazs at webkit.org>
Reviewed by Andreas Kling.
[Qt][WK2] Cleanup UpdateChunk and MappedMemoryPool
https://bugs.webkit.org/show_bug.cgi?id=48994
* Platform/qt/MappedMemoryPool.cpp:
(WebKit::MappedMemoryPool::mapMemory):
Removed argument with default value that was always
used with the default value.
(WebKit::MappedMemoryPool::mapFile): Ditto and
add some asserts.
* Platform/qt/MappedMemoryPool.h:
Encapsulating MappedMemory and remove the unused
MappedMemoryPool::searchForMappedMemory method.
(WebKit::MappedMemory::mappedFile):
(WebKit::MappedMemory::markFree):
(WebKit::MappedMemory::data):
(WebKit::MappedMemory::MappedMemory):
(WebKit::MappedMemory::markUsed):
(WebKit::MappedMemory::mapSize):
(WebKit::MappedMemory::isFree):
(WebKit::MappedMemoryPool::instance):
* Shared/qt/UpdateChunk.cpp:
Removed the unused data method besides other cleanups.
(WebKit::UpdateChunk::UpdateChunk):
(WebKit::UpdateChunk::encode):
(WebKit::UpdateChunk::decode):
(WebKit::UpdateChunk::createImage):
* Shared/qt/UpdateChunk.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71344 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 619f9a9..30a94d4 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,35 @@
+2010-11-04 Balazs Kelemen <kbalazs at webkit.org>
+
+ Reviewed by Andreas Kling.
+
+ [Qt][WK2] Cleanup UpdateChunk and MappedMemoryPool
+ https://bugs.webkit.org/show_bug.cgi?id=48994
+
+ * Platform/qt/MappedMemoryPool.cpp:
+ (WebKit::MappedMemoryPool::mapMemory):
+ Removed argument with default value that was always
+ used with the default value.
+ (WebKit::MappedMemoryPool::mapFile): Ditto and
+ add some asserts.
+ * Platform/qt/MappedMemoryPool.h:
+ Encapsulating MappedMemory and remove the unused
+ MappedMemoryPool::searchForMappedMemory method.
+ (WebKit::MappedMemory::mappedFile):
+ (WebKit::MappedMemory::markFree):
+ (WebKit::MappedMemory::data):
+ (WebKit::MappedMemory::MappedMemory):
+ (WebKit::MappedMemory::markUsed):
+ (WebKit::MappedMemory::mapSize):
+ (WebKit::MappedMemory::isFree):
+ (WebKit::MappedMemoryPool::instance):
+ * Shared/qt/UpdateChunk.cpp:
+ Removed the unused data method besides other cleanups.
+ (WebKit::UpdateChunk::UpdateChunk):
+ (WebKit::UpdateChunk::encode):
+ (WebKit::UpdateChunk::decode):
+ (WebKit::UpdateChunk::createImage):
+ * Shared/qt/UpdateChunk.h:
+
2010-11-04 Andreas Kling <kling at webkit.org>
Reviewed by Tor Arne Vestbø.
diff --git a/WebKit2/Platform/qt/MappedMemoryPool.cpp b/WebKit2/Platform/qt/MappedMemoryPool.cpp
index a59aea0..641312c 100644
--- a/WebKit2/Platform/qt/MappedMemoryPool.cpp
+++ b/WebKit2/Platform/qt/MappedMemoryPool.cpp
@@ -34,23 +34,7 @@
namespace WebKit {
-MappedMemoryPool* MappedMemoryPool::instance()
-{
- DEFINE_STATIC_LOCAL(MappedMemoryPool, singleton, ());
- return &singleton;
-}
-
-MappedMemory* MappedMemoryPool::searchForMappedMemory(uchar* p)
-{
- for (unsigned n = 0; n < m_pool.size(); ++n) {
- MappedMemory& current = m_pool.at(n);
- if (current.data() == p)
- return reinterpret_cast<MappedMemory*>(¤t);
- }
- return 0;
-}
-
-MappedMemory* MappedMemoryPool::mapMemory(size_t size, QIODevice::OpenMode openMode)
+MappedMemory* MappedMemoryPool::mapMemory(size_t size)
{
for (unsigned n = 0; n < m_pool.size(); ++n) {
MappedMemory& current = m_pool.at(n);
@@ -59,10 +43,11 @@ MappedMemory* MappedMemoryPool::mapMemory(size_t size, QIODevice::OpenMode openM
return ¤t;
}
}
+
MappedMemory newMap;
newMap.dataSize = size;
newMap.file = new QTemporaryFile(QDir::tempPath() + "/WebKit2UpdateChunk");
- newMap.file->open(openMode);
+ newMap.file->open(QIODevice::ReadWrite);
newMap.file->resize(newMap.mapSize());
newMap.mappedBytes = newMap.file->map(0, newMap.mapSize());
newMap.file->close();
@@ -71,7 +56,7 @@ MappedMemory* MappedMemoryPool::mapMemory(size_t size, QIODevice::OpenMode openM
return &m_pool.last();
}
-MappedMemory* MappedMemoryPool::mapFile(QString fileName, size_t size, QIODevice::OpenMode openMode)
+MappedMemory* MappedMemoryPool::mapFile(QString fileName, size_t size)
{
for (unsigned n = 0; n < m_pool.size(); ++n) {
MappedMemory& current = m_pool.at(n);
@@ -80,12 +65,15 @@ MappedMemory* MappedMemoryPool::mapFile(QString fileName, size_t size, QIODevice
return ¤t;
}
}
+
MappedMemory newMap;
newMap.file = new QFile(fileName);
- if (!newMap.file->open(openMode))
- return 0;
newMap.dataSize = size;
+ ASSERT(newMap.file->exists());
+ ASSERT(newMap.file->size() == newMap.mapSize());
+ newMap.file->open(QIODevice::ReadWrite);
newMap.mappedBytes = newMap.file->map(0, newMap.mapSize());
+ ASSERT(newMap.mappedBytes);
ASSERT(!newMap.isFree());
newMap.file->close();
newMap.file->remove(); // The map stays alive even when the file is unlinked.
diff --git a/WebKit2/Platform/qt/MappedMemoryPool.h b/WebKit2/Platform/qt/MappedMemoryPool.h
index 14ca594..530e7d0 100644
--- a/WebKit2/Platform/qt/MappedMemoryPool.h
+++ b/WebKit2/Platform/qt/MappedMemoryPool.h
@@ -29,36 +29,70 @@
#define MappedMemoryPool_h
#include <QFile>
+#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
namespace WebKit {
+class MappedMemoryPool;
+
+struct MappedMemory {
+
+ QFile* mappedFile() const
+ {
+ return file;
+ }
+
+ void markFree()
+ {
+ ASSERT(mappedBytes);
+ dataPtr->isFree = true;
+ }
+
+ uchar* data() const
+ {
+ ASSERT(mappedBytes);
+ return dataPtr->bytes;
+ }
+
+private:
+ friend class MappedMemoryPool;
+
+ MappedMemory()
+ : file(0)
+ , mappedBytes(0)
+ , dataSize(0)
+ {
+ }
+
+ void markUsed() { dataPtr->isFree = false; }
+
+ size_t mapSize() const { return dataSize + sizeof(Data); }
+ bool isFree() const { return dataPtr->isFree; }
+
+ struct Data {
+ uint32_t isFree; // keep bytes aligned
+ uchar bytes[];
+ };
+
+ QFile* file;
+ union {
+ uchar* mappedBytes;
+ Data* dataPtr;
+ };
+ size_t dataSize;
+};
+
class MappedMemoryPool {
public:
- static MappedMemoryPool* instance();
-
- struct MappedMemory {
- QFile* file;
- struct Data {
- uint32_t isFree; // keep bytes aligned
- uchar bytes;
- };
- union {
- uchar* mappedBytes;
- Data* dataPtr;
- };
- size_t dataSize;
-
- size_t mapSize() const { return dataSize + sizeof(Data); }
- void markUsed() { dataPtr->isFree = false; }
- void markFree() { dataPtr->isFree = true; }
- bool isFree() const { return dataPtr->isFree; }
- uchar* data() const { return &dataPtr->bytes; }
- };
+ static MappedMemoryPool* instance()
+ {
+ DEFINE_STATIC_LOCAL(MappedMemoryPool, singleton, ());
+ return &singleton;
+ }
- MappedMemory* mapMemory(size_t size, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
- MappedMemory* mapFile(QString fileName, size_t size, QIODevice::OpenMode openMode = QIODevice::ReadWrite);
- MappedMemory* searchForMappedMemory(uchar* p);
+ MappedMemory* mapMemory(size_t size);
+ MappedMemory* mapFile(QString fileName, size_t size);
private:
MappedMemoryPool() { };
@@ -66,8 +100,6 @@ private:
Vector<MappedMemory> m_pool;
};
-typedef MappedMemoryPool::MappedMemory MappedMemory;
-
} // namespace WebKit
#endif // MappedMemoryPool_h
diff --git a/WebKit2/Shared/qt/UpdateChunk.cpp b/WebKit2/Shared/qt/UpdateChunk.cpp
index 3d2ce31..60e5643 100644
--- a/WebKit2/Shared/qt/UpdateChunk.cpp
+++ b/WebKit2/Shared/qt/UpdateChunk.cpp
@@ -29,6 +29,7 @@
#include "ArgumentDecoder.h"
#include "ArgumentEncoder.h"
+#include "MappedMemoryPool.h"
#include "WebCoreArgumentCoders.h"
#include <QIODevice>
#include <QImage>
@@ -40,7 +41,6 @@ using namespace std;
namespace WebKit {
-static MappedMemoryPool* mappedMemoryPool = MappedMemoryPool::instance();
UpdateChunk::UpdateChunk()
: m_mappedMemory(0)
@@ -49,7 +49,7 @@ UpdateChunk::UpdateChunk()
UpdateChunk::UpdateChunk(const IntRect& rect)
: m_rect(rect)
- , m_mappedMemory(mappedMemoryPool->mapMemory(size()))
+ , m_mappedMemory(MappedMemoryPool::instance()->mapMemory(size()))
{
}
@@ -59,40 +59,38 @@ UpdateChunk::~UpdateChunk()
m_mappedMemory->markFree();
}
-uint8_t* UpdateChunk::data()
-{
- ASSERT(m_mappedMemory);
- ASSERT(m_mappedMemory->mappedBytes);
- return reinterpret_cast<uint8_t*>(m_mappedMemory->data());
-}
-
void UpdateChunk::encode(CoreIPC::ArgumentEncoder* encoder) const
{
encoder->encode(m_rect);
- encoder->encode(String(m_mappedMemory->file->fileName()));
+ encoder->encode(String(m_mappedMemory->mappedFile()->fileName()));
m_mappedMemory = 0;
}
bool UpdateChunk::decode(CoreIPC::ArgumentDecoder* decoder, UpdateChunk& chunk)
{
+ ASSERT_ARG(chunk, chunk.isEmpty());
+
IntRect rect;
if (!decoder->decode(rect))
return false;
chunk.m_rect = rect;
+ if (chunk.isEmpty())
+ return true; // Successfully decoded empty chunk.
+
String fileName;
if (!decoder->decode(fileName))
return false;
- chunk.m_mappedMemory = mappedMemoryPool->mapFile(fileName, chunk.size());
-
- return chunk.m_mappedMemory->mappedBytes;
+ chunk.m_mappedMemory = MappedMemoryPool::instance()->mapFile(fileName, chunk.size());
+ return true;
}
-QImage UpdateChunk::createImage()
+QImage UpdateChunk::createImage() const
{
- return QImage(data(), m_rect.width(), m_rect.height(), m_rect.width() * 4, QImage::Format_RGB32);
+ ASSERT(m_mappedMemory);
+ return QImage(m_mappedMemory->data(), m_rect.width(), m_rect.height(), m_rect.width() * 4, QImage::Format_RGB32);
}
} // namespace WebKit
diff --git a/WebKit2/Shared/qt/UpdateChunk.h b/WebKit2/Shared/qt/UpdateChunk.h
index bd8a7fa..bdfd9c1 100644
--- a/WebKit2/Shared/qt/UpdateChunk.h
+++ b/WebKit2/Shared/qt/UpdateChunk.h
@@ -27,7 +27,6 @@
#ifndef UpdateChunk_h
#define UpdateChunk_h
-#include "MappedMemoryPool.h"
#include <QImage>
#include <WebCore/IntRect.h>
@@ -38,21 +37,22 @@ class ArgumentDecoder;
namespace WebKit {
+class MappedMemory;
+
class UpdateChunk {
public:
UpdateChunk();
UpdateChunk(const WebCore::IntRect&);
~UpdateChunk();
- uint8_t* data();
const WebCore::IntRect& rect() const { return m_rect; }
bool isEmpty() const { return m_rect.isEmpty(); }
void encode(CoreIPC::ArgumentEncoder*) const;
static bool decode(CoreIPC::ArgumentDecoder*, UpdateChunk&);
-
- QImage createImage();
-
+
+ QImage createImage() const;
+
private:
size_t size() const { return m_rect.width() * 4 * m_rect.height(); }
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list