From 2f997258449b738de6096d8749c1acfd32f90260 Mon Sep 17 00:00:00 2001 From: Eunsol Park Date: Tue, 2 Apr 2013 13:21:11 +0900 Subject: [PATCH] Update tile partially [Title] update tile partially [Issue#] N/A [Problem] BrowserMark2 CSS 2D Transform test result is behind competitors. [Cause] Painting takes too long due to whole tile update. [Solution] Copy painted tile to empty tile and paint only dirty area. Change-Id: I7874ba77adc2a0bdec13c49487ec816aef9d0a19 --- .../WebPage/efl/tizen/PlatformSurfacePoolTizen.cpp | 8 +++ .../WebPage/efl/tizen/PlatformSurfacePoolTizen.h | 1 + .../efl/tizen/TiledBackingStoreRemoteTileTizen.cpp | 70 +++++++++++++++++++++- .../efl/tizen/TiledBackingStoreRemoteTileTizen.h | 2 +- 4 files changed, 77 insertions(+), 4 deletions(-) diff --git a/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.cpp b/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.cpp index 7051b51..c6ce2a4 100644 --- a/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.cpp @@ -132,6 +132,14 @@ SharedPlatformSurfaceTizen* PlatformSurfacePoolTizen::acquirePlatformSurface(con return 0; } +SharedPlatformSurfaceTizen* PlatformSurfacePoolTizen::acquirePlatformSurfaceByID(int platformSurfaceId) +{ + PlatformSurfaceMap::iterator foundSurface = m_platformSurfaces.find(platformSurfaceId); + if (foundSurface == m_platformSurfaces.end()) + return 0; + return foundSurface->second->m_SharedPlatformSurfaceTizen.get(); +} + void PlatformSurfacePoolTizen::freePlatformSurfaceByTileID(int tileID) { int platformSurfaceId = 0; diff --git a/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.h b/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.h index 2d37190..b5ba35e 100644 --- a/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.h +++ b/Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.h @@ -50,6 +50,7 @@ public : PlatformSurfacePoolTizen(); ~PlatformSurfacePoolTizen(); SharedPlatformSurfaceTizen* acquirePlatformSurface(const WebCore::IntSize&, int tileID); + SharedPlatformSurfaceTizen* acquirePlatformSurfaceByID(int platformSurfaceId); void freePlatformSurface(int platformSurfaceId); void freePlatformSurfaceByTileID(int tileID); void removePlatformSurface(int platformSurfaceId); diff --git a/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.cpp b/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.cpp index 27fcb5f..2f40b2c 100644 --- a/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.cpp +++ b/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.cpp @@ -49,6 +49,13 @@ TiledBackingStoreRemoteTileTizen::TiledBackingStoreRemoteTileTizen(TiledBackingS { } +static inline bool needUpdateBackBufferPartially(const IntRect& entireRect, const IntRect& dirtyRect) +{ + if (entireRect.size() != dirtyRect.size()) + return true; + return false; +} + Vector TiledBackingStoreRemoteTileTizen::updateBackBuffer() { if (!isDirty()) @@ -63,7 +70,7 @@ Vector TiledBackingStoreRemoteTileTizen::updateBackBuffer() needToCreateTile = true; } - if (!m_tiledBackingStoreRemoteTileBufferTizen->drawPlatformSurface(m_tiledBackingStore->tileSize(), m_rect, m_ID)) + if (!m_tiledBackingStoreRemoteTileBufferTizen->drawPlatformSurface(m_tiledBackingStore->tileSize(), m_dirtyRect, m_ID)) return Vector(); updateInfo.updateRect = m_rect; @@ -105,7 +112,58 @@ void TiledBackingStoreRemoteTileTizen::review() m_client->createTile(m_ID, updateInfo, m_rect); } -bool TiledBackingStoreRemoteTileBufferTizen::drawPlatformSurface(const IntSize& size, const IntRect& dirty, int tileID) +bool TiledBackingStoreRemoteTileBufferTizen::copyPreviousFrame(void* dst, int platformSurfaceID, const IntRect& wholeRect, const IntRect& clipRect) +{ + SharedPlatformSurfaceTizen* backupSurface; + unsigned int offset; + void* src; + + PlatformSurfacePoolTizen* platformSurfacePool = WebProcess::shared().platformSurfacePool(); + if(!platformSurfacePool) + return false; + + backupSurface = platformSurfacePool->acquirePlatformSurfaceByID(platformSurfaceID); + if (!backupSurface) + return false; + + if (!backupSurface->lockSurface()) + return false; + + if (!backupSurface->querySurface((int*)&src)) { + backupSurface->unlockSurface(); + return false; + } + + // upper side + if (clipRect.y() -wholeRect.y() > 0) + memcpy(dst, src, 4 * wholeRect.width() * (clipRect.y() -wholeRect.y())); + + if (wholeRect.width() - clipRect.width() > 0) { + offset = 4 * (clipRect.y() - wholeRect.y()) * wholeRect.width(); + for (int i = 0; i < clipRect.height(); i++) { + // left side + if (clipRect.x() - wholeRect.x() > 0) + memcpy(dst + offset, src + offset, 4 * (clipRect.x() - wholeRect.x())); + + // right side + if (wholeRect.x() + wholeRect.width() - clipRect.x() - clipRect.width() > 0) + memcpy(dst + offset + 4 * (clipRect.x() + clipRect.width() - wholeRect.x()), + src + offset + 4 * (clipRect.x() + clipRect.width() - wholeRect.x()), + 4 * (wholeRect.x() + wholeRect.width() - clipRect.x() - clipRect.width())); + offset += 4 * wholeRect.width(); + } + } + // lower side + if (wholeRect.y() + wholeRect.height() - clipRect.y() - clipRect.height() > 0) { + offset = 4 * wholeRect.width() * (clipRect.y() + clipRect.height() - wholeRect.y()); + memcpy(dst + offset, src + offset, + 4 * wholeRect.width() * (wholeRect.y() + wholeRect.height() - clipRect.y() - clipRect.height())); + } + backupSurface->unlockSurface(); + return true; +} + +bool TiledBackingStoreRemoteTileBufferTizen::drawPlatformSurface(const IntSize& size, const IntRect& dirtyRect, int tileID) { PlatformSurfacePoolTizen* platformSurfacePool = WebProcess::shared().platformSurfacePool(); if(!platformSurfacePool) @@ -139,6 +197,12 @@ bool TiledBackingStoreRemoteTileBufferTizen::drawPlatformSurface(const IntSize& #endif graphicsContext->clearRect(WebCore::FloatRect(WebCore::FloatPoint(0, 0), sharedPlatformSurface->size())); + IntRect paintRect = m_rect; + if (needUpdateBackBufferPartially(m_rect, dirtyRect) && m_platformSurfaceID > 0) { + if (copyPreviousFrame(m_eglImgData, m_platformSurfaceID, IntRect(m_rect.location(), sharedPlatformSurface->size()), dirtyRect)) + paintRect = dirtyRect; + } + #if ENABLE(TIZEN_RECORDING_SURFACE_SET) if (m_tiledBackingStore->client()->recordingSurfaceSetEnableGet()) { m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_rect); @@ -147,7 +211,7 @@ bool TiledBackingStoreRemoteTileBufferTizen::drawPlatformSurface(const IntSize& { graphicsContext->translate(-m_rect.x(), -m_rect.y()); graphicsContext->scale(FloatSize(m_tiledBackingStore->contentsScale(), m_tiledBackingStore->contentsScale())); - m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(dirty)); + m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(paintRect)); } m_platformSurfaceID = sharedPlatformSurface->id(); diff --git a/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.h b/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.h index c039949..bedbd49 100644 --- a/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.h +++ b/Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.h @@ -49,6 +49,7 @@ public: void resize(const WebCore::IntSize& size) { m_rect.setSize(size); } IntSize platformSurfaceSize() { return m_platformSurfaceSize; } private: + bool copyPreviousFrame(void* dst, int platformSurfaceID, const IntRect& wholeRect, const IntRect& clipRect); int m_platformSurfaceID; IntSize m_platformSurfaceSize; unsigned char* m_eglImgData; @@ -72,7 +73,6 @@ public: private: TiledBackingStoreRemoteTileTizen(TiledBackingStoreRemoteTileClient*, WebCore::TiledBackingStore*, const Coordinate&); - OwnPtr m_tiledBackingStoreRemoteTileBufferTizen; }; -- 2.7.4