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 "SkCanvas.h" | 11 #include "SkCanvas.h" |
11 #include "SkDevice.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 |
(...skipping 26 matching lines...) Expand all Loading... |
48 int32_t bottom; | 48 int32_t bottom; |
49 int32_t height = bitmap.height() / NumberOfTiles; | 49 int32_t height = bitmap.height() / NumberOfTiles; |
50 SkIRect rect; | 50 SkIRect rect; |
51 for (int i = 0; i < NumberOfTiles; i++) { | 51 for (int i = 0; i < NumberOfTiles; i++) { |
52 bottom = i + 1 == NumberOfTiles ? bitmap.height() : top + height; | 52 bottom = i + 1 == NumberOfTiles ? bitmap.height() : top + height; |
53 rect.setLTRB(0, top, bitmap.width(), bottom); | 53 rect.setLTRB(0, top, bitmap.width(), bottom); |
54 top = bottom; | 54 top = bottom; |
55 | 55 |
56 SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect); | 56 SkDEBUGCODE(bool extracted = )bitmap.extractSubset(&fBitmaps[i], rect); |
57 SkASSERT(extracted); | 57 SkASSERT(extracted); |
58 SkDevice* device = new SkDevice(fBitmaps[i]); | 58 SkBaseDevice* device = new SkBitmapDevice(fBitmaps[i]); |
59 SkCanvas* canvas = new SkCanvas(device); | 59 SkCanvas* canvas = new SkCanvas(device); |
60 device->unref(); | 60 device->unref(); |
61 if (initial != NULL) { | 61 if (initial != NULL) { |
62 canvas->setMatrix(*initial); | 62 canvas->setMatrix(*initial); |
63 } | 63 } |
64 canvas->translate(SkIntToScalar(-rect.left()), | 64 canvas->translate(SkIntToScalar(-rect.left()), |
65 SkIntToScalar(-rect.top())); | 65 SkIntToScalar(-rect.top())); |
66 if (0 == i) { | 66 if (0 == i) { |
67 fReader.setCanvas(canvas); | 67 fReader.setCanvas(canvas); |
68 } else { | 68 } else { |
(...skipping 40 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 |