OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SamplePipeControllers.h" | 8 #include "SamplePipeControllers.h" |
9 | 9 |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkGPipe.h" | 12 #include "SkGPipe.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 | 14 |
15 PipeController::PipeController(SkCanvas* target, SkPicture::InstallPixelRefProc
proc) | 15 PipeController::PipeController(SkCanvas* target, SkPicture::InstallPixelRefProc
proc) |
16 :fReader(target) { | 16 :fReader(target) { |
17 fBlock = NULL; | 17 fBlock = NULL; |
18 fBlockSize = fBytesWritten = 0; | 18 fBlockSize = fBytesWritten = 0; |
19 fReader.setBitmapDecoder(proc); | 19 fReader.setBitmapDecoder(proc); |
20 } | 20 } |
21 | 21 |
22 PipeController::~PipeController() { | 22 PipeController::~PipeController() { |
23 sk_free(fBlock); | 23 sk_free(fBlock); |
24 } | 24 } |
25 | 25 |
26 void* PipeController::requestBlock(size_t minRequest, size_t *actual) { | 26 void* PipeController::requestBlock(size_t minRequest, size_t *actual) { |
27 sk_free(fBlock); | 27 sk_free(fBlock); |
28 fBlockSize = minRequest * 4; | 28 fBlockSize = minRequest; |
29 fBlock = sk_malloc_throw(fBlockSize); | 29 fBlock = sk_malloc_throw(fBlockSize); |
30 fBytesWritten = 0; | 30 fBytesWritten = 0; |
31 *actual = fBlockSize; | 31 *actual = fBlockSize; |
32 return fBlock; | 32 return fBlock; |
33 } | 33 } |
34 | 34 |
35 void PipeController::notifyWritten(size_t bytes) { | 35 void PipeController::notifyWritten(size_t bytes) { |
36 fStatus = fReader.playback(this->getData(), bytes); | 36 fStatus = fReader.playback(this->getData(), bytes); |
37 SkASSERT(SkGPipeReader::kError_Status != fStatus); | 37 SkASSERT(SkGPipeReader::kError_Status != fStatus); |
38 fBytesWritten += bytes; | 38 fBytesWritten += bytes; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 void ThreadSafePipeController::draw(SkCanvas* target) { | 109 void ThreadSafePipeController::draw(SkCanvas* target) { |
110 SkGPipeReader reader(target); | 110 SkGPipeReader reader(target); |
111 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++
) { | 111 for (int currentBlock = 0; currentBlock < fBlockList.count(); currentBlock++
) { |
112 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock
].fBytes); | 112 reader.playback(fBlockList[currentBlock].fBlock, fBlockList[currentBlock
].fBytes); |
113 } | 113 } |
114 | 114 |
115 if (fBlock) { | 115 if (fBlock) { |
116 reader.playback(fBlock, fBytesWritten); | 116 reader.playback(fBlock, fBytesWritten); |
117 } | 117 } |
118 } | 118 } |
OLD | NEW |