Update tile partially
authorEunsol Park <eunsol47.park@samsung.com>
Tue, 2 Apr 2013 04:21:11 +0000 (13:21 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 12 Apr 2013 05:04:03 +0000 (14:04 +0900)
[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

Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.cpp
Source/WebKit2/WebProcess/WebPage/efl/tizen/PlatformSurfacePoolTizen.h
Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.cpp
Source/WebKit2/WebProcess/WebPage/efl/tizen/TiledBackingStoreRemoteTileTizen.h

index 7051b51..c6ce2a4 100644 (file)
@@ -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;
index 2d37190..b5ba35e 100644 (file)
@@ -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);
index 27fcb5f..2f40b2c 100644 (file)
@@ -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<IntRect> TiledBackingStoreRemoteTileTizen::updateBackBuffer()
 {
     if (!isDirty())
@@ -63,7 +70,7 @@ Vector<IntRect> 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<IntRect>();
 
     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();
index c039949..bedbd49 100644 (file)
@@ -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<TiledBackingStoreRemoteTileBufferTizen> m_tiledBackingStoreRemoteTileBufferTizen;
 };