diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp index b740877cce..ac66dc50d6 100644 --- a/tools/bench_pictures_main.cpp +++ b/tools/bench_pictures_main.cpp @@ -197,6 +197,14 @@ static bool run_single_benchmark(const SkString& inputPath, return false; } + if (FLAGS_preprocess) { + // Because the GPU preprocessing step relies on the in-memory picture + // statistics we need to rerecord the picture here + SkPictureRecorder recorder; + picture->draw(recorder.beginRecording(picture->width(), picture->height(), NULL, 0)); + picture.reset(recorder.endRecording()); + } + SkString filename = SkOSPath::Basename(inputPath.c_str()); gWriter.bench(filename.c_str(), picture->width(), picture->height()); diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index e2f772908f..23d973f901 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -172,13 +172,21 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w SkDebugf("deserializing... %s\n", inputPath.c_str()); - SkPicture* picture = SkPicture::CreateFromStream(&inputStream, proc); + SkAutoTUnref picture(SkPicture::CreateFromStream(&inputStream, proc)); if (NULL == picture) { SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str()); return false; } + if (FLAGS_preprocess) { + // Because the GPU preprocessing step relies on the in-memory picture + // statistics we need to rerecord the picture here + SkPictureRecorder recorder; + picture->draw(recorder.beginRecording(picture->width(), picture->height(), NULL, 0)); + picture.reset(recorder.endRecording()); + } + while (FLAGS_bench_record) { SkPictureRecorder recorder; picture->draw(recorder.beginRecording(picture->width(), picture->height(), NULL, 0)); @@ -207,7 +215,6 @@ static bool render_picture_internal(const SkString& inputPath, const SkString* w renderer.end(); - SkDELETE(picture); return success; }