2014-05-14 17:55:32 +00:00
|
|
|
#include "DMRecordTask.h"
|
|
|
|
#include "DMSKPTask.h"
|
|
|
|
#include "DMUtil.h"
|
|
|
|
#include "DMWriteTask.h"
|
|
|
|
|
|
|
|
namespace DM {
|
|
|
|
|
2014-05-14 20:26:00 +00:00
|
|
|
// 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)) {}
|
2014-05-14 17:55:32 +00:00
|
|
|
|
|
|
|
void SKPTask::draw() {
|
|
|
|
SkBitmap bitmap;
|
2014-05-15 17:33:31 +00:00
|
|
|
AllocatePixels(kN32_SkColorType, fPicture->width(), fPicture->height(), &bitmap);
|
2014-05-14 17:55:32 +00:00
|
|
|
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)));
|
2014-05-14 20:26:00 +00:00
|
|
|
this->spawnChild(SkNEW_ARGS(WriteTask, (*this, bitmap)));
|
2014-05-14 17:55:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace DM
|