2014-05-14 17:55:32 +00:00
|
|
|
#include "DMSKPTask.h"
|
|
|
|
#include "DMUtil.h"
|
|
|
|
#include "DMWriteTask.h"
|
|
|
|
|
2014-06-24 19:28:34 +00:00
|
|
|
#include "SkCommandLineFlags.h"
|
|
|
|
#include "SkPictureRecorder.h"
|
|
|
|
|
2014-08-07 21:27:03 +00:00
|
|
|
DEFINE_int32(skpMaxWidth, 1000, "Max SKPTask viewport width.");
|
|
|
|
DEFINE_int32(skpMaxHeight, 1000, "Max SKPTask viewport height.");
|
2014-06-24 19:28:34 +00:00
|
|
|
|
2014-05-14 17:55:32 +00:00
|
|
|
namespace DM {
|
|
|
|
|
2014-09-08 16:12:28 +00:00
|
|
|
SKPTask::SKPTask(Reporter* r,
|
|
|
|
TaskRunner* tr,
|
|
|
|
const SkPicture* pic,
|
|
|
|
SkString filename)
|
|
|
|
: CpuTask(r, tr)
|
|
|
|
, fPicture(SkRef(pic))
|
|
|
|
, fName(FileToTaskName(filename)) {}
|
2014-05-14 17:55:32 +00:00
|
|
|
|
|
|
|
void SKPTask::draw() {
|
2014-08-29 15:03:56 +00:00
|
|
|
const int width = SkTMin(SkScalarCeilToInt(fPicture->cullRect().width()), FLAGS_skpMaxWidth),
|
|
|
|
height = SkTMin(SkScalarCeilToInt(fPicture->cullRect().height()), FLAGS_skpMaxHeight);
|
2014-05-14 17:55:32 +00:00
|
|
|
SkBitmap bitmap;
|
2014-08-07 21:27:03 +00:00
|
|
|
AllocatePixels(kN32_SkColorType, width, height, &bitmap);
|
2014-06-24 19:28:34 +00:00
|
|
|
DrawPicture(*fPicture, &bitmap);
|
2014-05-14 17:55:32 +00:00
|
|
|
|
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
|