[chromium] Minimize memcpy for encoded image data in ImageFrameGenerator
authorhclam@chromium.org <hclam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 21:29:25 +0000 (21:29 +0000)
committerhclam@chromium.org <hclam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2012 21:29:25 +0000 (21:29 +0000)
commitf010a89cdba30b708792b6b7273ca79ce847b7bb
treea5f3646eba08c4250bff13138a4101563ae6a108
parent7ee56019d54e6b74b68aa2654a80131aada2a27f
[chromium] Minimize memcpy for encoded image data in ImageFrameGenerator
https://bugs.webkit.org/show_bug.cgi?id=103797

Reviewed by Stephen White.

Source/WebCore:

Added a new class ThreadSafeDataTransport to help transporting data in
SharedBuffer from one thread to another. This class is designed to minimize
thread contention and memory copy.

It is implemented using a data queue. New data segments are copied into
this queue. The queue is then consolidated with existing data when user
requests access to the final SharedBuffer.

Memory is copied into and out of the queue but this approach avoid
copying the entire SharedBuffer.

ImageFrameGenerator is now using this class for data transport between
threads.

Unit tests in ThreadSafeDataTransportTest. Also existing ImageFrameGeneratorTest passes.

* WebCore.gypi:
* platform/graphics/chromium/ImageFrameGenerator.cpp:
(WebCore::ImageFrameGenerator::ImageFrameGenerator):
(WebCore::ImageFrameGenerator::setData):
(WebCore::ImageFrameGenerator::tryToResumeDecodeAndScale):
Added logic to skip decoding if there's no new data.
(WebCore::ImageFrameGenerator::decode):
* platform/graphics/chromium/ImageFrameGenerator.h:
(ImageFrameGenerator):
* platform/graphics/chromium/ThreadSafeDataTransport.cpp: Added.
(WebCore):
(WebCore::ThreadSafeDataTransport::ThreadSafeDataTransport):
(WebCore::ThreadSafeDataTransport::~ThreadSafeDataTransport):
(WebCore::ThreadSafeDataTransport::setData):
(WebCore::ThreadSafeDataTransport::data):
(WebCore::ThreadSafeDataTransport::hasNewData):
* platform/graphics/chromium/ThreadSafeDataTransport.h: Added.
(WebCore):
(ThreadSafeDataTransport):

Source/WebKit/chromium:

Added unit tests for ThreadSafeDataTransport.

Added unit tests for ImageFrameGenerator to test behavior with and without
new data.

New tests:
ThreadSafeDataTransportTest.hasNewData
ThreadSafeDataTransportTest.setData
ImageFrameGeneratorTest.cacheMissWithIncompleteDecodeNoNewData

* WebKit.gypi:
* tests/ThreadSafeDataTransportTest.cpp: Added.
(WebCore):
(WebCore::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137508 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.cpp
Source/WebCore/platform/graphics/chromium/ImageFrameGenerator.h
Source/WebCore/platform/graphics/chromium/ThreadSafeDataTransport.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/ThreadSafeDataTransport.h [new file with mode: 0644]
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gypi
Source/WebKit/chromium/tests/ImageFrameGeneratorTest.cpp
Source/WebKit/chromium/tests/ThreadSafeDataTransportTest.cpp [new file with mode: 0644]