commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame] | 1 | #include "DMSKPTask.h" |
| 2 | #include "DMUtil.h" |
| 3 | #include "DMWriteTask.h" |
| 4 | |
mtklein | 7373456 | 2014-06-24 12:28:34 -0700 | [diff] [blame] | 5 | #include "SkCommandLineFlags.h" |
| 6 | #include "SkPictureRecorder.h" |
| 7 | |
mtklein | 72ebb9f | 2014-08-07 14:27:03 -0700 | [diff] [blame] | 8 | DEFINE_int32(skpMaxWidth, 1000, "Max SKPTask viewport width."); |
| 9 | DEFINE_int32(skpMaxHeight, 1000, "Max SKPTask viewport height."); |
mtklein | 7373456 | 2014-06-24 12:28:34 -0700 | [diff] [blame] | 10 | |
commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame] | 11 | namespace DM { |
| 12 | |
mtklein | 23c94f0 | 2014-09-08 09:12:28 -0700 | [diff] [blame] | 13 | SKPTask::SKPTask(Reporter* r, |
| 14 | TaskRunner* tr, |
mtklein | 23c94f0 | 2014-09-08 09:12:28 -0700 | [diff] [blame] | 15 | const SkPicture* pic, |
| 16 | SkString filename) |
| 17 | : CpuTask(r, tr) |
| 18 | , fPicture(SkRef(pic)) |
mtklein | 23c94f0 | 2014-09-08 09:12:28 -0700 | [diff] [blame] | 19 | , fName(FileToTaskName(filename)) {} |
commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame] | 20 | |
| 21 | void SKPTask::draw() { |
robertphillips | a8d7f0b | 2014-08-29 08:03:56 -0700 | [diff] [blame] | 22 | const int width = SkTMin(SkScalarCeilToInt(fPicture->cullRect().width()), FLAGS_skpMaxWidth), |
| 23 | height = SkTMin(SkScalarCeilToInt(fPicture->cullRect().height()), FLAGS_skpMaxHeight); |
commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame] | 24 | SkBitmap bitmap; |
mtklein | 72ebb9f | 2014-08-07 14:27:03 -0700 | [diff] [blame] | 25 | AllocatePixels(kN32_SkColorType, width, height, &bitmap); |
mtklein | 7373456 | 2014-06-24 12:28:34 -0700 | [diff] [blame] | 26 | DrawPicture(*fPicture, &bitmap); |
commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame] | 27 | |
mtklein | ea65bfa | 2014-09-09 07:59:46 -0700 | [diff] [blame] | 28 | this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "SKP", bitmap))); |
commit-bot@chromium.org | 90b5a2a | 2014-05-14 17:55:32 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | } // namespace DM |