Source/WebCore/ChangeLog

 12012-09-26 Arvid Nilsson <anilsson@rim.com>
 2
 3 [BlackBerry] Destroy thread-specific data for Platform::Graphics::Buffer on the right thread
 4 https://bugs.webkit.org/show_bug.cgi?id=97674
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 A new API was added to BlackBerry::Platform::Graphics for destroying
 9 thread-specific data generated on the compositing thread when we blit
 10 buffers. The buffers are otherwise created and destroyed on the WebKit
 11 thread, which doesn't give platform any opportunity to destroy the
 12 thread-specific data.
 13
 14 This patch adds calls to the new API to avoid leaking resources.
 15
 16 Reviewed internally by Jakob Petsovits and Filip Spacek.
 17
 18 PR 214644
 19
 20 Verified using manual testing.
 21
 22 * plugins/blackberry/PluginViewPrivateBlackBerry.cpp:
 23 (WebCore::PluginViewPrivate::createBuffers):
 24 (WebCore::PluginViewPrivate::destroyBuffers):
 25
1262012-09-27 Jinwoo Song <jinwoo7.song@samsung.com>
227
328 [CMAKE] Remove unnecessary header files from CMakeLists.txt

Source/WebKit/blackberry/ChangeLog

 12012-09-26 Arvid Nilsson <anilsson@rim.com>
 2
 3 [BlackBerry] Destroy thread-specific data for Platform::Graphics::Buffer on the right thread
 4 https://bugs.webkit.org/show_bug.cgi?id=97674
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 A new API was added to BlackBerry::Platform::Graphics for destroying
 9 thread-specific data generated on the compositing thread when we blit
 10 buffers. The buffers are otherwise created and destroyed on the WebKit
 11 thread, which doesn't give platform any opportunity to destroy the
 12 thread-specific data.
 13
 14 This patch adds calls to the new API to avoid leaking resources.
 15
 16 Reviewed internally by Jakob Petsovits and Filip Spacek.
 17
 18 PR 214644
 19
 20 * WebKitSupport/SurfacePool.cpp:
 21 (BlackBerry::WebKit::SurfacePool::initialize):
 22 (BlackBerry::WebKit::SurfacePool::createPlatformGraphicsContext):
 23 (BlackBerry::WebKit::SurfacePool::lockTileRenderingSurface):
 24 (BlackBerry::WebKit::SurfacePool::releaseTileRenderingSurface):
 25 (BlackBerry::WebKit::SurfacePool::initializeVisibleTileBuffer):
 26 (BlackBerry::WebKit::SurfacePool::createBuffers):
 27 (BlackBerry::WebKit::SurfacePool::releaseBuffers):
 28
1292012-09-26 Jakob Petsovits <jpetsovits@rim.com>
230
331 [BlackBerry] Remove blitContents() in favor of blitVisibleContents().

Source/WebCore/plugins/blackberry/PluginViewPrivateBlackBerry.cpp

2525#include "PluginLayerWebKitThread.h"
2626#endif
2727#include "NPCallbacksBlackBerry.h"
 28#include <BlackBerryPlatformExecutableMessage.h>
 29#include <BlackBerryPlatformMessageClient.h>
2830#include <wtf/MainThread.h>
2931
3032static unsigned s_counter = 0;

@@bool PluginViewPrivate::createBuffers(NPSurfaceFormat format, int width, int hei
277279 PthreadMutexLocker backLock(&m_backBufferMutex);
278280 PthreadWriteLocker frontLock(&m_frontBufferRwLock);
279281
 282 bool didDestroyBuffers = false;
280283 for (int i = 0; i < PLUGIN_BUFFERS; i++) {
281284 if (m_pluginBuffers[i]) {
 285 didDestroyBuffers = true;
282286 BlackBerry::Platform::Graphics::destroyBuffer(m_pluginBuffers[i]);
283287 m_pluginBuffers[i] = 0;
284288 }

@@bool PluginViewPrivate::createBuffers(NPSurfaceFormat format, int width, int hei
298302 if (success) {
299303 m_pluginBufferSize = IntSize(width, height);
300304 m_pluginBufferType = toBufferType(format);
 305
 306 if (didDestroyBuffers) {
 307 BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
 308 BlackBerry::Platform::createFunctionCallMessage(&BlackBerry::Platform::Graphics::collectThreadSpecificGarbage));
 309 }
301310 } else {
302311 m_pluginBufferSize = IntSize();
303312 m_pluginBufferType = BlackBerry::Platform::Graphics::PluginBufferWithAlpha;

@@bool PluginViewPrivate::destroyBuffers()
358367 PthreadMutexLocker backLock(&m_backBufferMutex);
359368 PthreadWriteLocker frontLock(&m_frontBufferRwLock);
360369
 370 bool didDestroyBuffers = false;
361371 for (int i = 0; i < PLUGIN_BUFFERS; i++) {
362372 if (m_pluginBuffers[i]) {
 373 didDestroyBuffers = true;
363374 BlackBerry::Platform::Graphics::destroyBuffer(m_pluginBuffers[i]);
364375 m_pluginBuffers[i] = 0;
365376 }
366377 }
367378 m_pluginBufferSize = IntSize();
368379
 380 if (didDestroyBuffers) {
 381 BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
 382 BlackBerry::Platform::createFunctionCallMessage(&BlackBerry::Platform::Graphics::collectThreadSpecificGarbage));
 383 }
 384
369385 return true;
370386}
371387

Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp

2121
2222#include "PlatformContextSkia.h"
2323
 24#include <BlackBerryPlatformExecutableMessage.h>
2425#include <BlackBerryPlatformGraphics.h>
2526#include <BlackBerryPlatformLog.h>
 27#include <BlackBerryPlatformMessageClient.h>
2628#include <BlackBerryPlatformMisc.h>
2729#include <BlackBerryPlatformScreen.h>
2830#include <BlackBerryPlatformSettings.h>

@@SurfacePool::SurfacePool()
6264{
6365}
6466
65 void SurfacePool::initialize(const BlackBerry::Platform::IntSize& tileSize)
 67void SurfacePool::initialize(const Platform::IntSize& tileSize)
6668{
6769 if (m_initialized)
6870 return;
6971 m_initialized = true;
7072
71  const unsigned numberOfTiles = BlackBerry::Platform::Settings::instance()->numberOfBackingStoreTiles();
72  const unsigned maxNumberOfTiles = BlackBerry::Platform::Settings::instance()->maximumNumberOfBackingStoreTilesAcrossProcesses();
 73 const unsigned numberOfTiles = Platform::Settings::instance()->numberOfBackingStoreTiles();
 74 const unsigned maxNumberOfTiles = Platform::Settings::instance()->maximumNumberOfBackingStoreTilesAcrossProcesses();
7375
7476 if (numberOfTiles) { // Only allocate if we actually use a backingstore.
7577 unsigned byteLimit = (maxNumberOfTiles /*pool*/ + 2 /*visible tile buffer, backbuffer*/) * tileSize.width() * tileSize.height() * 4;
76  bool success = BlackBerry::Platform::Graphics::createPixmapGroup(SHARED_PIXMAP_GROUP, byteLimit);
 78 bool success = Platform::Graphics::createPixmapGroup(SHARED_PIXMAP_GROUP, byteLimit);
7779 if (!success) {
78  BlackBerry::Platform::log(BlackBerry::Platform::LogLevelWarn,
 80 Platform::log(Platform::LogLevelWarn,
7981 "Shared buffer pool could not be set up, using regular memory allocation instead.");
8082 }
8183 }
8284
83  m_tileRenderingSurface = BlackBerry::Platform::Graphics::drawingSurface();
 85 m_tileRenderingSurface = Platform::Graphics::drawingSurface();
8486
8587 if (!numberOfTiles)
8688 return; // we only use direct rendering when 0 tiles are specified.

@@void SurfacePool::initialize(const BlackBerry::Platform::IntSize& tileSize)
113115 pthread_mutexattr_destroy(&attr);
114116}
115117
116 PlatformGraphicsContext* SurfacePool::createPlatformGraphicsContext(BlackBerry::Platform::Graphics::Drawable* drawable) const
 118PlatformGraphicsContext* SurfacePool::createPlatformGraphicsContext(Platform::Graphics::Drawable* drawable) const
117119{
118120 return new WebCore::PlatformContextSkia(drawable);
119121}

@@PlatformGraphicsContext* SurfacePool::lockTileRenderingSurface() const
123125 if (!m_tileRenderingSurface)
124126 return 0;
125127
126  return createPlatformGraphicsContext(BlackBerry::Platform::Graphics::lockBufferDrawable(m_tileRenderingSurface));
 128 return createPlatformGraphicsContext(Platform::Graphics::lockBufferDrawable(m_tileRenderingSurface));
127129}
128130
129131void SurfacePool::releaseTileRenderingSurface(PlatformGraphicsContext* context) const

@@void SurfacePool::releaseTileRenderingSurface(PlatformGraphicsContext* context)
132134 return;
133135
134136 delete context;
135  BlackBerry::Platform::Graphics::releaseBufferDrawable(m_tileRenderingSurface);
 137 Platform::Graphics::releaseBufferDrawable(m_tileRenderingSurface);
136138}
137139
138 void SurfacePool::initializeVisibleTileBuffer(const BlackBerry::Platform::IntSize& visibleSize)
 140void SurfacePool::initializeVisibleTileBuffer(const Platform::IntSize& visibleSize)
139141{
140142 if (!m_visibleTileBuffer || m_visibleTileBuffer->size() != visibleSize) {
141143 delete m_visibleTileBuffer;

@@void SurfacePool::createBuffers()
161163
162164 // Create the tile pool.
163165 for (size_t i = 0; i < m_tilePool.size(); ++i)
164  BlackBerry::Platform::Graphics::createPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
 166 Platform::Graphics::createPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
165167
166168 if (m_visibleTileBuffer)
167  BlackBerry::Platform::Graphics::createPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
 169 Platform::Graphics::createPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
168170
169171 if (backBuffer())
170  BlackBerry::Platform::Graphics::createPixmapBuffer(backBuffer()->nativeBuffer());
 172 Platform::Graphics::createPixmapBuffer(backBuffer()->nativeBuffer());
171173
172174 m_buffersSuspended = false;
173175}

@@void SurfacePool::releaseBuffers()
183185 for (size_t i = 0; i < m_tilePool.size(); ++i) {
184186 m_tilePool[i]->frontBuffer()->clearRenderedRegion();
185187 // Clear the buffer to prevent accidental leakage of (possibly sensitive) pixel data.
186  BlackBerry::Platform::Graphics::clearBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
187  BlackBerry::Platform::Graphics::destroyPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
 188 Platform::Graphics::clearBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
 189 Platform::Graphics::destroyPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
188190 }
189191
190192 if (m_visibleTileBuffer) {
191193 m_visibleTileBuffer->frontBuffer()->clearRenderedRegion();
192  BlackBerry::Platform::Graphics::clearBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
193  BlackBerry::Platform::Graphics::destroyPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
 194 Platform::Graphics::clearBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
 195 Platform::Graphics::destroyPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
194196 }
195197
196198 if (backBuffer()) {
197199 backBuffer()->clearRenderedRegion();
198  BlackBerry::Platform::Graphics::clearBuffer(backBuffer()->nativeBuffer(), 0, 0, 0, 0);
199  BlackBerry::Platform::Graphics::destroyPixmapBuffer(backBuffer()->nativeBuffer());
 200 Platform::Graphics::clearBuffer(backBuffer()->nativeBuffer(), 0, 0, 0, 0);
 201 Platform::Graphics::destroyPixmapBuffer(backBuffer()->nativeBuffer());
200202 }
 203
 204 Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
 205 Platform::createFunctionCallMessage(&Platform::Graphics::collectThreadSpecificGarbage));
201206}
202207
203208void SurfacePool::waitForBuffer(TileBuffer* tileBuffer)