blob: d633594ffc594e892f2d76dd53676ef5061078a5 [file] [log] [blame]
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +00001#include "DMSKPTask.h"
2#include "DMUtil.h"
3#include "DMWriteTask.h"
4
mtklein73734562014-06-24 12:28:34 -07005#include "SkCommandLineFlags.h"
6#include "SkPictureRecorder.h"
7
mtklein72ebb9f2014-08-07 14:27:03 -07008DEFINE_int32(skpMaxWidth, 1000, "Max SKPTask viewport width.");
9DEFINE_int32(skpMaxHeight, 1000, "Max SKPTask viewport height.");
mtklein73734562014-06-24 12:28:34 -070010
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000011namespace DM {
12
mtklein23c94f02014-09-08 09:12:28 -070013SKPTask::SKPTask(Reporter* r,
14 TaskRunner* tr,
mtklein23c94f02014-09-08 09:12:28 -070015 const SkPicture* pic,
16 SkString filename)
17 : CpuTask(r, tr)
18 , fPicture(SkRef(pic))
mtklein23c94f02014-09-08 09:12:28 -070019 , fName(FileToTaskName(filename)) {}
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000020
21void SKPTask::draw() {
robertphillipsa8d7f0b2014-08-29 08:03:56 -070022 const int width = SkTMin(SkScalarCeilToInt(fPicture->cullRect().width()), FLAGS_skpMaxWidth),
23 height = SkTMin(SkScalarCeilToInt(fPicture->cullRect().height()), FLAGS_skpMaxHeight);
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000024 SkBitmap bitmap;
mtklein72ebb9f2014-08-07 14:27:03 -070025 AllocatePixels(kN32_SkColorType, width, height, &bitmap);
mtklein73734562014-06-24 12:28:34 -070026 DrawPicture(*fPicture, &bitmap);
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000027
mtkleinea65bfa2014-09-09 07:59:46 -070028 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "SKP", bitmap)));
commit-bot@chromium.org90b5a2a2014-05-14 17:55:32 +000029}
30
31} // namespace DM