////////////////////////////////////////////////////////////////////////////////
-DeferredPipeController::DeferredPipeController(int numberOfReaders)
+ThreadSafePipeController::ThreadSafePipeController(int numberOfReaders)
: fAllocator(kMinBlockSize)
, fNumberOfReaders(numberOfReaders) {
fBlock = NULL;
fBytesWritten = 0;
}
-void* DeferredPipeController::requestBlock(size_t minRequest, size_t *actual) {
+void* ThreadSafePipeController::requestBlock(size_t minRequest, size_t *actual) {
if (fBlock) {
// Save the previous block for later
PipeBlock previousBloc(fBlock, fBytesWritten);
return fBlock;
}
-void DeferredPipeController::notifyWritten(size_t bytes) {
+void ThreadSafePipeController::notifyWritten(size_t bytes) {
fBytesWritten += bytes;
}
-void DeferredPipeController::playback(SkCanvas* target) {
+void ThreadSafePipeController::playback(SkCanvas* target) {
SkGPipeReader reader(target);
for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++ ) {
reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock].fBytes);
/**
* Borrowed (and modified) from SkDeferredCanvas.cpp::DeferredPipeController.
- * Allows playing back from multiple threads.
+ * Allows playing back from multiple threads, but does not do the threading itself.
*/
-class DeferredPipeController : public SkGPipeController {
+class ThreadSafePipeController : public SkGPipeController {
public:
- DeferredPipeController(int numberOfReaders);
+ ThreadSafePipeController(int numberOfReaders);
virtual void* requestBlock(size_t minRequest, size_t* actual) SK_OVERRIDE;
virtual void notifyWritten(size_t bytes) SK_OVERRIDE;
virtual int numberOfReaders() const SK_OVERRIDE { return fNumberOfReaders; }
// Draw using Pipe
struct TileData {
- TileData(SkCanvas* canvas, DeferredPipeController* controller);
+ TileData(SkCanvas* canvas, ThreadSafePipeController* controller);
SkCanvas* fCanvas;
- DeferredPipeController* fController;
+ ThreadSafePipeController* fController;
SkThread fThread;
};
tileData->fController->playback(tileData->fCanvas);
}
-TileData::TileData(SkCanvas* canvas, DeferredPipeController* controller)
+TileData::TileData(SkCanvas* canvas, ThreadSafePipeController* controller)
: fCanvas(canvas)
, fController(controller)
, fThread(&DrawTile, static_cast<void*>(this)) {}
if (fUsePipe) {
// First, draw into a pipe controller
SkGPipeWriter writer;
- DeferredPipeController controller(fTiles.count());
+ ThreadSafePipeController controller(fTiles.count());
SkCanvas* pipeCanvas = writer.startRecording(&controller,
SkGPipeWriter::kSimultaneousReaders_Flag);
pipeCanvas->drawPicture(*(fPicture));