| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkCommandLineFlags.h" | 8 #include "SkCommandLineFlags.h" |
| 9 #include "SkPicture.h" | 9 #include "SkPicture.h" |
| 10 #include "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 | 35 |
| 36 SkFILEStream inputStream(FLAGS_readFile[0]); | 36 SkFILEStream inputStream(FLAGS_readFile[0]); |
| 37 if (!inputStream.isValid()) { | 37 if (!inputStream.isValid()) { |
| 38 if (!FLAGS_quiet) { | 38 if (!FLAGS_quiet) { |
| 39 SkDebugf("Couldn't open file\n"); | 39 SkDebugf("Couldn't open file\n"); |
| 40 } | 40 } |
| 41 return kError; | 41 return kError; |
| 42 } | 42 } |
| 43 | 43 |
| 44 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream)); | 44 sk_sp<SkPicture> picture(SkPicture::MakeFromStream(&inputStream)); |
| 45 if (nullptr == picture.get()) { | 45 if (nullptr == picture) { |
| 46 if (!FLAGS_quiet) { | 46 if (!FLAGS_quiet) { |
| 47 SkDebugf("Could not read the SkPicture\n"); | 47 SkDebugf("Could not read the SkPicture\n"); |
| 48 } | 48 } |
| 49 return kError; | 49 return kError; |
| 50 } | 50 } |
| 51 | 51 |
| 52 // The SkPicture tracking information is only generated during recording | 52 // The SkPicture tracking information is only generated during recording |
| 53 // an isn't serialized. Replay the picture to regenerated the tracking data. | 53 // an isn't serialized. Replay the picture to regenerated the tracking data. |
| 54 SkPictureRecorder recorder; | 54 SkPictureRecorder recorder; |
| 55 picture->playback(recorder.beginRecording(picture->cullRect().width(), | 55 picture->playback(recorder.beginRecording(picture->cullRect().width(), |
| 56 picture->cullRect().height(), | 56 picture->cullRect().height(), |
| 57 nullptr, 0)); | 57 nullptr, 0)); |
| 58 SkAutoTUnref<SkPicture> recorded(recorder.endRecording()); | 58 sk_sp<SkPicture> recorded(recorder.finishRecordingAsPicture()); |
| 59 | 59 |
| 60 if (recorded->suitableForGpuRasterization(nullptr)) { | 60 if (recorded->suitableForGpuRasterization(nullptr)) { |
| 61 SkDebugf("suitable\n"); | 61 SkDebugf("suitable\n"); |
| 62 } else { | 62 } else { |
| 63 SkDebugf("unsuitable\n"); | 63 SkDebugf("unsuitable\n"); |
| 64 } | 64 } |
| 65 | 65 |
| 66 return kSuccess; | 66 return kSuccess; |
| 67 #else | 67 #else |
| 68 SkDebugf("gpuveto is only useful when GPU rendering is enabled\n"); | 68 SkDebugf("gpuveto is only useful when GPU rendering is enabled\n"); |
| 69 return kError; | 69 return kError; |
| 70 #endif | 70 #endif |
| 71 } | 71 } |
| 72 | 72 |
| 73 #if !defined SK_BUILD_FOR_IOS | 73 #if !defined SK_BUILD_FOR_IOS |
| 74 int main(int argc, char * const argv[]) { | 74 int main(int argc, char * const argv[]) { |
| 75 return tool_main(argc, (char**) argv); | 75 return tool_main(argc, (char**) argv); |
| 76 } | 76 } |
| 77 #endif | 77 #endif |
| OLD | NEW |