OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SampleApp.h" | 7 #include "SampleApp.h" |
8 | 8 |
9 #include "SkData.h" | 9 #include "SkData.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkGraphics.h" | 12 #include "SkGraphics.h" |
| 13 #include "SkImageDecoder.h" |
13 #include "SkImageEncoder.h" | 14 #include "SkImageEncoder.h" |
14 #include "SkPaint.h" | 15 #include "SkPaint.h" |
15 #include "SkPicture.h" | 16 #include "SkPicture.h" |
16 #include "SkStream.h" | 17 #include "SkStream.h" |
17 #include "SkTime.h" | 18 #include "SkTime.h" |
18 #include "SkWindow.h" | 19 #include "SkWindow.h" |
19 | 20 |
20 #include "SampleCode.h" | 21 #include "SampleCode.h" |
21 #include "SkTypeface.h" | 22 #include "SkTypeface.h" |
22 | 23 |
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 | 2197 |
2197 size_t fTotalWritten; | 2198 size_t fTotalWritten; |
2198 }; | 2199 }; |
2199 | 2200 |
2200 SimplePC::SimplePC(SkCanvas* target) : fReader(target) { | 2201 SimplePC::SimplePC(SkCanvas* target) : fReader(target) { |
2201 fBlock = NULL; | 2202 fBlock = NULL; |
2202 fBlockSize = fBytesWritten = 0; | 2203 fBlockSize = fBytesWritten = 0; |
2203 fStatus = SkGPipeReader::kDone_Status; | 2204 fStatus = SkGPipeReader::kDone_Status; |
2204 fTotalWritten = 0; | 2205 fTotalWritten = 0; |
2205 fAtomsWritten = 0; | 2206 fAtomsWritten = 0; |
| 2207 fReader.setBitmapDecoder(&SkImageDecoder::DecodeMemory); |
2206 } | 2208 } |
2207 | 2209 |
2208 SimplePC::~SimplePC() { | 2210 SimplePC::~SimplePC() { |
2209 // SkASSERT(SkGPipeReader::kDone_Status == fStatus); | 2211 // SkASSERT(SkGPipeReader::kDone_Status == fStatus); |
2210 if (fTotalWritten) { | 2212 if (fTotalWritten) { |
2211 SkDebugf("--- %d bytes %d atoms, status %d\n", fTotalWritten, | 2213 SkDebugf("--- %d bytes %d atoms, status %d\n", fTotalWritten, |
2212 fAtomsWritten, fStatus); | 2214 fAtomsWritten, fStatus); |
2213 #ifdef PIPE_FILE | 2215 #ifdef PIPE_FILE |
2214 //File is open in append mode | 2216 //File is open in append mode |
2215 FILE* f = fopen(FILE_PATH, "ab"); | 2217 FILE* f = fopen(FILE_PATH, "ab"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2247 fAtomsWritten += 1; | 2249 fAtomsWritten += 1; |
2248 } | 2250 } |
2249 | 2251 |
2250 void SampleView::draw(SkCanvas* canvas) { | 2252 void SampleView::draw(SkCanvas* canvas) { |
2251 if (SkOSMenu::kOffState == fPipeState) { | 2253 if (SkOSMenu::kOffState == fPipeState) { |
2252 this->INHERITED::draw(canvas); | 2254 this->INHERITED::draw(canvas); |
2253 } else { | 2255 } else { |
2254 SkGPipeWriter writer; | 2256 SkGPipeWriter writer; |
2255 SimplePC controller(canvas); | 2257 SimplePC controller(canvas); |
2256 TiledPipeController tc(canvas->getDevice()->accessBitmap(false), | 2258 TiledPipeController tc(canvas->getDevice()->accessBitmap(false), |
| 2259 &SkImageDecoder::DecodeMemory, |
2257 &canvas->getTotalMatrix()); | 2260 &canvas->getTotalMatrix()); |
2258 SkGPipeController* pc; | 2261 SkGPipeController* pc; |
2259 if (SkOSMenu::kMixedState == fPipeState) { | 2262 if (SkOSMenu::kMixedState == fPipeState) { |
2260 pc = &tc; | 2263 pc = &tc; |
2261 } else { | 2264 } else { |
2262 pc = &controller; | 2265 pc = &controller; |
2263 } | 2266 } |
2264 uint32_t flags = SkGPipeWriter::kCrossProcess_Flag; | 2267 uint32_t flags = SkGPipeWriter::kCrossProcess_Flag; |
2265 | 2268 |
2266 canvas = writer.startRecording(pc, flags); | 2269 canvas = writer.startRecording(pc, flags); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2452 SkGraphics::Init(); | 2455 SkGraphics::Init(); |
2453 SkEvent::Init(); | 2456 SkEvent::Init(); |
2454 } | 2457 } |
2455 | 2458 |
2456 // FIXME: this should be in a header | 2459 // FIXME: this should be in a header |
2457 void application_term(); | 2460 void application_term(); |
2458 void application_term() { | 2461 void application_term() { |
2459 SkEvent::Term(); | 2462 SkEvent::Term(); |
2460 SkGraphics::Term(); | 2463 SkGraphics::Term(); |
2461 } | 2464 } |
OLD | NEW |