skia2/dm/DMSKPTask.cpp
commit-bot@chromium.org d6dcacd4fe DM: tweaks
- translate filenames to task names instead of using a verbatim mode in WriteTask
  - add an option to write out only PNG data to the .png if you don't need -r to work

BUG=skia:
R=reed@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/288823002

git-svn-id: http://skia.googlecode.com/svn/trunk@14742 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-05-14 20:26:00 +00:00

33 lines
1.0 KiB
C++

#include "DMRecordTask.h"
#include "DMSKPTask.h"
#include "DMUtil.h"
#include "DMWriteTask.h"
namespace DM {
// foo_bar.skp -> foo-bar_skp
static SkString filename_to_task_name(SkString filename) {
for (size_t i = 0; i < filename.size(); i++) {
if ('_' == filename[i]) { filename[i] = '-'; }
if ('.' == filename[i]) { filename[i] = '_'; }
}
return filename;
}
SKPTask::SKPTask(Reporter* r, TaskRunner* tr, SkPicture* pic, SkString filename)
: CpuTask(r, tr), fPicture(SkRef(pic)), fName(filename_to_task_name(filename)) {}
void SKPTask::draw() {
SkBitmap bitmap;
SetupBitmap(kN32_SkColorType, *fPicture, &bitmap);
DrawPicture(fPicture, &bitmap);
this->spawnChild(SkNEW_ARGS(RecordTask,
(*this, fPicture, bitmap, RecordTask::kNoOptimize_Mode)));
this->spawnChild(SkNEW_ARGS(RecordTask,
(*this, fPicture, bitmap, RecordTask::kOptimize_Mode)));
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
}
} // namespace DM