| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkDumpCanvas.h" | 9 #include "SkDumpCanvas.h" |
| 10 #include "SkView.h" | 10 #include "SkView.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 SkBitmap bm; | 41 SkBitmap bm; |
| 42 if (SkImageDecoder::DecodeFile(path, &bm)) { | 42 if (SkImageDecoder::DecodeFile(path, &bm)) { |
| 43 bm.setImmutable(); | 43 bm.setImmutable(); |
| 44 pic = SkNEW(SkPicture); | 44 pic = SkNEW(SkPicture); |
| 45 SkCanvas* can = pic->beginRecording(bm.width(), bm.height()); | 45 SkCanvas* can = pic->beginRecording(bm.width(), bm.height()); |
| 46 can->drawBitmap(bm, 0, 0, NULL); | 46 can->drawBitmap(bm, 0, 0, NULL); |
| 47 pic->endRecording(); | 47 pic->endRecording(); |
| 48 } else { | 48 } else { |
| 49 SkFILEStream stream(path); | 49 SkFILEStream stream(path); |
| 50 if (stream.isValid()) { | 50 if (stream.isValid()) { |
| 51 pic = SkNEW_ARGS(SkPicture, (&stream, NULL, &SkImageDecoder::Dec
odeMemory)); | 51 pic = SkPicture::CreateFromStream(&stream); |
| 52 } | 52 } |
| 53 | 53 |
| 54 if (false) { // re-record | 54 if (false) { // re-record |
| 55 SkPicture p2; | 55 SkPicture p2; |
| 56 pic->draw(p2.beginRecording(pic->width(), pic->height())); | 56 pic->draw(p2.beginRecording(pic->width(), pic->height())); |
| 57 p2.endRecording(); | 57 p2.endRecording(); |
| 58 | 58 |
| 59 SkString path2(path); | 59 SkString path2(path); |
| 60 path2.append(".new.skp"); | 60 path2.append(".new.skp"); |
| 61 SkFILEWStream writer(path2.c_str()); | 61 SkFILEWStream writer(path2.c_str()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 SampleView* CreateSamplePictFileView(const char filename[]) { | 131 SampleView* CreateSamplePictFileView(const char filename[]) { |
| 132 return new PictFileView(filename); | 132 return new PictFileView(filename); |
| 133 } | 133 } |
| 134 | 134 |
| 135 ////////////////////////////////////////////////////////////////////////////// | 135 ////////////////////////////////////////////////////////////////////////////// |
| 136 | 136 |
| 137 #if 0 | 137 #if 0 |
| 138 static SkView* MyFactory() { return new PictFileView; } | 138 static SkView* MyFactory() { return new PictFileView; } |
| 139 static SkViewRegister reg(MyFactory); | 139 static SkViewRegister reg(MyFactory); |
| 140 #endif | 140 #endif |
| OLD | NEW |