aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pipe/utils/SamplePipeControllers.cpp
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-31 16:15:22 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-31 16:15:22 +0000
commit58b4ead36c62d8c0256ee4da554f3df2744d904c (patch)
treef06d09d531ee6b37df515ab83734111aad8cb5b0 /src/pipe/utils/SamplePipeControllers.cpp
parentb1d47e211c95779ed283b78a85abbd0bd5668871 (diff)
Perform multi core rendering in bench_pictures.
Add a flag in SkGPipeWriter for threadsafe drawing. Add a deferred pipe controller to SamplePipeControllers, which can be called to play back in multiple threads. Depends on http://codereview.appspot.com/6459105/ Review URL: https://codereview.appspot.com/6482068 git-svn-id: http://skia.googlecode.com/svn/trunk@5371 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pipe/utils/SamplePipeControllers.cpp')
-rw-r--r--src/pipe/utils/SamplePipeControllers.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/pipe/utils/SamplePipeControllers.cpp b/src/pipe/utils/SamplePipeControllers.cpp
index 740d1b835f..c54bd1334a 100644
--- a/src/pipe/utils/SamplePipeControllers.cpp
+++ b/src/pipe/utils/SamplePipeControllers.cpp
@@ -76,3 +76,40 @@ void TiledPipeController::notifyWritten(size_t bytes) {
}
this->INHERITED::notifyWritten(bytes);
}
+
+////////////////////////////////////////////////////////////////////////////////
+
+DeferredPipeController::DeferredPipeController(int numberOfReaders)
+: fAllocator(kMinBlockSize)
+, fNumberOfReaders(numberOfReaders) {
+ fBlock = NULL;
+ fBytesWritten = 0;
+}
+
+void* DeferredPipeController::requestBlock(size_t minRequest, size_t *actual) {
+ if (fBlock) {
+ // Save the previous block for later
+ PipeBlock previousBloc(fBlock, fBytesWritten);
+ fBlockList.push(previousBloc);
+ }
+ int32_t blockSize = SkMax32(minRequest, kMinBlockSize);
+ fBlock = fAllocator.allocThrow(blockSize);
+ fBytesWritten = 0;
+ *actual = blockSize;
+ return fBlock;
+}
+
+void DeferredPipeController::notifyWritten(size_t bytes) {
+ fBytesWritten += bytes;
+}
+
+void DeferredPipeController::playback(SkCanvas* target) {
+ SkGPipeReader reader(target);
+ for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) {
+ reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock].fBytes);
+ }
+
+ if (fBlock) {
+ reader.playback(fBlock, fBytesWritten);
+ }
+}