| * Copyright 2011 Google Inc. |
| * Use of this source code is governed by a BSD-style license that can be |
| * found in the LICENSE file. |
| #include "SkNetPipeController.h" |
| SkNetPipeController::SkNetPipeController(SkCanvas* target) : fReader(target) { |
| fBlockSize = fBytesWritten = 0; |
| fStatus = SkGPipeReader::kDone_Status; |
| SkNetPipeController::~SkNetPipeController() { |
| int SkNetPipeController::writeToSocket(SkSocket* sockfd, SkSocket::DataType type) { |
| if (NULL != sockfd && fTotalWritten > 4) |
| return sockfd->writePacket(fBlock, fBytesWritten, type); |
| void* SkNetPipeController::requestBlock(size_t minRequest, size_t* actual) { |
| fBlockSize = minRequest * 4; |
| fBlock = sk_malloc_throw(fBlockSize); |
| void SkNetPipeController::notifyWritten(size_t bytes) { |
| SkASSERT(fBytesWritten + bytes <= fBlockSize); |
| fStatus = fReader.playback((const char*)fBlock + fBytesWritten, bytes); |
| SkASSERT(SkGPipeReader::kError_Status != fStatus); |