Replaced handling row data with cairoAPI while copying dirty area
authorEunsol Park <eunsol47.park@samsung.com>
Thu, 2 May 2013 12:10:31 +0000 (21:10 +0900)
committerGerrit Code Review <gerrit2@kim11>
Fri, 3 May 2013 01:54:07 +0000 (10:54 +0900)
[Title] Replaced handling row data with cairoAPI while copying dirty areas
[Issue#] P130429-4677
[Problem] Crash once when copying dirty area
[Cause] The dirty area buffer was allocated by malloc, some part of that was broken.
[Solution] The buffer was used by cairo API, not allocated singly,
          because cairo API is safer to handle buffers.

Change-Id: I4b3f6c1064d24e352485990d75c8bd19bde0021e

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

index c87bffd..fa2578d 100644 (file)
@@ -118,19 +118,6 @@ void TiledBackingStoreRemoteTileTizen::review()
     m_client->createTile(m_ID, updateInfo, m_rect);
 }
 
-void TiledBackingStoreRemoteTileBufferTizen::copyDirtyRect(unsigned char* dst, unsigned char* src, const IntRect& wholeRect, const IntRect& dirtyRect)
-{
-    unsigned int offset = 4 * wholeRect.width() * (dirtyRect.y() - wholeRect.y()) + 4 * (dirtyRect.x() - wholeRect.x());
-
-    //FIXME : Now, handling row datas directly performs better than using Cairo APIs.
-    //This will be replaced to Cairo APIs if using Cairo APIs perform better.
-
-    for (int i = 0; i < dirtyRect.height(); i++) {
-        memcpy(dst + offset, src + (4 * i * dirtyRect.width()), 4 * dirtyRect.width());
-        offset += 4* wholeRect.width();
-    }
-}
-
 bool TiledBackingStoreRemoteTileBufferTizen::copyPreviousFrame(unsigned char* dst, int platformSurfaceID, const IntRect& wholeRect, const IntRect& clipRect)
 {
     SharedPlatformSurfaceTizen* backupSurface;
@@ -199,7 +186,6 @@ bool TiledBackingStoreRemoteTileBufferTizen::drawPlatformSurface(const IntSize&
     }
 
     unsigned char* dstBuffer;
-    unsigned char* dirtyBuffer;
     RefPtr<cairo_surface_t> dstSurface, dirtySurface;
     RefPtr<cairo_t> dstBitmapContext, dirtyBitmapContext;
     OwnPtr<WebCore::GraphicsContext> graphicsContext;
@@ -222,8 +208,7 @@ bool TiledBackingStoreRemoteTileBufferTizen::drawPlatformSurface(const IntSize&
     }
 
     if (canPartiallyUpdate) {
-        dirtyBuffer = (unsigned char*) malloc(4 * dirtyRect.width() * dirtyRect.height());
-        dirtySurface = adoptRef(cairo_image_surface_create_for_data(dirtyBuffer, CAIRO_FORMAT_ARGB32, dirtyRect.width(), dirtyRect.height(), 4 * dirtyRect.width()));
+        dirtySurface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dirtyRect.width(), dirtyRect.height()));
         dirtyBitmapContext = adoptRef(cairo_create(dirtySurface.get()));
         graphicsContext = adoptPtr(new GraphicsContext(dirtyBitmapContext.get()));
         graphicsContext->clearRect(WebCore::FloatRect(WebCore::FloatPoint(0, 0), dirtyRect.size()));
@@ -247,9 +232,10 @@ bool TiledBackingStoreRemoteTileBufferTizen::drawPlatformSurface(const IntSize&
     m_tiledBackingStore->client()->tiledBackingStorePaint(graphicsContext.get(), m_tiledBackingStore->mapToContents(paintRect));
 
     if (canPartiallyUpdate) {
-        copyDirtyRect(dstBuffer, dirtyBuffer, IntRect(m_rect.location(), sharedPlatformSurface->size()), dirtyRect);
         dstBitmapContext = adoptRef(cairo_create(dstSurface.get()));
-        free(dirtyBuffer);
+        cairo_set_source_surface(dstBitmapContext.get(), dirtySurface.get(), dirtyRect.x() - m_rect.x(), dirtyRect.y() - m_rect.y());
+        cairo_rectangle(dstBitmapContext.get(), dirtyRect.x() - m_rect.x(), dirtyRect.y() - m_rect.y(), dirtyRect.width(), dirtyRect.height());
+        cairo_fill(dstBitmapContext.get());
         dirtySurface.release();
         dirtyBitmapContext.release();
     }
index 62c4652..8b19b3a 100644 (file)
@@ -48,7 +48,6 @@ public:
     void resize(const WebCore::IntSize& size) { m_rect.setSize(size); }
     IntSize platformSurfaceSize() { return m_platformSurfaceSize; }
 private:
-    void copyDirtyRect(unsigned char* dst, unsigned char* src, const IntRect& wholeRect, const IntRect& dirtyRect);
     bool copyPreviousFrame(unsigned char* dst, int platformSurfaceID, const IntRect& wholeRect, const IntRect& clipRect);
     int m_platformSurfaceID;
     IntSize m_platformSurfaceSize;