blob: 04c4184846e00fe1e84c5bb93c190c92a57785b5 [file] [log] [blame]
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +00001#include "DMRecordTask.h"
2#include "DMSKPTask.h"
3#include "DMUtil.h"
4#include "DMWriteTask.h"
5
6namespace DM {
7
commit-bot@chromium.orgd6dcacd2014-05-14 20:26:00 +00008// foo_bar.skp -> foo-bar_skp
9static SkString filename_to_task_name(SkString filename) {
10 for (size_t i = 0; i < filename.size(); i++) {
11 if ('_' == filename[i]) { filename[i] = '-'; }
12 if ('.' == filename[i]) { filename[i] = '_'; }
13 }
14 return filename;
15}
16
17SKPTask::SKPTask(Reporter* r, TaskRunner* tr, SkPicture* pic, SkString filename)
18 : CpuTask(r, tr), fPicture(SkRef(pic)), fName(filename_to_task_name(filename)) {}
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000019
20void SKPTask::draw() {
21 SkBitmap bitmap;
commit-bot@chromium.org26642072014-05-15 17:33:31 +000022 AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000023 DrawPicture(fPicture, &bitmap);
24
25 this->spawnChild(SkNEW_ARGS(RecordTask,
26 (*this, fPicture, bitmap, RecordTask::kNoOptimize_Mode)));
27 this->spawnChild(SkNEW_ARGS(RecordTask,
28 (*this, fPicture, bitmap, RecordTask::kOptimize_Mode)));
commit-bot@chromium.orgd6dcacd2014-05-14 20:26:00 +000029 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000030}
31
32} // namespace DM